1 | Trezor-link-browser-extension
|
2 | ====
|
3 |
|
4 | Library for low-level communication with TREZOR for browser extensions.
|
5 |
|
6 | Intended as a "building block" for extension that talks with TREZOR.
|
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 |
|
10 | How to use
|
11 | -----
|
12 |
|
13 | Use like this:
|
14 |
|
15 | ```javascript
|
16 | var Link = require('trezor-link-browser-extension');
|
17 | var LowlevelTransport = Link.Lowlevel;
|
18 | var ChromeHidPlugin = Link.ChromeHid;
|
19 |
|
20 | var link = new LowlevelTransport(new ChromeHidPlugin());
|
21 |
|
22 | var 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 |
|
30 | return 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 |
|
49 | Notes
|
50 | ---
|
51 | Source is annotated with Flow types, so it's more obvious what is going on from source code.
|
52 |
|
53 | Flow
|
54 | ----
|
55 | 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.
|
56 |
|
57 | License
|
58 | ----
|
59 | LGPLv3
|
60 |
|
61 | * (C) 2015 Karel Bilek (SatoshiLabs) <kb@karelbilek.com>
|
62 | * (C) 2014 Mike Tsao <mike@sowbug.com>
|
63 | * (C) 2014 Liz Fong-Jones <lizf@google.com>
|
64 | * (C) 2015 William Wolf <throughnothing@gmail.com>
|
65 |
|