@onekeyfe/hd-shared 1.2.2-alpha.100 → 1.2.2-alpha.101

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;
@@ -125,6 +126,8 @@ export declare const HardwareErrorCode: {
125
126
  };
126
127
  export declare const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping;
127
128
  export declare const TypedError: (hardwareError: ErrorCodeUnion | string, message?: string, params?: any) => HardwareError;
129
+ export declare const isBleStaleBondHardwareError: (error: unknown) => boolean;
130
+ export declare const isBleStaleBondErrorText: (text: string) => boolean;
128
131
  export declare const serializeError: (payload: any) => any;
129
132
  export declare const CreateErrorByMessage: (message: string) => HardwareError;
130
133
  export declare const CreateHardwareErrorByBridgeError: (raw: string) => HardwareError;
@@ -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,i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StD,CAAC;AAEF,eAAO,MAAM,cAAc,YAAa,GAAG,QAe1C,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAa,MAAM,KAAG,aAOtD,CAAC;AAGF,eAAO,MAAM,gCAAgC,QAAS,MAAM,KAAG,aAQ9D,CAAC;AAEF,QAAA,MAAM,uCAAuC;oBAM3B,MAAM;oBACN,MAAM;;;mBAcvB,CAAC;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"}
@@ -77,6 +77,7 @@ export declare const normalizePro2FindMyAdvertisementName: (value: string) => st
77
77
  export declare const canonicalizePro2BleAdvertisementName: (value: string) => string;
78
78
  export declare const isSameOnekeyBleName: (left?: string | null, right?: string | null) => boolean;
79
79
  export declare const hasOnekeyCommunicationService: (serviceUuids: Array<string | null | undefined> | null | undefined) => boolean;
80
+ export declare const isPro2FamilyBleName: (value?: string | null) => boolean;
80
81
  export declare const isOnekeyBluetoothDevice: ({ id, name, localName, serviceUuids, }: BluetoothDeviceIdentity) => boolean;
81
82
  export {};
82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;IAC1B,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;CACxD,CAAC;AAIF,eAAO,MAAM,gBAAgB,UAAW,MAAM,GAAG,IAAI,WACP,CAAC;AAE/C,eAAO,MAAM,yBAAyB,SAAU,MAAM,KAAG,YAAY,MAAM,CAc1E,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAClB,MAAM,GAAG,IAAI,GAAG,SAAS,WAC5B,YAAY,MAAM,CAAC,YACgB,CAAC;AAmC/C,eAAO,MAAM,6BAA6B,WAAY,MAAM,GAAG,IAAI,YAWlE,CAAC;AAEF,eAAO,MAAM,oCAAoC,UAAW,MAAM,WAejE,CAAC;AAUF,eAAO,MAAM,oCAAoC,UAAW,MAAM,WAWjE,CAAC;AAEF,eAAO,MAAM,mBAAmB,UAAW,MAAM,GAAG,IAAI,UAAU,MAAM,GAAG,IAAI,YAO9E,CAAC;AAEF,eAAO,MAAM,6BAA6B,iBAC1B,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,YAIhE,CAAC;AAOJ,eAAO,MAAM,mBAAmB,WAAY,MAAM,GAAG,IAAI,KAAG,OAiB3D,CAAC;AAEF,eAAO,MAAM,uBAAuB,2CAKjC,uBAAuB,KAAG,OAiB5B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -103,6 +103,12 @@ declare const normalizePro2FindMyAdvertisementName: (value: string) => string;
103
103
  declare const canonicalizePro2BleAdvertisementName: (value: string) => string;
104
104
  declare const isSameOnekeyBleName: (left?: string | null, right?: string | null) => boolean;
105
105
  declare const hasOnekeyCommunicationService: (serviceUuids: Array<string | null | undefined> | null | undefined) => boolean;
106
+ /**
107
+ * Protocol V2 family (Pro2 / Neo) by advertised BLE name. Callers use it to
108
+ * pick a connection strategy: this family also advertises under Find My names
109
+ * that carry no OneKey service UUID, so a scan cannot always see it.
110
+ */
111
+ declare const isPro2FamilyBleName: (value?: string | null) => boolean;
106
112
  declare const isOnekeyBluetoothDevice: ({ id, name, localName, serviceUuids, }: BluetoothDeviceIdentity) => boolean;
107
113
 
108
114
  type Deferred<T, I = any, D = any> = {
@@ -355,6 +361,11 @@ declare const HardwareErrorCode: {
355
361
  readonly BlePoweredOff: 721;
356
362
  readonly BleUnsupported: 722;
357
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;
358
369
  /**
359
370
  * Hardware runtiome errors
360
371
  */
@@ -497,6 +508,8 @@ declare const HardwareErrorCode: {
497
508
  };
498
509
  declare const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping;
499
510
  declare const TypedError: (hardwareError: ErrorCodeUnion | string, message?: string, params?: any) => HardwareError;
511
+ declare const isBleStaleBondHardwareError: (error: unknown) => boolean;
512
+ declare const isBleStaleBondErrorText: (text: string) => boolean;
500
513
  declare const serializeError: (payload: any) => any;
501
514
  declare const CreateErrorByMessage: (message: string) => HardwareError;
502
515
  declare const CreateHardwareErrorByBridgeError: (raw: string) => HardwareError;
@@ -532,6 +545,8 @@ declare const HardwareError$1_HardwareError: typeof HardwareError;
532
545
  declare const HardwareError$1_HardwareErrorCode: typeof HardwareErrorCode;
533
546
  declare const HardwareError$1_HardwareErrorCodeMessage: typeof HardwareErrorCodeMessage;
534
547
  declare const HardwareError$1_TypedError: typeof TypedError;
548
+ declare const HardwareError$1_isBleStaleBondHardwareError: typeof isBleStaleBondHardwareError;
549
+ declare const HardwareError$1_isBleStaleBondErrorText: typeof isBleStaleBondErrorText;
535
550
  declare const HardwareError$1_serializeError: typeof serializeError;
536
551
  declare const HardwareError$1_CreateErrorByMessage: typeof CreateErrorByMessage;
537
552
  declare const HardwareError$1_CreateHardwareErrorByBridgeError: typeof CreateHardwareErrorByBridgeError;
@@ -548,6 +563,8 @@ declare namespace HardwareError$1 {
548
563
  HardwareError$1_HardwareErrorCode as HardwareErrorCode,
549
564
  HardwareError$1_HardwareErrorCodeMessage as HardwareErrorCodeMessage,
550
565
  HardwareError$1_TypedError as TypedError,
566
+ HardwareError$1_isBleStaleBondHardwareError as isBleStaleBondHardwareError,
567
+ HardwareError$1_isBleStaleBondErrorText as isBleStaleBondErrorText,
551
568
  HardwareError$1_serializeError as serializeError,
552
569
  HardwareError$1_CreateErrorByMessage as CreateErrorByMessage,
553
570
  HardwareError$1_CreateHardwareErrorByBridgeError as CreateHardwareErrorByBridgeError,
@@ -568,4 +585,4 @@ declare enum EDeviceType {
568
585
  Neo = "neo"
569
586
  }
570
587
 
571
- export { CreateErrorByMessage, CreateHardwareErrorByBridgeError, Deferred, EBleDisconnectReason, EDeviceType, EFirmwareType, EOneKeyBleMessageKeys, HardwareError$1 as ERRORS, ERROR_CODES_REQUIRE_DISCONNECT, ERROR_CODES_REQUIRE_RELEASE, HARDWARE_CONNECT_PROTOCOL, HardwareConnectProtocol, HardwareError, HardwareErrorCode, HardwareErrorCodeMessage, IHardwareError, ONEKEY_NOTIFY_CHARACTERISTIC_UUID, ONEKEY_PROTOCOL_V2_USB_IDS, ONEKEY_SERVICE_UUID, ONEKEY_WEBUSB_FILTER, ONEKEY_WRITE_CHARACTERISTIC_UUID, TypedError, canonicalizePro2BleAdvertisementName, createDefectiveFirmwareError, createDeferred, createDeprecatedHardwareError, createDeviceNotSupportMethodError, createKnownBleUuidAliases, createNeedUpgradeFirmwareHardwareError, createNewFirmwareForceUpdateHardwareError, createNewFirmwareUnReleaseHardwareError, hasOnekeyCommunicationService, inferProtocolHintFromUsbId, isHeaderChunk, isKnownTrezorWebUsbDevice, isOnekeyBluetoothDevice, isOnekeyDevice, isPro2FindMyAdvertisementName, isSameOnekeyBleName, matchesKnownBleUuid, normalizeBleUuid, normalizePro2FindMyAdvertisementName, resolveOneKeyUsbDevicePath, serializeError, wait };
588
+ export { CreateErrorByMessage, CreateHardwareErrorByBridgeError, Deferred, EBleDisconnectReason, EDeviceType, EFirmwareType, EOneKeyBleMessageKeys, HardwareError$1 as ERRORS, ERROR_CODES_REQUIRE_DISCONNECT, ERROR_CODES_REQUIRE_RELEASE, HARDWARE_CONNECT_PROTOCOL, HardwareConnectProtocol, HardwareError, HardwareErrorCode, HardwareErrorCodeMessage, IHardwareError, ONEKEY_NOTIFY_CHARACTERISTIC_UUID, ONEKEY_PROTOCOL_V2_USB_IDS, ONEKEY_SERVICE_UUID, ONEKEY_WEBUSB_FILTER, ONEKEY_WRITE_CHARACTERISTIC_UUID, TypedError, canonicalizePro2BleAdvertisementName, createDefectiveFirmwareError, createDeferred, createDeprecatedHardwareError, createDeviceNotSupportMethodError, createKnownBleUuidAliases, createNeedUpgradeFirmwareHardwareError, createNewFirmwareForceUpdateHardwareError, createNewFirmwareUnReleaseHardwareError, hasOnekeyCommunicationService, inferProtocolHintFromUsbId, isBleStaleBondErrorText, isBleStaleBondHardwareError, isHeaderChunk, isKnownTrezorWebUsbDevice, isOnekeyBluetoothDevice, isOnekeyDevice, isPro2FamilyBleName, isPro2FindMyAdvertisementName, isSameOnekeyBleName, matchesKnownBleUuid, normalizeBleUuid, normalizePro2FindMyAdvertisementName, resolveOneKeyUsbDevicePath, serializeError, wait };
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',
@@ -286,6 +288,20 @@ const TypedError = (hardwareError, message, params) => {
286
288
  }
287
289
  return new HardwareError({ errorCode: hardwareError, message: message !== null && message !== void 0 ? message : '', params });
288
290
  };
291
+ const isBleStaleBondHardwareError = (error) => {
292
+ const code = error === null || error === void 0 ? void 0 : error.errorCode;
293
+ return (code === HardwareErrorCode.BleDeviceBondError ||
294
+ code === HardwareErrorCode.BlePeerRemovedPairingInformation ||
295
+ code === HardwareErrorCode.BleBondInvalid);
296
+ };
297
+ const isBleStaleBondErrorText = (text) => {
298
+ const value = text.toLowerCase();
299
+ return (value.includes('encryption is insufficient') ||
300
+ value.includes('insufficient encryption') ||
301
+ value.includes('peer removed pairing information') ||
302
+ value.includes('cberrordomain:14') ||
303
+ value.includes('gatt_insuf_authentication'));
304
+ };
289
305
  const serializeError = (payload) => {
290
306
  if (payload && payload.error instanceof HardwareError) {
291
307
  return {
@@ -377,6 +393,8 @@ var HardwareError$1 = /*#__PURE__*/Object.freeze({
377
393
  HardwareErrorCode: HardwareErrorCode,
378
394
  HardwareErrorCodeMessage: HardwareErrorCodeMessage,
379
395
  TypedError: TypedError,
396
+ isBleStaleBondHardwareError: isBleStaleBondHardwareError,
397
+ isBleStaleBondErrorText: isBleStaleBondErrorText,
380
398
  serializeError: serializeError,
381
399
  CreateErrorByMessage: CreateErrorByMessage,
382
400
  CreateHardwareErrorByBridgeError: CreateHardwareErrorByBridgeError,
@@ -622,6 +640,22 @@ const isSameOnekeyBleName = (left, right) => {
622
640
  compactBleName(canonicalizePro2BleAdvertisementName(right)));
623
641
  };
624
642
  const hasOnekeyCommunicationService = (serviceUuids) => (serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : []).some(uuid => matchesKnownBleUuid(uuid, ONEKEY_COMMUNICATION_SERVICE_ALIASES));
643
+ const isPro2FamilyBleName = (value) => {
644
+ if (!value) {
645
+ return false;
646
+ }
647
+ const normalized = value.trim().toLowerCase();
648
+ if (!normalized) {
649
+ return false;
650
+ }
651
+ if (normalized.startsWith('pro2') || normalized.startsWith('neo')) {
652
+ return true;
653
+ }
654
+ const compact = compactBleName(normalized);
655
+ return (PRO2_COMPACT_NAME_PATTERN.test(compact) ||
656
+ NEO_COMPACT_NAME_PATTERN.test(compact) ||
657
+ isPro2FindMyAdvertisementName(value));
658
+ };
625
659
  const isOnekeyBluetoothDevice = ({ id, name, localName, serviceUuids, }) => {
626
660
  const advertisedServiceUuids = serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : [];
627
661
  if (hasOnekeyCommunicationService(advertisedServiceUuids)) {
@@ -736,10 +770,13 @@ exports.createNewFirmwareForceUpdateHardwareError = createNewFirmwareForceUpdate
736
770
  exports.createNewFirmwareUnReleaseHardwareError = createNewFirmwareUnReleaseHardwareError;
737
771
  exports.hasOnekeyCommunicationService = hasOnekeyCommunicationService;
738
772
  exports.inferProtocolHintFromUsbId = inferProtocolHintFromUsbId;
773
+ exports.isBleStaleBondErrorText = isBleStaleBondErrorText;
774
+ exports.isBleStaleBondHardwareError = isBleStaleBondHardwareError;
739
775
  exports.isHeaderChunk = isHeaderChunk;
740
776
  exports.isKnownTrezorWebUsbDevice = isKnownTrezorWebUsbDevice;
741
777
  exports.isOnekeyBluetoothDevice = isOnekeyBluetoothDevice;
742
778
  exports.isOnekeyDevice = isOnekeyDevice;
779
+ exports.isPro2FamilyBleName = isPro2FamilyBleName;
743
780
  exports.isPro2FindMyAdvertisementName = isPro2FindMyAdvertisementName;
744
781
  exports.isSameOnekeyBleName = isSameOnekeyBleName;
745
782
  exports.matchesKnownBleUuid = matchesKnownBleUuid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-shared",
3
- "version": "1.2.2-alpha.100",
3
+ "version": "1.2.2-alpha.101",
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": "c40dad085297b0e3cc2020bd218c146dff6ed3e1"
29
+ "gitHead": "b9a5ca0c73e5e2cc979c91c007ace476e442718c"
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
  */
@@ -682,6 +690,26 @@ export const TypedError = (
682
690
  return new HardwareError({ errorCode: hardwareError, message: message ?? '', params });
683
691
  };
684
692
 
693
+ export const isBleStaleBondHardwareError = (error: unknown): boolean => {
694
+ const code = (error as { errorCode?: unknown })?.errorCode;
695
+ return (
696
+ code === HardwareErrorCode.BleDeviceBondError ||
697
+ code === HardwareErrorCode.BlePeerRemovedPairingInformation ||
698
+ code === HardwareErrorCode.BleBondInvalid
699
+ );
700
+ };
701
+
702
+ export const isBleStaleBondErrorText = (text: string): boolean => {
703
+ const value = text.toLowerCase();
704
+ return (
705
+ value.includes('encryption is insufficient') ||
706
+ value.includes('insufficient encryption') ||
707
+ value.includes('peer removed pairing information') ||
708
+ value.includes('cberrordomain:14') ||
709
+ value.includes('gatt_insuf_authentication')
710
+ );
711
+ };
712
+
685
713
  export const serializeError = (payload: any) => {
686
714
  if (payload && payload.error instanceof HardwareError) {
687
715
  return {
package/src/constants.ts CHANGED
@@ -344,6 +344,30 @@ export const hasOnekeyCommunicationService = (
344
344
  matchesKnownBleUuid(uuid, ONEKEY_COMMUNICATION_SERVICE_ALIASES)
345
345
  );
346
346
 
347
+ /**
348
+ * Protocol V2 family (Pro2 / Neo) by advertised BLE name. Callers use it to
349
+ * pick a connection strategy: this family also advertises under Find My names
350
+ * that carry no OneKey service UUID, so a scan cannot always see it.
351
+ */
352
+ export const isPro2FamilyBleName = (value?: string | null): boolean => {
353
+ if (!value) {
354
+ return false;
355
+ }
356
+ const normalized = value.trim().toLowerCase();
357
+ if (!normalized) {
358
+ return false;
359
+ }
360
+ if (normalized.startsWith('pro2') || normalized.startsWith('neo')) {
361
+ return true;
362
+ }
363
+ const compact = compactBleName(normalized);
364
+ return (
365
+ PRO2_COMPACT_NAME_PATTERN.test(compact) ||
366
+ NEO_COMPACT_NAME_PATTERN.test(compact) ||
367
+ isPro2FindMyAdvertisementName(value)
368
+ );
369
+ };
370
+
347
371
  export const isOnekeyBluetoothDevice = ({
348
372
  id,
349
373
  name,