@onekeyfe/hd-transport-react-native 1.2.0-alpha.59 → 1.2.0-alpha.60

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAIL,UAAU,IAAI,aAAa,EAE5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAS,EAAE,EAEhB,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAKjB,KAAK,oBAAoB,EAG1B,MAAM,wBAAwB,CAAC;AAoBhC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAK1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAiBjE,KAAK,4BAA4B,GAAG,WAAW,CAAC;AAChD,KAAK,0BAA0B,GAAG;IAChC,mBAAmB,EAAE,cAAc,CAAC;IACpC,oBAAoB,EAAE,cAAc,CAAC;CACtC,CAAC;AAOF,eAAO,MAAM,+BAA+B,UACnC,OAAO,KACb,4BAA4B,GAAG,IAsBjC,CAAC;AASF,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAiBF,wBAAgB,4BAA4B,CAAC,MAAM,GAAE,mBAAwB,QAY5E;AAED,wBAAgB,wBAAwB,SAGvC;AAED,wBAAgB,sBAAsB;;;EAErC;AAkBD,MAAM,MAAM,aAAa,GAAG,oBAAoB,GAAG,MAAM,CAAC;AA4D1D,MAAM,CAAC,OAAO,OAAO,uBA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,OAAO,UAAQ;YAK7B,aAAa;IA8DrB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIjE,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;YA+BlB,cAAc;IA2M5B,IAAI;IAIE,UAAU,CAAC,OAAO,EAAE,MAAM;IA8EhC,MAAM;IASN,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,2BAA2B;IAOnC,OAAO,CAAC,4BAA4B;IAOpC,OAAO,CAAC,kBAAkB;YAMZ,cAAc;YA4Ed,iCAAiC;YAoDjC,eAAe;YAkBf,eAAe;IAwB7B,OAAO,CAAC,4BAA4B;IA2BpC,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,sBAAsB;YAShB,mBAAmB;YAiBnB,qBAAqB;YA0CrB,oBAAoB;YAwCpB,cAAc;IAoC5B,OAAO,CAAC,uBAAuB;IA4C/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
package/dist/index.js CHANGED
@@ -1312,24 +1312,15 @@ class ReactNativeBleTransport {
1312
1312
  }
1313
1313
  }
1314
1314
  detectProtocol(uuid, expectedProtocol, protocolHint, rebuildTransport) {
1315
- var _a;
1316
1315
  return __awaiter(this, void 0, void 0, function* () {
1317
- if (reactNative.Platform.OS === 'ios') {
1318
- const protocol = (_a = expectedProtocol !== null && expectedProtocol !== void 0 ? expectedProtocol : protocolHint) !== null && _a !== void 0 ? _a : 'V1';
1319
- let source = 'ios-legacy-default';
1320
- if (expectedProtocol) {
1321
- source = 'expected';
1322
- }
1323
- else if (protocolHint) {
1324
- source = 'hint';
1325
- }
1326
- this.deviceProtocol.set(uuid, protocol);
1316
+ if (reactNative.Platform.OS === 'ios' && expectedProtocol) {
1317
+ this.deviceProtocol.set(uuid, expectedProtocol);
1327
1318
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] protocol selected', {
1328
1319
  deviceId: uuid,
1329
- protocol,
1330
- source,
1320
+ protocol: expectedProtocol,
1321
+ source: 'expected',
1331
1322
  });
1332
- return protocol;
1323
+ return expectedProtocol;
1333
1324
  }
1334
1325
  if (expectedProtocol === 'V1') {
1335
1326
  if (yield this.probeProtocolV1(uuid)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "1.2.0-alpha.59",
3
+ "version": "1.2.0-alpha.60",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,11 +20,11 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-core": "1.2.0-alpha.59",
24
- "@onekeyfe/hd-shared": "1.2.0-alpha.59",
25
- "@onekeyfe/hd-transport": "1.2.0-alpha.59",
23
+ "@onekeyfe/hd-core": "1.2.0-alpha.60",
24
+ "@onekeyfe/hd-shared": "1.2.0-alpha.60",
25
+ "@onekeyfe/hd-transport": "1.2.0-alpha.60",
26
26
  "@onekeyfe/react-native-ble-utils": "^0.1.6",
27
27
  "react-native-ble-plx": "3.5.1"
28
28
  },
29
- "gitHead": "98794c3032aab55e13fb2afedc645d8281141d5f"
29
+ "gitHead": "bde29baa04ac87453fd0eff54fd1cafe905f0ec8"
30
30
  }
@@ -333,7 +333,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
333
333
  respondOnWriteCount: [1, 2],
334
334
  });
335
335
 
336
- await expect(transport.acquire({ uuid })).resolves.toEqual({
336
+ await expect(transport.acquire({ uuid, expectedProtocol: 'V1' })).resolves.toEqual({
337
337
  uuid,
338
338
  protocolType: 'V1',
339
339
  });
@@ -355,7 +355,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
355
355
  isWritableWithResponse: false,
356
356
  });
357
357
 
358
- await transport.acquire({ uuid });
358
+ await transport.acquire({ uuid, expectedProtocol: 'V1' });
359
359
  await expect(transport.call(uuid, 'Initialize', {}, { timeoutMs: 50 })).resolves.toBeDefined();
360
360
 
361
361
  expect(writeCharacteristic.writeWithResponse).not.toHaveBeenCalled();
@@ -367,7 +367,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
367
367
  const { transport, uuid, writeCharacteristic } = createV1Harness();
368
368
  const writeError = new Error('write with response failed');
369
369
 
370
- await transport.acquire({ uuid });
370
+ await transport.acquire({ uuid, expectedProtocol: 'V1' });
371
371
  writeCharacteristic.writeWithResponse.mockRejectedValueOnce(writeError);
372
372
 
373
373
  await expect(transport.call(uuid, 'Initialize', {}, { timeoutMs: 50 })).rejects.toMatchObject({
@@ -378,7 +378,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
378
378
  await transport.release(uuid, true);
379
379
  });
380
380
 
381
- test('keeps the first Core command as the first iOS BLE request for a Protocol V2 device', async () => {
381
+ test('actively probes Protocol V2 on iOS when only a name-derived hint is available', async () => {
382
382
  const { transport, uuid, sentSeqs, writeCharacteristic } = createHarness({
383
383
  deviceName: 'Pro2 6E9E',
384
384
  });
@@ -387,12 +387,32 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
387
387
  uuid,
388
388
  protocolType: 'V2',
389
389
  });
390
- expect(writeCharacteristic.writeWithoutResponse).not.toHaveBeenCalled();
390
+ expect(writeCharacteristic.writeWithResponse).toHaveBeenCalledTimes(1);
391
391
 
392
392
  await expect(
393
393
  transport.call(uuid, 'Ping', { message: 'first-core-command' })
394
394
  ).resolves.toBeDefined();
395
- expect(sentSeqs).toEqual([1]);
395
+ expect(sentSeqs).toEqual([1, 2]);
396
+ await transport.release(uuid, true);
397
+ });
398
+
399
+ test('falls back to the other active probe on iOS when protocol metadata is absent', async () => {
400
+ const { transport, uuid } = createHarness({ deviceName: 'OneKey' });
401
+ const probeProtocolV1 = jest
402
+ .spyOn(transport as any, 'probeProtocolV1')
403
+ .mockResolvedValue(false);
404
+ const probeProtocolV2 = jest.spyOn(transport as any, 'probeProtocolV2').mockResolvedValue(true);
405
+
406
+ await expect(transport.acquire({ uuid })).resolves.toEqual({
407
+ uuid,
408
+ protocolType: 'V2',
409
+ });
410
+
411
+ expect(probeProtocolV1).toHaveBeenCalledTimes(1);
412
+ expect(probeProtocolV2).toHaveBeenCalledTimes(1);
413
+ expect(probeProtocolV1.mock.invocationCallOrder[0]).toBeLessThan(
414
+ probeProtocolV2.mock.invocationCallOrder[0]
415
+ );
396
416
  await transport.release(uuid, true);
397
417
  });
398
418
 
@@ -467,10 +487,10 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
467
487
  resetProtocolV2BleTuning();
468
488
  });
469
489
 
470
- test('starts the Protocol V2 sequence with the first Core call on iOS', async () => {
490
+ test('uses the first Protocol V2 sequence for the first Core call when protocol is known', async () => {
471
491
  const { transport, uuid, sentSeqs } = createHarness();
472
492
 
473
- await transport.acquire({ uuid });
493
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
474
494
  await transport.call(uuid, 'Ping', { message: 'first-core-command' });
475
495
 
476
496
  expect(sentSeqs).toEqual([1]);
@@ -480,7 +500,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
480
500
  test('rejects the active Protocol V2 reader when the current monitor errors', async () => {
481
501
  const harness = createHarness();
482
502
  const { transport, uuid, sentSeqs } = harness;
483
- await transport.acquire({ uuid });
503
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
484
504
  harness.setShouldRespond(false);
485
505
 
486
506
  const call = transport.call(uuid, 'Ping', { message: 'wait-for-monitor' }, { timeoutMs: 50 });
@@ -502,10 +522,10 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
502
522
  test('retains the sequence cursor when a new monitor generation is acquired', async () => {
503
523
  const { transport, uuid, sentSeqs } = createHarness();
504
524
 
505
- await transport.acquire({ uuid });
525
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
506
526
  await transport.call(uuid, 'Ping', { message: 'first-generation' });
507
527
  await transport.release(uuid, true);
508
- await transport.acquire({ uuid });
528
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
509
529
  await transport.call(uuid, 'Ping', { message: 'second-generation' });
510
530
 
511
531
  expect(sentSeqs).toEqual([1, 2]);
@@ -515,7 +535,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
515
535
  test('uses withResponse for consecutive iOS Protocol V2 control calls without releasing', async () => {
516
536
  const { transport, uuid, writeCharacteristic } = createHarness();
517
537
 
518
- await transport.acquire({ uuid });
538
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
519
539
  const releaseNative = jest.spyOn(transport as any, 'releaseNative');
520
540
  expect(writeCharacteristic.writeWithoutResponse).not.toHaveBeenCalled();
521
541
  expect(writeCharacteristic.writeWithResponse).not.toHaveBeenCalled();
@@ -533,7 +553,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
533
553
  test('keeps iOS Protocol V2 high-volume calls on withoutResponse', async () => {
534
554
  const { transport, uuid, writeCharacteristic } = createHarness();
535
555
 
536
- await transport.acquire({ uuid });
556
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
537
557
 
538
558
  await transport.call(uuid, 'FileWrite', {});
539
559
  expect(writeCharacteristic.writeWithoutResponse).toHaveBeenCalledTimes(1);
@@ -544,7 +564,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
544
564
  test('uses withResponse for an iOS Protocol V2 firmware file write when requested', async () => {
545
565
  const { transport, uuid, writeCharacteristic } = createHarness();
546
566
 
547
- await transport.acquire({ uuid });
567
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
548
568
 
549
569
  await transport.call(uuid, 'FileWrite', {}, { writeWithResponse: true });
550
570
  expect(writeCharacteristic.writeWithResponse).toHaveBeenCalledTimes(1);
@@ -557,7 +577,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
557
577
  isWritableWithResponse: false,
558
578
  });
559
579
 
560
- await transport.acquire({ uuid });
580
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
561
581
  await transport.call(uuid, 'ProtocolInfoRequest', {});
562
582
 
563
583
  expect(writeCharacteristic.writeWithResponse).not.toHaveBeenCalled();
@@ -635,7 +655,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
635
655
  test('rejects an active Protocol V2 reader when disconnect resets the link', async () => {
636
656
  const harness = createHarness();
637
657
  const { transport, uuid, sentSeqs } = harness;
638
- await transport.acquire({ uuid });
658
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
639
659
  harness.setShouldRespond(false);
640
660
 
641
661
  const call = transport.call(uuid, 'Ping', { message: 'disconnect' }, { timeoutMs: 50 });
@@ -655,7 +675,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
655
675
  const disconnectListener = jest.fn();
656
676
  harness.emitter.on(TRANSPORT_EVENT.DEVICE_DISCONNECT, disconnectListener);
657
677
 
658
- await harness.transport.acquire({ uuid: harness.uuid });
678
+ await harness.transport.acquire({ uuid: harness.uuid, expectedProtocol: 'V2' });
659
679
  harness.emitDisconnect();
660
680
  await harness.transport.disconnect(harness.uuid);
661
681
 
package/src/index.ts CHANGED
@@ -1444,21 +1444,14 @@ export default class ReactNativeBleTransport {
1444
1444
  protocolHint?: ProtocolType,
1445
1445
  rebuildTransport?: () => Promise<void>
1446
1446
  ): Promise<ProtocolType> {
1447
- if (Platform.OS === 'ios') {
1448
- const protocol = expectedProtocol ?? protocolHint ?? 'V1';
1449
- let source = 'ios-legacy-default';
1450
- if (expectedProtocol) {
1451
- source = 'expected';
1452
- } else if (protocolHint) {
1453
- source = 'hint';
1454
- }
1455
- this.deviceProtocol.set(uuid, protocol);
1447
+ if (Platform.OS === 'ios' && expectedProtocol) {
1448
+ this.deviceProtocol.set(uuid, expectedProtocol);
1456
1449
  Log?.debug('[ReactNativeBleTransport] protocol selected', {
1457
1450
  deviceId: uuid,
1458
- protocol,
1459
- source,
1451
+ protocol: expectedProtocol,
1452
+ source: 'expected',
1460
1453
  });
1461
- return protocol;
1454
+ return expectedProtocol;
1462
1455
  }
1463
1456
 
1464
1457
  if (expectedProtocol === 'V1') {