@onekeyfe/hd-shared 1.2.0-alpha.7 → 1.2.0-alpha.70
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/HardwareError.d.ts +3 -0
- package/dist/HardwareError.d.ts.map +1 -1
- package/dist/constants.d.ts +19 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/deviceType.d.ts +2 -1
- package/dist/deviceType.d.ts.map +1 -1
- package/dist/index.d.ts +284 -2
- package/dist/index.js +90 -5
- package/jest.config.js +5 -0
- package/package.json +3 -2
- package/src/HardwareError.test.ts +9 -0
- package/src/HardwareError.ts +22 -0
- package/src/constants.test.ts +153 -0
- package/src/constants.ts +126 -9
- package/src/deviceType.ts +1 -0
package/dist/HardwareError.d.ts
CHANGED
|
@@ -115,6 +115,9 @@ export declare const HardwareErrorCode: {
|
|
|
115
115
|
readonly DeviceSettingsLanguageNotSupport: 826;
|
|
116
116
|
readonly TooManyInputs: 827;
|
|
117
117
|
readonly PinMismatch: 828;
|
|
118
|
+
readonly DeviceLocked: 830;
|
|
119
|
+
readonly WalletSessionInvalid: 831;
|
|
120
|
+
readonly NftStorageLimitReached: 832;
|
|
118
121
|
readonly LowlevelTrasnportConnectError: 900;
|
|
119
122
|
readonly WebDeviceNotFoundOrNeedsPermission: 901;
|
|
120
123
|
readonly WebDevicePromptAccessError: 902;
|
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwbpB,CAAC;AAEX,eAAO,MAAM,wBAAwB,EAAE,+BAoJ7B,CAAC;AAEX,eAAO,MAAM,UAAU,kBACN,cAAc,GAAG,MAAM,YAC5B,MAAM,WACP,GAAG,kBAMb,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"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -8,6 +8,12 @@ export declare const ONEKEY_WEBUSB_FILTER: {
|
|
|
8
8
|
vendorId: number;
|
|
9
9
|
productId: number;
|
|
10
10
|
}[];
|
|
11
|
+
type WebUsbIdentityDescriptor = {
|
|
12
|
+
vendorId?: number;
|
|
13
|
+
productId?: number;
|
|
14
|
+
manufacturerName?: string | null;
|
|
15
|
+
};
|
|
16
|
+
export declare const isKnownTrezorWebUsbDevice: (descriptor: WebUsbIdentityDescriptor) => boolean;
|
|
11
17
|
export declare const ERROR_CODES_REQUIRE_RELEASE: readonly [106, 107, 109, 112, 805, 801, 802, 812];
|
|
12
18
|
export declare const ERROR_CODES_REQUIRE_DISCONNECT: readonly [106, 805];
|
|
13
19
|
export declare enum EOneKeyBleMessageKeys {
|
|
@@ -39,4 +45,17 @@ export declare const ONEKEY_WRITE_CHARACTERISTIC_UUID = "00000002-0000-1000-8000
|
|
|
39
45
|
export declare const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = "00000003-0000-1000-8000-00805f9b34fb";
|
|
40
46
|
export declare const isHeaderChunk: (chunk: Buffer | Uint8Array) => boolean;
|
|
41
47
|
export declare const isOnekeyDevice: (name: string | null, id?: string) => boolean;
|
|
48
|
+
type BluetoothDeviceIdentity = {
|
|
49
|
+
id?: string;
|
|
50
|
+
name?: string | null;
|
|
51
|
+
localName?: string | null;
|
|
52
|
+
serviceUuids?: Array<string | null | undefined> | null;
|
|
53
|
+
};
|
|
54
|
+
export declare const normalizeBleUuid: (uuid?: string | null) => string;
|
|
55
|
+
export declare const createKnownBleUuidAliases: (uuid: string) => ReadonlySet<string>;
|
|
56
|
+
export declare const matchesKnownBleUuid: (actualUuid: string | null | undefined, aliases: ReadonlySet<string>) => boolean;
|
|
57
|
+
export declare const isPro2FindMyAdvertisementName: (value?: string | null) => boolean;
|
|
58
|
+
export declare const hasOnekeyCommunicationService: (serviceUuids: Array<string | null | undefined> | null | undefined) => boolean;
|
|
59
|
+
export declare const isOnekeyBluetoothDevice: ({ id, name, localName, serviceUuids, }: BluetoothDeviceIdentity) => boolean;
|
|
60
|
+
export {};
|
|
42
61
|
//# 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":";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;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;IACjD,cAAc,2BAA2B;IACzC,oBAAoB,iCAAiC;IAGrD,mBAAmB,gCAAgC;IACnD,oBAAoB,iCAAiC;IAGrD,aAAa,0BAA0B;IACvC,oBAAoB,iCAAiC;IAGrD,uBAAuB,oCAAoC;IAC3D,sBAAsB,mCAAmC;IAGzD,mBAAmB,gCAAgC;IACnD,mBAAmB,gCAAgC;IACnD,oBAAoB,iCAAiC;IACrD,iBAAiB,8BAA8B;IAC/C,oBAAoB,iCAAiC;IACrD,eAAe,4BAA4B;IAC3C,mBAAmB,gCAAgC;IACnD,qBAAqB,kCAAkC;IACvD,sBAAsB,mCAAmC;IACzD,wBAAwB,qCAAqC;CAC9D;AAED,eAAO,MAAM,mBAAmB,yCAAyC,CAAC;AAC1E,eAAO,MAAM,gCAAgC,yCAAyC,CAAC;AACvF,eAAO,MAAM,iCAAiC,yCAAyC,CAAC;AAIxF,eAAO,MAAM,aAAa,UAAW,MAAM,GAAG,UAAU,KAAG,OAa1D,CAAC;
|
|
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;AAEF,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;IACjD,cAAc,2BAA2B;IACzC,oBAAoB,iCAAiC;IAGrD,mBAAmB,gCAAgC;IACnD,oBAAoB,iCAAiC;IAGrD,aAAa,0BAA0B;IACvC,oBAAoB,iCAAiC;IAGrD,uBAAuB,oCAAoC;IAC3D,sBAAsB,mCAAmC;IAGzD,mBAAmB,gCAAgC;IACnD,mBAAmB,gCAAgC;IACnD,oBAAoB,iCAAiC;IACrD,iBAAiB,8BAA8B;IAC/C,oBAAoB,iCAAiC;IACrD,eAAe,4BAA4B;IAC3C,mBAAmB,gCAAgC;IACnD,qBAAqB,kCAAkC;IACvD,sBAAsB,mCAAmC;IACzD,wBAAwB,qCAAqC;CAC9D;AAED,eAAO,MAAM,mBAAmB,yCAAyC,CAAC;AAC1E,eAAO,MAAM,gCAAgC,yCAAyC,CAAC;AACvF,eAAO,MAAM,iCAAiC,yCAAyC,CAAC;AAIxF,eAAO,MAAM,aAAa,UAAW,MAAM,GAAG,UAAU,KAAG,OAa1D,CAAC;AAkBF,eAAO,MAAM,cAAc,SAAU,MAAM,GAAG,IAAI,OAAO,MAAM,KAAG,OAuBjE,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;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;AAK/C,eAAO,MAAM,6BAA6B,WAAY,MAAM,GAAG,IAAI,YAGlE,CAAC;AAEF,eAAO,MAAM,6BAA6B,iBAC1B,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,YAIhE,CAAC;AAEJ,eAAO,MAAM,uBAAuB,2CAKjC,uBAAuB,KAAG,OAiB5B,CAAC"}
|
package/dist/deviceType.d.ts
CHANGED
package/dist/deviceType.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceType.d.ts","sourceRoot":"","sources":["../src/deviceType.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;
|
|
1
|
+
{"version":3,"file":"deviceType.d.ts","sourceRoot":"","sources":["../src/deviceType.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;CACZ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,21 @@ declare const ONEKEY_WEBUSB_FILTER: {
|
|
|
7
7
|
vendorId: number;
|
|
8
8
|
productId: number;
|
|
9
9
|
}[];
|
|
10
|
+
type WebUsbIdentityDescriptor = {
|
|
11
|
+
vendorId?: number;
|
|
12
|
+
productId?: number;
|
|
13
|
+
manufacturerName?: string | null;
|
|
14
|
+
};
|
|
15
|
+
declare const isKnownTrezorWebUsbDevice: (descriptor: WebUsbIdentityDescriptor) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Error codes that require device release after occurrence
|
|
18
|
+
* These errors indicate the device is in an invalid state and needs to be released
|
|
19
|
+
*/
|
|
10
20
|
declare const ERROR_CODES_REQUIRE_RELEASE: readonly [106, 107, 109, 112, 805, 801, 802, 812];
|
|
21
|
+
/**
|
|
22
|
+
* Error codes that require device disconnect before release
|
|
23
|
+
* These errors indicate a communication failure that requires full reconnection
|
|
24
|
+
*/
|
|
11
25
|
declare const ERROR_CODES_REQUIRE_DISCONNECT: readonly [106, 805];
|
|
12
26
|
declare enum EOneKeyBleMessageKeys {
|
|
13
27
|
BLE_SELECT = "$onekey-ble-select",
|
|
@@ -38,6 +52,18 @@ declare const ONEKEY_WRITE_CHARACTERISTIC_UUID = "00000002-0000-1000-8000-00805f
|
|
|
38
52
|
declare const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = "00000003-0000-1000-8000-00805f9b34fb";
|
|
39
53
|
declare const isHeaderChunk: (chunk: Buffer | Uint8Array) => boolean;
|
|
40
54
|
declare const isOnekeyDevice: (name: string | null, id?: string) => boolean;
|
|
55
|
+
type BluetoothDeviceIdentity = {
|
|
56
|
+
id?: string;
|
|
57
|
+
name?: string | null;
|
|
58
|
+
localName?: string | null;
|
|
59
|
+
serviceUuids?: Array<string | null | undefined> | null;
|
|
60
|
+
};
|
|
61
|
+
declare const normalizeBleUuid: (uuid?: string | null) => string;
|
|
62
|
+
declare const createKnownBleUuidAliases: (uuid: string) => ReadonlySet<string>;
|
|
63
|
+
declare const matchesKnownBleUuid: (actualUuid: string | null | undefined, aliases: ReadonlySet<string>) => boolean;
|
|
64
|
+
declare const isPro2FindMyAdvertisementName: (value?: string | null) => boolean;
|
|
65
|
+
declare const hasOnekeyCommunicationService: (serviceUuids: Array<string | null | undefined> | null | undefined) => boolean;
|
|
66
|
+
declare const isOnekeyBluetoothDevice: ({ id, name, localName, serviceUuids, }: BluetoothDeviceIdentity) => boolean;
|
|
41
67
|
|
|
42
68
|
type Deferred<T, I = any, D = any> = {
|
|
43
69
|
id?: I;
|
|
@@ -70,53 +96,201 @@ declare class HardwareError extends Error {
|
|
|
70
96
|
constructor(hardwareError: IHardwareError | string);
|
|
71
97
|
}
|
|
72
98
|
declare const HardwareErrorCode: {
|
|
99
|
+
/**
|
|
100
|
+
* This error can be thrown when unexpected error occurred and in most cases it is related to implementation bug.
|
|
101
|
+
* Original message is available in message property.
|
|
102
|
+
*/
|
|
73
103
|
readonly UnknownError: 0;
|
|
104
|
+
/**
|
|
105
|
+
* Firmware version mismatch
|
|
106
|
+
*/
|
|
74
107
|
readonly DeviceFwException: 101;
|
|
108
|
+
/**
|
|
109
|
+
* Device unexpected mode
|
|
110
|
+
*/
|
|
75
111
|
readonly DeviceUnexpectedMode: 102;
|
|
112
|
+
/**
|
|
113
|
+
* Device list is not initialized
|
|
114
|
+
*/
|
|
76
115
|
readonly DeviceListNotInitialized: 103;
|
|
116
|
+
/**
|
|
117
|
+
* Please select the connected device
|
|
118
|
+
*/
|
|
77
119
|
readonly SelectDevice: 104;
|
|
120
|
+
/**
|
|
121
|
+
* Device not found
|
|
122
|
+
*/
|
|
78
123
|
readonly DeviceNotFound: 105;
|
|
124
|
+
/**
|
|
125
|
+
* Device is not initialized
|
|
126
|
+
*/
|
|
79
127
|
readonly DeviceInitializeFailed: 106;
|
|
128
|
+
/**
|
|
129
|
+
* Device interrupted from another operation
|
|
130
|
+
*/
|
|
80
131
|
readonly DeviceInterruptedFromOutside: 107;
|
|
132
|
+
/**
|
|
133
|
+
* Device should be in bootloader mode
|
|
134
|
+
*/
|
|
81
135
|
readonly RequiredButInBootloaderMode: 108;
|
|
136
|
+
/**
|
|
137
|
+
* Device interrupted from user
|
|
138
|
+
*/
|
|
82
139
|
readonly DeviceInterruptedFromUser: 109;
|
|
140
|
+
/**
|
|
141
|
+
* Check device id is same
|
|
142
|
+
*/
|
|
83
143
|
readonly DeviceCheckDeviceIdError: 110;
|
|
144
|
+
/**
|
|
145
|
+
* Do not support passphrase
|
|
146
|
+
* @params: { require: string }
|
|
147
|
+
*/
|
|
84
148
|
readonly DeviceNotSupportPassphrase: 111;
|
|
85
149
|
readonly DeviceCheckPassphraseStateError: 112;
|
|
150
|
+
/**
|
|
151
|
+
* use passphrase, but passphrase is not opened
|
|
152
|
+
*/
|
|
86
153
|
readonly DeviceNotOpenedPassphrase: 113;
|
|
154
|
+
/**
|
|
155
|
+
* not use passphrase, but passphrase is opened
|
|
156
|
+
*/
|
|
87
157
|
readonly DeviceOpenedPassphrase: 114;
|
|
158
|
+
/**
|
|
159
|
+
* Detect hardware that is in bootloader mode and return an error.
|
|
160
|
+
*/
|
|
88
161
|
readonly DeviceDetectInBootloaderMode: 115;
|
|
162
|
+
/**
|
|
163
|
+
* Device not allow in bootloader mode
|
|
164
|
+
*/
|
|
89
165
|
readonly NotAllowInBootloaderMode: 116;
|
|
166
|
+
/**
|
|
167
|
+
* Device is busy
|
|
168
|
+
*/
|
|
90
169
|
readonly DeviceBusy: 117;
|
|
170
|
+
/**
|
|
171
|
+
* Device check unlock type not match error
|
|
172
|
+
*/
|
|
91
173
|
readonly DeviceCheckUnlockTypeError: 118;
|
|
174
|
+
/**
|
|
175
|
+
* Not initialized
|
|
176
|
+
*/
|
|
92
177
|
readonly NotInitialized: 200;
|
|
178
|
+
/**
|
|
179
|
+
* Iframe not initialized
|
|
180
|
+
*/
|
|
93
181
|
readonly IFrameNotInitialized: 300;
|
|
182
|
+
/**
|
|
183
|
+
* iframe repeat initialization
|
|
184
|
+
*/
|
|
94
185
|
readonly IFrameAleradyInitialized: 301;
|
|
186
|
+
/**
|
|
187
|
+
* iframe load failure
|
|
188
|
+
*/
|
|
95
189
|
readonly IFrameLoadFail: 302;
|
|
190
|
+
/**
|
|
191
|
+
* init iframe time out
|
|
192
|
+
*/
|
|
96
193
|
readonly IframeTimeout: 303;
|
|
194
|
+
/**
|
|
195
|
+
* iframe blocked
|
|
196
|
+
*/
|
|
97
197
|
readonly IframeBlocked: 304;
|
|
198
|
+
/**
|
|
199
|
+
* iframe host not trust
|
|
200
|
+
*/
|
|
98
201
|
readonly IframeDistrust: 305;
|
|
202
|
+
/**
|
|
203
|
+
* Runtime errors during method execution
|
|
204
|
+
*/
|
|
99
205
|
readonly CallMethodError: 400;
|
|
206
|
+
/**
|
|
207
|
+
* Method does not responding
|
|
208
|
+
*/
|
|
100
209
|
readonly CallMethodNotResponse: 404;
|
|
210
|
+
/**
|
|
211
|
+
* Call method invalid parameter
|
|
212
|
+
*/
|
|
101
213
|
readonly CallMethodInvalidParameter: 405;
|
|
214
|
+
/**
|
|
215
|
+
* firmware update download failed
|
|
216
|
+
*/
|
|
102
217
|
readonly FirmwareUpdateDownloadFailed: 406;
|
|
218
|
+
/**
|
|
219
|
+
* Call method not supported, need update firmware
|
|
220
|
+
* @params: { current: string, require: string }
|
|
221
|
+
*/
|
|
103
222
|
readonly CallMethodNeedUpgradeFirmware: 407;
|
|
223
|
+
/**
|
|
224
|
+
* Call method not supported, is deprecated
|
|
225
|
+
* @params: { current: string, deprecated: string }
|
|
226
|
+
*/
|
|
104
227
|
readonly CallMethodDeprecated: 408;
|
|
228
|
+
/**
|
|
229
|
+
* Only one device can be connected during firmware upgrade
|
|
230
|
+
*/
|
|
105
231
|
readonly FirmwareUpdateLimitOneDevice: 409;
|
|
232
|
+
/**
|
|
233
|
+
* You need to manually enter boot
|
|
234
|
+
*/
|
|
106
235
|
readonly FirmwareUpdateManuallyEnterBoot: 410;
|
|
236
|
+
/**
|
|
237
|
+
* Manual entry fails. You must manually enter the boot
|
|
238
|
+
*/
|
|
107
239
|
readonly FirmwareUpdateAutoEnterBootFailure: 411;
|
|
240
|
+
/**
|
|
241
|
+
* The new firmware has not been released yet
|
|
242
|
+
*/
|
|
108
243
|
readonly NewFirmwareUnRelease: 412;
|
|
244
|
+
/**
|
|
245
|
+
* use OneKey desktop client to update the firmware
|
|
246
|
+
* because need copy resource file to Touch
|
|
247
|
+
*/
|
|
109
248
|
readonly UseDesktopToUpdateFirmware: 413;
|
|
249
|
+
/**
|
|
250
|
+
* Mandatory firmware update
|
|
251
|
+
* @params:{ connectId: string? , deviceId: string? }
|
|
252
|
+
*/
|
|
110
253
|
readonly NewFirmwareForceUpdate: 414;
|
|
254
|
+
/**
|
|
255
|
+
* Device not support this method
|
|
256
|
+
*/
|
|
111
257
|
readonly DeviceNotSupportMethod: 415;
|
|
258
|
+
/**
|
|
259
|
+
* Forbidden key path
|
|
260
|
+
*/
|
|
112
261
|
readonly ForbiddenKeyPath: 416;
|
|
262
|
+
/**
|
|
263
|
+
* Repeat unlocking
|
|
264
|
+
* all network get address by loop need repeat unlocking
|
|
265
|
+
*/
|
|
113
266
|
readonly RepeatUnlocking: 417;
|
|
267
|
+
/**
|
|
268
|
+
* Defective firmware detected
|
|
269
|
+
*/
|
|
114
270
|
readonly DefectiveFirmware: 418;
|
|
271
|
+
/**
|
|
272
|
+
* Netword request error
|
|
273
|
+
*/
|
|
115
274
|
readonly NetworkError: 500;
|
|
275
|
+
/**
|
|
276
|
+
* Transport not configured
|
|
277
|
+
*/
|
|
116
278
|
readonly TransportNotConfigured: 600;
|
|
279
|
+
/**
|
|
280
|
+
* Transport call in progress
|
|
281
|
+
*/
|
|
117
282
|
readonly TransportCallInProgress: 601;
|
|
283
|
+
/**
|
|
284
|
+
* Transport not found
|
|
285
|
+
*/
|
|
118
286
|
readonly TransportNotFound: 602;
|
|
287
|
+
/**
|
|
288
|
+
* Transport invalid protobuf
|
|
289
|
+
*/
|
|
119
290
|
readonly TransportInvalidProtobuf: 603;
|
|
291
|
+
/**
|
|
292
|
+
* Bluetooth error code
|
|
293
|
+
*/
|
|
120
294
|
readonly BleScanError: 700;
|
|
121
295
|
readonly BlePermissionError: 701;
|
|
122
296
|
readonly BleLocationError: 702;
|
|
@@ -140,37 +314,144 @@ declare const HardwareErrorCode: {
|
|
|
140
314
|
readonly BleDeviceDisconnected: 720;
|
|
141
315
|
readonly BlePoweredOff: 721;
|
|
142
316
|
readonly BleUnsupported: 722;
|
|
317
|
+
/**
|
|
318
|
+
* Hardware runtiome errors
|
|
319
|
+
*/
|
|
143
320
|
readonly RuntimeError: 800;
|
|
321
|
+
/**
|
|
322
|
+
* invalid pin
|
|
323
|
+
*/
|
|
144
324
|
readonly PinInvalid: 801;
|
|
325
|
+
/**
|
|
326
|
+
* pin cancelled by user
|
|
327
|
+
*/
|
|
145
328
|
readonly PinCancelled: 802;
|
|
329
|
+
/**
|
|
330
|
+
* Action cancelled by user
|
|
331
|
+
*/
|
|
146
332
|
readonly ActionCancelled: 803;
|
|
333
|
+
/**
|
|
334
|
+
* Firmware installation failed
|
|
335
|
+
*/
|
|
147
336
|
readonly FirmwareError: 804;
|
|
337
|
+
/**
|
|
338
|
+
* transport response unexpect error
|
|
339
|
+
*/
|
|
148
340
|
readonly ResponseUnexpectTypeError: 805;
|
|
341
|
+
/**
|
|
342
|
+
* bridge network error
|
|
343
|
+
*/
|
|
149
344
|
readonly BridgeNetworkError: 806;
|
|
345
|
+
/**
|
|
346
|
+
* Bridge network timeout
|
|
347
|
+
*/
|
|
150
348
|
readonly BridgeTimeoutError: 807;
|
|
349
|
+
/**
|
|
350
|
+
* Bridge not installed
|
|
351
|
+
*/
|
|
151
352
|
readonly BridgeNotInstalled: 808;
|
|
353
|
+
/**
|
|
354
|
+
* ensure connect timeout
|
|
355
|
+
*/
|
|
152
356
|
readonly PollingTimeout: 809;
|
|
357
|
+
/**
|
|
358
|
+
* ensure connect stop polling
|
|
359
|
+
*/
|
|
153
360
|
readonly PollingStop: 810;
|
|
361
|
+
/**
|
|
362
|
+
* Device does not open blid sign
|
|
363
|
+
*/
|
|
154
364
|
readonly BlindSignDisabled: 811;
|
|
155
365
|
readonly UnexpectPassphrase: 812;
|
|
366
|
+
/**
|
|
367
|
+
* NFT file already exists
|
|
368
|
+
*/
|
|
156
369
|
readonly FileAlreadyExists: 813;
|
|
370
|
+
/**
|
|
371
|
+
* check file length error
|
|
372
|
+
*/
|
|
157
373
|
readonly CheckDownloadFileError: 814;
|
|
374
|
+
/**
|
|
375
|
+
* not in signing mode
|
|
376
|
+
*/
|
|
158
377
|
readonly NotInSigningMode: 815;
|
|
378
|
+
/**
|
|
379
|
+
* not in signing mode
|
|
380
|
+
*/
|
|
159
381
|
readonly DataOverload: 816;
|
|
382
|
+
/**
|
|
383
|
+
* device disconnected during action
|
|
384
|
+
*/
|
|
160
385
|
readonly BridgeDeviceDisconnected: 817;
|
|
386
|
+
/**
|
|
387
|
+
* BTC PSBT too many utxos
|
|
388
|
+
* @params:{ count: number }
|
|
389
|
+
*/
|
|
161
390
|
readonly BTCPsbtTooManyUtxos: 818;
|
|
391
|
+
/**
|
|
392
|
+
* EMMC file write firmware error
|
|
393
|
+
*/
|
|
162
394
|
readonly EmmcFileWriteFirmwareError: 819;
|
|
395
|
+
/**
|
|
396
|
+
* Firmware verification failed (e.g., bootloader file verify failed)
|
|
397
|
+
*/
|
|
163
398
|
readonly FirmwareVerificationFailed: 820;
|
|
399
|
+
/**
|
|
400
|
+
* Web bridge coonect needs permission
|
|
401
|
+
*/
|
|
164
402
|
readonly BridgeNeedsPermission: 821;
|
|
165
403
|
readonly CallQueueActionCancelled: 822;
|
|
404
|
+
/**
|
|
405
|
+
* Firmware downgrade not allowed
|
|
406
|
+
*/
|
|
166
407
|
readonly FirmwareDowngradeNotAllowed: 823;
|
|
408
|
+
/**
|
|
409
|
+
* Cosmos invalid JSON message, Only support Amino msgs.
|
|
410
|
+
*/
|
|
167
411
|
readonly CosmosInvalidJsonMessage: 824;
|
|
412
|
+
/**
|
|
413
|
+
* No setting provided
|
|
414
|
+
*/
|
|
168
415
|
readonly DeviceSettingsNotProvided: 825;
|
|
416
|
+
/**
|
|
417
|
+
* Language not supported
|
|
418
|
+
*/
|
|
169
419
|
readonly DeviceSettingsLanguageNotSupport: 826;
|
|
420
|
+
/**
|
|
421
|
+
* Too many inputs
|
|
422
|
+
* @params: { count?: string }
|
|
423
|
+
*/
|
|
170
424
|
readonly TooManyInputs: 827;
|
|
425
|
+
/**
|
|
426
|
+
* The two PIN entries did not match while setting/changing PIN on device
|
|
427
|
+
*/
|
|
171
428
|
readonly PinMismatch: 828;
|
|
429
|
+
/**
|
|
430
|
+
* Protocol V2 device must be unlocked before the requested operation.
|
|
431
|
+
* @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
|
|
432
|
+
*/
|
|
433
|
+
readonly DeviceLocked: 830;
|
|
434
|
+
/**
|
|
435
|
+
* The cached wallet session is invalid or has expired.
|
|
436
|
+
* @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
|
|
437
|
+
*/
|
|
438
|
+
readonly WalletSessionInvalid: 831;
|
|
439
|
+
/**
|
|
440
|
+
* Pro2 NFT storage has reached its item limit.
|
|
441
|
+
* @params: { count: number; limit: number }
|
|
442
|
+
*/
|
|
443
|
+
readonly NftStorageLimitReached: 832;
|
|
444
|
+
/**
|
|
445
|
+
* Lowlevel transport connect error
|
|
446
|
+
*/
|
|
172
447
|
readonly LowlevelTrasnportConnectError: 900;
|
|
448
|
+
/**
|
|
449
|
+
* Web USB or Web Bluetooth device not found or needs permission
|
|
450
|
+
*/
|
|
173
451
|
readonly WebDeviceNotFoundOrNeedsPermission: 901;
|
|
452
|
+
/**
|
|
453
|
+
* Web USB or Web Bluetooth device prompt access error
|
|
454
|
+
*/
|
|
174
455
|
readonly WebDevicePromptAccessError: 902;
|
|
175
456
|
};
|
|
176
457
|
declare const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping;
|
|
@@ -242,7 +523,8 @@ declare enum EDeviceType {
|
|
|
242
523
|
Mini = "mini",
|
|
243
524
|
Touch = "touch",
|
|
244
525
|
Pro = "pro",
|
|
245
|
-
Pro2 = "pro2"
|
|
526
|
+
Pro2 = "pro2",
|
|
527
|
+
Neo = "neo"
|
|
246
528
|
}
|
|
247
529
|
|
|
248
|
-
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_SERVICE_UUID, ONEKEY_WEBUSB_FILTER, ONEKEY_WRITE_CHARACTERISTIC_UUID, TypedError, createDefectiveFirmwareError, createDeferred, createDeprecatedHardwareError, createDeviceNotSupportMethodError, createNeedUpgradeFirmwareHardwareError, createNewFirmwareForceUpdateHardwareError, createNewFirmwareUnReleaseHardwareError, isHeaderChunk, isOnekeyDevice, serializeError, wait };
|
|
530
|
+
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_SERVICE_UUID, ONEKEY_WEBUSB_FILTER, ONEKEY_WRITE_CHARACTERISTIC_UUID, TypedError, createDefectiveFirmwareError, createDeferred, createDeprecatedHardwareError, createDeviceNotSupportMethodError, createKnownBleUuidAliases, createNeedUpgradeFirmwareHardwareError, createNewFirmwareForceUpdateHardwareError, createNewFirmwareUnReleaseHardwareError, hasOnekeyCommunicationService, isHeaderChunk, isKnownTrezorWebUsbDevice, isOnekeyBluetoothDevice, isOnekeyDevice, isPro2FindMyAdvertisementName, matchesKnownBleUuid, normalizeBleUuid, serializeError, wait };
|
package/dist/index.js
CHANGED
|
@@ -164,6 +164,9 @@ const HardwareErrorCode = {
|
|
|
164
164
|
DeviceSettingsLanguageNotSupport: 826,
|
|
165
165
|
TooManyInputs: 827,
|
|
166
166
|
PinMismatch: 828,
|
|
167
|
+
DeviceLocked: 830,
|
|
168
|
+
WalletSessionInvalid: 831,
|
|
169
|
+
NftStorageLimitReached: 832,
|
|
167
170
|
LowlevelTrasnportConnectError: 900,
|
|
168
171
|
WebDeviceNotFoundOrNeedsPermission: 901,
|
|
169
172
|
WebDevicePromptAccessError: 902,
|
|
@@ -268,6 +271,9 @@ const HardwareErrorCodeMessage = {
|
|
|
268
271
|
[HardwareErrorCode.DeviceSettingsLanguageNotSupport]: 'Language not supported',
|
|
269
272
|
[HardwareErrorCode.TooManyInputs]: 'Too many inputs',
|
|
270
273
|
[HardwareErrorCode.PinMismatch]: 'PIN mismatch',
|
|
274
|
+
[HardwareErrorCode.DeviceLocked]: 'Device locked',
|
|
275
|
+
[HardwareErrorCode.WalletSessionInvalid]: 'Wallet session is invalid or expired',
|
|
276
|
+
[HardwareErrorCode.NftStorageLimitReached]: 'NFT storage limit reached. Remove an NFT from the device and try again.',
|
|
271
277
|
[HardwareErrorCode.LowlevelTrasnportConnectError]: 'Lowlevel transport connect error',
|
|
272
278
|
[HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission]: 'Web-USB or Web-Bluetooth device not found or needs permission',
|
|
273
279
|
[HardwareErrorCode.WebDevicePromptAccessError]: 'Web-USB or Web-Bluetooth device prompt access error',
|
|
@@ -391,6 +397,15 @@ const ONEKEY_WEBUSB_FILTER = [
|
|
|
391
397
|
{ vendorId: 0x1209, productId: 0x4f4b },
|
|
392
398
|
{ vendorId: 0x1209, productId: 0x4f4c },
|
|
393
399
|
];
|
|
400
|
+
const TREZOR_WEBUSB_MANUFACTURER_NAMES = new Set(['trezor', 'trezor company', 'satoshilabs']);
|
|
401
|
+
const isKnownTrezorWebUsbDevice = (descriptor) => {
|
|
402
|
+
var _a;
|
|
403
|
+
const isSharedWebUsbId = ONEKEY_WEBUSB_FILTER.some(filter => descriptor.vendorId === filter.vendorId && descriptor.productId === filter.productId);
|
|
404
|
+
if (!isSharedWebUsbId)
|
|
405
|
+
return false;
|
|
406
|
+
const manufacturerName = (_a = descriptor.manufacturerName) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase();
|
|
407
|
+
return manufacturerName != null && TREZOR_WEBUSB_MANUFACTURER_NAMES.has(manufacturerName);
|
|
408
|
+
};
|
|
394
409
|
const ERROR_CODES_REQUIRE_RELEASE = [
|
|
395
410
|
HardwareErrorCode.DeviceInitializeFailed,
|
|
396
411
|
HardwareErrorCode.DeviceInterruptedFromOutside,
|
|
@@ -446,16 +461,78 @@ const isHeaderChunk = (chunk) => {
|
|
|
446
461
|
}
|
|
447
462
|
return false;
|
|
448
463
|
};
|
|
464
|
+
const isKnownNonOneKeyDeviceName = (normalizedName) => normalizedName.startsWith('trezor') ||
|
|
465
|
+
normalizedName.startsWith('ledger') ||
|
|
466
|
+
normalizedName.startsWith('nano ') ||
|
|
467
|
+
normalizedName.startsWith('stax') ||
|
|
468
|
+
normalizedName.startsWith('flex');
|
|
469
|
+
const ONEKEY_EXACT_SHORT_NAMES = new Set(['s8']);
|
|
470
|
+
const isOneKeyShortName = (normalizedName) => {
|
|
471
|
+
if (ONEKEY_EXACT_SHORT_NAMES.has(normalizedName))
|
|
472
|
+
return true;
|
|
473
|
+
if (normalizedName.length !== 5)
|
|
474
|
+
return false;
|
|
475
|
+
const firstChar = normalizedName[0];
|
|
476
|
+
return (firstChar === 'k' || firstChar === 't') && /^\d{4}$/.test(normalizedName.slice(1));
|
|
477
|
+
};
|
|
449
478
|
const isOnekeyDevice = (name, id) => {
|
|
450
|
-
var _a;
|
|
451
|
-
|
|
479
|
+
var _a, _b;
|
|
480
|
+
const normalizedName = (_a = name === null || name === void 0 ? void 0 : name.trim().toLowerCase()) !== null && _a !== void 0 ? _a : '';
|
|
481
|
+
if (isKnownNonOneKeyDeviceName(normalizedName)) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
if ((_b = id === null || id === void 0 ? void 0 : id.startsWith) === null || _b === void 0 ? void 0 : _b.call(id, 'MI')) {
|
|
452
485
|
return true;
|
|
453
486
|
}
|
|
454
|
-
|
|
455
|
-
|
|
487
|
+
if (!name) {
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
if (normalizedName.startsWith('onekey') || normalizedName.startsWith('bixinkey'))
|
|
491
|
+
return true;
|
|
492
|
+
if (normalizedName.startsWith('touch ') ||
|
|
493
|
+
normalizedName.startsWith('pro ') ||
|
|
494
|
+
normalizedName.startsWith('pro2 ') ||
|
|
495
|
+
normalizedName.startsWith('neo ')) {
|
|
456
496
|
return true;
|
|
457
497
|
}
|
|
458
|
-
return
|
|
498
|
+
return isOneKeyShortName(normalizedName);
|
|
499
|
+
};
|
|
500
|
+
const BLUETOOTH_BASE_UUID_SUFFIX = '00001000800000805f9b34fb';
|
|
501
|
+
const normalizeBleUuid = (uuid) => (uuid !== null && uuid !== void 0 ? uuid : '').replace(/-/g, '').toLowerCase();
|
|
502
|
+
const createKnownBleUuidAliases = (uuid) => {
|
|
503
|
+
const normalized = normalizeBleUuid(uuid);
|
|
504
|
+
const aliases = new Set([normalized]);
|
|
505
|
+
if (normalized.length !== 32 || !normalized.endsWith(BLUETOOTH_BASE_UUID_SUFFIX)) {
|
|
506
|
+
return aliases;
|
|
507
|
+
}
|
|
508
|
+
const assignedNumber = normalized.slice(0, 8);
|
|
509
|
+
aliases.add(assignedNumber);
|
|
510
|
+
if (assignedNumber.startsWith('0000')) {
|
|
511
|
+
aliases.add(assignedNumber.slice(4));
|
|
512
|
+
}
|
|
513
|
+
return aliases;
|
|
514
|
+
};
|
|
515
|
+
const matchesKnownBleUuid = (actualUuid, aliases) => aliases.has(normalizeBleUuid(actualUuid));
|
|
516
|
+
const ONEKEY_COMMUNICATION_SERVICE_ALIASES = createKnownBleUuidAliases(ONEKEY_SERVICE_UUID);
|
|
517
|
+
const FIDO_SERVICE_ALIASES = createKnownBleUuidAliases('0000fffd-0000-1000-8000-00805f9b34fb');
|
|
518
|
+
const isPro2FindMyAdvertisementName = (value) => {
|
|
519
|
+
var _a;
|
|
520
|
+
const normalizedName = (_a = value === null || value === void 0 ? void 0 : value.trim().toLowerCase()) !== null && _a !== void 0 ? _a : '';
|
|
521
|
+
return /\bpro\s*2\b/.test(normalizedName) && /\bfinde?\s+my\b/.test(normalizedName);
|
|
522
|
+
};
|
|
523
|
+
const hasOnekeyCommunicationService = (serviceUuids) => (serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : []).some(uuid => matchesKnownBleUuid(uuid, ONEKEY_COMMUNICATION_SERVICE_ALIASES));
|
|
524
|
+
const isOnekeyBluetoothDevice = ({ id, name, localName, serviceUuids, }) => {
|
|
525
|
+
const advertisedServiceUuids = serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : [];
|
|
526
|
+
if (hasOnekeyCommunicationService(advertisedServiceUuids)) {
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
if (isPro2FindMyAdvertisementName(name) || isPro2FindMyAdvertisementName(localName)) {
|
|
530
|
+
return false;
|
|
531
|
+
}
|
|
532
|
+
if (advertisedServiceUuids.some(uuid => matchesKnownBleUuid(uuid, FIDO_SERVICE_ALIASES))) {
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
return isOnekeyDevice(name !== null && name !== void 0 ? name : null, id) || isOnekeyDevice(localName !== null && localName !== void 0 ? localName : null, id);
|
|
459
536
|
};
|
|
460
537
|
|
|
461
538
|
/******************************************************************************
|
|
@@ -529,6 +606,7 @@ exports.EDeviceType = void 0;
|
|
|
529
606
|
EDeviceType["Touch"] = "touch";
|
|
530
607
|
EDeviceType["Pro"] = "pro";
|
|
531
608
|
EDeviceType["Pro2"] = "pro2";
|
|
609
|
+
EDeviceType["Neo"] = "neo";
|
|
532
610
|
})(exports.EDeviceType || (exports.EDeviceType = {}));
|
|
533
611
|
|
|
534
612
|
exports.CreateErrorByMessage = CreateErrorByMessage;
|
|
@@ -549,10 +627,17 @@ exports.createDefectiveFirmwareError = createDefectiveFirmwareError;
|
|
|
549
627
|
exports.createDeferred = createDeferred;
|
|
550
628
|
exports.createDeprecatedHardwareError = createDeprecatedHardwareError;
|
|
551
629
|
exports.createDeviceNotSupportMethodError = createDeviceNotSupportMethodError;
|
|
630
|
+
exports.createKnownBleUuidAliases = createKnownBleUuidAliases;
|
|
552
631
|
exports.createNeedUpgradeFirmwareHardwareError = createNeedUpgradeFirmwareHardwareError;
|
|
553
632
|
exports.createNewFirmwareForceUpdateHardwareError = createNewFirmwareForceUpdateHardwareError;
|
|
554
633
|
exports.createNewFirmwareUnReleaseHardwareError = createNewFirmwareUnReleaseHardwareError;
|
|
634
|
+
exports.hasOnekeyCommunicationService = hasOnekeyCommunicationService;
|
|
555
635
|
exports.isHeaderChunk = isHeaderChunk;
|
|
636
|
+
exports.isKnownTrezorWebUsbDevice = isKnownTrezorWebUsbDevice;
|
|
637
|
+
exports.isOnekeyBluetoothDevice = isOnekeyBluetoothDevice;
|
|
556
638
|
exports.isOnekeyDevice = isOnekeyDevice;
|
|
639
|
+
exports.isPro2FindMyAdvertisementName = isPro2FindMyAdvertisementName;
|
|
640
|
+
exports.matchesKnownBleUuid = matchesKnownBleUuid;
|
|
641
|
+
exports.normalizeBleUuid = normalizeBleUuid;
|
|
557
642
|
exports.serializeError = serializeError;
|
|
558
643
|
exports.wait = wait;
|
package/jest.config.js
ADDED
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.70",
|
|
4
4
|
"description": "Hardware SDK's shared tool library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Hardware-SDK",
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"dev": "rimraf dist && rollup -c ../../build/rollup.config.js -w",
|
|
24
24
|
"build": "rimraf dist && rollup -c ../../build/rollup.config.js",
|
|
25
|
+
"test": "jest",
|
|
25
26
|
"lint": "eslint .",
|
|
26
27
|
"lint:fix": "eslint . --fix"
|
|
27
28
|
},
|
|
28
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "d86b033cf970f97e060c49fe4cf618f38b9ce666"
|
|
29
30
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HardwareErrorCode } from './HardwareError';
|
|
2
|
+
|
|
3
|
+
describe('HardwareErrorCode compatibility', () => {
|
|
4
|
+
test('preserves published Protocol V2 values while leaving code 829 unused', () => {
|
|
5
|
+
expect(HardwareErrorCode).not.toHaveProperty('KaspaPrevTxIdMismatch');
|
|
6
|
+
expect(HardwareErrorCode.DeviceLocked).toBe(830);
|
|
7
|
+
expect(HardwareErrorCode.WalletSessionInvalid).toBe(831);
|
|
8
|
+
});
|
|
9
|
+
});
|
package/src/HardwareError.ts
CHANGED
|
@@ -484,6 +484,24 @@ export const HardwareErrorCode = {
|
|
|
484
484
|
*/
|
|
485
485
|
PinMismatch: 828,
|
|
486
486
|
|
|
487
|
+
/**
|
|
488
|
+
* Protocol V2 device must be unlocked before the requested operation.
|
|
489
|
+
* @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
|
|
490
|
+
*/
|
|
491
|
+
DeviceLocked: 830,
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* The cached wallet session is invalid or has expired.
|
|
495
|
+
* @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
|
|
496
|
+
*/
|
|
497
|
+
WalletSessionInvalid: 831,
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Pro2 NFT storage has reached its item limit.
|
|
501
|
+
* @params: { count: number; limit: number }
|
|
502
|
+
*/
|
|
503
|
+
NftStorageLimitReached: 832,
|
|
504
|
+
|
|
487
505
|
/**
|
|
488
506
|
* Lowlevel transport connect error
|
|
489
507
|
*/
|
|
@@ -635,6 +653,10 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
|
|
|
635
653
|
[HardwareErrorCode.DeviceSettingsLanguageNotSupport]: 'Language not supported',
|
|
636
654
|
[HardwareErrorCode.TooManyInputs]: 'Too many inputs',
|
|
637
655
|
[HardwareErrorCode.PinMismatch]: 'PIN mismatch',
|
|
656
|
+
[HardwareErrorCode.DeviceLocked]: 'Device locked',
|
|
657
|
+
[HardwareErrorCode.WalletSessionInvalid]: 'Wallet session is invalid or expired',
|
|
658
|
+
[HardwareErrorCode.NftStorageLimitReached]:
|
|
659
|
+
'NFT storage limit reached. Remove an NFT from the device and try again.',
|
|
638
660
|
|
|
639
661
|
/**
|
|
640
662
|
* Lowlevel transport
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createKnownBleUuidAliases,
|
|
3
|
+
hasOnekeyCommunicationService,
|
|
4
|
+
isKnownTrezorWebUsbDevice,
|
|
5
|
+
isOnekeyBluetoothDevice,
|
|
6
|
+
isOnekeyDevice,
|
|
7
|
+
matchesKnownBleUuid,
|
|
8
|
+
} from './constants';
|
|
9
|
+
|
|
10
|
+
describe('hardware device identity filters', () => {
|
|
11
|
+
it('accepts known OneKey BLE names', () => {
|
|
12
|
+
expect(isOnekeyDevice('Touch A1B2')).toBe(true);
|
|
13
|
+
expect(isOnekeyDevice('Pro A1B2')).toBe(true);
|
|
14
|
+
expect(isOnekeyDevice('Neo A1B2')).toBe(true);
|
|
15
|
+
expect(isOnekeyDevice('K1234')).toBe(true);
|
|
16
|
+
expect(isOnekeyDevice('S8')).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('rejects known Trezor and Ledger BLE names from OneKey discovery', () => {
|
|
20
|
+
expect(isOnekeyDevice('Trezor Safe 7')).toBe(false);
|
|
21
|
+
expect(isOnekeyDevice('Ledger Nano X')).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('does not identify an FFFD-only advertisement as OneKey', () => {
|
|
25
|
+
expect(isOnekeyBluetoothDevice({ name: 'Find My', serviceUuids: ['fffd'] })).toBe(false);
|
|
26
|
+
expect(
|
|
27
|
+
isOnekeyBluetoothDevice({ serviceUuids: ['0000fffd-0000-1000-8000-00805f9b34fb'] })
|
|
28
|
+
).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('identifies Pro2 communication advertisements independently of their display name', () => {
|
|
32
|
+
expect(
|
|
33
|
+
isOnekeyBluetoothDevice({
|
|
34
|
+
name: 'Pro2 A1B2',
|
|
35
|
+
serviceUuids: ['0001', 'fffd'],
|
|
36
|
+
})
|
|
37
|
+
).toBe(true);
|
|
38
|
+
expect(
|
|
39
|
+
isOnekeyBluetoothDevice({
|
|
40
|
+
localName: 'Pro2 A1B2 - Find My',
|
|
41
|
+
serviceUuids: ['0001', 'fffd'],
|
|
42
|
+
})
|
|
43
|
+
).toBe(true);
|
|
44
|
+
expect(
|
|
45
|
+
isOnekeyBluetoothDevice({
|
|
46
|
+
name: 'Pro2 5E9D - Finde My',
|
|
47
|
+
serviceUuids: ['0001', 'fffd'],
|
|
48
|
+
})
|
|
49
|
+
).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('rejects Pro2 Find My entries when the communication service is absent', () => {
|
|
53
|
+
expect(
|
|
54
|
+
isOnekeyBluetoothDevice({
|
|
55
|
+
name: 'Pro2 A1B2 - Find My',
|
|
56
|
+
})
|
|
57
|
+
).toBe(false);
|
|
58
|
+
expect(
|
|
59
|
+
isOnekeyBluetoothDevice({
|
|
60
|
+
localName: 'OneKey Pro 2 A1B2 - Find My',
|
|
61
|
+
serviceUuids: [],
|
|
62
|
+
})
|
|
63
|
+
).toBe(false);
|
|
64
|
+
expect(
|
|
65
|
+
isOnekeyBluetoothDevice({
|
|
66
|
+
name: 'Pro2 5E9D - Finde My',
|
|
67
|
+
serviceUuids: ['fffd'],
|
|
68
|
+
})
|
|
69
|
+
).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('keeps OneKey discovery on the communication service', () => {
|
|
73
|
+
expect(
|
|
74
|
+
isOnekeyBluetoothDevice({
|
|
75
|
+
name: 'OneKey Pro 2',
|
|
76
|
+
serviceUuids: ['00000001-0000-1000-8000-00805f9b34fb'],
|
|
77
|
+
})
|
|
78
|
+
).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('only aliases standard Bluetooth Base UUID representations', () => {
|
|
82
|
+
const aliases = createKnownBleUuidAliases('00000001-0000-1000-8000-00805f9b34fb');
|
|
83
|
+
|
|
84
|
+
expect(matchesKnownBleUuid('0001', aliases)).toBe(true);
|
|
85
|
+
expect(matchesKnownBleUuid('00000001', aliases)).toBe(true);
|
|
86
|
+
expect(matchesKnownBleUuid('abcd0001-1234-5678-9012-abcdefabcdef', aliases)).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('does not treat vendor-specific UUID fragments as communication or FIDO services', () => {
|
|
90
|
+
expect(
|
|
91
|
+
isOnekeyBluetoothDevice({
|
|
92
|
+
name: 'OneKey Pro 2',
|
|
93
|
+
serviceUuids: ['abcdfffd-1234-5678-9012-abcdefabcdef'],
|
|
94
|
+
})
|
|
95
|
+
).toBe(true);
|
|
96
|
+
expect(
|
|
97
|
+
isOnekeyBluetoothDevice({
|
|
98
|
+
serviceUuids: ['abcd0001-1234-5678-9012-abcdefabcdef'],
|
|
99
|
+
})
|
|
100
|
+
).toBe(false);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('requires an explicitly advertised communication service for strict discovery', () => {
|
|
104
|
+
expect(hasOnekeyCommunicationService([])).toBe(false);
|
|
105
|
+
expect(hasOnekeyCommunicationService(['0001'])).toBe(true);
|
|
106
|
+
expect(hasOnekeyCommunicationService(['abcd0001-1234-5678-9012-abcdefabcdef'])).toBe(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('only filters WebUSB descriptors that are explicitly identified as Trezor', () => {
|
|
110
|
+
expect(
|
|
111
|
+
isKnownTrezorWebUsbDevice({
|
|
112
|
+
vendorId: 0x1209,
|
|
113
|
+
productId: 0x53c1,
|
|
114
|
+
manufacturerName: 'Trezor Company',
|
|
115
|
+
})
|
|
116
|
+
).toBe(true);
|
|
117
|
+
expect(
|
|
118
|
+
isKnownTrezorWebUsbDevice({
|
|
119
|
+
vendorId: 0x1209,
|
|
120
|
+
productId: 0x53c1,
|
|
121
|
+
manufacturerName: 'Trezor',
|
|
122
|
+
})
|
|
123
|
+
).toBe(true);
|
|
124
|
+
expect(
|
|
125
|
+
isKnownTrezorWebUsbDevice({
|
|
126
|
+
vendorId: 0x1209,
|
|
127
|
+
productId: 0x53c1,
|
|
128
|
+
manufacturerName: 'SatoshiLabs',
|
|
129
|
+
})
|
|
130
|
+
).toBe(true);
|
|
131
|
+
|
|
132
|
+
expect(
|
|
133
|
+
isKnownTrezorWebUsbDevice({
|
|
134
|
+
vendorId: 0x1209,
|
|
135
|
+
productId: 0x53c1,
|
|
136
|
+
manufacturerName: 'OneKey',
|
|
137
|
+
})
|
|
138
|
+
).toBe(false);
|
|
139
|
+
expect(
|
|
140
|
+
isKnownTrezorWebUsbDevice({
|
|
141
|
+
vendorId: 0x1209,
|
|
142
|
+
productId: 0x53c1,
|
|
143
|
+
})
|
|
144
|
+
).toBe(false);
|
|
145
|
+
expect(
|
|
146
|
+
isKnownTrezorWebUsbDevice({
|
|
147
|
+
vendorId: 0x1209,
|
|
148
|
+
productId: 0x53c1,
|
|
149
|
+
productName: 'Trezor Safe 7',
|
|
150
|
+
})
|
|
151
|
+
).toBe(false);
|
|
152
|
+
});
|
|
153
|
+
});
|
package/src/constants.ts
CHANGED
|
@@ -10,13 +10,31 @@ export type HardwareConnectProtocol =
|
|
|
10
10
|
|
|
11
11
|
export const ONEKEY_WEBUSB_FILTER = [
|
|
12
12
|
{ vendorId: 0x1209, productId: 0x53c0 }, // Classic Boot、Classic1s Boot、Mini Boot
|
|
13
|
-
{ vendorId: 0x1209, productId: 0x53c1 }, // Classic
|
|
14
|
-
{ vendorId: 0x1209, productId: 0x4f4a }, // Pro
|
|
15
|
-
{ vendorId: 0x1209, productId: 0x4f4b }, // Pro
|
|
16
|
-
{ vendorId: 0x1209, productId: 0x4f4c }, // Pro
|
|
13
|
+
{ vendorId: 0x1209, productId: 0x53c1 }, // Classic/Classic1s/Mini/Pro/Touch firmware and legacy Pro2; keep for existing devices
|
|
14
|
+
{ vendorId: 0x1209, productId: 0x4f4a }, // Pro bootloader, Touch bootloader, Pro2
|
|
15
|
+
{ vendorId: 0x1209, productId: 0x4f4b }, // Pro/Touch firmware (Trezor not implemented), Pro2
|
|
16
|
+
{ vendorId: 0x1209, productId: 0x4f4c }, // Pro board and Pro2 with the new firmware PID
|
|
17
17
|
// { vendorId: 0x1209, productId: 0x4f50 }, // Touch Board
|
|
18
18
|
];
|
|
19
19
|
|
|
20
|
+
type WebUsbIdentityDescriptor = {
|
|
21
|
+
vendorId?: number;
|
|
22
|
+
productId?: number;
|
|
23
|
+
manufacturerName?: string | null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const TREZOR_WEBUSB_MANUFACTURER_NAMES = new Set(['trezor', 'trezor company', 'satoshilabs']);
|
|
27
|
+
|
|
28
|
+
export const isKnownTrezorWebUsbDevice = (descriptor: WebUsbIdentityDescriptor): boolean => {
|
|
29
|
+
const isSharedWebUsbId = ONEKEY_WEBUSB_FILTER.some(
|
|
30
|
+
filter => descriptor.vendorId === filter.vendorId && descriptor.productId === filter.productId
|
|
31
|
+
);
|
|
32
|
+
if (!isSharedWebUsbId) return false;
|
|
33
|
+
|
|
34
|
+
const manufacturerName = descriptor.manufacturerName?.trim().toLowerCase();
|
|
35
|
+
return manufacturerName != null && TREZOR_WEBUSB_MANUFACTURER_NAMES.has(manufacturerName);
|
|
36
|
+
};
|
|
37
|
+
|
|
20
38
|
/**
|
|
21
39
|
* Error codes that require device release after occurrence
|
|
22
40
|
* These errors indicate the device is in an invalid state and needs to be released
|
|
@@ -97,16 +115,115 @@ export const isHeaderChunk = (chunk: Buffer | Uint8Array): boolean => {
|
|
|
97
115
|
return false;
|
|
98
116
|
};
|
|
99
117
|
|
|
118
|
+
const isKnownNonOneKeyDeviceName = (normalizedName: string): boolean =>
|
|
119
|
+
normalizedName.startsWith('trezor') ||
|
|
120
|
+
normalizedName.startsWith('ledger') ||
|
|
121
|
+
normalizedName.startsWith('nano ') ||
|
|
122
|
+
normalizedName.startsWith('stax') ||
|
|
123
|
+
normalizedName.startsWith('flex');
|
|
124
|
+
|
|
125
|
+
const ONEKEY_EXACT_SHORT_NAMES = new Set(['s8']);
|
|
126
|
+
|
|
127
|
+
const isOneKeyShortName = (normalizedName: string): boolean => {
|
|
128
|
+
if (ONEKEY_EXACT_SHORT_NAMES.has(normalizedName)) return true;
|
|
129
|
+
if (normalizedName.length !== 5) return false;
|
|
130
|
+
const firstChar = normalizedName[0];
|
|
131
|
+
return (firstChar === 'k' || firstChar === 't') && /^\d{4}$/.test(normalizedName.slice(1));
|
|
132
|
+
};
|
|
133
|
+
|
|
100
134
|
export const isOnekeyDevice = (name: string | null, id?: string): boolean => {
|
|
135
|
+
const normalizedName = name?.trim().toLowerCase() ?? '';
|
|
136
|
+
if (isKnownNonOneKeyDeviceName(normalizedName)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
101
140
|
if (id?.startsWith?.('MI')) {
|
|
102
141
|
return true;
|
|
103
142
|
}
|
|
104
143
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (
|
|
144
|
+
if (!name) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
if (normalizedName.startsWith('onekey') || normalizedName.startsWith('bixinkey')) return true;
|
|
148
|
+
if (
|
|
149
|
+
normalizedName.startsWith('touch ') ||
|
|
150
|
+
normalizedName.startsWith('pro ') ||
|
|
151
|
+
normalizedName.startsWith('pro2 ') ||
|
|
152
|
+
normalizedName.startsWith('neo ')
|
|
153
|
+
) {
|
|
109
154
|
return true;
|
|
110
155
|
}
|
|
111
|
-
return
|
|
156
|
+
return isOneKeyShortName(normalizedName);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
type BluetoothDeviceIdentity = {
|
|
160
|
+
id?: string;
|
|
161
|
+
name?: string | null;
|
|
162
|
+
localName?: string | null;
|
|
163
|
+
serviceUuids?: Array<string | null | undefined> | null;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const BLUETOOTH_BASE_UUID_SUFFIX = '00001000800000805f9b34fb';
|
|
167
|
+
|
|
168
|
+
export const normalizeBleUuid = (uuid?: string | null) =>
|
|
169
|
+
(uuid ?? '').replace(/-/g, '').toLowerCase();
|
|
170
|
+
|
|
171
|
+
export const createKnownBleUuidAliases = (uuid: string): ReadonlySet<string> => {
|
|
172
|
+
const normalized = normalizeBleUuid(uuid);
|
|
173
|
+
const aliases = new Set([normalized]);
|
|
174
|
+
|
|
175
|
+
if (normalized.length !== 32 || !normalized.endsWith(BLUETOOTH_BASE_UUID_SUFFIX)) {
|
|
176
|
+
return aliases;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const assignedNumber = normalized.slice(0, 8);
|
|
180
|
+
aliases.add(assignedNumber);
|
|
181
|
+
if (assignedNumber.startsWith('0000')) {
|
|
182
|
+
aliases.add(assignedNumber.slice(4));
|
|
183
|
+
}
|
|
184
|
+
return aliases;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const matchesKnownBleUuid = (
|
|
188
|
+
actualUuid: string | null | undefined,
|
|
189
|
+
aliases: ReadonlySet<string>
|
|
190
|
+
) => aliases.has(normalizeBleUuid(actualUuid));
|
|
191
|
+
|
|
192
|
+
const ONEKEY_COMMUNICATION_SERVICE_ALIASES = createKnownBleUuidAliases(ONEKEY_SERVICE_UUID);
|
|
193
|
+
const FIDO_SERVICE_ALIASES = createKnownBleUuidAliases('0000fffd-0000-1000-8000-00805f9b34fb');
|
|
194
|
+
|
|
195
|
+
export const isPro2FindMyAdvertisementName = (value?: string | null) => {
|
|
196
|
+
const normalizedName = value?.trim().toLowerCase() ?? '';
|
|
197
|
+
return /\bpro\s*2\b/.test(normalizedName) && /\bfinde?\s+my\b/.test(normalizedName);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const hasOnekeyCommunicationService = (
|
|
201
|
+
serviceUuids: Array<string | null | undefined> | null | undefined
|
|
202
|
+
) =>
|
|
203
|
+
(serviceUuids ?? []).some(uuid =>
|
|
204
|
+
matchesKnownBleUuid(uuid, ONEKEY_COMMUNICATION_SERVICE_ALIASES)
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
export const isOnekeyBluetoothDevice = ({
|
|
208
|
+
id,
|
|
209
|
+
name,
|
|
210
|
+
localName,
|
|
211
|
+
serviceUuids,
|
|
212
|
+
}: BluetoothDeviceIdentity): boolean => {
|
|
213
|
+
const advertisedServiceUuids = serviceUuids ?? [];
|
|
214
|
+
if (hasOnekeyCommunicationService(advertisedServiceUuids)) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Android can return a connected Find My peripheral without its advertised
|
|
219
|
+
// services. Do not let the Pro2-looking name fall through to name discovery.
|
|
220
|
+
if (isPro2FindMyAdvertisementName(name) || isPro2FindMyAdvertisementName(localName)) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (advertisedServiceUuids.some(uuid => matchesKnownBleUuid(uuid, FIDO_SERVICE_ALIASES))) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return isOnekeyDevice(name ?? null, id) || isOnekeyDevice(localName ?? null, id);
|
|
112
229
|
};
|