@onekeyfe/hd-core 1.2.0-alpha.10 → 1.2.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/DeviceCommands.test.ts +25 -0
- package/__tests__/RequestQueue.test.ts +34 -0
- package/__tests__/pro2Wallpaper.test.ts +50 -0
- package/__tests__/protocol-v2.test.ts +426 -60
- package/dist/api/BaseMethod.d.ts +4 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +0 -4
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +1 -6
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +18 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts +1 -4
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +16 -0
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +12 -0
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +26 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -0
- package/dist/core/RequestQueue.d.ts +2 -0
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/call.d.ts +7 -0
- package/dist/events/call.d.ts.map +1 -1
- package/dist/events/core.d.ts +2 -2
- package/dist/events/core.d.ts.map +1 -1
- package/dist/events/iframe.d.ts +1 -0
- package/dist/events/iframe.d.ts.map +1 -1
- package/dist/index.d.ts +76 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +694 -253
- package/dist/inject.d.ts +3 -2
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts +2 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +9 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +2 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +2 -10
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +8 -2
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +19 -4
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +0 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -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/pro2Wallpaper.d.ts +12 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +18 -0
- package/src/api/FileWrite.ts +9 -1
- package/src/api/FirmwareUpdateV4.ts +21 -91
- package/src/api/GetPassphraseState.ts +9 -18
- package/src/api/UploadPortfolio.ts +37 -0
- package/src/api/index.ts +5 -0
- package/src/api/protocol-v2/DeviceSessionGet.ts +3 -14
- package/src/api/protocol-v2/DeviceSettingsGet.ts +16 -0
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +59 -0
- package/src/api/protocol-v2/DeviceSettingsSet.ts +39 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +160 -0
- package/src/core/RequestQueue.ts +19 -0
- package/src/core/index.ts +10 -1
- package/src/data/messages/messages-protocol-v2.json +92 -8
- package/src/device/Device.ts +17 -3
- package/src/device/DeviceCommands.ts +9 -3
- package/src/events/call.ts +6 -0
- package/src/events/core.ts +2 -0
- package/src/events/iframe.ts +1 -0
- package/src/index.ts +4 -0
- package/src/inject.ts +13 -0
- package/src/lowLevelInject.ts +3 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +46 -0
- package/src/protocols/protocol-v2/walletSession.ts +14 -5
- package/src/topLevelInject.ts +2 -0
- package/src/types/api/firmwareUpdate.ts +12 -0
- package/src/types/api/getPassphraseState.ts +2 -11
- package/src/types/api/index.ts +12 -1
- package/src/types/api/protocolV2.ts +46 -3
- package/src/utils/deviceFeaturesUtils.ts +3 -8
- package/src/utils/index.ts +6 -0
- package/src/utils/pro2Wallpaper.ts +111 -0
package/dist/index.js
CHANGED
|
@@ -101,7 +101,7 @@ const executeCallback = (id, ...args) => {
|
|
|
101
101
|
const cleanupCallback = (id) => {
|
|
102
102
|
callbackManager.delete(id);
|
|
103
103
|
};
|
|
104
|
-
const inject = ({ call, cancel, dispose, eventEmitter, init, updateSettings, switchTransport, uiResponse, }) => {
|
|
104
|
+
const inject = ({ call, cancel, cancelOperation, dispose, eventEmitter, init, updateSettings, switchTransport, uiResponse, }) => {
|
|
105
105
|
const api = Object.assign({ on: (type, fn) => {
|
|
106
106
|
eventEmitter.on(type, fn);
|
|
107
107
|
}, emit: () => { }, off: (type, fn) => {
|
|
@@ -113,6 +113,7 @@ const inject = ({ call, cancel, dispose, eventEmitter, init, updateSettings, swi
|
|
|
113
113
|
dispose,
|
|
114
114
|
uiResponse,
|
|
115
115
|
cancel,
|
|
116
|
+
cancelOperation,
|
|
116
117
|
updateSettings,
|
|
117
118
|
switchTransport }, createCoreApi(call));
|
|
118
119
|
return api;
|
|
@@ -149,6 +150,10 @@ const createCoreApi = (call) => ({
|
|
|
149
150
|
deviceGetFirmwareUpdateStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetFirmwareUpdateStatus' })),
|
|
150
151
|
deviceFactoryInfoSet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFactoryInfoSet' })),
|
|
151
152
|
deviceFactoryInfoGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFactoryInfoGet' })),
|
|
153
|
+
deviceSettingsGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettingsGet' })),
|
|
154
|
+
deviceSettingsSet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettingsSet' })),
|
|
155
|
+
deviceSettingsPageShow: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettingsPageShow' })),
|
|
156
|
+
deviceUploadWallpaper: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceUploadWallpaper' })),
|
|
152
157
|
filesystemPermissionFix: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemPermissionFix' })),
|
|
153
158
|
fileRead: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'fileRead' })),
|
|
154
159
|
fileWrite: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'fileWrite' })),
|
|
@@ -159,6 +164,7 @@ const createCoreApi = (call) => ({
|
|
|
159
164
|
pathInfo: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'pathInfo' })),
|
|
160
165
|
filesystemFileRead: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemFileRead' })),
|
|
161
166
|
filesystemFileWrite: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemFileWrite' })),
|
|
167
|
+
uploadPortfolio: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'uploadPortfolio' })),
|
|
162
168
|
filesystemFileDelete: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemFileDelete' })),
|
|
163
169
|
filesystemDirList: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDirList' })),
|
|
164
170
|
filesystemDirMake: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDirMake' })),
|
|
@@ -293,7 +299,7 @@ const createCoreApi = (call) => ({
|
|
|
293
299
|
neoSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'neoSignTransaction' })),
|
|
294
300
|
});
|
|
295
301
|
|
|
296
|
-
const lowLevelInject = ({ call, cancel, dispose, eventEmitter, init, uiResponse, updateSettings, switchTransport, addHardwareGlobalEventListener, }) => {
|
|
302
|
+
const lowLevelInject = ({ call, cancel, cancelOperation, dispose, eventEmitter, init, uiResponse, updateSettings, switchTransport, addHardwareGlobalEventListener, }) => {
|
|
297
303
|
const api = Object.assign({ addHardwareGlobalEventListener, removeAllListeners: type => {
|
|
298
304
|
eventEmitter.removeAllListeners(type);
|
|
299
305
|
}, init,
|
|
@@ -301,6 +307,7 @@ const lowLevelInject = ({ call, cancel, dispose, eventEmitter, init, uiResponse,
|
|
|
301
307
|
dispose,
|
|
302
308
|
uiResponse,
|
|
303
309
|
cancel,
|
|
310
|
+
cancelOperation,
|
|
304
311
|
updateSettings,
|
|
305
312
|
switchTransport, emit: () => { } }, createCoreApi(call));
|
|
306
313
|
return api;
|
|
@@ -803,7 +810,7 @@ const topLevelInject = () => {
|
|
|
803
810
|
}, call }, createCoreApi(call)), { removeAllListeners: type => {
|
|
804
811
|
eventEmitter.removeAllListeners(type);
|
|
805
812
|
lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.removeAllListeners(type);
|
|
806
|
-
}, dispose: () => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.dispose(), uiResponse: response => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.uiResponse(response), cancel: (connectId) => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.cancel(connectId), updateSettings: settings => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.updateSettings(settings)) !== null && _a !== void 0 ? _a : Promise.resolve(false); }, switchTransport: (env) => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.switchTransport(env)) !== null && _a !== void 0 ? _a : Promise.resolve({ success: false }); } });
|
|
813
|
+
}, dispose: () => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.dispose(), uiResponse: response => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.uiResponse(response), cancel: (connectId) => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.cancel(connectId), cancelOperation: (operationId) => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.cancelOperation(operationId), updateSettings: settings => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.updateSettings(settings)) !== null && _a !== void 0 ? _a : Promise.resolve(false); }, switchTransport: (env) => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.switchTransport(env)) !== null && _a !== void 0 ? _a : Promise.resolve({ success: false }); } });
|
|
807
814
|
return api;
|
|
808
815
|
};
|
|
809
816
|
|
|
@@ -819,7 +826,7 @@ const createLogMessage = (type, payload) => ({
|
|
|
819
826
|
|
|
820
827
|
const MAX_ENTRIES = 500;
|
|
821
828
|
let postMessage$1;
|
|
822
|
-
class Log$
|
|
829
|
+
class Log$j {
|
|
823
830
|
constructor(prefix, enabled) {
|
|
824
831
|
this.prefix = prefix;
|
|
825
832
|
this.enabled = enabled;
|
|
@@ -871,7 +878,7 @@ class Log$i {
|
|
|
871
878
|
}
|
|
872
879
|
const _logs = {};
|
|
873
880
|
const initLog = (prefix, enabled) => {
|
|
874
|
-
const instance = new Log$
|
|
881
|
+
const instance = new Log$j(prefix, !!enabled);
|
|
875
882
|
_logs[prefix] = instance;
|
|
876
883
|
return instance;
|
|
877
884
|
};
|
|
@@ -1069,7 +1076,7 @@ function patchFeatures(response) {
|
|
|
1069
1076
|
return response;
|
|
1070
1077
|
}
|
|
1071
1078
|
|
|
1072
|
-
const Log$
|
|
1079
|
+
const Log$i = getLogger(exports.LoggerNames.Core);
|
|
1073
1080
|
let globalInstanceCounter = 0;
|
|
1074
1081
|
let sdkInstanceCounter = 0;
|
|
1075
1082
|
function generateSdkInstanceId() {
|
|
@@ -1129,7 +1136,7 @@ function completeRequestContext(responseID, error) {
|
|
|
1129
1136
|
context.status = error ? 'error' : 'success';
|
|
1130
1137
|
if (error) {
|
|
1131
1138
|
context.error = error.message;
|
|
1132
|
-
Log$
|
|
1139
|
+
Log$i.error(`[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`);
|
|
1133
1140
|
}
|
|
1134
1141
|
globalActiveRequests.delete(responseID);
|
|
1135
1142
|
if (context.sdkInstanceId) {
|
|
@@ -25765,6 +25772,7 @@ var nested = {
|
|
|
25765
25772
|
MessageType_DeviceSettings: 60410,
|
|
25766
25773
|
MessageType_DeviceSettingsGet: 60411,
|
|
25767
25774
|
MessageType_DeviceSettingsSet: 60412,
|
|
25775
|
+
MessageType_DeviceSettingsPageShow: 60413,
|
|
25768
25776
|
MessageType_DeviceCertificate: 60420,
|
|
25769
25777
|
MessageType_DeviceCertificateWrite: 60421,
|
|
25770
25778
|
MessageType_DeviceCertificateRead: 60422,
|
|
@@ -32374,14 +32382,6 @@ var nested = {
|
|
|
32374
32382
|
passphrase_state: {
|
|
32375
32383
|
type: "string",
|
|
32376
32384
|
id: 1
|
|
32377
|
-
},
|
|
32378
|
-
_only_main_pin: {
|
|
32379
|
-
type: "bool",
|
|
32380
|
-
id: 2
|
|
32381
|
-
},
|
|
32382
|
-
allow_create_attach_pin: {
|
|
32383
|
-
type: "bool",
|
|
32384
|
-
id: 3
|
|
32385
32385
|
}
|
|
32386
32386
|
}
|
|
32387
32387
|
},
|
|
@@ -36737,6 +36737,20 @@ var nested = {
|
|
|
36737
36737
|
}
|
|
36738
36738
|
}
|
|
36739
36739
|
},
|
|
36740
|
+
DeviceErrorCode: {
|
|
36741
|
+
values: {
|
|
36742
|
+
DeviceError_None: 0,
|
|
36743
|
+
DeviceError_Busy: 1,
|
|
36744
|
+
DeviceError_NotInitialized: 2,
|
|
36745
|
+
DeviceError_ActionCancelled: 3,
|
|
36746
|
+
DeviceError_PinAlreadyUsed: 4,
|
|
36747
|
+
DeviceError_PersistFailed: 5,
|
|
36748
|
+
DeviceError_SeError: 6,
|
|
36749
|
+
DeviceError_InvalidLanguage: 7,
|
|
36750
|
+
DeviceError_WallpaperNotUsable: 8,
|
|
36751
|
+
DeviceError_DeviceLocked: 9
|
|
36752
|
+
}
|
|
36753
|
+
},
|
|
36740
36754
|
DeviceRebootType: {
|
|
36741
36755
|
values: {
|
|
36742
36756
|
Normal: 0,
|
|
@@ -36766,6 +36780,62 @@ var nested = {
|
|
|
36766
36780
|
language: {
|
|
36767
36781
|
type: "string",
|
|
36768
36782
|
id: 3
|
|
36783
|
+
},
|
|
36784
|
+
wallpaper_path: {
|
|
36785
|
+
type: "string",
|
|
36786
|
+
id: 4
|
|
36787
|
+
},
|
|
36788
|
+
passphrase_enable: {
|
|
36789
|
+
type: "bool",
|
|
36790
|
+
id: 6
|
|
36791
|
+
},
|
|
36792
|
+
brightness: {
|
|
36793
|
+
type: "uint32",
|
|
36794
|
+
id: 7
|
|
36795
|
+
},
|
|
36796
|
+
autolock_delay_ms: {
|
|
36797
|
+
type: "uint32",
|
|
36798
|
+
id: 8
|
|
36799
|
+
},
|
|
36800
|
+
autoshutdown_delay_ms: {
|
|
36801
|
+
type: "uint32",
|
|
36802
|
+
id: 9
|
|
36803
|
+
},
|
|
36804
|
+
animation_enable: {
|
|
36805
|
+
type: "bool",
|
|
36806
|
+
id: 10
|
|
36807
|
+
},
|
|
36808
|
+
tap_to_wake: {
|
|
36809
|
+
type: "bool",
|
|
36810
|
+
id: 11
|
|
36811
|
+
},
|
|
36812
|
+
haptic_feedback: {
|
|
36813
|
+
type: "bool",
|
|
36814
|
+
id: 12
|
|
36815
|
+
},
|
|
36816
|
+
device_name_display_enabled: {
|
|
36817
|
+
type: "bool",
|
|
36818
|
+
id: 13
|
|
36819
|
+
},
|
|
36820
|
+
airgap_mode: {
|
|
36821
|
+
type: "bool",
|
|
36822
|
+
id: 14
|
|
36823
|
+
},
|
|
36824
|
+
fido_enabled: {
|
|
36825
|
+
type: "bool",
|
|
36826
|
+
id: 15
|
|
36827
|
+
},
|
|
36828
|
+
experimental_features: {
|
|
36829
|
+
type: "bool",
|
|
36830
|
+
id: 16
|
|
36831
|
+
},
|
|
36832
|
+
usb_lock_enable: {
|
|
36833
|
+
type: "bool",
|
|
36834
|
+
id: 17
|
|
36835
|
+
},
|
|
36836
|
+
random_keypad: {
|
|
36837
|
+
type: "bool",
|
|
36838
|
+
id: 18
|
|
36769
36839
|
}
|
|
36770
36840
|
}
|
|
36771
36841
|
},
|
|
@@ -36782,6 +36852,27 @@ var nested = {
|
|
|
36782
36852
|
}
|
|
36783
36853
|
}
|
|
36784
36854
|
},
|
|
36855
|
+
DeviceSettingsPage: {
|
|
36856
|
+
values: {
|
|
36857
|
+
DeviceReset: 0,
|
|
36858
|
+
DevicePinChange: 1,
|
|
36859
|
+
DevicePassphrase: 2,
|
|
36860
|
+
DeviceAirgap: 3
|
|
36861
|
+
}
|
|
36862
|
+
},
|
|
36863
|
+
DeviceSettingsPageShow: {
|
|
36864
|
+
fields: {
|
|
36865
|
+
page: {
|
|
36866
|
+
rule: "required",
|
|
36867
|
+
type: "DeviceSettingsPage",
|
|
36868
|
+
id: 1
|
|
36869
|
+
},
|
|
36870
|
+
field_name: {
|
|
36871
|
+
type: "string",
|
|
36872
|
+
id: 2
|
|
36873
|
+
}
|
|
36874
|
+
}
|
|
36875
|
+
},
|
|
36785
36876
|
DeviceCertificate: {
|
|
36786
36877
|
fields: {
|
|
36787
36878
|
cert_and_pubkey: {
|
|
@@ -38373,7 +38464,7 @@ const findLatestRelease = (releases) => {
|
|
|
38373
38464
|
};
|
|
38374
38465
|
|
|
38375
38466
|
var _a$1;
|
|
38376
|
-
const Log$
|
|
38467
|
+
const Log$h = getLogger(exports.LoggerNames.Core);
|
|
38377
38468
|
const FIRMWARE_FIELDS = [
|
|
38378
38469
|
'firmware',
|
|
38379
38470
|
'firmware-v1',
|
|
@@ -38437,37 +38528,37 @@ class DataManager {
|
|
|
38437
38528
|
let data = null;
|
|
38438
38529
|
let fetchMethod = 'none';
|
|
38439
38530
|
if (settings.configFetcher) {
|
|
38440
|
-
Log$
|
|
38531
|
+
Log$h.debug('[DataConfig] Trying configFetcher (client-side fetcher)...');
|
|
38441
38532
|
try {
|
|
38442
38533
|
data = yield settings.configFetcher(urlWithCache);
|
|
38443
38534
|
if (data) {
|
|
38444
38535
|
fetchMethod = 'configFetcher';
|
|
38445
|
-
Log$
|
|
38536
|
+
Log$h.log('[DataConfig] ConfigFetcher success');
|
|
38446
38537
|
}
|
|
38447
38538
|
else {
|
|
38448
|
-
Log$
|
|
38539
|
+
Log$h.debug('[DataConfig] ConfigFetcher returned null, will fallback to axios');
|
|
38449
38540
|
}
|
|
38450
38541
|
}
|
|
38451
38542
|
catch (e) {
|
|
38452
|
-
Log$
|
|
38543
|
+
Log$h.warn('[DataConfig] ConfigFetcher error, will fallback to axios:', e);
|
|
38453
38544
|
}
|
|
38454
38545
|
}
|
|
38455
38546
|
if (!data) {
|
|
38456
|
-
Log$
|
|
38547
|
+
Log$h.debug('[DataConfig] Trying axios (SDK default fetcher)...');
|
|
38457
38548
|
try {
|
|
38458
38549
|
const response = yield axios__default["default"].get(urlWithCache, {
|
|
38459
38550
|
timeout: 7000,
|
|
38460
38551
|
});
|
|
38461
38552
|
data = response.data;
|
|
38462
38553
|
fetchMethod = 'axios';
|
|
38463
|
-
Log$
|
|
38554
|
+
Log$h.log('[DataConfig] Axios fetch success');
|
|
38464
38555
|
}
|
|
38465
38556
|
catch (e) {
|
|
38466
|
-
Log$
|
|
38557
|
+
Log$h.warn('[DataConfig] Axios fetch error:', e);
|
|
38467
38558
|
}
|
|
38468
38559
|
}
|
|
38469
38560
|
if (data) {
|
|
38470
|
-
Log$
|
|
38561
|
+
Log$h.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
|
|
38471
38562
|
this.deviceMap = {
|
|
38472
38563
|
[hdShared.EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
38473
38564
|
[hdShared.EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
|
|
@@ -38482,7 +38573,7 @@ class DataManager {
|
|
|
38482
38573
|
};
|
|
38483
38574
|
}
|
|
38484
38575
|
else {
|
|
38485
|
-
Log$
|
|
38576
|
+
Log$h.warn('[DataConfig] All fetch methods failed, using built-in default config');
|
|
38486
38577
|
}
|
|
38487
38578
|
});
|
|
38488
38579
|
}
|
|
@@ -38796,7 +38887,14 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
38796
38887
|
}
|
|
38797
38888
|
const cachedSessionId = typeof device.getInternalState === 'function' ? device.getInternalState() : undefined;
|
|
38798
38889
|
try {
|
|
38799
|
-
const
|
|
38890
|
+
const requestDeviceSession = (sessionId) => device.commands.typedCall('DeviceSessionGet', 'DeviceSession', sessionId ? { session_id: sessionId } : {});
|
|
38891
|
+
const { message } = yield requestDeviceSession(cachedSessionId).catch((error) => __awaiter(this, void 0, void 0, function* () {
|
|
38892
|
+
if (!cachedSessionId || !isProtocolV2InvalidSessionError(error)) {
|
|
38893
|
+
throw error;
|
|
38894
|
+
}
|
|
38895
|
+
device.clearInternalState();
|
|
38896
|
+
return requestDeviceSession();
|
|
38897
|
+
}));
|
|
38800
38898
|
if ((options === null || options === void 0 ? void 0 : options.expectedPassphraseState) &&
|
|
38801
38899
|
options.expectedPassphraseState !== message.btc_test_address) {
|
|
38802
38900
|
device.clearInternalState();
|
|
@@ -38914,12 +39012,9 @@ const getPassphraseState = (device, options) => __awaiter(void 0, void 0, void 0
|
|
|
38914
39012
|
const supportAttachPinCapability = existCapability(features, hdTransport.Enum_Capability.Capability_AttachToPin);
|
|
38915
39013
|
const supportGetPassphraseState = supportAttachPinCapability || supportProSeriesAttachPinPassphrase(deviceType, firmwareVersion);
|
|
38916
39014
|
if (supportGetPassphraseState) {
|
|
38917
|
-
const payload =
|
|
38918
|
-
?
|
|
38919
|
-
|
|
38920
|
-
if (options === null || options === void 0 ? void 0 : options.allowCreateAttachPin) {
|
|
38921
|
-
payload.allow_create_attach_pin = true;
|
|
38922
|
-
}
|
|
39015
|
+
const payload = {
|
|
39016
|
+
passphrase_state: (options === null || options === void 0 ? void 0 : options.onlyMainPin) ? undefined : options === null || options === void 0 ? void 0 : options.expectPassphraseState,
|
|
39017
|
+
};
|
|
38923
39018
|
const { message, type } = yield commands.typedCall('GetPassphraseState', 'PassphraseState', payload);
|
|
38924
39019
|
if (type === 'CallMethodError') {
|
|
38925
39020
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
@@ -39619,6 +39714,93 @@ const getHomeScreenSize = ({ deviceType, homeScreenType, thumbnail, }) => {
|
|
|
39619
39714
|
return thumbnail ? deviceConfig.thumbnail[homeScreenType] : deviceConfig.full;
|
|
39620
39715
|
};
|
|
39621
39716
|
|
|
39717
|
+
const PRO2_WALLPAPER_WIDTH = 604;
|
|
39718
|
+
const PRO2_WALLPAPER_HEIGHT = 1024;
|
|
39719
|
+
const COLOR_FORMAT_RGB565 = 0x12;
|
|
39720
|
+
const COLOR_FORMAT_RGB565A8 = 0x14;
|
|
39721
|
+
const RED_THRESHOLD = [
|
|
39722
|
+
1, 7, 3, 5, 0, 8, 2, 6, 7, 1, 5, 3, 8, 0, 6, 2, 3, 5, 0, 8, 2, 6, 1, 7, 5, 3, 8,
|
|
39723
|
+
0, 6, 2, 7, 1, 0, 8, 2, 6, 1, 7, 3, 5, 8, 0, 6, 2, 7, 1, 5, 3, 2, 6, 1, 7, 3, 5, 0,
|
|
39724
|
+
8, 6, 2, 7, 1, 5, 3, 8, 0,
|
|
39725
|
+
];
|
|
39726
|
+
const GREEN_THRESHOLD = [
|
|
39727
|
+
1, 3, 2, 2, 3, 1, 2, 2, 2, 2, 0, 4, 2, 2, 4, 0, 3, 1, 2, 2, 1, 3, 2, 2, 2, 2, 4,
|
|
39728
|
+
0, 2, 2, 0, 4, 1, 3, 2, 2, 3, 1, 2, 2, 2, 2, 0, 4, 2, 2, 4, 0, 3, 1, 2, 2, 1, 3, 2,
|
|
39729
|
+
2, 2, 2, 4, 0, 2, 2, 0, 4,
|
|
39730
|
+
];
|
|
39731
|
+
const BLUE_THRESHOLD = [
|
|
39732
|
+
5, 3, 8, 0, 6, 2, 7, 1, 3, 5, 0, 8, 2, 6, 1, 7, 8, 0, 6, 2, 7, 1, 5, 3, 0, 8, 2,
|
|
39733
|
+
6, 1, 7, 3, 5, 6, 2, 7, 1, 5, 3, 8, 0, 2, 6, 1, 7, 3, 5, 0, 8, 7, 1, 5, 3, 8, 0, 6,
|
|
39734
|
+
2, 1, 7, 3, 5, 0, 8, 2, 6,
|
|
39735
|
+
];
|
|
39736
|
+
function invalidParameter$2(message) {
|
|
39737
|
+
return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
39738
|
+
}
|
|
39739
|
+
function asBytes(rgba) {
|
|
39740
|
+
return rgba instanceof Uint8Array ? rgba : new Uint8Array(rgba);
|
|
39741
|
+
}
|
|
39742
|
+
function align(value, boundary) {
|
|
39743
|
+
return Math.ceil(value / boundary) * boundary;
|
|
39744
|
+
}
|
|
39745
|
+
function encodePro2Wallpaper(options) {
|
|
39746
|
+
const { width, height } = options;
|
|
39747
|
+
if (!Number.isInteger(width) || width <= 0 || width > 0xffff) {
|
|
39748
|
+
throw invalidParameter$2('Wallpaper width must be an integer between 1 and 65535.');
|
|
39749
|
+
}
|
|
39750
|
+
if (!Number.isInteger(height) || height <= 0 || height > 0xffff) {
|
|
39751
|
+
throw invalidParameter$2('Wallpaper height must be an integer between 1 and 65535.');
|
|
39752
|
+
}
|
|
39753
|
+
const rgba = asBytes(options.rgba);
|
|
39754
|
+
const expectedLength = width * height * 4;
|
|
39755
|
+
if (rgba.byteLength !== expectedLength) {
|
|
39756
|
+
throw invalidParameter$2(`Wallpaper RGBA data length must be ${expectedLength} bytes, received ${rgba.byteLength}.`);
|
|
39757
|
+
}
|
|
39758
|
+
let hasTransparency = false;
|
|
39759
|
+
for (let index = 3; index < rgba.length; index += 4) {
|
|
39760
|
+
if (rgba[index] !== 0xff) {
|
|
39761
|
+
hasTransparency = true;
|
|
39762
|
+
break;
|
|
39763
|
+
}
|
|
39764
|
+
}
|
|
39765
|
+
const colorFormat = hasTransparency ? 'RGB565A8' : 'RGB565';
|
|
39766
|
+
const stride = align(width * 2, 4);
|
|
39767
|
+
const alphaStride = stride / 2;
|
|
39768
|
+
const rgbSize = stride * height;
|
|
39769
|
+
const alphaSize = hasTransparency ? alphaStride * height : 0;
|
|
39770
|
+
const data = new Uint8Array(12 + rgbSize + alphaSize);
|
|
39771
|
+
const view = new DataView(data.buffer);
|
|
39772
|
+
data[0] = 0x19;
|
|
39773
|
+
data[1] = hasTransparency ? COLOR_FORMAT_RGB565A8 : COLOR_FORMAT_RGB565;
|
|
39774
|
+
view.setUint16(2, 0, true);
|
|
39775
|
+
view.setUint16(4, width, true);
|
|
39776
|
+
view.setUint16(6, height, true);
|
|
39777
|
+
view.setUint16(8, stride, true);
|
|
39778
|
+
view.setUint16(10, 0, true);
|
|
39779
|
+
for (let y = 0; y < height; y += 1) {
|
|
39780
|
+
for (let x = 0; x < width; x += 1) {
|
|
39781
|
+
const sourceOffset = (y * width + x) * 4;
|
|
39782
|
+
const thresholdIndex = ((y & 7) << 3) + (x & 7);
|
|
39783
|
+
let red = Math.min(rgba[sourceOffset] + RED_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
39784
|
+
let green = Math.min(rgba[sourceOffset + 1] + GREEN_THRESHOLD[thresholdIndex], 0xff) & 0xfc;
|
|
39785
|
+
let blue = Math.min(rgba[sourceOffset + 2] + BLUE_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
39786
|
+
if (!hasTransparency) {
|
|
39787
|
+
const alpha = rgba[sourceOffset + 3];
|
|
39788
|
+
red = (red * alpha) >> 8;
|
|
39789
|
+
green = (green * alpha) >> 8;
|
|
39790
|
+
blue = (blue * alpha) >> 8;
|
|
39791
|
+
}
|
|
39792
|
+
const rgb565 = ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3);
|
|
39793
|
+
const rgbOffset = 12 + y * stride + x * 2;
|
|
39794
|
+
data[rgbOffset] = rgb565 & 0xff;
|
|
39795
|
+
data[rgbOffset + 1] = rgb565 >> 8;
|
|
39796
|
+
if (hasTransparency) {
|
|
39797
|
+
data[12 + rgbSize + y * alphaStride + x] = rgba[sourceOffset + 3];
|
|
39798
|
+
}
|
|
39799
|
+
}
|
|
39800
|
+
}
|
|
39801
|
+
return { data, colorFormat };
|
|
39802
|
+
}
|
|
39803
|
+
|
|
39622
39804
|
const isBleConnect = (env) => env === 'react-native' || env === 'lowlevel';
|
|
39623
39805
|
const wait = (ms) => new Promise(resolve => {
|
|
39624
39806
|
setTimeout(resolve, ms);
|
|
@@ -39748,6 +39930,7 @@ const IFRAME = {
|
|
|
39748
39930
|
INIT_BRIDGE: 'iframe-init-bridge',
|
|
39749
39931
|
CALL: 'iframe-call',
|
|
39750
39932
|
CANCEL: 'iframe-cancel',
|
|
39933
|
+
CANCEL_OPERATION: 'iframe-cancel-operation',
|
|
39751
39934
|
SWITCH_TRANSPORT: 'iframe-switch-transport',
|
|
39752
39935
|
CALLBACK: 'iframe-callback',
|
|
39753
39936
|
};
|
|
@@ -39837,7 +40020,7 @@ function getLogBlockLabel(message) {
|
|
|
39837
40020
|
return undefined;
|
|
39838
40021
|
}
|
|
39839
40022
|
|
|
39840
|
-
const Log$
|
|
40023
|
+
const Log$g = getLogger(exports.LoggerNames.DevicePool);
|
|
39841
40024
|
const getDiff = (current, descriptors) => {
|
|
39842
40025
|
const connected = descriptors.filter(d => current.find(x => x.path === d.path) === undefined);
|
|
39843
40026
|
const disconnected = current.filter(d => descriptors.find(x => x.path === d.path) === undefined);
|
|
@@ -39895,7 +40078,7 @@ class DevicePool extends events.exports {
|
|
|
39895
40078
|
yield this._checkDevicePool(initOptions);
|
|
39896
40079
|
return { devices, deviceList };
|
|
39897
40080
|
}
|
|
39898
|
-
Log$
|
|
40081
|
+
Log$g.debug('found device in cache, but path is different: ', connectId);
|
|
39899
40082
|
}
|
|
39900
40083
|
}
|
|
39901
40084
|
try {
|
|
@@ -39956,7 +40139,7 @@ class DevicePool extends events.exports {
|
|
|
39956
40139
|
for (let i = this.connectedPool.length - 1; i >= 0; i--) {
|
|
39957
40140
|
const descriptor = this.connectedPool[i];
|
|
39958
40141
|
const device = yield this._createDevice(descriptor, initOptions);
|
|
39959
|
-
Log$
|
|
40142
|
+
Log$g.debug('emit DEVICE.CONNECT: ', device === null || device === void 0 ? void 0 : device.features);
|
|
39960
40143
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
39961
40144
|
this.connectedPool.splice(i, 1);
|
|
39962
40145
|
}
|
|
@@ -39976,9 +40159,9 @@ class DevicePool extends events.exports {
|
|
|
39976
40159
|
const diff = getDiff(this.current || [], upcoming);
|
|
39977
40160
|
this.upcoming = upcoming;
|
|
39978
40161
|
this.current = this.upcoming;
|
|
39979
|
-
Log$
|
|
39980
|
-
Log$
|
|
39981
|
-
Log$
|
|
40162
|
+
Log$g.debug('device pool -> current: ', this.current);
|
|
40163
|
+
Log$g.debug('device pool -> upcomming: ', this.upcoming);
|
|
40164
|
+
Log$g.debug('DeviceCache.reportDeviceChange diff: ', diff);
|
|
39982
40165
|
if (!diff.didUpdate) {
|
|
39983
40166
|
return;
|
|
39984
40167
|
}
|
|
@@ -39988,7 +40171,7 @@ class DevicePool extends events.exports {
|
|
|
39988
40171
|
this._addConnectedDeviceToPool(d);
|
|
39989
40172
|
return;
|
|
39990
40173
|
}
|
|
39991
|
-
Log$
|
|
40174
|
+
Log$g.debug('emit DEVICE.CONNECT: ', device.features);
|
|
39992
40175
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
39993
40176
|
});
|
|
39994
40177
|
diff.disconnected.forEach(d => {
|
|
@@ -39998,7 +40181,7 @@ class DevicePool extends events.exports {
|
|
|
39998
40181
|
this._addDisconnectedDeviceToPool(d);
|
|
39999
40182
|
return;
|
|
40000
40183
|
}
|
|
40001
|
-
Log$
|
|
40184
|
+
Log$g.debug('emit DEVICE.DISCONNECT: ', device.features);
|
|
40002
40185
|
this.emitter.emit(DEVICE.DISCONNECT, device);
|
|
40003
40186
|
});
|
|
40004
40187
|
}
|
|
@@ -40034,7 +40217,7 @@ class DevicePool extends events.exports {
|
|
|
40034
40217
|
this.disconnectPool = [];
|
|
40035
40218
|
this.devicesCache = {};
|
|
40036
40219
|
this.emitter.removeAllListeners();
|
|
40037
|
-
Log$
|
|
40220
|
+
Log$g.debug('DevicePool state has been reset');
|
|
40038
40221
|
}
|
|
40039
40222
|
}
|
|
40040
40223
|
DevicePool.current = null;
|
|
@@ -40044,7 +40227,7 @@ DevicePool.disconnectPool = [];
|
|
|
40044
40227
|
DevicePool.devicesCache = {};
|
|
40045
40228
|
DevicePool.emitter = new events.exports();
|
|
40046
40229
|
|
|
40047
|
-
const Log$
|
|
40230
|
+
const Log$f = getLogger(exports.LoggerNames.Transport);
|
|
40048
40231
|
const BleLogger = getLogger(exports.LoggerNames.HdBleTransport);
|
|
40049
40232
|
const HttpLogger = getLogger(exports.LoggerNames.HdTransportHttp);
|
|
40050
40233
|
const LowLevelLogger = getLogger(exports.LoggerNames.HdTransportLowLevel);
|
|
@@ -40054,7 +40237,7 @@ const WebUsbLogger = getLogger(exports.LoggerNames.HdTransportWebUsb);
|
|
|
40054
40237
|
const REACT_NATIVE_BLE_SCAN_TIMEOUT_MS = 8000;
|
|
40055
40238
|
class TransportManager {
|
|
40056
40239
|
static load() {
|
|
40057
|
-
Log$
|
|
40240
|
+
Log$f.debug('transport manager load');
|
|
40058
40241
|
this.defaultMessages = DataManager.getProtobufMessages();
|
|
40059
40242
|
this.currentMessages = this.defaultMessages;
|
|
40060
40243
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
@@ -40063,14 +40246,14 @@ class TransportManager {
|
|
|
40063
40246
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40064
40247
|
try {
|
|
40065
40248
|
const env = DataManager.getSettings('env');
|
|
40066
|
-
Log$
|
|
40249
|
+
Log$f.debug('Initializing transports', env);
|
|
40067
40250
|
if (env === 'react-native') {
|
|
40068
40251
|
if (!this.reactNativeInit) {
|
|
40069
40252
|
yield this.transport.init(BleLogger, DevicePool.emitter);
|
|
40070
40253
|
this.reactNativeInit = true;
|
|
40071
40254
|
}
|
|
40072
40255
|
else {
|
|
40073
|
-
Log$
|
|
40256
|
+
Log$f.debug('React Native Do Not Initializing transports');
|
|
40074
40257
|
}
|
|
40075
40258
|
}
|
|
40076
40259
|
else if (env === 'node-usb') {
|
|
@@ -40091,15 +40274,15 @@ class TransportManager {
|
|
|
40091
40274
|
else {
|
|
40092
40275
|
yield this.transport.init(HttpLogger);
|
|
40093
40276
|
}
|
|
40094
|
-
Log$
|
|
40277
|
+
Log$f.debug('Configuring transports');
|
|
40095
40278
|
yield this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
40096
40279
|
this.currentMessages = this.defaultMessages;
|
|
40097
40280
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
40098
40281
|
yield this.configureProtocolV2Messages();
|
|
40099
|
-
Log$
|
|
40282
|
+
Log$f.debug('Configuring transports done');
|
|
40100
40283
|
}
|
|
40101
40284
|
catch (error) {
|
|
40102
|
-
Log$
|
|
40285
|
+
Log$f.debug('Initializing transports error: ', error);
|
|
40103
40286
|
if (error.code === 'ECONNABORTED') {
|
|
40104
40287
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError);
|
|
40105
40288
|
}
|
|
@@ -40115,7 +40298,7 @@ class TransportManager {
|
|
|
40115
40298
|
if (this.currentMessages === messages || !messages) {
|
|
40116
40299
|
return;
|
|
40117
40300
|
}
|
|
40118
|
-
Log$
|
|
40301
|
+
Log$f.debug(`Reconfiguring transports Protocol V1 schema:${protocolV1MessageSchema}`);
|
|
40119
40302
|
try {
|
|
40120
40303
|
yield this.transport.configure(JSON.stringify(messages));
|
|
40121
40304
|
this.currentMessages = messages;
|
|
@@ -40138,9 +40321,9 @@ class TransportManager {
|
|
|
40138
40321
|
}
|
|
40139
40322
|
if (plugin) {
|
|
40140
40323
|
this.plugin = plugin;
|
|
40141
|
-
Log$
|
|
40324
|
+
Log$f.debug('set transport plugin: ', this.plugin);
|
|
40142
40325
|
}
|
|
40143
|
-
Log$
|
|
40326
|
+
Log$f.debug('set transport: ', this.transport.name, this.transport.version, this.transport.configured);
|
|
40144
40327
|
}
|
|
40145
40328
|
static getTransport() {
|
|
40146
40329
|
return this.transport;
|
|
@@ -40151,7 +40334,7 @@ class TransportManager {
|
|
|
40151
40334
|
const { configureProtocolV2 } = this.transport;
|
|
40152
40335
|
if (protocolV2Messages && typeof configureProtocolV2 === 'function') {
|
|
40153
40336
|
yield configureProtocolV2.call(this.transport, JSON.stringify(protocolV2Messages));
|
|
40154
|
-
Log$
|
|
40337
|
+
Log$f.debug('Protocol V2 messages configured');
|
|
40155
40338
|
}
|
|
40156
40339
|
});
|
|
40157
40340
|
}
|
|
@@ -40329,7 +40512,7 @@ const cancelDeviceWithInitialize = (device) => {
|
|
|
40329
40512
|
},
|
|
40330
40513
|
}));
|
|
40331
40514
|
};
|
|
40332
|
-
const Log$
|
|
40515
|
+
const Log$e = getLogger(exports.LoggerNames.DeviceCommands);
|
|
40333
40516
|
const LogCore = getLogger(exports.LoggerNames.Core);
|
|
40334
40517
|
class DeviceCommands {
|
|
40335
40518
|
constructor(device, mainId) {
|
|
@@ -40338,7 +40521,7 @@ class DeviceCommands {
|
|
|
40338
40521
|
this.transport = TransportManager.getTransport();
|
|
40339
40522
|
this.disposed = false;
|
|
40340
40523
|
this.instanceId = generateInstanceId('DeviceCommands', device.sdkInstanceId);
|
|
40341
|
-
Log$
|
|
40524
|
+
Log$e.debug(`[DeviceCommands] Created: ${this.instanceId}, device: ${this.device.instanceId}`);
|
|
40342
40525
|
}
|
|
40343
40526
|
dispose(_cancelRequest) {
|
|
40344
40527
|
var _a, _b;
|
|
@@ -40408,7 +40591,7 @@ class DeviceCommands {
|
|
|
40408
40591
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40409
40592
|
const shouldReduceDebug = shouldReduceDebugForCall(type);
|
|
40410
40593
|
if (!shouldReduceDebug) {
|
|
40411
|
-
Log$
|
|
40594
|
+
Log$e.debug('[DeviceCommands] [call] Sending', type);
|
|
40412
40595
|
}
|
|
40413
40596
|
try {
|
|
40414
40597
|
const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
|
|
@@ -40443,7 +40626,7 @@ class DeviceCommands {
|
|
|
40443
40626
|
}
|
|
40444
40627
|
}
|
|
40445
40628
|
if (responseData) {
|
|
40446
|
-
Log$
|
|
40629
|
+
Log$e.debug('error response', responseData);
|
|
40447
40630
|
}
|
|
40448
40631
|
if (responseError === 'device disconnected during action') {
|
|
40449
40632
|
return { type: 'BridgeDeviceDisconnected', message: { error: responseError } };
|
|
@@ -40483,7 +40666,7 @@ class DeviceCommands {
|
|
|
40483
40666
|
'ResourceAck',
|
|
40484
40667
|
];
|
|
40485
40668
|
if (!skipTypes.includes(type) && msg) {
|
|
40486
|
-
Log$
|
|
40669
|
+
Log$e.debug('[DeviceCommands] [typedCall] Sending payload', type, sanitizeDebugPayload(msg));
|
|
40487
40670
|
}
|
|
40488
40671
|
}
|
|
40489
40672
|
catch (e) {
|
|
@@ -40494,10 +40677,10 @@ class DeviceCommands {
|
|
|
40494
40677
|
assertType(response, resType);
|
|
40495
40678
|
}
|
|
40496
40679
|
catch (error) {
|
|
40497
|
-
Log$
|
|
40680
|
+
Log$e.debug('DeviceCommands typedcall error: ', error);
|
|
40498
40681
|
if (error instanceof hdShared.HardwareError) {
|
|
40499
40682
|
if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
40500
|
-
Log$
|
|
40683
|
+
Log$e.debug('[DeviceCommands] [typedCall] Unexpected response type', {
|
|
40501
40684
|
request: type,
|
|
40502
40685
|
expected: resType,
|
|
40503
40686
|
received: response.type,
|
|
@@ -40533,17 +40716,17 @@ class DeviceCommands {
|
|
|
40533
40716
|
if (shouldReduceDebugForCall(callType)) {
|
|
40534
40717
|
}
|
|
40535
40718
|
else if (DataManager.getSettings('env') === 'react-native') {
|
|
40536
|
-
Log$
|
|
40719
|
+
Log$e.debug('_filterCommonTypes: ', JSON.stringify(sanitizeDebugPayload(res)));
|
|
40537
40720
|
}
|
|
40538
40721
|
else {
|
|
40539
|
-
Log$
|
|
40722
|
+
Log$e.debug('_filterCommonTypes: ', sanitizeDebugPayload(res));
|
|
40540
40723
|
}
|
|
40541
40724
|
}
|
|
40542
40725
|
catch (error) {
|
|
40543
40726
|
}
|
|
40544
40727
|
this.device.clearCancelableAction();
|
|
40545
40728
|
if (res.type === 'Failure') {
|
|
40546
|
-
const { code, message } = res.message;
|
|
40729
|
+
const { code, subcode, message } = res.message;
|
|
40547
40730
|
let error = null;
|
|
40548
40731
|
if (code === 'Failure_FirmwareError' && !message) {
|
|
40549
40732
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError);
|
|
@@ -40578,7 +40761,14 @@ class DeviceCommands {
|
|
|
40578
40761
|
}
|
|
40579
40762
|
}
|
|
40580
40763
|
if (code === 'Failure_ProcessError') {
|
|
40581
|
-
if (
|
|
40764
|
+
if (subcode === 9) {
|
|
40765
|
+
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceLocked, message, {
|
|
40766
|
+
failureCode: code,
|
|
40767
|
+
subcode,
|
|
40768
|
+
firmwareMessage: message,
|
|
40769
|
+
});
|
|
40770
|
+
}
|
|
40771
|
+
else if ((message === null || message === void 0 ? void 0 : message.includes('Bootloader file verify failed')) ||
|
|
40582
40772
|
(message === null || message === void 0 ? void 0 : message.includes('verify failed'))) {
|
|
40583
40773
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, message);
|
|
40584
40774
|
}
|
|
@@ -40665,7 +40855,7 @@ class DeviceCommands {
|
|
|
40665
40855
|
reject(error);
|
|
40666
40856
|
});
|
|
40667
40857
|
const listenerCount = this.device.listenerCount(DEVICE.PIN);
|
|
40668
|
-
Log$
|
|
40858
|
+
Log$e.debug(`[${this.instanceId}] _promptPin called`, {
|
|
40669
40859
|
responseID: this.currentResponseID,
|
|
40670
40860
|
deviceInstanceId: this.device.instanceId,
|
|
40671
40861
|
listenerCount,
|
|
@@ -41382,7 +41572,7 @@ const parseRunOptions = (options) => {
|
|
|
41382
41572
|
options = {};
|
|
41383
41573
|
return options;
|
|
41384
41574
|
};
|
|
41385
|
-
const Log$
|
|
41575
|
+
const Log$d = getLogger(exports.LoggerNames.Device);
|
|
41386
41576
|
function preloadSessionCache(deviceId, passphraseState, sessionId) {
|
|
41387
41577
|
deviceWalletSessionStore.set(deviceId, passphraseState, sessionId);
|
|
41388
41578
|
}
|
|
@@ -41404,7 +41594,7 @@ class Device extends events.exports {
|
|
|
41404
41594
|
this.sdkInstanceId = sdkInstanceId;
|
|
41405
41595
|
this.instanceId = generateInstanceId('Device', this.sdkInstanceId);
|
|
41406
41596
|
this.createdAt = Date.now();
|
|
41407
|
-
Log$
|
|
41597
|
+
Log$d.debug(`[Device] Created: ${this.instanceId}${this.sdkInstanceId ? ` for SDK: ${this.sdkInstanceId}` : ''}`);
|
|
41408
41598
|
}
|
|
41409
41599
|
static fromDescriptor(originalDescriptor, sdkInstanceId) {
|
|
41410
41600
|
const descriptor = Object.assign({}, originalDescriptor);
|
|
@@ -41484,12 +41674,12 @@ class Device extends events.exports {
|
|
|
41484
41674
|
if (DataManager.isBleConnect(env)) {
|
|
41485
41675
|
acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, expectedProtocol));
|
|
41486
41676
|
this.mainId = (_b = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.uuid) !== null && _b !== void 0 ? _b : '';
|
|
41487
|
-
Log$
|
|
41677
|
+
Log$d.debug('Expected uuid:', this.mainId);
|
|
41488
41678
|
}
|
|
41489
41679
|
else {
|
|
41490
41680
|
acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, expectedProtocol));
|
|
41491
41681
|
this.mainId = acquireResult;
|
|
41492
|
-
Log$
|
|
41682
|
+
Log$d.debug('Expected session id:', this.mainId);
|
|
41493
41683
|
}
|
|
41494
41684
|
this.deviceAcquired = true;
|
|
41495
41685
|
this.updateDescriptor({ [mainIdKey]: this.mainId });
|
|
@@ -41524,11 +41714,11 @@ class Device extends events.exports {
|
|
|
41524
41714
|
(this.mainId && DataManager.isBleConnect(env))) {
|
|
41525
41715
|
if (this.pendingCallbackPromise) {
|
|
41526
41716
|
try {
|
|
41527
|
-
Log$
|
|
41717
|
+
Log$d.debug('Waiting for callback tasks to complete before releasing device (in release method)');
|
|
41528
41718
|
yield this.pendingCallbackPromise.promise;
|
|
41529
41719
|
}
|
|
41530
41720
|
catch (error) {
|
|
41531
|
-
Log$
|
|
41721
|
+
Log$d.error('Error waiting for callback tasks in release method:', error);
|
|
41532
41722
|
}
|
|
41533
41723
|
}
|
|
41534
41724
|
if (this.commands) {
|
|
@@ -41547,7 +41737,7 @@ class Device extends events.exports {
|
|
|
41547
41737
|
this.updateDescriptor({ session: null });
|
|
41548
41738
|
}
|
|
41549
41739
|
catch (err) {
|
|
41550
|
-
Log$
|
|
41740
|
+
Log$d.error('[Device] release error: ', err);
|
|
41551
41741
|
}
|
|
41552
41742
|
finally {
|
|
41553
41743
|
this.needReloadDevice = true;
|
|
@@ -41722,7 +41912,7 @@ class Device extends events.exports {
|
|
|
41722
41912
|
}
|
|
41723
41913
|
getInternalState(_deviceId) {
|
|
41724
41914
|
var _a;
|
|
41725
|
-
Log$
|
|
41915
|
+
Log$d.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `passphraseState: ${this.passphraseState}`);
|
|
41726
41916
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
41727
41917
|
if (!deviceId)
|
|
41728
41918
|
return undefined;
|
|
@@ -41731,7 +41921,7 @@ class Device extends events.exports {
|
|
|
41731
41921
|
return deviceWalletSessionStore.get(deviceId, this.passphraseState);
|
|
41732
41922
|
}
|
|
41733
41923
|
updateInternalState(enablePassphrase, passphraseState, deviceId, sessionId = null, featuresSessionId = null) {
|
|
41734
|
-
Log$
|
|
41924
|
+
Log$d.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `passphraseState: ${passphraseState}`, `hasSessionId: ${Boolean(sessionId)}`, `hasFeaturesSessionId: ${Boolean(featuresSessionId)}`);
|
|
41735
41925
|
const cacheDeviceKey = this.getSessionCacheDeviceKey(deviceId);
|
|
41736
41926
|
if (!cacheDeviceKey)
|
|
41737
41927
|
return;
|
|
@@ -41743,7 +41933,7 @@ class Device extends events.exports {
|
|
|
41743
41933
|
}
|
|
41744
41934
|
setInternalState(state, initSession) {
|
|
41745
41935
|
var _a;
|
|
41746
|
-
Log$
|
|
41936
|
+
Log$d.debug('setInternalState session param: ', `hasState: ${Boolean(state)}`, `initSession: ${initSession}`, `deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `passphraseState: ${this.passphraseState}`);
|
|
41747
41937
|
if (!this.passphraseState && !initSession)
|
|
41748
41938
|
return;
|
|
41749
41939
|
const deviceId = this.getSessionCacheDeviceKey();
|
|
@@ -41757,7 +41947,7 @@ class Device extends events.exports {
|
|
|
41757
41947
|
}
|
|
41758
41948
|
}
|
|
41759
41949
|
clearInternalState(_deviceId) {
|
|
41760
|
-
Log$
|
|
41950
|
+
Log$d.debug('clearInternalState param: ', _deviceId);
|
|
41761
41951
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
41762
41952
|
if (!deviceId)
|
|
41763
41953
|
return;
|
|
@@ -41810,25 +42000,25 @@ class Device extends events.exports {
|
|
|
41810
42000
|
yield TransportManager.reconfigure(this.features);
|
|
41811
42001
|
}
|
|
41812
42002
|
catch (error) {
|
|
41813
|
-
Log$
|
|
42003
|
+
Log$d.error('Initialization failed:', error);
|
|
41814
42004
|
throw error;
|
|
41815
42005
|
}
|
|
41816
42006
|
});
|
|
41817
42007
|
}
|
|
41818
42008
|
_initializeProtocolV2(options) {
|
|
41819
42009
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41820
|
-
Log$
|
|
42010
|
+
Log$d.debug('Initialize device via Protocol V2 features adapter');
|
|
41821
42011
|
try {
|
|
41822
42012
|
const deviceInfo = yield requestProtocolV2DeviceInfo({
|
|
41823
42013
|
commands: this.commands,
|
|
41824
42014
|
timeoutMs: options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs,
|
|
41825
42015
|
});
|
|
41826
42016
|
const features = this.updateProtocolV2Features(deviceInfo);
|
|
41827
|
-
Log$
|
|
42017
|
+
Log$d.debug('Protocol V2 features:', features);
|
|
41828
42018
|
this.featuresNeedsReload = false;
|
|
41829
42019
|
}
|
|
41830
42020
|
catch (error) {
|
|
41831
|
-
Log$
|
|
42021
|
+
Log$d.error('Protocol V2 initialization failed:', error);
|
|
41832
42022
|
throw error;
|
|
41833
42023
|
}
|
|
41834
42024
|
});
|
|
@@ -41842,10 +42032,10 @@ class Device extends events.exports {
|
|
|
41842
42032
|
timeoutMs: options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs,
|
|
41843
42033
|
});
|
|
41844
42034
|
const features = this.updateProtocolV2Features(deviceInfo);
|
|
41845
|
-
Log$
|
|
42035
|
+
Log$d.debug('Protocol V2 features (status refresh):', features);
|
|
41846
42036
|
}
|
|
41847
42037
|
catch (error) {
|
|
41848
|
-
Log$
|
|
42038
|
+
Log$d.error('Protocol V2 status refresh failed:', error);
|
|
41849
42039
|
throw error;
|
|
41850
42040
|
}
|
|
41851
42041
|
});
|
|
@@ -41930,7 +42120,7 @@ class Device extends events.exports {
|
|
|
41930
42120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41931
42121
|
if (this.runPromise) {
|
|
41932
42122
|
yield this.interruptionFromOutside();
|
|
41933
|
-
Log$
|
|
42123
|
+
Log$d.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
41934
42124
|
}
|
|
41935
42125
|
options = parseRunOptions(options);
|
|
41936
42126
|
this.runPromise = hdShared.createDeferred(this._runInner.bind(this, fn, options));
|
|
@@ -41988,7 +42178,7 @@ class Device extends events.exports {
|
|
|
41988
42178
|
yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
|
|
41989
42179
|
}
|
|
41990
42180
|
yield this.release();
|
|
41991
|
-
Log$
|
|
42181
|
+
Log$d.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
41992
42182
|
}
|
|
41993
42183
|
this.runPromise = null;
|
|
41994
42184
|
return;
|
|
@@ -41998,7 +42188,7 @@ class Device extends events.exports {
|
|
|
41998
42188
|
options.keepSession === false) {
|
|
41999
42189
|
this.keepSession = false;
|
|
42000
42190
|
yield this.release();
|
|
42001
|
-
Log$
|
|
42191
|
+
Log$d.debug('release device, mainId: ', this.mainId);
|
|
42002
42192
|
}
|
|
42003
42193
|
if (this.runPromise) {
|
|
42004
42194
|
this.runPromise.resolve();
|
|
@@ -42031,7 +42221,7 @@ class Device extends events.exports {
|
|
|
42031
42221
|
setCancelableAction(callback) {
|
|
42032
42222
|
this.cancelableAction = (e) => callback(e)
|
|
42033
42223
|
.catch(e2 => {
|
|
42034
|
-
Log$
|
|
42224
|
+
Log$d.debug('cancelableAction error', e2);
|
|
42035
42225
|
})
|
|
42036
42226
|
.finally(() => {
|
|
42037
42227
|
this.clearCancelableAction();
|
|
@@ -42143,8 +42333,9 @@ class Device extends events.exports {
|
|
|
42143
42333
|
var _a, _b, _c;
|
|
42144
42334
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42145
42335
|
if (this.isProtocolV2()) {
|
|
42336
|
+
let pinResult;
|
|
42146
42337
|
try {
|
|
42147
|
-
yield this.commands.typedCall('DeviceSessionAskPin', 'DeviceSessionPinResult');
|
|
42338
|
+
({ message: pinResult } = yield this.commands.typedCall('DeviceSessionAskPin', 'DeviceSessionPinResult'));
|
|
42148
42339
|
}
|
|
42149
42340
|
catch (error) {
|
|
42150
42341
|
const errorText = error instanceof Error
|
|
@@ -42155,7 +42346,17 @@ class Device extends events.exports {
|
|
|
42155
42346
|
}
|
|
42156
42347
|
throw error;
|
|
42157
42348
|
}
|
|
42158
|
-
|
|
42349
|
+
const status = {};
|
|
42350
|
+
if (pinResult.unlocked != null) {
|
|
42351
|
+
status.unlocked = pinResult.unlocked;
|
|
42352
|
+
}
|
|
42353
|
+
if (pinResult.unlocked_attach_pin != null) {
|
|
42354
|
+
status.unlocked_by_attach_to_pin = pinResult.unlocked_attach_pin;
|
|
42355
|
+
}
|
|
42356
|
+
if (pinResult.passphrase_protection != null) {
|
|
42357
|
+
status.passphrase_enabled = pinResult.passphrase_protection;
|
|
42358
|
+
}
|
|
42359
|
+
return this.updateProtocolV2Status(status);
|
|
42159
42360
|
}
|
|
42160
42361
|
const firmwareVersion = (_c = this.getCurrentFirmwareVersionString()) !== null && _c !== void 0 ? _c : '0.0.0';
|
|
42161
42362
|
const versionRange = this.getCurrentMethodVersionRange(type => this.supportUnlockVersionRange()[type]);
|
|
@@ -42201,7 +42402,7 @@ class Device extends events.exports {
|
|
|
42201
42402
|
const mainWalletUseAttachPin = unlockedAttachPin && useEmptyPassphrase;
|
|
42202
42403
|
const useErrorAttachPin = unlockedAttachPin && passphraseState && passphraseState !== newPassphraseState;
|
|
42203
42404
|
const passphraseStateMismatch = !!passphraseState && passphraseState !== newPassphraseState;
|
|
42204
|
-
Log$
|
|
42405
|
+
Log$d.debug('Check passphrase state safety: ', {
|
|
42205
42406
|
passphraseState,
|
|
42206
42407
|
newPassphraseState,
|
|
42207
42408
|
unlockedAttachPin,
|
|
@@ -42329,7 +42530,7 @@ const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwar
|
|
|
42329
42530
|
};
|
|
42330
42531
|
};
|
|
42331
42532
|
|
|
42332
|
-
const Log$
|
|
42533
|
+
const Log$c = getLogger(exports.LoggerNames.Method);
|
|
42333
42534
|
const isEvmLedgerLegacyPathWithHighIndex = (path) => {
|
|
42334
42535
|
let addressN;
|
|
42335
42536
|
if (typeof path === 'string') {
|
|
@@ -42362,6 +42563,12 @@ class BaseMethod {
|
|
|
42362
42563
|
this.name,
|
|
42363
42564
|
].join('|');
|
|
42364
42565
|
}
|
|
42566
|
+
throwIfAborted() {
|
|
42567
|
+
var _a;
|
|
42568
|
+
if ((_a = this.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
42569
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled, 'Hardware operation cancelled');
|
|
42570
|
+
}
|
|
42571
|
+
}
|
|
42365
42572
|
constructor(message) {
|
|
42366
42573
|
this.shouldEnsureConnected = true;
|
|
42367
42574
|
this.checkDeviceId = false;
|
|
@@ -42372,6 +42579,7 @@ class BaseMethod {
|
|
|
42372
42579
|
this.preWarmTtl = 60 * 1000;
|
|
42373
42580
|
this.strictCheckDeviceSupport = false;
|
|
42374
42581
|
this.requireProtocolV2 = false;
|
|
42582
|
+
this.unlockPolicy = 'none';
|
|
42375
42583
|
this.temporarySafetyCheckPrompted = false;
|
|
42376
42584
|
this.postPreviousAddressMessage = (data) => {
|
|
42377
42585
|
this.postMessage(createUiMessage(UI_REQUEST.PREVIOUS_ADDRESS_RESULT, {
|
|
@@ -42395,7 +42603,7 @@ class BaseMethod {
|
|
|
42395
42603
|
setContext(context) {
|
|
42396
42604
|
this.sdkInstanceId = context.sdkInstanceId;
|
|
42397
42605
|
this.instanceId = generateInstanceId('Method', this.sdkInstanceId);
|
|
42398
|
-
Log$
|
|
42606
|
+
Log$c.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
|
|
42399
42607
|
}
|
|
42400
42608
|
setDevice(device) {
|
|
42401
42609
|
var _a, _b;
|
|
@@ -42415,7 +42623,7 @@ class BaseMethod {
|
|
|
42415
42623
|
if (device.commands) {
|
|
42416
42624
|
device.commands.currentResponseID = this.responseID;
|
|
42417
42625
|
}
|
|
42418
|
-
Log$
|
|
42626
|
+
Log$c.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
|
|
42419
42627
|
}
|
|
42420
42628
|
checkFirmwareRelease() {
|
|
42421
42629
|
if (!this.device || this.device.isProtocolV2())
|
|
@@ -42493,7 +42701,7 @@ class BaseMethod {
|
|
|
42493
42701
|
checkFlag = true;
|
|
42494
42702
|
}
|
|
42495
42703
|
if (checkFlag && this.device.getCurrentSafetyChecks() === 'Strict') {
|
|
42496
|
-
Log$
|
|
42704
|
+
Log$c.debug('will change safety_checks level');
|
|
42497
42705
|
yield this.device.commands.typedCall('ApplySettings', 'Success', {
|
|
42498
42706
|
safety_checks: 'PromptTemporarily',
|
|
42499
42707
|
});
|
|
@@ -42527,7 +42735,7 @@ class TestInitializeDeviceDuration extends BaseMethod {
|
|
|
42527
42735
|
}
|
|
42528
42736
|
}
|
|
42529
42737
|
|
|
42530
|
-
const Log$
|
|
42738
|
+
const Log$b = getLogger(exports.LoggerNames.Core);
|
|
42531
42739
|
const parseInitOptions$1 = (payload) => ({
|
|
42532
42740
|
initSession: payload === null || payload === void 0 ? void 0 : payload.initSession,
|
|
42533
42741
|
passphraseState: payload === null || payload === void 0 ? void 0 : payload.passphraseState,
|
|
@@ -42550,7 +42758,7 @@ class PreInitialize extends BaseMethod {
|
|
|
42550
42758
|
}
|
|
42551
42759
|
catch (_a) {
|
|
42552
42760
|
this.device.clearPreInitialized();
|
|
42553
|
-
Log$
|
|
42761
|
+
Log$b.debug('[PRE-INIT][FAILED]');
|
|
42554
42762
|
return false;
|
|
42555
42763
|
}
|
|
42556
42764
|
});
|
|
@@ -42836,26 +43044,16 @@ class GetPassphraseState extends BaseMethod {
|
|
|
42836
43044
|
this.useDevicePassphraseState = false;
|
|
42837
43045
|
}
|
|
42838
43046
|
run() {
|
|
42839
|
-
var _a, _b;
|
|
42840
43047
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42841
|
-
const { passphraseState
|
|
43048
|
+
const { passphraseState } = yield getPassphraseStateWithRefreshDeviceInfo(this.device, {
|
|
42842
43049
|
expectPassphraseState: this.payload.passphraseState,
|
|
42843
43050
|
onlyMainPin: this.payload.useEmptyPassphrase,
|
|
42844
|
-
allowCreateAttachPin: this.payload.allowCreateAttachPin,
|
|
42845
43051
|
initSession: this.payload.initSession,
|
|
42846
43052
|
});
|
|
42847
|
-
const
|
|
42848
|
-
const passphraseProtection = (_a = this.device.getCurrentPassphraseProtection()) !== null && _a !== void 0 ? _a : null;
|
|
43053
|
+
const passphraseProtection = this.device.getCurrentPassphraseProtection();
|
|
42849
43054
|
const deviceType = this.device.getCurrentDeviceType();
|
|
42850
43055
|
const isProSeries = deviceType === hdShared.EDeviceType.Pro || deviceType === hdShared.EDeviceType.Pro2;
|
|
42851
|
-
return Promise.resolve(
|
|
42852
|
-
passphraseState: isProSeries || passphraseProtection === true ? passphraseState : undefined,
|
|
42853
|
-
sessionId: this.payload.initSession
|
|
42854
|
-
? newSession !== null && newSession !== void 0 ? newSession : undefined
|
|
42855
|
-
: (_b = newSession !== null && newSession !== void 0 ? newSession : features === null || features === void 0 ? void 0 : features.sessionId) !== null && _b !== void 0 ? _b : undefined,
|
|
42856
|
-
unlockedAttachPin: unlockedAttachPin !== null && unlockedAttachPin !== void 0 ? unlockedAttachPin : features === null || features === void 0 ? void 0 : features.unlockedAttachPin,
|
|
42857
|
-
passphraseProtection,
|
|
42858
|
-
});
|
|
43056
|
+
return Promise.resolve(isProSeries || passphraseProtection === true ? passphraseState : undefined);
|
|
42859
43057
|
});
|
|
42860
43058
|
}
|
|
42861
43059
|
}
|
|
@@ -43882,7 +44080,7 @@ const getInfo = ({ features, updateType, targetVersion, firmwareType }) => {
|
|
|
43882
44080
|
const NEW_BOOT_UPRATE_FIRMWARE_VERSION = '2.4.5';
|
|
43883
44081
|
const SESSION_ERROR$2 = 'session not found';
|
|
43884
44082
|
const FIRMWARE_UPDATE_CONFIRM$1 = 'Firmware install confirmed';
|
|
43885
|
-
const Log$
|
|
44083
|
+
const Log$a = getLogger(exports.LoggerNames.Method);
|
|
43886
44084
|
const isDeviceDisconnectedError$1 = (error) => {
|
|
43887
44085
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
43888
44086
|
return (message.includes('device was disconnected') ||
|
|
@@ -43931,13 +44129,13 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
|
|
|
43931
44129
|
const newFeatures = yield typedCall('GetFeatures', 'Features', {});
|
|
43932
44130
|
const deviceBootloaderVersion = getDeviceBootloaderVersion(buildProtocolV1FeaturesPayload(newFeatures.message, device.features)).join('.');
|
|
43933
44131
|
const supportUpgradeFileHeader = semver__default["default"].gte(deviceBootloaderVersion, '2.1.0');
|
|
43934
|
-
Log$
|
|
44132
|
+
Log$a.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
|
|
43935
44133
|
if (supportUpgradeFileHeader) {
|
|
43936
44134
|
const HEADER_SIZE = 1024;
|
|
43937
44135
|
if (payload.byteLength < HEADER_SIZE) {
|
|
43938
44136
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${payload.byteLength} bytes, expected at least ${HEADER_SIZE} bytes`);
|
|
43939
44137
|
}
|
|
43940
|
-
Log$
|
|
44138
|
+
Log$a.debug('Uploading firmware header:', {
|
|
43941
44139
|
size: HEADER_SIZE,
|
|
43942
44140
|
totalSize: payload.byteLength,
|
|
43943
44141
|
});
|
|
@@ -43949,18 +44147,18 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
|
|
|
43949
44147
|
});
|
|
43950
44148
|
const isUnknownMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage');
|
|
43951
44149
|
if (headerRes.type !== 'Success' && !isUnknownMessage) {
|
|
43952
|
-
Log$
|
|
44150
|
+
Log$a.error('Firmware header upload failed:', headerRes);
|
|
43953
44151
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
|
|
43954
44152
|
}
|
|
43955
44153
|
}
|
|
43956
44154
|
catch (error) {
|
|
43957
|
-
Log$
|
|
44155
|
+
Log$a.error('Firmware header upload failed:', error);
|
|
43958
44156
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
43959
44157
|
if (!message.includes('Failure_UnknownMessage')) {
|
|
43960
44158
|
throw error;
|
|
43961
44159
|
}
|
|
43962
44160
|
}
|
|
43963
|
-
Log$
|
|
44161
|
+
Log$a.debug('Firmware header uploaded successfully');
|
|
43964
44162
|
}
|
|
43965
44163
|
}
|
|
43966
44164
|
const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
|
|
@@ -43978,7 +44176,7 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
|
|
|
43978
44176
|
}
|
|
43979
44177
|
catch (error) {
|
|
43980
44178
|
if (isDeviceDisconnectedError$1(error)) {
|
|
43981
|
-
Log$
|
|
44179
|
+
Log$a.log('Rebooting device');
|
|
43982
44180
|
updateResponse = {
|
|
43983
44181
|
type: 'Success',
|
|
43984
44182
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -44064,7 +44262,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
|
|
|
44064
44262
|
}
|
|
44065
44263
|
catch (error) {
|
|
44066
44264
|
if (isDeviceDisconnectedError$1(error)) {
|
|
44067
|
-
Log$
|
|
44265
|
+
Log$a.log('Rebooting device');
|
|
44068
44266
|
response = {
|
|
44069
44267
|
type: 'Success',
|
|
44070
44268
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -44095,7 +44293,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
|
|
|
44095
44293
|
]);
|
|
44096
44294
|
}
|
|
44097
44295
|
catch (e) {
|
|
44098
|
-
Log$
|
|
44296
|
+
Log$a.log('catch Bluetooth error when device is restarting: ', e);
|
|
44099
44297
|
}
|
|
44100
44298
|
}
|
|
44101
44299
|
else {
|
|
@@ -44116,7 +44314,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
|
|
|
44116
44314
|
}
|
|
44117
44315
|
catch (error) {
|
|
44118
44316
|
console.error('Device reconnect failed: ', error);
|
|
44119
|
-
Log$
|
|
44317
|
+
Log$a.error('Device reconnect failed:', error);
|
|
44120
44318
|
yield wait(1000);
|
|
44121
44319
|
}
|
|
44122
44320
|
}
|
|
@@ -44156,7 +44354,7 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
|
|
|
44156
44354
|
return result;
|
|
44157
44355
|
}
|
|
44158
44356
|
catch (error) {
|
|
44159
|
-
Log$
|
|
44357
|
+
Log$a.error(`emmcWrite error: `, error);
|
|
44160
44358
|
retryCount--;
|
|
44161
44359
|
if (retryCount === 0) {
|
|
44162
44360
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -44327,7 +44525,7 @@ const createFirmwareProgressThrottle = (intervalMs = DEFAULT_FIRMWARE_PROGRESS_I
|
|
|
44327
44525
|
};
|
|
44328
44526
|
};
|
|
44329
44527
|
|
|
44330
|
-
const Log$
|
|
44528
|
+
const Log$9 = getLogger(exports.LoggerNames.Method);
|
|
44331
44529
|
const SESSION_ERROR$1 = 'session not found';
|
|
44332
44530
|
const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
44333
44531
|
const isDeviceDisconnectedError = (error) => {
|
|
@@ -44410,7 +44608,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
44410
44608
|
this.checkPromise = hdShared.createDeferred();
|
|
44411
44609
|
const env = DataManager.getSettings('env');
|
|
44412
44610
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
44413
|
-
Log$
|
|
44611
|
+
Log$9.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
44414
44612
|
let isFirstCheck = true;
|
|
44415
44613
|
let checkCount = 0;
|
|
44416
44614
|
let hasPromptedWebDevice = false;
|
|
@@ -44421,10 +44619,10 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
44421
44619
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
44422
44620
|
var _c, _d, _e;
|
|
44423
44621
|
checkCount += 1;
|
|
44424
|
-
Log$
|
|
44622
|
+
Log$9.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
44425
44623
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
44426
44624
|
isFirstCheck = false;
|
|
44427
|
-
Log$
|
|
44625
|
+
Log$9.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] wait 3000ms');
|
|
44428
44626
|
yield wait(3000);
|
|
44429
44627
|
}
|
|
44430
44628
|
if (checkCount > 4 &&
|
|
@@ -44444,7 +44642,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
44444
44642
|
catch (e) {
|
|
44445
44643
|
clearInterval(intervalTimer);
|
|
44446
44644
|
clearTimeout(timeoutTimer);
|
|
44447
|
-
Log$
|
|
44645
|
+
Log$9.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
44448
44646
|
(_c = this.checkPromise) === null || _c === void 0 ? void 0 : _c.reject(e);
|
|
44449
44647
|
}
|
|
44450
44648
|
finally {
|
|
@@ -44462,7 +44660,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
44462
44660
|
}
|
|
44463
44661
|
}
|
|
44464
44662
|
catch (e) {
|
|
44465
|
-
Log$
|
|
44663
|
+
Log$9.log('catch Bluetooth error when device is restarting: ', e);
|
|
44466
44664
|
}
|
|
44467
44665
|
}
|
|
44468
44666
|
else {
|
|
@@ -44543,7 +44741,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
44543
44741
|
}
|
|
44544
44742
|
catch (error) {
|
|
44545
44743
|
if (isDeviceDisconnectedError(error)) {
|
|
44546
|
-
Log$
|
|
44744
|
+
Log$9.log('Rebooting device');
|
|
44547
44745
|
updateResponse = {
|
|
44548
44746
|
type: 'Success',
|
|
44549
44747
|
message: { message: FIRMWARE_UPDATE_CONFIRM },
|
|
@@ -44633,7 +44831,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
44633
44831
|
return result;
|
|
44634
44832
|
}
|
|
44635
44833
|
catch (error) {
|
|
44636
|
-
Log$
|
|
44834
|
+
Log$9.error(`emmcWrite error: `, error);
|
|
44637
44835
|
retryCount--;
|
|
44638
44836
|
if (retryCount === 0) {
|
|
44639
44837
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -44811,7 +45009,7 @@ class GetNextU2FCounter extends BaseMethod {
|
|
|
44811
45009
|
}
|
|
44812
45010
|
}
|
|
44813
45011
|
|
|
44814
|
-
const Log$
|
|
45012
|
+
const Log$8 = getLogger(exports.LoggerNames.Method);
|
|
44815
45013
|
class FirmwareUpdate extends BaseMethod {
|
|
44816
45014
|
constructor() {
|
|
44817
45015
|
super(...arguments);
|
|
@@ -44849,7 +45047,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
44849
45047
|
this.checkPromise = hdShared.createDeferred();
|
|
44850
45048
|
const env = DataManager.getSettings('env');
|
|
44851
45049
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
44852
|
-
Log$
|
|
45050
|
+
Log$8.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
44853
45051
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
44854
45052
|
var _a, _b, _c, _d, _e, _f;
|
|
44855
45053
|
if (isBleReconnect) {
|
|
@@ -44862,7 +45060,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
44862
45060
|
}
|
|
44863
45061
|
}
|
|
44864
45062
|
catch (e) {
|
|
44865
|
-
Log$
|
|
45063
|
+
Log$8.log('catch Bluetooth error when device is restarting: ', e);
|
|
44866
45064
|
}
|
|
44867
45065
|
}
|
|
44868
45066
|
else {
|
|
@@ -44919,7 +45117,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
44919
45117
|
if (e instanceof hdShared.HardwareError) {
|
|
44920
45118
|
return Promise.reject(e);
|
|
44921
45119
|
}
|
|
44922
|
-
Log$
|
|
45120
|
+
Log$8.log('auto go to bootloader mode failed: ', e);
|
|
44923
45121
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure));
|
|
44924
45122
|
}
|
|
44925
45123
|
}
|
|
@@ -44956,7 +45154,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
44956
45154
|
}
|
|
44957
45155
|
}
|
|
44958
45156
|
|
|
44959
|
-
const Log$
|
|
45157
|
+
const Log$7 = getLogger(exports.LoggerNames.Method);
|
|
44960
45158
|
class FirmwareUpdateV2 extends BaseMethod {
|
|
44961
45159
|
constructor() {
|
|
44962
45160
|
super(...arguments);
|
|
@@ -45019,7 +45217,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
45019
45217
|
this.checkPromise = hdShared.createDeferred();
|
|
45020
45218
|
const env = DataManager.getSettings('env');
|
|
45021
45219
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
45022
|
-
Log$
|
|
45220
|
+
Log$7.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
45023
45221
|
let isFirstCheck = true;
|
|
45024
45222
|
let checkCount = 0;
|
|
45025
45223
|
let timeoutTimer;
|
|
@@ -45028,10 +45226,10 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
45028
45226
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
45029
45227
|
var _b, _c, _d;
|
|
45030
45228
|
checkCount += 1;
|
|
45031
|
-
Log$
|
|
45229
|
+
Log$7.log('FirmwareUpdateV2 [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
45032
45230
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
45033
45231
|
isFirstCheck = false;
|
|
45034
|
-
Log$
|
|
45232
|
+
Log$7.log('FirmwareUpdateV2 [checkDeviceToBootloader] wait 3000ms');
|
|
45035
45233
|
yield wait(3000);
|
|
45036
45234
|
}
|
|
45037
45235
|
if (checkCount > 4 &&
|
|
@@ -45047,7 +45245,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
45047
45245
|
}
|
|
45048
45246
|
}
|
|
45049
45247
|
catch (e) {
|
|
45050
|
-
Log$
|
|
45248
|
+
Log$7.log('FirmwareUpdateV2 [checkDeviceToBootloader] promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
45051
45249
|
(_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.reject(e);
|
|
45052
45250
|
}
|
|
45053
45251
|
return;
|
|
@@ -45062,7 +45260,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
45062
45260
|
}
|
|
45063
45261
|
}
|
|
45064
45262
|
catch (e) {
|
|
45065
|
-
Log$
|
|
45263
|
+
Log$7.log('catch Bluetooth error when device is restarting: ', e);
|
|
45066
45264
|
}
|
|
45067
45265
|
}
|
|
45068
45266
|
else {
|
|
@@ -45229,7 +45427,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
45229
45427
|
}
|
|
45230
45428
|
}
|
|
45231
45429
|
|
|
45232
|
-
const Log$
|
|
45430
|
+
const Log$6 = getLogger(exports.LoggerNames.Method);
|
|
45233
45431
|
const MIN_UPDATE_V3_BOOTLOADER_VERSION = '2.8.0';
|
|
45234
45432
|
class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
45235
45433
|
constructor() {
|
|
@@ -45273,7 +45471,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
45273
45471
|
if (this.device.isProtocolV2()) {
|
|
45274
45472
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 firmware update must use firmwareUpdateV4');
|
|
45275
45473
|
}
|
|
45276
|
-
Log$
|
|
45474
|
+
Log$6.debug('FirmwareUpdateV3 strategy: Protocol V1');
|
|
45277
45475
|
return this.runProtocolV1();
|
|
45278
45476
|
});
|
|
45279
45477
|
}
|
|
@@ -45344,7 +45542,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
45344
45542
|
const resource = (yield getSysResourceBinary(resourceUrl)).binary;
|
|
45345
45543
|
return resource;
|
|
45346
45544
|
}
|
|
45347
|
-
Log$
|
|
45545
|
+
Log$6.warn('No resource url found');
|
|
45348
45546
|
return null;
|
|
45349
45547
|
});
|
|
45350
45548
|
}
|
|
@@ -45469,7 +45667,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
45469
45667
|
yield this.startEmmcFirmwareUpdate({ path: '0:updates' });
|
|
45470
45668
|
}
|
|
45471
45669
|
catch (error) {
|
|
45472
|
-
Log$
|
|
45670
|
+
Log$6.error('triggerFirmwareUpdateEmmc error: ', error);
|
|
45473
45671
|
if (error === null || error === void 0 ? void 0 : error.errorCode) {
|
|
45474
45672
|
const unexpectedError = [
|
|
45475
45673
|
hdShared.HardwareErrorCode.ActionCancelled,
|
|
@@ -45530,7 +45728,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
45530
45728
|
yield hdShared.wait(1000);
|
|
45531
45729
|
}
|
|
45532
45730
|
catch (error) {
|
|
45533
|
-
Log$
|
|
45731
|
+
Log$6.log('getFeatures error', error);
|
|
45534
45732
|
let shouldReconnect = true;
|
|
45535
45733
|
const progress = this.extractUpdateModeProgress(error);
|
|
45536
45734
|
if (progress !== null) {
|
|
@@ -45628,7 +45826,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
45628
45826
|
return;
|
|
45629
45827
|
}
|
|
45630
45828
|
catch (e) {
|
|
45631
|
-
Log$
|
|
45829
|
+
Log$6.log('catch Bluetooth error when device is restarting: ', e);
|
|
45632
45830
|
}
|
|
45633
45831
|
}
|
|
45634
45832
|
else {
|
|
@@ -45643,7 +45841,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
45643
45841
|
yield this._promptDeviceForSwitchFirmwareWebDevice();
|
|
45644
45842
|
}
|
|
45645
45843
|
catch (e) {
|
|
45646
|
-
Log$
|
|
45844
|
+
Log$6.log('WebUSB re-authorization failed: ', e);
|
|
45647
45845
|
}
|
|
45648
45846
|
webUsbCheckCount = 0;
|
|
45649
45847
|
}
|
|
@@ -45664,7 +45862,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
45664
45862
|
}
|
|
45665
45863
|
catch (error) {
|
|
45666
45864
|
console.error('Device reconnect failed: ', error);
|
|
45667
|
-
Log$
|
|
45865
|
+
Log$6.error('Device reconnect failed:', error);
|
|
45668
45866
|
yield hdShared.wait(1000);
|
|
45669
45867
|
}
|
|
45670
45868
|
}
|
|
@@ -45838,7 +46036,7 @@ function normalizeFirmwareTargets(params) {
|
|
|
45838
46036
|
});
|
|
45839
46037
|
}
|
|
45840
46038
|
|
|
45841
|
-
const Log$
|
|
46039
|
+
const Log$5 = getLogger(exports.LoggerNames.Method);
|
|
45842
46040
|
const SESSION_ERROR = 'session not found';
|
|
45843
46041
|
const PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT = 60 * 1000;
|
|
45844
46042
|
const PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT = 5 * 1000;
|
|
@@ -45918,6 +46116,16 @@ const PROTOCOL_V2_REMOTE_COMPONENT_TARGETS = {
|
|
|
45918
46116
|
kind: 'firmware',
|
|
45919
46117
|
},
|
|
45920
46118
|
};
|
|
46119
|
+
const PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID = new Map([
|
|
46120
|
+
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER, 'boot'],
|
|
46121
|
+
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1, 'app_v1'],
|
|
46122
|
+
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2, 'app_v2'],
|
|
46123
|
+
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_COPROCESSOR, 'coprocessor'],
|
|
46124
|
+
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE01, 'se01'],
|
|
46125
|
+
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE02, 'se02'],
|
|
46126
|
+
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE03, 'se03'],
|
|
46127
|
+
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE04, 'se04'],
|
|
46128
|
+
]);
|
|
45921
46129
|
const PROTOCOL_V2_ROMLOADER_UNSUPPORTED_MESSAGE = 'FW_MGMT_TARGET_ROMLOADER is not accepted by the current Pro2 bootloader update request. Flash romloader with the loader-specific flow instead of firmwareUpdateV4.';
|
|
45922
46130
|
const PROTOCOL_V2_TARGET_ID_BY_DECODED_NAME = new Map(Object.entries(ProtocolV2FirmwareTargetType).map(([key, value]) => [key, value]));
|
|
45923
46131
|
const PROTOCOL_V2_TARGET_STATUS_BY_DECODED_NAME = new Map([
|
|
@@ -45982,14 +46190,6 @@ const versionArrayToNumber = (version) => {
|
|
|
45982
46190
|
return undefined;
|
|
45983
46191
|
return version[0] * 0x10000 + version[1] * 0x100 + version[2];
|
|
45984
46192
|
};
|
|
45985
|
-
const versionStringToArray = (version) => {
|
|
45986
|
-
if (!version)
|
|
45987
|
-
return undefined;
|
|
45988
|
-
const parts = version.split('.').map(part => Number(part));
|
|
45989
|
-
if (parts.length !== 3 || parts.some(part => !Number.isFinite(part)))
|
|
45990
|
-
return undefined;
|
|
45991
|
-
return parts;
|
|
45992
|
-
};
|
|
45993
46193
|
const compareProtocolV2Versions = (current, target) => {
|
|
45994
46194
|
const currentNumber = versionArrayToNumber(current);
|
|
45995
46195
|
const targetNumber = versionArrayToNumber(target);
|
|
@@ -46095,6 +46295,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46095
46295
|
{ name: 'se03Binary', type: 'buffer' },
|
|
46096
46296
|
{ name: 'se04Binary', type: 'buffer' },
|
|
46097
46297
|
{ name: 'firmwareType', type: 'string' },
|
|
46298
|
+
{ name: 'targetsToUpdate', type: 'array', allowEmpty: true },
|
|
46098
46299
|
{ name: 'platform', type: 'string' },
|
|
46099
46300
|
{ name: 'resourceBundleFiles', type: 'array', allowEmpty: true },
|
|
46100
46301
|
]);
|
|
@@ -46112,6 +46313,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46112
46313
|
se04Binary: payload.se04Binary,
|
|
46113
46314
|
resourceBundleFiles: payload.resourceBundleFiles,
|
|
46114
46315
|
firmwareType: payload.firmwareType,
|
|
46316
|
+
targetsToUpdate: payload.targetsToUpdate,
|
|
46115
46317
|
platform: payload.platform,
|
|
46116
46318
|
};
|
|
46117
46319
|
}
|
|
@@ -46132,7 +46334,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46132
46334
|
if (!this.device.isProtocolV2()) {
|
|
46133
46335
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'firmwareUpdateV4 requires a Protocol V2 device');
|
|
46134
46336
|
}
|
|
46135
|
-
Log$
|
|
46337
|
+
Log$5.debug('FirmwareUpdateV4 strategy: Protocol V2');
|
|
46136
46338
|
return this.runProtocolV2();
|
|
46137
46339
|
});
|
|
46138
46340
|
}
|
|
@@ -46238,47 +46440,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46238
46440
|
}
|
|
46239
46441
|
return target;
|
|
46240
46442
|
}
|
|
46241
|
-
getProtocolV2ComponentTargetVersion(release, component, target) {
|
|
46242
|
-
if (component.version)
|
|
46243
|
-
return component.version;
|
|
46244
|
-
if (target.targetId === ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER) {
|
|
46245
|
-
return release.bootloaderVersion;
|
|
46246
|
-
}
|
|
46247
|
-
if (target.targetId === ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1 ||
|
|
46248
|
-
target.targetId === ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2) {
|
|
46249
|
-
return release.version;
|
|
46250
|
-
}
|
|
46251
|
-
return undefined;
|
|
46252
|
-
}
|
|
46253
|
-
getProtocolV2ComponentCurrentVersion(features, target) {
|
|
46254
|
-
switch (target.targetId) {
|
|
46255
|
-
case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER:
|
|
46256
|
-
return getDeviceBootloaderVersion(features);
|
|
46257
|
-
case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1:
|
|
46258
|
-
case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2:
|
|
46259
|
-
return getDeviceFirmwareVersion(features);
|
|
46260
|
-
case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_COPROCESSOR:
|
|
46261
|
-
return getDeviceBLEFirmwareVersion(features);
|
|
46262
|
-
case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE01:
|
|
46263
|
-
return versionStringToArray(features.se01Version);
|
|
46264
|
-
case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE02:
|
|
46265
|
-
return versionStringToArray(features.se02Version);
|
|
46266
|
-
case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE03:
|
|
46267
|
-
return versionStringToArray(features.se03Version);
|
|
46268
|
-
case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE04:
|
|
46269
|
-
return versionStringToArray(features.se04Version);
|
|
46270
|
-
default:
|
|
46271
|
-
return undefined;
|
|
46272
|
-
}
|
|
46273
|
-
}
|
|
46274
|
-
isProtocolV2ComponentVersionSatisfied(release, component, target, features) {
|
|
46275
|
-
const targetVersion = this.getProtocolV2ComponentTargetVersion(release, component, target);
|
|
46276
|
-
if (!targetVersion)
|
|
46277
|
-
return false;
|
|
46278
|
-
const currentVersion = this.getProtocolV2ComponentCurrentVersion(features, target);
|
|
46279
|
-
const compareResult = compareProtocolV2Versions(currentVersion, targetVersion);
|
|
46280
|
-
return compareResult !== undefined && compareResult >= 0;
|
|
46281
|
-
}
|
|
46282
46443
|
getProtocolV2ResourceFilePath(path) {
|
|
46283
46444
|
if (path.startsWith('vol'))
|
|
46284
46445
|
return path;
|
|
@@ -46330,13 +46491,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46330
46491
|
return parseProtocolV2OkppHeader(headerBytes);
|
|
46331
46492
|
});
|
|
46332
46493
|
}
|
|
46333
|
-
shouldInstallRemoteProtocolV2Component(release, key, component, target, features) {
|
|
46334
|
-
const versionSatisfied = this.isProtocolV2ComponentVersionSatisfied(release, component, target, features);
|
|
46335
|
-
if (versionSatisfied) {
|
|
46336
|
-
Log$4.log(`[FirmwareUpdateV4] skip Protocol V2 component ${key}; version is up to date`);
|
|
46337
|
-
}
|
|
46338
|
-
return !versionSatisfied;
|
|
46339
|
-
}
|
|
46340
46494
|
downloadRemoteProtocolV2Component(key, component) {
|
|
46341
46495
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46342
46496
|
const target = this.getRemoteComponentTarget(key, component);
|
|
@@ -46348,6 +46502,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46348
46502
|
});
|
|
46349
46503
|
}
|
|
46350
46504
|
prepareRemoteProtocolV2Binaries(firmwareType, features) {
|
|
46505
|
+
var _a;
|
|
46351
46506
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46352
46507
|
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
46353
46508
|
let bootloaderBinary = null;
|
|
@@ -46361,9 +46516,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46361
46516
|
};
|
|
46362
46517
|
}
|
|
46363
46518
|
const entries = this.getRemoteComponentEntries(release);
|
|
46519
|
+
const targetsToUpdate = new Set((_a = this.params.targetsToUpdate) !== null && _a !== void 0 ? _a : []);
|
|
46364
46520
|
for (const [key, component] of entries) {
|
|
46365
46521
|
const target = this.getRemoteComponentTarget(key, component);
|
|
46366
|
-
const
|
|
46522
|
+
const updateTarget = PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID.get(target.targetId);
|
|
46523
|
+
const shouldInstall = updateTarget ? targetsToUpdate.has(updateTarget) : false;
|
|
46367
46524
|
if (shouldInstall) {
|
|
46368
46525
|
const remoteBinary = yield this.downloadRemoteProtocolV2Component(key, component);
|
|
46369
46526
|
if (remoteBinary.kind === 'bootloader') {
|
|
@@ -46394,7 +46551,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46394
46551
|
});
|
|
46395
46552
|
}
|
|
46396
46553
|
prepareProtocolV2ResourceBundles(firmwareType, features) {
|
|
46397
|
-
var _a, _b;
|
|
46554
|
+
var _a, _b, _c;
|
|
46398
46555
|
if ((_a = this.params.resourceBundleFiles) === null || _a === void 0 ? void 0 : _a.length) {
|
|
46399
46556
|
return this.params.resourceBundleFiles.map(file => {
|
|
46400
46557
|
var _a;
|
|
@@ -46405,8 +46562,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46405
46562
|
});
|
|
46406
46563
|
});
|
|
46407
46564
|
}
|
|
46565
|
+
if (!((_b = this.params.targetsToUpdate) === null || _b === void 0 ? void 0 : _b.includes('resource'))) {
|
|
46566
|
+
return undefined;
|
|
46567
|
+
}
|
|
46408
46568
|
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
46409
|
-
if (!((
|
|
46569
|
+
if (!((_c = release === null || release === void 0 ? void 0 : release.resourceBundles) === null || _c === void 0 ? void 0 : _c.length))
|
|
46410
46570
|
return undefined;
|
|
46411
46571
|
return release.resourceBundles.map(bundle => ({
|
|
46412
46572
|
name: bundle.name,
|
|
@@ -46428,13 +46588,13 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46428
46588
|
const filtered = [];
|
|
46429
46589
|
for (const bundle of bundles) {
|
|
46430
46590
|
if (bundle.binary.byteLength === 0 && bundle.url) {
|
|
46431
|
-
Log$
|
|
46591
|
+
Log$5.log(`[FirmwareUpdateV4] downloading RESC bundle ${bundle.name} from ${bundle.url}`);
|
|
46432
46592
|
const { binary } = yield getSysResourceBinary(bundle.url);
|
|
46433
46593
|
bundle.binary = binary;
|
|
46434
46594
|
}
|
|
46435
46595
|
const upToDate = yield this.isProtocolV2ResourceBundleUpToDate(bundle);
|
|
46436
46596
|
if (upToDate) {
|
|
46437
|
-
Log$
|
|
46597
|
+
Log$5.log(`[FirmwareUpdateV4] skip RESC bundle ${bundle.name}; already up to date`);
|
|
46438
46598
|
}
|
|
46439
46599
|
else {
|
|
46440
46600
|
filtered.push(bundle);
|
|
@@ -46443,7 +46603,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46443
46603
|
bundlesToSync = filtered;
|
|
46444
46604
|
}
|
|
46445
46605
|
if (bundlesToSync.length === 0) {
|
|
46446
|
-
Log$
|
|
46606
|
+
Log$5.log('[FirmwareUpdateV4] all RESC bundles up to date, nothing to sync');
|
|
46447
46607
|
return { processedSize: 0, totalSize: firmwareSize };
|
|
46448
46608
|
}
|
|
46449
46609
|
let totalSize = 0;
|
|
@@ -46452,7 +46612,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46452
46612
|
const transferTotalSize = totalSize + firmwareSize;
|
|
46453
46613
|
let processedSize = 0;
|
|
46454
46614
|
for (const bundle of bundlesToSync) {
|
|
46455
|
-
Log$
|
|
46615
|
+
Log$5.log(`[FirmwareUpdateV4] syncing RESC bundle ${bundle.name} -> ${bundle.devicePath} bytes=${bundle.binary.byteLength}`);
|
|
46456
46616
|
processedSize = yield this.protocolV2CommonUpdateProcess({
|
|
46457
46617
|
payload: bundle.binary,
|
|
46458
46618
|
filePath: bundle.devicePath,
|
|
@@ -46461,7 +46621,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46461
46621
|
});
|
|
46462
46622
|
}
|
|
46463
46623
|
const elapsedMs = Date.now() - transferStartTime;
|
|
46464
|
-
Log$
|
|
46624
|
+
Log$5.log(`[FirmwareUpdateV4] RESC bundle sync finished transport=${transferTransport} bytes=${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(totalSize, elapsedMs)} KB/s`);
|
|
46465
46625
|
return { processedSize, totalSize: transferTotalSize };
|
|
46466
46626
|
});
|
|
46467
46627
|
}
|
|
@@ -46493,7 +46653,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46493
46653
|
return true;
|
|
46494
46654
|
}
|
|
46495
46655
|
catch (error) {
|
|
46496
|
-
Log$
|
|
46656
|
+
Log$5.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
46497
46657
|
return false;
|
|
46498
46658
|
}
|
|
46499
46659
|
});
|
|
@@ -46508,7 +46668,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46508
46668
|
enterProtocolV2BootloaderMode() {
|
|
46509
46669
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46510
46670
|
if (this.isProtocolV2BootloaderMode()) {
|
|
46511
|
-
Log$
|
|
46671
|
+
Log$5.debug('Protocol V2 device is already in bootloader mode, skip reboot to bootloader');
|
|
46512
46672
|
return false;
|
|
46513
46673
|
}
|
|
46514
46674
|
try {
|
|
@@ -46523,7 +46683,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46523
46683
|
if (error instanceof hdShared.HardwareError) {
|
|
46524
46684
|
throw error;
|
|
46525
46685
|
}
|
|
46526
|
-
Log$
|
|
46686
|
+
Log$5.log('Protocol V2 auto go to bootloader mode failed: ', error);
|
|
46527
46687
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
46528
46688
|
}
|
|
46529
46689
|
});
|
|
@@ -46547,7 +46707,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46547
46707
|
}
|
|
46548
46708
|
catch (error) {
|
|
46549
46709
|
lastError = error;
|
|
46550
|
-
Log$
|
|
46710
|
+
Log$5.log('Protocol V2 bootloader mode not ready, polling reconnect: ', error);
|
|
46551
46711
|
}
|
|
46552
46712
|
yield hdShared.wait(retryInterval);
|
|
46553
46713
|
}
|
|
@@ -46590,7 +46750,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46590
46750
|
totalSize = resourceTransfer.totalSize;
|
|
46591
46751
|
}
|
|
46592
46752
|
if (orderedInstallItems.length === 0) {
|
|
46593
|
-
Log$
|
|
46753
|
+
Log$5.log('[FirmwareUpdateV4] no firmware targets to install (RESC bundles only)');
|
|
46594
46754
|
if (totalSize > 0) {
|
|
46595
46755
|
this.postProgressMessage(100, 'transferData');
|
|
46596
46756
|
}
|
|
@@ -46603,12 +46763,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46603
46763
|
const onTransferredBytes = (bytes) => {
|
|
46604
46764
|
transferredSize = bytes;
|
|
46605
46765
|
};
|
|
46606
|
-
Log$
|
|
46766
|
+
Log$5.log(`[FirmwareUpdateV4] transfer started transport=${transferTransport} total=${totalSize} bytes chunk=${chunkSize} bytes`);
|
|
46607
46767
|
const stagedInstallTargets = [];
|
|
46608
46768
|
try {
|
|
46609
46769
|
for (const item of orderedInstallItems) {
|
|
46610
46770
|
const filePath = this.getProtocolV2InstallItemStagingPath(item);
|
|
46611
|
-
Log$
|
|
46771
|
+
Log$5.log(`[FirmwareUpdateV4] staging ${item.kind} via FilesystemFileWrite target=${item.targetId} path=${filePath} source=${item.fileName} bytes=${item.binary.byteLength}`);
|
|
46612
46772
|
processedSize = yield this.protocolV2CommonUpdateProcess({
|
|
46613
46773
|
payload: item.binary,
|
|
46614
46774
|
filePath,
|
|
@@ -46624,11 +46784,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46624
46784
|
this.postProgressMessage(100, 'transferData');
|
|
46625
46785
|
}
|
|
46626
46786
|
const elapsedMs = Date.now() - transferStartTime;
|
|
46627
|
-
Log$
|
|
46787
|
+
Log$5.log(`[FirmwareUpdateV4] transfer finished transport=${transferTransport} bytes=${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(totalSize, elapsedMs)} KB/s`);
|
|
46628
46788
|
}
|
|
46629
46789
|
catch (error) {
|
|
46630
46790
|
const elapsedMs = Date.now() - transferStartTime;
|
|
46631
|
-
Log$
|
|
46791
|
+
Log$5.warn(`[FirmwareUpdateV4] transfer failed transport=${transferTransport} bytes=${transferredSize}/${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(transferredSize, elapsedMs)} KB/s`);
|
|
46632
46792
|
throw error;
|
|
46633
46793
|
}
|
|
46634
46794
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.ConfirmOnDevice);
|
|
@@ -46636,7 +46796,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46636
46796
|
target_id: item.targetId,
|
|
46637
46797
|
path: item.path,
|
|
46638
46798
|
}));
|
|
46639
|
-
Log$
|
|
46799
|
+
Log$5.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateRequest targets=${JSON.stringify(allTargets)}`);
|
|
46640
46800
|
const startResponse = yield this.protocolV2StartFirmwareUpdate({ targets: allTargets });
|
|
46641
46801
|
yield this.waitForProtocolV2FirmwareUpdateComplete(allTargets, startResponse);
|
|
46642
46802
|
});
|
|
@@ -46683,7 +46843,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46683
46843
|
});
|
|
46684
46844
|
const features = this.device.updateProtocolV2Features(deviceInfo);
|
|
46685
46845
|
if (this.isProtocolV2NormalModeFeatures(features)) {
|
|
46686
|
-
Log$
|
|
46846
|
+
Log$5.log('Protocol V2 firmware install finished; device is back in normal mode');
|
|
46687
46847
|
return true;
|
|
46688
46848
|
}
|
|
46689
46849
|
return false;
|
|
@@ -46741,7 +46901,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46741
46901
|
if (error instanceof hdShared.HardwareError && error.errorCode === hdShared.HardwareErrorCode.FirmwareError) {
|
|
46742
46902
|
throw error;
|
|
46743
46903
|
}
|
|
46744
|
-
Log$
|
|
46904
|
+
Log$5.log('Protocol V2 firmware install status polling failed: ', error);
|
|
46745
46905
|
if (isProtocolV2PollingTransientError(error)) {
|
|
46746
46906
|
try {
|
|
46747
46907
|
yield this.reconnectProtocolV2Device();
|
|
@@ -46751,15 +46911,15 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46751
46911
|
}
|
|
46752
46912
|
catch (reconnectError) {
|
|
46753
46913
|
lastError = reconnectError;
|
|
46754
|
-
Log$
|
|
46914
|
+
Log$5.log('Protocol V2 firmware install reconnect/normal-mode probe failed: ', reconnectError);
|
|
46755
46915
|
}
|
|
46756
46916
|
try {
|
|
46757
46917
|
yield this.pingProtocolV2Device();
|
|
46758
|
-
Log$
|
|
46918
|
+
Log$5.log('Protocol V2 firmware status unavailable, Ping is ready');
|
|
46759
46919
|
}
|
|
46760
46920
|
catch (pingError) {
|
|
46761
46921
|
lastError = pingError;
|
|
46762
|
-
Log$
|
|
46922
|
+
Log$5.log('Protocol V2 firmware install Ping polling failed: ', pingError);
|
|
46763
46923
|
}
|
|
46764
46924
|
}
|
|
46765
46925
|
}
|
|
@@ -46774,12 +46934,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46774
46934
|
try {
|
|
46775
46935
|
yield this.reconnectProtocolV2Device();
|
|
46776
46936
|
if (yield this.probeProtocolV2NormalMode()) {
|
|
46777
|
-
Log$
|
|
46937
|
+
Log$5.log('Protocol V2 device is already in normal mode, skip normal reboot');
|
|
46778
46938
|
return;
|
|
46779
46939
|
}
|
|
46780
46940
|
}
|
|
46781
46941
|
catch (error) {
|
|
46782
|
-
Log$
|
|
46942
|
+
Log$5.log('Protocol V2 normal-mode probe before reboot failed: ', error);
|
|
46783
46943
|
}
|
|
46784
46944
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
46785
46945
|
});
|
|
@@ -46791,7 +46951,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46791
46951
|
const bleVersion = getDeviceBLEFirmwareVersion(features).join('.');
|
|
46792
46952
|
const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
|
|
46793
46953
|
if (firmwareVersion === '0.0.0') {
|
|
46794
|
-
Log$
|
|
46954
|
+
Log$5.warn('Protocol V2 firmware update finished but app firmware version is still 0.0.0. This is allowed for Pro2 debug BLE-only update flows.');
|
|
46795
46955
|
}
|
|
46796
46956
|
return {
|
|
46797
46957
|
bootloaderVersion,
|
|
@@ -46820,7 +46980,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46820
46980
|
}
|
|
46821
46981
|
catch (error) {
|
|
46822
46982
|
lastError = error;
|
|
46823
|
-
Log$
|
|
46983
|
+
Log$5.log('Protocol V2 normal mode not ready, polling Ping: ', error);
|
|
46824
46984
|
yield hdShared.wait(1000);
|
|
46825
46985
|
}
|
|
46826
46986
|
}
|
|
@@ -46851,7 +47011,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46851
47011
|
if (deviceList.length !== 1) {
|
|
46852
47012
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
|
|
46853
47013
|
}
|
|
46854
|
-
Log$
|
|
47014
|
+
Log$5.debug('Protocol V2 firmware reconnect using single enumerated device:', deviceList[0].getConnectId());
|
|
46855
47015
|
this.device.updateFromCache(deviceList[0]);
|
|
46856
47016
|
yield this.device.acquire(PROTOCOL_V2_CONNECT_PROTOCOL, { throwOnRunPromiseError: true });
|
|
46857
47017
|
this.device.commands.disposed = false;
|
|
@@ -46868,7 +47028,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46868
47028
|
}
|
|
46869
47029
|
catch (error) {
|
|
46870
47030
|
lastError = error;
|
|
46871
|
-
Log$
|
|
47031
|
+
Log$5.error(`Protocol V2 file transfer failed path=${params.filePath} attempt=${attempt}/${PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT}; restarting from offset 0`, error);
|
|
46872
47032
|
if (attempt === PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
|
|
46873
47033
|
break;
|
|
46874
47034
|
}
|
|
@@ -46982,7 +47142,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46982
47142
|
}
|
|
46983
47143
|
catch (error) {
|
|
46984
47144
|
if (isProtocolV2StartUpdateTransientError(error)) {
|
|
46985
|
-
Log$
|
|
47145
|
+
Log$5.log('Protocol V2 firmware update request did not return; continue status polling', error);
|
|
46986
47146
|
}
|
|
46987
47147
|
else {
|
|
46988
47148
|
throw error;
|
|
@@ -47017,7 +47177,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
47017
47177
|
}
|
|
47018
47178
|
}
|
|
47019
47179
|
|
|
47020
|
-
const Log$
|
|
47180
|
+
const Log$4 = getLogger(exports.LoggerNames.Method);
|
|
47021
47181
|
class PromptWebDeviceAccess extends BaseMethod {
|
|
47022
47182
|
init() {
|
|
47023
47183
|
this.useDevice = false;
|
|
@@ -47074,7 +47234,7 @@ class PromptWebDeviceAccess extends BaseMethod {
|
|
|
47074
47234
|
return { device: null };
|
|
47075
47235
|
}
|
|
47076
47236
|
catch (error) {
|
|
47077
|
-
Log$
|
|
47237
|
+
Log$4.debug(error);
|
|
47078
47238
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
|
|
47079
47239
|
}
|
|
47080
47240
|
});
|
|
@@ -47239,14 +47399,11 @@ class DeviceSessionGet extends BaseMethod {
|
|
|
47239
47399
|
this.requireProtocolV2 = true;
|
|
47240
47400
|
this.useDevicePassphraseState = false;
|
|
47241
47401
|
this.skipForceUpdateCheck = true;
|
|
47242
|
-
this.params =
|
|
47243
|
-
sessionId: this.payload.sessionId,
|
|
47244
|
-
};
|
|
47402
|
+
this.params = undefined;
|
|
47245
47403
|
}
|
|
47246
47404
|
run() {
|
|
47247
47405
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47248
|
-
const
|
|
47249
|
-
const { message } = yield this.device.commands.typedCall('DeviceSessionGet', 'DeviceSession', payload);
|
|
47406
|
+
const { message } = yield this.device.commands.typedCall('DeviceSessionGet', 'DeviceSession', {});
|
|
47250
47407
|
return message;
|
|
47251
47408
|
});
|
|
47252
47409
|
}
|
|
@@ -47376,6 +47533,198 @@ class DeviceFactoryInfoGet extends BaseMethod {
|
|
|
47376
47533
|
}
|
|
47377
47534
|
}
|
|
47378
47535
|
|
|
47536
|
+
class DeviceSettingsGet extends BaseMethod {
|
|
47537
|
+
init() {
|
|
47538
|
+
this.requireProtocolV2 = true;
|
|
47539
|
+
this.unlockPolicy = 'retry-on-locked';
|
|
47540
|
+
this.skipForceUpdateCheck = true;
|
|
47541
|
+
this.useDevicePassphraseState = false;
|
|
47542
|
+
this.params = undefined;
|
|
47543
|
+
}
|
|
47544
|
+
run() {
|
|
47545
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47546
|
+
const res = yield this.device.commands.typedCall('DeviceSettingsGet', 'DeviceSettings', {});
|
|
47547
|
+
return Promise.resolve(res.message);
|
|
47548
|
+
});
|
|
47549
|
+
}
|
|
47550
|
+
}
|
|
47551
|
+
|
|
47552
|
+
class DeviceSettingsSet extends BaseMethod {
|
|
47553
|
+
init() {
|
|
47554
|
+
const settings = this.payload.settings;
|
|
47555
|
+
if (!settings || typeof settings !== 'object' || Array.isArray(settings)) {
|
|
47556
|
+
throw invalidParameter('Parameter [settings] must be an object.');
|
|
47557
|
+
}
|
|
47558
|
+
const _a = settings, supported = __rest(_a, ["passphrase_enable", "airgap_mode"]);
|
|
47559
|
+
if (Object.keys(supported).length === 0) {
|
|
47560
|
+
throw invalidParameter('Parameter [settings] must contain at least one supported setting.');
|
|
47561
|
+
}
|
|
47562
|
+
this.requireProtocolV2 = true;
|
|
47563
|
+
this.unlockPolicy = 'retry-on-locked';
|
|
47564
|
+
this.skipForceUpdateCheck = true;
|
|
47565
|
+
this.useDevicePassphraseState = false;
|
|
47566
|
+
this.params = { settings: supported };
|
|
47567
|
+
}
|
|
47568
|
+
run() {
|
|
47569
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47570
|
+
const res = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', this.params);
|
|
47571
|
+
return Promise.resolve(res.message);
|
|
47572
|
+
});
|
|
47573
|
+
}
|
|
47574
|
+
}
|
|
47575
|
+
|
|
47576
|
+
const SUPPORTED_PAGES = new Set([
|
|
47577
|
+
hdTransport.DeviceSettingsPage.DeviceReset,
|
|
47578
|
+
hdTransport.DeviceSettingsPage.DevicePinChange,
|
|
47579
|
+
hdTransport.DeviceSettingsPage.DevicePassphrase,
|
|
47580
|
+
hdTransport.DeviceSettingsPage.DeviceAirgap,
|
|
47581
|
+
]);
|
|
47582
|
+
function normalizePage(value) {
|
|
47583
|
+
const page = typeof value === 'string' ? hdTransport.DeviceSettingsPage[value] : value;
|
|
47584
|
+
if (page !== undefined && SUPPORTED_PAGES.has(page)) {
|
|
47585
|
+
return page;
|
|
47586
|
+
}
|
|
47587
|
+
throw invalidParameter('Parameter [page] must be DeviceReset, DevicePinChange, DevicePassphrase, or DeviceAirgap.');
|
|
47588
|
+
}
|
|
47589
|
+
class DeviceSettingsPageShow extends BaseMethod {
|
|
47590
|
+
init() {
|
|
47591
|
+
var _a;
|
|
47592
|
+
this.requireProtocolV2 = true;
|
|
47593
|
+
this.unlockPolicy = 'retry-on-locked';
|
|
47594
|
+
this.skipForceUpdateCheck = true;
|
|
47595
|
+
this.useDevicePassphraseState = false;
|
|
47596
|
+
this.params = {
|
|
47597
|
+
page: normalizePage(this.payload.page),
|
|
47598
|
+
field_name: (_a = this.payload.field_name) !== null && _a !== void 0 ? _a : this.payload.fieldName,
|
|
47599
|
+
};
|
|
47600
|
+
}
|
|
47601
|
+
run() {
|
|
47602
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47603
|
+
const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', this.params);
|
|
47604
|
+
return Promise.resolve(res.message);
|
|
47605
|
+
});
|
|
47606
|
+
}
|
|
47607
|
+
}
|
|
47608
|
+
|
|
47609
|
+
const WALLPAPER_DIRECTORY = 'vol0:/wallpapers/user';
|
|
47610
|
+
const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
|
|
47611
|
+
function getDefaultChunkSize() {
|
|
47612
|
+
const env = DataManager.getSettings('env');
|
|
47613
|
+
return env && DataManager.isBleConnect(env)
|
|
47614
|
+
? hdTransport.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE
|
|
47615
|
+
: hdTransport.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
47616
|
+
}
|
|
47617
|
+
function normalizeFileName(fileName, data) {
|
|
47618
|
+
if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
|
|
47619
|
+
throw invalidParameter('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
|
|
47620
|
+
}
|
|
47621
|
+
const baseName = fileName !== null && fileName !== void 0 ? fileName : `wallpaper-${utils.bytesToHex(blake2s.blake2s(data)).slice(0, 12)}`;
|
|
47622
|
+
return baseName.endsWith('.bin') ? baseName : `${baseName}.bin`;
|
|
47623
|
+
}
|
|
47624
|
+
class DeviceUploadWallpaper extends BaseMethod {
|
|
47625
|
+
constructor() {
|
|
47626
|
+
super(...arguments);
|
|
47627
|
+
this.directoryReady = false;
|
|
47628
|
+
this.uploaded = false;
|
|
47629
|
+
this.path = '';
|
|
47630
|
+
}
|
|
47631
|
+
init() {
|
|
47632
|
+
const { width, height, rgba, fileName, chunkSize } = this.payload;
|
|
47633
|
+
if (width !== PRO2_WALLPAPER_WIDTH || height !== PRO2_WALLPAPER_HEIGHT) {
|
|
47634
|
+
throw invalidParameter(`Pro2 wallpaper dimensions must be ${PRO2_WALLPAPER_WIDTH}x${PRO2_WALLPAPER_HEIGHT}.`);
|
|
47635
|
+
}
|
|
47636
|
+
if (!(rgba instanceof ArrayBuffer) && !ArrayBuffer.isView(rgba)) {
|
|
47637
|
+
throw invalidParameter('Parameter [rgba] must be an ArrayBuffer or Uint8Array.');
|
|
47638
|
+
}
|
|
47639
|
+
if (chunkSize !== undefined && (!Number.isInteger(chunkSize) || chunkSize <= 0)) {
|
|
47640
|
+
throw invalidParameter('Parameter [chunkSize] must be a positive integer.');
|
|
47641
|
+
}
|
|
47642
|
+
const rgbaBytes = rgba instanceof ArrayBuffer
|
|
47643
|
+
? rgba
|
|
47644
|
+
: new Uint8Array(rgba.buffer, rgba.byteOffset, rgba.byteLength);
|
|
47645
|
+
this.encoded = encodePro2Wallpaper({ width, height, rgba: rgbaBytes });
|
|
47646
|
+
this.path = `${WALLPAPER_DIRECTORY}/${normalizeFileName(fileName, this.encoded.data)}`;
|
|
47647
|
+
this.params = { width, height, rgba: rgbaBytes, fileName, chunkSize };
|
|
47648
|
+
this.requireProtocolV2 = true;
|
|
47649
|
+
this.unlockPolicy = 'retry-on-locked';
|
|
47650
|
+
this.skipForceUpdateCheck = true;
|
|
47651
|
+
this.useDevicePassphraseState = false;
|
|
47652
|
+
}
|
|
47653
|
+
ensureDirectory() {
|
|
47654
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47655
|
+
if (this.directoryReady)
|
|
47656
|
+
return;
|
|
47657
|
+
try {
|
|
47658
|
+
yield this.device.commands.typedCall('FilesystemDirMake', 'Success', {
|
|
47659
|
+
path: WALLPAPER_DIRECTORY,
|
|
47660
|
+
});
|
|
47661
|
+
}
|
|
47662
|
+
catch (error) {
|
|
47663
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
47664
|
+
if (!/exist/i.test(message))
|
|
47665
|
+
throw error;
|
|
47666
|
+
}
|
|
47667
|
+
this.directoryReady = true;
|
|
47668
|
+
});
|
|
47669
|
+
}
|
|
47670
|
+
upload() {
|
|
47671
|
+
var _a, _b;
|
|
47672
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47673
|
+
if (this.uploaded)
|
|
47674
|
+
return;
|
|
47675
|
+
const encoded = this.encoded;
|
|
47676
|
+
if (!encoded)
|
|
47677
|
+
throw invalidParameter('Wallpaper data has not been initialized.');
|
|
47678
|
+
const maxChunkSize = getDefaultChunkSize();
|
|
47679
|
+
const requestedChunkSize = (_a = this.params.chunkSize) !== null && _a !== void 0 ? _a : maxChunkSize;
|
|
47680
|
+
const chunkSize = Math.min(Math.max(64, Math.floor(requestedChunkSize)), maxChunkSize);
|
|
47681
|
+
let offset = 0;
|
|
47682
|
+
while (offset < encoded.data.byteLength) {
|
|
47683
|
+
const chunk = encoded.data.slice(offset, Math.min(offset + chunkSize, encoded.data.byteLength));
|
|
47684
|
+
const response = yield this.device.commands.typedCall('FilesystemFileWrite', 'FilesystemFile', {
|
|
47685
|
+
file: {
|
|
47686
|
+
path: this.path,
|
|
47687
|
+
offset,
|
|
47688
|
+
total_size: encoded.data.byteLength,
|
|
47689
|
+
data: chunk,
|
|
47690
|
+
},
|
|
47691
|
+
overwrite: offset === 0,
|
|
47692
|
+
append: false,
|
|
47693
|
+
ui_percentage: Math.min(Math.ceil(((offset + chunk.byteLength) / encoded.data.byteLength) * 100), 100),
|
|
47694
|
+
}, { timeoutMs: undefined });
|
|
47695
|
+
const processedByte = Number((_b = response.message) === null || _b === void 0 ? void 0 : _b.processed_byte);
|
|
47696
|
+
offset = Number.isFinite(processedByte) && processedByte > offset
|
|
47697
|
+
? processedByte
|
|
47698
|
+
: offset + chunk.byteLength;
|
|
47699
|
+
if (offset > encoded.data.byteLength) {
|
|
47700
|
+
throw invalidParameter(`Invalid processed_byte returned by device: ${processedByte}.`);
|
|
47701
|
+
}
|
|
47702
|
+
}
|
|
47703
|
+
this.uploaded = true;
|
|
47704
|
+
});
|
|
47705
|
+
}
|
|
47706
|
+
run() {
|
|
47707
|
+
var _a;
|
|
47708
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47709
|
+
const encoded = this.encoded;
|
|
47710
|
+
if (!encoded)
|
|
47711
|
+
throw invalidParameter('Wallpaper data has not been initialized.');
|
|
47712
|
+
yield this.ensureDirectory();
|
|
47713
|
+
yield this.upload();
|
|
47714
|
+
const response = yield this.device.commands.typedCall('SetWallpaper', 'Success', {
|
|
47715
|
+
target: hdTransport.WallpaperTarget.Lock,
|
|
47716
|
+
path: this.path,
|
|
47717
|
+
});
|
|
47718
|
+
return {
|
|
47719
|
+
path: this.path,
|
|
47720
|
+
size: encoded.data.byteLength,
|
|
47721
|
+
colorFormat: encoded.colorFormat,
|
|
47722
|
+
message: (_a = response.message) === null || _a === void 0 ? void 0 : _a.message,
|
|
47723
|
+
};
|
|
47724
|
+
});
|
|
47725
|
+
}
|
|
47726
|
+
}
|
|
47727
|
+
|
|
47379
47728
|
class FilesystemPermissionFix extends BaseMethod {
|
|
47380
47729
|
init() {
|
|
47381
47730
|
this.requireProtocolV2 = true;
|
|
@@ -47653,6 +48002,7 @@ class FileWrite extends BaseMethod {
|
|
|
47653
48002
|
run() {
|
|
47654
48003
|
var _a, _b, _c, _d, _e, _f;
|
|
47655
48004
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48005
|
+
this.throwIfAborted();
|
|
47656
48006
|
const data = yield dataToUint8Array(this.params.data);
|
|
47657
48007
|
const dataLength = data.byteLength;
|
|
47658
48008
|
const offsetValue = Number((_a = this.params.offset) !== null && _a !== void 0 ? _a : 0);
|
|
@@ -47673,6 +48023,7 @@ class FileWrite extends BaseMethod {
|
|
|
47673
48023
|
const startTime = Date.now();
|
|
47674
48024
|
const timeoutMs = this.params.timeoutMs === undefined ? undefined : Number(this.params.timeoutMs);
|
|
47675
48025
|
while (written < dataLength) {
|
|
48026
|
+
this.throwIfAborted();
|
|
47676
48027
|
const chunkEnd = Math.min(written + chunkSize, dataLength);
|
|
47677
48028
|
const chunk = data.slice(written, chunkEnd);
|
|
47678
48029
|
const offset = startOffset + written;
|
|
@@ -47691,6 +48042,7 @@ class FileWrite extends BaseMethod {
|
|
|
47691
48042
|
}, {
|
|
47692
48043
|
timeoutMs,
|
|
47693
48044
|
});
|
|
48045
|
+
this.throwIfAborted();
|
|
47694
48046
|
lastMessage = res.message;
|
|
47695
48047
|
const processedByte = Number((_f = res.message) === null || _f === void 0 ? void 0 : _f.processed_byte);
|
|
47696
48048
|
if (Number.isFinite(processedByte) && processedByte > offset) {
|
|
@@ -47818,6 +48170,27 @@ class PathInfo extends BaseMethod {
|
|
|
47818
48170
|
}
|
|
47819
48171
|
}
|
|
47820
48172
|
|
|
48173
|
+
const PORTFOLIO_PENDING_PATH = 'vol1:/portfolio/portfolio.pfol.pending';
|
|
48174
|
+
const PORTFOLIO_CHUNK_SIZE = 2048;
|
|
48175
|
+
class UploadPortfolio extends FileWrite {
|
|
48176
|
+
init() {
|
|
48177
|
+
const { packageBytes, timeoutMs } = this.payload;
|
|
48178
|
+
this.payload = Object.assign(Object.assign({}, this.payload), { path: PORTFOLIO_PENDING_PATH, offset: 0, data: packageBytes, chunkSize: PORTFOLIO_CHUNK_SIZE, overwrite: true, append: false, timeoutMs });
|
|
48179
|
+
super.init();
|
|
48180
|
+
}
|
|
48181
|
+
run() {
|
|
48182
|
+
const _super = Object.create(null, {
|
|
48183
|
+
run: { get: () => super.run }
|
|
48184
|
+
});
|
|
48185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48186
|
+
const stagedFile = yield _super.run.call(this);
|
|
48187
|
+
this.throwIfAborted();
|
|
48188
|
+
yield this.device.commands.typedCall('PortfolioUpdate', 'Success', {});
|
|
48189
|
+
return Object.assign(Object.assign({}, stagedFile), { portfolioUpdated: true });
|
|
48190
|
+
});
|
|
48191
|
+
}
|
|
48192
|
+
}
|
|
48193
|
+
|
|
47821
48194
|
class CipherKeyValue extends BaseMethod {
|
|
47822
48195
|
constructor() {
|
|
47823
48196
|
super(...arguments);
|
|
@@ -57040,6 +57413,10 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
57040
57413
|
deviceGetFirmwareUpdateStatus: DeviceGetFirmwareUpdateStatus,
|
|
57041
57414
|
deviceFactoryInfoSet: DeviceFactoryInfoSet,
|
|
57042
57415
|
deviceFactoryInfoGet: DeviceFactoryInfoGet,
|
|
57416
|
+
deviceSettingsGet: DeviceSettingsGet,
|
|
57417
|
+
deviceSettingsSet: DeviceSettingsSet,
|
|
57418
|
+
deviceSettingsPageShow: DeviceSettingsPageShow,
|
|
57419
|
+
deviceUploadWallpaper: DeviceUploadWallpaper,
|
|
57043
57420
|
filesystemPermissionFix: FilesystemPermissionFix,
|
|
57044
57421
|
filesystemFormat: FilesystemFormat,
|
|
57045
57422
|
filesystemDiskControl: FilesystemDiskControl,
|
|
@@ -57052,6 +57429,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
57052
57429
|
pathInfo: PathInfo,
|
|
57053
57430
|
filesystemFileRead: FileRead,
|
|
57054
57431
|
filesystemFileWrite: FileWrite,
|
|
57432
|
+
uploadPortfolio: UploadPortfolio,
|
|
57055
57433
|
filesystemFileDelete: FileDelete,
|
|
57056
57434
|
filesystemDirList: DirList,
|
|
57057
57435
|
filesystemDirMake: DirMake,
|
|
@@ -57167,7 +57545,7 @@ const resolveAfter = (msec, value) => new Promise(resolve => {
|
|
|
57167
57545
|
setTimeout(resolve, msec, value);
|
|
57168
57546
|
});
|
|
57169
57547
|
|
|
57170
|
-
const Log$
|
|
57548
|
+
const Log$3 = getLogger(exports.LoggerNames.DeviceConnector);
|
|
57171
57549
|
class DeviceConnector {
|
|
57172
57550
|
constructor() {
|
|
57173
57551
|
this.listenTimestamp = 0;
|
|
@@ -57198,7 +57576,7 @@ class DeviceConnector {
|
|
|
57198
57576
|
this.listening = true;
|
|
57199
57577
|
let descriptors;
|
|
57200
57578
|
try {
|
|
57201
|
-
Log$
|
|
57579
|
+
Log$3.debug('Start listening', current);
|
|
57202
57580
|
this.listenTimestamp = new Date().getTime();
|
|
57203
57581
|
descriptors = waitForEvent
|
|
57204
57582
|
? yield this.transport.listen(current)
|
|
@@ -57206,21 +57584,21 @@ class DeviceConnector {
|
|
|
57206
57584
|
if (!this.listening)
|
|
57207
57585
|
return;
|
|
57208
57586
|
this.upcoming = descriptors;
|
|
57209
|
-
Log$
|
|
57587
|
+
Log$3.debug('Listen result', descriptors);
|
|
57210
57588
|
this._reportDevicesChange();
|
|
57211
57589
|
if (this.listening)
|
|
57212
57590
|
this.listen();
|
|
57213
57591
|
}
|
|
57214
57592
|
catch (error) {
|
|
57215
57593
|
const time = new Date().getTime() - this.listenTimestamp;
|
|
57216
|
-
Log$
|
|
57594
|
+
Log$3.debug('Listen error', 'timestamp', time, typeof error);
|
|
57217
57595
|
if (time > 1100) {
|
|
57218
57596
|
yield resolveAfter(1000, null);
|
|
57219
57597
|
if (this.listening)
|
|
57220
57598
|
this.listen();
|
|
57221
57599
|
}
|
|
57222
57600
|
else {
|
|
57223
|
-
Log$
|
|
57601
|
+
Log$3.warn('Transport error');
|
|
57224
57602
|
}
|
|
57225
57603
|
}
|
|
57226
57604
|
});
|
|
@@ -57230,7 +57608,7 @@ class DeviceConnector {
|
|
|
57230
57608
|
}
|
|
57231
57609
|
acquire(path, session, forceCleanRunPromise, connectProtocol) {
|
|
57232
57610
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57233
|
-
Log$
|
|
57611
|
+
Log$3.debug('acquire', path, session, connectProtocol);
|
|
57234
57612
|
const env = DataManager.getSettings('env');
|
|
57235
57613
|
try {
|
|
57236
57614
|
let res;
|
|
@@ -57257,7 +57635,7 @@ class DeviceConnector {
|
|
|
57257
57635
|
return res;
|
|
57258
57636
|
}
|
|
57259
57637
|
catch (error) {
|
|
57260
|
-
Log$
|
|
57638
|
+
Log$3.error('acquire error: ', error.message);
|
|
57261
57639
|
safeThrowError(error);
|
|
57262
57640
|
}
|
|
57263
57641
|
});
|
|
@@ -57296,10 +57674,11 @@ class DeviceConnector {
|
|
|
57296
57674
|
}
|
|
57297
57675
|
}
|
|
57298
57676
|
|
|
57299
|
-
const Log$
|
|
57677
|
+
const Log$2 = getLogger(exports.LoggerNames.Core);
|
|
57300
57678
|
class RequestQueue {
|
|
57301
57679
|
constructor() {
|
|
57302
57680
|
this.requestQueue = new Map();
|
|
57681
|
+
this.operationRequestIds = new Map();
|
|
57303
57682
|
this.pendingCallbackTasks = new Map();
|
|
57304
57683
|
this.generateRequestId = (method) => {
|
|
57305
57684
|
if (method && method.responseID != null) {
|
|
@@ -57309,15 +57688,25 @@ class RequestQueue {
|
|
|
57309
57688
|
};
|
|
57310
57689
|
}
|
|
57311
57690
|
createTask(method) {
|
|
57691
|
+
var _a;
|
|
57312
57692
|
const requestId = this.generateRequestId(method);
|
|
57313
57693
|
if (method && method.responseID !== requestId) {
|
|
57314
57694
|
method.responseID = requestId;
|
|
57315
57695
|
}
|
|
57316
57696
|
const abortController = new AbortController();
|
|
57697
|
+
method.abortSignal = abortController.signal;
|
|
57317
57698
|
const task = { id: requestId, method, abortController };
|
|
57318
57699
|
this.requestQueue.set(requestId, task);
|
|
57700
|
+
const operationId = (_a = method.payload) === null || _a === void 0 ? void 0 : _a.operationId;
|
|
57701
|
+
if (typeof operationId === 'string' && operationId) {
|
|
57702
|
+
this.operationRequestIds.set(operationId, requestId);
|
|
57703
|
+
}
|
|
57319
57704
|
return task;
|
|
57320
57705
|
}
|
|
57706
|
+
abortOperation(operationId) {
|
|
57707
|
+
const requestId = this.operationRequestIds.get(operationId);
|
|
57708
|
+
return requestId === undefined ? false : this.abortRequest(requestId);
|
|
57709
|
+
}
|
|
57321
57710
|
getTask(requestId) {
|
|
57322
57711
|
return this.requestQueue.get(requestId);
|
|
57323
57712
|
}
|
|
@@ -57328,7 +57717,7 @@ class RequestQueue {
|
|
|
57328
57717
|
abortRequest(requestId) {
|
|
57329
57718
|
const request = this.requestQueue.get(requestId);
|
|
57330
57719
|
if (request === null || request === void 0 ? void 0 : request.abortController) {
|
|
57331
|
-
Log$
|
|
57720
|
+
Log$2.debug(`Aborting request ${requestId}`);
|
|
57332
57721
|
request.abortController.abort();
|
|
57333
57722
|
return true;
|
|
57334
57723
|
}
|
|
@@ -57375,12 +57764,18 @@ class RequestQueue {
|
|
|
57375
57764
|
this.releaseTask(requestId);
|
|
57376
57765
|
}
|
|
57377
57766
|
releaseTask(requestId) {
|
|
57767
|
+
var _a, _b;
|
|
57768
|
+
const operationId = (_b = (_a = this.requestQueue.get(requestId)) === null || _a === void 0 ? void 0 : _a.method.payload) === null || _b === void 0 ? void 0 : _b.operationId;
|
|
57769
|
+
if (typeof operationId === 'string' &&
|
|
57770
|
+
this.operationRequestIds.get(operationId) === requestId) {
|
|
57771
|
+
this.operationRequestIds.delete(operationId);
|
|
57772
|
+
}
|
|
57378
57773
|
this.requestQueue.delete(requestId);
|
|
57379
57774
|
}
|
|
57380
57775
|
registerPendingCallbackTask(connectId, callbackPromise) {
|
|
57381
57776
|
this.pendingCallbackTasks.set(connectId, callbackPromise);
|
|
57382
57777
|
callbackPromise.promise.finally(() => {
|
|
57383
|
-
Log$
|
|
57778
|
+
Log$2.debug(`Callback task completed for connectId: ${connectId}`);
|
|
57384
57779
|
if (this.pendingCallbackTasks.get(connectId) === callbackPromise) {
|
|
57385
57780
|
this.pendingCallbackTasks.delete(connectId);
|
|
57386
57781
|
}
|
|
@@ -57390,7 +57785,7 @@ class RequestQueue {
|
|
|
57390
57785
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57391
57786
|
const pendingTask = this.pendingCallbackTasks.get(connectId);
|
|
57392
57787
|
if (pendingTask && pendingTask !== exceptTask) {
|
|
57393
|
-
Log$
|
|
57788
|
+
Log$2.debug(`Waiting for pending callback task to complete for connectId: ${connectId}`);
|
|
57394
57789
|
yield pendingTask.promise;
|
|
57395
57790
|
}
|
|
57396
57791
|
});
|
|
@@ -57425,6 +57820,40 @@ const getSynchronize = (mutex) => {
|
|
|
57425
57820
|
return (action, lockId) => lock(lockId).then(unlock => Promise.resolve().then(action).finally(unlock));
|
|
57426
57821
|
};
|
|
57427
57822
|
|
|
57823
|
+
const Log$1 = getLogger(exports.LoggerNames.Core);
|
|
57824
|
+
function isDeviceLockedError(error) {
|
|
57825
|
+
return (typeof error === 'object' &&
|
|
57826
|
+
error !== null &&
|
|
57827
|
+
'errorCode' in error &&
|
|
57828
|
+
error.errorCode === hdShared.HardwareErrorCode.DeviceLocked);
|
|
57829
|
+
}
|
|
57830
|
+
function runMethodWithUnlockRetry(method, device) {
|
|
57831
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57832
|
+
try {
|
|
57833
|
+
return yield method.run();
|
|
57834
|
+
}
|
|
57835
|
+
catch (error) {
|
|
57836
|
+
if (!device.isProtocolV2() ||
|
|
57837
|
+
method.unlockPolicy !== 'retry-on-locked' ||
|
|
57838
|
+
!isDeviceLockedError(error)) {
|
|
57839
|
+
throw error;
|
|
57840
|
+
}
|
|
57841
|
+
Log$1.debug('Protocol V2 unlock retry triggered', { method: method.name });
|
|
57842
|
+
yield device.unlockDevice();
|
|
57843
|
+
Log$1.debug('Protocol V2 unlock completed', { method: method.name });
|
|
57844
|
+
try {
|
|
57845
|
+
const response = yield method.run();
|
|
57846
|
+
Log$1.debug('Protocol V2 method retry completed', { method: method.name, success: true });
|
|
57847
|
+
return response;
|
|
57848
|
+
}
|
|
57849
|
+
catch (retryError) {
|
|
57850
|
+
Log$1.debug('Protocol V2 method retry completed', { method: method.name, success: false });
|
|
57851
|
+
throw retryError;
|
|
57852
|
+
}
|
|
57853
|
+
}
|
|
57854
|
+
});
|
|
57855
|
+
}
|
|
57856
|
+
|
|
57428
57857
|
const Log = getLogger(exports.LoggerNames.Core);
|
|
57429
57858
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
57430
57859
|
const preWarmInflight = new Map();
|
|
@@ -57776,7 +58205,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
57776
58205
|
}
|
|
57777
58206
|
(_p = (_o = method.device) === null || _o === void 0 ? void 0 : _o.commands) === null || _p === void 0 ? void 0 : _p.checkDisposed();
|
|
57778
58207
|
try {
|
|
57779
|
-
const response = yield method
|
|
58208
|
+
const response = yield runMethodWithUnlockRetry(method, device);
|
|
57780
58209
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
57781
58210
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
57782
58211
|
completeMethodRequestContext(method);
|
|
@@ -58310,6 +58739,9 @@ class Core extends events.exports {
|
|
|
58310
58739
|
this.sdkInstanceId = this.tracingContext.sdkInstanceId;
|
|
58311
58740
|
Log.debug(`[Core] Created SDK instance: ${this.sdkInstanceId}`);
|
|
58312
58741
|
}
|
|
58742
|
+
cancelOperation(operationId) {
|
|
58743
|
+
this.requestQueue.abortOperation(operationId);
|
|
58744
|
+
}
|
|
58313
58745
|
getCoreContext() {
|
|
58314
58746
|
return {
|
|
58315
58747
|
sdkInstanceId: this.sdkInstanceId,
|
|
@@ -58367,6 +58799,10 @@ class Core extends events.exports {
|
|
|
58367
58799
|
cancel(this.getCoreContext(), message.payload.connectId);
|
|
58368
58800
|
break;
|
|
58369
58801
|
}
|
|
58802
|
+
case IFRAME.CANCEL_OPERATION: {
|
|
58803
|
+
this.cancelOperation(message.payload.operationId);
|
|
58804
|
+
break;
|
|
58805
|
+
}
|
|
58370
58806
|
case IFRAME.CALLBACK: {
|
|
58371
58807
|
Log.log('callback message: ', message);
|
|
58372
58808
|
postMessage(message);
|
|
@@ -58428,17 +58864,18 @@ const switchTransport = ({ env, Transport, plugin, }) => {
|
|
|
58428
58864
|
initConnector();
|
|
58429
58865
|
};
|
|
58430
58866
|
|
|
58431
|
-
const HardwareSdk = ({ init, call, dispose, eventEmitter, uiResponse, cancel, updateSettings, switchTransport, }) => inject({
|
|
58867
|
+
const HardwareSdk = ({ init, call, dispose, eventEmitter, uiResponse, cancel, cancelOperation, updateSettings, switchTransport, }) => inject({
|
|
58432
58868
|
init,
|
|
58433
58869
|
call,
|
|
58434
58870
|
dispose,
|
|
58435
58871
|
eventEmitter,
|
|
58436
58872
|
uiResponse,
|
|
58437
58873
|
cancel,
|
|
58874
|
+
cancelOperation,
|
|
58438
58875
|
updateSettings,
|
|
58439
58876
|
switchTransport,
|
|
58440
58877
|
});
|
|
58441
|
-
const HardwareSDKLowLevel = ({ init, call, dispose, eventEmitter, addHardwareGlobalEventListener, uiResponse, cancel, updateSettings, switchTransport, }) => lowLevelInject({
|
|
58878
|
+
const HardwareSDKLowLevel = ({ init, call, dispose, eventEmitter, addHardwareGlobalEventListener, uiResponse, cancel, cancelOperation, updateSettings, switchTransport, }) => lowLevelInject({
|
|
58442
58879
|
init,
|
|
58443
58880
|
call,
|
|
58444
58881
|
dispose,
|
|
@@ -58446,6 +58883,7 @@ const HardwareSDKLowLevel = ({ init, call, dispose, eventEmitter, addHardwareGlo
|
|
|
58446
58883
|
addHardwareGlobalEventListener,
|
|
58447
58884
|
uiResponse,
|
|
58448
58885
|
cancel,
|
|
58886
|
+
cancelOperation,
|
|
58449
58887
|
updateSettings,
|
|
58450
58888
|
switchTransport,
|
|
58451
58889
|
});
|
|
@@ -58483,6 +58921,8 @@ exports.IFRAME = IFRAME;
|
|
|
58483
58921
|
exports.LOG = LOG;
|
|
58484
58922
|
exports.LOG_EVENT = LOG_EVENT;
|
|
58485
58923
|
exports.LogBlockEvent = LogBlockEvent;
|
|
58924
|
+
exports.PRO2_WALLPAPER_HEIGHT = PRO2_WALLPAPER_HEIGHT;
|
|
58925
|
+
exports.PRO2_WALLPAPER_WIDTH = PRO2_WALLPAPER_WIDTH;
|
|
58486
58926
|
exports.RESPONSE_EVENT = RESPONSE_EVENT;
|
|
58487
58927
|
exports.UI_EVENT = UI_EVENT;
|
|
58488
58928
|
exports.UI_REQUEST = UI_REQUEST;
|
|
@@ -58505,6 +58945,7 @@ exports.createUiMessage = createUiMessage;
|
|
|
58505
58945
|
exports.createUiResponse = createUiResponse;
|
|
58506
58946
|
exports["default"] = HardwareSdk;
|
|
58507
58947
|
exports.enableLog = enableLog;
|
|
58948
|
+
exports.encodePro2Wallpaper = encodePro2Wallpaper;
|
|
58508
58949
|
exports.executeCallback = executeCallback;
|
|
58509
58950
|
exports.formatRequestContext = formatRequestContext;
|
|
58510
58951
|
exports.generateInstanceId = generateInstanceId;
|