Coder Social home page Coder Social logo

trezor / trezor-link Goto Github PK

View Code? Open in Web Editor NEW
18.0 16.0 40.0 1.83 MB

Javascript module for integrating TREZOR into Node.js and web applications.

License: Other

JavaScript 42.63% Nix 0.44% Shell 3.54% TypeScript 53.39%
bitcoin trezor link javascript nodejs browser

trezor-link's Introduction

trezor-link's People

Contributors

alepop avatar dependabot[bot] avatar karelbilek avatar michal-novacek avatar mroz22 avatar prusnak avatar szymonlesisz avatar tomaszorvan avatar tsusanka avatar wbobeirne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trezor-link's Issues

src/lowlevel/node-hid.js: macOS & interface number

be1272d introduces a match over the interface number == 0. However, on macOS 10.12.1, at least, the interface number is set to -1 systematically, preventing the library from finding the TREZOR device.

{ vendorId: 21324,
    productId: 1,
    path: 'IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS01@14100000/TREZOR@14100000/U2F Interface@1/IOUSBHostHIDDevice@14100000,1',
    serialNumber: '4A10A0367FB8A8A1089F4AEA',
    manufacturer: 'SatoshiLabs',
    product: 'TREZOR',
    release: 256,
    interface: -1,
    usagePage: 61904,
    usage: 1 },

Help getting trezor working

@prusnak recommended I created an issue here for help integrating.

Basically I'm trying to write a node-js test app to test the integration into trezor-common and trezor-core, but I keep hitting a wall where I need some kind of config (config_signed.bin or messages JSON) in order to get any further. I will still need it to work for node-js later on, and would like to understand how it all works for the future.
I tried trezor-connect originally but i kept getting errors about navigator is not defined and window is not defined because I'm writing this in nodejs. The device I'm testing for is the Trezor Model T. I've made changes to both trezor-core and trezor-common which I'm trying to test before submitting them in a Pull Request.

Thanks in advance!

Request to Bridge v2 fails with 403

I'm trying to use trezor.js with Bridge v2 installed, but it won't find my device. After some digging, it looks like the request to 127.0.0.1:21325 fails with a 403 despite me being able to load it in the browser. It's coming back with a 403 code, so I think it may be CORS related. Am I doing something incorrectly, or is the way I'm going about integrating Trezor into a node application incorrect? Here's my code:

import { DeviceList } from 'trezor.js';
const deviceList = new DeviceList({ debug: false });
// ...
const { session } = await deviceList.acquireFirstDevice(true);

Expose error messages

We need to export error messages up, to avoid string comparison.
Example:

trezor-link will throw Error("device not found"); to catch it and react properly i need to compare error.message with local string "device not found".

Better solution is:

export const DEVICE_NOT_FOUND = new Error('device not found');

then:

import { DEVICE_NOT_FOUND } from 'trezor-link';

and then:

if (error === DEVICE_NOT_FOUND) { ... }

Unable to handle passphrase requests

Hello gang. I've got a little research project I'm playing with and I need help understanding the correct way to handle some passphrase requests that seem to be happening before I can subscribe to UI events. I have a webusb / no-popup app I'm working on where I do the following (in order):

resetDevice({passphrase_protection: true, useEmptyPassphrase: false});

then:

applySettings({label: 'Test Device'});

then:

changePin({remove: false});

I have some subscriptions to the UI events that respond automatically for me:

TrezorConnect.on(UI_EVENT, event => {
  if(event.type === UI.REQUEST_PASSPHRASE) {
    this.uiResponse({type: UI.RECEIVE_PASSPHRASE, payload: {value: 'test passphrase', save: true, passphraseOnDevice: false}});
  }

  this.publish(UI_EVENT, event);
});

My problem is that when I run applySettings() after having successfully resetDevice(), I see trezor-link activity where a passphrase request occurs and a response automatically happens but with an empty string as the payload: {passphrase: ""}. I believe this is causing later API calls (for example, calling ethereumGetAddress()) to fail with: Passphrase is incorrect.. Can anyone shed any light on this? What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.