1.0.3 • Published 6 years ago

trezor-session v1.0.3

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

NPM

Usage

TrezorSession = require('trezor-session') // or TrezorSession = require('.')

// trezorSession = TrezorSession( config = {out: console.out, trezor: {}, onConnect: device => {}} )
// See config's jsdocs in ./session.js

// Wait until your ready, this is going to start "Looking for the device"
trezorSession = TrezorSession()


console.log(trezorSession.isAvailable()) // true after connecting

// This can pause: "Looking for device.."
trezorSession((err, session) => {
  if(err) {
    console.error(err)
    return
  }
  // Trezor session: See https://github.com/trezor/trezor.js/blob/master/API.md

  // Currently all Trezor session methods return a Promise.  So you must return a
  // Promise here or an Error will be thrown. It is very confusing without this
  // error.  If there is a future case to skip the Promise return true.

  // Remember to return a Promise
  return session.getEntropy(16).then(entropy => {
    console.log('entropy', entropy)
    console.log('done')
  })
  .catch(error => {
    console.error(error)
  })

})

// process.on('exit', () => { trezorSession.close() })

Environment

Node 6+

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago