@onekeyfe/hd-transport-usb 1.2.0-alpha.33 → 1.2.0-alpha.35
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/__tests__/protocol-v2-link.test.ts +41 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -25
- package/dist/transportLog.d.ts +1 -6
- package/dist/transportLog.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +21 -15
- package/src/transportLog.ts +1 -11
|
@@ -253,6 +253,28 @@ const createHarness = () => {
|
|
|
253
253
|
};
|
|
254
254
|
|
|
255
255
|
describe('NodeUsbTransport Protocol V2 link lifecycle', () => {
|
|
256
|
+
test('falls back to Protocol V2 when a cached V1 hint is stale', async () => {
|
|
257
|
+
const transport = new NodeUsbTransport() as any;
|
|
258
|
+
const events: string[] = [];
|
|
259
|
+
transport.probeProtocolV1 = jest.fn().mockImplementation(() => {
|
|
260
|
+
events.push('probe-v1');
|
|
261
|
+
return Promise.resolve(false);
|
|
262
|
+
});
|
|
263
|
+
transport.resetConnectionAfterProbe = jest.fn().mockImplementation(() => {
|
|
264
|
+
events.push('reset');
|
|
265
|
+
return Promise.resolve();
|
|
266
|
+
});
|
|
267
|
+
transport.probeProtocolV2 = jest.fn().mockImplementation(() => {
|
|
268
|
+
events.push('probe-v2');
|
|
269
|
+
return Promise.resolve(true);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
await expect(transport.detectProtocol('pro-usb', undefined, 'V1')).resolves.toBe('V2');
|
|
273
|
+
|
|
274
|
+
expect(events).toEqual(['probe-v1', 'reset', 'probe-v2']);
|
|
275
|
+
expect(transport.getProtocolType('pro-usb')).toBe('V2');
|
|
276
|
+
});
|
|
277
|
+
|
|
256
278
|
test('keeps active links when the Protocol V2 schema is configured repeatedly', () => {
|
|
257
279
|
const transport = new NodeUsbTransport() as any;
|
|
258
280
|
transport.invalidateAllProtocolV2UsbLinks = jest.fn().mockResolvedValue(undefined);
|
|
@@ -286,6 +308,25 @@ describe('NodeUsbTransport Protocol V2 link lifecycle', () => {
|
|
|
286
308
|
);
|
|
287
309
|
});
|
|
288
310
|
|
|
311
|
+
test('releases the USB interface when protocol detection rejects acquire', async () => {
|
|
312
|
+
const harness = createHarness();
|
|
313
|
+
const { transport, path, device, iface } = harness;
|
|
314
|
+
await transport.enumerate();
|
|
315
|
+
device.close.mockClear();
|
|
316
|
+
iface.release.mockClear();
|
|
317
|
+
jest
|
|
318
|
+
.spyOn(transport as any, 'detectProtocol')
|
|
319
|
+
.mockRejectedValueOnce(new Error('terminal protocol probe failure'));
|
|
320
|
+
|
|
321
|
+
await expect(transport.acquire({ path })).rejects.toMatchObject({
|
|
322
|
+
errorCode: expect.any(Number),
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
expect(iface.release).toHaveBeenCalledTimes(1);
|
|
326
|
+
expect(device.close).toHaveBeenCalledTimes(1);
|
|
327
|
+
expect((transport as any).openDevices.has(path)).toBe(false);
|
|
328
|
+
});
|
|
329
|
+
|
|
289
330
|
test('stop releases an acquired USB interface even before a Protocol V2 call', async () => {
|
|
290
331
|
const harness = createHarness();
|
|
291
332
|
const { transport, path, device, iface } = harness;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,SAAS,EAAE,EAQhB,0BAA0B,EAE3B,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAuIhC,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,0BAA0B,CAAC,MAAM,CAAC;IAC9E,QAAQ,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAA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S,EAAE,MAAM,GAAG,KAAK;YAOnE,cAAc;YAad,WAAW;IA6CzB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
|
package/dist/index.js
CHANGED
|
@@ -59,14 +59,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
59
59
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
const HIGH_VOLUME_CALLS = new Set(['FileWrite', 'FilesystemFileWrite', 'EmmcFileWrite']);
|
|
63
|
-
function shouldSuppressHighVolumeCallLog(name) {
|
|
64
|
-
return HIGH_VOLUME_CALLS.has(name);
|
|
65
|
-
}
|
|
66
|
-
function createTransportCallLog(name, protocol) {
|
|
67
|
-
return { name, protocol };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
62
|
const { parseConfigure, ProtocolV1, check } = transport__default["default"];
|
|
71
63
|
const PACKET_SIZE = transport.PROTOCOL_V1_USB_PACKET_SIZE;
|
|
72
64
|
const REPORT_ID = transport.PROTOCOL_V1_REPORT_ID;
|
|
@@ -261,7 +253,7 @@ class NodeUsbTransport extends transport.ProtocolV2UsbTransportBase {
|
|
|
261
253
|
});
|
|
262
254
|
}
|
|
263
255
|
acquire(input) {
|
|
264
|
-
var _a, _b, _c;
|
|
256
|
+
var _a, _b, _c, _d;
|
|
265
257
|
return __awaiter(this, void 0, void 0, function* () {
|
|
266
258
|
this.cancelled = false;
|
|
267
259
|
const path = (_a = input.path) !== null && _a !== void 0 ? _a : '';
|
|
@@ -272,12 +264,18 @@ class NodeUsbTransport extends transport.ProtocolV2UsbTransportBase {
|
|
|
272
264
|
yield this.rotateProtocolV2UsbGeneration(path, 'Node USB transport acquired');
|
|
273
265
|
yield this.closeOpenDevice(path);
|
|
274
266
|
yield this.openDevice(path);
|
|
275
|
-
yield this.detectProtocol(path, input.expectedProtocol);
|
|
267
|
+
yield this.detectProtocol(path, input.expectedProtocol, input.protocolHint);
|
|
276
268
|
return path;
|
|
277
269
|
}
|
|
278
270
|
catch (error) {
|
|
279
271
|
(_b = this.Log) === null || _b === void 0 ? void 0 : _b.debug('NodeUsbTransport acquire error: ', error);
|
|
280
|
-
|
|
272
|
+
try {
|
|
273
|
+
yield this.release(path);
|
|
274
|
+
}
|
|
275
|
+
catch (cleanupError) {
|
|
276
|
+
(_c = this.Log) === null || _c === void 0 ? void 0 : _c.debug('NodeUsbTransport acquire cleanup error: ', cleanupError);
|
|
277
|
+
}
|
|
278
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, (_d = error.message) !== null && _d !== void 0 ? _d : String(error));
|
|
281
279
|
}
|
|
282
280
|
});
|
|
283
281
|
}
|
|
@@ -401,8 +399,8 @@ class NodeUsbTransport extends transport.ProtocolV2UsbTransportBase {
|
|
|
401
399
|
if (!protocol) {
|
|
402
400
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol has not been detected for ${path}`);
|
|
403
401
|
}
|
|
404
|
-
if (!shouldSuppressHighVolumeCallLog(name)) {
|
|
405
|
-
(_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug('transport call', createTransportCallLog(name, protocol));
|
|
402
|
+
if (!transport.shouldSuppressHighVolumeCallLog(name)) {
|
|
403
|
+
(_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug('transport call', transport.createTransportCallLog(name, protocol, data));
|
|
406
404
|
}
|
|
407
405
|
if (protocol === 'V2') {
|
|
408
406
|
return this.callProtocolV2(path, name, data, options);
|
|
@@ -650,7 +648,7 @@ class NodeUsbTransport extends transport.ProtocolV2UsbTransportBase {
|
|
|
650
648
|
createProtocolDetectionError() {
|
|
651
649
|
return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Unable to detect USB protocol: device did not respond to Protocol V1 Initialize or Protocol V2 Ping');
|
|
652
650
|
}
|
|
653
|
-
detectProtocol(path, expectedProtocol) {
|
|
651
|
+
detectProtocol(path, expectedProtocol, protocolHint) {
|
|
654
652
|
var _a;
|
|
655
653
|
return __awaiter(this, void 0, void 0, function* () {
|
|
656
654
|
if (expectedProtocol === 'V2') {
|
|
@@ -668,17 +666,16 @@ class NodeUsbTransport extends transport.ProtocolV2UsbTransportBase {
|
|
|
668
666
|
}
|
|
669
667
|
throw this.createProtocolMismatchError(expectedProtocol);
|
|
670
668
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
this.
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return 'V2';
|
|
669
|
+
const probeOrder = protocolHint === 'V2' || this.deviceProtocol.get(path) === 'V2' ? ['V2', 'V1'] : ['V1', 'V2'];
|
|
670
|
+
for (const [index, protocol] of probeOrder.entries()) {
|
|
671
|
+
if (index > 0) {
|
|
672
|
+
yield this.resetConnectionAfterProbe(path);
|
|
673
|
+
}
|
|
674
|
+
const detected = protocol === 'V1' ? yield this.probeProtocolV1(path) : yield this.probeProtocolV2(path);
|
|
675
|
+
if (detected) {
|
|
676
|
+
this.deviceProtocol.set(path, protocol);
|
|
677
|
+
return protocol;
|
|
678
|
+
}
|
|
682
679
|
}
|
|
683
680
|
this.deviceProtocol.delete(path);
|
|
684
681
|
throw this.createProtocolDetectionError();
|
package/dist/transportLog.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function shouldSuppressHighVolumeCallLog(name: string): boolean;
|
|
3
|
-
export declare function createTransportCallLog(name: string, protocol: ProtocolType): {
|
|
4
|
-
name: string;
|
|
5
|
-
protocol: ProtocolType;
|
|
6
|
-
};
|
|
1
|
+
export { createTransportCallLog, shouldSuppressHighVolumeCallLog } from '@onekeyfe/hd-transport';
|
|
7
2
|
//# sourceMappingURL=transportLog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transportLog.d.ts","sourceRoot":"","sources":["../src/transportLog.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"transportLog.d.ts","sourceRoot":"","sources":["../src/transportLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-usb",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.35",
|
|
4
4
|
"description": "OneKey hardware wallet direct USB transport plugin (libusb)",
|
|
5
5
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"lint:fix": "eslint . --fix"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
25
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
24
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.35",
|
|
25
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.35",
|
|
26
26
|
"bytebuffer": "^5.0.1",
|
|
27
27
|
"usb": "^2.14.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "638bd33030686c4a3321e4feb4924c3f9f5c81a8"
|
|
30
30
|
}
|
package/src/index.ts
CHANGED
|
@@ -346,10 +346,15 @@ export default class NodeUsbTransport extends ProtocolV2UsbTransportBase<string>
|
|
|
346
346
|
await this.rotateProtocolV2UsbGeneration(path, 'Node USB transport acquired');
|
|
347
347
|
await this.closeOpenDevice(path);
|
|
348
348
|
await this.openDevice(path);
|
|
349
|
-
await this.detectProtocol(path, input.expectedProtocol);
|
|
349
|
+
await this.detectProtocol(path, input.expectedProtocol, input.protocolHint);
|
|
350
350
|
return path;
|
|
351
351
|
} catch (error: any) {
|
|
352
352
|
this.Log?.debug('NodeUsbTransport acquire error: ', error);
|
|
353
|
+
try {
|
|
354
|
+
await this.release(path);
|
|
355
|
+
} catch (cleanupError) {
|
|
356
|
+
this.Log?.debug('NodeUsbTransport acquire cleanup error: ', cleanupError);
|
|
357
|
+
}
|
|
353
358
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotFound, error.message ?? String(error));
|
|
354
359
|
}
|
|
355
360
|
}
|
|
@@ -498,7 +503,7 @@ export default class NodeUsbTransport extends ProtocolV2UsbTransportBase<string>
|
|
|
498
503
|
);
|
|
499
504
|
}
|
|
500
505
|
if (!shouldSuppressHighVolumeCallLog(name)) {
|
|
501
|
-
this.Log?.debug('transport call', createTransportCallLog(name, protocol));
|
|
506
|
+
this.Log?.debug('transport call', createTransportCallLog(name, protocol, data));
|
|
502
507
|
}
|
|
503
508
|
|
|
504
509
|
if (protocol === 'V2') {
|
|
@@ -843,7 +848,8 @@ export default class NodeUsbTransport extends ProtocolV2UsbTransportBase<string>
|
|
|
843
848
|
|
|
844
849
|
private async detectProtocol(
|
|
845
850
|
path: string,
|
|
846
|
-
expectedProtocol?: ProtocolType
|
|
851
|
+
expectedProtocol?: ProtocolType,
|
|
852
|
+
protocolHint?: ProtocolType
|
|
847
853
|
): Promise<ProtocolType> {
|
|
848
854
|
if (expectedProtocol === 'V2') {
|
|
849
855
|
if (await this.probeProtocolV2(path)) {
|
|
@@ -862,19 +868,19 @@ export default class NodeUsbTransport extends ProtocolV2UsbTransportBase<string>
|
|
|
862
868
|
throw this.createProtocolMismatchError(expectedProtocol);
|
|
863
869
|
}
|
|
864
870
|
|
|
865
|
-
|
|
866
|
-
this.deviceProtocol.
|
|
867
|
-
return 'V2';
|
|
868
|
-
}
|
|
871
|
+
const probeOrder: ProtocolType[] =
|
|
872
|
+
protocolHint === 'V2' || this.deviceProtocol.get(path) === 'V2' ? ['V2', 'V1'] : ['V1', 'V2'];
|
|
869
873
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
874
|
+
for (const [index, protocol] of probeOrder.entries()) {
|
|
875
|
+
if (index > 0) {
|
|
876
|
+
await this.resetConnectionAfterProbe(path);
|
|
877
|
+
}
|
|
878
|
+
const detected =
|
|
879
|
+
protocol === 'V1' ? await this.probeProtocolV1(path) : await this.probeProtocolV2(path);
|
|
880
|
+
if (detected) {
|
|
881
|
+
this.deviceProtocol.set(path, protocol);
|
|
882
|
+
return protocol;
|
|
883
|
+
}
|
|
878
884
|
}
|
|
879
885
|
|
|
880
886
|
this.deviceProtocol.delete(path);
|
package/src/transportLog.ts
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const HIGH_VOLUME_CALLS = new Set(['FileWrite', 'FilesystemFileWrite', 'EmmcFileWrite']);
|
|
4
|
-
|
|
5
|
-
export function shouldSuppressHighVolumeCallLog(name: string) {
|
|
6
|
-
return HIGH_VOLUME_CALLS.has(name);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function createTransportCallLog(name: string, protocol: ProtocolType) {
|
|
10
|
-
return { name, protocol };
|
|
11
|
-
}
|
|
1
|
+
export { createTransportCallLog, shouldSuppressHighVolumeCallLog } from '@onekeyfe/hd-transport';
|