UNPKG

1.85 kBMarkdownView Raw
1Trezor-link
2====
3
4Library for low-level communication with TREZOR.
5
6Intended as a "building block" for other packages - it is used in trezor.js and chrome extension.
7
8*You probably don't want to use this package directly.* For communication with Trezor with a more high-level API, use [trezor.js](https://www.npmjs.com/package/trezor.js).
9
10How to use
11-----
12
13Use like this:
14
15```javascript
16var Link = require('trezor-link');
17var LowlevelTransport = Link.Lowlevel;
18var NodeHidPlugin = Link.NodeHid;
19
20var link = new LowlevelTransport(new NodeHidPlugin());
21
22var config = fetch('https://wallet.mytrezor.com/data/config_signed.bin').then(function (response) {
23 if (response.ok) {
24 return response.text();
25 } else {
26 throw new Error(`Fetch error ${response.status}`);
27 }
28});
29
30return link.init().then(function () {
31 return config.then(function (configData) {
32 return link.configure(configData);
33 });
34}).then(function () {
35 return link.enumerate();
36}).then(function (devices) {
37 return link.acquire(devices[0].path);
38}).then(function (session) {
39 return link.call(session, 'GetFeatures', {}).then(function (features) {
40 console.log(features);
41 return link.release(session);
42 });
43}).catch(function (error) {
44 console.error(error);
45});
46
47```
48
49Notes
50---
51Source is annotated with Flow types, so it's more obvious what is going on from source code.
52
53Flow
54----
55If 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.
56
57
58License
59----
60LGPLv3
61
62* (C) 2015 Karel Bilek (SatoshiLabs) <kb@karelbilek.com>
63* (C) 2014 Mike Tsao <mike@sowbug.com>
64* (C) 2014 Liz Fong-Jones <lizf@google.com>
65* (C) 2015 William Wolf <throughnothing@gmail.com>
66