Deprecated. Moved to trezor-suite repository.
trezor / trezor-link Goto Github PK
View Code? Open in Web Editor NEWJavascript module for integrating TREZOR into Node.js and web applications.
License: Other
Javascript module for integrating TREZOR into Node.js and web applications.
License: Other
Deprecated. Moved to trezor-suite repository.
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?
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);
problems:
solution:
process hid devices is the same way as bootloader
devices
https://github.com/trezor/trezor-link/blob/master/src/lowlevel/webusb.js#L86
process unreadableHidDeviceChange
internally and resolve it by enumerate
response
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) { ... }
@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!
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 },
In case when received ButtonRequest is a unknown type trezor-link should not fail with error.
more:
trezor/trezor-suite#1642
https://github.com/trezor/trezor-link/blob/master/src/bridge/v1.js should not be used anywhere anymore.
When i try to use is it throws error:
Uncaught ReferenceError: regeneratorRuntime is not defined at http.js:12
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.