@onekeyfe/hd-shared 1.1.22-alpha.1 → 1.1.22-alpha.3
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 +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +132 -116
- package/package.json +2 -2
- package/src/constants.ts +26 -0
package/dist/constants.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export declare const ONEKEY_WEBUSB_FILTER: {
|
|
|
3
3
|
vendorId: number;
|
|
4
4
|
productId: number;
|
|
5
5
|
}[];
|
|
6
|
+
export declare const ERROR_CODES_REQUIRE_RELEASE: readonly [106, 107, 109, 112, 805, 801, 802, 812];
|
|
7
|
+
export declare const ERROR_CODES_REQUIRE_DISCONNECT: readonly [106, 805];
|
|
6
8
|
export declare enum EOneKeyBleMessageKeys {
|
|
7
9
|
BLE_SELECT = "$onekey-ble-select",
|
|
8
10
|
BLE_SELECT_RESULT = "$onekey-ble-select-result",
|
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":";AAEA,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;AAEF,eAAO,MAAM,cAAc,SAAU,MAAM,GAAG,IAAI,OAAO,MAAM,KAAG,OAYjE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ declare const ONEKEY_WEBUSB_FILTER: {
|
|
|
2
2
|
vendorId: number;
|
|
3
3
|
productId: number;
|
|
4
4
|
}[];
|
|
5
|
+
declare const ERROR_CODES_REQUIRE_RELEASE: readonly [106, 107, 109, 112, 805, 801, 802, 812];
|
|
6
|
+
declare const ERROR_CODES_REQUIRE_DISCONNECT: readonly [106, 805];
|
|
5
7
|
declare enum EOneKeyBleMessageKeys {
|
|
6
8
|
BLE_SELECT = "$onekey-ble-select",
|
|
7
9
|
BLE_SELECT_RESULT = "$onekey-ble-select-result",
|
|
@@ -233,4 +235,4 @@ declare enum EDeviceType {
|
|
|
233
235
|
Pro = "pro"
|
|
234
236
|
}
|
|
235
237
|
|
|
236
|
-
export { CreateErrorByMessage, CreateHardwareErrorByBridgeError, Deferred, EDeviceType, EFirmwareType, EOneKeyBleMessageKeys, HardwareError$1 as ERRORS, 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 };
|
|
238
|
+
export { CreateErrorByMessage, CreateHardwareErrorByBridgeError, Deferred, EDeviceType, EFirmwareType, EOneKeyBleMessageKeys, HardwareError$1 as ERRORS, ERROR_CODES_REQUIRE_DISCONNECT, ERROR_CODES_REQUIRE_RELEASE, 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 };
|
package/dist/index.js
CHANGED
|
@@ -2,122 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const ONEKEY_WEBUSB_FILTER = [
|
|
6
|
-
{ vendorId: 0x1209, productId: 0x53c0 },
|
|
7
|
-
{ vendorId: 0x1209, productId: 0x53c1 },
|
|
8
|
-
{ vendorId: 0x1209, productId: 0x4f4a },
|
|
9
|
-
{ vendorId: 0x1209, productId: 0x4f4b },
|
|
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
|
-
EOneKeyBleMessageKeys["BLE_AVAILABILITY_CHECK"] = "$onekey-ble-availability-check";
|
|
25
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_ENUMERATE"] = "$onekey-noble-ble-enumerate";
|
|
26
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_STOP_SCAN"] = "$onekey-noble-ble-stop-scan";
|
|
27
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_GET_DEVICE"] = "$onekey-noble-ble-get-device";
|
|
28
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_CONNECT"] = "$onekey-noble-ble-connect";
|
|
29
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_DISCONNECT"] = "$onekey-noble-ble-disconnect";
|
|
30
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_WRITE"] = "$onekey-noble-ble-write";
|
|
31
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_SUBSCRIBE"] = "$onekey-noble-ble-subscribe";
|
|
32
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_UNSUBSCRIBE"] = "$onekey-noble-ble-unsubscribe";
|
|
33
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_NOTIFICATION"] = "$onekey-noble-ble-notification";
|
|
34
|
-
EOneKeyBleMessageKeys["NOBLE_BLE_CANCEL_PAIRING"] = "$onekey-noble-ble-cancel-pairing";
|
|
35
|
-
})(exports.EOneKeyBleMessageKeys || (exports.EOneKeyBleMessageKeys = {}));
|
|
36
|
-
const ONEKEY_SERVICE_UUID = '00000001-0000-1000-8000-00805f9b34fb';
|
|
37
|
-
const ONEKEY_WRITE_CHARACTERISTIC_UUID = '00000002-0000-1000-8000-00805f9b34fb';
|
|
38
|
-
const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = '00000003-0000-1000-8000-00805f9b34fb';
|
|
39
|
-
const MESSAGE_TOP_CHAR = 63;
|
|
40
|
-
const MESSAGE_HEADER_BYTE = 35;
|
|
41
|
-
const isHeaderChunk = (chunk) => {
|
|
42
|
-
if (chunk.length < 9)
|
|
43
|
-
return false;
|
|
44
|
-
const [MagicQuestionMark, sharp1, sharp2] = chunk;
|
|
45
|
-
if (String.fromCharCode(MagicQuestionMark) === String.fromCharCode(MESSAGE_TOP_CHAR) &&
|
|
46
|
-
String.fromCharCode(sharp1) === String.fromCharCode(MESSAGE_HEADER_BYTE) &&
|
|
47
|
-
String.fromCharCode(sharp2) === String.fromCharCode(MESSAGE_HEADER_BYTE)) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
};
|
|
52
|
-
const isOnekeyDevice = (name, id) => {
|
|
53
|
-
var _a;
|
|
54
|
-
if ((_a = id === null || id === void 0 ? void 0 : id.startsWith) === null || _a === void 0 ? void 0 : _a.call(id, 'MI')) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
const re = /(BixinKey\d{10})|(K\d{4})|(T\d{4})|(Touch\s\w{4})|(Pro\s\w{4})/i;
|
|
58
|
-
if (name && re.exec(name)) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/******************************************************************************
|
|
65
|
-
Copyright (c) Microsoft Corporation.
|
|
66
|
-
|
|
67
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
68
|
-
purpose with or without fee is hereby granted.
|
|
69
|
-
|
|
70
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
71
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
72
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
73
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
74
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
75
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
76
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
77
|
-
***************************************************************************** */
|
|
78
|
-
|
|
79
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
80
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
81
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
82
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
83
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
84
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
85
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
90
|
-
var e = new Error(message);
|
|
91
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
function createDeferred(arg, data) {
|
|
95
|
-
let localResolve = (_t) => { };
|
|
96
|
-
let localReject = (_e) => { };
|
|
97
|
-
let id;
|
|
98
|
-
const promise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
localResolve = resolve;
|
|
100
|
-
localReject = reject;
|
|
101
|
-
if (typeof arg === 'function') {
|
|
102
|
-
try {
|
|
103
|
-
yield arg();
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
reject(error);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (typeof arg === 'string')
|
|
110
|
-
id = arg;
|
|
111
|
-
}));
|
|
112
|
-
return {
|
|
113
|
-
id,
|
|
114
|
-
data,
|
|
115
|
-
resolve: localResolve,
|
|
116
|
-
reject: localReject,
|
|
117
|
-
promise,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
5
|
exports.EFirmwareType = void 0;
|
|
122
6
|
(function (EFirmwareType) {
|
|
123
7
|
EFirmwareType["Universal"] = "universal";
|
|
@@ -488,6 +372,136 @@ var HardwareError$1 = /*#__PURE__*/Object.freeze({
|
|
|
488
372
|
createDeviceNotSupportMethodError: createDeviceNotSupportMethodError
|
|
489
373
|
});
|
|
490
374
|
|
|
375
|
+
const ONEKEY_WEBUSB_FILTER = [
|
|
376
|
+
{ vendorId: 0x1209, productId: 0x53c0 },
|
|
377
|
+
{ vendorId: 0x1209, productId: 0x53c1 },
|
|
378
|
+
{ vendorId: 0x1209, productId: 0x4f4a },
|
|
379
|
+
{ vendorId: 0x1209, productId: 0x4f4b },
|
|
380
|
+
];
|
|
381
|
+
const ERROR_CODES_REQUIRE_RELEASE = [
|
|
382
|
+
HardwareErrorCode.DeviceInitializeFailed,
|
|
383
|
+
HardwareErrorCode.DeviceInterruptedFromOutside,
|
|
384
|
+
HardwareErrorCode.DeviceInterruptedFromUser,
|
|
385
|
+
HardwareErrorCode.DeviceCheckPassphraseStateError,
|
|
386
|
+
HardwareErrorCode.ResponseUnexpectTypeError,
|
|
387
|
+
HardwareErrorCode.PinInvalid,
|
|
388
|
+
HardwareErrorCode.PinCancelled,
|
|
389
|
+
HardwareErrorCode.UnexpectPassphrase,
|
|
390
|
+
];
|
|
391
|
+
const ERROR_CODES_REQUIRE_DISCONNECT = [
|
|
392
|
+
HardwareErrorCode.DeviceInitializeFailed,
|
|
393
|
+
HardwareErrorCode.ResponseUnexpectTypeError,
|
|
394
|
+
];
|
|
395
|
+
exports.EOneKeyBleMessageKeys = void 0;
|
|
396
|
+
(function (EOneKeyBleMessageKeys) {
|
|
397
|
+
EOneKeyBleMessageKeys["BLE_SELECT"] = "$onekey-ble-select";
|
|
398
|
+
EOneKeyBleMessageKeys["BLE_SELECT_RESULT"] = "$onekey-ble-select-result";
|
|
399
|
+
EOneKeyBleMessageKeys["BLE_STOP_SCAN"] = "$onekey-ble-stop-scan";
|
|
400
|
+
EOneKeyBleMessageKeys["BLE_CANCEL_REQUEST"] = "$onekey-ble-cancel-request";
|
|
401
|
+
EOneKeyBleMessageKeys["BLE_PRE_SELECT"] = "$onekey-ble-pre-select";
|
|
402
|
+
EOneKeyBleMessageKeys["BLE_CLEAR_PRE_SELECT"] = "$onekey-ble-clear-pre-select";
|
|
403
|
+
EOneKeyBleMessageKeys["BLE_PAIRING_REQUEST"] = "$onekey-ble-pairing-request";
|
|
404
|
+
EOneKeyBleMessageKeys["BLE_PAIRING_RESPONSE"] = "$onekey-ble-pairing-response";
|
|
405
|
+
EOneKeyBleMessageKeys["BLE_ENUMERATE"] = "$onekey-ble-enumerate";
|
|
406
|
+
EOneKeyBleMessageKeys["BLE_ENUMERATE_RESULT"] = "$onekey-ble-enumerate-result";
|
|
407
|
+
EOneKeyBleMessageKeys["BLE_DEVICE_DISCONNECTED"] = "$onekey-ble-device-disconnected";
|
|
408
|
+
EOneKeyBleMessageKeys["BLE_AVAILABILITY_CHECK"] = "$onekey-ble-availability-check";
|
|
409
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_ENUMERATE"] = "$onekey-noble-ble-enumerate";
|
|
410
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_STOP_SCAN"] = "$onekey-noble-ble-stop-scan";
|
|
411
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_GET_DEVICE"] = "$onekey-noble-ble-get-device";
|
|
412
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_CONNECT"] = "$onekey-noble-ble-connect";
|
|
413
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_DISCONNECT"] = "$onekey-noble-ble-disconnect";
|
|
414
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_WRITE"] = "$onekey-noble-ble-write";
|
|
415
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_SUBSCRIBE"] = "$onekey-noble-ble-subscribe";
|
|
416
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_UNSUBSCRIBE"] = "$onekey-noble-ble-unsubscribe";
|
|
417
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_NOTIFICATION"] = "$onekey-noble-ble-notification";
|
|
418
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_CANCEL_PAIRING"] = "$onekey-noble-ble-cancel-pairing";
|
|
419
|
+
})(exports.EOneKeyBleMessageKeys || (exports.EOneKeyBleMessageKeys = {}));
|
|
420
|
+
const ONEKEY_SERVICE_UUID = '00000001-0000-1000-8000-00805f9b34fb';
|
|
421
|
+
const ONEKEY_WRITE_CHARACTERISTIC_UUID = '00000002-0000-1000-8000-00805f9b34fb';
|
|
422
|
+
const ONEKEY_NOTIFY_CHARACTERISTIC_UUID = '00000003-0000-1000-8000-00805f9b34fb';
|
|
423
|
+
const MESSAGE_TOP_CHAR = 63;
|
|
424
|
+
const MESSAGE_HEADER_BYTE = 35;
|
|
425
|
+
const isHeaderChunk = (chunk) => {
|
|
426
|
+
if (chunk.length < 9)
|
|
427
|
+
return false;
|
|
428
|
+
const [MagicQuestionMark, sharp1, sharp2] = chunk;
|
|
429
|
+
if (String.fromCharCode(MagicQuestionMark) === String.fromCharCode(MESSAGE_TOP_CHAR) &&
|
|
430
|
+
String.fromCharCode(sharp1) === String.fromCharCode(MESSAGE_HEADER_BYTE) &&
|
|
431
|
+
String.fromCharCode(sharp2) === String.fromCharCode(MESSAGE_HEADER_BYTE)) {
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
return false;
|
|
435
|
+
};
|
|
436
|
+
const isOnekeyDevice = (name, id) => {
|
|
437
|
+
var _a;
|
|
438
|
+
if ((_a = id === null || id === void 0 ? void 0 : id.startsWith) === null || _a === void 0 ? void 0 : _a.call(id, 'MI')) {
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
const re = /(BixinKey\d{10})|(K\d{4})|(T\d{4})|(Touch\s\w{4})|(Pro\s\w{4})/i;
|
|
442
|
+
if (name && re.exec(name)) {
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
return false;
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
/******************************************************************************
|
|
449
|
+
Copyright (c) Microsoft Corporation.
|
|
450
|
+
|
|
451
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
452
|
+
purpose with or without fee is hereby granted.
|
|
453
|
+
|
|
454
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
455
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
456
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
457
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
458
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
459
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
460
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
461
|
+
***************************************************************************** */
|
|
462
|
+
|
|
463
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
464
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
465
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
466
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
467
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
468
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
469
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
474
|
+
var e = new Error(message);
|
|
475
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
function createDeferred(arg, data) {
|
|
479
|
+
let localResolve = (_t) => { };
|
|
480
|
+
let localReject = (_e) => { };
|
|
481
|
+
let id;
|
|
482
|
+
const promise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
483
|
+
localResolve = resolve;
|
|
484
|
+
localReject = reject;
|
|
485
|
+
if (typeof arg === 'function') {
|
|
486
|
+
try {
|
|
487
|
+
yield arg();
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
reject(error);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (typeof arg === 'string')
|
|
494
|
+
id = arg;
|
|
495
|
+
}));
|
|
496
|
+
return {
|
|
497
|
+
id,
|
|
498
|
+
data,
|
|
499
|
+
resolve: localResolve,
|
|
500
|
+
reject: localReject,
|
|
501
|
+
promise,
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
|
|
491
505
|
const wait = (ms) => new Promise(resolve => {
|
|
492
506
|
setTimeout(resolve, ms);
|
|
493
507
|
});
|
|
@@ -506,6 +520,8 @@ exports.EDeviceType = void 0;
|
|
|
506
520
|
exports.CreateErrorByMessage = CreateErrorByMessage;
|
|
507
521
|
exports.CreateHardwareErrorByBridgeError = CreateHardwareErrorByBridgeError;
|
|
508
522
|
exports.ERRORS = HardwareError$1;
|
|
523
|
+
exports.ERROR_CODES_REQUIRE_DISCONNECT = ERROR_CODES_REQUIRE_DISCONNECT;
|
|
524
|
+
exports.ERROR_CODES_REQUIRE_RELEASE = ERROR_CODES_REQUIRE_RELEASE;
|
|
509
525
|
exports.HardwareError = HardwareError;
|
|
510
526
|
exports.HardwareErrorCode = HardwareErrorCode;
|
|
511
527
|
exports.HardwareErrorCodeMessage = HardwareErrorCodeMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-shared",
|
|
3
|
-
"version": "1.1.22-alpha.
|
|
3
|
+
"version": "1.1.22-alpha.3",
|
|
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": "6c31e9c8e0004d335278c9b64c796214b3558d34"
|
|
29
29
|
}
|
package/src/constants.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { HardwareErrorCode } from './HardwareError';
|
|
2
|
+
|
|
1
3
|
export const ONEKEY_WEBUSB_FILTER = [
|
|
2
4
|
{ vendorId: 0x1209, productId: 0x53c0 }, // Classic Boot、Classic1s Boot、Mini Boot
|
|
3
5
|
{ vendorId: 0x1209, productId: 0x53c1 }, // Classic Firmware、Classic1s Firmware、Mini Firmware、Pro Firmware、Touch Firmware
|
|
@@ -7,6 +9,30 @@ export const ONEKEY_WEBUSB_FILTER = [
|
|
|
7
9
|
// { vendorId: 0x1209, productId: 0x4f50 }, // Touch Board
|
|
8
10
|
];
|
|
9
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Error codes that require device release after occurrence
|
|
14
|
+
* These errors indicate the device is in an invalid state and needs to be released
|
|
15
|
+
*/
|
|
16
|
+
export const ERROR_CODES_REQUIRE_RELEASE = [
|
|
17
|
+
HardwareErrorCode.DeviceInitializeFailed,
|
|
18
|
+
HardwareErrorCode.DeviceInterruptedFromOutside,
|
|
19
|
+
HardwareErrorCode.DeviceInterruptedFromUser,
|
|
20
|
+
HardwareErrorCode.DeviceCheckPassphraseStateError,
|
|
21
|
+
HardwareErrorCode.ResponseUnexpectTypeError,
|
|
22
|
+
HardwareErrorCode.PinInvalid,
|
|
23
|
+
HardwareErrorCode.PinCancelled,
|
|
24
|
+
HardwareErrorCode.UnexpectPassphrase,
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Error codes that require device disconnect before release
|
|
29
|
+
* These errors indicate a communication failure that requires full reconnection
|
|
30
|
+
*/
|
|
31
|
+
export const ERROR_CODES_REQUIRE_DISCONNECT = [
|
|
32
|
+
HardwareErrorCode.DeviceInitializeFailed,
|
|
33
|
+
HardwareErrorCode.ResponseUnexpectTypeError,
|
|
34
|
+
] as const;
|
|
35
|
+
|
|
10
36
|
// BLE IPC communication message types
|
|
11
37
|
export enum EOneKeyBleMessageKeys {
|
|
12
38
|
// BLE device selection related
|