@onekeyfe/hd-core 1.1.18 → 1.1.19-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/BaseMethod.d.ts +9 -4
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +3 -2
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +2 -2
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +2 -2
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +6 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +6 -3
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/releaseHelper.d.ts +7 -2
- package/dist/api/firmware/releaseHelper.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +7 -2
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +4 -4
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +16 -9
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +5 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +6 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/device.d.ts +2 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/index.d.ts +96 -28
- package/dist/index.js +543 -132
- package/dist/types/api/checkAllFirmwareRelease.d.ts +5 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBootloaderRelease.d.ts +5 -2
- package/dist/types/api/checkBootloaderRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareRelease.d.ts +6 -2
- package/dist/types/api/checkFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceFullyUploadResource.d.ts +6 -1
- package/dist/types/api/deviceFullyUploadResource.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -3
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +3 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +128 -128
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/device.d.ts +4 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/settings.d.ts +3 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +7 -5
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- 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/dist/utils/release.d.ts +1 -1
- package/dist/utils/release.d.ts.map +1 -1
- package/dist/utils/tracing.d.ts +34 -0
- package/dist/utils/tracing.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +55 -8
- package/src/api/CheckAllFirmwareRelease.ts +14 -6
- package/src/api/CheckBootloaderRelease.ts +13 -2
- package/src/api/CheckFirmwareRelease.ts +9 -2
- package/src/api/FirmwareUpdate.ts +7 -5
- package/src/api/FirmwareUpdateV2.ts +26 -14
- package/src/api/FirmwareUpdateV3.ts +31 -18
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +56 -26
- package/src/api/device/DeviceFullyUploadResource.ts +8 -2
- package/src/api/device/DeviceUpdateBootloader.ts +21 -5
- package/src/api/firmware/getBinary.ts +15 -4
- package/src/api/firmware/releaseHelper.ts +22 -11
- package/src/api/firmware/updateBootloader.ts +17 -9
- package/src/api/firmware/uploadFirmware.ts +51 -15
- package/src/api/sui/SuiSignTransaction.ts +7 -1
- package/src/core/index.ts +111 -8
- package/src/data/messages/messages.json +11 -1
- package/src/data-manager/DataManager.ts +126 -22
- package/src/device/Device.ts +24 -3
- package/src/device/DeviceCommands.ts +42 -8
- package/src/events/device.ts +2 -2
- package/src/types/api/checkAllFirmwareRelease.ts +5 -1
- package/src/types/api/checkBootloaderRelease.ts +7 -3
- package/src/types/api/checkFirmwareRelease.ts +10 -2
- package/src/types/api/deviceFullyUploadResource.ts +7 -1
- package/src/types/api/deviceUpdateBootloader.ts +8 -4
- package/src/types/api/firmwareUpdate.ts +4 -1
- package/src/types/api/index.ts +128 -161
- package/src/types/device.ts +7 -1
- package/src/types/settings.ts +37 -0
- package/src/utils/deviceFeaturesUtils.ts +22 -10
- package/src/utils/index.ts +1 -0
- package/src/utils/release.ts +2 -1
- package/src/utils/tracing.ts +251 -0
package/dist/index.js
CHANGED
|
@@ -787,7 +787,7 @@ const createLogMessage = (type, payload) => ({
|
|
|
787
787
|
|
|
788
788
|
const MAX_ENTRIES = 500;
|
|
789
789
|
let postMessage$1;
|
|
790
|
-
class Log$
|
|
790
|
+
class Log$f {
|
|
791
791
|
constructor(prefix, enabled) {
|
|
792
792
|
this.prefix = prefix;
|
|
793
793
|
this.enabled = enabled;
|
|
@@ -839,7 +839,7 @@ class Log$e {
|
|
|
839
839
|
}
|
|
840
840
|
const _logs = {};
|
|
841
841
|
const initLog = (prefix, enabled) => {
|
|
842
|
-
const instance = new Log$
|
|
842
|
+
const instance = new Log$f(prefix, !!enabled);
|
|
843
843
|
_logs[prefix] = instance;
|
|
844
844
|
return instance;
|
|
845
845
|
};
|
|
@@ -1035,6 +1035,108 @@ function patchFeatures(response) {
|
|
|
1035
1035
|
return response;
|
|
1036
1036
|
}
|
|
1037
1037
|
|
|
1038
|
+
const Log$e = getLogger(exports.LoggerNames.Core);
|
|
1039
|
+
let globalInstanceCounter = 0;
|
|
1040
|
+
let sdkInstanceCounter = 0;
|
|
1041
|
+
function generateSdkInstanceId() {
|
|
1042
|
+
sdkInstanceCounter++;
|
|
1043
|
+
const timestamp = Date.now().toString().slice(-6);
|
|
1044
|
+
return `SDK-${sdkInstanceCounter}-${timestamp}`;
|
|
1045
|
+
}
|
|
1046
|
+
function generateInstanceId(type, sdkInstanceId) {
|
|
1047
|
+
globalInstanceCounter++;
|
|
1048
|
+
const timestamp = Date.now().toString().slice(-6);
|
|
1049
|
+
const baseId = `${type}-${globalInstanceCounter}-${timestamp}`;
|
|
1050
|
+
return sdkInstanceId ? `${sdkInstanceId}.${baseId}` : baseId;
|
|
1051
|
+
}
|
|
1052
|
+
const sdkInstances = new Map();
|
|
1053
|
+
const globalActiveRequests = new Map();
|
|
1054
|
+
function createSdkTracingContext() {
|
|
1055
|
+
const sdkInstanceId = generateSdkInstanceId();
|
|
1056
|
+
const context = {
|
|
1057
|
+
sdkInstanceId,
|
|
1058
|
+
createdAt: Date.now(),
|
|
1059
|
+
activeRequests: new Map(),
|
|
1060
|
+
};
|
|
1061
|
+
sdkInstances.set(sdkInstanceId, context);
|
|
1062
|
+
return context;
|
|
1063
|
+
}
|
|
1064
|
+
function createRequestContext(responseID, methodName, options) {
|
|
1065
|
+
const context = {
|
|
1066
|
+
responseID,
|
|
1067
|
+
sdkInstanceId: options === null || options === void 0 ? void 0 : options.sdkInstanceId,
|
|
1068
|
+
methodName,
|
|
1069
|
+
connectId: options === null || options === void 0 ? void 0 : options.connectId,
|
|
1070
|
+
deviceInstanceId: options === null || options === void 0 ? void 0 : options.deviceInstanceId,
|
|
1071
|
+
commandsInstanceId: options === null || options === void 0 ? void 0 : options.commandsInstanceId,
|
|
1072
|
+
parentResponseID: options === null || options === void 0 ? void 0 : options.parentResponseID,
|
|
1073
|
+
startTime: Date.now(),
|
|
1074
|
+
status: 'pending',
|
|
1075
|
+
};
|
|
1076
|
+
globalActiveRequests.set(context.responseID, context);
|
|
1077
|
+
if (options === null || options === void 0 ? void 0 : options.sdkInstanceId) {
|
|
1078
|
+
const sdkContext = sdkInstances.get(options.sdkInstanceId);
|
|
1079
|
+
if (sdkContext) {
|
|
1080
|
+
sdkContext.activeRequests.set(context.responseID, context);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
return context;
|
|
1084
|
+
}
|
|
1085
|
+
function updateRequestContext(responseID, updates) {
|
|
1086
|
+
const context = globalActiveRequests.get(responseID);
|
|
1087
|
+
if (context) {
|
|
1088
|
+
Object.assign(context, updates);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
function completeRequestContext(responseID, error) {
|
|
1092
|
+
const context = globalActiveRequests.get(responseID);
|
|
1093
|
+
if (context) {
|
|
1094
|
+
context.endTime = Date.now();
|
|
1095
|
+
context.status = error ? 'error' : 'success';
|
|
1096
|
+
if (error) {
|
|
1097
|
+
context.error = error.message;
|
|
1098
|
+
Log$e.error(`[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`);
|
|
1099
|
+
}
|
|
1100
|
+
globalActiveRequests.delete(responseID);
|
|
1101
|
+
if (context.sdkInstanceId) {
|
|
1102
|
+
const sdkContext = sdkInstances.get(context.sdkInstanceId);
|
|
1103
|
+
if (sdkContext) {
|
|
1104
|
+
sdkContext.activeRequests.delete(responseID);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
function getActiveRequestsByDeviceInstance(deviceInstanceId) {
|
|
1110
|
+
return Array.from(globalActiveRequests.values()).filter(ctx => ctx.deviceInstanceId === deviceInstanceId);
|
|
1111
|
+
}
|
|
1112
|
+
function formatRequestContext(context) {
|
|
1113
|
+
const duration = context.endTime
|
|
1114
|
+
? context.endTime - context.startTime
|
|
1115
|
+
: Date.now() - context.startTime;
|
|
1116
|
+
const parts = [
|
|
1117
|
+
`[req:${context.responseID}]`,
|
|
1118
|
+
context.sdkInstanceId ? `sdk=${context.sdkInstanceId}` : null,
|
|
1119
|
+
`method=${context.methodName}`,
|
|
1120
|
+
context.connectId ? `connectId=${context.connectId}` : null,
|
|
1121
|
+
context.deviceInstanceId ? `deviceInst=${context.deviceInstanceId}` : null,
|
|
1122
|
+
context.commandsInstanceId ? `commandsInst=${context.commandsInstanceId}` : null,
|
|
1123
|
+
context.parentResponseID ? `parent=${context.parentResponseID}` : null,
|
|
1124
|
+
`duration=${duration}ms`,
|
|
1125
|
+
`status=${context.status}`,
|
|
1126
|
+
`error=${context.error}`,
|
|
1127
|
+
].filter(Boolean);
|
|
1128
|
+
return parts.join(' ');
|
|
1129
|
+
}
|
|
1130
|
+
function cleanupSdkInstance(sdkInstanceId) {
|
|
1131
|
+
const sdkContext = sdkInstances.get(sdkInstanceId);
|
|
1132
|
+
if (sdkContext) {
|
|
1133
|
+
for (const responseID of sdkContext.activeRequests.keys()) {
|
|
1134
|
+
globalActiveRequests.delete(responseID);
|
|
1135
|
+
}
|
|
1136
|
+
sdkInstances.delete(sdkInstanceId);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1038
1140
|
exports.EOneKeyDeviceMode = void 0;
|
|
1039
1141
|
(function (EOneKeyDeviceMode) {
|
|
1040
1142
|
EOneKeyDeviceMode["bootloader"] = "bootloader";
|
|
@@ -3351,6 +3453,15 @@ var nested$1 = {
|
|
|
3351
3453
|
}
|
|
3352
3454
|
}
|
|
3353
3455
|
},
|
|
3456
|
+
UpgradeFileHeader: {
|
|
3457
|
+
fields: {
|
|
3458
|
+
data: {
|
|
3459
|
+
rule: "required",
|
|
3460
|
+
type: "bytes",
|
|
3461
|
+
id: 1
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
},
|
|
3354
3465
|
CardanoDerivationType: {
|
|
3355
3466
|
values: {
|
|
3356
3467
|
LEDGER: 0,
|
|
@@ -13795,7 +13906,8 @@ var nested$1 = {
|
|
|
13795
13906
|
MessageType_GetPassphraseState: 10028,
|
|
13796
13907
|
MessageType_PassphraseState: 10029,
|
|
13797
13908
|
MessageType_UnLockDevice: 10030,
|
|
13798
|
-
MessageType_UnLockDeviceResponse: 10031
|
|
13909
|
+
MessageType_UnLockDeviceResponse: 10031,
|
|
13910
|
+
MessageType_UpgradeFileHeader: 10050
|
|
13799
13911
|
}
|
|
13800
13912
|
},
|
|
13801
13913
|
google: {
|
|
@@ -24930,7 +25042,54 @@ const findLatestRelease = (releases) => {
|
|
|
24930
25042
|
};
|
|
24931
25043
|
|
|
24932
25044
|
var _a$1;
|
|
25045
|
+
const FIRMWARE_FIELDS = [
|
|
25046
|
+
'firmware',
|
|
25047
|
+
'firmware-v2',
|
|
25048
|
+
'firmware-v7',
|
|
25049
|
+
'firmware-btc-v7',
|
|
25050
|
+
];
|
|
25051
|
+
const FIRMWARE_FIELD_TYPE_MAP = {
|
|
25052
|
+
firmware: hdShared.EFirmwareType.Universal,
|
|
25053
|
+
'firmware-v2': hdShared.EFirmwareType.Universal,
|
|
25054
|
+
'firmware-v7': hdShared.EFirmwareType.Universal,
|
|
25055
|
+
'firmware-btc-v7': hdShared.EFirmwareType.BitcoinOnly,
|
|
25056
|
+
};
|
|
25057
|
+
function getFirmwareTypeFromField(firmwareField) {
|
|
25058
|
+
const firmwareType = FIRMWARE_FIELD_TYPE_MAP[firmwareField];
|
|
25059
|
+
if (firmwareType === undefined) {
|
|
25060
|
+
return hdShared.EFirmwareType.Universal;
|
|
25061
|
+
}
|
|
25062
|
+
return firmwareType;
|
|
25063
|
+
}
|
|
24933
25064
|
class DataManager {
|
|
25065
|
+
static enrichFirmwareReleaseInfo(deviceData) {
|
|
25066
|
+
if (!deviceData || typeof deviceData !== 'object') {
|
|
25067
|
+
return {
|
|
25068
|
+
firmware: [],
|
|
25069
|
+
ble: [],
|
|
25070
|
+
};
|
|
25071
|
+
}
|
|
25072
|
+
const enrichedData = Object.assign({}, deviceData);
|
|
25073
|
+
FIRMWARE_FIELDS.forEach(field => {
|
|
25074
|
+
const releases = enrichedData[field];
|
|
25075
|
+
if (!releases || !Array.isArray(releases) || releases.length === 0) {
|
|
25076
|
+
return;
|
|
25077
|
+
}
|
|
25078
|
+
try {
|
|
25079
|
+
enrichedData[field] = releases.map(release => {
|
|
25080
|
+
if (!release || typeof release !== 'object' || !!release.firmwareType) {
|
|
25081
|
+
return release;
|
|
25082
|
+
}
|
|
25083
|
+
const firmwareType = getFirmwareTypeFromField(field);
|
|
25084
|
+
return Object.assign(Object.assign({}, release), { firmwareType });
|
|
25085
|
+
});
|
|
25086
|
+
}
|
|
25087
|
+
catch (error) {
|
|
25088
|
+
console.error(`Error enriching firmware field "${field}":`, error);
|
|
25089
|
+
}
|
|
25090
|
+
});
|
|
25091
|
+
return enrichedData;
|
|
25092
|
+
}
|
|
24934
25093
|
static load(settings) {
|
|
24935
25094
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24936
25095
|
this.settings = settings;
|
|
@@ -24945,12 +25104,12 @@ class DataManager {
|
|
|
24945
25104
|
timeout: 7000,
|
|
24946
25105
|
});
|
|
24947
25106
|
this.deviceMap = {
|
|
24948
|
-
[hdShared.EDeviceType.Classic]: data.classic,
|
|
24949
|
-
[hdShared.EDeviceType.Classic1s]: data.classic1s,
|
|
24950
|
-
[hdShared.EDeviceType.ClassicPure]: data.classicpure,
|
|
24951
|
-
[hdShared.EDeviceType.Mini]: data.mini,
|
|
24952
|
-
[hdShared.EDeviceType.Touch]: data.touch,
|
|
24953
|
-
[hdShared.EDeviceType.Pro]: data.pro,
|
|
25107
|
+
[hdShared.EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
25108
|
+
[hdShared.EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
|
|
25109
|
+
[hdShared.EDeviceType.ClassicPure]: this.enrichFirmwareReleaseInfo(data.classicpure),
|
|
25110
|
+
[hdShared.EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
|
|
25111
|
+
[hdShared.EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
|
|
25112
|
+
[hdShared.EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
|
|
24954
25113
|
};
|
|
24955
25114
|
this.assets = {
|
|
24956
25115
|
bridge: data.bridge,
|
|
@@ -25021,11 +25180,12 @@ DataManager.messages = {
|
|
|
25021
25180
|
v1: MessagesLegacyV1JSON,
|
|
25022
25181
|
};
|
|
25023
25182
|
DataManager.lastCheckTimestamp = 0;
|
|
25024
|
-
DataManager.getFirmwareStatus = (features) => {
|
|
25183
|
+
DataManager.getFirmwareStatus = (features, firmwareType) => {
|
|
25025
25184
|
var _b, _c;
|
|
25026
25185
|
const deviceType = getDeviceType(features);
|
|
25027
25186
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
25028
25187
|
return 'unknown';
|
|
25188
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
25029
25189
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
25030
25190
|
if (features.firmware_present === false) {
|
|
25031
25191
|
return 'none';
|
|
@@ -25033,12 +25193,19 @@ DataManager.getFirmwareStatus = (features) => {
|
|
|
25033
25193
|
if (DeviceModelToTypes.model_mini.includes(deviceType) && features.bootloader_mode) {
|
|
25034
25194
|
return 'unknown';
|
|
25035
25195
|
}
|
|
25036
|
-
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25196
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25197
|
+
features,
|
|
25198
|
+
updateType: 'firmware',
|
|
25199
|
+
firmwareType,
|
|
25200
|
+
});
|
|
25037
25201
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25038
|
-
|
|
25202
|
+
let currentVersion = deviceFirmwareVersion.join('.');
|
|
25203
|
+
if (targetDeviceConfigList.length > 0 && deviceFirmwareType !== firmwareType) {
|
|
25204
|
+
currentVersion = '0.0.0';
|
|
25205
|
+
}
|
|
25039
25206
|
return getReleaseStatus(targetDeviceConfigList, currentVersion);
|
|
25040
25207
|
};
|
|
25041
|
-
DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
|
|
25208
|
+
DataManager.getSysResourcesLatestRelease = ({ features, forcedUpdateRes, firmwareType, }) => {
|
|
25042
25209
|
var _b, _c, _d;
|
|
25043
25210
|
const deviceType = getDeviceType(features);
|
|
25044
25211
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
@@ -25047,6 +25214,7 @@ DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
|
|
|
25047
25214
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25048
25215
|
features,
|
|
25049
25216
|
updateType: 'firmware',
|
|
25217
|
+
firmwareType,
|
|
25050
25218
|
});
|
|
25051
25219
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25052
25220
|
const currentVersion = deviceFirmwareVersion.join('.');
|
|
@@ -25055,7 +25223,7 @@ DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
|
|
|
25055
25223
|
: semver__default["default"].gt(item.version.join('.'), currentVersion) && !!item.resource);
|
|
25056
25224
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.resource;
|
|
25057
25225
|
};
|
|
25058
|
-
DataManager.getSysFullResource = (features) => {
|
|
25226
|
+
DataManager.getSysFullResource = (features, firmwareType) => {
|
|
25059
25227
|
var _b, _c, _d;
|
|
25060
25228
|
const deviceType = getDeviceType(features);
|
|
25061
25229
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25065,12 +25233,13 @@ DataManager.getSysFullResource = (features) => {
|
|
|
25065
25233
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25066
25234
|
features,
|
|
25067
25235
|
updateType: 'firmware',
|
|
25236
|
+
firmwareType,
|
|
25068
25237
|
});
|
|
25069
25238
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25070
25239
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.fullResource);
|
|
25071
25240
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.fullResource;
|
|
25072
25241
|
};
|
|
25073
|
-
DataManager.getBootloaderResource = (features) => {
|
|
25242
|
+
DataManager.getBootloaderResource = (features, firmwareType) => {
|
|
25074
25243
|
var _b, _c, _d;
|
|
25075
25244
|
const deviceType = getDeviceType(features);
|
|
25076
25245
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25080,6 +25249,7 @@ DataManager.getBootloaderResource = (features) => {
|
|
|
25080
25249
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25081
25250
|
features,
|
|
25082
25251
|
updateType: 'firmware',
|
|
25252
|
+
firmwareType,
|
|
25083
25253
|
});
|
|
25084
25254
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25085
25255
|
if (targetDeviceConfigList.length === 0) {
|
|
@@ -25088,7 +25258,7 @@ DataManager.getBootloaderResource = (features) => {
|
|
|
25088
25258
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderResource);
|
|
25089
25259
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.bootloaderResource;
|
|
25090
25260
|
};
|
|
25091
|
-
DataManager.getBootloaderTargetVersion = (features) => {
|
|
25261
|
+
DataManager.getBootloaderTargetVersion = (features, firmwareType) => {
|
|
25092
25262
|
var _b, _c, _d, _e;
|
|
25093
25263
|
const deviceType = getDeviceType(features);
|
|
25094
25264
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25096,12 +25266,13 @@ DataManager.getBootloaderTargetVersion = (features) => {
|
|
|
25096
25266
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25097
25267
|
features,
|
|
25098
25268
|
updateType: 'firmware',
|
|
25269
|
+
firmwareType,
|
|
25099
25270
|
});
|
|
25100
25271
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25101
25272
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderResource);
|
|
25102
25273
|
return (_e = (_d = targetDeviceConfig === null || targetDeviceConfig === void 0 ? void 0 : targetDeviceConfig[0]) === null || _d === void 0 ? void 0 : _d.bootloaderVersion) !== null && _e !== void 0 ? _e : undefined;
|
|
25103
25274
|
};
|
|
25104
|
-
DataManager.getBootloaderRelatedFirmwareVersion = (features) => {
|
|
25275
|
+
DataManager.getBootloaderRelatedFirmwareVersion = (features, firmwareType) => {
|
|
25105
25276
|
var _b, _c, _d, _e;
|
|
25106
25277
|
const deviceType = getDeviceType(features);
|
|
25107
25278
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25111,12 +25282,13 @@ DataManager.getBootloaderRelatedFirmwareVersion = (features) => {
|
|
|
25111
25282
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25112
25283
|
features,
|
|
25113
25284
|
updateType: 'firmware',
|
|
25285
|
+
firmwareType,
|
|
25114
25286
|
});
|
|
25115
25287
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25116
25288
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderRelatedFirmwareVersion);
|
|
25117
25289
|
return (_e = (_d = targetDeviceConfig === null || targetDeviceConfig === void 0 ? void 0 : targetDeviceConfig[0]) === null || _d === void 0 ? void 0 : _d.bootloaderRelatedFirmwareVersion) !== null && _e !== void 0 ? _e : undefined;
|
|
25118
25290
|
};
|
|
25119
|
-
DataManager.getFirmwareChangelog = (features) => {
|
|
25291
|
+
DataManager.getFirmwareChangelog = (features, firmwareType) => {
|
|
25120
25292
|
var _b, _c;
|
|
25121
25293
|
const deviceType = getDeviceType(features);
|
|
25122
25294
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25125,6 +25297,7 @@ DataManager.getFirmwareChangelog = (features) => {
|
|
|
25125
25297
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25126
25298
|
features,
|
|
25127
25299
|
updateType: 'firmware',
|
|
25300
|
+
firmwareType,
|
|
25128
25301
|
});
|
|
25129
25302
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25130
25303
|
if (features.firmware_present === false ||
|
|
@@ -25134,7 +25307,7 @@ DataManager.getFirmwareChangelog = (features) => {
|
|
|
25134
25307
|
const currentVersion = deviceFirmwareVersion.join('.');
|
|
25135
25308
|
return getReleaseChangelog(targetDeviceConfigList, currentVersion);
|
|
25136
25309
|
};
|
|
25137
|
-
DataManager.getFirmwareLatestRelease = (features) => {
|
|
25310
|
+
DataManager.getFirmwareLatestRelease = (features, firmwareType) => {
|
|
25138
25311
|
var _b, _c;
|
|
25139
25312
|
const deviceType = getDeviceType(features);
|
|
25140
25313
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25142,13 +25315,14 @@ DataManager.getFirmwareLatestRelease = (features) => {
|
|
|
25142
25315
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25143
25316
|
features,
|
|
25144
25317
|
updateType: 'firmware',
|
|
25318
|
+
firmwareType,
|
|
25145
25319
|
});
|
|
25146
25320
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25147
25321
|
const target = findLatestRelease(targetDeviceConfigList);
|
|
25148
25322
|
if (!target)
|
|
25149
25323
|
return target;
|
|
25150
25324
|
if (!target.resource) {
|
|
25151
|
-
const resource = _a$1.getSysResourcesLatestRelease(features);
|
|
25325
|
+
const resource = _a$1.getSysResourcesLatestRelease({ features, firmwareType });
|
|
25152
25326
|
return Object.assign(Object.assign({}, target), { resource });
|
|
25153
25327
|
}
|
|
25154
25328
|
return target;
|
|
@@ -25347,28 +25521,35 @@ const supportModifyHomescreen = (features) => {
|
|
|
25347
25521
|
}
|
|
25348
25522
|
return { support: semver__default["default"].gte(currentVersion, '3.4.0') };
|
|
25349
25523
|
};
|
|
25350
|
-
const
|
|
25524
|
+
const getLatestFirmwareField = (firmwareType) => {
|
|
25525
|
+
if (firmwareType === 'bitcoinonly') {
|
|
25526
|
+
return `firmware-btc-v7`;
|
|
25527
|
+
}
|
|
25528
|
+
return `firmware-v7`;
|
|
25529
|
+
};
|
|
25530
|
+
const getFirmwareUpdateField = ({ features, updateType, targetVersion, firmwareType, }) => {
|
|
25351
25531
|
const deviceType = getDeviceType(features);
|
|
25352
25532
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
25353
25533
|
if (updateType === 'ble') {
|
|
25354
25534
|
return 'ble';
|
|
25355
25535
|
}
|
|
25536
|
+
const latestFirmwareField = getLatestFirmwareField(firmwareType);
|
|
25356
25537
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
25357
|
-
return
|
|
25538
|
+
return latestFirmwareField;
|
|
25358
25539
|
}
|
|
25359
25540
|
if (deviceType === hdShared.EDeviceType.Touch) {
|
|
25360
25541
|
if (targetVersion) {
|
|
25361
25542
|
if (semver__default["default"].eq(targetVersion, '4.0.0'))
|
|
25362
25543
|
return 'firmware-v2';
|
|
25363
25544
|
if (semver__default["default"].gt(targetVersion, '4.0.0'))
|
|
25364
|
-
return
|
|
25545
|
+
return latestFirmwareField;
|
|
25365
25546
|
}
|
|
25366
25547
|
if (semver__default["default"].lt(deviceFirmwareVersion.join('.'), '3.4.0'))
|
|
25367
25548
|
return 'firmware';
|
|
25368
|
-
return
|
|
25549
|
+
return latestFirmwareField;
|
|
25369
25550
|
}
|
|
25370
25551
|
if (deviceType === hdShared.EDeviceType.Pro) {
|
|
25371
|
-
return
|
|
25552
|
+
return latestFirmwareField;
|
|
25372
25553
|
}
|
|
25373
25554
|
return 'firmware';
|
|
25374
25555
|
};
|
|
@@ -25550,20 +25731,20 @@ function isEnteredManuallyBoot(features, updateType) {
|
|
|
25550
25731
|
return isMini || isBoot183ClassicUpBle;
|
|
25551
25732
|
}
|
|
25552
25733
|
|
|
25553
|
-
function checkNeedUpdateBootForTouch(features) {
|
|
25734
|
+
function checkNeedUpdateBootForTouch(features, firmwareType) {
|
|
25554
25735
|
const deviceType = getDeviceType(features);
|
|
25555
25736
|
if (!DeviceModelToTypes.model_touch.includes(deviceType))
|
|
25556
25737
|
return false;
|
|
25557
25738
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
25558
25739
|
const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
|
|
25559
|
-
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features);
|
|
25740
|
+
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features, firmwareType);
|
|
25560
25741
|
if (!targetBootloaderVersion)
|
|
25561
25742
|
return false;
|
|
25562
25743
|
return (semver__default["default"].gte(currentVersion, '3.2.0') &&
|
|
25563
25744
|
semver__default["default"].gte(currentVersion, '4.1.0') &&
|
|
25564
25745
|
semver__default["default"].lte(bootloaderVersion, targetBootloaderVersion.join('.')));
|
|
25565
25746
|
}
|
|
25566
|
-
function checkNeedUpdateBootForClassicAndMini(features, willUpdateFirmware) {
|
|
25747
|
+
function checkNeedUpdateBootForClassicAndMini({ features, willUpdateFirmware, firmwareType, }) {
|
|
25567
25748
|
const deviceType = getDeviceType(features);
|
|
25568
25749
|
if (!DeviceModelToTypes.model_mini.includes(deviceType))
|
|
25569
25750
|
return false;
|
|
@@ -25571,11 +25752,11 @@ function checkNeedUpdateBootForClassicAndMini(features, willUpdateFirmware) {
|
|
|
25571
25752
|
return false;
|
|
25572
25753
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
25573
25754
|
const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
|
|
25574
|
-
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features);
|
|
25755
|
+
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features, firmwareType);
|
|
25575
25756
|
if (targetBootloaderVersion && semver__default["default"].gte(bootloaderVersion, targetBootloaderVersion.join('.'))) {
|
|
25576
25757
|
return false;
|
|
25577
25758
|
}
|
|
25578
|
-
const bootloaderRelatedFirmwareVersion = DataManager.getBootloaderRelatedFirmwareVersion(features);
|
|
25759
|
+
const bootloaderRelatedFirmwareVersion = DataManager.getBootloaderRelatedFirmwareVersion(features, firmwareType);
|
|
25579
25760
|
if (!bootloaderRelatedFirmwareVersion)
|
|
25580
25761
|
return false;
|
|
25581
25762
|
return shouldUpdateBootloaderForClassicAndMini({
|
|
@@ -26487,12 +26668,15 @@ const cancelDeviceWithInitialize = (device) => {
|
|
|
26487
26668
|
}));
|
|
26488
26669
|
};
|
|
26489
26670
|
const Log$b = getLogger(exports.LoggerNames.DeviceCommands);
|
|
26671
|
+
const LogCore = getLogger(exports.LoggerNames.Core);
|
|
26490
26672
|
class DeviceCommands {
|
|
26491
26673
|
constructor(device, mainId) {
|
|
26492
26674
|
this.device = device;
|
|
26493
26675
|
this.mainId = mainId;
|
|
26494
26676
|
this.transport = TransportManager.getTransport();
|
|
26495
26677
|
this.disposed = false;
|
|
26678
|
+
this.instanceId = generateInstanceId('DeviceCommands', device.sdkInstanceId);
|
|
26679
|
+
Log$b.debug(`[DeviceCommands] Created: ${this.instanceId}, device: ${this.device.instanceId}`);
|
|
26496
26680
|
}
|
|
26497
26681
|
dispose(_cancelRequest) {
|
|
26498
26682
|
var _a, _b;
|
|
@@ -26565,11 +26749,11 @@ class DeviceCommands {
|
|
|
26565
26749
|
const promise = this.transport.call(this.mainId, type, msg);
|
|
26566
26750
|
this.callPromise = promise;
|
|
26567
26751
|
const res = yield promise;
|
|
26568
|
-
|
|
26752
|
+
LogCore.debug('[DeviceCommands] [call] Received', res.type);
|
|
26569
26753
|
return res;
|
|
26570
26754
|
}
|
|
26571
26755
|
catch (error) {
|
|
26572
|
-
|
|
26756
|
+
LogCore.debug('[DeviceCommands] [call] Received error', error);
|
|
26573
26757
|
if (error.errorCode === hdShared.HardwareErrorCode.BleDeviceBondError) {
|
|
26574
26758
|
return {
|
|
26575
26759
|
type: 'BleDeviceBondError',
|
|
@@ -26768,7 +26952,7 @@ class DeviceCommands {
|
|
|
26768
26952
|
return new Promise((resolve, reject) => {
|
|
26769
26953
|
const cancelAndReject = (_error) => cancelDeviceInPrompt(this.device, false)
|
|
26770
26954
|
.then(onCancel => {
|
|
26771
|
-
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
26955
|
+
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled, `${DEVICE.PIN} canceled`);
|
|
26772
26956
|
if (onCancel) {
|
|
26773
26957
|
const { payload } = onCancel || {};
|
|
26774
26958
|
reject(error || new Error(payload === null || payload === void 0 ? void 0 : payload.message));
|
|
@@ -26780,7 +26964,13 @@ class DeviceCommands {
|
|
|
26780
26964
|
.catch(error => {
|
|
26781
26965
|
reject(error);
|
|
26782
26966
|
});
|
|
26783
|
-
|
|
26967
|
+
const listenerCount = this.device.listenerCount(DEVICE.PIN);
|
|
26968
|
+
Log$b.debug(`[${this.instanceId}] _promptPin called`, {
|
|
26969
|
+
responseID: this.currentResponseID,
|
|
26970
|
+
deviceInstanceId: this.device.instanceId,
|
|
26971
|
+
listenerCount,
|
|
26972
|
+
});
|
|
26973
|
+
if (listenerCount > 0) {
|
|
26784
26974
|
this.device.setCancelableAction(cancelAndReject);
|
|
26785
26975
|
this.device.emit(DEVICE.PIN, this.device, type, (err, pin) => {
|
|
26786
26976
|
this.device.clearCancelableAction();
|
|
@@ -26793,8 +26983,16 @@ class DeviceCommands {
|
|
|
26793
26983
|
});
|
|
26794
26984
|
}
|
|
26795
26985
|
else {
|
|
26796
|
-
|
|
26797
|
-
|
|
26986
|
+
const activeRequests = getActiveRequestsByDeviceInstance(this.device.instanceId);
|
|
26987
|
+
const errorInfo = {
|
|
26988
|
+
commandsInstanceId: this.instanceId,
|
|
26989
|
+
deviceInstanceId: this.device.instanceId,
|
|
26990
|
+
currentResponseID: this.currentResponseID,
|
|
26991
|
+
listenerCount,
|
|
26992
|
+
activeRequests: activeRequests.map(formatRequestContext),
|
|
26993
|
+
};
|
|
26994
|
+
LogCore.error('[DeviceCommands] [call] PIN callback not configured, cancelling request', Object.assign({}, errorInfo));
|
|
26995
|
+
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `_promptPin: PIN callback not configured: ${JSON.stringify(errorInfo)}`));
|
|
26798
26996
|
}
|
|
26799
26997
|
});
|
|
26800
26998
|
}
|
|
@@ -26802,7 +27000,7 @@ class DeviceCommands {
|
|
|
26802
27000
|
return new Promise((resolve, reject) => {
|
|
26803
27001
|
const cancelAndReject = (_error) => cancelDeviceInPrompt(this.device, false)
|
|
26804
27002
|
.then(onCancel => {
|
|
26805
|
-
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
27003
|
+
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled, `${DEVICE.PASSPHRASE} canceled`);
|
|
26806
27004
|
if (onCancel) {
|
|
26807
27005
|
const { payload } = onCancel || {};
|
|
26808
27006
|
reject(error || new Error(payload === null || payload === void 0 ? void 0 : payload.message));
|
|
@@ -26827,7 +27025,7 @@ class DeviceCommands {
|
|
|
26827
27025
|
});
|
|
26828
27026
|
}
|
|
26829
27027
|
else {
|
|
26830
|
-
|
|
27028
|
+
LogCore.error('[DeviceCommands] [call] Passphrase callback not configured, cancelling request');
|
|
26831
27029
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, '_promptPassphrase: Passphrase callback not configured'));
|
|
26832
27030
|
}
|
|
26833
27031
|
});
|
|
@@ -26842,7 +27040,7 @@ const parseRunOptions = (options) => {
|
|
|
26842
27040
|
const Log$a = getLogger(exports.LoggerNames.Device);
|
|
26843
27041
|
const deviceSessionCache = {};
|
|
26844
27042
|
class Device extends events.exports {
|
|
26845
|
-
constructor(descriptor) {
|
|
27043
|
+
constructor(descriptor, sdkInstanceId) {
|
|
26846
27044
|
super();
|
|
26847
27045
|
this.deviceConnector = null;
|
|
26848
27046
|
this.deviceAcquired = false;
|
|
@@ -26856,10 +27054,14 @@ class Device extends events.exports {
|
|
|
26856
27054
|
this.keepSession = false;
|
|
26857
27055
|
this.passphraseState = undefined;
|
|
26858
27056
|
this.originalDescriptor = descriptor;
|
|
27057
|
+
this.sdkInstanceId = sdkInstanceId;
|
|
27058
|
+
this.instanceId = generateInstanceId('Device', this.sdkInstanceId);
|
|
27059
|
+
this.createdAt = Date.now();
|
|
27060
|
+
Log$a.debug(`[Device] Created: ${this.instanceId}${this.sdkInstanceId ? ` for SDK: ${this.sdkInstanceId}` : ''}`);
|
|
26859
27061
|
}
|
|
26860
|
-
static fromDescriptor(originalDescriptor) {
|
|
27062
|
+
static fromDescriptor(originalDescriptor, sdkInstanceId) {
|
|
26861
27063
|
const descriptor = Object.assign({}, originalDescriptor);
|
|
26862
|
-
return new Device(descriptor);
|
|
27064
|
+
return new Device(descriptor, sdkInstanceId);
|
|
26863
27065
|
}
|
|
26864
27066
|
toMessageObject() {
|
|
26865
27067
|
if (this.isUnacquired() || !this.features)
|
|
@@ -26871,6 +27073,9 @@ class Device extends events.exports {
|
|
|
26871
27073
|
return {
|
|
26872
27074
|
connectId: DataManager.isBleConnect(env) ? this.mainId || null : getDeviceUUID(this.features),
|
|
26873
27075
|
uuid: getDeviceUUID(this.features),
|
|
27076
|
+
sdkInstanceId: this.sdkInstanceId,
|
|
27077
|
+
instanceId: this.instanceId,
|
|
27078
|
+
createdAt: this.createdAt,
|
|
26874
27079
|
deviceType,
|
|
26875
27080
|
deviceId: this.features.device_id || null,
|
|
26876
27081
|
path: this.originalDescriptor.path,
|
|
@@ -27445,10 +27650,10 @@ class DeviceList extends events.exports {
|
|
|
27445
27650
|
}
|
|
27446
27651
|
}
|
|
27447
27652
|
|
|
27448
|
-
const getFirmwareReleaseInfo = (features) => {
|
|
27449
|
-
const firmwareStatus = DataManager.getFirmwareStatus(features);
|
|
27450
|
-
const changelog = DataManager.getFirmwareChangelog(features);
|
|
27451
|
-
const release = DataManager.getFirmwareLatestRelease(features);
|
|
27653
|
+
const getFirmwareReleaseInfo = (features, firmwareType) => {
|
|
27654
|
+
const firmwareStatus = DataManager.getFirmwareStatus(features, firmwareType);
|
|
27655
|
+
const changelog = DataManager.getFirmwareChangelog(features, firmwareType);
|
|
27656
|
+
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
27452
27657
|
const bootloaderMode = !!features.bootloader_mode;
|
|
27453
27658
|
return {
|
|
27454
27659
|
status: firmwareStatus,
|
|
@@ -27469,8 +27674,8 @@ const getBleFirmwareReleaseInfo = (features) => {
|
|
|
27469
27674
|
bootloaderMode,
|
|
27470
27675
|
};
|
|
27471
27676
|
};
|
|
27472
|
-
const getBootloaderReleaseInfo = (features, willUpdateFirmwareVersion) => {
|
|
27473
|
-
const release = DataManager.getFirmwareLatestRelease(features);
|
|
27677
|
+
const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwareType, }) => {
|
|
27678
|
+
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
27474
27679
|
const changelog = [release === null || release === void 0 ? void 0 : release.bootloaderChangelog].filter(item => item != null &&
|
|
27475
27680
|
typeof item === 'object' &&
|
|
27476
27681
|
Object.prototype.hasOwnProperty.call(item, 'zh-CN') &&
|
|
@@ -27479,10 +27684,14 @@ const getBootloaderReleaseInfo = (features, willUpdateFirmwareVersion) => {
|
|
|
27479
27684
|
let shouldUpdate = false;
|
|
27480
27685
|
const deviceType = getDeviceType(features);
|
|
27481
27686
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
27482
|
-
shouldUpdate = !!checkNeedUpdateBootForClassicAndMini(
|
|
27687
|
+
shouldUpdate = !!checkNeedUpdateBootForClassicAndMini({
|
|
27688
|
+
features,
|
|
27689
|
+
willUpdateFirmware: willUpdateFirmwareVersion,
|
|
27690
|
+
firmwareType,
|
|
27691
|
+
});
|
|
27483
27692
|
}
|
|
27484
27693
|
else if (DeviceModelToTypes.model_touch.includes(deviceType)) {
|
|
27485
|
-
shouldUpdate = checkNeedUpdateBootForTouch(features);
|
|
27694
|
+
shouldUpdate = checkNeedUpdateBootForTouch(features, firmwareType);
|
|
27486
27695
|
}
|
|
27487
27696
|
return {
|
|
27488
27697
|
status: shouldUpdate ? 'outdated' : 'valid',
|
|
@@ -27520,13 +27729,36 @@ class BaseMethod {
|
|
|
27520
27729
|
getVersionRange() {
|
|
27521
27730
|
return {};
|
|
27522
27731
|
}
|
|
27732
|
+
setContext(context) {
|
|
27733
|
+
this.sdkInstanceId = context.sdkInstanceId;
|
|
27734
|
+
this.instanceId = generateInstanceId('Method', this.sdkInstanceId);
|
|
27735
|
+
Log$9.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
|
|
27736
|
+
}
|
|
27523
27737
|
setDevice(device) {
|
|
27738
|
+
var _a, _b;
|
|
27524
27739
|
this.device = device;
|
|
27740
|
+
if (!device.sdkInstanceId && this.sdkInstanceId) {
|
|
27741
|
+
device.sdkInstanceId = this.sdkInstanceId;
|
|
27742
|
+
device.instanceId = generateInstanceId('Device', this.sdkInstanceId);
|
|
27743
|
+
}
|
|
27744
|
+
if (this.requestContext) {
|
|
27745
|
+
this.requestContext.deviceInstanceId = device.instanceId;
|
|
27746
|
+
this.requestContext.commandsInstanceId = (_a = device.commands) === null || _a === void 0 ? void 0 : _a.instanceId;
|
|
27747
|
+
this.requestContext.sdkInstanceId = this.sdkInstanceId;
|
|
27748
|
+
}
|
|
27749
|
+
if (device.commands && this.sdkInstanceId) {
|
|
27750
|
+
device.commands.instanceId = generateInstanceId('DeviceCommands', this.sdkInstanceId);
|
|
27751
|
+
}
|
|
27752
|
+
if (device.commands) {
|
|
27753
|
+
device.commands.currentResponseID = this.responseID;
|
|
27754
|
+
}
|
|
27755
|
+
Log$9.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
|
|
27525
27756
|
}
|
|
27526
27757
|
checkFirmwareRelease() {
|
|
27527
27758
|
if (!this.device || !this.device.features)
|
|
27528
27759
|
return;
|
|
27529
|
-
const
|
|
27760
|
+
const firmwareType = getFirmwareType(this.device.features);
|
|
27761
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features, firmwareType);
|
|
27530
27762
|
this.postMessage(createFirmwareMessage(FIRMWARE.RELEASE_INFO, Object.assign(Object.assign({}, releaseInfo), { device: this.device.toMessageObject() })));
|
|
27531
27763
|
const bleReleaseInfo = getBleFirmwareReleaseInfo(this.device.features);
|
|
27532
27764
|
this.postMessage(createFirmwareMessage(FIRMWARE.BLE_RELEASE_INFO, Object.assign(Object.assign({}, bleReleaseInfo), { device: this.device.toMessageObject() })));
|
|
@@ -27726,8 +27958,12 @@ class CheckFirmwareRelease extends BaseMethod {
|
|
|
27726
27958
|
this.skipForceUpdateCheck = true;
|
|
27727
27959
|
}
|
|
27728
27960
|
run() {
|
|
27961
|
+
var _a;
|
|
27962
|
+
const payload = this.payload;
|
|
27729
27963
|
if (this.device.features) {
|
|
27730
|
-
const
|
|
27964
|
+
const deviceFirmwareType = getFirmwareType(this.device.features);
|
|
27965
|
+
const firmwareType = (_a = payload.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
27966
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features, firmwareType);
|
|
27731
27967
|
return Promise.resolve(releaseInfo);
|
|
27732
27968
|
}
|
|
27733
27969
|
return Promise.resolve(null);
|
|
@@ -27868,12 +28104,20 @@ class CheckBootloaderRelease extends BaseMethod {
|
|
|
27868
28104
|
this.skipForceUpdateCheck = true;
|
|
27869
28105
|
}
|
|
27870
28106
|
run() {
|
|
28107
|
+
var _a;
|
|
27871
28108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27872
28109
|
if (!this.device.features) {
|
|
27873
28110
|
return null;
|
|
27874
28111
|
}
|
|
27875
28112
|
const { features } = this.device;
|
|
27876
|
-
const
|
|
28113
|
+
const payload = this.payload;
|
|
28114
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
28115
|
+
const firmwareType = (_a = payload.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
28116
|
+
const releaseInfo = getBootloaderReleaseInfo({
|
|
28117
|
+
features,
|
|
28118
|
+
willUpdateFirmwareVersion: payload.willUpdateFirmwareVersion,
|
|
28119
|
+
firmwareType,
|
|
28120
|
+
});
|
|
27877
28121
|
return Promise.resolve(releaseInfo);
|
|
27878
28122
|
});
|
|
27879
28123
|
}
|
|
@@ -27889,11 +28133,14 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
27889
28133
|
var _a, _b;
|
|
27890
28134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27891
28135
|
const { features } = this.device;
|
|
27892
|
-
const { checkBridgeRelease } = this
|
|
28136
|
+
const { checkBridgeRelease, firmwareType: firmwareTypeParams } = this
|
|
28137
|
+
.payload;
|
|
27893
28138
|
if (!features) {
|
|
27894
28139
|
return Promise.resolve(null);
|
|
27895
28140
|
}
|
|
27896
|
-
const
|
|
28141
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
28142
|
+
const firmwareType = firmwareTypeParams !== null && firmwareTypeParams !== void 0 ? firmwareTypeParams : deviceFirmwareType;
|
|
28143
|
+
const firmwareRelease = getFirmwareReleaseInfo(features, firmwareType);
|
|
27897
28144
|
const currentFirmwareVersion = getDeviceFirmwareVersion(features).join('.');
|
|
27898
28145
|
const willUpdateFirmwareVersion = (_b = (_a = firmwareRelease.release) === null || _a === void 0 ? void 0 : _a.version) === null || _b === void 0 ? void 0 : _b.join('.');
|
|
27899
28146
|
const deviceType = getDeviceType(features);
|
|
@@ -27906,7 +28153,11 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
27906
28153
|
willUpdateFirmwareVersion,
|
|
27907
28154
|
});
|
|
27908
28155
|
}
|
|
27909
|
-
const bootloaderRelease = getBootloaderReleaseInfo(
|
|
28156
|
+
const bootloaderRelease = getBootloaderReleaseInfo({
|
|
28157
|
+
features,
|
|
28158
|
+
willUpdateFirmwareVersion,
|
|
28159
|
+
firmwareType,
|
|
28160
|
+
});
|
|
27910
28161
|
const bleFirmwareReleaseInfo = getBleFirmwareReleaseInfo(features);
|
|
27911
28162
|
return {
|
|
27912
28163
|
firmware: firmwareRelease,
|
|
@@ -27920,6 +28171,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
27920
28171
|
release: bridgeReleaseInfo.releaseVersion,
|
|
27921
28172
|
}
|
|
27922
28173
|
: undefined,
|
|
28174
|
+
features,
|
|
27923
28175
|
};
|
|
27924
28176
|
});
|
|
27925
28177
|
}
|
|
@@ -28552,8 +28804,13 @@ class DeviceWipe extends BaseMethod {
|
|
|
28552
28804
|
}
|
|
28553
28805
|
}
|
|
28554
28806
|
|
|
28555
|
-
const getBinary = ({ features, updateType, version, isUpdateBootloader, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28556
|
-
const releaseInfo = getInfo({
|
|
28807
|
+
const getBinary = ({ features, updateType, version, isUpdateBootloader, firmwareType, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28808
|
+
const releaseInfo = getInfo({
|
|
28809
|
+
features,
|
|
28810
|
+
updateType,
|
|
28811
|
+
targetVersion: version === null || version === void 0 ? void 0 : version.join('.'),
|
|
28812
|
+
firmwareType,
|
|
28813
|
+
});
|
|
28557
28814
|
if (!releaseInfo) {
|
|
28558
28815
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'no firmware found for this device');
|
|
28559
28816
|
}
|
|
@@ -28590,7 +28847,7 @@ const getSysResourceBinary = (url) => __awaiter(void 0, void 0, void 0, function
|
|
|
28590
28847
|
binary: fw,
|
|
28591
28848
|
};
|
|
28592
28849
|
});
|
|
28593
|
-
const getInfo = ({ features, updateType, targetVersion }) => {
|
|
28850
|
+
const getInfo = ({ features, updateType, targetVersion, firmwareType }) => {
|
|
28594
28851
|
var _a, _b;
|
|
28595
28852
|
const deviceType = getDeviceType(features);
|
|
28596
28853
|
if (deviceType === 'unknown') {
|
|
@@ -28601,6 +28858,7 @@ const getInfo = ({ features, updateType, targetVersion }) => {
|
|
|
28601
28858
|
features,
|
|
28602
28859
|
updateType,
|
|
28603
28860
|
targetVersion,
|
|
28861
|
+
firmwareType,
|
|
28604
28862
|
});
|
|
28605
28863
|
const releaseInfo = (_b = (_a = deviceMap === null || deviceMap === void 0 ? void 0 : deviceMap[deviceType]) === null || _a === void 0 ? void 0 : _a[firmwareUpdateField]) !== null && _b !== void 0 ? _b : [];
|
|
28606
28864
|
return findLatestRelease(releaseInfo);
|
|
@@ -28648,11 +28906,34 @@ const waitBleInstall = (updateType) => __awaiter(void 0, void 0, void 0, functio
|
|
|
28648
28906
|
}
|
|
28649
28907
|
});
|
|
28650
28908
|
const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, rebootOnSuccess, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28909
|
+
var _a, _b;
|
|
28651
28910
|
const deviceType = getDeviceType(device.features);
|
|
28652
28911
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
28653
28912
|
postConfirmationMessage(device);
|
|
28654
28913
|
postProgressTip(device, 'ConfirmOnDevice', postMessage);
|
|
28655
|
-
const
|
|
28914
|
+
const isFirmware = updateType === 'firmware';
|
|
28915
|
+
const deviceBootloaderVersion = getDeviceBootloaderVersion(device.features).join('.');
|
|
28916
|
+
const supportUpgradeFileHeader = semver__default["default"].gt(deviceBootloaderVersion, '2.1.0');
|
|
28917
|
+
Log$8.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader, 'deviceBootloaderVersion:', deviceBootloaderVersion);
|
|
28918
|
+
if (isFirmware && supportUpgradeFileHeader) {
|
|
28919
|
+
const HEADER_SIZE = 1024;
|
|
28920
|
+
if (payload.byteLength < HEADER_SIZE) {
|
|
28921
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${payload.byteLength} bytes, expected at least ${HEADER_SIZE} bytes`);
|
|
28922
|
+
}
|
|
28923
|
+
Log$8.debug('Uploading firmware header:', { size: HEADER_SIZE, totalSize: payload.byteLength });
|
|
28924
|
+
postProgressTip(device, 'UploadingFirmwareHeader', postMessage);
|
|
28925
|
+
const header = new Uint8Array(payload.slice(0, HEADER_SIZE));
|
|
28926
|
+
const headerRes = (yield typedCall('UpgradeFileHeader', 'Success', {
|
|
28927
|
+
data: bytesToHex(header),
|
|
28928
|
+
}));
|
|
28929
|
+
const isUnexpectedMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnexpectedMessage');
|
|
28930
|
+
if (headerRes.type !== 'Success' && !isUnexpectedMessage) {
|
|
28931
|
+
Log$8.error('Firmware header upload failed:', headerRes);
|
|
28932
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
|
|
28933
|
+
}
|
|
28934
|
+
Log$8.debug('Firmware header uploaded successfully, isUnexpectedMessage:', isUnexpectedMessage);
|
|
28935
|
+
}
|
|
28936
|
+
const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
|
|
28656
28937
|
const eraseRes = yield typedCall(eraseCommand, 'Success', {});
|
|
28657
28938
|
if (eraseRes.type !== 'Success') {
|
|
28658
28939
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'erase firmware error');
|
|
@@ -28705,7 +28986,7 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
|
|
|
28705
28986
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'uploadFirmware: unknown device model');
|
|
28706
28987
|
});
|
|
28707
28988
|
const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, rebootOnSuccess = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28708
|
-
var
|
|
28989
|
+
var _c, _d, _e, _f, _g;
|
|
28709
28990
|
let typedCall = device.getCommands().typedCall.bind(device.getCommands());
|
|
28710
28991
|
postProgressTip(device, 'StartTransferData', postMessage);
|
|
28711
28992
|
const filePath = `0:${updateType === 'ble' ? 'ble-' : ''}firmware.bin`;
|
|
@@ -28749,7 +29030,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
|
|
|
28749
29030
|
}
|
|
28750
29031
|
}
|
|
28751
29032
|
if (response.type === 'Success' &&
|
|
28752
|
-
((
|
|
29033
|
+
((_c = response === null || response === void 0 ? void 0 : response.message) === null || _c === void 0 ? void 0 : _c.message) === FIRMWARE_UPDATE_CONFIRM$1) {
|
|
28753
29034
|
const timeout = 2 * 60 * 1000;
|
|
28754
29035
|
const startTime = Date.now();
|
|
28755
29036
|
const isBleReconnect = DataManager.isBleConnect(env);
|
|
@@ -28757,7 +29038,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
|
|
|
28757
29038
|
try {
|
|
28758
29039
|
if (isBleReconnect) {
|
|
28759
29040
|
try {
|
|
28760
|
-
yield ((
|
|
29041
|
+
yield ((_d = device.deviceConnector) === null || _d === void 0 ? void 0 : _d.acquire(device.originalDescriptor.id, null, true));
|
|
28761
29042
|
const typedCall = device.getCommands().typedCall.bind(device.getCommands());
|
|
28762
29043
|
yield Promise.race([
|
|
28763
29044
|
typedCall('Initialize', 'Features', {}),
|
|
@@ -28773,14 +29054,14 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
|
|
|
28773
29054
|
}
|
|
28774
29055
|
}
|
|
28775
29056
|
else {
|
|
28776
|
-
const deviceDiff = yield ((
|
|
28777
|
-
const devicesDescriptor = (
|
|
29057
|
+
const deviceDiff = yield ((_e = device.deviceConnector) === null || _e === void 0 ? void 0 : _e.enumerate());
|
|
29058
|
+
const devicesDescriptor = (_f = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _f !== void 0 ? _f : [];
|
|
28778
29059
|
const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, device.originalDescriptor.id);
|
|
28779
29060
|
if (deviceList.length === 1) {
|
|
28780
29061
|
device.updateFromCache(deviceList[0]);
|
|
28781
29062
|
yield device.acquire();
|
|
28782
29063
|
device.commands.disposed = false;
|
|
28783
|
-
device.getCommands().mainId = (
|
|
29064
|
+
device.getCommands().mainId = (_g = device.mainId) !== null && _g !== void 0 ? _g : '';
|
|
28784
29065
|
}
|
|
28785
29066
|
}
|
|
28786
29067
|
const typedCall = device.getCommands().typedCall.bind(device.getCommands());
|
|
@@ -28798,9 +29079,9 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
|
|
|
28798
29079
|
return response;
|
|
28799
29080
|
});
|
|
28800
29081
|
const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, overwrite, progress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28801
|
-
var
|
|
29082
|
+
var _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
28802
29083
|
const writeFunc = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28803
|
-
var
|
|
29084
|
+
var _s;
|
|
28804
29085
|
const typedCall = device.getCommands().typedCall.bind(device.getCommands());
|
|
28805
29086
|
const writeRes = yield typedCall('EmmcFileWrite', 'EmmcFile', {
|
|
28806
29087
|
file: {
|
|
@@ -28815,7 +29096,7 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
|
|
|
28815
29096
|
});
|
|
28816
29097
|
if (writeRes.type !== 'EmmcFile') {
|
|
28817
29098
|
if (writeRes.type === 'CallMethodError') {
|
|
28818
|
-
if (((
|
|
29099
|
+
if (((_s = writeRes.message.error) !== null && _s !== void 0 ? _s : '').indexOf(SESSION_ERROR$1) > -1) {
|
|
28819
29100
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, SESSION_ERROR$1);
|
|
28820
29101
|
}
|
|
28821
29102
|
}
|
|
@@ -28838,18 +29119,18 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
|
|
|
28838
29119
|
const env = DataManager.getSettings('env');
|
|
28839
29120
|
if (DataManager.isBleConnect(env)) {
|
|
28840
29121
|
yield wait(3000);
|
|
28841
|
-
yield ((
|
|
29122
|
+
yield ((_h = device.deviceConnector) === null || _h === void 0 ? void 0 : _h.acquire(device.originalDescriptor.id, null, true));
|
|
28842
29123
|
yield device.initialize();
|
|
28843
29124
|
}
|
|
28844
|
-
else if (((
|
|
28845
|
-
((
|
|
28846
|
-
const deviceDiff = yield ((
|
|
28847
|
-
const devicesDescriptor = (
|
|
29125
|
+
else if (((_j = error === null || error === void 0 ? void 0 : error.message) === null || _j === void 0 ? void 0 : _j.indexOf(SESSION_ERROR$1)) > -1 ||
|
|
29126
|
+
((_l = (_k = error === null || error === void 0 ? void 0 : error.response) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.indexOf(SESSION_ERROR$1)) > -1) {
|
|
29127
|
+
const deviceDiff = yield ((_m = device.deviceConnector) === null || _m === void 0 ? void 0 : _m.enumerate());
|
|
29128
|
+
const devicesDescriptor = (_o = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _o !== void 0 ? _o : [];
|
|
28848
29129
|
const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, undefined);
|
|
28849
|
-
if (deviceList.length === 1 && ((
|
|
29130
|
+
if (deviceList.length === 1 && ((_q = (_p = deviceList[0]) === null || _p === void 0 ? void 0 : _p.features) === null || _q === void 0 ? void 0 : _q.bootloader_mode)) {
|
|
28850
29131
|
device.updateFromCache(deviceList[0]);
|
|
28851
29132
|
yield device.acquire();
|
|
28852
|
-
device.getCommands().mainId = (
|
|
29133
|
+
device.getCommands().mainId = (_r = device.mainId) !== null && _r !== void 0 ? _r : '';
|
|
28853
29134
|
}
|
|
28854
29135
|
}
|
|
28855
29136
|
yield wait(3000);
|
|
@@ -28943,15 +29224,19 @@ class DeviceFullyUploadResource extends BaseMethod {
|
|
|
28943
29224
|
return isTouchMode && semver__default["default"].gte(currentVersion, '3.4.0');
|
|
28944
29225
|
}
|
|
28945
29226
|
run() {
|
|
29227
|
+
var _a;
|
|
28946
29228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28947
29229
|
const { device } = this;
|
|
28948
29230
|
const { features } = device;
|
|
29231
|
+
const payload = this.payload;
|
|
29232
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
29233
|
+
const firmwareType = (_a = payload.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
28949
29234
|
if (!(features === null || features === void 0 ? void 0 : features.bootloader_mode) && features) {
|
|
28950
29235
|
if (features) {
|
|
28951
29236
|
let { binary } = this.payload;
|
|
28952
29237
|
if (!binary) {
|
|
28953
29238
|
this.postTipMessage('CheckLatestUiResource');
|
|
28954
|
-
const resourceUrl = DataManager.getSysFullResource(features);
|
|
29239
|
+
const resourceUrl = DataManager.getSysFullResource(features, firmwareType);
|
|
28955
29240
|
if (resourceUrl) {
|
|
28956
29241
|
this.postTipMessage('DownloadLatestUiResource');
|
|
28957
29242
|
const resource = yield getSysResourceBinary(resourceUrl);
|
|
@@ -29315,12 +29600,14 @@ class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod {
|
|
|
29315
29600
|
return true;
|
|
29316
29601
|
});
|
|
29317
29602
|
}
|
|
29318
|
-
updateTouchBootloader(device, features) {
|
|
29603
|
+
updateTouchBootloader({ device, features, firmwareType, }) {
|
|
29319
29604
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29320
29605
|
let { binary } = this.payload;
|
|
29321
29606
|
if (!binary) {
|
|
29322
29607
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.CheckLatestUiResource);
|
|
29323
|
-
const resourceUrl = features
|
|
29608
|
+
const resourceUrl = features
|
|
29609
|
+
? DataManager.getBootloaderResource(features, firmwareType)
|
|
29610
|
+
: null;
|
|
29324
29611
|
if (resourceUrl) {
|
|
29325
29612
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.DownloadLatestBootloaderResource);
|
|
29326
29613
|
const resource = yield getSysResourceBinary(resourceUrl);
|
|
@@ -29344,12 +29631,16 @@ class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod {
|
|
|
29344
29631
|
});
|
|
29345
29632
|
}
|
|
29346
29633
|
run() {
|
|
29634
|
+
var _a;
|
|
29347
29635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29348
29636
|
const { device } = this;
|
|
29349
29637
|
const { features } = device;
|
|
29638
|
+
const payload = this.payload;
|
|
29350
29639
|
const deviceType = getDeviceType(features);
|
|
29640
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
29641
|
+
const firmwareType = (_a = payload.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
29351
29642
|
if (DeviceModelToTypes.model_touch.includes(deviceType)) {
|
|
29352
|
-
return this.updateTouchBootloader(device, features);
|
|
29643
|
+
return this.updateTouchBootloader({ device, features, firmwareType });
|
|
29353
29644
|
}
|
|
29354
29645
|
return Promise.resolve(true);
|
|
29355
29646
|
});
|
|
@@ -29541,6 +29832,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
29541
29832
|
features: device.features,
|
|
29542
29833
|
version: params.version,
|
|
29543
29834
|
updateType: params.updateType,
|
|
29835
|
+
firmwareType: hdShared.EFirmwareType.Universal,
|
|
29544
29836
|
});
|
|
29545
29837
|
binary = firmware.binary;
|
|
29546
29838
|
this.postTipMessage('DownloadFirmwareSuccess');
|
|
@@ -29584,6 +29876,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29584
29876
|
{ name: 'binary', type: 'buffer' },
|
|
29585
29877
|
{ name: 'forcedUpdateRes', type: 'boolean' },
|
|
29586
29878
|
{ name: 'platform', type: 'string', required: true },
|
|
29879
|
+
{ name: 'firmwareType', type: 'string' },
|
|
29587
29880
|
]);
|
|
29588
29881
|
if (!payload.updateType) {
|
|
29589
29882
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'updateType is required');
|
|
@@ -29594,7 +29887,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29594
29887
|
isUpdateBootloader: payload.isUpdateBootloader,
|
|
29595
29888
|
};
|
|
29596
29889
|
if ('version' in payload) {
|
|
29597
|
-
this.params = Object.assign(Object.assign({}, this.params), { version: payload.version });
|
|
29890
|
+
this.params = Object.assign(Object.assign({}, this.params), { version: payload.version, firmwareType: payload.firmwareType });
|
|
29598
29891
|
}
|
|
29599
29892
|
if ('binary' in payload) {
|
|
29600
29893
|
this.params = Object.assign(Object.assign({}, this.params), { binary: payload.binary });
|
|
@@ -29715,7 +30008,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29715
30008
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
29716
30009
|
return isTouchMode && semver__default["default"].gte(currentVersion, '3.2.0');
|
|
29717
30010
|
}
|
|
29718
|
-
checkVersionForCopyTouchResource(features) {
|
|
30011
|
+
checkVersionForCopyTouchResource(features, firmwareType) {
|
|
29719
30012
|
var _a;
|
|
29720
30013
|
if (!features)
|
|
29721
30014
|
return;
|
|
@@ -29723,7 +30016,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29723
30016
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
29724
30017
|
const targetVersion = (_a = this.params.version) === null || _a === void 0 ? void 0 : _a.join('.');
|
|
29725
30018
|
const { updateType } = this.params;
|
|
29726
|
-
const releaseInfo = getInfo({ features, updateType });
|
|
30019
|
+
const releaseInfo = getInfo({ features, updateType, firmwareType });
|
|
29727
30020
|
if (!releaseInfo)
|
|
29728
30021
|
return;
|
|
29729
30022
|
const { fullResourceRange } = releaseInfo;
|
|
@@ -29739,12 +30032,14 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29739
30032
|
}
|
|
29740
30033
|
}
|
|
29741
30034
|
run() {
|
|
29742
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
30035
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
29743
30036
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29744
30037
|
const { device, params } = this;
|
|
29745
30038
|
const { features, commands } = device;
|
|
29746
30039
|
const deviceType = getDeviceType(features);
|
|
29747
|
-
|
|
30040
|
+
const deviceFirmwareType = getFirmwareType(device.features);
|
|
30041
|
+
const firmwareType = (_a = params.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
30042
|
+
this.checkVersionForCopyTouchResource(features, firmwareType);
|
|
29748
30043
|
if (!(features === null || features === void 0 ? void 0 : features.bootloader_mode) && features) {
|
|
29749
30044
|
const uuid = getDeviceUUID(features);
|
|
29750
30045
|
if (this.isEnteredManuallyBoot(features)) {
|
|
@@ -29752,7 +30047,11 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29752
30047
|
}
|
|
29753
30048
|
if (features && this.isSupportResourceUpdate(features, params.updateType)) {
|
|
29754
30049
|
this.postTipMessage('CheckLatestUiResource');
|
|
29755
|
-
const resourceUrl = DataManager.getSysResourcesLatestRelease(
|
|
30050
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
30051
|
+
features,
|
|
30052
|
+
forcedUpdateRes: params.forcedUpdateRes,
|
|
30053
|
+
firmwareType,
|
|
30054
|
+
});
|
|
29756
30055
|
if (resourceUrl) {
|
|
29757
30056
|
this.postTipMessage('DownloadLatestUiResource');
|
|
29758
30057
|
const resource = yield getSysResourceBinary(resourceUrl);
|
|
@@ -29762,7 +30061,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29762
30061
|
}
|
|
29763
30062
|
}
|
|
29764
30063
|
}
|
|
29765
|
-
(
|
|
30064
|
+
(_c = (_b = this.device) === null || _b === void 0 ? void 0 : _b.commands) === null || _c === void 0 ? void 0 : _c.checkDisposed();
|
|
29766
30065
|
try {
|
|
29767
30066
|
this.postTipMessage('AutoRebootToBootloader');
|
|
29768
30067
|
const bootRes = yield commands.typedCall('DeviceBackToBoot', 'Success');
|
|
@@ -29775,9 +30074,9 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29775
30074
|
DevicePool.clearDeviceCache(uuid);
|
|
29776
30075
|
}
|
|
29777
30076
|
delete DevicePool.devicesCache[''];
|
|
29778
|
-
yield ((
|
|
30077
|
+
yield ((_d = this.checkPromise) === null || _d === void 0 ? void 0 : _d.promise);
|
|
29779
30078
|
this.checkPromise = null;
|
|
29780
|
-
(
|
|
30079
|
+
(_f = (_e = this.device) === null || _e === void 0 ? void 0 : _e.commands) === null || _f === void 0 ? void 0 : _f.checkDisposed();
|
|
29781
30080
|
const isTouch = DeviceModelToTypes.model_touch.includes(deviceType);
|
|
29782
30081
|
yield wait(isTouch ? 3000 : 1500);
|
|
29783
30082
|
}
|
|
@@ -29804,15 +30103,16 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29804
30103
|
version: params.version,
|
|
29805
30104
|
updateType: params.updateType,
|
|
29806
30105
|
isUpdateBootloader: params.isUpdateBootloader,
|
|
30106
|
+
firmwareType,
|
|
29807
30107
|
});
|
|
29808
30108
|
binary = firmware.binary;
|
|
29809
30109
|
this.postTipMessage('DownloadFirmwareSuccess');
|
|
29810
30110
|
}
|
|
29811
30111
|
}
|
|
29812
30112
|
catch (err) {
|
|
29813
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (
|
|
30113
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_g = err.message) !== null && _g !== void 0 ? _g : err);
|
|
29814
30114
|
}
|
|
29815
|
-
(
|
|
30115
|
+
(_j = (_h = this.device) === null || _h === void 0 ? void 0 : _h.commands) === null || _j === void 0 ? void 0 : _j.checkDisposed();
|
|
29816
30116
|
yield this.device.acquire();
|
|
29817
30117
|
const response = yield uploadFirmware(params.updateType, this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: binary, rebootOnSuccess: true });
|
|
29818
30118
|
if (this.connectId) {
|
|
@@ -29845,6 +30145,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29845
30145
|
{ name: 'forcedUpdateRes', type: 'boolean' },
|
|
29846
30146
|
{ name: 'bootloaderVersion', type: 'array' },
|
|
29847
30147
|
{ name: 'bootloaderBinary', type: 'buffer' },
|
|
30148
|
+
{ name: 'firmwareType', type: 'string' },
|
|
29848
30149
|
{ name: 'platform', type: 'string' },
|
|
29849
30150
|
]);
|
|
29850
30151
|
this.params = {
|
|
@@ -29856,11 +30157,12 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29856
30157
|
bootloaderBinary: payload.bootloaderBinary,
|
|
29857
30158
|
firmwareVersion: payload.firmwareVersion,
|
|
29858
30159
|
resourceBinary: payload.resourceBinary,
|
|
30160
|
+
firmwareType: payload.firmwareType,
|
|
29859
30161
|
platform: payload.platform,
|
|
29860
30162
|
};
|
|
29861
30163
|
}
|
|
29862
30164
|
run() {
|
|
29863
|
-
var _a;
|
|
30165
|
+
var _a, _b;
|
|
29864
30166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29865
30167
|
const { device } = this;
|
|
29866
30168
|
const { features } = device;
|
|
@@ -29870,18 +30172,20 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29870
30172
|
if (!features) {
|
|
29871
30173
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Device features not available');
|
|
29872
30174
|
}
|
|
30175
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
30176
|
+
const firmwareType = (_a = this.params.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
29873
30177
|
let resourceBinary = null;
|
|
29874
30178
|
let fwBinaryMap = [];
|
|
29875
30179
|
let bootloaderBinary = null;
|
|
29876
30180
|
try {
|
|
29877
30181
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.StartDownloadFirmware);
|
|
29878
|
-
resourceBinary = yield this.prepareResourceBinary();
|
|
29879
|
-
fwBinaryMap = yield this.prepareFirmwareAndBleBinary();
|
|
29880
|
-
bootloaderBinary = yield this.prepareBootloaderBinary();
|
|
30182
|
+
resourceBinary = yield this.prepareResourceBinary(firmwareType);
|
|
30183
|
+
fwBinaryMap = yield this.prepareFirmwareAndBleBinary(firmwareType);
|
|
30184
|
+
bootloaderBinary = yield this.prepareBootloaderBinary(firmwareType);
|
|
29881
30185
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.FinishDownloadFirmware);
|
|
29882
30186
|
}
|
|
29883
30187
|
catch (err) {
|
|
29884
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (
|
|
30188
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_b = err.message) !== null && _b !== void 0 ? _b : err);
|
|
29885
30189
|
}
|
|
29886
30190
|
if (!bootloaderBinary && fwBinaryMap.length === 0) {
|
|
29887
30191
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, 'No firmware to update');
|
|
@@ -29906,7 +30210,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29906
30210
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'bootloader version needs to be updated');
|
|
29907
30211
|
}
|
|
29908
30212
|
}
|
|
29909
|
-
prepareResourceBinary() {
|
|
30213
|
+
prepareResourceBinary(firmwareType) {
|
|
29910
30214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29911
30215
|
if (this.params.resourceBinary) {
|
|
29912
30216
|
return this.params.resourceBinary;
|
|
@@ -29914,7 +30218,11 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29914
30218
|
const { features } = this.device;
|
|
29915
30219
|
if (!features)
|
|
29916
30220
|
return null;
|
|
29917
|
-
const resourceUrl = DataManager.getSysResourcesLatestRelease(
|
|
30221
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
30222
|
+
features,
|
|
30223
|
+
forcedUpdateRes: this.params.forcedUpdateRes,
|
|
30224
|
+
firmwareType,
|
|
30225
|
+
});
|
|
29918
30226
|
if (resourceUrl) {
|
|
29919
30227
|
const resource = (yield getSysResourceBinary(resourceUrl)).binary;
|
|
29920
30228
|
return resource;
|
|
@@ -29923,7 +30231,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29923
30231
|
return null;
|
|
29924
30232
|
});
|
|
29925
30233
|
}
|
|
29926
|
-
prepareBootloaderBinary() {
|
|
30234
|
+
prepareBootloaderBinary(firmwareType) {
|
|
29927
30235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29928
30236
|
if (this.params.bootloaderBinary) {
|
|
29929
30237
|
return this.params.bootloaderBinary;
|
|
@@ -29932,7 +30240,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29932
30240
|
if (!features)
|
|
29933
30241
|
return null;
|
|
29934
30242
|
if (this.params.bootloaderVersion) {
|
|
29935
|
-
const bootResourceUrl = DataManager.getBootloaderResource(features);
|
|
30243
|
+
const bootResourceUrl = DataManager.getBootloaderResource(features, firmwareType);
|
|
29936
30244
|
if (bootResourceUrl) {
|
|
29937
30245
|
const bootBinary = (yield getSysResourceBinary(bootResourceUrl)).binary;
|
|
29938
30246
|
return bootBinary;
|
|
@@ -29941,7 +30249,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29941
30249
|
return null;
|
|
29942
30250
|
});
|
|
29943
30251
|
}
|
|
29944
|
-
prepareFirmwareAndBleBinary() {
|
|
30252
|
+
prepareFirmwareAndBleBinary(firmwareType) {
|
|
29945
30253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29946
30254
|
const fwBinaryMap = [];
|
|
29947
30255
|
if (this.params.firmwareBinary) {
|
|
@@ -29958,6 +30266,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29958
30266
|
version: this.params.firmwareVersion,
|
|
29959
30267
|
updateType: 'firmware',
|
|
29960
30268
|
isUpdateBootloader: false,
|
|
30269
|
+
firmwareType,
|
|
29961
30270
|
})).binary;
|
|
29962
30271
|
fwBinaryMap.push({
|
|
29963
30272
|
fileName: 'firmware.bin',
|
|
@@ -29978,6 +30287,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29978
30287
|
features,
|
|
29979
30288
|
version: this.params.bleVersion,
|
|
29980
30289
|
updateType: 'ble',
|
|
30290
|
+
firmwareType,
|
|
29981
30291
|
});
|
|
29982
30292
|
fwBinaryMap.push({
|
|
29983
30293
|
fileName: 'ble-firmware.bin',
|
|
@@ -30049,6 +30359,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
30049
30359
|
if (error === null || error === void 0 ? void 0 : error.errorCode) {
|
|
30050
30360
|
const unexpectedError = [
|
|
30051
30361
|
hdShared.HardwareErrorCode.ActionCancelled,
|
|
30362
|
+
hdShared.HardwareErrorCode.CallQueueActionCancelled,
|
|
30052
30363
|
hdShared.HardwareErrorCode.FirmwareVerificationFailed,
|
|
30053
30364
|
hdShared.HardwareErrorCode.BleDeviceNotBonded,
|
|
30054
30365
|
hdShared.HardwareErrorCode.BleServiceNotFound,
|
|
@@ -30495,7 +30806,7 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
30495
30806
|
};
|
|
30496
30807
|
}
|
|
30497
30808
|
callMethod(methodName, params, rootFingerprint) {
|
|
30498
|
-
var _a;
|
|
30809
|
+
var _a, _b, _c;
|
|
30499
30810
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30500
30811
|
const method = findMethod({
|
|
30501
30812
|
event: IFRAME.CALL,
|
|
@@ -30504,25 +30815,38 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
30504
30815
|
});
|
|
30505
30816
|
method.connector = this.connector;
|
|
30506
30817
|
method.postMessage = this.postMessage;
|
|
30818
|
+
if (this.context) {
|
|
30819
|
+
(_a = method.setContext) === null || _a === void 0 ? void 0 : _a.call(method, this.context);
|
|
30820
|
+
}
|
|
30821
|
+
method.requestContext = createRequestContext(method.responseID, methodName, {
|
|
30822
|
+
sdkInstanceId: this.sdkInstanceId,
|
|
30823
|
+
connectId: this.payload.connectId,
|
|
30824
|
+
parentResponseID: this.responseID,
|
|
30825
|
+
});
|
|
30826
|
+
const onSignalAbort = () => {
|
|
30827
|
+
var _a;
|
|
30828
|
+
(_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort(hdShared.HardwareErrorCodeMessage[hdShared.HardwareErrorCode.RepeatUnlocking]);
|
|
30829
|
+
};
|
|
30830
|
+
const buttonListener = (...[device, request]) => {
|
|
30831
|
+
if (request.code === 'ButtonRequest_PinEntry' || request.code === 'ButtonRequest_AttachPin') {
|
|
30832
|
+
onSignalAbort();
|
|
30833
|
+
}
|
|
30834
|
+
else {
|
|
30835
|
+
onDeviceButtonHandler(device, request);
|
|
30836
|
+
}
|
|
30837
|
+
};
|
|
30507
30838
|
let result;
|
|
30508
30839
|
try {
|
|
30509
30840
|
method.init();
|
|
30510
|
-
(
|
|
30841
|
+
(_b = method.setDevice) === null || _b === void 0 ? void 0 : _b.call(method, this.device);
|
|
30511
30842
|
method.context = this.context;
|
|
30512
|
-
|
|
30513
|
-
|
|
30514
|
-
|
|
30515
|
-
|
|
30516
|
-
|
|
30517
|
-
|
|
30518
|
-
|
|
30519
|
-
onSignalAbort();
|
|
30520
|
-
}
|
|
30521
|
-
else {
|
|
30522
|
-
onDeviceButtonHandler(device, request);
|
|
30523
|
-
}
|
|
30524
|
-
};
|
|
30525
|
-
this.device.on(DEVICE.BUTTON, _onDeviceButtonHandler);
|
|
30843
|
+
if (method.requestContext && this.device) {
|
|
30844
|
+
updateRequestContext(method.requestContext.responseID, {
|
|
30845
|
+
deviceInstanceId: this.device.instanceId,
|
|
30846
|
+
commandsInstanceId: (_c = this.device.commands) === null || _c === void 0 ? void 0 : _c.instanceId,
|
|
30847
|
+
});
|
|
30848
|
+
}
|
|
30849
|
+
this.device.on(DEVICE.BUTTON, buttonListener);
|
|
30526
30850
|
this.device.on(DEVICE.PIN, onSignalAbort);
|
|
30527
30851
|
this.device.on(DEVICE.PASSPHRASE, onSignalAbort);
|
|
30528
30852
|
preCheckDeviceSupport(this.device, method);
|
|
@@ -30531,6 +30855,9 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
30531
30855
|
throw new Error('No response');
|
|
30532
30856
|
}
|
|
30533
30857
|
result = response.map((item, index) => (Object.assign(Object.assign({}, params.bundle[index]._originRequestParams), { success: true, payload: Object.assign(Object.assign({}, item), { rootFingerprint }) })));
|
|
30858
|
+
if (method.requestContext) {
|
|
30859
|
+
completeRequestContext(method.requestContext.responseID);
|
|
30860
|
+
}
|
|
30534
30861
|
}
|
|
30535
30862
|
catch (e) {
|
|
30536
30863
|
const error = handleSkippableHardwareError(e, this.device, method);
|
|
@@ -30546,6 +30873,14 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
30546
30873
|
else {
|
|
30547
30874
|
throw e;
|
|
30548
30875
|
}
|
|
30876
|
+
if (method.requestContext) {
|
|
30877
|
+
completeRequestContext(method.requestContext.responseID, e instanceof Error ? e : new Error(String(e)));
|
|
30878
|
+
}
|
|
30879
|
+
}
|
|
30880
|
+
finally {
|
|
30881
|
+
this.device.off(DEVICE.BUTTON, buttonListener);
|
|
30882
|
+
this.device.off(DEVICE.PIN, onSignalAbort);
|
|
30883
|
+
this.device.off(DEVICE.PASSPHRASE, onSignalAbort);
|
|
30549
30884
|
}
|
|
30550
30885
|
return result;
|
|
30551
30886
|
});
|
|
@@ -39217,7 +39552,33 @@ const pollingState = {};
|
|
|
39217
39552
|
let preConnectCache = {
|
|
39218
39553
|
passphraseState: undefined,
|
|
39219
39554
|
};
|
|
39555
|
+
const toError = (error) => {
|
|
39556
|
+
if (error instanceof Error)
|
|
39557
|
+
return error;
|
|
39558
|
+
if (error == null)
|
|
39559
|
+
return undefined;
|
|
39560
|
+
if (typeof error === 'string')
|
|
39561
|
+
return new Error(error);
|
|
39562
|
+
try {
|
|
39563
|
+
return new Error(JSON.stringify(error));
|
|
39564
|
+
}
|
|
39565
|
+
catch (_a) {
|
|
39566
|
+
return new Error(String(error));
|
|
39567
|
+
}
|
|
39568
|
+
};
|
|
39569
|
+
const updateMethodRequestContext = (method, updates) => {
|
|
39570
|
+
if (method.requestContext) {
|
|
39571
|
+
updateRequestContext(method.requestContext.responseID, updates);
|
|
39572
|
+
}
|
|
39573
|
+
};
|
|
39574
|
+
const completeMethodRequestContext = (method, error) => {
|
|
39575
|
+
if (!method.requestContext) {
|
|
39576
|
+
return;
|
|
39577
|
+
}
|
|
39578
|
+
completeRequestContext(method.requestContext.responseID, toError(error));
|
|
39579
|
+
};
|
|
39220
39580
|
const callAPI = (context, message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39581
|
+
var _a;
|
|
39221
39582
|
if (!message.id || !message.payload || message.type !== IFRAME.CALL) {
|
|
39222
39583
|
return Promise.reject(hdShared.ERRORS.TypedError('on call: message.id or message.payload is missing'));
|
|
39223
39584
|
}
|
|
@@ -39226,6 +39587,12 @@ const callAPI = (context, message) => __awaiter(void 0, void 0, void 0, function
|
|
|
39226
39587
|
method = findMethod(message);
|
|
39227
39588
|
method.connector = _connector;
|
|
39228
39589
|
method.postMessage = postMessage;
|
|
39590
|
+
(_a = method.setContext) === null || _a === void 0 ? void 0 : _a.call(method, context);
|
|
39591
|
+
method.requestContext = createRequestContext(method.responseID, method.name, {
|
|
39592
|
+
sdkInstanceId: context.sdkInstanceId,
|
|
39593
|
+
connectId: method.connectId,
|
|
39594
|
+
});
|
|
39595
|
+
Log.debug(`[${context.sdkInstanceId}] callAPI: ${formatRequestContext(method.requestContext)}`);
|
|
39229
39596
|
method.init();
|
|
39230
39597
|
}
|
|
39231
39598
|
catch (error) {
|
|
@@ -39233,11 +39600,14 @@ const callAPI = (context, message) => __awaiter(void 0, void 0, void 0, function
|
|
|
39233
39600
|
}
|
|
39234
39601
|
DevicePool.emitter.on(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
39235
39602
|
if (!method.useDevice) {
|
|
39603
|
+
updateMethodRequestContext(method, { status: 'running' });
|
|
39236
39604
|
try {
|
|
39237
39605
|
const response = yield method.run();
|
|
39606
|
+
completeMethodRequestContext(method);
|
|
39238
39607
|
return createResponseMessage(method.responseID, true, response);
|
|
39239
39608
|
}
|
|
39240
39609
|
catch (error) {
|
|
39610
|
+
completeMethodRequestContext(method, error);
|
|
39241
39611
|
return createResponseMessage(method.responseID, false, { error });
|
|
39242
39612
|
}
|
|
39243
39613
|
}
|
|
@@ -39277,9 +39647,10 @@ const waitForPendingPromise = (getPrePendingCallPromise, removePrePendingCallPro
|
|
|
39277
39647
|
}
|
|
39278
39648
|
});
|
|
39279
39649
|
const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39280
|
-
var
|
|
39650
|
+
var _b, _c, _d;
|
|
39281
39651
|
let messageResponse;
|
|
39282
39652
|
const { requestQueue, getPrePendingCallPromise, setPrePendingCallPromise } = context;
|
|
39653
|
+
updateMethodRequestContext(method, { status: 'running' });
|
|
39283
39654
|
const connectStateChange = preConnectCache.passphraseState !== method.payload.passphraseState;
|
|
39284
39655
|
preConnectCache = {
|
|
39285
39656
|
passphraseState: method.payload.passphraseState,
|
|
@@ -39299,10 +39670,11 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39299
39670
|
pollingState[pollingId] = false;
|
|
39300
39671
|
}
|
|
39301
39672
|
pollingId += 1;
|
|
39302
|
-
device = yield ensureConnected(context, method, pollingId, (
|
|
39673
|
+
device = yield ensureConnected(context, method, pollingId, (_b = task.abortController) === null || _b === void 0 ? void 0 : _b.signal);
|
|
39303
39674
|
}
|
|
39304
39675
|
catch (e) {
|
|
39305
39676
|
console.log('ensureConnected error: ', e);
|
|
39677
|
+
completeMethodRequestContext(method, e);
|
|
39306
39678
|
if (e.name === 'AbortError' || e.message === 'Request aborted') {
|
|
39307
39679
|
requestQueue.releaseTask(method.responseID);
|
|
39308
39680
|
return createResponseMessage(method.responseID, false, {
|
|
@@ -39313,8 +39685,16 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39313
39685
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
39314
39686
|
}
|
|
39315
39687
|
Log.debug('Call API - setDevice: ', device.mainId);
|
|
39316
|
-
(
|
|
39688
|
+
(_c = method.setDevice) === null || _c === void 0 ? void 0 : _c.call(method, device);
|
|
39317
39689
|
method.context = context;
|
|
39690
|
+
updateMethodRequestContext(method, {
|
|
39691
|
+
deviceInstanceId: device.instanceId,
|
|
39692
|
+
commandsInstanceId: (_d = device.commands) === null || _d === void 0 ? void 0 : _d.instanceId,
|
|
39693
|
+
});
|
|
39694
|
+
const activeRequests = getActiveRequestsByDeviceInstance(device.instanceId);
|
|
39695
|
+
if (activeRequests.length > 0) {
|
|
39696
|
+
Log.warn(`[${method.instanceId}] Device ${device.instanceId} has ${activeRequests.length} active requests:`, activeRequests.map(formatRequestContext));
|
|
39697
|
+
}
|
|
39318
39698
|
device.on(DEVICE.PIN, onDevicePinHandler);
|
|
39319
39699
|
device.on(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
39320
39700
|
device.on(DEVICE.PASSPHRASE, message.payload.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler);
|
|
@@ -39327,7 +39707,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39327
39707
|
}
|
|
39328
39708
|
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
39329
39709
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39330
|
-
var
|
|
39710
|
+
var _e, _f, _g, _h, _j;
|
|
39331
39711
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
39332
39712
|
if (device.features) {
|
|
39333
39713
|
yield DataManager.checkAndReloadData();
|
|
@@ -39337,7 +39717,8 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39337
39717
|
throw hdShared.createDefectiveFirmwareError(defectiveInfo.serialNo, defectiveInfo.seVersion || 'Unknown', defectiveInfo.deviceType, method.connectId, method.deviceId);
|
|
39338
39718
|
}
|
|
39339
39719
|
}
|
|
39340
|
-
const
|
|
39720
|
+
const deviceFirmwareType = getFirmwareType(device.features);
|
|
39721
|
+
const newVersionStatus = DataManager.getFirmwareStatus(device.features, deviceFirmwareType);
|
|
39341
39722
|
const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
|
|
39342
39723
|
const currentFirmwareVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
39343
39724
|
const currentBleVersion = getDeviceBLEFirmwareVersion(device.features).join('.');
|
|
@@ -39403,7 +39784,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39403
39784
|
require: support.require,
|
|
39404
39785
|
}));
|
|
39405
39786
|
}
|
|
39406
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((
|
|
39787
|
+
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_e = method.payload) === null || _e === void 0 ? void 0 : _e.passphraseState, (_f = method.payload) === null || _f === void 0 ? void 0 : _f.useEmptyPassphrase, (_g = method.payload) === null || _g === void 0 ? void 0 : _g.skipPassphraseCheck);
|
|
39407
39788
|
checkPassphraseEnableState(method, device.features);
|
|
39408
39789
|
if (!passphraseStateSafety) {
|
|
39409
39790
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -39420,17 +39801,19 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39420
39801
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
39421
39802
|
throw error;
|
|
39422
39803
|
}
|
|
39423
|
-
(
|
|
39804
|
+
(_j = (_h = method.device) === null || _h === void 0 ? void 0 : _h.commands) === null || _j === void 0 ? void 0 : _j.checkDisposed();
|
|
39424
39805
|
try {
|
|
39425
39806
|
const response = yield method.run();
|
|
39426
39807
|
Log.debug('Call API - Inner Method Run: ');
|
|
39427
39808
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
39428
39809
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
39810
|
+
completeMethodRequestContext(method);
|
|
39429
39811
|
}
|
|
39430
39812
|
catch (error) {
|
|
39431
|
-
Log.debug(
|
|
39813
|
+
Log.debug(`Call API - Inner Method Run Error`, error);
|
|
39432
39814
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
39433
39815
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
39816
|
+
completeMethodRequestContext(method, error);
|
|
39434
39817
|
}
|
|
39435
39818
|
});
|
|
39436
39819
|
Log.debug('Call API - Device Run: ', device.mainId);
|
|
@@ -39442,6 +39825,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39442
39825
|
}
|
|
39443
39826
|
catch (e) {
|
|
39444
39827
|
Log.debug('Device Run Error: ', e);
|
|
39828
|
+
completeMethodRequestContext(method, e);
|
|
39445
39829
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
39446
39830
|
}
|
|
39447
39831
|
}
|
|
@@ -39449,6 +39833,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39449
39833
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
39450
39834
|
requestQueue.rejectRequest(method.responseID, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodError, error.message));
|
|
39451
39835
|
Log.debug('Call API - Run Error: ', error);
|
|
39836
|
+
completeMethodRequestContext(method, error);
|
|
39452
39837
|
}
|
|
39453
39838
|
finally {
|
|
39454
39839
|
const response = messageResponse;
|
|
@@ -39460,7 +39845,17 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39460
39845
|
requestQueue.releaseTask(method.responseID);
|
|
39461
39846
|
closePopup();
|
|
39462
39847
|
cleanup();
|
|
39463
|
-
|
|
39848
|
+
if (device) {
|
|
39849
|
+
const stillActive = getActiveRequestsByDeviceInstance(device.instanceId);
|
|
39850
|
+
if (stillActive.length > 1) {
|
|
39851
|
+
Log.warn(`[${method.instanceId}] Removing listeners while ${stillActive.length} requests are active!`, {
|
|
39852
|
+
deviceInstanceId: device.instanceId,
|
|
39853
|
+
activeRequests: stillActive.map(formatRequestContext),
|
|
39854
|
+
pinListeners: device.listenerCount(DEVICE.PIN),
|
|
39855
|
+
});
|
|
39856
|
+
}
|
|
39857
|
+
removeDeviceListener(device);
|
|
39858
|
+
}
|
|
39464
39859
|
}
|
|
39465
39860
|
});
|
|
39466
39861
|
function initDeviceList(method) {
|
|
@@ -39530,7 +39925,7 @@ function initDeviceForBle(method) {
|
|
|
39530
39925
|
device = deviceCacheMap.get(method.connectId);
|
|
39531
39926
|
}
|
|
39532
39927
|
else {
|
|
39533
|
-
device = Device.fromDescriptor({ id: method.connectId });
|
|
39928
|
+
device = Device.fromDescriptor({ id: method.connectId }, method.sdkInstanceId);
|
|
39534
39929
|
deviceCacheMap.set(method.connectId, device);
|
|
39535
39930
|
}
|
|
39536
39931
|
device.deviceConnector = _connector;
|
|
@@ -39570,7 +39965,7 @@ const ensureConnected = (_context, method, pollingId, abortSignal) => __awaiter(
|
|
|
39570
39965
|
if (timer) {
|
|
39571
39966
|
clearTimeout(timer);
|
|
39572
39967
|
}
|
|
39573
|
-
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
39968
|
+
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled));
|
|
39574
39969
|
return true;
|
|
39575
39970
|
}
|
|
39576
39971
|
return false;
|
|
@@ -39700,7 +40095,7 @@ const cancel = (context, connectId) => {
|
|
|
39700
40095
|
setPrePendingCallPromise(device === null || device === void 0 ? void 0 : device.interruptionFromUser());
|
|
39701
40096
|
canceledDevices.push(device);
|
|
39702
40097
|
}
|
|
39703
|
-
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
40098
|
+
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled));
|
|
39704
40099
|
}
|
|
39705
40100
|
}
|
|
39706
40101
|
requestQueue.abortRequestsByConnectId(connectId);
|
|
@@ -39723,7 +40118,7 @@ const cancel = (context, connectId) => {
|
|
|
39723
40118
|
device === null || device === void 0 ? void 0 : device.interruptionFromUser();
|
|
39724
40119
|
canceledDevices.push(device);
|
|
39725
40120
|
}
|
|
39726
|
-
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
40121
|
+
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled));
|
|
39727
40122
|
}
|
|
39728
40123
|
}
|
|
39729
40124
|
}
|
|
@@ -39735,7 +40130,7 @@ const cancel = (context, connectId) => {
|
|
|
39735
40130
|
}
|
|
39736
40131
|
});
|
|
39737
40132
|
requestQueue.getRequestTasksId().forEach(requestId => {
|
|
39738
|
-
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
40133
|
+
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled));
|
|
39739
40134
|
});
|
|
39740
40135
|
}
|
|
39741
40136
|
}
|
|
@@ -39856,12 +40251,17 @@ const removeUiPromise = (promise) => {
|
|
|
39856
40251
|
};
|
|
39857
40252
|
class Core extends events.exports {
|
|
39858
40253
|
constructor() {
|
|
39859
|
-
super(
|
|
40254
|
+
super();
|
|
39860
40255
|
this.requestQueue = new RequestQueue();
|
|
39861
40256
|
this.methodSynchronize = getSynchronize();
|
|
40257
|
+
this.tracingContext = createSdkTracingContext();
|
|
40258
|
+
this.sdkInstanceId = this.tracingContext.sdkInstanceId;
|
|
40259
|
+
Log.debug(`[Core] Created SDK instance: ${this.sdkInstanceId}`);
|
|
39862
40260
|
}
|
|
39863
40261
|
getCoreContext() {
|
|
39864
40262
|
return {
|
|
40263
|
+
sdkInstanceId: this.sdkInstanceId,
|
|
40264
|
+
tracingContext: this.tracingContext,
|
|
39865
40265
|
requestQueue: this.requestQueue,
|
|
39866
40266
|
methodSynchronize: this.methodSynchronize,
|
|
39867
40267
|
getPrePendingCallPromise: () => this.prePendingCallPromise,
|
|
@@ -39926,6 +40326,8 @@ class Core extends events.exports {
|
|
|
39926
40326
|
dispose() {
|
|
39927
40327
|
_deviceList = undefined;
|
|
39928
40328
|
_connector = undefined;
|
|
40329
|
+
Log.debug(`[Core] Disposing SDK instance: ${this.sdkInstanceId}`);
|
|
40330
|
+
cleanupSdkInstance(this.sdkInstanceId);
|
|
39929
40331
|
}
|
|
39930
40332
|
}
|
|
39931
40333
|
const initCore = () => {
|
|
@@ -39946,7 +40348,7 @@ const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0,
|
|
|
39946
40348
|
yield DataManager.load(settings);
|
|
39947
40349
|
initTransport(Transport, plugin);
|
|
39948
40350
|
}
|
|
39949
|
-
catch (
|
|
40351
|
+
catch (_k) {
|
|
39950
40352
|
Log.error('DataManager.load error');
|
|
39951
40353
|
}
|
|
39952
40354
|
enableLog(DataManager.getSettings('debug'));
|
|
@@ -40020,18 +40422,26 @@ exports.UI_RESPONSE = UI_RESPONSE;
|
|
|
40020
40422
|
exports.checkNeedUpdateBootForClassicAndMini = checkNeedUpdateBootForClassicAndMini;
|
|
40021
40423
|
exports.checkNeedUpdateBootForTouch = checkNeedUpdateBootForTouch;
|
|
40022
40424
|
exports.cleanupCallback = cleanupCallback;
|
|
40425
|
+
exports.cleanupSdkInstance = cleanupSdkInstance;
|
|
40426
|
+
exports.completeRequestContext = completeRequestContext;
|
|
40023
40427
|
exports.corsValidator = corsValidator;
|
|
40024
40428
|
exports.createDeviceMessage = createDeviceMessage;
|
|
40025
40429
|
exports.createErrorMessage = createErrorMessage;
|
|
40026
40430
|
exports.createFirmwareMessage = createFirmwareMessage;
|
|
40027
40431
|
exports.createIFrameMessage = createIFrameMessage;
|
|
40028
40432
|
exports.createLogMessage = createLogMessage;
|
|
40433
|
+
exports.createRequestContext = createRequestContext;
|
|
40029
40434
|
exports.createResponseMessage = createResponseMessage;
|
|
40435
|
+
exports.createSdkTracingContext = createSdkTracingContext;
|
|
40030
40436
|
exports.createUiMessage = createUiMessage;
|
|
40031
40437
|
exports.createUiResponse = createUiResponse;
|
|
40032
40438
|
exports["default"] = HardwareSdk;
|
|
40033
40439
|
exports.enableLog = enableLog;
|
|
40034
40440
|
exports.executeCallback = executeCallback;
|
|
40441
|
+
exports.formatRequestContext = formatRequestContext;
|
|
40442
|
+
exports.generateInstanceId = generateInstanceId;
|
|
40443
|
+
exports.generateSdkInstanceId = generateSdkInstanceId;
|
|
40444
|
+
exports.getActiveRequestsByDeviceInstance = getActiveRequestsByDeviceInstance;
|
|
40035
40445
|
exports.getDeviceBLEFirmwareVersion = getDeviceBLEFirmwareVersion;
|
|
40036
40446
|
exports.getDeviceBleName = getDeviceBleName;
|
|
40037
40447
|
exports.getDeviceBoardloaderVersion = getDeviceBoardloaderVersion;
|
|
@@ -40069,6 +40479,7 @@ exports.safeThrowError = safeThrowError;
|
|
|
40069
40479
|
exports.setLoggerPostMessage = setLoggerPostMessage;
|
|
40070
40480
|
exports.supportInputPinOnSoftware = supportInputPinOnSoftware;
|
|
40071
40481
|
exports.switchTransport = switchTransport;
|
|
40482
|
+
exports.updateRequestContext = updateRequestContext;
|
|
40072
40483
|
exports.versionCompare = versionCompare;
|
|
40073
40484
|
exports.versionSplit = versionSplit;
|
|
40074
40485
|
exports.wait = wait;
|