开发者社区> 镜像站> NPM> @hyperdivision/pin-peer
@hyperdivision/pin-peer
Verify a secure connection using a manual PIN
Last updated 6 months ago by benlyn .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @hyperdivision/pin-peer 
SYNC missed versions from official npm registry.

pin-peer

Verify a secure connection using a manual PIN

Usage

const pin = require('pin-peer')

var outOfBandPin // this would normally be communicated somehow

const t = transport()
const i = pin.initiator(transportStreamA, function (verify) {
  return verify(null, outOfBandPin)
})

const r = pin.responder(transportStreamB)
r.once('pin', (pin) => {
  outOfBandPin = pin
})

// Hook up transportStreamA and transportStreamB

API

const initiatorStream = pin.initiator(rawStream, onverifypin(verify(err, enteredPin)), prolouge = '')

If the pin is incorrect the initiatorStream is closed immediately.

enteredPin must be a Base32 encoded string. prolouge can be an arbitrary string that was used to find the other peer. This doesn't add security to the encryption key, but does ensure both parties have the same view of how anything that happened prior to the noise handshake.

const bool = initiatorStream.secure

Boolean indicating whether the secure handshake has completed

initiatorStream.once('secure', function () {})

Emitted once the handshaking has completed

const responderStream = pin.responder(rawStream, prolouge = '')

If the initiator did not accept the pin the responderStream is closed immediately. prolouge can be an arbitrary string that was used to find the other peer. This doesn't add security to the encryption key, but does ensure both parties have the same view of how anything that happened prior to the noise handshake.

responderStream.once('pin', pinStr)

Emitted when the pin is ready

const pinStr = responderStream.pin

null until the pin is ready. Encoded as a Base32 string

Install

npm install pin-peer

License

ISC

Current Tags

  • 1.4.0                                ...           latest (6 months ago)

4 Versions

  • 1.4.0                                ...           6 months ago
  • 1.3.0                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.0.0                                ...           a year ago
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 4
Dependencies (4)
Dev Dependencies (3)
Dependents (0)
None