@onekeyfe/hd-shared 1.2.2-alpha.11 → 1.2.2-alpha.13

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.
@@ -87,6 +87,7 @@ export declare const HardwareErrorCode: {
87
87
  readonly BlePoweredOff: 721;
88
88
  readonly BleUnsupported: 722;
89
89
  readonly BleUnavailableWhileUsbConnected: 723;
90
+ readonly BleBondInvalid: 724;
90
91
  readonly RuntimeError: 800;
91
92
  readonly PinInvalid: 801;
92
93
  readonly PinCancelled: 802;
@@ -1 +1 @@
1
- {"version":3,"file":"HardwareError.d.ts","sourceRoot":"","sources":["../src/HardwareError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED,KAAK,OAAO,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE5C,KAAK,+BAA+B,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,OAAO,iBAAiB,CAAC,GAAG,MAAM;CAAE,CAAC;AAE5F,KAAK,cAAc,GAAG,OAAO,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAsCxD,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAS,EAAE,cAAc,CAAkC;IAE3D,OAAO,SAAM;IAEb,MAAM,EAAE,GAAG,CAAM;gBAEL,aAAa,EAAE,cAAc,GAAG,MAAM;CAmBnD;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAybpB,CAAC;AAEX,eAA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AAC;AAEF,QAAA,MAAM,sCAAsC;oBAM1B,MAAM;oBACN,MAAM;;;mBAcvB,CAAC;AAEF,QAAA,MAAM,yCAAyC,cAClC,MAAM,GAAG,SAAS,YACnB,MAAM,GAAG,SAAS,iBACb,CAAC,UAAU,GAAG,KAAK,CAAC,EAAE,oBACnB;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,kBAsBF,CAAC;AAEF,QAAA,MAAM,6BAA6B,mBACjB,MAAM,qBACH,MAAM,eACZ,MAAM,kBAQpB,CAAC;AAEF,QAAA,MAAM,4BAA4B,aACtB,MAAM,aACL,MAAM,cACL,MAAM,cACN,MAAM,aACP,MAAM,kBAWlB,CAAC;AAEF,QAAA,MAAM,iCAAiC,eAAgB,MAAM,gBAAgB,aAAa,kBAItF,CAAC;AAEL,OAAO,EACL,uCAAuC,EACvC,sCAAsC,EACtC,yCAAyC,EACzC,6BAA6B,EAC7B,4BAA4B,EAC5B,iCAAiC,GAClC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -361,6 +361,11 @@ declare const HardwareErrorCode: {
361
361
  readonly BlePoweredOff: 721;
362
362
  readonly BleUnsupported: 722;
363
363
  readonly BleUnavailableWhileUsbConnected: 723;
364
+ /**
365
+ * The host OS still has a stale BLE bond after the device pairing state was reset.
366
+ * The user must forget the device in system Bluetooth settings and pair it again.
367
+ */
368
+ readonly BleBondInvalid: 724;
364
369
  /**
365
370
  * Hardware runtiome errors
366
371
  */
package/dist/index.js CHANGED
@@ -136,6 +136,7 @@ const HardwareErrorCode = {
136
136
  BlePoweredOff: 721,
137
137
  BleUnsupported: 722,
138
138
  BleUnavailableWhileUsbConnected: 723,
139
+ BleBondInvalid: 724,
139
140
  RuntimeError: 800,
140
141
  PinInvalid: 801,
141
142
  PinCancelled: 802,
@@ -244,6 +245,7 @@ const HardwareErrorCodeMessage = {
244
245
  [HardwareErrorCode.BlePoweredOff]: 'Bluetooth is turned off',
245
246
  [HardwareErrorCode.BleUnsupported]: 'Bluetooth is not supported on this device',
246
247
  [HardwareErrorCode.BleUnavailableWhileUsbConnected]: 'Bluetooth is unavailable while USB is connected. Unplug USB and try again.',
248
+ [HardwareErrorCode.BleBondInvalid]: 'Bluetooth pairing information is no longer valid. Forget the device in system Bluetooth settings and pair it again.',
247
249
  [HardwareErrorCode.RuntimeError]: 'Runtime error',
248
250
  [HardwareErrorCode.PinInvalid]: 'Pin invalid',
249
251
  [HardwareErrorCode.PinCancelled]: 'Pin cancelled',
@@ -289,7 +291,8 @@ const TypedError = (hardwareError, message, params) => {
289
291
  const isBleStaleBondHardwareError = (error) => {
290
292
  const code = error === null || error === void 0 ? void 0 : error.errorCode;
291
293
  return (code === HardwareErrorCode.BleDeviceBondError ||
292
- code === HardwareErrorCode.BlePeerRemovedPairingInformation);
294
+ code === HardwareErrorCode.BlePeerRemovedPairingInformation ||
295
+ code === HardwareErrorCode.BleBondInvalid);
293
296
  };
294
297
  const isBleStaleBondErrorText = (text) => {
295
298
  const value = text.toLowerCase();
@@ -297,6 +300,7 @@ const isBleStaleBondErrorText = (text) => {
297
300
  value.includes('insufficient encryption') ||
298
301
  value.includes('peer removed pairing information') ||
299
302
  value.includes('cberrordomain:14') ||
303
+ value.includes('cbatterrordomain:14') ||
300
304
  value.includes('gatt_insuf_authentication'));
301
305
  };
302
306
  const serializeError = (payload) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-shared",
3
- "version": "1.2.2-alpha.11",
3
+ "version": "1.2.2-alpha.13",
4
4
  "description": "Hardware SDK's shared tool library",
5
5
  "keywords": [
6
6
  "Hardware-SDK",
@@ -26,5 +26,5 @@
26
26
  "lint": "eslint .",
27
27
  "lint:fix": "eslint . --fix"
28
28
  },
29
- "gitHead": "8928100acb893d72361eb74422d5e2a0f7af77d8"
29
+ "gitHead": "c901cdc6b474d015c7f50390fc5dc3db0ca4fbdb"
30
30
  }
@@ -44,12 +44,20 @@ describe('HardwareErrorCode compatibility', () => {
44
44
  });
45
45
  });
46
46
 
47
+ test('reserves a dedicated hd-core code for an invalid OS BLE bond', () => {
48
+ expect(HardwareErrorCode.BleBondInvalid).toBe(724);
49
+ expect(HardwareErrorCodeMessage[HardwareErrorCode.BleBondInvalid]).toContain(
50
+ 'pairing information is no longer valid'
51
+ );
52
+ });
53
+
47
54
  test('recognizes the macOS CoreBluetooth stale-pairing error without matching generic failures', () => {
48
55
  expect(
49
56
  isBleStaleBondErrorText(
50
57
  'CBErrorDomain:14 Peer removed pairing information on the device side'
51
58
  )
52
59
  ).toBe(true);
60
+ expect(isBleStaleBondErrorText('CBATTErrorDomain:14 localized native message')).toBe(true);
53
61
  expect(isBleStaleBondErrorText('connection failed')).toBe(false);
54
62
  });
55
63
  });
@@ -346,6 +346,11 @@ export const HardwareErrorCode = {
346
346
  BlePoweredOff: 721,
347
347
  BleUnsupported: 722,
348
348
  BleUnavailableWhileUsbConnected: 723,
349
+ /**
350
+ * The host OS still has a stale BLE bond after the device pairing state was reset.
351
+ * The user must forget the device in system Bluetooth settings and pair it again.
352
+ */
353
+ BleBondInvalid: 724,
349
354
 
350
355
  /**
351
356
  * Hardware runtiome errors
@@ -624,6 +629,8 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
624
629
  [HardwareErrorCode.BleUnsupported]: 'Bluetooth is not supported on this device',
625
630
  [HardwareErrorCode.BleUnavailableWhileUsbConnected]:
626
631
  'Bluetooth is unavailable while USB is connected. Unplug USB and try again.',
632
+ [HardwareErrorCode.BleBondInvalid]:
633
+ 'Bluetooth pairing information is no longer valid. Forget the device in system Bluetooth settings and pair it again.',
627
634
 
628
635
  /**
629
636
  * Runtime Error
@@ -687,7 +694,8 @@ export const isBleStaleBondHardwareError = (error: unknown): boolean => {
687
694
  const code = (error as { errorCode?: unknown })?.errorCode;
688
695
  return (
689
696
  code === HardwareErrorCode.BleDeviceBondError ||
690
- code === HardwareErrorCode.BlePeerRemovedPairingInformation
697
+ code === HardwareErrorCode.BlePeerRemovedPairingInformation ||
698
+ code === HardwareErrorCode.BleBondInvalid
691
699
  );
692
700
  };
693
701
 
@@ -698,6 +706,7 @@ export const isBleStaleBondErrorText = (text: string): boolean => {
698
706
  value.includes('insufficient encryption') ||
699
707
  value.includes('peer removed pairing information') ||
700
708
  value.includes('cberrordomain:14') ||
709
+ value.includes('cbatterrordomain:14') ||
701
710
  value.includes('gatt_insuf_authentication')
702
711
  );
703
712
  };