@onekeyfe/hd-transport-usb 1.2.0-alpha.21 → 1.2.0-alpha.23

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.
@@ -290,19 +290,19 @@ describe('NodeUsbTransport Protocol V2 link lifecycle', () => {
290
290
  expect(transport.getProtocolType(path)).toBeUndefined();
291
291
  });
292
292
 
293
- test('trusts explicit Protocol V2 during bootloader reconnect without probing Ping', async () => {
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).not.toHaveBeenCalled();
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 reacquire without probing explicit V2', async () => {
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.deviceProtocol.set(path, 'V2');
648
- (_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug(`[NodeUsbTransport] detectProtocol: path=${path} -> V2 (expected)`);
649
- return 'V2';
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.21",
3
+ "version": "1.2.0-alpha.23",
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.21",
24
- "@onekeyfe/hd-transport": "1.2.0-alpha.21",
23
+ "@onekeyfe/hd-shared": "1.2.0-alpha.23",
24
+ "@onekeyfe/hd-transport": "1.2.0-alpha.23",
25
25
  "bytebuffer": "^5.0.1",
26
26
  "usb": "^2.14.0"
27
27
  },
28
- "gitHead": "efe594367fb3b196a5126baee7e2aba3e94986cd"
28
+ "gitHead": "7cadb40ca6414053a488756f28a9f413164b235d"
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
- // Bootloader may not answer Ping after an update reboot. An explicit V2 hint means
837
- // the protocol was confirmed earlier; establish the link and let the first command
838
- // verify that USB initialization completed.
839
- this.deviceProtocol.set(path, 'V2');
840
- this.Log?.debug(`[NodeUsbTransport] detectProtocol: path=${path} -> V2 (expected)`);
841
- return 'V2';
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') {