@ledgerhq/hw-transport-node-hid-noevents 6.30.5-next.0 → 6.30.6-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +18 -0
- package/lib/TransportNodeHid.d.ts +1 -0
- package/lib/TransportNodeHid.d.ts.map +1 -1
- package/lib/TransportNodeHid.js +104 -115
- package/lib/TransportNodeHid.js.map +1 -1
- package/lib-es/TransportNodeHid.d.ts +1 -0
- package/lib-es/TransportNodeHid.d.ts.map +1 -1
- package/lib-es/TransportNodeHid.js +105 -117
- package/lib-es/TransportNodeHid.js.map +1 -1
- package/package.json +7 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/hw-transport-node-hid-noevents@6.30.
|
|
3
|
-
> tsc && tsc -m
|
|
2
|
+
> @ledgerhq/hw-transport-node-hid-noevents@6.30.5 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-transport-node-hid-noevents
|
|
3
|
+
> tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ledgerhq/hw-transport-node-hid-noevents
|
|
2
2
|
|
|
3
|
+
## 6.30.6-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`107f35a`](https://github.com/LedgerHQ/ledger-live/commit/107f35a0650412716b088a3503b86435e6d9cf47), [`9081c26`](https://github.com/LedgerHQ/ledger-live/commit/9081c2648490f977469a33762a3c67bb2c2a0be5)]:
|
|
8
|
+
- @ledgerhq/errors@6.21.0-next.0
|
|
9
|
+
- @ledgerhq/devices@8.4.5-next.0
|
|
10
|
+
- @ledgerhq/hw-transport@6.31.5-next.0
|
|
11
|
+
|
|
12
|
+
## 6.30.5
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`0a71c43`](https://github.com/LedgerHQ/ledger-live/commit/0a71c4344b7bb2c6640f3e5dda152ae815573330)]:
|
|
17
|
+
- @ledgerhq/errors@6.19.1
|
|
18
|
+
- @ledgerhq/devices@8.4.4
|
|
19
|
+
- @ledgerhq/hw-transport@6.31.4
|
|
20
|
+
|
|
3
21
|
## 6.30.5-next.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransportNodeHid.d.ts","sourceRoot":"","sources":["../src/TransportNodeHid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TransportNodeHid.d.ts","sourceRoot":"","sources":["../src/TransportNodeHid.ts"],"names":[],"mappings":";;AAAA,OAAO,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,SAAS,EAAE,EAChB,QAAQ,EACR,eAAe,EACf,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAYhD,wBAAgB,UAAU,IAAI,CAAC,MAAM,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CAEjE;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,SAAS;IAC7D;;OAEG;IACH,MAAM,CAAC,WAAW,QAAO,QAAQ,OAAO,CAAC,CAAmD;IAE5F;;OAEG;IACH,MAAM,CAAC,IAAI,QAAO,QAAQ,GAAG,CAAC,CAAmD;IAEjF;OACG;IACH,MAAM,CAAC,MAAM,aAAc,SAAS,gBAAgB,GAAG,CAAC,CAAC,KAAG,YAAY,CActE;IAEF;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAY3C,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC;IAChB,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,OAAO,SAAsC;IAC7C,UAAU,SAAM;IAChB,YAAY,UAAS;gBAGnB,MAAM,EAAE,GAAG,CAAC,GAAG,EACf,EAAE,OAAO,EAAE,OAAO,EAAE,GAAE;QAAE,OAAO,CAAC,EAAE,YAAY,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO;IAc1E,eAAe,aAOb;IAEF,QAAQ,YAAa,MAAM,KAAG,QAAQ,IAAI,CAAC,CAyBzC;IAEF,OAAO,QAAO,QAAQ,MAAM,CAAC,CAwBzB;IAEJ;;;;;OAKG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmC7C,cAAc;IAEd;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|
package/lib/TransportNodeHid.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -34,6 +25,31 @@ exports.getDevices = getDevices;
|
|
|
34
25
|
* TransportNodeHid.create().then(transport => ...)
|
|
35
26
|
*/
|
|
36
27
|
class TransportNodeHidNoEvents extends hw_transport_1.default {
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
static isSupported = () => Promise.resolve(typeof node_hid_1.default.HID === "function");
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
static list = () => Promise.resolve(getDevices().map(d => d.path));
|
|
36
|
+
/**
|
|
37
|
+
*/
|
|
38
|
+
static listen = (observer) => {
|
|
39
|
+
getDevices().forEach(device => {
|
|
40
|
+
const deviceModel = (0, devices_2.identifyUSBProductId)(device.productId);
|
|
41
|
+
observer.next({
|
|
42
|
+
type: "add",
|
|
43
|
+
descriptor: device.path,
|
|
44
|
+
deviceModel,
|
|
45
|
+
device: device,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
observer.complete();
|
|
49
|
+
return {
|
|
50
|
+
unsubscribe: () => { },
|
|
51
|
+
};
|
|
52
|
+
};
|
|
37
53
|
/**
|
|
38
54
|
* if path="" is not provided, the library will take the first device
|
|
39
55
|
*/
|
|
@@ -48,58 +64,13 @@ class TransportNodeHidNoEvents extends hw_transport_1.default {
|
|
|
48
64
|
return new TransportNodeHidNoEvents(new node_hid_1.default.HID(device.path));
|
|
49
65
|
});
|
|
50
66
|
}
|
|
67
|
+
device;
|
|
68
|
+
deviceModel;
|
|
69
|
+
channel = Math.floor(Math.random() * 0xffff);
|
|
70
|
+
packetSize = 64;
|
|
71
|
+
disconnected = false;
|
|
51
72
|
constructor(device, { context, logType } = {}) {
|
|
52
73
|
super({ context, logType });
|
|
53
|
-
this.channel = Math.floor(Math.random() * 0xffff);
|
|
54
|
-
this.packetSize = 64;
|
|
55
|
-
this.disconnected = false;
|
|
56
|
-
this.setDisconnected = () => {
|
|
57
|
-
this.tracer.trace("Setting to disconnected", { alreadyDisconnected: this.disconnected });
|
|
58
|
-
if (!this.disconnected) {
|
|
59
|
-
this.emit("disconnect");
|
|
60
|
-
this.disconnected = true;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
this.writeHID = (content) => {
|
|
64
|
-
const data = [0x00];
|
|
65
|
-
for (let i = 0; i < content.length; i++) {
|
|
66
|
-
data.push(content[i]);
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
this.device.write(data);
|
|
70
|
-
return Promise.resolve();
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
this.tracer.trace(`Received an error during HID write: ${error}`, { error });
|
|
74
|
-
let maybeMappedError = error;
|
|
75
|
-
if (error instanceof Error) {
|
|
76
|
-
maybeMappedError = new errors_1.DisconnectedDeviceDuringOperation(error.message);
|
|
77
|
-
}
|
|
78
|
-
if (maybeMappedError instanceof errors_1.DisconnectedDeviceDuringOperation) {
|
|
79
|
-
this.tracer.trace("Disconnected during HID write");
|
|
80
|
-
this.setDisconnected();
|
|
81
|
-
}
|
|
82
|
-
return Promise.reject(maybeMappedError);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
this.readHID = () => new Promise((resolve, reject) => this.device.read((e, res) => {
|
|
86
|
-
if (!res) {
|
|
87
|
-
return reject(new errors_1.DisconnectedDevice());
|
|
88
|
-
}
|
|
89
|
-
if (e) {
|
|
90
|
-
this.tracer.trace(`Received an error during HID read: ${e}`, { e });
|
|
91
|
-
const maybeMappedError = e && e.message ? new errors_1.DisconnectedDeviceDuringOperation(e.message) : e;
|
|
92
|
-
if (maybeMappedError instanceof errors_1.DisconnectedDeviceDuringOperation) {
|
|
93
|
-
this.tracer.trace("Disconnected during HID read");
|
|
94
|
-
this.setDisconnected();
|
|
95
|
-
}
|
|
96
|
-
reject(maybeMappedError);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
const buffer = Buffer.from(res);
|
|
100
|
-
resolve(buffer);
|
|
101
|
-
}
|
|
102
|
-
}));
|
|
103
74
|
this.updateTraceContext({ hidChannel: this.channel });
|
|
104
75
|
this.device = device;
|
|
105
76
|
// @ts-expect-error accessing low level API in C
|
|
@@ -107,75 +78,93 @@ class TransportNodeHidNoEvents extends hw_transport_1.default {
|
|
|
107
78
|
this.tracer.trace(`Connected to HID device ${!!info}`, { info });
|
|
108
79
|
this.deviceModel = info && info.product ? (0, devices_2.identifyProductName)(info.product) : null;
|
|
109
80
|
}
|
|
81
|
+
setDisconnected = () => {
|
|
82
|
+
this.tracer.trace("Setting to disconnected", { alreadyDisconnected: this.disconnected });
|
|
83
|
+
if (!this.disconnected) {
|
|
84
|
+
this.emit("disconnect");
|
|
85
|
+
this.disconnected = true;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
writeHID = (content) => {
|
|
89
|
+
const data = [0x00];
|
|
90
|
+
for (let i = 0; i < content.length; i++) {
|
|
91
|
+
data.push(content[i]);
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
this.device.write(data);
|
|
95
|
+
return Promise.resolve();
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
this.tracer.trace(`Received an error during HID write: ${error}`, { error });
|
|
99
|
+
let maybeMappedError = error;
|
|
100
|
+
if (error instanceof Error) {
|
|
101
|
+
maybeMappedError = new errors_1.DisconnectedDeviceDuringOperation(error.message);
|
|
102
|
+
}
|
|
103
|
+
if (maybeMappedError instanceof errors_1.DisconnectedDeviceDuringOperation) {
|
|
104
|
+
this.tracer.trace("Disconnected during HID write");
|
|
105
|
+
this.setDisconnected();
|
|
106
|
+
}
|
|
107
|
+
return Promise.reject(maybeMappedError);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
readHID = () => new Promise((resolve, reject) => this.device.read((e, res) => {
|
|
111
|
+
if (!res) {
|
|
112
|
+
return reject(new errors_1.DisconnectedDevice());
|
|
113
|
+
}
|
|
114
|
+
if (e) {
|
|
115
|
+
this.tracer.trace(`Received an error during HID read: ${e}`, { e });
|
|
116
|
+
const maybeMappedError = e && e.message ? new errors_1.DisconnectedDeviceDuringOperation(e.message) : e;
|
|
117
|
+
if (maybeMappedError instanceof errors_1.DisconnectedDeviceDuringOperation) {
|
|
118
|
+
this.tracer.trace("Disconnected during HID read");
|
|
119
|
+
this.setDisconnected();
|
|
120
|
+
}
|
|
121
|
+
reject(maybeMappedError);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const buffer = Buffer.from(res);
|
|
125
|
+
resolve(buffer);
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
110
128
|
/**
|
|
111
129
|
* Exchange with the device using APDU protocol.
|
|
112
130
|
*
|
|
113
131
|
* @param apdu
|
|
114
132
|
* @returns a promise of apdu response
|
|
115
133
|
*/
|
|
116
|
-
exchange(apdu) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return result;
|
|
140
|
-
}));
|
|
141
|
-
return b;
|
|
134
|
+
async exchange(apdu) {
|
|
135
|
+
const tracer = this.tracer.withUpdatedContext({
|
|
136
|
+
function: "exchange",
|
|
137
|
+
});
|
|
138
|
+
tracer.trace("Exchanging APDU ...");
|
|
139
|
+
const b = await this.exchangeAtomicImpl(async () => {
|
|
140
|
+
const { channel, packetSize } = this;
|
|
141
|
+
tracer.withType("apdu").trace(`=> ${apdu.toString("hex")}`, { channel, packetSize });
|
|
142
|
+
const framingHelper = (0, hid_framing_1.default)(channel, packetSize);
|
|
143
|
+
// Creates HID-framed chunks from the APDU to be sent to the device...
|
|
144
|
+
const blocks = framingHelper.makeBlocks(apdu);
|
|
145
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
146
|
+
await this.writeHID(blocks[i]);
|
|
147
|
+
}
|
|
148
|
+
// Read...
|
|
149
|
+
let result;
|
|
150
|
+
let acc;
|
|
151
|
+
while (!(result = framingHelper.getReducedResult(acc))) {
|
|
152
|
+
const buffer = await this.readHID();
|
|
153
|
+
acc = framingHelper.reduceResponse(acc, buffer);
|
|
154
|
+
}
|
|
155
|
+
tracer.withType("apdu").trace(`<= ${result.toString("hex")}`, { channel, packetSize });
|
|
156
|
+
return result;
|
|
142
157
|
});
|
|
158
|
+
return b;
|
|
143
159
|
}
|
|
144
160
|
setScrambleKey() { }
|
|
145
161
|
/**
|
|
146
162
|
* release the USB device.
|
|
147
163
|
*/
|
|
148
|
-
close() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.device.close();
|
|
152
|
-
});
|
|
164
|
+
async close() {
|
|
165
|
+
await this.exchangeBusyPromise;
|
|
166
|
+
this.device.close();
|
|
153
167
|
}
|
|
154
168
|
}
|
|
155
|
-
/**
|
|
156
|
-
*
|
|
157
|
-
*/
|
|
158
|
-
TransportNodeHidNoEvents.isSupported = () => Promise.resolve(typeof node_hid_1.default.HID === "function");
|
|
159
|
-
/**
|
|
160
|
-
*
|
|
161
|
-
*/
|
|
162
|
-
TransportNodeHidNoEvents.list = () => Promise.resolve(getDevices().map(d => d.path));
|
|
163
|
-
/**
|
|
164
|
-
*/
|
|
165
|
-
TransportNodeHidNoEvents.listen = (observer) => {
|
|
166
|
-
getDevices().forEach(device => {
|
|
167
|
-
const deviceModel = (0, devices_2.identifyUSBProductId)(device.productId);
|
|
168
|
-
observer.next({
|
|
169
|
-
type: "add",
|
|
170
|
-
descriptor: device.path,
|
|
171
|
-
deviceModel,
|
|
172
|
-
device: device,
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
observer.complete();
|
|
176
|
-
return {
|
|
177
|
-
unsubscribe: () => { },
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
169
|
exports.default = TransportNodeHidNoEvents;
|
|
181
170
|
//# sourceMappingURL=TransportNodeHid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransportNodeHid.js","sourceRoot":"","sources":["../src/TransportNodeHid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TransportNodeHid.js","sourceRoot":"","sources":["../src/TransportNodeHid.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAuC;AAEvC,0EAKgC;AAChC,+CAAsD;AACtD,gFAAuD;AACvD,+CAA8E;AAE9E,6CAI0B;AAE1B,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAC/B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC5C,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,MAAM;IAC7B,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,CAAC,CAAC;AAE7B,SAAgB,UAAU;IACxB,OAAO,kBAAG,CAAC,OAAO,CAAC,2BAAiB,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AACrE,CAAC;AAFD,gCAEC;AAED;;;;;;GAMG;AACH,MAAqB,wBAAyB,SAAQ,sBAAS;IAC7D;;OAEG;IACH,MAAM,CAAC,WAAW,GAAG,GAAqB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,kBAAG,CAAC,GAAG,KAAK,UAAU,CAAC,CAAC;IAE5F;;OAEG;IACH,MAAM,CAAC,IAAI,GAAG,GAAiB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAEjF;OACG;IACH,MAAM,CAAC,MAAM,GAAG,CAAC,QAAwC,EAAgB,EAAE;QACzE,UAAU,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC5B,MAAM,WAAW,GAAG,IAAA,8BAAoB,EAAC,MAAM,CA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M,CAAC,CAAC;YAClD,CAAC;YAED,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;YACvF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAW,CAAC;IACrB,CAAC;IAED,cAAc,KAAI,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,mBAAmB,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;;AAjLH,2CAkLC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransportNodeHid.d.ts","sourceRoot":"","sources":["../src/TransportNodeHid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TransportNodeHid.d.ts","sourceRoot":"","sources":["../src/TransportNodeHid.ts"],"names":[],"mappings":";;AAAA,OAAO,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,SAAS,EAAE,EAChB,QAAQ,EACR,eAAe,EACf,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAYhD,wBAAgB,UAAU,IAAI,CAAC,MAAM,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CAEjE;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,SAAS;IAC7D;;OAEG;IACH,MAAM,CAAC,WAAW,QAAO,QAAQ,OAAO,CAAC,CAAmD;IAE5F;;OAEG;IACH,MAAM,CAAC,IAAI,QAAO,QAAQ,GAAG,CAAC,CAAmD;IAEjF;OACG;IACH,MAAM,CAAC,MAAM,aAAc,SAAS,gBAAgB,GAAG,CAAC,CAAC,KAAG,YAAY,CActE;IAEF;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAY3C,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC;IAChB,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,OAAO,SAAsC;IAC7C,UAAU,SAAM;IAChB,YAAY,UAAS;gBAGnB,MAAM,EAAE,GAAG,CAAC,GAAG,EACf,EAAE,OAAO,EAAE,OAAO,EAAE,GAAE;QAAE,OAAO,CAAC,EAAE,YAAY,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO;IAc1E,eAAe,aAOb;IAEF,QAAQ,YAAa,MAAM,KAAG,QAAQ,IAAI,CAAC,CAyBzC;IAEF,OAAO,QAAO,QAAQ,MAAM,CAAC,CAwBzB;IAEJ;;;;;OAKG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmC7C,cAAc;IAEd;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import HID from "node-hid";
|
|
11
2
|
import Transport from "@ledgerhq/hw-transport";
|
|
12
3
|
import { ledgerUSBVendorId } from "@ledgerhq/devices";
|
|
@@ -26,7 +17,32 @@ export function getDevices() {
|
|
|
26
17
|
* ...
|
|
27
18
|
* TransportNodeHid.create().then(transport => ...)
|
|
28
19
|
*/
|
|
29
|
-
class TransportNodeHidNoEvents extends Transport {
|
|
20
|
+
export default class TransportNodeHidNoEvents extends Transport {
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
static isSupported = () => Promise.resolve(typeof HID.HID === "function");
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
static list = () => Promise.resolve(getDevices().map(d => d.path));
|
|
29
|
+
/**
|
|
30
|
+
*/
|
|
31
|
+
static listen = (observer) => {
|
|
32
|
+
getDevices().forEach(device => {
|
|
33
|
+
const deviceModel = identifyUSBProductId(device.productId);
|
|
34
|
+
observer.next({
|
|
35
|
+
type: "add",
|
|
36
|
+
descriptor: device.path,
|
|
37
|
+
deviceModel,
|
|
38
|
+
device: device,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
observer.complete();
|
|
42
|
+
return {
|
|
43
|
+
unsubscribe: () => { },
|
|
44
|
+
};
|
|
45
|
+
};
|
|
30
46
|
/**
|
|
31
47
|
* if path="" is not provided, the library will take the first device
|
|
32
48
|
*/
|
|
@@ -41,58 +57,13 @@ class TransportNodeHidNoEvents extends Transport {
|
|
|
41
57
|
return new TransportNodeHidNoEvents(new HID.HID(device.path));
|
|
42
58
|
});
|
|
43
59
|
}
|
|
60
|
+
device;
|
|
61
|
+
deviceModel;
|
|
62
|
+
channel = Math.floor(Math.random() * 0xffff);
|
|
63
|
+
packetSize = 64;
|
|
64
|
+
disconnected = false;
|
|
44
65
|
constructor(device, { context, logType } = {}) {
|
|
45
66
|
super({ context, logType });
|
|
46
|
-
this.channel = Math.floor(Math.random() * 0xffff);
|
|
47
|
-
this.packetSize = 64;
|
|
48
|
-
this.disconnected = false;
|
|
49
|
-
this.setDisconnected = () => {
|
|
50
|
-
this.tracer.trace("Setting to disconnected", { alreadyDisconnected: this.disconnected });
|
|
51
|
-
if (!this.disconnected) {
|
|
52
|
-
this.emit("disconnect");
|
|
53
|
-
this.disconnected = true;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
this.writeHID = (content) => {
|
|
57
|
-
const data = [0x00];
|
|
58
|
-
for (let i = 0; i < content.length; i++) {
|
|
59
|
-
data.push(content[i]);
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
this.device.write(data);
|
|
63
|
-
return Promise.resolve();
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
this.tracer.trace(`Received an error during HID write: ${error}`, { error });
|
|
67
|
-
let maybeMappedError = error;
|
|
68
|
-
if (error instanceof Error) {
|
|
69
|
-
maybeMappedError = new DisconnectedDeviceDuringOperation(error.message);
|
|
70
|
-
}
|
|
71
|
-
if (maybeMappedError instanceof DisconnectedDeviceDuringOperation) {
|
|
72
|
-
this.tracer.trace("Disconnected during HID write");
|
|
73
|
-
this.setDisconnected();
|
|
74
|
-
}
|
|
75
|
-
return Promise.reject(maybeMappedError);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
this.readHID = () => new Promise((resolve, reject) => this.device.read((e, res) => {
|
|
79
|
-
if (!res) {
|
|
80
|
-
return reject(new DisconnectedDevice());
|
|
81
|
-
}
|
|
82
|
-
if (e) {
|
|
83
|
-
this.tracer.trace(`Received an error during HID read: ${e}`, { e });
|
|
84
|
-
const maybeMappedError = e && e.message ? new DisconnectedDeviceDuringOperation(e.message) : e;
|
|
85
|
-
if (maybeMappedError instanceof DisconnectedDeviceDuringOperation) {
|
|
86
|
-
this.tracer.trace("Disconnected during HID read");
|
|
87
|
-
this.setDisconnected();
|
|
88
|
-
}
|
|
89
|
-
reject(maybeMappedError);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
const buffer = Buffer.from(res);
|
|
93
|
-
resolve(buffer);
|
|
94
|
-
}
|
|
95
|
-
}));
|
|
96
67
|
this.updateTraceContext({ hidChannel: this.channel });
|
|
97
68
|
this.device = device;
|
|
98
69
|
// @ts-expect-error accessing low level API in C
|
|
@@ -100,75 +71,92 @@ class TransportNodeHidNoEvents extends Transport {
|
|
|
100
71
|
this.tracer.trace(`Connected to HID device ${!!info}`, { info });
|
|
101
72
|
this.deviceModel = info && info.product ? identifyProductName(info.product) : null;
|
|
102
73
|
}
|
|
74
|
+
setDisconnected = () => {
|
|
75
|
+
this.tracer.trace("Setting to disconnected", { alreadyDisconnected: this.disconnected });
|
|
76
|
+
if (!this.disconnected) {
|
|
77
|
+
this.emit("disconnect");
|
|
78
|
+
this.disconnected = true;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
writeHID = (content) => {
|
|
82
|
+
const data = [0x00];
|
|
83
|
+
for (let i = 0; i < content.length; i++) {
|
|
84
|
+
data.push(content[i]);
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
this.device.write(data);
|
|
88
|
+
return Promise.resolve();
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.tracer.trace(`Received an error during HID write: ${error}`, { error });
|
|
92
|
+
let maybeMappedError = error;
|
|
93
|
+
if (error instanceof Error) {
|
|
94
|
+
maybeMappedError = new DisconnectedDeviceDuringOperation(error.message);
|
|
95
|
+
}
|
|
96
|
+
if (maybeMappedError instanceof DisconnectedDeviceDuringOperation) {
|
|
97
|
+
this.tracer.trace("Disconnected during HID write");
|
|
98
|
+
this.setDisconnected();
|
|
99
|
+
}
|
|
100
|
+
return Promise.reject(maybeMappedError);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
readHID = () => new Promise((resolve, reject) => this.device.read((e, res) => {
|
|
104
|
+
if (!res) {
|
|
105
|
+
return reject(new DisconnectedDevice());
|
|
106
|
+
}
|
|
107
|
+
if (e) {
|
|
108
|
+
this.tracer.trace(`Received an error during HID read: ${e}`, { e });
|
|
109
|
+
const maybeMappedError = e && e.message ? new DisconnectedDeviceDuringOperation(e.message) : e;
|
|
110
|
+
if (maybeMappedError instanceof DisconnectedDeviceDuringOperation) {
|
|
111
|
+
this.tracer.trace("Disconnected during HID read");
|
|
112
|
+
this.setDisconnected();
|
|
113
|
+
}
|
|
114
|
+
reject(maybeMappedError);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const buffer = Buffer.from(res);
|
|
118
|
+
resolve(buffer);
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
103
121
|
/**
|
|
104
122
|
* Exchange with the device using APDU protocol.
|
|
105
123
|
*
|
|
106
124
|
* @param apdu
|
|
107
125
|
* @returns a promise of apdu response
|
|
108
126
|
*/
|
|
109
|
-
exchange(apdu) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return result;
|
|
133
|
-
}));
|
|
134
|
-
return b;
|
|
127
|
+
async exchange(apdu) {
|
|
128
|
+
const tracer = this.tracer.withUpdatedContext({
|
|
129
|
+
function: "exchange",
|
|
130
|
+
});
|
|
131
|
+
tracer.trace("Exchanging APDU ...");
|
|
132
|
+
const b = await this.exchangeAtomicImpl(async () => {
|
|
133
|
+
const { channel, packetSize } = this;
|
|
134
|
+
tracer.withType("apdu").trace(`=> ${apdu.toString("hex")}`, { channel, packetSize });
|
|
135
|
+
const framingHelper = hidFraming(channel, packetSize);
|
|
136
|
+
// Creates HID-framed chunks from the APDU to be sent to the device...
|
|
137
|
+
const blocks = framingHelper.makeBlocks(apdu);
|
|
138
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
139
|
+
await this.writeHID(blocks[i]);
|
|
140
|
+
}
|
|
141
|
+
// Read...
|
|
142
|
+
let result;
|
|
143
|
+
let acc;
|
|
144
|
+
while (!(result = framingHelper.getReducedResult(acc))) {
|
|
145
|
+
const buffer = await this.readHID();
|
|
146
|
+
acc = framingHelper.reduceResponse(acc, buffer);
|
|
147
|
+
}
|
|
148
|
+
tracer.withType("apdu").trace(`<= ${result.toString("hex")}`, { channel, packetSize });
|
|
149
|
+
return result;
|
|
135
150
|
});
|
|
151
|
+
return b;
|
|
136
152
|
}
|
|
137
153
|
setScrambleKey() { }
|
|
138
154
|
/**
|
|
139
155
|
* release the USB device.
|
|
140
156
|
*/
|
|
141
|
-
close() {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.device.close();
|
|
145
|
-
});
|
|
157
|
+
async close() {
|
|
158
|
+
await this.exchangeBusyPromise;
|
|
159
|
+
this.device.close();
|
|
146
160
|
}
|
|
147
161
|
}
|
|
148
|
-
/**
|
|
149
|
-
*
|
|
150
|
-
*/
|
|
151
|
-
TransportNodeHidNoEvents.isSupported = () => Promise.resolve(typeof HID.HID === "function");
|
|
152
|
-
/**
|
|
153
|
-
*
|
|
154
|
-
*/
|
|
155
|
-
TransportNodeHidNoEvents.list = () => Promise.resolve(getDevices().map(d => d.path));
|
|
156
|
-
/**
|
|
157
|
-
*/
|
|
158
|
-
TransportNodeHidNoEvents.listen = (observer) => {
|
|
159
|
-
getDevices().forEach(device => {
|
|
160
|
-
const deviceModel = identifyUSBProductId(device.productId);
|
|
161
|
-
observer.next({
|
|
162
|
-
type: "add",
|
|
163
|
-
descriptor: device.path,
|
|
164
|
-
deviceModel,
|
|
165
|
-
device: device,
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
observer.complete();
|
|
169
|
-
return {
|
|
170
|
-
unsubscribe: () => { },
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
export default TransportNodeHidNoEvents;
|
|
174
162
|
//# sourceMappingURL=TransportNodeHid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransportNodeHid.js","sourceRoot":"","sources":["../src/TransportNodeHid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TransportNodeHid.js","sourceRoot":"","sources":["../src/TransportNodeHid.ts"],"names":[],"mappings":"AAAA,OAAO,GAAe,MAAM,UAAU,CAAC;AAEvC,OAAO,SAKN,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iCAAiC,GAClC,MAAM,kBAAkB,CAAC;AAE1B,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAC/B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC5C,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,MAAM;IAC7B,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,CAAC,CAAC;AAE7B,MAAM,UAAU,UAAU;IACxB,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AACrE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,SAAS;IAC7D;;OAEG;IACH,MAAM,CAAC,WAAW,GAAG,GAAqB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,GAAG,KAAK,UAAU,CAAC,CAAC;IAE5F;;OAEG;IACH,MAAM,CAAC,IAAI,GAAG,GAAiB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CA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AM,GAAG,aAAa,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;gBACpC,GAAG,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAClD,CAAC;YAED,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;YACvF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAW,CAAC;IACrB,CAAC;IAED,cAAc,KAAI,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,mBAAmB,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/hw-transport-node-hid-noevents",
|
|
3
|
-
"version": "6.30.
|
|
3
|
+
"version": "6.30.6-next.0",
|
|
4
4
|
"description": "Ledger Hardware Wallet Node implementation of the communication layer, using node-hid. without usb events",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"node-hid": "2.1.2",
|
|
31
|
-
"@ledgerhq/devices": "
|
|
32
|
-
"@ledgerhq/errors": "^6.
|
|
33
|
-
"@ledgerhq/hw-transport": "^6.31.
|
|
31
|
+
"@ledgerhq/devices": "8.4.5-next.0",
|
|
32
|
+
"@ledgerhq/errors": "^6.21.0-next.0",
|
|
33
|
+
"@ledgerhq/hw-transport": "^6.31.5-next.0",
|
|
34
34
|
"@ledgerhq/logs": "^6.12.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/jest": "^29.5.10",
|
|
38
|
-
"@types/node": "^
|
|
38
|
+
"@types/node": "^22.10.10",
|
|
39
39
|
"@types/node-hid": "^1.3.1",
|
|
40
40
|
"documentation": "14.0.2",
|
|
41
41
|
"jest": "^29.7.0",
|
|
@@ -47,9 +47,10 @@
|
|
|
47
47
|
"gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec",
|
|
48
48
|
"scripts": {
|
|
49
49
|
"clean": "rimraf lib lib-es",
|
|
50
|
-
"build": "tsc && tsc -m
|
|
50
|
+
"build": "tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es",
|
|
51
51
|
"prewatch": "pnpm build",
|
|
52
52
|
"watch": "tsc --watch",
|
|
53
|
+
"watch:es": "tsc --watch -m esnext --moduleResolution bundler --outDir lib-es",
|
|
53
54
|
"doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
|
|
54
55
|
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
|
|
55
56
|
"lint:fix": "pnpm lint --fix",
|