Javascript module for integrating TREZOR into Node.js and web applications. https://github.com/trezor/trezor-link
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Tomas Zorvan e9ec09239a 1.6.6 1 week ago
flowtype Add new flow shims 1 year ago
src Remove device.reset() from WebUSB plugin (#22) 1 week ago
.eslintrc Eslint 3 years ago
.flowconfig Use new Flow 1 year ago
.gitignore Simplifying build 1 year ago
.gitmodules Coding 3 years ago
.npmignore Update .npmignore 3 months ago
.travis.yml Update .travis.yml 3 months ago
COPYING rename LICENSE to COPYING 2 years ago
Makefile Remove old Flow workaround 1 year ago
README.md Starting to clean up, remove extension+node lowlevel 1 year ago
babel.config.js update configs 3 months ago
package.json 1.6.6 1 week ago
yarn.lock update outdated packages (babel, eslint, fetch) 3 months ago

README.md

trezor-link

Build Status gitter

Library for low-level communication with TREZOR.

Intended as a “building block” for other packages - it is used in trezor.js and chrome extension.

You probably don’t want to use this package directly. For communication with Trezor with a more high-level API, use trezor.js.

How to use

Use like this:

var Link = require('trezor-link');
var LowlevelTransport = Link.Lowlevel;
var NodeHidPlugin = Link.NodeHid;

var link = new LowlevelTransport(new NodeHidPlugin());

var config = fetch('https://wallet.mytrezor.com/data/config_signed.bin').then(function (response) {
  if (response.ok) {
    return response.text();
  } else {
    throw new Error(`Fetch error ${response.status}`);
  }
});

return link.init().then(function () { 
  return config.then(function (configData) {
    return link.configure(configData);
  });
}).then(function () {
  return link.enumerate();
}).then(function (devices) {
  return link.acquire(devices[0].path);
}).then(function (session) {
  return link.call(session, 'GetFeatures', {}).then(function (features) {
    console.log(features);
    return link.release(session);
  });
}).catch(function (error) {
  console.error(error);
});

Notes

Source is annotated with Flow types, so it’s more obvious what is going on from source code.

Flow

If you want to use flow for typechecking, just include the file as normally, it will automatically use the included flow file. However, you need to add flowtype/*.js to your [libs] (or copy it yourself from flow-typed repository), and probably libs from flowconfig.

License

LGPLv3