@onekeyfe/hd-transport-react-native 1.2.0-alpha.184 → 1.2.0-alpha.186

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":"bleStaleBond.d.ts","sourceRoot":"","sources":["../src/bleStaleBond.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,2BAA2B,EAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,2BAA2B,EAAE,CAAC;AAkBvC,eAAO,MAAM,yBAAyB,UAAW,OAAO,KAAG,OAe1D,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAAW,OAAO,UAiBzD,CAAC"}
1
+ {"version":3,"file":"bleStaleBond.d.ts","sourceRoot":"","sources":["../src/bleStaleBond.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,2BAA2B,EAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,2BAA2B,EAAE,CAAC;AAkBvC,eAAO,MAAM,yBAAyB,UAAW,OAAO,KAAG,OAe1D,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAAW,OAAO,UAkBzD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,UAAU,IAAI,aAAa,EAG5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAS,EAAE,EAChB,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAKjB,KAAK,oBAAoB,EAI1B,MAAM,wBAAwB,CAAC;AA+BhC,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,e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OAAO,CAAC,qBAAqB;YAOf,mBAAmB;YAiBnB,qBAAqB;YAgErB,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
@@ -218,8 +218,9 @@ const toBleStaleBondHardwareError = (error) => {
218
218
  }
219
219
  const nativeError = (error !== null && error !== void 0 ? error : {});
220
220
  const text = nativeErrorText(nativeError);
221
+ const normalizedText = text.toLowerCase();
221
222
  const peerRemoved = nativeError.iosErrorCode === IOS_PEER_REMOVED_PAIRING_INFORMATION ||
222
- text.includes('Peer removed pairing information');
223
+ normalizedText.includes('peer removed pairing information');
223
224
  return hdShared.ERRORS.TypedError(peerRemoved
224
225
  ? hdShared.HardwareErrorCode.BlePeerRemovedPairingInformation
225
226
  : hdShared.HardwareErrorCode.BleDeviceBondError, text || undefined);
@@ -990,7 +991,9 @@ class ReactNativeBleTransport {
990
991
  if (!expectedProtocol) {
991
992
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'skipProtocolProbe requires an expected BLE protocol');
992
993
  }
993
- if (this.sessionProtocols.get(uuid) !== expectedProtocol) {
994
+ const hasConfirmedProtocol = this.sessionProtocols.get(uuid) === expectedProtocol ||
995
+ (expectedProtocol === 'V2' && this.confirmedProtocolV2.has(uuid));
996
+ if (!hasConfirmedProtocol) {
994
997
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'skipProtocolProbe requires a previously confirmed protocol for this BLE endpoint');
995
998
  }
996
999
  this.deviceProtocol.set(uuid, expectedProtocol);
@@ -1768,7 +1771,6 @@ class ReactNativeBleTransport {
1768
1771
  this.staleBondErrors.clear();
1769
1772
  this.acquiringProtocolV2.clear();
1770
1773
  this.sessionProtocols.clear();
1771
- this.confirmedProtocolV2.clear();
1772
1774
  this.protocolReprobeFailures.clear();
1773
1775
  this.writeTimeoutCounts.clear();
1774
1776
  this.connectionSetupTimeoutCounts.clear();
@@ -1781,9 +1783,8 @@ class ReactNativeBleTransport {
1781
1783
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] BLE manager destroy failed (ignored):', error);
1782
1784
  }
1783
1785
  }
1784
- createProtocolMismatchError(expected, uuid) {
1785
- const isStaleV2Bond = expected === 'V2' && this.confirmedProtocolV2.has(uuid);
1786
- return hdShared.ERRORS.TypedError(isStaleV2Bond ? hdShared.HardwareErrorCode.BleDeviceBondError : hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
1786
+ createProtocolMismatchError(expected) {
1787
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
1787
1788
  }
1788
1789
  createProtocolDetectionError() {
1789
1790
  return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, 'Unable to detect BLE protocol: device did not respond to Protocol V1 GetFeatures or Protocol V2 Ping');
@@ -1827,7 +1828,7 @@ class ReactNativeBleTransport {
1827
1828
  });
1828
1829
  return 'V2';
1829
1830
  }
1830
- throw this.createProtocolMismatchError(expectedProtocol, uuid);
1831
+ throw this.createProtocolMismatchError(expectedProtocol);
1831
1832
  }
1832
1833
  const sessionProtocol = this.sessionProtocols.get(uuid);
1833
1834
  const reprobeFailures = (_a = this.protocolReprobeFailures.get(uuid)) !== null && _a !== void 0 ? _a : 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "1.2.0-alpha.184",
3
+ "version": "1.2.0-alpha.186",
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.184",
24
- "@onekeyfe/hd-shared": "1.2.0-alpha.184",
25
- "@onekeyfe/hd-transport": "1.2.0-alpha.184",
23
+ "@onekeyfe/hd-core": "1.2.0-alpha.186",
24
+ "@onekeyfe/hd-shared": "1.2.0-alpha.186",
25
+ "@onekeyfe/hd-transport": "1.2.0-alpha.186",
26
26
  "@onekeyfe/react-native-ble-utils": "^0.1.6",
27
27
  "react-native-ble-plx": "3.5.1"
28
28
  },
29
- "gitHead": "833ce30a921a49ca0ed60cfc491062c26f5b90ae"
29
+ "gitHead": "d4b7f8e0e308ed4b95b1d82e385e1ec4b3e0e3f6"
30
30
  }
@@ -16,6 +16,14 @@ describe('native BLE stale bond mapping', () => {
16
16
  { iosErrorCode: 14, reason: 'Peer removed pairing information' },
17
17
  HardwareErrorCode.BlePeerRemovedPairingInformation,
18
18
  ],
19
+ [
20
+ { reason: 'peer removed pairing information' },
21
+ HardwareErrorCode.BlePeerRemovedPairingInformation,
22
+ ],
23
+ [
24
+ { message: 'PEER REMOVED PAIRING INFORMATION' },
25
+ HardwareErrorCode.BlePeerRemovedPairingInformation,
26
+ ],
19
27
  ])('maps %j to %s', (nativeError, errorCode) => {
20
28
  expect(isNativeBleStaleBondError(nativeError)).toBe(true);
21
29
  expect(toBleStaleBondHardwareError(nativeError)).toMatchObject({ errorCode });
@@ -505,6 +505,33 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
505
505
  expect(transport.getProtocolType(uuid)).toBeUndefined();
506
506
  });
507
507
 
508
+ test('keeps confirmed V2 authorization across a BLE manager reset', async () => {
509
+ const { transport, uuid, device, bleManager, writeCharacteristic } = createHarness();
510
+ const probeProtocolV2 = jest.spyOn(transport as any, 'probeProtocolV2');
511
+
512
+ await transport.acquire({ uuid, expectedProtocol: 'V2' });
513
+ expect(probeProtocolV2).toHaveBeenCalledTimes(1);
514
+
515
+ (transport as any).resetPlxManager();
516
+ transport.blePlxManager = bleManager as any;
517
+ device.connect = jest.fn().mockResolvedValue(device);
518
+ device.isConnected.mockResolvedValueOnce(false);
519
+ writeCharacteristic.writeWithResponse.mockClear();
520
+ writeCharacteristic.writeWithoutResponse.mockClear();
521
+
522
+ await expect(
523
+ transport.acquire({ uuid, expectedProtocol: 'V2', skipProtocolProbe: true })
524
+ ).resolves.toEqual({
525
+ uuid,
526
+ protocolType: 'V2',
527
+ });
528
+
529
+ expect(probeProtocolV2).toHaveBeenCalledTimes(1);
530
+ expect(writeCharacteristic.writeWithResponse).not.toHaveBeenCalled();
531
+ expect(writeCharacteristic.writeWithoutResponse).not.toHaveBeenCalled();
532
+ await transport.release(uuid, true);
533
+ });
534
+
508
535
  test.each(['ios', 'android'] as const)(
509
536
  'keeps a first expected Protocol V2 probe miss retryable on %s',
510
537
  async platform => {
@@ -570,7 +597,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
570
597
  );
571
598
 
572
599
  test.each(['ios', 'android'] as const)(
573
- 'reports a stale bond on %s when a previously confirmed Protocol V2 device stops responding',
600
+ 'keeps a confirmed Protocol V2 probe miss retryable on %s without native bond evidence',
574
601
  async platform => {
575
602
  setPlatformOS(platform);
576
603
  const { transport, uuid, device } = createHarness();
@@ -579,10 +606,10 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
579
606
  jest.spyOn(transport as any, 'probeProtocolV2').mockResolvedValue(false);
580
607
 
581
608
  await expect(transport.acquire({ uuid, expectedProtocol: 'V2' })).rejects.toMatchObject({
582
- errorCode: HardwareErrorCode.BleDeviceBondError,
609
+ errorCode: HardwareErrorCode.RuntimeError,
583
610
  });
584
611
 
585
- expect(device.cancelConnection).toHaveBeenCalled();
612
+ expect(device.cancelConnection).not.toHaveBeenCalled();
586
613
  expect(transport.getProtocolType(uuid)).toBeUndefined();
587
614
  }
588
615
  );
@@ -47,9 +47,10 @@ export const toBleStaleBondHardwareError = (error: unknown) => {
47
47
 
48
48
  const nativeError = (error ?? {}) as NativeBleErrorFields;
49
49
  const text = nativeErrorText(nativeError);
50
+ const normalizedText = text.toLowerCase();
50
51
  const peerRemoved =
51
52
  nativeError.iosErrorCode === IOS_PEER_REMOVED_PAIRING_INFORMATION ||
52
- text.includes('Peer removed pairing information');
53
+ normalizedText.includes('peer removed pairing information');
53
54
 
54
55
  return ERRORS.TypedError(
55
56
  peerRemoved
package/src/index.ts CHANGED
@@ -1105,7 +1105,10 @@ export default class ReactNativeBleTransport {
1105
1105
  'skipProtocolProbe requires an expected BLE protocol'
1106
1106
  );
1107
1107
  }
1108
- if (this.sessionProtocols.get(uuid) !== expectedProtocol) {
1108
+ const hasConfirmedProtocol =
1109
+ this.sessionProtocols.get(uuid) === expectedProtocol ||
1110
+ (expectedProtocol === 'V2' && this.confirmedProtocolV2.has(uuid));
1111
+ if (!hasConfirmedProtocol) {
1109
1112
  throw ERRORS.TypedError(
1110
1113
  HardwareErrorCode.RuntimeError,
1111
1114
  'skipProtocolProbe requires a previously confirmed protocol for this BLE endpoint'
@@ -2097,7 +2100,8 @@ export default class ReactNativeBleTransport {
2097
2100
  this.staleBondErrors.clear();
2098
2101
  this.acquiringProtocolV2.clear();
2099
2102
  this.sessionProtocols.clear();
2100
- this.confirmedProtocolV2.clear();
2103
+ // Keep transport-lifetime V2 proof so the same endpoint can finish a no-probe
2104
+ // firmware reconnect after the native BLE manager is recreated.
2101
2105
  this.protocolReprobeFailures.clear();
2102
2106
  this.writeTimeoutCounts.clear();
2103
2107
  this.connectionSetupTimeoutCounts.clear();
@@ -2110,12 +2114,11 @@ export default class ReactNativeBleTransport {
2110
2114
  }
2111
2115
  }
2112
2116
 
2113
- private createProtocolMismatchError(expected: ProtocolType, uuid: string) {
2114
- // A generic Ping miss is not a bond failure. Only a later miss after this
2115
- // endpoint already answered V2, or a native encryption/pairing error, is.
2116
- const isStaleV2Bond = expected === 'V2' && this.confirmedProtocolV2.has(uuid);
2117
+ private createProtocolMismatchError(expected: ProtocolType) {
2118
+ // A protocol probe miss alone does not prove that the OS bond is stale.
2119
+ // Native authentication/encryption failures are mapped separately.
2117
2120
  return ERRORS.TypedError(
2118
- isStaleV2Bond ? HardwareErrorCode.BleDeviceBondError : HardwareErrorCode.RuntimeError,
2121
+ HardwareErrorCode.RuntimeError,
2119
2122
  `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`
2120
2123
  );
2121
2124
  }
@@ -2183,7 +2186,7 @@ export default class ReactNativeBleTransport {
2183
2186
  });
2184
2187
  return 'V2';
2185
2188
  }
2186
- throw this.createProtocolMismatchError(expectedProtocol, uuid);
2189
+ throw this.createProtocolMismatchError(expectedProtocol);
2187
2190
  }
2188
2191
 
2189
2192
  // Protocol must be actively probed after connection. Name, PID, and descriptors only