@onekeyfe/hd-shared 1.2.0-alpha.157 → 1.2.0-alpha.159
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.
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +8 -0
- package/package.json +2 -2
- package/src/constants.test.ts +6 -0
- package/src/constants.ts +21 -0
package/dist/constants.d.ts
CHANGED
|
@@ -46,6 +46,10 @@ export declare enum EOneKeyBleMessageKeys {
|
|
|
46
46
|
NOBLE_BLE_MTU_CHANGED = "$onekey-noble-ble-mtu-changed",
|
|
47
47
|
NOBLE_BLE_CANCEL_PAIRING = "$onekey-noble-ble-cancel-pairing"
|
|
48
48
|
}
|
|
49
|
+
export declare enum EBleDisconnectReason {
|
|
50
|
+
DeviceDisconnected = "device-disconnected",
|
|
51
|
+
IdleKeepAlive = "idle-keep-alive"
|
|
52
|
+
}
|
|
49
53
|
export declare const ONEKEY_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
|
|
50
54
|
export declare const ONEKEY_WRITE_CHARACTERISTIC_UUID = "00000002-0000-1000-8000-00805f9b34fb";
|
|
51
55
|
export declare const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = "00000003-0000-1000-8000-00805f9b34fb";
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -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,MA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/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,20 @@ declare enum EOneKeyBleMessageKeys {
|
|
|
54
54
|
NOBLE_BLE_MTU_CHANGED = "$onekey-noble-ble-mtu-changed",
|
|
55
55
|
NOBLE_BLE_CANCEL_PAIRING = "$onekey-noble-ble-cancel-pairing"
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Why a BLE link went down, carried on BLE_DEVICE_DISCONNECTED.
|
|
59
|
+
*
|
|
60
|
+
* The main process frees an idle link on its own keep-alive timer, which is an
|
|
61
|
+
* internal optimisation the device knows nothing about — consumers must not
|
|
62
|
+
* treat it as "the device is gone". Only DeviceDisconnected means the
|
|
63
|
+
* peripheral actually dropped.
|
|
64
|
+
*/
|
|
65
|
+
declare enum EBleDisconnectReason {
|
|
66
|
+
/** Unsolicited peripheral drop: powered off, out of range, cable/BLE lost. */
|
|
67
|
+
DeviceDisconnected = "device-disconnected",
|
|
68
|
+
/** Main-process keep-alive timer released an idle link; device still present. */
|
|
69
|
+
IdleKeepAlive = "idle-keep-alive"
|
|
70
|
+
}
|
|
57
71
|
declare const ONEKEY_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
|
|
58
72
|
declare const ONEKEY_WRITE_CHARACTERISTIC_UUID = "00000002-0000-1000-8000-00805f9b34fb";
|
|
59
73
|
declare const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = "00000003-0000-1000-8000-00805f9b34fb";
|
|
@@ -82,6 +96,9 @@ declare const normalizePro2FindMyAdvertisementName: (value: string) => string;
|
|
|
82
96
|
* Current Pro2 advertisements use "Pro 2 XXXX". Older firmware used "Pro2 XXXX".
|
|
83
97
|
* Discovery and DeviceInfo both go through this helper so the public BLE name
|
|
84
98
|
* stays on the spaced form without changing OneKey Pro / Neo names.
|
|
99
|
+
*
|
|
100
|
+
* Match the compact Pro2 form first. A leading "Pro 2" regex would also eat the
|
|
101
|
+
* first digit of a OneKey Pro suffix such as "Pro 22D8" or "Pro 2D8F".
|
|
85
102
|
*/
|
|
86
103
|
declare const canonicalizePro2BleAdvertisementName: (value: string) => string;
|
|
87
104
|
declare const isSameOnekeyBleName: (left?: string | null, right?: string | null) => boolean;
|
|
@@ -551,4 +568,4 @@ declare enum EDeviceType {
|
|
|
551
568
|
Neo = "neo"
|
|
552
569
|
}
|
|
553
570
|
|
|
554
|
-
export { CreateErrorByMessage, CreateHardwareErrorByBridgeError, Deferred, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -450,6 +450,11 @@ exports.EOneKeyBleMessageKeys = void 0;
|
|
|
450
450
|
EOneKeyBleMessageKeys["NOBLE_BLE_MTU_CHANGED"] = "$onekey-noble-ble-mtu-changed";
|
|
451
451
|
EOneKeyBleMessageKeys["NOBLE_BLE_CANCEL_PAIRING"] = "$onekey-noble-ble-cancel-pairing";
|
|
452
452
|
})(exports.EOneKeyBleMessageKeys || (exports.EOneKeyBleMessageKeys = {}));
|
|
453
|
+
exports.EBleDisconnectReason = void 0;
|
|
454
|
+
(function (EBleDisconnectReason) {
|
|
455
|
+
EBleDisconnectReason["DeviceDisconnected"] = "device-disconnected";
|
|
456
|
+
EBleDisconnectReason["IdleKeepAlive"] = "idle-keep-alive";
|
|
457
|
+
})(exports.EBleDisconnectReason || (exports.EBleDisconnectReason = {}));
|
|
453
458
|
const ONEKEY_SERVICE_UUID = '00000001-0000-1000-8000-00805f9b34fb';
|
|
454
459
|
const ONEKEY_WRITE_CHARACTERISTIC_UUID = '00000002-0000-1000-8000-00805f9b34fb';
|
|
455
460
|
const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = '00000003-0000-1000-8000-00805f9b34fb';
|
|
@@ -598,6 +603,9 @@ const normalizePro2FindMyAdvertisementName = (value) => {
|
|
|
598
603
|
};
|
|
599
604
|
const canonicalizePro2BleAdvertisementName = (value) => {
|
|
600
605
|
const withoutFindMy = normalizePro2FindMyAdvertisementName(value);
|
|
606
|
+
const compact = compactBleName(withoutFindMy);
|
|
607
|
+
if (!PRO2_COMPACT_NAME_PATTERN.test(compact))
|
|
608
|
+
return withoutFindMy;
|
|
601
609
|
const match = withoutFindMy.match(/^(onekey\s*)?pro\s*2\s*/i);
|
|
602
610
|
if (!match)
|
|
603
611
|
return withoutFindMy;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-shared",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.159",
|
|
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": "
|
|
29
|
+
"gitHead": "302f9ff916b3769cdb0cf79d58d09a87eeac68c2"
|
|
30
30
|
}
|
package/src/constants.test.ts
CHANGED
|
@@ -125,6 +125,9 @@ describe('hardware device identity filters', () => {
|
|
|
125
125
|
['OneKey Pro 2 A1B2', 'OneKey Pro 2 A1B2'],
|
|
126
126
|
['OneKey Pro 2', 'OneKey Pro 2'],
|
|
127
127
|
['Pro A1B2', 'Pro A1B2'],
|
|
128
|
+
['Pro 22D8', 'Pro 22D8'],
|
|
129
|
+
['Pro 2D8F', 'Pro 2D8F'],
|
|
130
|
+
['OneKey Pro 22D8', 'OneKey Pro 22D8'],
|
|
128
131
|
['Neo 22D8', 'Neo 22D8'],
|
|
129
132
|
])('canonicalizes the public Pro2 advertisement name %s', (name, expected) => {
|
|
130
133
|
expect(canonicalizePro2BleAdvertisementName(name)).toBe(expected);
|
|
@@ -135,6 +138,9 @@ describe('hardware device identity filters', () => {
|
|
|
135
138
|
expect(isSameOnekeyBleName('Pro2 6136 - Find My', 'Pro 2 6136')).toBe(true);
|
|
136
139
|
expect(isSameOnekeyBleName('Pro 2 6136', 'Pro 2 0088')).toBe(false);
|
|
137
140
|
expect(isSameOnekeyBleName('Pro A1B2', 'Pro 2 A1B2')).toBe(false);
|
|
141
|
+
expect(isSameOnekeyBleName('Pro 22D8', 'Pro 22D8')).toBe(true);
|
|
142
|
+
expect(isSameOnekeyBleName('Pro 22D8', 'Pro2 22D8')).toBe(false);
|
|
143
|
+
expect(isSameOnekeyBleName('Pro 22D8', 'Pro 2 22D8')).toBe(false);
|
|
138
144
|
});
|
|
139
145
|
|
|
140
146
|
it('keeps OneKey discovery on the communication service', () => {
|
package/src/constants.ts
CHANGED
|
@@ -101,6 +101,21 @@ export enum EOneKeyBleMessageKeys {
|
|
|
101
101
|
NOBLE_BLE_CANCEL_PAIRING = '$onekey-noble-ble-cancel-pairing',
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Why a BLE link went down, carried on BLE_DEVICE_DISCONNECTED.
|
|
106
|
+
*
|
|
107
|
+
* The main process frees an idle link on its own keep-alive timer, which is an
|
|
108
|
+
* internal optimisation the device knows nothing about — consumers must not
|
|
109
|
+
* treat it as "the device is gone". Only DeviceDisconnected means the
|
|
110
|
+
* peripheral actually dropped.
|
|
111
|
+
*/
|
|
112
|
+
export enum EBleDisconnectReason {
|
|
113
|
+
/** Unsolicited peripheral drop: powered off, out of range, cable/BLE lost. */
|
|
114
|
+
DeviceDisconnected = 'device-disconnected',
|
|
115
|
+
/** Main-process keep-alive timer released an idle link; device still present. */
|
|
116
|
+
IdleKeepAlive = 'idle-keep-alive',
|
|
117
|
+
}
|
|
118
|
+
|
|
104
119
|
export const ONEKEY_SERVICE_UUID = '00000001-0000-1000-8000-00805f9b34fb';
|
|
105
120
|
export const ONEKEY_WRITE_CHARACTERISTIC_UUID = '00000002-0000-1000-8000-00805f9b34fb';
|
|
106
121
|
export const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = '00000003-0000-1000-8000-00805f9b34fb';
|
|
@@ -296,9 +311,15 @@ export const normalizePro2FindMyAdvertisementName = (value: string) => {
|
|
|
296
311
|
* Current Pro2 advertisements use "Pro 2 XXXX". Older firmware used "Pro2 XXXX".
|
|
297
312
|
* Discovery and DeviceInfo both go through this helper so the public BLE name
|
|
298
313
|
* stays on the spaced form without changing OneKey Pro / Neo names.
|
|
314
|
+
*
|
|
315
|
+
* Match the compact Pro2 form first. A leading "Pro 2" regex would also eat the
|
|
316
|
+
* first digit of a OneKey Pro suffix such as "Pro 22D8" or "Pro 2D8F".
|
|
299
317
|
*/
|
|
300
318
|
export const canonicalizePro2BleAdvertisementName = (value: string) => {
|
|
301
319
|
const withoutFindMy = normalizePro2FindMyAdvertisementName(value);
|
|
320
|
+
const compact = compactBleName(withoutFindMy);
|
|
321
|
+
if (!PRO2_COMPACT_NAME_PATTERN.test(compact)) return withoutFindMy;
|
|
322
|
+
|
|
302
323
|
const match = withoutFindMy.match(/^(onekey\s*)?pro\s*2\s*/i);
|
|
303
324
|
if (!match) return withoutFindMy;
|
|
304
325
|
|