@onekeyfe/hd-transport-usb 1.2.0-alpha.21 → 1.2.0-alpha.22
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 +5 -5
- package/dist/index.js +6 -3
- package/package.json +4 -4
- package/src/index.ts +6 -6
|
@@ -290,19 +290,19 @@ describe('NodeUsbTransport Protocol V2 link lifecycle', () => {
|
|
|
290
290
|
expect(transport.getProtocolType(path)).toBeUndefined();
|
|
291
291
|
});
|
|
292
292
|
|
|
293
|
-
test('
|
|
293
|
+
test('actively probes explicit Protocol V2 during bootloader reconnect', async () => {
|
|
294
294
|
const harness = createHarness();
|
|
295
295
|
const { transport, path, epOut } = harness;
|
|
296
296
|
|
|
297
297
|
await transport.enumerate();
|
|
298
298
|
await transport.acquire({ path, expectedProtocol: 'V2' });
|
|
299
299
|
|
|
300
|
-
expect(epOut.makeTransfer).
|
|
300
|
+
expect(epOut.makeTransfer).toHaveBeenCalledTimes(1);
|
|
301
301
|
expect(transport.getProtocolType(path)).toBe('V2');
|
|
302
302
|
await transport.release(path);
|
|
303
303
|
});
|
|
304
304
|
|
|
305
|
-
test('keeps seq across calls and
|
|
305
|
+
test('keeps seq across calls and actively probed reacquire', async () => {
|
|
306
306
|
const harness = createHarness();
|
|
307
307
|
const { transport, path, sentSeqs } = harness;
|
|
308
308
|
|
|
@@ -312,7 +312,7 @@ describe('NodeUsbTransport Protocol V2 link lifecycle', () => {
|
|
|
312
312
|
await harness.acquire();
|
|
313
313
|
await transport.call(path, 'Ping', { message: 'second' });
|
|
314
314
|
|
|
315
|
-
expect(sentSeqs).toEqual([1, 2]);
|
|
315
|
+
expect(sentSeqs).toEqual([1, 2, 3, 4]);
|
|
316
316
|
await transport.release(path);
|
|
317
317
|
});
|
|
318
318
|
|
|
@@ -381,7 +381,7 @@ describe('NodeUsbTransport Protocol V2 link lifecycle', () => {
|
|
|
381
381
|
await harness.acquire();
|
|
382
382
|
await transport.call(path, 'Ping', { message: 'after-timeout' });
|
|
383
383
|
|
|
384
|
-
expect(sentSeqs).toEqual([1, 2]);
|
|
384
|
+
expect(sentSeqs).toEqual([1, 2, 3, 4]);
|
|
385
385
|
await transport.release(path);
|
|
386
386
|
});
|
|
387
387
|
});
|
package/dist/index.js
CHANGED
|
@@ -644,9 +644,12 @@ class NodeUsbTransport extends transport.ProtocolV2UsbTransportBase {
|
|
|
644
644
|
var _a;
|
|
645
645
|
return __awaiter(this, void 0, void 0, function* () {
|
|
646
646
|
if (expectedProtocol === 'V2') {
|
|
647
|
-
this.
|
|
648
|
-
|
|
649
|
-
|
|
647
|
+
if (yield this.probeProtocolV2(path)) {
|
|
648
|
+
this.deviceProtocol.set(path, 'V2');
|
|
649
|
+
(_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug(`[NodeUsbTransport] detectProtocol: path=${path} -> V2 (expected)`);
|
|
650
|
+
return 'V2';
|
|
651
|
+
}
|
|
652
|
+
throw this.createProtocolMismatchError(expectedProtocol);
|
|
650
653
|
}
|
|
651
654
|
if (expectedProtocol === 'V1') {
|
|
652
655
|
if (yield this.probeProtocolV1(path)) {
|
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.22",
|
|
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",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"lint:fix": "eslint . --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
24
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
23
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.22",
|
|
24
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.22",
|
|
25
25
|
"bytebuffer": "^5.0.1",
|
|
26
26
|
"usb": "^2.14.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "ce94a5ebbe141b0c15db7c68d08085ca1ddb0166"
|
|
29
29
|
}
|
package/src/index.ts
CHANGED
|
@@ -833,12 +833,12 @@ export default class NodeUsbTransport extends ProtocolV2UsbTransportBase<string>
|
|
|
833
833
|
expectedProtocol?: ProtocolType
|
|
834
834
|
): Promise<ProtocolType> {
|
|
835
835
|
if (expectedProtocol === 'V2') {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
836
|
+
if (await this.probeProtocolV2(path)) {
|
|
837
|
+
this.deviceProtocol.set(path, 'V2');
|
|
838
|
+
this.Log?.debug(`[NodeUsbTransport] detectProtocol: path=${path} -> V2 (expected)`);
|
|
839
|
+
return 'V2';
|
|
840
|
+
}
|
|
841
|
+
throw this.createProtocolMismatchError(expectedProtocol);
|
|
842
842
|
}
|
|
843
843
|
|
|
844
844
|
if (expectedProtocol === 'V1') {
|