@onekeyfe/hd-shared 1.0.34-alpha.0 → 1.0.34
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 +0 -19
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +1 -19
- package/dist/index.js +0 -46
- package/package.json +2 -2
- package/src/constants.ts +0 -57
package/dist/constants.d.ts
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
export declare const ONEKEY_WEBUSB_FILTER: {
|
|
3
2
|
vendorId: number;
|
|
4
3
|
productId: number;
|
|
5
4
|
}[];
|
|
6
|
-
export declare enum EOneKeyBleMessageKeys {
|
|
7
|
-
BLE_SELECT = "$onekey-ble-select",
|
|
8
|
-
BLE_SELECT_RESULT = "$onekey-ble-select-result",
|
|
9
|
-
BLE_STOP_SCAN = "$onekey-ble-stop-scan",
|
|
10
|
-
BLE_CANCEL_REQUEST = "$onekey-ble-cancel-request",
|
|
11
|
-
BLE_PRE_SELECT = "$onekey-ble-pre-select",
|
|
12
|
-
BLE_CLEAR_PRE_SELECT = "$onekey-ble-clear-pre-select",
|
|
13
|
-
BLE_PAIRING_REQUEST = "$onekey-ble-pairing-request",
|
|
14
|
-
BLE_PAIRING_RESPONSE = "$onekey-ble-pairing-response",
|
|
15
|
-
BLE_ENUMERATE = "$onekey-ble-enumerate",
|
|
16
|
-
BLE_ENUMERATE_RESULT = "$onekey-ble-enumerate-result",
|
|
17
|
-
BLE_DEVICE_DISCONNECTED = "$onekey-ble-device-disconnected"
|
|
18
|
-
}
|
|
19
|
-
export declare const ONEKEY_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
|
|
20
|
-
export declare const ONEKEY_WRITE_CHARACTERISTIC_UUID = "00000002-0000-1000-8000-00805f9b34fb";
|
|
21
|
-
export declare const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = "00000003-0000-1000-8000-00805f9b34fb";
|
|
22
|
-
export declare const isHeaderChunk: (chunk: Buffer | Uint8Array) => boolean;
|
|
23
|
-
export declare const isOnekeyDevice: (name: string | null, id?: string) => boolean;
|
|
24
5
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;GAOhC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,24 +2,6 @@ declare const ONEKEY_WEBUSB_FILTER: {
|
|
|
2
2
|
vendorId: number;
|
|
3
3
|
productId: number;
|
|
4
4
|
}[];
|
|
5
|
-
declare enum EOneKeyBleMessageKeys {
|
|
6
|
-
BLE_SELECT = "$onekey-ble-select",
|
|
7
|
-
BLE_SELECT_RESULT = "$onekey-ble-select-result",
|
|
8
|
-
BLE_STOP_SCAN = "$onekey-ble-stop-scan",
|
|
9
|
-
BLE_CANCEL_REQUEST = "$onekey-ble-cancel-request",
|
|
10
|
-
BLE_PRE_SELECT = "$onekey-ble-pre-select",
|
|
11
|
-
BLE_CLEAR_PRE_SELECT = "$onekey-ble-clear-pre-select",
|
|
12
|
-
BLE_PAIRING_REQUEST = "$onekey-ble-pairing-request",
|
|
13
|
-
BLE_PAIRING_RESPONSE = "$onekey-ble-pairing-response",
|
|
14
|
-
BLE_ENUMERATE = "$onekey-ble-enumerate",
|
|
15
|
-
BLE_ENUMERATE_RESULT = "$onekey-ble-enumerate-result",
|
|
16
|
-
BLE_DEVICE_DISCONNECTED = "$onekey-ble-device-disconnected"
|
|
17
|
-
}
|
|
18
|
-
declare const ONEKEY_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
|
|
19
|
-
declare const ONEKEY_WRITE_CHARACTERISTIC_UUID = "00000002-0000-1000-8000-00805f9b34fb";
|
|
20
|
-
declare const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = "00000003-0000-1000-8000-00805f9b34fb";
|
|
21
|
-
declare const isHeaderChunk: (chunk: Buffer | Uint8Array) => boolean;
|
|
22
|
-
declare const isOnekeyDevice: (name: string | null, id?: string) => boolean;
|
|
23
5
|
|
|
24
6
|
type Deferred<T, I = any, D = any> = {
|
|
25
7
|
id?: I;
|
|
@@ -185,4 +167,4 @@ declare enum EDeviceType {
|
|
|
185
167
|
Pro = "pro"
|
|
186
168
|
}
|
|
187
169
|
|
|
188
|
-
export { CreateErrorByMessage, Deferred, EDeviceType,
|
|
170
|
+
export { CreateErrorByMessage, Deferred, EDeviceType, HardwareError$1 as ERRORS, HardwareError, HardwareErrorCode, HardwareErrorCodeMessage, IHardwareError, ONEKEY_WEBUSB_FILTER, TypedError, createDeferred, createDeprecatedHardwareError, createNeedUpgradeFirmwareHardwareError, createNewFirmwareForceUpdateHardwareError, createNewFirmwareUnReleaseHardwareError, serializeError, wait };
|
package/dist/index.js
CHANGED
|
@@ -8,47 +8,6 @@ const ONEKEY_WEBUSB_FILTER = [
|
|
|
8
8
|
{ vendorId: 0x1209, productId: 0x4f4a },
|
|
9
9
|
{ vendorId: 0x1209, productId: 0x4f4b },
|
|
10
10
|
];
|
|
11
|
-
exports.EOneKeyBleMessageKeys = void 0;
|
|
12
|
-
(function (EOneKeyBleMessageKeys) {
|
|
13
|
-
EOneKeyBleMessageKeys["BLE_SELECT"] = "$onekey-ble-select";
|
|
14
|
-
EOneKeyBleMessageKeys["BLE_SELECT_RESULT"] = "$onekey-ble-select-result";
|
|
15
|
-
EOneKeyBleMessageKeys["BLE_STOP_SCAN"] = "$onekey-ble-stop-scan";
|
|
16
|
-
EOneKeyBleMessageKeys["BLE_CANCEL_REQUEST"] = "$onekey-ble-cancel-request";
|
|
17
|
-
EOneKeyBleMessageKeys["BLE_PRE_SELECT"] = "$onekey-ble-pre-select";
|
|
18
|
-
EOneKeyBleMessageKeys["BLE_CLEAR_PRE_SELECT"] = "$onekey-ble-clear-pre-select";
|
|
19
|
-
EOneKeyBleMessageKeys["BLE_PAIRING_REQUEST"] = "$onekey-ble-pairing-request";
|
|
20
|
-
EOneKeyBleMessageKeys["BLE_PAIRING_RESPONSE"] = "$onekey-ble-pairing-response";
|
|
21
|
-
EOneKeyBleMessageKeys["BLE_ENUMERATE"] = "$onekey-ble-enumerate";
|
|
22
|
-
EOneKeyBleMessageKeys["BLE_ENUMERATE_RESULT"] = "$onekey-ble-enumerate-result";
|
|
23
|
-
EOneKeyBleMessageKeys["BLE_DEVICE_DISCONNECTED"] = "$onekey-ble-device-disconnected";
|
|
24
|
-
})(exports.EOneKeyBleMessageKeys || (exports.EOneKeyBleMessageKeys = {}));
|
|
25
|
-
const ONEKEY_SERVICE_UUID = '00000001-0000-1000-8000-00805f9b34fb';
|
|
26
|
-
const ONEKEY_WRITE_CHARACTERISTIC_UUID = '00000002-0000-1000-8000-00805f9b34fb';
|
|
27
|
-
const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = '00000003-0000-1000-8000-00805f9b34fb';
|
|
28
|
-
const MESSAGE_TOP_CHAR = 63;
|
|
29
|
-
const MESSAGE_HEADER_BYTE = 35;
|
|
30
|
-
const isHeaderChunk = (chunk) => {
|
|
31
|
-
if (chunk.length < 9)
|
|
32
|
-
return false;
|
|
33
|
-
const [MagicQuestionMark, sharp1, sharp2] = chunk;
|
|
34
|
-
if (String.fromCharCode(MagicQuestionMark) === String.fromCharCode(MESSAGE_TOP_CHAR) &&
|
|
35
|
-
String.fromCharCode(sharp1) === String.fromCharCode(MESSAGE_HEADER_BYTE) &&
|
|
36
|
-
String.fromCharCode(sharp2) === String.fromCharCode(MESSAGE_HEADER_BYTE)) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
};
|
|
41
|
-
const isOnekeyDevice = (name, id) => {
|
|
42
|
-
var _a;
|
|
43
|
-
if ((_a = id === null || id === void 0 ? void 0 : id.startsWith) === null || _a === void 0 ? void 0 : _a.call(id, 'MI')) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
const re = /(BixinKey\d{10})|(K\d{4})|(T\d{4})|(Touch\s\w{4})|(Pro\s\w{4})/i;
|
|
47
|
-
if (name && re.exec(name)) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
};
|
|
52
11
|
|
|
53
12
|
/******************************************************************************
|
|
54
13
|
Copyright (c) Microsoft Corporation.
|
|
@@ -385,17 +344,12 @@ exports.ERRORS = HardwareError$1;
|
|
|
385
344
|
exports.HardwareError = HardwareError;
|
|
386
345
|
exports.HardwareErrorCode = HardwareErrorCode;
|
|
387
346
|
exports.HardwareErrorCodeMessage = HardwareErrorCodeMessage;
|
|
388
|
-
exports.ONEKEY_NOTIFY_CHARACTERISTIC_UUID = ONEKEY_NOTIFY_CHARACTERISTIC_UUID;
|
|
389
|
-
exports.ONEKEY_SERVICE_UUID = ONEKEY_SERVICE_UUID;
|
|
390
347
|
exports.ONEKEY_WEBUSB_FILTER = ONEKEY_WEBUSB_FILTER;
|
|
391
|
-
exports.ONEKEY_WRITE_CHARACTERISTIC_UUID = ONEKEY_WRITE_CHARACTERISTIC_UUID;
|
|
392
348
|
exports.TypedError = TypedError;
|
|
393
349
|
exports.createDeferred = createDeferred;
|
|
394
350
|
exports.createDeprecatedHardwareError = createDeprecatedHardwareError;
|
|
395
351
|
exports.createNeedUpgradeFirmwareHardwareError = createNeedUpgradeFirmwareHardwareError;
|
|
396
352
|
exports.createNewFirmwareForceUpdateHardwareError = createNewFirmwareForceUpdateHardwareError;
|
|
397
353
|
exports.createNewFirmwareUnReleaseHardwareError = createNewFirmwareUnReleaseHardwareError;
|
|
398
|
-
exports.isHeaderChunk = isHeaderChunk;
|
|
399
|
-
exports.isOnekeyDevice = isOnekeyDevice;
|
|
400
354
|
exports.serializeError = serializeError;
|
|
401
355
|
exports.wait = wait;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-shared",
|
|
3
|
-
"version": "1.0.34
|
|
3
|
+
"version": "1.0.34",
|
|
4
4
|
"description": "Hardware SDK's shared tool library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Hardware-SDK",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"lint": "eslint .",
|
|
26
26
|
"lint:fix": "eslint . --fix"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "3172095f33c4637dd76b36fee3ea0cfa0bd3ae40"
|
|
29
29
|
}
|
package/src/constants.ts
CHANGED
|
@@ -6,60 +6,3 @@ export const ONEKEY_WEBUSB_FILTER = [
|
|
|
6
6
|
// { vendorId: 0x1209, productId: 0x4f4c }, // Pro Board
|
|
7
7
|
// { vendorId: 0x1209, productId: 0x4f50 }, // Touch Board
|
|
8
8
|
];
|
|
9
|
-
|
|
10
|
-
// BLE IPC communication message types
|
|
11
|
-
export enum EOneKeyBleMessageKeys {
|
|
12
|
-
// BLE device selection related
|
|
13
|
-
BLE_SELECT = '$onekey-ble-select',
|
|
14
|
-
BLE_SELECT_RESULT = '$onekey-ble-select-result',
|
|
15
|
-
BLE_STOP_SCAN = '$onekey-ble-stop-scan',
|
|
16
|
-
BLE_CANCEL_REQUEST = '$onekey-ble-cancel-request',
|
|
17
|
-
BLE_PRE_SELECT = '$onekey-ble-pre-select',
|
|
18
|
-
BLE_CLEAR_PRE_SELECT = '$onekey-ble-clear-pre-select',
|
|
19
|
-
|
|
20
|
-
// BLE pairing related
|
|
21
|
-
BLE_PAIRING_REQUEST = '$onekey-ble-pairing-request',
|
|
22
|
-
BLE_PAIRING_RESPONSE = '$onekey-ble-pairing-response',
|
|
23
|
-
|
|
24
|
-
// BLE enumeration related
|
|
25
|
-
BLE_ENUMERATE = '$onekey-ble-enumerate',
|
|
26
|
-
BLE_ENUMERATE_RESULT = '$onekey-ble-enumerate-result',
|
|
27
|
-
|
|
28
|
-
// BLE connection status related
|
|
29
|
-
BLE_DEVICE_DISCONNECTED = '$onekey-ble-device-disconnected',
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const ONEKEY_SERVICE_UUID = '00000001-0000-1000-8000-00805f9b34fb';
|
|
33
|
-
export const ONEKEY_WRITE_CHARACTERISTIC_UUID = '00000002-0000-1000-8000-00805f9b34fb';
|
|
34
|
-
export const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = '00000003-0000-1000-8000-00805f9b34fb';
|
|
35
|
-
|
|
36
|
-
const MESSAGE_TOP_CHAR = 63;
|
|
37
|
-
const MESSAGE_HEADER_BYTE = 35;
|
|
38
|
-
export const isHeaderChunk = (chunk: Buffer | Uint8Array): boolean => {
|
|
39
|
-
if (chunk.length < 9) return false;
|
|
40
|
-
const [MagicQuestionMark, sharp1, sharp2] = chunk;
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
String.fromCharCode(MagicQuestionMark) === String.fromCharCode(MESSAGE_TOP_CHAR) &&
|
|
44
|
-
String.fromCharCode(sharp1) === String.fromCharCode(MESSAGE_HEADER_BYTE) &&
|
|
45
|
-
String.fromCharCode(sharp2) === String.fromCharCode(MESSAGE_HEADER_BYTE)
|
|
46
|
-
) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return false;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const isOnekeyDevice = (name: string | null, id?: string): boolean => {
|
|
54
|
-
if (id?.startsWith?.('MI')) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 过滤 BixinKeyxxx 和 Kxxxx 和 Txxxx
|
|
59
|
-
// i 忽略大小写模式
|
|
60
|
-
const re = /(BixinKey\d{10})|(K\d{4})|(T\d{4})|(Touch\s\w{4})|(Pro\s\w{4})/i;
|
|
61
|
-
if (name && re.exec(name)) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
return false;
|
|
65
|
-
};
|