Socket
Book a DemoInstallSign in
Socket

@hyperdivision/heimdall-pairing

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperdivision/heimdall-pairing

Pair a new user (initator) and an existing user (responder) in Heimdall

latest
Source
npmnpm
Version
6.0.7
Version published
Weekly downloads
30
1400%
Maintainers
2
Weekly downloads
 
Created
Source

heimdall-pairing

Pair a new user (initator) and an existing user (responder) in Heimdall

npm install @hyperdivision/heimdall-pairing

Usage

const { Initiator, Responder } = require('@hyperdivision/heimdall-pairing')

const i = new Initiator({
  keypair,
  profile
})

const r = new Responder({
  propose (key, profile, profileSignature, done) {
    // human validate the profile and propose it on the network
    // then reply back with the server key
    done(null, serverKey)
  })
})

// share the discovery key
r.setDiscoveryKey(i.discoveryKey)

r.on('pin', function (pin) {
  // communicate the security ping to i
  i.setPin(pin)
})

i.on('server-key', function (serverKey) {
  // and you are paired!
  // once the network approves you the server will
  // start replicating with you if you join the swarm using the above key
})

API

i.setProfile(profile)

Set the profile asynchrously in case you cannot pass one in the constructor

i.on('connected')

Emitted when it connects to the other peer before it is verified

i.on('verified')

Emitted when the other peer is verified (the pin matched)

i.on('server-key', serverKey)

Emitted when the pairing is done and the responder sends the server key

i.on('announcing')

Emitted when the initiator starts announcing on the network

i.on('error', err)

Emitted when there was an error in the pairing flow

i.discoveryKey

Share this discovery key with the responder (3 words)

i.setPin(pin)

Call this when the responder communicates the pin to you

i.destroy(err)

Call this to forcefully shutdown the pairing.

r.on('discovery-key', dk)

Emitted when the discovery key is set on the responder.

r.on('peer', peer)

Emitted when the responder founds a peer on the DHT that could be the initiator.

r.on('connecting', peer)

Emitted when the responder tries to connect to peer.

r.on('connected')

Emitted when the responder established connection with a potential initiator.

r.on('profile', key, profile, profileSignature)

Emitted when a profile is received from the initiator.

r.on('error', error)

Emitted when there was an error in the pairing flow.

r.on('server-key', serverKey)

Emitted when the responder sends the server key.

r.destroy(err)

Call this to forcefully shutdown the pairing.

bool = Responder.validateDiscoveryKey(dk)

Static helper to check if a discovery consists of valid words.

License

MIT

FAQs

Package last updated on 07 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts