@onekeyfe/hd-core 1.1.27-alpha.32 → 1.1.27-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/protocol-v2.test.ts +140 -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/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 +94 -4
- package/dist/index.js +404 -58
- 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/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/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/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',
|
|
@@ -45695,7 +45915,19 @@ class DeviceFirmwareUpdate extends BaseMethod {
|
|
|
45695
45915
|
const targets = normalizeFirmwareTargets(this.params);
|
|
45696
45916
|
const res = yield this.device.commands.typedCall('DeviceFirmwareUpdate', PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES, {
|
|
45697
45917
|
targets,
|
|
45698
|
-
}, PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS)
|
|
45918
|
+
}, Object.assign(Object.assign({}, PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS), { onIntermediateResponse: response => {
|
|
45919
|
+
var _a;
|
|
45920
|
+
if (response.type !== 'DeviceFirmwareInstallProgress')
|
|
45921
|
+
return;
|
|
45922
|
+
const progress = Number((_a = response.message) === null || _a === void 0 ? void 0 : _a.progress);
|
|
45923
|
+
if (!Number.isFinite(progress))
|
|
45924
|
+
return;
|
|
45925
|
+
this.postMessage(createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
|
|
45926
|
+
device: this.device.toMessageObject(),
|
|
45927
|
+
progress: Math.min(Math.max(progress, 0), 100),
|
|
45928
|
+
progressType: 'installingFirmware',
|
|
45929
|
+
}));
|
|
45930
|
+
} }));
|
|
45699
45931
|
return Promise.resolve(res.message);
|
|
45700
45932
|
});
|
|
45701
45933
|
}
|
|
@@ -45783,6 +46015,27 @@ class FilesystemFormat extends BaseMethod {
|
|
|
45783
46015
|
}
|
|
45784
46016
|
}
|
|
45785
46017
|
|
|
46018
|
+
class FilesystemDiskControl extends BaseMethod {
|
|
46019
|
+
init() {
|
|
46020
|
+
this.skipForceUpdateCheck = true;
|
|
46021
|
+
this.useDevicePassphraseState = false;
|
|
46022
|
+
this.params = {
|
|
46023
|
+
enable: validateNonNegativeInteger(this.payload.enable, 'enable', 0),
|
|
46024
|
+
timeoutMs: validateOptionalNonNegativeInteger(this.payload.timeoutMs, 'timeoutMs'),
|
|
46025
|
+
};
|
|
46026
|
+
}
|
|
46027
|
+
run() {
|
|
46028
|
+
var _a;
|
|
46029
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46030
|
+
const timeoutMs = Number(this.params.timeoutMs);
|
|
46031
|
+
const res = yield this.device.commands.typedCall('FilesystemDiskControl', 'Success', {
|
|
46032
|
+
enable: Number((_a = this.params.enable) !== null && _a !== void 0 ? _a : 0),
|
|
46033
|
+
}, Number.isFinite(timeoutMs) && timeoutMs > 0 ? { timeoutMs } : undefined);
|
|
46034
|
+
return Promise.resolve(res.message);
|
|
46035
|
+
});
|
|
46036
|
+
}
|
|
46037
|
+
}
|
|
46038
|
+
|
|
45786
46039
|
const MIN_FILE_READ_CHUNK_SIZE = 64;
|
|
45787
46040
|
function getProtocolV2FileReadChunkLimit() {
|
|
45788
46041
|
const env = DataManager.getSettings('env');
|
|
@@ -46494,12 +46747,11 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
46494
46747
|
}
|
|
46495
46748
|
}
|
|
46496
46749
|
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
46750
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
46502
46751
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
46752
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
46753
|
+
throw hdShared.ERRORS.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
46754
|
+
}
|
|
46503
46755
|
if (versionRange &&
|
|
46504
46756
|
semver__default["default"].valid(versionRange.min) &&
|
|
46505
46757
|
semver__default["default"].lt(currentVersion, versionRange.min)) {
|
|
@@ -46515,16 +46767,10 @@ function preCheckDeviceSupport(device, method) {
|
|
|
46515
46767
|
}
|
|
46516
46768
|
}
|
|
46517
46769
|
function handleSkippableHardwareError(e, device, method) {
|
|
46518
|
-
var _a, _b, _c, _d, _e, _f
|
|
46770
|
+
var _a, _b, _c, _d, _e, _f;
|
|
46519
46771
|
let error;
|
|
46520
|
-
const skipMethodSupportCheck = shouldSkipMethodSupportCheck(device.features, (_a = device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType);
|
|
46521
46772
|
if (e instanceof hdShared.HardwareError && e.errorCode !== hdShared.HardwareErrorCode.RuntimeError) {
|
|
46522
46773
|
const { errorCode } = e;
|
|
46523
|
-
if (skipMethodSupportCheck &&
|
|
46524
|
-
(errorCode === hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware ||
|
|
46525
|
-
errorCode === hdShared.HardwareErrorCode.DeviceNotSupportMethod)) {
|
|
46526
|
-
return undefined;
|
|
46527
|
-
}
|
|
46528
46774
|
if (errorCode === hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware) {
|
|
46529
46775
|
error = e;
|
|
46530
46776
|
}
|
|
@@ -46532,13 +46778,14 @@ function handleSkippableHardwareError(e, device, method) {
|
|
|
46532
46778
|
error = e;
|
|
46533
46779
|
}
|
|
46534
46780
|
}
|
|
46535
|
-
else if (((
|
|
46536
|
-
((
|
|
46537
|
-
if (skipMethodSupportCheck) {
|
|
46538
|
-
return undefined;
|
|
46539
|
-
}
|
|
46781
|
+
else if (((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes('Failure_UnexpectedMessage')) ||
|
|
46782
|
+
((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage'))) {
|
|
46540
46783
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
46541
46784
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
46785
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
46786
|
+
error = hdShared.ERRORS.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
46787
|
+
return error;
|
|
46788
|
+
}
|
|
46542
46789
|
if (versionRange &&
|
|
46543
46790
|
semver__default["default"].valid(versionRange.min) &&
|
|
46544
46791
|
semver__default["default"].lt(currentVersion, versionRange.min)) {
|
|
@@ -46553,8 +46800,8 @@ function handleSkippableHardwareError(e, device, method) {
|
|
|
46553
46800
|
error = hdShared.ERRORS.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
46554
46801
|
}
|
|
46555
46802
|
}
|
|
46556
|
-
else if (((
|
|
46557
|
-
((
|
|
46803
|
+
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')) ||
|
|
46804
|
+
((_f = (_e = e.message) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === null || _f === void 0 ? void 0 : _f.includes('invalid path'))) {
|
|
46558
46805
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, e.message);
|
|
46559
46806
|
}
|
|
46560
46807
|
return error;
|
|
@@ -46982,6 +47229,10 @@ function isCoinNameInList(coinName, coinNames) {
|
|
|
46982
47229
|
function getBitcoinForkVersionRange(params) {
|
|
46983
47230
|
if (isCoinNameInList('Neurai', params)) {
|
|
46984
47231
|
return {
|
|
47232
|
+
pro2: {
|
|
47233
|
+
min: '0.0.0',
|
|
47234
|
+
unsupported: true,
|
|
47235
|
+
},
|
|
46985
47236
|
model_mini: {
|
|
46986
47237
|
min: '3.7.0',
|
|
46987
47238
|
},
|
|
@@ -47067,14 +47318,13 @@ function splitArray(array, size) {
|
|
|
47067
47318
|
}
|
|
47068
47319
|
|
|
47069
47320
|
function batchGetPublickeys(device, paths, ecdsaCurveName, coinType, options) {
|
|
47070
|
-
var _a
|
|
47321
|
+
var _a;
|
|
47071
47322
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47072
47323
|
const existsPathNotValid = paths.find(p => p.address_n.length < 3);
|
|
47073
47324
|
if (existsPathNotValid) {
|
|
47074
47325
|
throw hdShared.TypedError(hdShared.HardwareErrorCode.ForbiddenKeyPath, 'Path length must be greater than 3');
|
|
47075
47326
|
}
|
|
47076
|
-
const supportsBatchPublicKey =
|
|
47077
|
-
supportBatchPublicKey(device.features, options);
|
|
47327
|
+
const supportsBatchPublicKey = supportBatchPublicKey(device.features, options);
|
|
47078
47328
|
if (!supportsBatchPublicKey) {
|
|
47079
47329
|
throw hdShared.createDeviceNotSupportMethodError('BatchGetPublickeys', getFirmwareType(device.features));
|
|
47080
47330
|
}
|
|
@@ -47099,7 +47349,7 @@ function batchGetPublickeys(device, paths, ecdsaCurveName, coinType, options) {
|
|
|
47099
47349
|
const res = yield device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
47100
47350
|
paths,
|
|
47101
47351
|
ecdsa_curve_name: ecdsaCurveName,
|
|
47102
|
-
include_node: (
|
|
47352
|
+
include_node: (_a = options === null || options === void 0 ? void 0 : options.includeNode) !== null && _a !== void 0 ? _a : false,
|
|
47103
47353
|
});
|
|
47104
47354
|
if (res.type !== 'EcdsaPublicKeys') {
|
|
47105
47355
|
throw hdShared.createDeviceNotSupportMethodError('BatchGetPublickeys', getFirmwareType(device.features));
|
|
@@ -48288,6 +48538,10 @@ class EVMSignMessageEIP712 extends BaseMethod {
|
|
|
48288
48538
|
}
|
|
48289
48539
|
getVersionRange() {
|
|
48290
48540
|
return {
|
|
48541
|
+
pro2: {
|
|
48542
|
+
min: '0.0.0',
|
|
48543
|
+
unsupported: true,
|
|
48544
|
+
},
|
|
48291
48545
|
model_mini: {
|
|
48292
48546
|
min: '2.1.9',
|
|
48293
48547
|
},
|
|
@@ -48298,6 +48552,9 @@ class EVMSignMessageEIP712 extends BaseMethod {
|
|
|
48298
48552
|
}
|
|
48299
48553
|
run() {
|
|
48300
48554
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48555
|
+
this.checkFeatureVersionLimit(() => true, () => this.getVersionRange(), {
|
|
48556
|
+
strictCheckDeviceSupport: true,
|
|
48557
|
+
});
|
|
48301
48558
|
const res = yield this.device.commands.typedCall('EthereumSignMessageEIP712', 'EthereumMessageSignature', Object.assign({}, this.params));
|
|
48302
48559
|
return Promise.resolve(res.message);
|
|
48303
48560
|
});
|
|
@@ -49877,6 +50134,14 @@ class StellarGetAddress extends BaseMethod {
|
|
|
49877
50134
|
});
|
|
49878
50135
|
});
|
|
49879
50136
|
}
|
|
50137
|
+
getVersionRange() {
|
|
50138
|
+
return {
|
|
50139
|
+
pro2: {
|
|
50140
|
+
min: '0.0.0',
|
|
50141
|
+
unsupported: true,
|
|
50142
|
+
},
|
|
50143
|
+
};
|
|
50144
|
+
}
|
|
49880
50145
|
run() {
|
|
49881
50146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49882
50147
|
const responses = [];
|
|
@@ -50110,6 +50375,14 @@ class StellarSignTransaction extends BaseMethod {
|
|
|
50110
50375
|
}
|
|
50111
50376
|
});
|
|
50112
50377
|
}
|
|
50378
|
+
getVersionRange() {
|
|
50379
|
+
return {
|
|
50380
|
+
pro2: {
|
|
50381
|
+
min: '0.0.0',
|
|
50382
|
+
unsupported: true,
|
|
50383
|
+
},
|
|
50384
|
+
};
|
|
50385
|
+
}
|
|
50113
50386
|
init() {
|
|
50114
50387
|
this.checkDeviceId = true;
|
|
50115
50388
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -51466,6 +51739,11 @@ class SuiSignTransaction extends BaseMethod {
|
|
|
51466
51739
|
};
|
|
51467
51740
|
}
|
|
51468
51741
|
supportChunkTransfer() {
|
|
51742
|
+
var _a;
|
|
51743
|
+
if (((_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType) === 'V2' ||
|
|
51744
|
+
getDeviceType(this.device.features) === hdShared.EDeviceType.Pro2) {
|
|
51745
|
+
return true;
|
|
51746
|
+
}
|
|
51469
51747
|
const deviceType = getDeviceType(this.device.features);
|
|
51470
51748
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
51471
51749
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
@@ -51484,7 +51762,7 @@ class SuiSignTransaction extends BaseMethod {
|
|
|
51484
51762
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51485
51763
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
51486
51764
|
let offset = 0;
|
|
51487
|
-
let data;
|
|
51765
|
+
let data = Buffer.alloc(0);
|
|
51488
51766
|
if (this.supportChunkTransfer()) {
|
|
51489
51767
|
offset = this.chunkByteSize;
|
|
51490
51768
|
data = Buffer.from(this.params.raw_tx, 'hex');
|
|
@@ -53317,6 +53595,10 @@ class NexaGetAddress extends BaseMethod {
|
|
|
53317
53595
|
}
|
|
53318
53596
|
getVersionRange() {
|
|
53319
53597
|
return {
|
|
53598
|
+
pro2: {
|
|
53599
|
+
min: '0.0.0',
|
|
53600
|
+
unsupported: true,
|
|
53601
|
+
},
|
|
53320
53602
|
model_mini: {
|
|
53321
53603
|
min: '3.2.0',
|
|
53322
53604
|
},
|
|
@@ -53367,6 +53649,10 @@ class NexaSignTransaction extends BaseMethod {
|
|
|
53367
53649
|
}
|
|
53368
53650
|
getVersionRange() {
|
|
53369
53651
|
return {
|
|
53652
|
+
pro2: {
|
|
53653
|
+
min: '0.0.0',
|
|
53654
|
+
unsupported: true,
|
|
53655
|
+
},
|
|
53370
53656
|
model_mini: {
|
|
53371
53657
|
min: '3.2.0',
|
|
53372
53658
|
},
|
|
@@ -53748,6 +54034,10 @@ class NervosGetAddress extends BaseMethod {
|
|
|
53748
54034
|
}
|
|
53749
54035
|
getVersionRange() {
|
|
53750
54036
|
return {
|
|
54037
|
+
pro2: {
|
|
54038
|
+
min: '0.0.0',
|
|
54039
|
+
unsupported: true,
|
|
54040
|
+
},
|
|
53751
54041
|
model_mini: {
|
|
53752
54042
|
min: '3.7.0',
|
|
53753
54043
|
},
|
|
@@ -53827,6 +54117,10 @@ class NervosSignTransaction extends BaseMethod {
|
|
|
53827
54117
|
}
|
|
53828
54118
|
getVersionRange() {
|
|
53829
54119
|
return {
|
|
54120
|
+
pro2: {
|
|
54121
|
+
min: '0.0.0',
|
|
54122
|
+
unsupported: true,
|
|
54123
|
+
},
|
|
53830
54124
|
model_mini: {
|
|
53831
54125
|
min: '3.7.0',
|
|
53832
54126
|
},
|
|
@@ -54366,6 +54660,10 @@ class ScdoGetAddress extends BaseMethod {
|
|
|
54366
54660
|
}
|
|
54367
54661
|
getVersionRange() {
|
|
54368
54662
|
return {
|
|
54663
|
+
pro2: {
|
|
54664
|
+
min: '0.0.0',
|
|
54665
|
+
unsupported: true,
|
|
54666
|
+
},
|
|
54369
54667
|
model_touch: {
|
|
54370
54668
|
min: '4.10.0',
|
|
54371
54669
|
},
|
|
@@ -54441,6 +54739,10 @@ class ScdoSignTransaction extends BaseMethod {
|
|
|
54441
54739
|
}
|
|
54442
54740
|
getVersionRange() {
|
|
54443
54741
|
return {
|
|
54742
|
+
pro2: {
|
|
54743
|
+
min: '0.0.0',
|
|
54744
|
+
unsupported: true,
|
|
54745
|
+
},
|
|
54444
54746
|
model_touch: {
|
|
54445
54747
|
min: '4.10.0',
|
|
54446
54748
|
},
|
|
@@ -54480,6 +54782,10 @@ class ScdoSignMessage extends BaseMethod {
|
|
|
54480
54782
|
}
|
|
54481
54783
|
getVersionRange() {
|
|
54482
54784
|
return {
|
|
54785
|
+
pro2: {
|
|
54786
|
+
min: '0.0.0',
|
|
54787
|
+
unsupported: true,
|
|
54788
|
+
},
|
|
54483
54789
|
model_touch: {
|
|
54484
54790
|
min: '4.10.0',
|
|
54485
54791
|
},
|
|
@@ -54521,6 +54827,10 @@ class AlephiumGetAddress extends BaseMethod {
|
|
|
54521
54827
|
}
|
|
54522
54828
|
getVersionRange() {
|
|
54523
54829
|
return {
|
|
54830
|
+
pro2: {
|
|
54831
|
+
min: '0.0.0',
|
|
54832
|
+
unsupported: true,
|
|
54833
|
+
},
|
|
54524
54834
|
model_touch: {
|
|
54525
54835
|
min: '4.10.0',
|
|
54526
54836
|
},
|
|
@@ -54604,6 +54914,10 @@ class AlephiumSignTransaction extends BaseMethod {
|
|
|
54604
54914
|
}
|
|
54605
54915
|
getVersionRange() {
|
|
54606
54916
|
return {
|
|
54917
|
+
pro2: {
|
|
54918
|
+
min: '0.0.0',
|
|
54919
|
+
unsupported: true,
|
|
54920
|
+
},
|
|
54607
54921
|
model_touch: {
|
|
54608
54922
|
min: '4.10.0',
|
|
54609
54923
|
},
|
|
@@ -54645,6 +54959,10 @@ class AlephiumSignMessage extends BaseMethod {
|
|
|
54645
54959
|
}
|
|
54646
54960
|
getVersionRange() {
|
|
54647
54961
|
return {
|
|
54962
|
+
pro2: {
|
|
54963
|
+
min: '0.0.0',
|
|
54964
|
+
unsupported: true,
|
|
54965
|
+
},
|
|
54648
54966
|
model_touch: {
|
|
54649
54967
|
min: '4.10.0',
|
|
54650
54968
|
},
|
|
@@ -54720,6 +55038,10 @@ class BenfenGetAddress extends BaseMethod {
|
|
|
54720
55038
|
}
|
|
54721
55039
|
getVersionRange() {
|
|
54722
55040
|
return {
|
|
55041
|
+
pro2: {
|
|
55042
|
+
min: '0.0.0',
|
|
55043
|
+
unsupported: true,
|
|
55044
|
+
},
|
|
54723
55045
|
pro: {
|
|
54724
55046
|
min: '4.12.0',
|
|
54725
55047
|
},
|
|
@@ -54808,6 +55130,10 @@ class BenfenGetPublicKey extends BaseMethod {
|
|
|
54808
55130
|
}
|
|
54809
55131
|
getVersionRange() {
|
|
54810
55132
|
return {
|
|
55133
|
+
pro2: {
|
|
55134
|
+
min: '0.0.0',
|
|
55135
|
+
unsupported: true,
|
|
55136
|
+
},
|
|
54811
55137
|
pro: {
|
|
54812
55138
|
min: '4.12.0',
|
|
54813
55139
|
},
|
|
@@ -54848,6 +55174,10 @@ class BenfenSignMessage extends BaseMethod {
|
|
|
54848
55174
|
}
|
|
54849
55175
|
getVersionRange() {
|
|
54850
55176
|
return {
|
|
55177
|
+
pro2: {
|
|
55178
|
+
min: '0.0.0',
|
|
55179
|
+
unsupported: true,
|
|
55180
|
+
},
|
|
54851
55181
|
pro: {
|
|
54852
55182
|
min: '4.12.0',
|
|
54853
55183
|
},
|
|
@@ -54901,6 +55231,10 @@ class BenfenSignTransaction extends BaseMethod {
|
|
|
54901
55231
|
}
|
|
54902
55232
|
getVersionRange() {
|
|
54903
55233
|
return {
|
|
55234
|
+
pro2: {
|
|
55235
|
+
min: '0.0.0',
|
|
55236
|
+
unsupported: true,
|
|
55237
|
+
},
|
|
54904
55238
|
pro: {
|
|
54905
55239
|
min: '4.12.0',
|
|
54906
55240
|
},
|
|
@@ -54957,6 +55291,10 @@ class NeoGetAddress extends BaseMethod {
|
|
|
54957
55291
|
}
|
|
54958
55292
|
getVersionRange() {
|
|
54959
55293
|
return {
|
|
55294
|
+
pro2: {
|
|
55295
|
+
min: '0.0.0',
|
|
55296
|
+
unsupported: true,
|
|
55297
|
+
},
|
|
54960
55298
|
pro: {
|
|
54961
55299
|
min: '4.12.0',
|
|
54962
55300
|
},
|
|
@@ -55011,6 +55349,10 @@ class NeoSignTransaction extends BaseMethod {
|
|
|
55011
55349
|
}
|
|
55012
55350
|
getVersionRange() {
|
|
55013
55351
|
return {
|
|
55352
|
+
pro2: {
|
|
55353
|
+
min: '0.0.0',
|
|
55354
|
+
unsupported: true,
|
|
55355
|
+
},
|
|
55014
55356
|
pro: {
|
|
55015
55357
|
min: '4.12.0',
|
|
55016
55358
|
},
|
|
@@ -55041,6 +55383,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
55041
55383
|
testInitializeDeviceDuration: TestInitializeDeviceDuration,
|
|
55042
55384
|
searchDevices: SearchDevices,
|
|
55043
55385
|
getFeatures: GetFeatures,
|
|
55386
|
+
getDeviceInfo: GetDeviceInfo,
|
|
55044
55387
|
getOnekeyFeatures: GetOnekeyFeatures,
|
|
55045
55388
|
getPassphraseState: GetPassphraseState,
|
|
55046
55389
|
getLogs: GetLogs,
|
|
@@ -55087,6 +55430,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
55087
55430
|
factoryGetDeviceInfo: FactoryGetDeviceInfo,
|
|
55088
55431
|
filesystemFixPermission: FilesystemFixPermission,
|
|
55089
55432
|
filesystemFormat: FilesystemFormat,
|
|
55433
|
+
filesystemDiskControl: FilesystemDiskControl,
|
|
55090
55434
|
fileRead: FileRead,
|
|
55091
55435
|
fileWrite: FileWrite,
|
|
55092
55436
|
fileDelete: FileDelete,
|
|
@@ -55655,9 +55999,8 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55655
55999
|
}
|
|
55656
56000
|
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
55657
56001
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55658
|
-
var _f, _g, _h, _j, _k
|
|
56002
|
+
var _f, _g, _h, _j, _k;
|
|
55659
56003
|
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
56004
|
if (device.features) {
|
|
55662
56005
|
yield DataManager.checkAndReloadData();
|
|
55663
56006
|
if (findDefectiveBatchDevice(device.features)) {
|
|
@@ -55686,7 +56029,10 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55686
56029
|
}
|
|
55687
56030
|
throw hdShared.createNewFirmwareForceUpdateHardwareError(method.connectId, method.deviceId, requiredUpdates, currentVersions);
|
|
55688
56031
|
}
|
|
55689
|
-
if (
|
|
56032
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
56033
|
+
throw hdShared.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
56034
|
+
}
|
|
56035
|
+
if (versionRange) {
|
|
55690
56036
|
if (semver__default["default"].valid(versionRange.min) &&
|
|
55691
56037
|
semver__default["default"].lt(currentFirmwareVersion, versionRange.min)) {
|
|
55692
56038
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
@@ -55710,7 +56056,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55710
56056
|
return Promise.reject(hdShared.createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name));
|
|
55711
56057
|
}
|
|
55712
56058
|
}
|
|
55713
|
-
else if (
|
|
56059
|
+
else if (method.strictCheckDeviceSupport) {
|
|
55714
56060
|
throw hdShared.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
55715
56061
|
}
|
|
55716
56062
|
}
|
|
@@ -55743,7 +56089,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55743
56089
|
require: support.require,
|
|
55744
56090
|
}));
|
|
55745
56091
|
}
|
|
55746
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((
|
|
56092
|
+
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
56093
|
checkPassphraseEnableState(method, device.features);
|
|
55748
56094
|
if (!passphraseStateSafety) {
|
|
55749
56095
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -55760,7 +56106,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55760
56106
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
55761
56107
|
throw error;
|
|
55762
56108
|
}
|
|
55763
|
-
(
|
|
56109
|
+
(_k = (_j = method.device) === null || _j === void 0 ? void 0 : _j.commands) === null || _k === void 0 ? void 0 : _k.checkDisposed();
|
|
55764
56110
|
try {
|
|
55765
56111
|
const response = yield method.run();
|
|
55766
56112
|
Log.debug('Call API - Inner Method Run: ');
|
|
@@ -55937,7 +56283,7 @@ const ensureConnected = (_context, method, pollingId, abortSignal) => __awaiter(
|
|
|
55937
56283
|
Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
|
|
55938
56284
|
const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55939
56285
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55940
|
-
var
|
|
56286
|
+
var _l;
|
|
55941
56287
|
const abort = () => {
|
|
55942
56288
|
if (abortSignal && abortSignal.aborted) {
|
|
55943
56289
|
if (timer) {
|
|
@@ -56042,7 +56388,7 @@ const ensureConnected = (_context, method, pollingId, abortSignal) => __awaiter(
|
|
|
56042
56388
|
clearTimeout(timer);
|
|
56043
56389
|
}
|
|
56044
56390
|
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
56045
|
-
if (DataManager.isBrowserWebUsb(env) && !((
|
|
56391
|
+
if (DataManager.isBrowserWebUsb(env) && !((_l = method.payload) === null || _l === void 0 ? void 0 : _l.skipWebDevicePrompt)) {
|
|
56046
56392
|
postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
|
|
56047
56393
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
|
|
56048
56394
|
}
|
|
@@ -56352,7 +56698,7 @@ const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0,
|
|
|
56352
56698
|
yield DataManager.load(settings);
|
|
56353
56699
|
initTransport(Transport, plugin);
|
|
56354
56700
|
}
|
|
56355
|
-
catch (
|
|
56701
|
+
catch (_m) {
|
|
56356
56702
|
Log.error('DataManager.load error');
|
|
56357
56703
|
}
|
|
56358
56704
|
enableLog(DataManager.getSettings('debug'));
|
|
@@ -56480,6 +56826,7 @@ exports.getTimeStamp = getTimeStamp;
|
|
|
56480
56826
|
exports.httpRequest = httpRequest;
|
|
56481
56827
|
exports.initCore = init;
|
|
56482
56828
|
exports.isBleConnect = isBleConnect;
|
|
56829
|
+
exports.isMethodVersionRangeUnsupported = isMethodVersionRangeUnsupported;
|
|
56483
56830
|
exports.isValidVersionArray = isValidVersionArray;
|
|
56484
56831
|
exports.isValidVersionString = isValidVersionString;
|
|
56485
56832
|
exports.normalizeVersionArray = normalizeVersionArray;
|
|
@@ -56489,7 +56836,6 @@ exports.patchFeatures = patchFeatures;
|
|
|
56489
56836
|
exports.preloadSessionCache = preloadSessionCache;
|
|
56490
56837
|
exports.safeThrowError = safeThrowError;
|
|
56491
56838
|
exports.setLoggerPostMessage = setLoggerPostMessage;
|
|
56492
|
-
exports.shouldSkipMethodSupportCheck = shouldSkipMethodSupportCheck;
|
|
56493
56839
|
exports.supportInputPinOnSoftware = supportInputPinOnSoftware;
|
|
56494
56840
|
exports.switchTransport = switchTransport;
|
|
56495
56841
|
exports.updateRequestContext = updateRequestContext;
|