@onekeyfe/hd-transport-react-native 1.2.0-alpha.144 → 1.2.0-alpha.146

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/dist/index.d.ts CHANGED
@@ -123,8 +123,6 @@ declare class ReactNativeBleTransport {
123
123
  private sessionProtocols;
124
124
  /** Endpoints that answered a V2 probe in this transport lifetime. Survives disconnect. */
125
125
  private confirmedProtocolV2;
126
- /** First expected-V2 miss for an unconfirmed endpoint; the next miss is a stale bond. */
127
- private retryableV2Mismatch;
128
126
  /** Consecutive detections that failed while trusting sessionProtocols. */
129
127
  private protocolReprobeFailures;
130
128
  private protocolV2Assemblers;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAIL,UAAU,IAAI,aAAa,EAG5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAS,EAAE,EAChB,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAKjB,KAAK,oBAAoB,EAI1B,MAAM,wBAAwB,CAAC;AA0BhC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAI1C,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;AAgBjE,KAAK,4BAA4B,GAAG,WAAW,CAAC;AAChD,KAAK,0BAA0B,GAAG;IAChC,mBAAmB,EAAE,cAAc,CAAC;IACpC,oBAAoB,EAAE,cAAc,CAAC;CACtC,CAAC;AAkCF,eAAO,MAAM,+BAA+B,UACnC,OAAO,KACb,4BAA4B,GAAG,IAsBjC,CAAC;AAcF,eAAO,MAAM,2BAA2B,QAAS,CA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OAAO,CAAC,wBAAwB;IAgChC,OAAO,CAAC,kBAAkB;YAcZ,cAAc;IA8C5B,OAAO,CAAC,kBAAkB;IA6B1B,OAAO,CAAC,eAAe;IAmDvB,OAAO,CAAC,2BAA2B;IAUnC,OAAO,CAAC,4BAA4B;IAOpC,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,iBAAiB;YAIX,cAAc;YA0Gd,iCAAiC;YAoDjC,eAAe;YAwBf,eAAe;IA0B7B,OAAO,CAAC,4BAA4B;IA2BpC,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,sBAAsB;YAShB,mBAAmB;YAiBnB,qBAAqB;YA2DrB,oBAAoB;YAgCpB,cAAc;YAqEd,iCAAiC;IAiB/C,OAAO,CAAC,8BAA8B;YAQxB,mCAAmC;IAsBjD,OAAO,CAAC,yCAAyC;YAanC,gCAAgC;IAoB9C,OAAO,CAAC,uBAAuB;IAmD/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
package/dist/index.js CHANGED
@@ -311,9 +311,6 @@ function resetProtocolV2BleTuning() {
311
311
  function getProtocolV2BleTuning() {
312
312
  return Object.assign({}, protocolV2BleTuning);
313
313
  }
314
- function inferProtocolHintFromDeviceName(name) {
315
- return /\bpro\s*2\b/i.test(name !== null && name !== void 0 ? name : '') ? 'V2' : undefined;
316
- }
317
314
  function getDeviceDisplayName(device) {
318
315
  return (device === null || device === void 0 ? void 0 : device.name) || (device === null || device === void 0 ? void 0 : device.localName) || null;
319
316
  }
@@ -405,7 +402,6 @@ class ReactNativeBleTransport {
405
402
  this.deviceProtocolHints = new Map();
406
403
  this.sessionProtocols = new Map();
407
404
  this.confirmedProtocolV2 = new Set();
408
- this.retryableV2Mismatch = new Set();
409
405
  this.protocolReprobeFailures = new Map();
410
406
  this.protocolV2Assemblers = new Map();
411
407
  this.protocolV2FrameQueues = new Map();
@@ -723,16 +719,11 @@ class ReactNativeBleTransport {
723
719
  var _a;
724
720
  if (deviceList.every(d => d.id !== device.id)) {
725
721
  const displayName = (_a = getDeviceDisplayName(device)) !== null && _a !== void 0 ? _a : 'Unknown BLE Device';
726
- const protocolHint = inferProtocolHintFromDeviceName(displayName);
727
- if (protocolHint) {
728
- this.deviceProtocolHints.set(device.id, protocolHint);
729
- }
730
722
  deviceList.push(Object.assign(Object.assign({}, device), { name: displayName, commType: 'ble' }));
731
723
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] OneKey BLE device discovered', {
732
724
  deviceId: device.id,
733
725
  name: displayName,
734
726
  serviceUUIDs: device.serviceUUIDs,
735
- protocolHint,
736
727
  });
737
728
  }
738
729
  };
@@ -804,7 +795,7 @@ class ReactNativeBleTransport {
804
795
  });
805
796
  }
806
797
  acquireUnlocked(input) {
807
- var _a, _b;
798
+ var _a;
808
799
  return __awaiter(this, void 0, void 0, function* () {
809
800
  const { uuid, forceCleanRunPromise, expectedProtocol } = input;
810
801
  const cachedTransport = transportCache[uuid];
@@ -918,7 +909,7 @@ class ReactNativeBleTransport {
918
909
  const { writeCharacteristic, notifyCharacteristic } = yield this.resolveCharacteristicsWithTimeout(uuid, acquiredDevice);
919
910
  const protocolHint = expectedProtocol
920
911
  ? undefined
921
- : (_b = (_a = input.protocolHint) !== null && _a !== void 0 ? _a : this.deviceProtocolHints.get(uuid)) !== null && _b !== void 0 ? _b : inferProtocolHintFromDeviceName(getDeviceDisplayName(acquiredDevice));
912
+ : (_a = input.protocolHint) !== null && _a !== void 0 ? _a : this.deviceProtocolHints.get(uuid);
922
913
  yield this.releaseUnlocked(uuid, true);
923
914
  if (protocolHint) {
924
915
  this.deviceProtocolHints.set(uuid, protocolHint);
@@ -1667,7 +1658,6 @@ class ReactNativeBleTransport {
1667
1658
  this.probingProtocols.clear();
1668
1659
  this.sessionProtocols.clear();
1669
1660
  this.confirmedProtocolV2.clear();
1670
- this.retryableV2Mismatch.clear();
1671
1661
  this.protocolReprobeFailures.clear();
1672
1662
  this.writeTimeoutCounts.clear();
1673
1663
  this.connectionSetupTimeoutCounts.clear();
@@ -1681,14 +1671,7 @@ class ReactNativeBleTransport {
1681
1671
  }
1682
1672
  }
1683
1673
  createProtocolMismatchError(expected, uuid) {
1684
- const isStaleV2Bond = expected === 'V2' &&
1685
- (this.confirmedProtocolV2.has(uuid) || this.retryableV2Mismatch.has(uuid));
1686
- if (expected === 'V2' && !isStaleV2Bond) {
1687
- this.retryableV2Mismatch.add(uuid);
1688
- }
1689
- else if (isStaleV2Bond) {
1690
- this.retryableV2Mismatch.delete(uuid);
1691
- }
1674
+ const isStaleV2Bond = expected === 'V2' && this.confirmedProtocolV2.has(uuid);
1692
1675
  return hdShared.ERRORS.TypedError(isStaleV2Bond ? hdShared.HardwareErrorCode.BleDeviceBondError : hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
1693
1676
  }
1694
1677
  createProtocolDetectionError() {
@@ -1736,7 +1719,6 @@ class ReactNativeBleTransport {
1736
1719
  this.deviceProtocol.set(uuid, 'V2');
1737
1720
  this.sessionProtocols.set(uuid, 'V2');
1738
1721
  this.confirmedProtocolV2.add(uuid);
1739
- this.retryableV2Mismatch.delete(uuid);
1740
1722
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] protocol detected', {
1741
1723
  deviceId: uuid,
1742
1724
  protocol: 'V2',
@@ -1770,7 +1752,6 @@ class ReactNativeBleTransport {
1770
1752
  this.sessionProtocols.set(uuid, protocol);
1771
1753
  if (protocol === 'V2') {
1772
1754
  this.confirmedProtocolV2.add(uuid);
1773
- this.retryableV2Mismatch.delete(uuid);
1774
1755
  }
1775
1756
  this.protocolReprobeFailures.delete(uuid);
1776
1757
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] protocol detected', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "1.2.0-alpha.144",
3
+ "version": "1.2.0-alpha.146",
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.144",
24
- "@onekeyfe/hd-shared": "1.2.0-alpha.144",
25
- "@onekeyfe/hd-transport": "1.2.0-alpha.144",
23
+ "@onekeyfe/hd-core": "1.2.0-alpha.146",
24
+ "@onekeyfe/hd-shared": "1.2.0-alpha.146",
25
+ "@onekeyfe/hd-transport": "1.2.0-alpha.146",
26
26
  "@onekeyfe/react-native-ble-utils": "^0.1.6",
27
27
  "react-native-ble-plx": "3.5.1"
28
28
  },
29
- "gitHead": "6240fc52a40bcad467fece58183a54f1af2631fb"
29
+ "gitHead": "447f0806b061695326a6dcba63d8c228b871d01a"
30
30
  }
@@ -405,7 +405,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
405
405
  await transport.release(uuid, true);
406
406
  });
407
407
 
408
- test('actively probes Protocol V2 on iOS when only a name-derived hint is available', async () => {
408
+ test('detects Protocol V2 on iOS without using the BLE name as a protocol hint', async () => {
409
409
  const { transport, uuid, device, sentSeqs, writeCharacteristic } = createHarness({
410
410
  deviceName: 'Pro2 6E9E',
411
411
  });
@@ -415,12 +415,12 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
415
415
  protocolType: 'V2',
416
416
  });
417
417
  expect(device.requestMTU).toHaveBeenCalledWith(247);
418
- expect(writeCharacteristic.writeWithResponse).toHaveBeenCalledTimes(1);
418
+ expect(writeCharacteristic.writeWithResponse.mock.calls.length).toBeGreaterThan(1);
419
419
 
420
420
  await expect(
421
421
  transport.call(uuid, 'Ping', { message: 'first-core-command' })
422
422
  ).resolves.toBeDefined();
423
- expect(sentSeqs).toEqual([1, 2]);
423
+ expect(sentSeqs.filter(seq => seq > 0)).toEqual([1, 2]);
424
424
  await transport.release(uuid, true);
425
425
  });
426
426
 
@@ -441,7 +441,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
441
441
  );
442
442
 
443
443
  test.each(['ios', 'android'] as const)(
444
- 'reports a stale bond on %s after a second expected Protocol V2 probe miss',
444
+ 'keeps a second expected Protocol V2 probe miss retryable on %s',
445
445
  async platform => {
446
446
  setPlatformOS(platform);
447
447
  const { transport, uuid, device } = createHarness();
@@ -451,10 +451,10 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
451
451
  errorCode: HardwareErrorCode.RuntimeError,
452
452
  });
453
453
  await expect(transport.acquire({ uuid, expectedProtocol: 'V2' })).rejects.toMatchObject({
454
- errorCode: HardwareErrorCode.BleDeviceBondError,
454
+ errorCode: HardwareErrorCode.RuntimeError,
455
455
  });
456
456
 
457
- expect(device.cancelConnection).toHaveBeenCalledTimes(1);
457
+ expect(device.cancelConnection).not.toHaveBeenCalled();
458
458
  expect(transport.getProtocolType(uuid)).toBeUndefined();
459
459
  }
460
460
  );
package/src/index.ts CHANGED
@@ -203,10 +203,6 @@ export function getProtocolV2BleTuning() {
203
203
  return { ...protocolV2BleTuning };
204
204
  }
205
205
 
206
- function inferProtocolHintFromDeviceName(name?: string | null): ProtocolType | undefined {
207
- return /\bpro\s*2\b/i.test(name ?? '') ? 'V2' : undefined;
208
- }
209
-
210
206
  function getDeviceDisplayName(device?: Device | null) {
211
207
  return device?.name || device?.localName || null;
212
208
  }
@@ -384,9 +380,6 @@ export default class ReactNativeBleTransport {
384
380
  /** Endpoints that answered a V2 probe in this transport lifetime. Survives disconnect. */
385
381
  private confirmedProtocolV2 = new Set<string>();
386
382
 
387
- /** First expected-V2 miss for an unconfirmed endpoint; the next miss is a stale bond. */
388
- private retryableV2Mismatch = new Set<string>();
389
-
390
383
  /** Consecutive detections that failed while trusting sessionProtocols. */
391
384
  private protocolReprobeFailures: Map<string, number> = new Map();
392
385
 
@@ -771,10 +764,7 @@ export default class ReactNativeBleTransport {
771
764
  const addDevice = (device: Device) => {
772
765
  if (deviceList.every(d => d.id !== device.id)) {
773
766
  const displayName = getDeviceDisplayName(device) ?? 'Unknown BLE Device';
774
- const protocolHint = inferProtocolHintFromDeviceName(displayName);
775
- if (protocolHint) {
776
- this.deviceProtocolHints.set(device.id, protocolHint);
777
- }
767
+
778
768
  deviceList.push({
779
769
  ...device,
780
770
  name: displayName,
@@ -784,7 +774,6 @@ export default class ReactNativeBleTransport {
784
774
  deviceId: device.id,
785
775
  name: displayName,
786
776
  serviceUUIDs: device.serviceUUIDs,
787
- protocolHint,
788
777
  });
789
778
  }
790
779
  };
@@ -1021,9 +1010,7 @@ export default class ReactNativeBleTransport {
1021
1010
 
1022
1011
  const protocolHint = expectedProtocol
1023
1012
  ? undefined
1024
- : input.protocolHint ??
1025
- this.deviceProtocolHints.get(uuid) ??
1026
- inferProtocolHintFromDeviceName(getDeviceDisplayName(acquiredDevice));
1013
+ : input.protocolHint ?? this.deviceProtocolHints.get(uuid);
1027
1014
 
1028
1015
  // release transport before new transport instance
1029
1016
  await this.releaseUnlocked(uuid, true);
@@ -1254,7 +1241,7 @@ export default class ReactNativeBleTransport {
1254
1241
 
1255
1242
  this.deviceProtocol.delete(uuid);
1256
1243
  this.probingProtocols.delete(uuid);
1257
- // Preserve a name-derived hint across disconnects so reconnect can probe V2 first.
1244
+ // Confirmed protocol and caller hints stay in deviceProtocol / protocolHint.
1258
1245
  this.protocolV2Assemblers.get(uuid)?.reset();
1259
1246
  this.protocolV2Assemblers.delete(uuid);
1260
1247
  this.resetProtocolV2Frames(uuid);
@@ -1976,7 +1963,6 @@ export default class ReactNativeBleTransport {
1976
1963
  this.probingProtocols.clear();
1977
1964
  this.sessionProtocols.clear();
1978
1965
  this.confirmedProtocolV2.clear();
1979
- this.retryableV2Mismatch.clear();
1980
1966
  this.protocolReprobeFailures.clear();
1981
1967
  this.writeTimeoutCounts.clear();
1982
1968
  this.connectionSetupTimeoutCounts.clear();
@@ -1990,17 +1976,9 @@ export default class ReactNativeBleTransport {
1990
1976
  }
1991
1977
 
1992
1978
  private createProtocolMismatchError(expected: ProtocolType, uuid: string) {
1993
- // Caller `expectedProtocol: 'V2'` is not proof this endpoint already answered.
1994
- // A first-connect or flaky Ping must stay retryable. A later miss after a
1995
- // confirmed V2 answer, or a second miss on the same uuid, is a stale bond.
1996
- const isStaleV2Bond =
1997
- expected === 'V2' &&
1998
- (this.confirmedProtocolV2.has(uuid) || this.retryableV2Mismatch.has(uuid));
1999
- if (expected === 'V2' && !isStaleV2Bond) {
2000
- this.retryableV2Mismatch.add(uuid);
2001
- } else if (isStaleV2Bond) {
2002
- this.retryableV2Mismatch.delete(uuid);
2003
- }
1979
+ // A generic Ping miss is not a bond failure. Only a later miss after this
1980
+ // endpoint already answered V2, or a native encryption/pairing error, is.
1981
+ const isStaleV2Bond = expected === 'V2' && this.confirmedProtocolV2.has(uuid);
2004
1982
  return ERRORS.TypedError(
2005
1983
  isStaleV2Bond ? HardwareErrorCode.BleDeviceBondError : HardwareErrorCode.RuntimeError,
2006
1984
  `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`
@@ -2066,7 +2044,6 @@ export default class ReactNativeBleTransport {
2066
2044
  this.deviceProtocol.set(uuid, 'V2');
2067
2045
  this.sessionProtocols.set(uuid, 'V2');
2068
2046
  this.confirmedProtocolV2.add(uuid);
2069
- this.retryableV2Mismatch.delete(uuid);
2070
2047
  Log?.debug('[ReactNativeBleTransport] protocol detected', {
2071
2048
  deviceId: uuid,
2072
2049
  protocol: 'V2',
@@ -2111,7 +2088,6 @@ export default class ReactNativeBleTransport {
2111
2088
  this.sessionProtocols.set(uuid, protocol);
2112
2089
  if (protocol === 'V2') {
2113
2090
  this.confirmedProtocolV2.add(uuid);
2114
- this.retryableV2Mismatch.delete(uuid);
2115
2091
  }
2116
2092
  this.protocolReprobeFailures.delete(uuid);
2117
2093
  Log?.debug('[ReactNativeBleTransport] protocol detected', {