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

@rsksmart/rif-id-daf

v0.1.0

Published

RIF Identity - DAF

Downloads

13

Readme

npm i @rsksmart/rif-id-daf

Extensions for uPort DAF agent.

Features

Support for RIF Identity key model

uPort DAF provides an Identity provider module that is responsible for the creation of keys and derivation of the respective identity. Each time an identity is created, a new private key is generated. RIF model proposes to use deterministic derivation for private keys, making all the identities associated with a single mnemonic phrase.

The model uses a wallet account like derivation for identity keys:

  1. Create a mnemonic phrase to derive identities from
  2. Use BIP32 to derive private keys using TBD derivation path

For a better developer experience the extension also provides BIP-44 support. Use mnemonic phrase instead of hex keys.

To use this interface we provide:

  1. New ORM Entity: IdentityMnemonic. Now used to store one single mnemonic.
  2. SeedStore class - interface to store a seed
  3. RIFIdKeyManagementSystem class - wrapper for a daf AbstractKeyManagementSystem - responsible for creating private keys derived from the mnemonic's seed.
  4. RIFIdentityProvider class - Extension for daf IdentityProvider enabling to import a mnemonic

All this modules can be plugged to uPort agent as explained in usage to provide uPort agent of this capabilities.

The identity recovery model is to be defined

Usage

To setup a DAF agent using RIF identity provider implementation:

import { Connection } from 'typeorm'
import { KeyStore, IdentityStore, Agent } from 'daf-core'
import { SecretBox, KeyManagementSystem } from 'daf-libsodium' // change for daf-react-native-libsodioum for React Native support
import { Entities, MnemonicStore, RIFIdKeyManagementSystem, RIFIdentityProvider } from '@rsksamrt/rid-id-daf'

const dbConnection = createConnection({
  type: 'sqlite',
  database: 'rif-identity.sqlite',
  entities: [...Entities, ...DAFEntities],
  logging: false,
  synchronize: true
})

// key store
const secretKey = '0f3c04d7416607ba306997f9fd1920474aff39beb23b847da5c21215076cc9b3' // set your own secret key
const secretBox = new SecretBox(secretKey)
const keyStore = new KeyStore(dbConnection, secretBox)
const mnemonicStore = new MnemonicStore(dbConnection, secretBox)

// key management system
const keyManagementSystem = new KeyManagementSystem(keyStore)
const rifIdKeyManagementSystem = new RIFIdKeyManagementSystem(keyManagementSystem, keyStore, mnemonicStore)

// rif identity provider
const identityStore = new IdentityStore('rsk-testnet-ethr', dbConnection)

const rifIdentityProvider = new RIFIdentityProvider({
    kms: rifIdKeyManagementSystem,
    identityStore,
    network: 'rsk',
    rpcUrl: 'http://localhost:8545'
})

const agent = new Agent({
    dbConnection,
    identityProviders: [rifIdentityProvider],
    didResolver: null
})

const mnemonic = generateMnemonic(12)

await rifIdentityProvider.importMnemonic(mnemonic)

const identity = await agent.identityManager.createIdentity()

Extend

  • Enable multiple mnemonics

Test

From base repo directory run npm test or any of the described test script variants.

References

  • uPort DAF: https://github.com/uport-project/daf