@onekeyfe/hd-core 1.1.27-alpha.33 → 1.1.27-alpha.35
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/__tests__/protocol-v2.test.ts +183 -45
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/GetDeviceInfo.d.ts +9 -0
- package/dist/api/GetDeviceInfo.d.ts.map +1 -0
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetPassphraseState.d.ts +2 -2
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumGetAddress.d.ts +2 -6
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts +2 -5
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts +2 -5
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts +2 -9
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts +2 -9
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts +2 -8
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts +2 -8
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -11
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -11
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -15
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -11
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -11
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -11
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -8
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/helpers/deviceInfo.d.ts +15 -0
- package/dist/api/helpers/deviceInfo.d.ts.map +1 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts +2 -8
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts +2 -8
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts +2 -9
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts +2 -9
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts +2 -8
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +2 -9
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +10 -0
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +1 -0
- package/dist/api/scdo/ScdoGetAddress.d.ts +2 -6
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts +2 -5
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts +2 -5
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +2 -1
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +2 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +2 -2
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/index.d.ts +95 -5
- package/dist/index.js +411 -70
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +20 -3
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/types/api/getDeviceInfo.d.ts +84 -0
- package/dist/types/api/getDeviceInfo.d.ts.map +1 -0
- package/dist/types/api/getPassphraseState.d.ts +1 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +5 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +4 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +5 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +1 -1
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +5 -10
- package/src/api/GetDeviceInfo.ts +153 -0
- package/src/api/GetPassphraseState.ts +7 -14
- package/src/api/alephium/AlephiumGetAddress.ts +6 -2
- package/src/api/alephium/AlephiumSignMessage.ts +6 -1
- package/src/api/alephium/AlephiumSignTransaction.ts +6 -2
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +13 -20
- package/src/api/benfen/BenfenGetAddress.ts +6 -2
- package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
- package/src/api/benfen/BenfenSignMessage.ts +6 -1
- package/src/api/benfen/BenfenSignTransaction.ts +6 -1
- package/src/api/btc/helpers/versionLimit.ts +7 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +14 -1
- package/src/api/helpers/batchGetPublickeys.ts +2 -4
- package/src/api/helpers/deviceInfo.ts +205 -0
- package/src/api/index.ts +2 -0
- package/src/api/neo/NeoGetAddress.ts +6 -1
- package/src/api/neo/NeoSignTransaction.ts +6 -1
- package/src/api/nervos/NervosGetAddress.ts +6 -2
- package/src/api/nervos/NervosSignTransaction.ts +6 -2
- package/src/api/nexa/NexaGetAddress.ts +6 -2
- package/src/api/nexa/NexaSignTransaction.ts +6 -2
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +17 -1
- package/src/api/protocol-v2/FilesystemDiskControl.ts +34 -0
- package/src/api/scdo/ScdoGetAddress.ts +6 -2
- package/src/api/scdo/ScdoSignMessage.ts +6 -1
- package/src/api/scdo/ScdoSignTransaction.ts +6 -2
- package/src/api/stellar/StellarGetAddress.ts +10 -1
- package/src/api/stellar/StellarSignTransaction.ts +14 -1
- package/src/api/sui/SuiSignTransaction.ts +12 -9
- package/src/core/index.ts +7 -7
- package/src/data/messages/messages-protocol-v2.json +10 -0
- package/src/inject.ts +3 -0
- package/src/protocols/protocol-v2/features.ts +35 -21
- package/src/types/api/getDeviceInfo.ts +97 -0
- package/src/types/api/getPassphraseState.ts +6 -8
- package/src/types/api/index.ts +16 -0
- package/src/types/api/protocolV2.ts +5 -0
- package/src/types/device.ts +30 -1
- package/src/utils/deviceFeaturesUtils.ts +9 -2
- package/src/utils/deviceInfoUtils.ts +5 -7
- package/src/utils/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -121,6 +121,7 @@ const createCoreApi = (call) => ({
|
|
|
121
121
|
getLogs: () => call({ method: 'getLogs' }),
|
|
122
122
|
searchDevices: params => call(Object.assign(Object.assign({}, params), { method: 'searchDevices' })),
|
|
123
123
|
getFeatures: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'getFeatures' })),
|
|
124
|
+
getDeviceInfo: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'getDeviceInfo' })),
|
|
124
125
|
getOnekeyFeatures: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'getOnekeyFeatures' })),
|
|
125
126
|
checkFirmwareRelease: connectId => call({ connectId, method: 'checkFirmwareRelease' }),
|
|
126
127
|
checkBLEFirmwareRelease: connectId => call({ connectId, method: 'checkBLEFirmwareRelease' }),
|
|
@@ -161,6 +162,7 @@ const createCoreApi = (call) => ({
|
|
|
161
162
|
filesystemDirRemove: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDirRemove' })),
|
|
162
163
|
filesystemPathInfoQuery: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemPathInfoQuery' })),
|
|
163
164
|
filesystemFormat: connectId => call({ connectId, method: 'filesystemFormat' }),
|
|
165
|
+
filesystemDiskControl: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDiskControl' })),
|
|
164
166
|
deviceRecovery: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceRecovery' })),
|
|
165
167
|
deviceReset: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceReset' })),
|
|
166
168
|
deviceSettings: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettings' })),
|
|
@@ -1288,7 +1290,7 @@ const getDeviceLabel = (features) => {
|
|
|
1288
1290
|
};
|
|
1289
1291
|
const getMethodVersionRange = (features, getVersionRange) => {
|
|
1290
1292
|
const deviceType = getDeviceType(features);
|
|
1291
|
-
|
|
1293
|
+
const versionRange = getVersionRange(deviceType);
|
|
1292
1294
|
if (versionRange) {
|
|
1293
1295
|
return versionRange;
|
|
1294
1296
|
}
|
|
@@ -1300,15 +1302,15 @@ const getMethodVersionRange = (features, getVersionRange) => {
|
|
|
1300
1302
|
];
|
|
1301
1303
|
for (const model of modelFallbacks) {
|
|
1302
1304
|
if (DeviceModelToTypes[model].includes(deviceType)) {
|
|
1303
|
-
versionRange = getVersionRange(model);
|
|
1305
|
+
const versionRange = getVersionRange(model);
|
|
1304
1306
|
if (versionRange) {
|
|
1305
1307
|
return versionRange;
|
|
1306
1308
|
}
|
|
1307
1309
|
}
|
|
1308
1310
|
}
|
|
1309
|
-
return
|
|
1311
|
+
return undefined;
|
|
1310
1312
|
};
|
|
1311
|
-
const
|
|
1313
|
+
const isMethodVersionRangeUnsupported = (versionRange) => (versionRange === null || versionRange === void 0 ? void 0 : versionRange.unsupported) === true;
|
|
1312
1314
|
const getFirmwareType = (features) => {
|
|
1313
1315
|
var _a;
|
|
1314
1316
|
if (!features) {
|
|
@@ -25818,6 +25820,7 @@ var nested = {
|
|
|
25818
25820
|
MessageType_FilesystemDirMake: 60809,
|
|
25819
25821
|
MessageType_FilesystemDirRemove: 60810,
|
|
25820
25822
|
MessageType_FilesystemFormat: 60811,
|
|
25823
|
+
MessageType_FilesystemDiskControl: 60812,
|
|
25821
25824
|
MessageType_DeviceFirmwareUpdate: 61000,
|
|
25822
25825
|
MessageType_DeviceFirmwareInstallProgress: 61001,
|
|
25823
25826
|
MessageType_DeviceGetFirmwareUpdateStatus: 61002,
|
|
@@ -37759,6 +37762,15 @@ var nested = {
|
|
|
37759
37762
|
fields: {
|
|
37760
37763
|
}
|
|
37761
37764
|
},
|
|
37765
|
+
FilesystemDiskControl: {
|
|
37766
|
+
fields: {
|
|
37767
|
+
enable: {
|
|
37768
|
+
rule: "required",
|
|
37769
|
+
type: "uint32",
|
|
37770
|
+
id: 1
|
|
37771
|
+
}
|
|
37772
|
+
}
|
|
37773
|
+
},
|
|
37762
37774
|
DeviceGetOnboardingStatus: {
|
|
37763
37775
|
fields: {
|
|
37764
37776
|
}
|
|
@@ -39045,7 +39057,8 @@ const supportBatchPublicKey = (features, options) => {
|
|
|
39045
39057
|
return false;
|
|
39046
39058
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
39047
39059
|
const deviceType = getDeviceType(features);
|
|
39048
|
-
if (!!(options === null || options === void 0 ? void 0 : options.includeNode) &&
|
|
39060
|
+
if (!!(options === null || options === void 0 ? void 0 : options.includeNode) &&
|
|
39061
|
+
(deviceType === hdShared.EDeviceType.Pro || deviceType === hdShared.EDeviceType.Pro2)) {
|
|
39049
39062
|
return semver__default["default"].gte(currentVersion, '4.14.0');
|
|
39050
39063
|
}
|
|
39051
39064
|
if (!!(options === null || options === void 0 ? void 0 : options.includeNode) && deviceType === hdShared.EDeviceType.Touch) {
|
|
@@ -39060,7 +39073,9 @@ const supportBatchPublicKey = (features, options) => {
|
|
|
39060
39073
|
if (options === null || options === void 0 ? void 0 : options.includeNode) {
|
|
39061
39074
|
return false;
|
|
39062
39075
|
}
|
|
39063
|
-
if (deviceType === hdShared.EDeviceType.Touch ||
|
|
39076
|
+
if (deviceType === hdShared.EDeviceType.Touch ||
|
|
39077
|
+
deviceType === hdShared.EDeviceType.Pro ||
|
|
39078
|
+
deviceType === hdShared.EDeviceType.Pro2) {
|
|
39064
39079
|
return semver__default["default"].gte(currentVersion, '3.1.0');
|
|
39065
39080
|
}
|
|
39066
39081
|
return semver__default["default"].gte(currentVersion, '2.6.0');
|
|
@@ -40926,22 +40941,23 @@ function createBaseFeatures(descriptor) {
|
|
|
40926
40941
|
auto_lock_delay_ms: null,
|
|
40927
40942
|
display_rotation: null,
|
|
40928
40943
|
experimental_features: null,
|
|
40944
|
+
protocol_version: null,
|
|
40929
40945
|
onekey_device_type: hdShared.EDeviceType.Pro2,
|
|
40930
40946
|
onekey_serial_no: descriptorId,
|
|
40931
40947
|
serial_no: descriptorId,
|
|
40932
40948
|
};
|
|
40933
40949
|
}
|
|
40934
40950
|
function normalizeProtocolV2Features(descriptor, deviceInfo) {
|
|
40935
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
40951
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28;
|
|
40936
40952
|
const features = createBaseFeatures(descriptor);
|
|
40937
40953
|
if (!deviceInfo)
|
|
40938
40954
|
return features;
|
|
40939
40955
|
const serialNo = ((_a = deviceInfo.hw) === null || _a === void 0 ? void 0 : _a.serial_no) || features.onekey_serial_no || getDescriptorId(descriptor);
|
|
40940
40956
|
const firmwareVersion = getImageVersion((_b = deviceInfo.fw) === null || _b === void 0 ? void 0 : _b.app);
|
|
40941
40957
|
const [fwMajor, fwMinor, fwPatch] = parseVersion(firmwareVersion);
|
|
40942
|
-
return Object.assign(Object.assign({}, features), { major_version: fwMajor, minor_version: fwMinor, patch_version: fwPatch, fw_major: fwMajor, fw_minor: fwMinor, fw_patch: fwPatch, device_id: serialNo, serial_no: serialNo, onekey_serial_no: serialNo, label: (
|
|
40958
|
+
return Object.assign(Object.assign({}, features), { major_version: fwMajor, minor_version: fwMinor, patch_version: fwPatch, fw_major: fwMajor, fw_minor: fwMinor, fw_patch: fwPatch, device_id: serialNo, serial_no: serialNo, onekey_serial_no: serialNo, protocol_version: (_c = deviceInfo.protocol_version) !== null && _c !== void 0 ? _c : features.protocol_version, label: (_e = (_d = deviceInfo.status) === null || _d === void 0 ? void 0 : _d.label) !== null && _e !== void 0 ? _e : features.label, language: (_g = (_f = deviceInfo.status) === null || _f === void 0 ? void 0 : _f.language) !== null && _g !== void 0 ? _g : features.language, initialized: (_j = (_h = deviceInfo.status) === null || _h === void 0 ? void 0 : _h.init_states) !== null && _j !== void 0 ? _j : features.initialized, passphrase_protection: (_l = (_k = deviceInfo.status) === null || _k === void 0 ? void 0 : _k.passphrase_protection) !== null && _l !== void 0 ? _l : features.passphrase_protection, needs_backup: (_o = (_m = deviceInfo.status) === null || _m === void 0 ? void 0 : _m.backup_required) !== null && _o !== void 0 ? _o : features.needs_backup, ble_enable: (_p = deviceInfo.status) === null || _p === void 0 ? void 0 : _p.bt_enable, onekey_ble_name: (_q = deviceInfo.bt) === null || _q === void 0 ? void 0 : _q.adv_name, ble_name: (_r = deviceInfo.bt) === null || _r === void 0 ? void 0 : _r.adv_name, onekey_firmware_version: firmwareVersion, onekey_firmware_build_id: getImageBuildId((_s = deviceInfo.fw) === null || _s === void 0 ? void 0 : _s.app), onekey_firmware_hash: getImageHash((_t = deviceInfo.fw) === null || _t === void 0 ? void 0 : _t.app), onekey_boot_version: getImageVersion((_u = deviceInfo.fw) === null || _u === void 0 ? void 0 : _u.boot), bootloader_version: getImageVersion((_v = deviceInfo.fw) === null || _v === void 0 ? void 0 : _v.boot), onekey_boot_build_id: getImageBuildId((_w = deviceInfo.fw) === null || _w === void 0 ? void 0 : _w.boot), onekey_boot_hash: getImageHash((_x = deviceInfo.fw) === null || _x === void 0 ? void 0 : _x.boot), onekey_board_version: getImageVersion((_y = deviceInfo.fw) === null || _y === void 0 ? void 0 : _y.board), onekey_board_build_id: getImageBuildId((_z = deviceInfo.fw) === null || _z === void 0 ? void 0 : _z.board), onekey_board_hash: getImageHash((_0 = deviceInfo.fw) === null || _0 === void 0 ? void 0 : _0.board), onekey_ble_version: getImageVersion((_1 = deviceInfo.bt) === null || _1 === void 0 ? void 0 : _1.app), ble_ver: getImageVersion((_2 = deviceInfo.bt) === null || _2 === void 0 ? void 0 : _2.app), onekey_ble_build_id: getImageBuildId((_3 = deviceInfo.bt) === null || _3 === void 0 ? void 0 : _3.app), onekey_ble_hash: getImageHash((_4 = deviceInfo.bt) === null || _4 === void 0 ? void 0 : _4.app), onekey_se01_version: getImageVersion((_5 = deviceInfo.se1) === null || _5 === void 0 ? void 0 : _5.app), onekey_se01_hash: getImageHash((_6 = deviceInfo.se1) === null || _6 === void 0 ? void 0 : _6.app), onekey_se01_build_id: getImageBuildId((_7 = deviceInfo.se1) === null || _7 === void 0 ? void 0 : _7.app), onekey_se01_boot_version: getImageVersion((_8 = deviceInfo.se1) === null || _8 === void 0 ? void 0 : _8.boot), onekey_se01_boot_hash: getImageHash((_9 = deviceInfo.se1) === null || _9 === void 0 ? void 0 : _9.boot), onekey_se01_boot_build_id: getImageBuildId((_10 = deviceInfo.se1) === null || _10 === void 0 ? void 0 : _10.boot), onekey_se01_state: getSeState(deviceInfo.se1), onekey_se02_version: getImageVersion((_11 = deviceInfo.se2) === null || _11 === void 0 ? void 0 : _11.app), onekey_se02_hash: getImageHash((_12 = deviceInfo.se2) === null || _12 === void 0 ? void 0 : _12.app), onekey_se02_build_id: getImageBuildId((_13 = deviceInfo.se2) === null || _13 === void 0 ? void 0 : _13.app), onekey_se02_boot_version: getImageVersion((_14 = deviceInfo.se2) === null || _14 === void 0 ? void 0 : _14.boot), onekey_se02_boot_hash: getImageHash((_15 = deviceInfo.se2) === null || _15 === void 0 ? void 0 : _15.boot), onekey_se02_boot_build_id: getImageBuildId((_16 = deviceInfo.se2) === null || _16 === void 0 ? void 0 : _16.boot), onekey_se02_state: getSeState(deviceInfo.se2), onekey_se03_version: getImageVersion((_17 = deviceInfo.se3) === null || _17 === void 0 ? void 0 : _17.app), onekey_se03_hash: getImageHash((_18 = deviceInfo.se3) === null || _18 === void 0 ? void 0 : _18.app), onekey_se03_build_id: getImageBuildId((_19 = deviceInfo.se3) === null || _19 === void 0 ? void 0 : _19.app), onekey_se03_boot_version: getImageVersion((_20 = deviceInfo.se3) === null || _20 === void 0 ? void 0 : _20.boot), onekey_se03_boot_hash: getImageHash((_21 = deviceInfo.se3) === null || _21 === void 0 ? void 0 : _21.boot), onekey_se03_boot_build_id: getImageBuildId((_22 = deviceInfo.se3) === null || _22 === void 0 ? void 0 : _22.boot), onekey_se03_state: getSeState(deviceInfo.se3), onekey_se04_version: getImageVersion((_23 = deviceInfo.se4) === null || _23 === void 0 ? void 0 : _23.app), onekey_se04_hash: getImageHash((_24 = deviceInfo.se4) === null || _24 === void 0 ? void 0 : _24.app), onekey_se04_build_id: getImageBuildId((_25 = deviceInfo.se4) === null || _25 === void 0 ? void 0 : _25.app), onekey_se04_boot_version: getImageVersion((_26 = deviceInfo.se4) === null || _26 === void 0 ? void 0 : _26.boot), onekey_se04_boot_hash: getImageHash((_27 = deviceInfo.se4) === null || _27 === void 0 ? void 0 : _27.boot), onekey_se04_boot_build_id: getImageBuildId((_28 = deviceInfo.se4) === null || _28 === void 0 ? void 0 : _28.boot), onekey_se04_state: getSeState(deviceInfo.se4) });
|
|
40943
40959
|
}
|
|
40944
|
-
function getProtocolV2Features({ commands, descriptor,
|
|
40960
|
+
function getProtocolV2Features({ commands, descriptor, timeoutMs, }) {
|
|
40945
40961
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40946
40962
|
const callOptions = timeoutMs ? { timeoutMs } : undefined;
|
|
40947
40963
|
if (callOptions) {
|
|
@@ -40950,16 +40966,10 @@ function getProtocolV2Features({ commands, descriptor, onDeviceInfoError, timeou
|
|
|
40950
40966
|
else {
|
|
40951
40967
|
yield commands.typedCall('Ping', 'Success', { message: 'init' });
|
|
40952
40968
|
}
|
|
40953
|
-
|
|
40954
|
-
|
|
40955
|
-
|
|
40956
|
-
|
|
40957
|
-
return normalizeProtocolV2Features(descriptor, message);
|
|
40958
|
-
}
|
|
40959
|
-
catch (error) {
|
|
40960
|
-
onDeviceInfoError === null || onDeviceInfoError === void 0 ? void 0 : onDeviceInfoError(error);
|
|
40961
|
-
return normalizeProtocolV2Features(descriptor);
|
|
40962
|
-
}
|
|
40969
|
+
const { message } = callOptions
|
|
40970
|
+
? yield commands.typedCall('DeviceGetDeviceInfo', 'DeviceInfo', PROTOCOL_V2_DEVICE_INFO_REQUEST, callOptions)
|
|
40971
|
+
: yield commands.typedCall('DeviceGetDeviceInfo', 'DeviceInfo', PROTOCOL_V2_DEVICE_INFO_REQUEST);
|
|
40972
|
+
return normalizeProtocolV2Features(descriptor, message);
|
|
40963
40973
|
});
|
|
40964
40974
|
}
|
|
40965
40975
|
|
|
@@ -41776,15 +41786,15 @@ class BaseMethod {
|
|
|
41776
41786
|
}));
|
|
41777
41787
|
}
|
|
41778
41788
|
checkFeatureVersionLimit(checkCondition, getVersionRange, options) {
|
|
41779
|
-
var _a
|
|
41789
|
+
var _a;
|
|
41780
41790
|
if (!checkCondition()) {
|
|
41781
41791
|
return;
|
|
41782
41792
|
}
|
|
41783
|
-
|
|
41784
|
-
return;
|
|
41785
|
-
}
|
|
41786
|
-
const firmwareVersion = (_b = getDeviceFirmwareVersion(this.device.features)) === null || _b === void 0 ? void 0 : _b.join('.');
|
|
41793
|
+
const firmwareVersion = (_a = getDeviceFirmwareVersion(this.device.features)) === null || _a === void 0 ? void 0 : _a.join('.');
|
|
41787
41794
|
const versionRange = getMethodVersionRange(this.device.features, type => getVersionRange()[type]);
|
|
41795
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
41796
|
+
throw hdShared.createDeviceNotSupportMethodError(this.name, getFirmwareType(this.device.features));
|
|
41797
|
+
}
|
|
41788
41798
|
if (!versionRange) {
|
|
41789
41799
|
if (options === null || options === void 0 ? void 0 : options.strictCheckDeviceSupport) {
|
|
41790
41800
|
throw hdShared.createDeviceNotSupportMethodError(this.name, getFirmwareType(this.device.features));
|
|
@@ -41893,6 +41903,216 @@ class GetFeatures extends BaseMethod {
|
|
|
41893
41903
|
}
|
|
41894
41904
|
}
|
|
41895
41905
|
|
|
41906
|
+
const isMeaningfulVersion = (version) => Boolean(version && version !== '0.0.0');
|
|
41907
|
+
const versionArrayToString = (version) => {
|
|
41908
|
+
if (!version || version.length === 0)
|
|
41909
|
+
return null;
|
|
41910
|
+
const value = version.join('.');
|
|
41911
|
+
return isMeaningfulVersion(value) ? value : null;
|
|
41912
|
+
};
|
|
41913
|
+
const firstVersion = (...versions) => { var _a; return (_a = versions.find(isMeaningfulVersion)) !== null && _a !== void 0 ? _a : null; };
|
|
41914
|
+
const safeGetDeviceUUID = (features) => (features ? getDeviceUUID(features) : '');
|
|
41915
|
+
const shouldIncludeVerify = (scope) => scope === 'verify' || scope === 'full';
|
|
41916
|
+
const getDeviceMode = (features) => {
|
|
41917
|
+
if (!features)
|
|
41918
|
+
return 'unknown';
|
|
41919
|
+
if (features.bootloader_mode === true)
|
|
41920
|
+
return 'bootloader';
|
|
41921
|
+
if (features.initialized === false)
|
|
41922
|
+
return 'notInitialized';
|
|
41923
|
+
if (features.initialized === true)
|
|
41924
|
+
return 'normal';
|
|
41925
|
+
return 'unknown';
|
|
41926
|
+
};
|
|
41927
|
+
const normalizeVersions = (features, onekeyFeatures) => ({
|
|
41928
|
+
firmware: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_firmware_version, versionArrayToString(getDeviceFirmwareVersion(features))),
|
|
41929
|
+
bootloader: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_boot_version, versionArrayToString(getDeviceBootloaderVersion(features))),
|
|
41930
|
+
board: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_board_version, versionArrayToString(features ? getDeviceBoardloaderVersion(features) : undefined)),
|
|
41931
|
+
ble: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_ble_version, features === null || features === void 0 ? void 0 : features.onekey_ble_version, features === null || features === void 0 ? void 0 : features.ble_ver, versionArrayToString(features ? getDeviceBLEFirmwareVersion(features) : undefined)),
|
|
41932
|
+
se01: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_version, features === null || features === void 0 ? void 0 : features.onekey_se01_version),
|
|
41933
|
+
se02: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_version, features === null || features === void 0 ? void 0 : features.onekey_se02_version),
|
|
41934
|
+
se03: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_version, features === null || features === void 0 ? void 0 : features.onekey_se03_version),
|
|
41935
|
+
se04: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_version, features === null || features === void 0 ? void 0 : features.onekey_se04_version),
|
|
41936
|
+
se01Boot: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_boot_version, features === null || features === void 0 ? void 0 : features.onekey_se01_boot_version),
|
|
41937
|
+
se02Boot: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_boot_version, features === null || features === void 0 ? void 0 : features.onekey_se02_boot_version),
|
|
41938
|
+
se03Boot: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_boot_version, features === null || features === void 0 ? void 0 : features.onekey_se03_boot_version),
|
|
41939
|
+
se04Boot: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_boot_version, features === null || features === void 0 ? void 0 : features.onekey_se04_boot_version),
|
|
41940
|
+
});
|
|
41941
|
+
const normalizeStatus = (protocol, features) => {
|
|
41942
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
41943
|
+
return ({
|
|
41944
|
+
mode: getDeviceMode(features),
|
|
41945
|
+
initialized: (_a = features === null || features === void 0 ? void 0 : features.initialized) !== null && _a !== void 0 ? _a : null,
|
|
41946
|
+
bootloaderMode: (_b = features === null || features === void 0 ? void 0 : features.bootloader_mode) !== null && _b !== void 0 ? _b : null,
|
|
41947
|
+
unlocked: protocol === 'V2' ? null : (_c = features === null || features === void 0 ? void 0 : features.unlocked) !== null && _c !== void 0 ? _c : null,
|
|
41948
|
+
passphraseProtection: (_d = features === null || features === void 0 ? void 0 : features.passphrase_protection) !== null && _d !== void 0 ? _d : null,
|
|
41949
|
+
backupRequired: (_e = features === null || features === void 0 ? void 0 : features.needs_backup) !== null && _e !== void 0 ? _e : null,
|
|
41950
|
+
language: (_f = features === null || features === void 0 ? void 0 : features.language) !== null && _f !== void 0 ? _f : null,
|
|
41951
|
+
bleEnabled: (_g = features === null || features === void 0 ? void 0 : features.ble_enable) !== null && _g !== void 0 ? _g : null,
|
|
41952
|
+
});
|
|
41953
|
+
};
|
|
41954
|
+
const normalizeVerify = (features, onekeyFeatures) => {
|
|
41955
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
41956
|
+
const featureRecord = features;
|
|
41957
|
+
return {
|
|
41958
|
+
firmwareBuildId: (_a = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_firmware_build_id) !== null && _a !== void 0 ? _a : features === null || features === void 0 ? void 0 : features.onekey_firmware_build_id,
|
|
41959
|
+
firmwareHash: (_b = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_firmware_hash) !== null && _b !== void 0 ? _b : features === null || features === void 0 ? void 0 : features.onekey_firmware_hash,
|
|
41960
|
+
bootloaderBuildId: (_c = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_boot_build_id) !== null && _c !== void 0 ? _c : features === null || features === void 0 ? void 0 : features.onekey_boot_build_id,
|
|
41961
|
+
bootloaderHash: (_d = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_boot_hash) !== null && _d !== void 0 ? _d : features === null || features === void 0 ? void 0 : features.onekey_boot_hash,
|
|
41962
|
+
boardBuildId: (_e = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_board_build_id) !== null && _e !== void 0 ? _e : featureRecord === null || featureRecord === void 0 ? void 0 : featureRecord.onekey_board_build_id,
|
|
41963
|
+
boardHash: (_f = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_board_hash) !== null && _f !== void 0 ? _f : features === null || features === void 0 ? void 0 : features.onekey_board_hash,
|
|
41964
|
+
bleBuildId: (_g = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_ble_build_id) !== null && _g !== void 0 ? _g : features === null || features === void 0 ? void 0 : features.onekey_ble_build_id,
|
|
41965
|
+
bleHash: (_h = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_ble_hash) !== null && _h !== void 0 ? _h : features === null || features === void 0 ? void 0 : features.onekey_ble_hash,
|
|
41966
|
+
se01BuildId: (_j = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_build_id) !== null && _j !== void 0 ? _j : features === null || features === void 0 ? void 0 : features.onekey_se01_build_id,
|
|
41967
|
+
se01Hash: (_k = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_hash) !== null && _k !== void 0 ? _k : featureRecord === null || featureRecord === void 0 ? void 0 : featureRecord.onekey_se01_hash,
|
|
41968
|
+
se02BuildId: (_l = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_build_id) !== null && _l !== void 0 ? _l : featureRecord === null || featureRecord === void 0 ? void 0 : featureRecord.onekey_se02_build_id,
|
|
41969
|
+
se02Hash: (_m = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_hash) !== null && _m !== void 0 ? _m : featureRecord === null || featureRecord === void 0 ? void 0 : featureRecord.onekey_se02_hash,
|
|
41970
|
+
se03BuildId: (_o = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_build_id) !== null && _o !== void 0 ? _o : featureRecord === null || featureRecord === void 0 ? void 0 : featureRecord.onekey_se03_build_id,
|
|
41971
|
+
se03Hash: (_p = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_hash) !== null && _p !== void 0 ? _p : featureRecord === null || featureRecord === void 0 ? void 0 : featureRecord.onekey_se03_hash,
|
|
41972
|
+
se04BuildId: (_q = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_build_id) !== null && _q !== void 0 ? _q : featureRecord === null || featureRecord === void 0 ? void 0 : featureRecord.onekey_se04_build_id,
|
|
41973
|
+
se04Hash: (_r = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_hash) !== null && _r !== void 0 ? _r : featureRecord === null || featureRecord === void 0 ? void 0 : featureRecord.onekey_se04_hash,
|
|
41974
|
+
se01BootBuildId: (_s = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_boot_build_id) !== null && _s !== void 0 ? _s : features === null || features === void 0 ? void 0 : features.onekey_se01_boot_build_id,
|
|
41975
|
+
se01BootHash: (_t = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_boot_hash) !== null && _t !== void 0 ? _t : features === null || features === void 0 ? void 0 : features.onekey_se01_boot_hash,
|
|
41976
|
+
se02BootBuildId: (_u = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_boot_build_id) !== null && _u !== void 0 ? _u : features === null || features === void 0 ? void 0 : features.onekey_se02_boot_build_id,
|
|
41977
|
+
se02BootHash: (_v = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_boot_hash) !== null && _v !== void 0 ? _v : features === null || features === void 0 ? void 0 : features.onekey_se02_boot_hash,
|
|
41978
|
+
se03BootBuildId: (_w = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_boot_build_id) !== null && _w !== void 0 ? _w : features === null || features === void 0 ? void 0 : features.onekey_se03_boot_build_id,
|
|
41979
|
+
se03BootHash: (_x = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_boot_hash) !== null && _x !== void 0 ? _x : features === null || features === void 0 ? void 0 : features.onekey_se03_boot_hash,
|
|
41980
|
+
se04BootBuildId: (_y = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_boot_build_id) !== null && _y !== void 0 ? _y : features === null || features === void 0 ? void 0 : features.onekey_se04_boot_build_id,
|
|
41981
|
+
se04BootHash: (_z = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_boot_hash) !== null && _z !== void 0 ? _z : features === null || features === void 0 ? void 0 : features.onekey_se04_boot_hash,
|
|
41982
|
+
};
|
|
41983
|
+
};
|
|
41984
|
+
const normalizeRaw = ({ features, onekeyFeatures, protocolV2DeviceInfo, }) => (Object.assign(Object.assign(Object.assign({}, (features ? { features } : {})), (onekeyFeatures ? { onekeyFeatures } : {})), (protocolV2DeviceInfo ? { protocolV2DeviceInfo } : {})));
|
|
41985
|
+
function buildUnifiedDeviceInfo({ protocol, features, onekeyFeatures, protocolV2DeviceInfo, sources, scope = 'basic', includeRaw = false, }) {
|
|
41986
|
+
const mergedFeatures = Object.assign(Object.assign({}, (features !== null && features !== void 0 ? features : {})), (onekeyFeatures !== null && onekeyFeatures !== void 0 ? onekeyFeatures : {}));
|
|
41987
|
+
const hasFeatures = Boolean(features || onekeyFeatures);
|
|
41988
|
+
const sourceFeatures = hasFeatures ? mergedFeatures : undefined;
|
|
41989
|
+
const deviceType = getDeviceType(sourceFeatures);
|
|
41990
|
+
const verify = normalizeVerify(sourceFeatures, onekeyFeatures);
|
|
41991
|
+
return Object.assign(Object.assign({ protocol,
|
|
41992
|
+
sources,
|
|
41993
|
+
deviceType, firmwareType: getFirmwareType(sourceFeatures), deviceId: (sourceFeatures === null || sourceFeatures === void 0 ? void 0 : sourceFeatures.device_id) || safeGetDeviceUUID(sourceFeatures), serialNo: safeGetDeviceUUID(sourceFeatures), label: getDeviceLabel(sourceFeatures), bleName: getDeviceBleName(sourceFeatures), status: normalizeStatus(protocol, sourceFeatures), versions: normalizeVersions(sourceFeatures, onekeyFeatures) }, (shouldIncludeVerify(scope) ? { verify } : {})), (includeRaw
|
|
41994
|
+
? {
|
|
41995
|
+
raw: normalizeRaw({
|
|
41996
|
+
features,
|
|
41997
|
+
onekeyFeatures,
|
|
41998
|
+
protocolV2DeviceInfo,
|
|
41999
|
+
}),
|
|
42000
|
+
}
|
|
42001
|
+
: {}));
|
|
42002
|
+
}
|
|
42003
|
+
|
|
42004
|
+
const DEVICE_INFO_SCOPES = ['basic', 'versions', 'verify', 'full'];
|
|
42005
|
+
function isDeviceInfoScope(scope) {
|
|
42006
|
+
return typeof scope === 'string' && DEVICE_INFO_SCOPES.includes(scope);
|
|
42007
|
+
}
|
|
42008
|
+
function normalizeScope(scope) {
|
|
42009
|
+
if (scope === undefined || scope === null)
|
|
42010
|
+
return 'basic';
|
|
42011
|
+
if (isDeviceInfoScope(scope)) {
|
|
42012
|
+
return scope;
|
|
42013
|
+
}
|
|
42014
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, `Invalid getDeviceInfo scope: ${String(scope)}`);
|
|
42015
|
+
}
|
|
42016
|
+
function shouldReadProtocolV2DeviceInfo(params) {
|
|
42017
|
+
return (params.refresh === true ||
|
|
42018
|
+
params.includeRaw === true ||
|
|
42019
|
+
params.scope === 'verify' ||
|
|
42020
|
+
params.scope === 'full');
|
|
42021
|
+
}
|
|
42022
|
+
function shouldReadOnekeyFeatures(params) {
|
|
42023
|
+
return (params.includeRaw === true ||
|
|
42024
|
+
params.scope === 'versions' ||
|
|
42025
|
+
params.scope === 'verify' ||
|
|
42026
|
+
params.scope === 'full');
|
|
42027
|
+
}
|
|
42028
|
+
function supportOnekeyFeatures(features) {
|
|
42029
|
+
if (!features || features.bootloader_mode)
|
|
42030
|
+
return false;
|
|
42031
|
+
const deviceType = getDeviceType(features);
|
|
42032
|
+
return ![
|
|
42033
|
+
hdShared.EDeviceType.Unknown,
|
|
42034
|
+
hdShared.EDeviceType.Classic1s,
|
|
42035
|
+
hdShared.EDeviceType.ClassicPure,
|
|
42036
|
+
hdShared.EDeviceType.Pro2,
|
|
42037
|
+
].includes(deviceType);
|
|
42038
|
+
}
|
|
42039
|
+
function normalizeOnekeyFeatures(message) {
|
|
42040
|
+
if (message.onekey_firmware_version && !semver__default["default"].valid(message.onekey_firmware_version)) {
|
|
42041
|
+
message.onekey_firmware_version = fixVersion(message.onekey_firmware_version);
|
|
42042
|
+
}
|
|
42043
|
+
return message;
|
|
42044
|
+
}
|
|
42045
|
+
class GetDeviceInfo extends BaseMethod {
|
|
42046
|
+
init() {
|
|
42047
|
+
this.allowDeviceMode = [
|
|
42048
|
+
...this.allowDeviceMode,
|
|
42049
|
+
UI_REQUEST.NOT_INITIALIZE,
|
|
42050
|
+
UI_REQUEST.BOOTLOADER,
|
|
42051
|
+
];
|
|
42052
|
+
this.useDevicePassphraseState = false;
|
|
42053
|
+
this.skipForceUpdateCheck = true;
|
|
42054
|
+
this.params = {
|
|
42055
|
+
scope: normalizeScope(this.payload.scope),
|
|
42056
|
+
refresh: this.payload.refresh,
|
|
42057
|
+
includeRaw: this.payload.includeRaw,
|
|
42058
|
+
};
|
|
42059
|
+
}
|
|
42060
|
+
run() {
|
|
42061
|
+
var _a;
|
|
42062
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42063
|
+
if (((_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType) === 'V2') {
|
|
42064
|
+
return this.runProtocolV2();
|
|
42065
|
+
}
|
|
42066
|
+
return this.runProtocolV1();
|
|
42067
|
+
});
|
|
42068
|
+
}
|
|
42069
|
+
runProtocolV2() {
|
|
42070
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42071
|
+
const sources = ['features'];
|
|
42072
|
+
let { features } = this.device;
|
|
42073
|
+
let protocolV2DeviceInfo;
|
|
42074
|
+
if (shouldReadProtocolV2DeviceInfo(this.params)) {
|
|
42075
|
+
const { message } = yield this.device.commands.typedCall('DeviceGetDeviceInfo', 'DeviceInfo', PROTOCOL_V2_DEVICE_INFO_REQUEST);
|
|
42076
|
+
protocolV2DeviceInfo = message;
|
|
42077
|
+
features = normalizeProtocolV2Features(this.device.originalDescriptor, protocolV2DeviceInfo);
|
|
42078
|
+
this.device._updateFeatures(features);
|
|
42079
|
+
sources.push('deviceGetDeviceInfo');
|
|
42080
|
+
}
|
|
42081
|
+
return buildUnifiedDeviceInfo({
|
|
42082
|
+
protocol: 'V2',
|
|
42083
|
+
features,
|
|
42084
|
+
protocolV2DeviceInfo,
|
|
42085
|
+
sources,
|
|
42086
|
+
scope: this.params.scope,
|
|
42087
|
+
includeRaw: this.params.includeRaw,
|
|
42088
|
+
});
|
|
42089
|
+
});
|
|
42090
|
+
}
|
|
42091
|
+
runProtocolV1() {
|
|
42092
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42093
|
+
if (this.params.refresh === true) {
|
|
42094
|
+
yield this.device.getFeatures();
|
|
42095
|
+
}
|
|
42096
|
+
const sources = ['features'];
|
|
42097
|
+
const { features } = this.device;
|
|
42098
|
+
let onekeyFeatures;
|
|
42099
|
+
if (shouldReadOnekeyFeatures(this.params) && supportOnekeyFeatures(features)) {
|
|
42100
|
+
const { message } = yield this.device.commands.typedCall('OnekeyGetFeatures', 'OnekeyFeatures');
|
|
42101
|
+
onekeyFeatures = normalizeOnekeyFeatures(message);
|
|
42102
|
+
sources.push('onekeyFeatures');
|
|
42103
|
+
}
|
|
42104
|
+
return buildUnifiedDeviceInfo({
|
|
42105
|
+
protocol: 'V1',
|
|
42106
|
+
features,
|
|
42107
|
+
onekeyFeatures,
|
|
42108
|
+
sources,
|
|
42109
|
+
scope: this.params.scope,
|
|
42110
|
+
includeRaw: this.params.includeRaw,
|
|
42111
|
+
});
|
|
42112
|
+
});
|
|
42113
|
+
}
|
|
42114
|
+
}
|
|
42115
|
+
|
|
41896
42116
|
const ONEKEY_FEATURE_KEYS = [
|
|
41897
42117
|
'onekey_device_type',
|
|
41898
42118
|
'onekey_board_version',
|
|
@@ -41997,18 +42217,13 @@ class GetPassphraseState extends BaseMethod {
|
|
|
41997
42217
|
});
|
|
41998
42218
|
const { features } = this.device;
|
|
41999
42219
|
const isPro2 = getDeviceType(features) === hdShared.EDeviceType.Pro2;
|
|
42000
|
-
|
|
42001
|
-
|
|
42002
|
-
|
|
42003
|
-
|
|
42004
|
-
|
|
42005
|
-
|
|
42006
|
-
|
|
42007
|
-
}
|
|
42008
|
-
if (features && features.passphrase_protection === true) {
|
|
42009
|
-
return Promise.resolve(passphraseState);
|
|
42010
|
-
}
|
|
42011
|
-
return Promise.resolve(undefined);
|
|
42220
|
+
const passphraseProtection = (_a = features === null || features === void 0 ? void 0 : features.passphrase_protection) !== null && _a !== void 0 ? _a : null;
|
|
42221
|
+
return Promise.resolve({
|
|
42222
|
+
passphrase_state: isPro2 || passphraseProtection === true ? passphraseState : undefined,
|
|
42223
|
+
session_id: (_b = newSession !== null && newSession !== void 0 ? newSession : features === null || features === void 0 ? void 0 : features.session_id) !== null && _b !== void 0 ? _b : undefined,
|
|
42224
|
+
unlocked_attach_pin: unlockedAttachPin !== null && unlockedAttachPin !== void 0 ? unlockedAttachPin : features === null || features === void 0 ? void 0 : features.unlocked_attach_pin,
|
|
42225
|
+
passphrase_protection: passphraseProtection,
|
|
42226
|
+
});
|
|
42012
42227
|
});
|
|
42013
42228
|
}
|
|
42014
42229
|
}
|
|
@@ -45695,7 +45910,19 @@ class DeviceFirmwareUpdate extends BaseMethod {
|
|
|
45695
45910
|
const targets = normalizeFirmwareTargets(this.params);
|
|
45696
45911
|
const res = yield this.device.commands.typedCall('DeviceFirmwareUpdate', PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES, {
|
|
45697
45912
|
targets,
|
|
45698
|
-
}, PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS)
|
|
45913
|
+
}, Object.assign(Object.assign({}, PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS), { onIntermediateResponse: response => {
|
|
45914
|
+
var _a;
|
|
45915
|
+
if (response.type !== 'DeviceFirmwareInstallProgress')
|
|
45916
|
+
return;
|
|
45917
|
+
const progress = Number((_a = response.message) === null || _a === void 0 ? void 0 : _a.progress);
|
|
45918
|
+
if (!Number.isFinite(progress))
|
|
45919
|
+
return;
|
|
45920
|
+
this.postMessage(createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
|
|
45921
|
+
device: this.device.toMessageObject(),
|
|
45922
|
+
progress: Math.min(Math.max(progress, 0), 100),
|
|
45923
|
+
progressType: 'installingFirmware',
|
|
45924
|
+
}));
|
|
45925
|
+
} }));
|
|
45699
45926
|
return Promise.resolve(res.message);
|
|
45700
45927
|
});
|
|
45701
45928
|
}
|
|
@@ -45783,6 +46010,27 @@ class FilesystemFormat extends BaseMethod {
|
|
|
45783
46010
|
}
|
|
45784
46011
|
}
|
|
45785
46012
|
|
|
46013
|
+
class FilesystemDiskControl extends BaseMethod {
|
|
46014
|
+
init() {
|
|
46015
|
+
this.skipForceUpdateCheck = true;
|
|
46016
|
+
this.useDevicePassphraseState = false;
|
|
46017
|
+
this.params = {
|
|
46018
|
+
enable: validateNonNegativeInteger(this.payload.enable, 'enable', 0),
|
|
46019
|
+
timeoutMs: validateOptionalNonNegativeInteger(this.payload.timeoutMs, 'timeoutMs'),
|
|
46020
|
+
};
|
|
46021
|
+
}
|
|
46022
|
+
run() {
|
|
46023
|
+
var _a;
|
|
46024
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46025
|
+
const timeoutMs = Number(this.params.timeoutMs);
|
|
46026
|
+
const res = yield this.device.commands.typedCall('FilesystemDiskControl', 'Success', {
|
|
46027
|
+
enable: Number((_a = this.params.enable) !== null && _a !== void 0 ? _a : 0),
|
|
46028
|
+
}, Number.isFinite(timeoutMs) && timeoutMs > 0 ? { timeoutMs } : undefined);
|
|
46029
|
+
return Promise.resolve(res.message);
|
|
46030
|
+
});
|
|
46031
|
+
}
|
|
46032
|
+
}
|
|
46033
|
+
|
|
45786
46034
|
const MIN_FILE_READ_CHUNK_SIZE = 64;
|
|
45787
46035
|
function getProtocolV2FileReadChunkLimit() {
|
|
45788
46036
|
const env = DataManager.getSettings('env');
|
|
@@ -46494,12 +46742,11 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
46494
46742
|
}
|
|
46495
46743
|
}
|
|
46496
46744
|
function preCheckDeviceSupport(device, method) {
|
|
46497
|
-
var _a;
|
|
46498
|
-
if (shouldSkipMethodSupportCheck(device.features, (_a = device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType)) {
|
|
46499
|
-
return;
|
|
46500
|
-
}
|
|
46501
46745
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
46502
46746
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
46747
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
46748
|
+
throw hdShared.ERRORS.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
46749
|
+
}
|
|
46503
46750
|
if (versionRange &&
|
|
46504
46751
|
semver__default["default"].valid(versionRange.min) &&
|
|
46505
46752
|
semver__default["default"].lt(currentVersion, versionRange.min)) {
|
|
@@ -46515,16 +46762,10 @@ function preCheckDeviceSupport(device, method) {
|
|
|
46515
46762
|
}
|
|
46516
46763
|
}
|
|
46517
46764
|
function handleSkippableHardwareError(e, device, method) {
|
|
46518
|
-
var _a, _b, _c, _d, _e, _f
|
|
46765
|
+
var _a, _b, _c, _d, _e, _f;
|
|
46519
46766
|
let error;
|
|
46520
|
-
const skipMethodSupportCheck = shouldSkipMethodSupportCheck(device.features, (_a = device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType);
|
|
46521
46767
|
if (e instanceof hdShared.HardwareError && e.errorCode !== hdShared.HardwareErrorCode.RuntimeError) {
|
|
46522
46768
|
const { errorCode } = e;
|
|
46523
|
-
if (skipMethodSupportCheck &&
|
|
46524
|
-
(errorCode === hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware ||
|
|
46525
|
-
errorCode === hdShared.HardwareErrorCode.DeviceNotSupportMethod)) {
|
|
46526
|
-
return undefined;
|
|
46527
|
-
}
|
|
46528
46769
|
if (errorCode === hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware) {
|
|
46529
46770
|
error = e;
|
|
46530
46771
|
}
|
|
@@ -46532,13 +46773,14 @@ function handleSkippableHardwareError(e, device, method) {
|
|
|
46532
46773
|
error = e;
|
|
46533
46774
|
}
|
|
46534
46775
|
}
|
|
46535
|
-
else if (((
|
|
46536
|
-
((
|
|
46537
|
-
if (skipMethodSupportCheck) {
|
|
46538
|
-
return undefined;
|
|
46539
|
-
}
|
|
46776
|
+
else if (((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes('Failure_UnexpectedMessage')) ||
|
|
46777
|
+
((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage'))) {
|
|
46540
46778
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
46541
46779
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
46780
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
46781
|
+
error = hdShared.ERRORS.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
46782
|
+
return error;
|
|
46783
|
+
}
|
|
46542
46784
|
if (versionRange &&
|
|
46543
46785
|
semver__default["default"].valid(versionRange.min) &&
|
|
46544
46786
|
semver__default["default"].lt(currentVersion, versionRange.min)) {
|
|
@@ -46553,8 +46795,8 @@ function handleSkippableHardwareError(e, device, method) {
|
|
|
46553
46795
|
error = hdShared.ERRORS.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
46554
46796
|
}
|
|
46555
46797
|
}
|
|
46556
|
-
else if (((
|
|
46557
|
-
((
|
|
46798
|
+
else if (((_d = (_c = e.message) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === null || _d === void 0 ? void 0 : _d.includes('forbidden key path')) ||
|
|
46799
|
+
((_f = (_e = e.message) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === null || _f === void 0 ? void 0 : _f.includes('invalid path'))) {
|
|
46558
46800
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, e.message);
|
|
46559
46801
|
}
|
|
46560
46802
|
return error;
|
|
@@ -46982,6 +47224,10 @@ function isCoinNameInList(coinName, coinNames) {
|
|
|
46982
47224
|
function getBitcoinForkVersionRange(params) {
|
|
46983
47225
|
if (isCoinNameInList('Neurai', params)) {
|
|
46984
47226
|
return {
|
|
47227
|
+
pro2: {
|
|
47228
|
+
min: '0.0.0',
|
|
47229
|
+
unsupported: true,
|
|
47230
|
+
},
|
|
46985
47231
|
model_mini: {
|
|
46986
47232
|
min: '3.7.0',
|
|
46987
47233
|
},
|
|
@@ -47067,14 +47313,13 @@ function splitArray(array, size) {
|
|
|
47067
47313
|
}
|
|
47068
47314
|
|
|
47069
47315
|
function batchGetPublickeys(device, paths, ecdsaCurveName, coinType, options) {
|
|
47070
|
-
var _a
|
|
47316
|
+
var _a;
|
|
47071
47317
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47072
47318
|
const existsPathNotValid = paths.find(p => p.address_n.length < 3);
|
|
47073
47319
|
if (existsPathNotValid) {
|
|
47074
47320
|
throw hdShared.TypedError(hdShared.HardwareErrorCode.ForbiddenKeyPath, 'Path length must be greater than 3');
|
|
47075
47321
|
}
|
|
47076
|
-
const supportsBatchPublicKey =
|
|
47077
|
-
supportBatchPublicKey(device.features, options);
|
|
47322
|
+
const supportsBatchPublicKey = supportBatchPublicKey(device.features, options);
|
|
47078
47323
|
if (!supportsBatchPublicKey) {
|
|
47079
47324
|
throw hdShared.createDeviceNotSupportMethodError('BatchGetPublickeys', getFirmwareType(device.features));
|
|
47080
47325
|
}
|
|
@@ -47099,7 +47344,7 @@ function batchGetPublickeys(device, paths, ecdsaCurveName, coinType, options) {
|
|
|
47099
47344
|
const res = yield device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
47100
47345
|
paths,
|
|
47101
47346
|
ecdsa_curve_name: ecdsaCurveName,
|
|
47102
|
-
include_node: (
|
|
47347
|
+
include_node: (_a = options === null || options === void 0 ? void 0 : options.includeNode) !== null && _a !== void 0 ? _a : false,
|
|
47103
47348
|
});
|
|
47104
47349
|
if (res.type !== 'EcdsaPublicKeys') {
|
|
47105
47350
|
throw hdShared.createDeviceNotSupportMethodError('BatchGetPublickeys', getFirmwareType(device.features));
|
|
@@ -48288,6 +48533,10 @@ class EVMSignMessageEIP712 extends BaseMethod {
|
|
|
48288
48533
|
}
|
|
48289
48534
|
getVersionRange() {
|
|
48290
48535
|
return {
|
|
48536
|
+
pro2: {
|
|
48537
|
+
min: '0.0.0',
|
|
48538
|
+
unsupported: true,
|
|
48539
|
+
},
|
|
48291
48540
|
model_mini: {
|
|
48292
48541
|
min: '2.1.9',
|
|
48293
48542
|
},
|
|
@@ -48298,6 +48547,9 @@ class EVMSignMessageEIP712 extends BaseMethod {
|
|
|
48298
48547
|
}
|
|
48299
48548
|
run() {
|
|
48300
48549
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48550
|
+
this.checkFeatureVersionLimit(() => true, () => this.getVersionRange(), {
|
|
48551
|
+
strictCheckDeviceSupport: true,
|
|
48552
|
+
});
|
|
48301
48553
|
const res = yield this.device.commands.typedCall('EthereumSignMessageEIP712', 'EthereumMessageSignature', Object.assign({}, this.params));
|
|
48302
48554
|
return Promise.resolve(res.message);
|
|
48303
48555
|
});
|
|
@@ -49877,6 +50129,14 @@ class StellarGetAddress extends BaseMethod {
|
|
|
49877
50129
|
});
|
|
49878
50130
|
});
|
|
49879
50131
|
}
|
|
50132
|
+
getVersionRange() {
|
|
50133
|
+
return {
|
|
50134
|
+
pro2: {
|
|
50135
|
+
min: '0.0.0',
|
|
50136
|
+
unsupported: true,
|
|
50137
|
+
},
|
|
50138
|
+
};
|
|
50139
|
+
}
|
|
49880
50140
|
run() {
|
|
49881
50141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49882
50142
|
const responses = [];
|
|
@@ -50110,6 +50370,14 @@ class StellarSignTransaction extends BaseMethod {
|
|
|
50110
50370
|
}
|
|
50111
50371
|
});
|
|
50112
50372
|
}
|
|
50373
|
+
getVersionRange() {
|
|
50374
|
+
return {
|
|
50375
|
+
pro2: {
|
|
50376
|
+
min: '0.0.0',
|
|
50377
|
+
unsupported: true,
|
|
50378
|
+
},
|
|
50379
|
+
};
|
|
50380
|
+
}
|
|
50113
50381
|
init() {
|
|
50114
50382
|
this.checkDeviceId = true;
|
|
50115
50383
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -51466,6 +51734,11 @@ class SuiSignTransaction extends BaseMethod {
|
|
|
51466
51734
|
};
|
|
51467
51735
|
}
|
|
51468
51736
|
supportChunkTransfer() {
|
|
51737
|
+
var _a;
|
|
51738
|
+
if (((_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType) === 'V2' ||
|
|
51739
|
+
getDeviceType(this.device.features) === hdShared.EDeviceType.Pro2) {
|
|
51740
|
+
return true;
|
|
51741
|
+
}
|
|
51469
51742
|
const deviceType = getDeviceType(this.device.features);
|
|
51470
51743
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
51471
51744
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
@@ -51484,7 +51757,7 @@ class SuiSignTransaction extends BaseMethod {
|
|
|
51484
51757
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51485
51758
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
51486
51759
|
let offset = 0;
|
|
51487
|
-
let data;
|
|
51760
|
+
let data = Buffer.alloc(0);
|
|
51488
51761
|
if (this.supportChunkTransfer()) {
|
|
51489
51762
|
offset = this.chunkByteSize;
|
|
51490
51763
|
data = Buffer.from(this.params.raw_tx, 'hex');
|
|
@@ -53317,6 +53590,10 @@ class NexaGetAddress extends BaseMethod {
|
|
|
53317
53590
|
}
|
|
53318
53591
|
getVersionRange() {
|
|
53319
53592
|
return {
|
|
53593
|
+
pro2: {
|
|
53594
|
+
min: '0.0.0',
|
|
53595
|
+
unsupported: true,
|
|
53596
|
+
},
|
|
53320
53597
|
model_mini: {
|
|
53321
53598
|
min: '3.2.0',
|
|
53322
53599
|
},
|
|
@@ -53367,6 +53644,10 @@ class NexaSignTransaction extends BaseMethod {
|
|
|
53367
53644
|
}
|
|
53368
53645
|
getVersionRange() {
|
|
53369
53646
|
return {
|
|
53647
|
+
pro2: {
|
|
53648
|
+
min: '0.0.0',
|
|
53649
|
+
unsupported: true,
|
|
53650
|
+
},
|
|
53370
53651
|
model_mini: {
|
|
53371
53652
|
min: '3.2.0',
|
|
53372
53653
|
},
|
|
@@ -53748,6 +54029,10 @@ class NervosGetAddress extends BaseMethod {
|
|
|
53748
54029
|
}
|
|
53749
54030
|
getVersionRange() {
|
|
53750
54031
|
return {
|
|
54032
|
+
pro2: {
|
|
54033
|
+
min: '0.0.0',
|
|
54034
|
+
unsupported: true,
|
|
54035
|
+
},
|
|
53751
54036
|
model_mini: {
|
|
53752
54037
|
min: '3.7.0',
|
|
53753
54038
|
},
|
|
@@ -53827,6 +54112,10 @@ class NervosSignTransaction extends BaseMethod {
|
|
|
53827
54112
|
}
|
|
53828
54113
|
getVersionRange() {
|
|
53829
54114
|
return {
|
|
54115
|
+
pro2: {
|
|
54116
|
+
min: '0.0.0',
|
|
54117
|
+
unsupported: true,
|
|
54118
|
+
},
|
|
53830
54119
|
model_mini: {
|
|
53831
54120
|
min: '3.7.0',
|
|
53832
54121
|
},
|
|
@@ -54366,6 +54655,10 @@ class ScdoGetAddress extends BaseMethod {
|
|
|
54366
54655
|
}
|
|
54367
54656
|
getVersionRange() {
|
|
54368
54657
|
return {
|
|
54658
|
+
pro2: {
|
|
54659
|
+
min: '0.0.0',
|
|
54660
|
+
unsupported: true,
|
|
54661
|
+
},
|
|
54369
54662
|
model_touch: {
|
|
54370
54663
|
min: '4.10.0',
|
|
54371
54664
|
},
|
|
@@ -54441,6 +54734,10 @@ class ScdoSignTransaction extends BaseMethod {
|
|
|
54441
54734
|
}
|
|
54442
54735
|
getVersionRange() {
|
|
54443
54736
|
return {
|
|
54737
|
+
pro2: {
|
|
54738
|
+
min: '0.0.0',
|
|
54739
|
+
unsupported: true,
|
|
54740
|
+
},
|
|
54444
54741
|
model_touch: {
|
|
54445
54742
|
min: '4.10.0',
|
|
54446
54743
|
},
|
|
@@ -54480,6 +54777,10 @@ class ScdoSignMessage extends BaseMethod {
|
|
|
54480
54777
|
}
|
|
54481
54778
|
getVersionRange() {
|
|
54482
54779
|
return {
|
|
54780
|
+
pro2: {
|
|
54781
|
+
min: '0.0.0',
|
|
54782
|
+
unsupported: true,
|
|
54783
|
+
},
|
|
54483
54784
|
model_touch: {
|
|
54484
54785
|
min: '4.10.0',
|
|
54485
54786
|
},
|
|
@@ -54521,6 +54822,10 @@ class AlephiumGetAddress extends BaseMethod {
|
|
|
54521
54822
|
}
|
|
54522
54823
|
getVersionRange() {
|
|
54523
54824
|
return {
|
|
54825
|
+
pro2: {
|
|
54826
|
+
min: '0.0.0',
|
|
54827
|
+
unsupported: true,
|
|
54828
|
+
},
|
|
54524
54829
|
model_touch: {
|
|
54525
54830
|
min: '4.10.0',
|
|
54526
54831
|
},
|
|
@@ -54604,6 +54909,10 @@ class AlephiumSignTransaction extends BaseMethod {
|
|
|
54604
54909
|
}
|
|
54605
54910
|
getVersionRange() {
|
|
54606
54911
|
return {
|
|
54912
|
+
pro2: {
|
|
54913
|
+
min: '0.0.0',
|
|
54914
|
+
unsupported: true,
|
|
54915
|
+
},
|
|
54607
54916
|
model_touch: {
|
|
54608
54917
|
min: '4.10.0',
|
|
54609
54918
|
},
|
|
@@ -54645,6 +54954,10 @@ class AlephiumSignMessage extends BaseMethod {
|
|
|
54645
54954
|
}
|
|
54646
54955
|
getVersionRange() {
|
|
54647
54956
|
return {
|
|
54957
|
+
pro2: {
|
|
54958
|
+
min: '0.0.0',
|
|
54959
|
+
unsupported: true,
|
|
54960
|
+
},
|
|
54648
54961
|
model_touch: {
|
|
54649
54962
|
min: '4.10.0',
|
|
54650
54963
|
},
|
|
@@ -54720,6 +55033,10 @@ class BenfenGetAddress extends BaseMethod {
|
|
|
54720
55033
|
}
|
|
54721
55034
|
getVersionRange() {
|
|
54722
55035
|
return {
|
|
55036
|
+
pro2: {
|
|
55037
|
+
min: '0.0.0',
|
|
55038
|
+
unsupported: true,
|
|
55039
|
+
},
|
|
54723
55040
|
pro: {
|
|
54724
55041
|
min: '4.12.0',
|
|
54725
55042
|
},
|
|
@@ -54808,6 +55125,10 @@ class BenfenGetPublicKey extends BaseMethod {
|
|
|
54808
55125
|
}
|
|
54809
55126
|
getVersionRange() {
|
|
54810
55127
|
return {
|
|
55128
|
+
pro2: {
|
|
55129
|
+
min: '0.0.0',
|
|
55130
|
+
unsupported: true,
|
|
55131
|
+
},
|
|
54811
55132
|
pro: {
|
|
54812
55133
|
min: '4.12.0',
|
|
54813
55134
|
},
|
|
@@ -54848,6 +55169,10 @@ class BenfenSignMessage extends BaseMethod {
|
|
|
54848
55169
|
}
|
|
54849
55170
|
getVersionRange() {
|
|
54850
55171
|
return {
|
|
55172
|
+
pro2: {
|
|
55173
|
+
min: '0.0.0',
|
|
55174
|
+
unsupported: true,
|
|
55175
|
+
},
|
|
54851
55176
|
pro: {
|
|
54852
55177
|
min: '4.12.0',
|
|
54853
55178
|
},
|
|
@@ -54901,6 +55226,10 @@ class BenfenSignTransaction extends BaseMethod {
|
|
|
54901
55226
|
}
|
|
54902
55227
|
getVersionRange() {
|
|
54903
55228
|
return {
|
|
55229
|
+
pro2: {
|
|
55230
|
+
min: '0.0.0',
|
|
55231
|
+
unsupported: true,
|
|
55232
|
+
},
|
|
54904
55233
|
pro: {
|
|
54905
55234
|
min: '4.12.0',
|
|
54906
55235
|
},
|
|
@@ -54957,6 +55286,10 @@ class NeoGetAddress extends BaseMethod {
|
|
|
54957
55286
|
}
|
|
54958
55287
|
getVersionRange() {
|
|
54959
55288
|
return {
|
|
55289
|
+
pro2: {
|
|
55290
|
+
min: '0.0.0',
|
|
55291
|
+
unsupported: true,
|
|
55292
|
+
},
|
|
54960
55293
|
pro: {
|
|
54961
55294
|
min: '4.12.0',
|
|
54962
55295
|
},
|
|
@@ -55011,6 +55344,10 @@ class NeoSignTransaction extends BaseMethod {
|
|
|
55011
55344
|
}
|
|
55012
55345
|
getVersionRange() {
|
|
55013
55346
|
return {
|
|
55347
|
+
pro2: {
|
|
55348
|
+
min: '0.0.0',
|
|
55349
|
+
unsupported: true,
|
|
55350
|
+
},
|
|
55014
55351
|
pro: {
|
|
55015
55352
|
min: '4.12.0',
|
|
55016
55353
|
},
|
|
@@ -55041,6 +55378,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
55041
55378
|
testInitializeDeviceDuration: TestInitializeDeviceDuration,
|
|
55042
55379
|
searchDevices: SearchDevices,
|
|
55043
55380
|
getFeatures: GetFeatures,
|
|
55381
|
+
getDeviceInfo: GetDeviceInfo,
|
|
55044
55382
|
getOnekeyFeatures: GetOnekeyFeatures,
|
|
55045
55383
|
getPassphraseState: GetPassphraseState,
|
|
55046
55384
|
getLogs: GetLogs,
|
|
@@ -55087,6 +55425,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
55087
55425
|
factoryGetDeviceInfo: FactoryGetDeviceInfo,
|
|
55088
55426
|
filesystemFixPermission: FilesystemFixPermission,
|
|
55089
55427
|
filesystemFormat: FilesystemFormat,
|
|
55428
|
+
filesystemDiskControl: FilesystemDiskControl,
|
|
55090
55429
|
fileRead: FileRead,
|
|
55091
55430
|
fileWrite: FileWrite,
|
|
55092
55431
|
fileDelete: FileDelete,
|
|
@@ -55655,9 +55994,8 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55655
55994
|
}
|
|
55656
55995
|
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
55657
55996
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55658
|
-
var _f, _g, _h, _j, _k
|
|
55997
|
+
var _f, _g, _h, _j, _k;
|
|
55659
55998
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
55660
|
-
const skipMethodSupportCheck = shouldSkipMethodSupportCheck(device.features, (_f = device.originalDescriptor) === null || _f === void 0 ? void 0 : _f.protocolType);
|
|
55661
55999
|
if (device.features) {
|
|
55662
56000
|
yield DataManager.checkAndReloadData();
|
|
55663
56001
|
if (findDefectiveBatchDevice(device.features)) {
|
|
@@ -55686,7 +56024,10 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55686
56024
|
}
|
|
55687
56025
|
throw hdShared.createNewFirmwareForceUpdateHardwareError(method.connectId, method.deviceId, requiredUpdates, currentVersions);
|
|
55688
56026
|
}
|
|
55689
|
-
if (
|
|
56027
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
56028
|
+
throw hdShared.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
56029
|
+
}
|
|
56030
|
+
if (versionRange) {
|
|
55690
56031
|
if (semver__default["default"].valid(versionRange.min) &&
|
|
55691
56032
|
semver__default["default"].lt(currentFirmwareVersion, versionRange.min)) {
|
|
55692
56033
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
@@ -55710,7 +56051,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55710
56051
|
return Promise.reject(hdShared.createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name));
|
|
55711
56052
|
}
|
|
55712
56053
|
}
|
|
55713
|
-
else if (
|
|
56054
|
+
else if (method.strictCheckDeviceSupport) {
|
|
55714
56055
|
throw hdShared.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
55715
56056
|
}
|
|
55716
56057
|
}
|
|
@@ -55743,7 +56084,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55743
56084
|
require: support.require,
|
|
55744
56085
|
}));
|
|
55745
56086
|
}
|
|
55746
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((
|
|
56087
|
+
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_f = method.payload) === null || _f === void 0 ? void 0 : _f.passphraseState, (_g = method.payload) === null || _g === void 0 ? void 0 : _g.useEmptyPassphrase, (_h = method.payload) === null || _h === void 0 ? void 0 : _h.skipPassphraseCheck);
|
|
55747
56088
|
checkPassphraseEnableState(method, device.features);
|
|
55748
56089
|
if (!passphraseStateSafety) {
|
|
55749
56090
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -55760,7 +56101,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55760
56101
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
55761
56102
|
throw error;
|
|
55762
56103
|
}
|
|
55763
|
-
(
|
|
56104
|
+
(_k = (_j = method.device) === null || _j === void 0 ? void 0 : _j.commands) === null || _k === void 0 ? void 0 : _k.checkDisposed();
|
|
55764
56105
|
try {
|
|
55765
56106
|
const response = yield method.run();
|
|
55766
56107
|
Log.debug('Call API - Inner Method Run: ');
|
|
@@ -55937,7 +56278,7 @@ const ensureConnected = (_context, method, pollingId, abortSignal) => __awaiter(
|
|
|
55937
56278
|
Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
|
|
55938
56279
|
const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55939
56280
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55940
|
-
var
|
|
56281
|
+
var _l;
|
|
55941
56282
|
const abort = () => {
|
|
55942
56283
|
if (abortSignal && abortSignal.aborted) {
|
|
55943
56284
|
if (timer) {
|
|
@@ -56042,7 +56383,7 @@ const ensureConnected = (_context, method, pollingId, abortSignal) => __awaiter(
|
|
|
56042
56383
|
clearTimeout(timer);
|
|
56043
56384
|
}
|
|
56044
56385
|
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
56045
|
-
if (DataManager.isBrowserWebUsb(env) && !((
|
|
56386
|
+
if (DataManager.isBrowserWebUsb(env) && !((_l = method.payload) === null || _l === void 0 ? void 0 : _l.skipWebDevicePrompt)) {
|
|
56046
56387
|
postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
|
|
56047
56388
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
|
|
56048
56389
|
}
|
|
@@ -56352,7 +56693,7 @@ const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0,
|
|
|
56352
56693
|
yield DataManager.load(settings);
|
|
56353
56694
|
initTransport(Transport, plugin);
|
|
56354
56695
|
}
|
|
56355
|
-
catch (
|
|
56696
|
+
catch (_m) {
|
|
56356
56697
|
Log.error('DataManager.load error');
|
|
56357
56698
|
}
|
|
56358
56699
|
enableLog(DataManager.getSettings('debug'));
|
|
@@ -56480,6 +56821,7 @@ exports.getTimeStamp = getTimeStamp;
|
|
|
56480
56821
|
exports.httpRequest = httpRequest;
|
|
56481
56822
|
exports.initCore = init;
|
|
56482
56823
|
exports.isBleConnect = isBleConnect;
|
|
56824
|
+
exports.isMethodVersionRangeUnsupported = isMethodVersionRangeUnsupported;
|
|
56483
56825
|
exports.isValidVersionArray = isValidVersionArray;
|
|
56484
56826
|
exports.isValidVersionString = isValidVersionString;
|
|
56485
56827
|
exports.normalizeVersionArray = normalizeVersionArray;
|
|
@@ -56489,7 +56831,6 @@ exports.patchFeatures = patchFeatures;
|
|
|
56489
56831
|
exports.preloadSessionCache = preloadSessionCache;
|
|
56490
56832
|
exports.safeThrowError = safeThrowError;
|
|
56491
56833
|
exports.setLoggerPostMessage = setLoggerPostMessage;
|
|
56492
|
-
exports.shouldSkipMethodSupportCheck = shouldSkipMethodSupportCheck;
|
|
56493
56834
|
exports.supportInputPinOnSoftware = supportInputPinOnSoftware;
|
|
56494
56835
|
exports.switchTransport = switchTransport;
|
|
56495
56836
|
exports.updateRequestContext = updateRequestContext;
|