@onekeyfe/hd-shared 1.2.0-alpha.171 → 1.2.0-alpha.173

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.
@@ -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
83
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,yBAAyB;;;CAG5B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,OAAO,yBAAyB,CAAC,CAAC;AAE7E,eAAO,MAAM,oBAAoB;;;GAOhC,CAAC;AAGF,eAAO,MAAM,0BAA0B;;;EAAqD,CAAC;AAE7F,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAIF,eAAO,MAAM,yBAAyB,eAAgB,wBAAwB,KAAG,OAQhF,CAAC;AAMF,eAAO,MAAM,2BAA2B,mDAS9B,CAAC;AAMX,eAAO,MAAM,8BAA8B,qBAGjC,CAAC;AAGX,oBAAY,qBAAqB;IAE/B,UAAU,uBAAuB;IACjC,iBAAiB,8BAA8B;IAC/C,aAAa,0BAA0B;IACvC,kBAAkB,+BAA+B;IAC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I,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> = {
@@ -568,4 +574,4 @@ declare enum EDeviceType {
568
574
  Neo = "neo"
569
575
  }
570
576
 
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 };
577
+ 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, isPro2FamilyBleName, isPro2FindMyAdvertisementName, isSameOnekeyBleName, matchesKnownBleUuid, normalizeBleUuid, normalizePro2FindMyAdvertisementName, resolveOneKeyUsbDevicePath, serializeError, wait };
package/dist/index.js CHANGED
@@ -622,6 +622,22 @@ const isSameOnekeyBleName = (left, right) => {
622
622
  compactBleName(canonicalizePro2BleAdvertisementName(right)));
623
623
  };
624
624
  const hasOnekeyCommunicationService = (serviceUuids) => (serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : []).some(uuid => matchesKnownBleUuid(uuid, ONEKEY_COMMUNICATION_SERVICE_ALIASES));
625
+ const isPro2FamilyBleName = (value) => {
626
+ if (!value) {
627
+ return false;
628
+ }
629
+ const normalized = value.trim().toLowerCase();
630
+ if (!normalized) {
631
+ return false;
632
+ }
633
+ if (normalized.startsWith('pro2') || normalized.startsWith('neo')) {
634
+ return true;
635
+ }
636
+ const compact = compactBleName(normalized);
637
+ return (PRO2_COMPACT_NAME_PATTERN.test(compact) ||
638
+ NEO_COMPACT_NAME_PATTERN.test(compact) ||
639
+ isPro2FindMyAdvertisementName(value));
640
+ };
625
641
  const isOnekeyBluetoothDevice = ({ id, name, localName, serviceUuids, }) => {
626
642
  const advertisedServiceUuids = serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : [];
627
643
  if (hasOnekeyCommunicationService(advertisedServiceUuids)) {
@@ -740,6 +756,7 @@ exports.isHeaderChunk = isHeaderChunk;
740
756
  exports.isKnownTrezorWebUsbDevice = isKnownTrezorWebUsbDevice;
741
757
  exports.isOnekeyBluetoothDevice = isOnekeyBluetoothDevice;
742
758
  exports.isOnekeyDevice = isOnekeyDevice;
759
+ exports.isPro2FamilyBleName = isPro2FamilyBleName;
743
760
  exports.isPro2FindMyAdvertisementName = isPro2FindMyAdvertisementName;
744
761
  exports.isSameOnekeyBleName = isSameOnekeyBleName;
745
762
  exports.matchesKnownBleUuid = matchesKnownBleUuid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-shared",
3
- "version": "1.2.0-alpha.171",
3
+ "version": "1.2.0-alpha.173",
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": "68de201cc95fe521936c74f828addb3fb5251c67"
29
+ "gitHead": "b2fa03ff17b01696a15318c2e27c923d9ba3deb0"
30
30
  }
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,