@onekeyfe/hd-shared 1.2.2-alpha.15 → 1.2.2-alpha.17

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,
@@ -183,7 +184,7 @@ const HardwareErrorCodeMessage = {
183
184
  [HardwareErrorCode.DeviceInterruptedFromOutside]: 'Device interrupted',
184
185
  [HardwareErrorCode.DeviceInterruptedFromUser]: 'Device interrupted',
185
186
  [HardwareErrorCode.RequiredButInBootloaderMode]: 'Device should be in bootloader mode',
186
- [HardwareErrorCode.DeviceCheckDeviceIdError]: 'Device Id in the features is not same.',
187
+ [HardwareErrorCode.DeviceCheckDeviceIdError]: 'The connected device does not match this wallet. Reconnect the correct device, or add it again after a reset or recovery.',
187
188
  [HardwareErrorCode.DeviceNotSupportPassphrase]: 'Device not support passphrase',
188
189
  [HardwareErrorCode.DeviceCheckPassphraseStateError]: 'Device passphrase state error',
189
190
  [HardwareErrorCode.DeviceNotOpenedPassphrase]: 'Device not opened passphrase',
@@ -191,7 +192,7 @@ const HardwareErrorCodeMessage = {
191
192
  [HardwareErrorCode.DeviceDetectInBootloaderMode]: 'Device in bootloader mode',
192
193
  [HardwareErrorCode.NotAllowInBootloaderMode]: 'Device not allow in bootloader mode',
193
194
  [HardwareErrorCode.DeviceBusy]: 'Device is busy',
194
- [HardwareErrorCode.DeviceCheckUnlockTypeError]: 'Device check unlock type not match error',
195
+ [HardwareErrorCode.DeviceCheckUnlockTypeError]: 'The unlocked wallet does not match the selected wallet. Use the corresponding PIN or passphrase and try again.',
195
196
  [HardwareErrorCode.NotInitialized]: 'Not initialized',
196
197
  [HardwareErrorCode.IFrameNotInitialized]: 'IFrame not initialized',
197
198
  [HardwareErrorCode.IFrameAleradyInitialized]: 'IFrame alerady initialized',
@@ -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,13 +291,15 @@ 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();
296
299
  return (value.includes('encryption is insufficient') ||
297
300
  value.includes('insufficient encryption') ||
298
301
  value.includes('peer removed pairing information') ||
302
+ value.includes('cberrordomain:14') ||
299
303
  value.includes('gatt_insuf_authentication'));
300
304
  };
301
305
  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.15",
3
+ "version": "1.2.2-alpha.17",
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": "ea66eff5817385ee2144d8e037c385342e44e21f"
29
+ "gitHead": "b6c48b842d1c325dcd5ce42c03a07ee4377002dd"
30
30
  }
@@ -2,6 +2,7 @@ import {
2
2
  HardwareErrorCode,
3
3
  HardwareErrorCodeMessage,
4
4
  TypedError,
5
+ isBleStaleBondErrorText,
5
6
  serializeError,
6
7
  } from './HardwareError';
7
8
 
@@ -12,6 +13,15 @@ describe('HardwareErrorCode compatibility', () => {
12
13
  expect(HardwareErrorCode.WalletSessionInvalid).toBe(831);
13
14
  });
14
15
 
16
+ test('uses actionable wallet-context messages', () => {
17
+ expect(HardwareErrorCodeMessage[HardwareErrorCode.DeviceCheckDeviceIdError]).toContain(
18
+ 'does not match this wallet'
19
+ );
20
+ expect(HardwareErrorCodeMessage[HardwareErrorCode.DeviceCheckUnlockTypeError]).toContain(
21
+ 'corresponding PIN or passphrase'
22
+ );
23
+ });
24
+
15
25
  test('reserves the BLE and USB conflict code for app error mapping', () => {
16
26
  expect(HardwareErrorCode.BleUnavailableWhileUsbConnected).toBe(723);
17
27
  expect(HardwareErrorCodeMessage[HardwareErrorCode.BleUnavailableWhileUsbConnected]).toBe(
@@ -33,4 +43,21 @@ describe('HardwareErrorCode compatibility', () => {
33
43
  },
34
44
  });
35
45
  });
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
+
54
+ test('recognizes the macOS CoreBluetooth stale-pairing error without matching generic failures', () => {
55
+ expect(
56
+ isBleStaleBondErrorText(
57
+ 'CBErrorDomain:14 Peer removed pairing information on the device side'
58
+ )
59
+ ).toBe(true);
60
+ expect(isBleStaleBondErrorText('CBATTErrorDomain:14 localized native message')).toBe(false);
61
+ expect(isBleStaleBondErrorText('connection failed')).toBe(false);
62
+ });
36
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
@@ -534,7 +539,8 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
534
539
  [HardwareErrorCode.DeviceInterruptedFromOutside]: 'Device interrupted',
535
540
  [HardwareErrorCode.DeviceInterruptedFromUser]: 'Device interrupted',
536
541
  [HardwareErrorCode.RequiredButInBootloaderMode]: 'Device should be in bootloader mode',
537
- [HardwareErrorCode.DeviceCheckDeviceIdError]: 'Device Id in the features is not same.',
542
+ [HardwareErrorCode.DeviceCheckDeviceIdError]:
543
+ 'The connected device does not match this wallet. Reconnect the correct device, or add it again after a reset or recovery.',
538
544
  [HardwareErrorCode.DeviceNotSupportPassphrase]: 'Device not support passphrase',
539
545
  [HardwareErrorCode.DeviceCheckPassphraseStateError]: 'Device passphrase state error',
540
546
  [HardwareErrorCode.DeviceNotOpenedPassphrase]: 'Device not opened passphrase',
@@ -542,7 +548,8 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
542
548
  [HardwareErrorCode.DeviceDetectInBootloaderMode]: 'Device in bootloader mode',
543
549
  [HardwareErrorCode.NotAllowInBootloaderMode]: 'Device not allow in bootloader mode',
544
550
  [HardwareErrorCode.DeviceBusy]: 'Device is busy',
545
- [HardwareErrorCode.DeviceCheckUnlockTypeError]: 'Device check unlock type not match error',
551
+ [HardwareErrorCode.DeviceCheckUnlockTypeError]:
552
+ 'The unlocked wallet does not match the selected wallet. Use the corresponding PIN or passphrase and try again.',
546
553
  /**
547
554
  * Node Errors
548
555
  */
@@ -622,6 +629,8 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
622
629
  [HardwareErrorCode.BleUnsupported]: 'Bluetooth is not supported on this device',
623
630
  [HardwareErrorCode.BleUnavailableWhileUsbConnected]:
624
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.',
625
634
 
626
635
  /**
627
636
  * Runtime Error
@@ -660,7 +669,6 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
660
669
  [HardwareErrorCode.WalletSessionInvalid]: 'Wallet session is invalid or expired',
661
670
  [HardwareErrorCode.NftStorageLimitReached]:
662
671
  'NFT storage limit reached. Remove an NFT from the device and try again.',
663
-
664
672
  /**
665
673
  * Lowlevel transport
666
674
  */
@@ -686,7 +694,8 @@ export const isBleStaleBondHardwareError = (error: unknown): boolean => {
686
694
  const code = (error as { errorCode?: unknown })?.errorCode;
687
695
  return (
688
696
  code === HardwareErrorCode.BleDeviceBondError ||
689
- code === HardwareErrorCode.BlePeerRemovedPairingInformation
697
+ code === HardwareErrorCode.BlePeerRemovedPairingInformation ||
698
+ code === HardwareErrorCode.BleBondInvalid
690
699
  );
691
700
  };
692
701
 
@@ -696,6 +705,7 @@ export const isBleStaleBondErrorText = (text: string): boolean => {
696
705
  value.includes('encryption is insufficient') ||
697
706
  value.includes('insufficient encryption') ||
698
707
  value.includes('peer removed pairing information') ||
708
+ value.includes('cberrordomain:14') ||
699
709
  value.includes('gatt_insuf_authentication')
700
710
  );
701
711
  };