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

@dwebid/simple-identity-exchange-protocol

v1.0.0

Published

Protocol for giving write access of a dWeb-based identity document from one device to another.

Downloads

2

Readme

@dwebid/simple-identity-exchange-protocol

A protocol for exchanging diffKeys and a seed to an identity document (multi-writer dTree), between one device and another.

Install

npm install @dwebid/simple-identity-exchange-protocol

Usage On Device A

import SIEP from '@dwebid/simple-identity-exchange-protocol'

let seed = null
let remoteDiffKey = null

// true means Device A is the initiator
const a = new SIEP(true, {
  // make sure the connection with Device B is encrypted and that there is a NOISE handshake
  encrypted: true
  noise: true
  // listen for the handshake to finalize and react to it
  onhandshake() {
    a.open(1, { deviceId: keyHere })
  }
  // listen for a verify message and react to it.
  onverify (channel, message) {
     // retrieve type from message
    const verificationType = message.type
    if (verificationType === "device-verification") {
      // send the secret shown on the screen of Device B
      a.prove(channel, { secret: 777777 })
    }
  }
  // listen for a releaseseed message and react to it.
  onreleaseseed (channel, message) {
    // Extract seed from message sent by Device B
    seed = message.seed
  }
  // listen for a wantkey message and react to it.
  onwantkey (channel, message) {
    // save Device A's dTree diffKey into a constant
    const dMessengerDbDiffKey = db.diffKey
    // provide the key that Device B asked for in their `wantkey` message
    a.provideKey(channel, {
      identifier: "dmessenger",
      diffKey: dMessengerDbDiffKey
    })    
  }
  // listen for a providekey message and react to it
  onprovidekey (channel, message) {
    // Extract the diffKey from the message sent by Device B
    remoteDiffKey = message.diffKey
  }
})

Usage On Device B

import SIEP from '@dwebid/simple-identity-exchange-protocol'

let seed = null
let remoteDiffKey = nulll
let verified = false

// false means Device B is the receiver
const b = new SIEP(false, {
   // make sure the connection to Device A is encrypted
  encrypted: true
   // listen for an open message and react to it
  onopen (channel, message) {
    console.log(`Connection opened with deviceID ${message.deviceId} on channel # ${channel}`)
    // when Device A opens the connection, we send a verify message immediately back to device A, letting it
    // know which type of verification is required.
    b.verify(channel, { type: 'device-verification' })
  }
  // listen for a "prove" message and react to it
  onproof (channel, message) {
    const secretCode = 777777
    // ensure that the secret code sent in the prove message, is the secretCode Device B is expecting.
    if (message.secret ==== secretCode) {
      verified = true
      seed = secretEncryptionSeedHere
      // since Device A verified the secret, we can now release the seed
      b.releaseseed(channel, { seed: seed })
     // while we're at it, lets ask Device B for their diffKey for the database related to "dmessenger"
      b.wantkey(channel, { identifier: 'dmessenger' })
    } else {
      b.destroy()
    }
  }
  // listen for a providekey message and react to it
  onprovidekey (channel, message) {
    remoteDiffKey = message.diffKey
  }
  // listen for a wantkey message and react to it
  onwantkey (channel, message) {
    if (verified) {
      b.providekey(channel, { identifier: 'dmessenger', diffKey: db.diffKey })
    }
  }
})

API Documentation

Coming soon

LICENSE

MIT