npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nillion-tools/key-manager

v0.0.4

Published

Key Manager is a tool to manage and authenticate Ed25519 keys. It provides a simple workflow to create, import, and export keys. It also provides a way to authenticate keys using WebAuthn (PRF) and FIDO2.

Downloads

2

Readme

Key Manager

Key Manager is a tool to manage and authenticate Ed25519 keys. It provides a simple workflow to create, import, and export keys. It also provides a way to authenticate keys using WebAuthn (PRF) and FIDO2.

Features

  • 🪝 Support for Mordern Frameworks such as Next.js, React, Vite, Svelte and more.
  • 🔐 Uses @simplewebauth internally which passes FIDO® Conformance Server Tests.
  • 🧩 Everything is authored in 100% TypeScript!
  • 🍳 Simple to use API Syntax so that you can focus on your main application.
  • 👏 Fully typed and tree-shakeable
  • ...and many more ✨

Structure

The Package is divided into the following parts:

  1. KeyChain: A KeyChain is a root class that manages keys. It provides a way to create, import, and export keys.
  2. Storage: A Storage class that provides a way to store keys securely. It provides implementations for local storage and browser storage(IndexedDB).
  3. WebAuthn: A WebAuthn based implementation that can encrypt and decrypt Private keys using PRF(Pseudo Random Function).
  4. React: A react wrapper for the KeyChain and WebAuthn classes.
  5. Types: Shared types used in the package.

Getting Started

To install Key Manager in your project, run the following command:

npm i @nillion-tools/key-manager
# or
yarn add @nillion-tools/key-manager
# or
pnpm add @nillion-tools/key-manager
# or
bun add @nillion-tools/key-manager

Storage

To Start using the key manager, you first need to define a data source. This can be of any type that follows the DataSource Interface. For Example, you can use the IndexedDB data source as shown below:

import { IndexedDBDataSource } from '@nillion-tools/key-manager/storage';
import type { KeyType } from '@nillion-tools/key-manager/types';

const keyChainDB = new IndexedDBDataSource<KeyType>('keychain');

Keychain

Two Initialize keychain you need two functions: encrypt and decrypt. These functions are used to encrypt and decrypt the data. You can use any encryption library of your choice. The function takes in the id and data in from of Uint8Array and returns encrypted or decrypted Uint8Array.

import { KeyChain } from '@nillion-tools/key-manager/keychain';

const encrypt = (id: string, data: Uint8Array, nonce: Uint8Array) => {
  // Your encryption logic
  // Nonce is used to prevent replay attacks
  return data;
};

const decrypt = (id: string, data: Uint8Array) => {
  // Your decryption logic
  return data;
};

const keyChain = new KeyChain(keyChainDB, encrypt, decrypt);

const key = await keyChain.createKey('username');
console.log(key);
{
  "id": "username",
  "userId": "z2i83AvZqBYe7NPR6rUdLMw1P8pW6J6dV7PSjWRLUZWW5SCDJm6KXTujZBtF1iJMxe7iLufkNQr5pSibz5kfiusTt",
  "encryptedUserKey": "z3dod5kUYH3KNhdhQzpC7BQDp3cAKA3MeN4kEQJf6qu63oxzoujnJHtEek3M2jgZ5Yf",
  "nonce": [178, 34, 89, 112, 98, 12, 67, 87, 3, 8, 33, 21]
}

Documentation

For a complete overview of available functions and usage examples, please refer to the official documentation: https://nillion-tools.envoy1084.xyz

Contributing

We welcome contributions! Check out our contributing guide for more information

Future Plans

We're actively working on expanding functionality. Stay tuned for:

  • Connect Kit

Let's build the future blind computation together!