@onekeyfe/hd-shared 1.2.0-alpha.17 → 1.2.0-alpha.170

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.
@@ -86,6 +86,7 @@ export declare const HardwareErrorCode: {
86
86
  readonly BleDeviceDisconnected: 720;
87
87
  readonly BlePoweredOff: 721;
88
88
  readonly BleUnsupported: 722;
89
+ readonly BleUnavailableWhileUsbConnected: 723;
89
90
  readonly RuntimeError: 800;
90
91
  readonly PinInvalid: 801;
91
92
  readonly PinCancelled: 802;
@@ -115,7 +116,9 @@ export declare const HardwareErrorCode: {
115
116
  readonly DeviceSettingsLanguageNotSupport: 826;
116
117
  readonly TooManyInputs: 827;
117
118
  readonly PinMismatch: 828;
118
- readonly DeviceLocked: 829;
119
+ readonly DeviceLocked: 830;
120
+ readonly WalletSessionInvalid: 831;
121
+ readonly NftStorageLimitReached: 832;
119
122
  readonly LowlevelTrasnportConnectError: 900;
120
123
  readonly WebDeviceNotFoundOrNeedsPermission: 901;
121
124
  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,qBA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AM,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"}
@@ -8,6 +8,10 @@ export declare const ONEKEY_WEBUSB_FILTER: {
8
8
  vendorId: number;
9
9
  productId: number;
10
10
  }[];
11
+ export declare const ONEKEY_PROTOCOL_V2_USB_IDS: readonly [{
12
+ readonly vendorId: 4617;
13
+ readonly productId: 20300;
14
+ }];
11
15
  type WebUsbIdentityDescriptor = {
12
16
  vendorId?: number;
13
17
  productId?: number;
@@ -33,17 +37,46 @@ export declare enum EOneKeyBleMessageKeys {
33
37
  NOBLE_BLE_STOP_SCAN = "$onekey-noble-ble-stop-scan",
34
38
  NOBLE_BLE_GET_DEVICE = "$onekey-noble-ble-get-device",
35
39
  NOBLE_BLE_CONNECT = "$onekey-noble-ble-connect",
40
+ NOBLE_BLE_RELEASE = "$onekey-noble-ble-release",
36
41
  NOBLE_BLE_DISCONNECT = "$onekey-noble-ble-disconnect",
37
42
  NOBLE_BLE_WRITE = "$onekey-noble-ble-write",
38
43
  NOBLE_BLE_SUBSCRIBE = "$onekey-noble-ble-subscribe",
39
44
  NOBLE_BLE_UNSUBSCRIBE = "$onekey-noble-ble-unsubscribe",
40
45
  NOBLE_BLE_NOTIFICATION = "$onekey-noble-ble-notification",
46
+ NOBLE_BLE_MTU_CHANGED = "$onekey-noble-ble-mtu-changed",
41
47
  NOBLE_BLE_CANCEL_PAIRING = "$onekey-noble-ble-cancel-pairing"
42
48
  }
49
+ export declare enum EBleDisconnectReason {
50
+ DeviceDisconnected = "device-disconnected",
51
+ IdleKeepAlive = "idle-keep-alive"
52
+ }
43
53
  export declare const ONEKEY_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
44
54
  export declare const ONEKEY_WRITE_CHARACTERISTIC_UUID = "00000002-0000-1000-8000-00805f9b34fb";
45
55
  export declare const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = "00000003-0000-1000-8000-00805f9b34fb";
46
56
  export declare const isHeaderChunk: (chunk: Buffer | Uint8Array) => boolean;
47
57
  export declare const isOnekeyDevice: (name: string | null, id?: string) => boolean;
58
+ export declare const inferProtocolHintFromUsbId: (vendorId?: number | null, productId?: number | null) => "V2" | undefined;
59
+ type UsbDevicePathInput = {
60
+ serialNumber?: string | null;
61
+ vendorId?: number;
62
+ productId?: number;
63
+ productName?: string | null;
64
+ };
65
+ export declare const resolveOneKeyUsbDevicePath: (device: UsbDevicePathInput) => string | undefined;
66
+ type BluetoothDeviceIdentity = {
67
+ id?: string;
68
+ name?: string | null;
69
+ localName?: string | null;
70
+ serviceUuids?: Array<string | null | undefined> | null;
71
+ };
72
+ export declare const normalizeBleUuid: (uuid?: string | null) => string;
73
+ export declare const createKnownBleUuidAliases: (uuid: string) => ReadonlySet<string>;
74
+ export declare const matchesKnownBleUuid: (actualUuid: string | null | undefined, aliases: ReadonlySet<string>) => boolean;
75
+ export declare const isPro2FindMyAdvertisementName: (value?: string | null) => boolean;
76
+ export declare const normalizePro2FindMyAdvertisementName: (value: string) => string;
77
+ export declare const canonicalizePro2BleAdvertisementName: (value: string) => string;
78
+ export declare const isSameOnekeyBleName: (left?: string | null, right?: string | null) => boolean;
79
+ export declare const hasOnekeyCommunicationService: (serviceUuids: Array<string | null | undefined> | null | undefined) => boolean;
80
+ export declare const isOnekeyBluetoothDevice: ({ id, name, localName, serviceUuids, }: BluetoothDeviceIdentity) => boolean;
48
81
  export {};
49
82
  //# 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;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;IACn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AAE,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;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;AAEJ,eAAO,MAAM,uBAAuB,2CAKjC,uBAAuB,KAAG,OAiB5B,CAAC"}
@@ -6,6 +6,7 @@ export declare enum EDeviceType {
6
6
  Mini = "mini",
7
7
  Touch = "touch",
8
8
  Pro = "pro",
9
- Pro2 = "pro2"
9
+ Pro2 = "pro2",
10
+ Neo = "neo"
10
11
  }
11
12
  //# sourceMappingURL=deviceType.d.ts.map
@@ -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;CACd"}
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,13 +7,26 @@ declare const ONEKEY_WEBUSB_FILTER: {
7
7
  vendorId: number;
8
8
  productId: number;
9
9
  }[];
10
+ /** USB IDs whose first probe should be Protocol V2. Shared Pro/Touch PIDs stay unhinted. */
11
+ declare const ONEKEY_PROTOCOL_V2_USB_IDS: readonly [{
12
+ readonly vendorId: 4617;
13
+ readonly productId: 20300;
14
+ }];
10
15
  type WebUsbIdentityDescriptor = {
11
16
  vendorId?: number;
12
17
  productId?: number;
13
18
  manufacturerName?: string | null;
14
19
  };
15
20
  declare const isKnownTrezorWebUsbDevice: (descriptor: WebUsbIdentityDescriptor) => boolean;
21
+ /**
22
+ * Error codes that require device release after occurrence
23
+ * These errors indicate the device is in an invalid state and needs to be released
24
+ */
16
25
  declare const ERROR_CODES_REQUIRE_RELEASE: readonly [106, 107, 109, 112, 805, 801, 802, 812];
26
+ /**
27
+ * Error codes that require device disconnect before release
28
+ * These errors indicate a communication failure that requires full reconnection
29
+ */
17
30
  declare const ERROR_CODES_REQUIRE_DISCONNECT: readonly [106, 805];
18
31
  declare enum EOneKeyBleMessageKeys {
19
32
  BLE_SELECT = "$onekey-ble-select",
@@ -32,18 +45,65 @@ declare enum EOneKeyBleMessageKeys {
32
45
  NOBLE_BLE_STOP_SCAN = "$onekey-noble-ble-stop-scan",
33
46
  NOBLE_BLE_GET_DEVICE = "$onekey-noble-ble-get-device",
34
47
  NOBLE_BLE_CONNECT = "$onekey-noble-ble-connect",
48
+ NOBLE_BLE_RELEASE = "$onekey-noble-ble-release",
35
49
  NOBLE_BLE_DISCONNECT = "$onekey-noble-ble-disconnect",
36
50
  NOBLE_BLE_WRITE = "$onekey-noble-ble-write",
37
51
  NOBLE_BLE_SUBSCRIBE = "$onekey-noble-ble-subscribe",
38
52
  NOBLE_BLE_UNSUBSCRIBE = "$onekey-noble-ble-unsubscribe",
39
53
  NOBLE_BLE_NOTIFICATION = "$onekey-noble-ble-notification",
54
+ NOBLE_BLE_MTU_CHANGED = "$onekey-noble-ble-mtu-changed",
40
55
  NOBLE_BLE_CANCEL_PAIRING = "$onekey-noble-ble-cancel-pairing"
41
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
+ }
42
71
  declare const ONEKEY_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
43
72
  declare const ONEKEY_WRITE_CHARACTERISTIC_UUID = "00000002-0000-1000-8000-00805f9b34fb";
44
73
  declare const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = "00000003-0000-1000-8000-00805f9b34fb";
45
74
  declare const isHeaderChunk: (chunk: Buffer | Uint8Array) => boolean;
46
75
  declare const isOnekeyDevice: (name: string | null, id?: string) => boolean;
76
+ declare const inferProtocolHintFromUsbId: (vendorId?: number | null, productId?: number | null) => "V2" | undefined;
77
+ type UsbDevicePathInput = {
78
+ serialNumber?: string | null;
79
+ vendorId?: number;
80
+ productId?: number;
81
+ productName?: string | null;
82
+ };
83
+ declare const resolveOneKeyUsbDevicePath: (device: UsbDevicePathInput) => string | undefined;
84
+ type BluetoothDeviceIdentity = {
85
+ id?: string;
86
+ name?: string | null;
87
+ localName?: string | null;
88
+ serviceUuids?: Array<string | null | undefined> | null;
89
+ };
90
+ declare const normalizeBleUuid: (uuid?: string | null) => string;
91
+ declare const createKnownBleUuidAliases: (uuid: string) => ReadonlySet<string>;
92
+ declare const matchesKnownBleUuid: (actualUuid: string | null | undefined, aliases: ReadonlySet<string>) => boolean;
93
+ declare const isPro2FindMyAdvertisementName: (value?: string | null) => boolean;
94
+ declare const normalizePro2FindMyAdvertisementName: (value: string) => string;
95
+ /**
96
+ * Current Pro2 advertisements use "Pro 2 XXXX". Older firmware used "Pro2 XXXX".
97
+ * Discovery and DeviceInfo both go through this helper so the public BLE name
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".
102
+ */
103
+ declare const canonicalizePro2BleAdvertisementName: (value: string) => string;
104
+ declare const isSameOnekeyBleName: (left?: string | null, right?: string | null) => boolean;
105
+ declare const hasOnekeyCommunicationService: (serviceUuids: Array<string | null | undefined> | null | undefined) => boolean;
106
+ declare const isOnekeyBluetoothDevice: ({ id, name, localName, serviceUuids, }: BluetoothDeviceIdentity) => boolean;
47
107
 
48
108
  type Deferred<T, I = any, D = any> = {
49
109
  id?: I;
@@ -76,53 +136,201 @@ declare class HardwareError extends Error {
76
136
  constructor(hardwareError: IHardwareError | string);
77
137
  }
78
138
  declare const HardwareErrorCode: {
139
+ /**
140
+ * This error can be thrown when unexpected error occurred and in most cases it is related to implementation bug.
141
+ * Original message is available in message property.
142
+ */
79
143
  readonly UnknownError: 0;
144
+ /**
145
+ * Firmware version mismatch
146
+ */
80
147
  readonly DeviceFwException: 101;
148
+ /**
149
+ * Device unexpected mode
150
+ */
81
151
  readonly DeviceUnexpectedMode: 102;
152
+ /**
153
+ * Device list is not initialized
154
+ */
82
155
  readonly DeviceListNotInitialized: 103;
156
+ /**
157
+ * Please select the connected device
158
+ */
83
159
  readonly SelectDevice: 104;
160
+ /**
161
+ * Device not found
162
+ */
84
163
  readonly DeviceNotFound: 105;
164
+ /**
165
+ * Device is not initialized
166
+ */
85
167
  readonly DeviceInitializeFailed: 106;
168
+ /**
169
+ * Device interrupted from another operation
170
+ */
86
171
  readonly DeviceInterruptedFromOutside: 107;
172
+ /**
173
+ * Device should be in bootloader mode
174
+ */
87
175
  readonly RequiredButInBootloaderMode: 108;
176
+ /**
177
+ * Device interrupted from user
178
+ */
88
179
  readonly DeviceInterruptedFromUser: 109;
180
+ /**
181
+ * Check device id is same
182
+ */
89
183
  readonly DeviceCheckDeviceIdError: 110;
184
+ /**
185
+ * Do not support passphrase
186
+ * @params: { require: string }
187
+ */
90
188
  readonly DeviceNotSupportPassphrase: 111;
91
189
  readonly DeviceCheckPassphraseStateError: 112;
190
+ /**
191
+ * use passphrase, but passphrase is not opened
192
+ */
92
193
  readonly DeviceNotOpenedPassphrase: 113;
194
+ /**
195
+ * not use passphrase, but passphrase is opened
196
+ */
93
197
  readonly DeviceOpenedPassphrase: 114;
198
+ /**
199
+ * Detect hardware that is in bootloader mode and return an error.
200
+ */
94
201
  readonly DeviceDetectInBootloaderMode: 115;
202
+ /**
203
+ * Device not allow in bootloader mode
204
+ */
95
205
  readonly NotAllowInBootloaderMode: 116;
206
+ /**
207
+ * Device is busy
208
+ */
96
209
  readonly DeviceBusy: 117;
210
+ /**
211
+ * Device check unlock type not match error
212
+ */
97
213
  readonly DeviceCheckUnlockTypeError: 118;
214
+ /**
215
+ * Not initialized
216
+ */
98
217
  readonly NotInitialized: 200;
218
+ /**
219
+ * Iframe not initialized
220
+ */
99
221
  readonly IFrameNotInitialized: 300;
222
+ /**
223
+ * iframe repeat initialization
224
+ */
100
225
  readonly IFrameAleradyInitialized: 301;
226
+ /**
227
+ * iframe load failure
228
+ */
101
229
  readonly IFrameLoadFail: 302;
230
+ /**
231
+ * init iframe time out
232
+ */
102
233
  readonly IframeTimeout: 303;
234
+ /**
235
+ * iframe blocked
236
+ */
103
237
  readonly IframeBlocked: 304;
238
+ /**
239
+ * iframe host not trust
240
+ */
104
241
  readonly IframeDistrust: 305;
242
+ /**
243
+ * Runtime errors during method execution
244
+ */
105
245
  readonly CallMethodError: 400;
246
+ /**
247
+ * Method does not responding
248
+ */
106
249
  readonly CallMethodNotResponse: 404;
250
+ /**
251
+ * Call method invalid parameter
252
+ */
107
253
  readonly CallMethodInvalidParameter: 405;
254
+ /**
255
+ * firmware update download failed
256
+ */
108
257
  readonly FirmwareUpdateDownloadFailed: 406;
258
+ /**
259
+ * Call method not supported, need update firmware
260
+ * @params: { current: string, require: string }
261
+ */
109
262
  readonly CallMethodNeedUpgradeFirmware: 407;
263
+ /**
264
+ * Call method not supported, is deprecated
265
+ * @params: { current: string, deprecated: string }
266
+ */
110
267
  readonly CallMethodDeprecated: 408;
268
+ /**
269
+ * Only one device can be connected during firmware upgrade
270
+ */
111
271
  readonly FirmwareUpdateLimitOneDevice: 409;
272
+ /**
273
+ * You need to manually enter boot
274
+ */
112
275
  readonly FirmwareUpdateManuallyEnterBoot: 410;
276
+ /**
277
+ * Manual entry fails. You must manually enter the boot
278
+ */
113
279
  readonly FirmwareUpdateAutoEnterBootFailure: 411;
280
+ /**
281
+ * The new firmware has not been released yet
282
+ */
114
283
  readonly NewFirmwareUnRelease: 412;
284
+ /**
285
+ * use OneKey desktop client to update the firmware
286
+ * because need copy resource file to Touch
287
+ */
115
288
  readonly UseDesktopToUpdateFirmware: 413;
289
+ /**
290
+ * Mandatory firmware update
291
+ * @params:{ connectId: string? , deviceId: string? }
292
+ */
116
293
  readonly NewFirmwareForceUpdate: 414;
294
+ /**
295
+ * Device not support this method
296
+ */
117
297
  readonly DeviceNotSupportMethod: 415;
298
+ /**
299
+ * Forbidden key path
300
+ */
118
301
  readonly ForbiddenKeyPath: 416;
302
+ /**
303
+ * Repeat unlocking
304
+ * all network get address by loop need repeat unlocking
305
+ */
119
306
  readonly RepeatUnlocking: 417;
307
+ /**
308
+ * Defective firmware detected
309
+ */
120
310
  readonly DefectiveFirmware: 418;
311
+ /**
312
+ * Netword request error
313
+ */
121
314
  readonly NetworkError: 500;
315
+ /**
316
+ * Transport not configured
317
+ */
122
318
  readonly TransportNotConfigured: 600;
319
+ /**
320
+ * Transport call in progress
321
+ */
123
322
  readonly TransportCallInProgress: 601;
323
+ /**
324
+ * Transport not found
325
+ */
124
326
  readonly TransportNotFound: 602;
327
+ /**
328
+ * Transport invalid protobuf
329
+ */
125
330
  readonly TransportInvalidProtobuf: 603;
331
+ /**
332
+ * Bluetooth error code
333
+ */
126
334
  readonly BleScanError: 700;
127
335
  readonly BlePermissionError: 701;
128
336
  readonly BleLocationError: 702;
@@ -146,38 +354,145 @@ declare const HardwareErrorCode: {
146
354
  readonly BleDeviceDisconnected: 720;
147
355
  readonly BlePoweredOff: 721;
148
356
  readonly BleUnsupported: 722;
357
+ readonly BleUnavailableWhileUsbConnected: 723;
358
+ /**
359
+ * Hardware runtiome errors
360
+ */
149
361
  readonly RuntimeError: 800;
362
+ /**
363
+ * invalid pin
364
+ */
150
365
  readonly PinInvalid: 801;
366
+ /**
367
+ * pin cancelled by user
368
+ */
151
369
  readonly PinCancelled: 802;
370
+ /**
371
+ * Action cancelled by user
372
+ */
152
373
  readonly ActionCancelled: 803;
374
+ /**
375
+ * Firmware installation failed
376
+ */
153
377
  readonly FirmwareError: 804;
378
+ /**
379
+ * transport response unexpect error
380
+ */
154
381
  readonly ResponseUnexpectTypeError: 805;
382
+ /**
383
+ * bridge network error
384
+ */
155
385
  readonly BridgeNetworkError: 806;
386
+ /**
387
+ * Bridge network timeout
388
+ */
156
389
  readonly BridgeTimeoutError: 807;
390
+ /**
391
+ * Bridge not installed
392
+ */
157
393
  readonly BridgeNotInstalled: 808;
394
+ /**
395
+ * ensure connect timeout
396
+ */
158
397
  readonly PollingTimeout: 809;
398
+ /**
399
+ * ensure connect stop polling
400
+ */
159
401
  readonly PollingStop: 810;
402
+ /**
403
+ * Device does not open blid sign
404
+ */
160
405
  readonly BlindSignDisabled: 811;
161
406
  readonly UnexpectPassphrase: 812;
407
+ /**
408
+ * NFT file already exists
409
+ */
162
410
  readonly FileAlreadyExists: 813;
411
+ /**
412
+ * check file length error
413
+ */
163
414
  readonly CheckDownloadFileError: 814;
415
+ /**
416
+ * not in signing mode
417
+ */
164
418
  readonly NotInSigningMode: 815;
419
+ /**
420
+ * not in signing mode
421
+ */
165
422
  readonly DataOverload: 816;
423
+ /**
424
+ * device disconnected during action
425
+ */
166
426
  readonly BridgeDeviceDisconnected: 817;
427
+ /**
428
+ * BTC PSBT too many utxos
429
+ * @params:{ count: number }
430
+ */
167
431
  readonly BTCPsbtTooManyUtxos: 818;
432
+ /**
433
+ * EMMC file write firmware error
434
+ */
168
435
  readonly EmmcFileWriteFirmwareError: 819;
436
+ /**
437
+ * Firmware verification failed (e.g., bootloader file verify failed)
438
+ */
169
439
  readonly FirmwareVerificationFailed: 820;
440
+ /**
441
+ * Web bridge coonect needs permission
442
+ */
170
443
  readonly BridgeNeedsPermission: 821;
171
444
  readonly CallQueueActionCancelled: 822;
445
+ /**
446
+ * Firmware downgrade not allowed
447
+ */
172
448
  readonly FirmwareDowngradeNotAllowed: 823;
449
+ /**
450
+ * Cosmos invalid JSON message, Only support Amino msgs.
451
+ */
173
452
  readonly CosmosInvalidJsonMessage: 824;
453
+ /**
454
+ * No setting provided
455
+ */
174
456
  readonly DeviceSettingsNotProvided: 825;
457
+ /**
458
+ * Language not supported
459
+ */
175
460
  readonly DeviceSettingsLanguageNotSupport: 826;
461
+ /**
462
+ * Too many inputs
463
+ * @params: { count?: string }
464
+ */
176
465
  readonly TooManyInputs: 827;
466
+ /**
467
+ * The two PIN entries did not match while setting/changing PIN on device
468
+ */
177
469
  readonly PinMismatch: 828;
178
- readonly DeviceLocked: 829;
470
+ /**
471
+ * Protocol V2 device must be unlocked before the requested operation.
472
+ * @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
473
+ */
474
+ readonly DeviceLocked: 830;
475
+ /**
476
+ * The cached wallet session is invalid or has expired.
477
+ * @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
478
+ */
479
+ readonly WalletSessionInvalid: 831;
480
+ /**
481
+ * Pro2 NFT storage has reached its item limit.
482
+ * @params: { count: number; limit: number }
483
+ */
484
+ readonly NftStorageLimitReached: 832;
485
+ /**
486
+ * Lowlevel transport connect error
487
+ */
179
488
  readonly LowlevelTrasnportConnectError: 900;
489
+ /**
490
+ * Web USB or Web Bluetooth device not found or needs permission
491
+ */
180
492
  readonly WebDeviceNotFoundOrNeedsPermission: 901;
493
+ /**
494
+ * Web USB or Web Bluetooth device prompt access error
495
+ */
181
496
  readonly WebDevicePromptAccessError: 902;
182
497
  };
183
498
  declare const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping;
@@ -249,7 +564,8 @@ declare enum EDeviceType {
249
564
  Mini = "mini",
250
565
  Touch = "touch",
251
566
  Pro = "pro",
252
- Pro2 = "pro2"
567
+ Pro2 = "pro2",
568
+ Neo = "neo"
253
569
  }
254
570
 
255
- 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, isKnownTrezorWebUsbDevice, isOnekeyDevice, 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 };