@onekeyfe/hd-core 1.2.0-alpha.134 → 1.2.0-alpha.136
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 +7 -0
- package/__tests__/device-lifecycle-events.test.ts +91 -2
- package/__tests__/device-settings.test.ts +167 -9
- package/__tests__/protocol-v2.test.ts +34 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +2 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +258 -189
- package/package.json +4 -4
- package/src/api/device/DeviceSettings.ts +2 -16
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +11 -0
- package/src/core/index.ts +67 -25
- package/src/device/Device.ts +30 -2
- package/src/device/DeviceCommands.ts +14 -1
package/dist/index.js
CHANGED
|
@@ -2261,7 +2261,7 @@ const createLogMessage = (type, payload) => ({
|
|
|
2261
2261
|
|
|
2262
2262
|
const MAX_ENTRIES = 500;
|
|
2263
2263
|
let postMessage$1;
|
|
2264
|
-
class Log$
|
|
2264
|
+
class Log$n {
|
|
2265
2265
|
constructor(prefix, enabled) {
|
|
2266
2266
|
this.prefix = prefix;
|
|
2267
2267
|
this.enabled = enabled;
|
|
@@ -2313,7 +2313,7 @@ class Log$m {
|
|
|
2313
2313
|
}
|
|
2314
2314
|
const _logs = {};
|
|
2315
2315
|
const initLog = (prefix, enabled) => {
|
|
2316
|
-
const instance = new Log$
|
|
2316
|
+
const instance = new Log$n(prefix, !!enabled);
|
|
2317
2317
|
_logs[prefix] = instance;
|
|
2318
2318
|
return instance;
|
|
2319
2319
|
};
|
|
@@ -2711,7 +2711,7 @@ function patchFeatures(response) {
|
|
|
2711
2711
|
return response;
|
|
2712
2712
|
}
|
|
2713
2713
|
|
|
2714
|
-
const Log$
|
|
2714
|
+
const Log$m = getLogger(exports.LoggerNames.Core);
|
|
2715
2715
|
let globalInstanceCounter = 0;
|
|
2716
2716
|
let sdkInstanceCounter = 0;
|
|
2717
2717
|
function generateSdkInstanceId() {
|
|
@@ -2771,7 +2771,7 @@ function completeRequestContext(responseID, error) {
|
|
|
2771
2771
|
context.status = error ? 'error' : 'success';
|
|
2772
2772
|
if (error) {
|
|
2773
2773
|
context.error = error.message;
|
|
2774
|
-
Log$
|
|
2774
|
+
Log$m.debug(`[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`);
|
|
2775
2775
|
}
|
|
2776
2776
|
globalActiveRequests.delete(responseID);
|
|
2777
2777
|
if (context.sdkInstanceId) {
|
|
@@ -40799,7 +40799,7 @@ function selectProtocolV2ResourceManifestFiles({ manifest, targetsToUpdate, }) {
|
|
|
40799
40799
|
|
|
40800
40800
|
var _a$1;
|
|
40801
40801
|
const FIRMWARE_UPDATE_CONFIG_FRESHNESS_MS = 5 * 60 * 1000;
|
|
40802
|
-
const Log$
|
|
40802
|
+
const Log$l = getLogger(exports.LoggerNames.Core);
|
|
40803
40803
|
const FIRMWARE_FIELDS = [
|
|
40804
40804
|
'firmware',
|
|
40805
40805
|
'firmware-v1',
|
|
@@ -40880,11 +40880,11 @@ class DataManager {
|
|
|
40880
40880
|
const manifestMode = (_b = settings.firmwareManifestMode) !== null && _b !== void 0 ? _b : (settings.fetchConfig ? 'sdk-managed' : undefined);
|
|
40881
40881
|
if (settings.preloadedConfig) {
|
|
40882
40882
|
this.applyRemoteConfig(settings.preloadedConfig);
|
|
40883
|
-
Log$
|
|
40883
|
+
Log$l.log('[DataConfig] Preloaded firmware config loaded');
|
|
40884
40884
|
return true;
|
|
40885
40885
|
}
|
|
40886
40886
|
if (manifestMode === 'external-only') {
|
|
40887
|
-
Log$
|
|
40887
|
+
Log$l.warn('[DataConfig] External firmware config is unavailable; SDK-managed networking remains disabled');
|
|
40888
40888
|
return false;
|
|
40889
40889
|
}
|
|
40890
40890
|
if (manifestMode !== 'sdk-managed') {
|
|
@@ -40897,7 +40897,7 @@ class DataManager {
|
|
|
40897
40897
|
let data = null;
|
|
40898
40898
|
let fetchMethod = 'none';
|
|
40899
40899
|
if (settings.configFetcher) {
|
|
40900
|
-
Log$
|
|
40900
|
+
Log$l.debug('[DataConfig] Trying client configFetcher...');
|
|
40901
40901
|
try {
|
|
40902
40902
|
data = yield settings.configFetcher(urlWithCache);
|
|
40903
40903
|
if (data) {
|
|
@@ -40905,40 +40905,40 @@ class DataManager {
|
|
|
40905
40905
|
}
|
|
40906
40906
|
}
|
|
40907
40907
|
catch (e) {
|
|
40908
|
-
Log$
|
|
40908
|
+
Log$l.warn('[DataConfig] Client configFetcher failed:', e);
|
|
40909
40909
|
}
|
|
40910
40910
|
}
|
|
40911
40911
|
if (!data) {
|
|
40912
|
-
Log$
|
|
40912
|
+
Log$l.debug('[DataConfig] Trying SDK-managed config request...');
|
|
40913
40913
|
try {
|
|
40914
40914
|
const response = yield axios__default["default"].get(urlWithCache, {
|
|
40915
40915
|
timeout: 7000,
|
|
40916
40916
|
});
|
|
40917
40917
|
data = response.data;
|
|
40918
40918
|
fetchMethod = 'axios';
|
|
40919
|
-
Log$
|
|
40919
|
+
Log$l.log('[DataConfig] SDK-managed config request succeeded');
|
|
40920
40920
|
}
|
|
40921
40921
|
catch (e) {
|
|
40922
|
-
Log$
|
|
40922
|
+
Log$l.warn('[DataConfig] SDK-managed config request failed:', e);
|
|
40923
40923
|
}
|
|
40924
40924
|
}
|
|
40925
40925
|
if (data) {
|
|
40926
40926
|
this.applyRemoteConfig(data);
|
|
40927
|
-
Log$
|
|
40927
|
+
Log$l.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
|
|
40928
40928
|
return true;
|
|
40929
40929
|
}
|
|
40930
|
-
Log$
|
|
40930
|
+
Log$l.warn('[DataConfig] All fetch methods failed, using built-in default config');
|
|
40931
40931
|
return false;
|
|
40932
40932
|
});
|
|
40933
40933
|
}
|
|
40934
40934
|
static applyRemoteConfig(data) {
|
|
40935
40935
|
const pro2Config = this.enrichProtocolV2FirmwareReleaseInfo(data.pro2, error => {
|
|
40936
40936
|
this.protocolV2ResourcesConfigError = error;
|
|
40937
|
-
Log$
|
|
40937
|
+
Log$l.warn('[DataConfig] Ignoring invalid Pro2 release resources config:', error);
|
|
40938
40938
|
});
|
|
40939
40939
|
const neoConfig = this.enrichProtocolV2FirmwareReleaseInfo(data.neo, error => {
|
|
40940
40940
|
this.protocolV2NeoResourcesConfigError = error;
|
|
40941
|
-
Log$
|
|
40941
|
+
Log$l.warn('[DataConfig] Ignoring invalid Neo release resources config:', error);
|
|
40942
40942
|
});
|
|
40943
40943
|
this.deviceMap = {
|
|
40944
40944
|
[hdShared.EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
@@ -43108,7 +43108,7 @@ const getDefectiveDeviceInfo = (features) => {
|
|
|
43108
43108
|
};
|
|
43109
43109
|
};
|
|
43110
43110
|
|
|
43111
|
-
const Log$
|
|
43111
|
+
const Log$k = getLogger(exports.LoggerNames.DevicePool);
|
|
43112
43112
|
const canPathIdentifyDevice = (path) => !!path && !/^0+$/.test(path);
|
|
43113
43113
|
const getDiff = (current, descriptors) => {
|
|
43114
43114
|
const connected = descriptors.filter(d => current.find(x => x.path === d.path) === undefined);
|
|
@@ -43170,7 +43170,7 @@ class DevicePool extends events.exports {
|
|
|
43170
43170
|
yield this._checkDevicePool(initOptions, connectId);
|
|
43171
43171
|
return { devices, deviceList };
|
|
43172
43172
|
}
|
|
43173
|
-
Log$
|
|
43173
|
+
Log$k.debug('found device in cache, but path is different: ', connectId);
|
|
43174
43174
|
}
|
|
43175
43175
|
}
|
|
43176
43176
|
const matchedDescriptor = connectId
|
|
@@ -43273,7 +43273,7 @@ class DevicePool extends events.exports {
|
|
|
43273
43273
|
});
|
|
43274
43274
|
}
|
|
43275
43275
|
catch (error) {
|
|
43276
|
-
Log$
|
|
43276
|
+
Log$k.debug('Unable to refresh Protocol V2 device label during discovery', error);
|
|
43277
43277
|
}
|
|
43278
43278
|
});
|
|
43279
43279
|
}
|
|
@@ -43289,7 +43289,7 @@ class DevicePool extends events.exports {
|
|
|
43289
43289
|
const descriptor = this.connectedPool[i];
|
|
43290
43290
|
if (!connectId || descriptor.path === connectId) {
|
|
43291
43291
|
const device = yield this._createDevice(descriptor, initOptions);
|
|
43292
|
-
Log$
|
|
43292
|
+
Log$k.debug('emit DEVICE.CONNECT: ', device === null || device === void 0 ? void 0 : device.features);
|
|
43293
43293
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
43294
43294
|
this.connectedPool.splice(i, 1);
|
|
43295
43295
|
}
|
|
@@ -43311,9 +43311,9 @@ class DevicePool extends events.exports {
|
|
|
43311
43311
|
const diff = getDiff(this.current || [], upcoming);
|
|
43312
43312
|
this.upcoming = upcoming;
|
|
43313
43313
|
this.current = this.upcoming;
|
|
43314
|
-
Log$
|
|
43315
|
-
Log$
|
|
43316
|
-
Log$
|
|
43314
|
+
Log$k.debug('device pool -> current: ', this.current);
|
|
43315
|
+
Log$k.debug('device pool -> upcomming: ', this.upcoming);
|
|
43316
|
+
Log$k.debug('DeviceCache.reportDeviceChange diff: ', diff);
|
|
43317
43317
|
if (!diff.didUpdate) {
|
|
43318
43318
|
return;
|
|
43319
43319
|
}
|
|
@@ -43323,7 +43323,7 @@ class DevicePool extends events.exports {
|
|
|
43323
43323
|
this._addConnectedDeviceToPool(d);
|
|
43324
43324
|
return;
|
|
43325
43325
|
}
|
|
43326
|
-
Log$
|
|
43326
|
+
Log$k.debug('emit DEVICE.CONNECT: ', device.features);
|
|
43327
43327
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
43328
43328
|
});
|
|
43329
43329
|
diff.disconnected.forEach(d => {
|
|
@@ -43333,7 +43333,7 @@ class DevicePool extends events.exports {
|
|
|
43333
43333
|
this._addDisconnectedDeviceToPool(d);
|
|
43334
43334
|
return;
|
|
43335
43335
|
}
|
|
43336
|
-
Log$
|
|
43336
|
+
Log$k.debug('emit DEVICE.DISCONNECT: ', device.features);
|
|
43337
43337
|
device.markTransportDisconnected();
|
|
43338
43338
|
this.emitter.emit(DEVICE.DISCONNECT, device);
|
|
43339
43339
|
});
|
|
@@ -43371,7 +43371,7 @@ class DevicePool extends events.exports {
|
|
|
43371
43371
|
this.connectedPool = [];
|
|
43372
43372
|
this.disconnectPool = [];
|
|
43373
43373
|
this.devicesCache = {};
|
|
43374
|
-
Log$
|
|
43374
|
+
Log$k.debug('DevicePool state has been reset');
|
|
43375
43375
|
}
|
|
43376
43376
|
static dispose() {
|
|
43377
43377
|
this.resetState();
|
|
@@ -43385,7 +43385,7 @@ DevicePool.disconnectPool = [];
|
|
|
43385
43385
|
DevicePool.devicesCache = {};
|
|
43386
43386
|
DevicePool.emitter = new events.exports();
|
|
43387
43387
|
|
|
43388
|
-
const Log$
|
|
43388
|
+
const Log$j = getLogger(exports.LoggerNames.Transport);
|
|
43389
43389
|
const BleLogger = getLogger(exports.LoggerNames.HdBleTransport);
|
|
43390
43390
|
const HttpLogger = getLogger(exports.LoggerNames.HdTransportHttp);
|
|
43391
43391
|
const LowLevelLogger = getLogger(exports.LoggerNames.HdTransportLowLevel);
|
|
@@ -43395,7 +43395,7 @@ const WebUsbLogger = getLogger(exports.LoggerNames.HdTransportWebUsb);
|
|
|
43395
43395
|
const REACT_NATIVE_BLE_SCAN_TIMEOUT_MS = 3000;
|
|
43396
43396
|
class TransportManager {
|
|
43397
43397
|
static load() {
|
|
43398
|
-
Log$
|
|
43398
|
+
Log$j.debug('transport manager load');
|
|
43399
43399
|
this.defaultMessages = DataManager.getProtobufMessages();
|
|
43400
43400
|
this.currentMessages = this.defaultMessages;
|
|
43401
43401
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
@@ -43404,14 +43404,14 @@ class TransportManager {
|
|
|
43404
43404
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43405
43405
|
try {
|
|
43406
43406
|
const env = DataManager.getSettings('env');
|
|
43407
|
-
Log$
|
|
43407
|
+
Log$j.debug('Initializing transports', env);
|
|
43408
43408
|
if (env === 'react-native') {
|
|
43409
43409
|
if (!this.reactNativeInit) {
|
|
43410
43410
|
yield this.transport.init(BleLogger, DevicePool.emitter);
|
|
43411
43411
|
this.reactNativeInit = true;
|
|
43412
43412
|
}
|
|
43413
43413
|
else {
|
|
43414
|
-
Log$
|
|
43414
|
+
Log$j.debug('React Native Do Not Initializing transports');
|
|
43415
43415
|
}
|
|
43416
43416
|
}
|
|
43417
43417
|
else if (env === 'node-usb') {
|
|
@@ -43432,15 +43432,15 @@ class TransportManager {
|
|
|
43432
43432
|
else {
|
|
43433
43433
|
yield this.transport.init(HttpLogger);
|
|
43434
43434
|
}
|
|
43435
|
-
Log$
|
|
43435
|
+
Log$j.debug('Configuring transports');
|
|
43436
43436
|
yield this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
43437
43437
|
this.currentMessages = this.defaultMessages;
|
|
43438
43438
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
43439
43439
|
yield this.configureProtocolV2Messages();
|
|
43440
|
-
Log$
|
|
43440
|
+
Log$j.debug('Configuring transports done');
|
|
43441
43441
|
}
|
|
43442
43442
|
catch (error) {
|
|
43443
|
-
Log$
|
|
43443
|
+
Log$j.debug('Initializing transports error: ', error);
|
|
43444
43444
|
if (error.code === 'ECONNABORTED') {
|
|
43445
43445
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError);
|
|
43446
43446
|
}
|
|
@@ -43456,7 +43456,7 @@ class TransportManager {
|
|
|
43456
43456
|
if (this.currentMessages === messages || !messages) {
|
|
43457
43457
|
return;
|
|
43458
43458
|
}
|
|
43459
|
-
Log$
|
|
43459
|
+
Log$j.debug(`Reconfiguring transports Protocol V1 schema:${protocolV1MessageSchema}`);
|
|
43460
43460
|
try {
|
|
43461
43461
|
yield this.transport.configure(JSON.stringify(messages));
|
|
43462
43462
|
this.currentMessages = messages;
|
|
@@ -43482,9 +43482,9 @@ class TransportManager {
|
|
|
43482
43482
|
}
|
|
43483
43483
|
if (plugin) {
|
|
43484
43484
|
this.plugin = plugin;
|
|
43485
|
-
Log$
|
|
43485
|
+
Log$j.debug('set transport plugin: ', this.plugin);
|
|
43486
43486
|
}
|
|
43487
|
-
Log$
|
|
43487
|
+
Log$j.debug('set transport: ', this.transport.name, this.transport.version, this.transport.configured);
|
|
43488
43488
|
}
|
|
43489
43489
|
static getTransport() {
|
|
43490
43490
|
return this.transport;
|
|
@@ -43495,7 +43495,7 @@ class TransportManager {
|
|
|
43495
43495
|
const { configureProtocolV2 } = this.transport;
|
|
43496
43496
|
if (protocolV2Messages && typeof configureProtocolV2 === 'function') {
|
|
43497
43497
|
yield configureProtocolV2.call(this.transport, JSON.stringify(protocolV2Messages));
|
|
43498
|
-
Log$
|
|
43498
|
+
Log$j.debug('Protocol V2 messages configured');
|
|
43499
43499
|
}
|
|
43500
43500
|
});
|
|
43501
43501
|
}
|
|
@@ -43617,7 +43617,7 @@ const cancelDeviceWithInitialize = (device) => {
|
|
|
43617
43617
|
},
|
|
43618
43618
|
}));
|
|
43619
43619
|
};
|
|
43620
|
-
const Log$
|
|
43620
|
+
const Log$i = getLogger(exports.LoggerNames.DeviceCommands);
|
|
43621
43621
|
const LogCore = getLogger(exports.LoggerNames.Core);
|
|
43622
43622
|
class DeviceCommands {
|
|
43623
43623
|
constructor(device, mainId) {
|
|
@@ -43626,7 +43626,7 @@ class DeviceCommands {
|
|
|
43626
43626
|
this.transport = TransportManager.getTransport();
|
|
43627
43627
|
this.disposed = false;
|
|
43628
43628
|
this.instanceId = generateInstanceId('DeviceCommands', device.sdkInstanceId);
|
|
43629
|
-
Log$
|
|
43629
|
+
Log$i.debug(`[DeviceCommands] Created: ${this.instanceId}, device: ${this.device.instanceId}`);
|
|
43630
43630
|
}
|
|
43631
43631
|
dispose(_cancelRequest) {
|
|
43632
43632
|
var _a, _b;
|
|
@@ -43679,6 +43679,7 @@ class DeviceCommands {
|
|
|
43679
43679
|
}
|
|
43680
43680
|
const activeCall = this.callPromise;
|
|
43681
43681
|
let timer;
|
|
43682
|
+
let timedOut = false;
|
|
43682
43683
|
const cancellation = (() => __awaiter(this, void 0, void 0, function* () {
|
|
43683
43684
|
yield this.dispose(true);
|
|
43684
43685
|
yield (activeCall === null || activeCall === void 0 ? void 0 : activeCall.catch(() => undefined));
|
|
@@ -43687,13 +43688,23 @@ class DeviceCommands {
|
|
|
43687
43688
|
yield Promise.race([
|
|
43688
43689
|
cancellation,
|
|
43689
43690
|
new Promise(resolve => {
|
|
43690
|
-
timer = setTimeout(
|
|
43691
|
+
timer = setTimeout(() => {
|
|
43692
|
+
timedOut = true;
|
|
43693
|
+
resolve();
|
|
43694
|
+
}, 10 * 1000);
|
|
43691
43695
|
}),
|
|
43692
43696
|
]);
|
|
43693
43697
|
}
|
|
43694
43698
|
finally {
|
|
43695
43699
|
if (timer)
|
|
43696
43700
|
clearTimeout(timer);
|
|
43701
|
+
if (timedOut &&
|
|
43702
|
+
this.transport.name === 'ReactNativeBleTransport' &&
|
|
43703
|
+
this.transport.disconnect) {
|
|
43704
|
+
yield this.transport.disconnect(this.mainId).catch(error => {
|
|
43705
|
+
Log$i.debug('BLE cancellation timeout disconnect error (ignored)', error);
|
|
43706
|
+
});
|
|
43707
|
+
}
|
|
43697
43708
|
if (this.callPromise === activeCall) {
|
|
43698
43709
|
this.callPromise = undefined;
|
|
43699
43710
|
}
|
|
@@ -43706,7 +43717,7 @@ class DeviceCommands {
|
|
|
43706
43717
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43707
43718
|
const shouldReduceDebug = shouldReduceDebugForCall(type);
|
|
43708
43719
|
if (!shouldReduceDebug) {
|
|
43709
|
-
Log$
|
|
43720
|
+
Log$i.debug('[DeviceCommands] [call] Sending', type, hdTransport.getSafeTransportLogPayload(msg !== null && msg !== void 0 ? msg : {}, type));
|
|
43710
43721
|
}
|
|
43711
43722
|
try {
|
|
43712
43723
|
const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
|
|
@@ -43765,10 +43776,10 @@ class DeviceCommands {
|
|
|
43765
43776
|
assertType(response, resType);
|
|
43766
43777
|
}
|
|
43767
43778
|
catch (error) {
|
|
43768
|
-
Log$
|
|
43779
|
+
Log$i.debug('DeviceCommands typedcall error: ', error);
|
|
43769
43780
|
if (error instanceof hdShared.HardwareError) {
|
|
43770
43781
|
if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
43771
|
-
Log$
|
|
43782
|
+
Log$i.debug('[DeviceCommands] [typedCall] Unexpected response type', {
|
|
43772
43783
|
request: type,
|
|
43773
43784
|
expected: resType,
|
|
43774
43785
|
received: response.type,
|
|
@@ -43802,7 +43813,7 @@ class DeviceCommands {
|
|
|
43802
43813
|
var _a;
|
|
43803
43814
|
try {
|
|
43804
43815
|
if (!shouldReduceDebugForCall(callType)) {
|
|
43805
|
-
Log$
|
|
43816
|
+
Log$i.debug('_filterCommonTypes: ', {
|
|
43806
43817
|
request: callType,
|
|
43807
43818
|
response: {
|
|
43808
43819
|
type: res.type,
|
|
@@ -44022,7 +44033,7 @@ class DeviceCommands {
|
|
|
44022
44033
|
reject(error);
|
|
44023
44034
|
});
|
|
44024
44035
|
const listenerCount = this.device.listenerCount(DEVICE.PIN);
|
|
44025
|
-
Log$
|
|
44036
|
+
Log$i.debug(`[${this.instanceId}] _promptPin called`, {
|
|
44026
44037
|
responseID: this.currentResponseID,
|
|
44027
44038
|
deviceInstanceId: this.device.instanceId,
|
|
44028
44039
|
listenerCount,
|
|
@@ -45079,7 +45090,7 @@ const parseRunOptions = (options) => {
|
|
|
45079
45090
|
options = {};
|
|
45080
45091
|
return options;
|
|
45081
45092
|
};
|
|
45082
|
-
const Log$
|
|
45093
|
+
const Log$h = getLogger(exports.LoggerNames.Device);
|
|
45083
45094
|
const isProtocolV2DeviceStatusUnsupportedError = (error) => {
|
|
45084
45095
|
var _a, _b, _c;
|
|
45085
45096
|
if (error instanceof hdShared.HardwareError) {
|
|
@@ -45140,7 +45151,7 @@ class Device extends events.exports {
|
|
|
45140
45151
|
this.sdkInstanceId = sdkInstanceId;
|
|
45141
45152
|
this.instanceId = generateInstanceId('Device', this.sdkInstanceId);
|
|
45142
45153
|
this.createdAt = Date.now();
|
|
45143
|
-
Log$
|
|
45154
|
+
Log$h.debug(`[Device] Created: ${this.instanceId}${this.sdkInstanceId ? ` for SDK: ${this.sdkInstanceId}` : ''}`);
|
|
45144
45155
|
}
|
|
45145
45156
|
static fromDescriptor(originalDescriptor, sdkInstanceId) {
|
|
45146
45157
|
const descriptor = Object.assign({}, originalDescriptor);
|
|
@@ -45231,12 +45242,12 @@ class Device extends events.exports {
|
|
|
45231
45242
|
if (DataManager.isBleConnect(env)) {
|
|
45232
45243
|
acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, strictProtocol, undefined));
|
|
45233
45244
|
this.mainId = (_b = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.uuid) !== null && _b !== void 0 ? _b : '';
|
|
45234
|
-
Log$
|
|
45245
|
+
Log$h.debug('Expected uuid:', this.mainId);
|
|
45235
45246
|
}
|
|
45236
45247
|
else {
|
|
45237
45248
|
acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, strictProtocol, undefined));
|
|
45238
45249
|
this.mainId = acquireResult;
|
|
45239
|
-
Log$
|
|
45250
|
+
Log$h.debug('Expected session id:', this.mainId);
|
|
45240
45251
|
}
|
|
45241
45252
|
const detectedProtocol = (_d = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.protocolType) !== null && _d !== void 0 ? _d : (_f = (_e = TransportManager.transport) === null || _e === void 0 ? void 0 : _e.getProtocolType) === null || _f === void 0 ? void 0 : _f.call(_e, DataManager.isBleConnect(env) ? this.originalDescriptor.id : this.originalDescriptor.path);
|
|
45242
45253
|
if ((options === null || options === void 0 ? void 0 : options.forceProtocolDetection) && !detectedProtocol) {
|
|
@@ -45263,7 +45274,7 @@ class Device extends events.exports {
|
|
|
45263
45274
|
yield ((_j = (_h = this.deviceConnector) === null || _h === void 0 ? void 0 : _h.release) === null || _j === void 0 ? void 0 : _j.call(_h, failedSession, false));
|
|
45264
45275
|
}
|
|
45265
45276
|
catch (releaseError) {
|
|
45266
|
-
Log$
|
|
45277
|
+
Log$h.debug('Failed to release an unsuccessful protocol probe', releaseError);
|
|
45267
45278
|
}
|
|
45268
45279
|
}
|
|
45269
45280
|
if (!DataManager.isBleConnect(env)) {
|
|
@@ -45292,11 +45303,11 @@ class Device extends events.exports {
|
|
|
45292
45303
|
(this.mainId && DataManager.isBleConnect(env))) {
|
|
45293
45304
|
if (this.pendingCallbackPromise) {
|
|
45294
45305
|
try {
|
|
45295
|
-
Log$
|
|
45306
|
+
Log$h.debug('Waiting for callback tasks to complete before releasing device (in release method)');
|
|
45296
45307
|
yield this.pendingCallbackPromise.promise;
|
|
45297
45308
|
}
|
|
45298
45309
|
catch (error) {
|
|
45299
|
-
Log$
|
|
45310
|
+
Log$h.error('Error waiting for callback tasks in release method:', error);
|
|
45300
45311
|
}
|
|
45301
45312
|
}
|
|
45302
45313
|
if (this.commands) {
|
|
@@ -45315,7 +45326,7 @@ class Device extends events.exports {
|
|
|
45315
45326
|
this.updateDescriptor({ session: null });
|
|
45316
45327
|
}
|
|
45317
45328
|
catch (err) {
|
|
45318
|
-
Log$
|
|
45329
|
+
Log$h.error('[Device] release error: ', err);
|
|
45319
45330
|
}
|
|
45320
45331
|
finally {
|
|
45321
45332
|
this.needReloadDevice = true;
|
|
@@ -45520,7 +45531,7 @@ class Device extends events.exports {
|
|
|
45520
45531
|
});
|
|
45521
45532
|
}
|
|
45522
45533
|
getInternalState(_deviceId) {
|
|
45523
|
-
Log$
|
|
45534
|
+
Log$h.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `currentDeviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
45524
45535
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
45525
45536
|
if (!deviceId)
|
|
45526
45537
|
return undefined;
|
|
@@ -45535,7 +45546,7 @@ class Device extends events.exports {
|
|
|
45535
45546
|
return deviceWalletSessionStore.getStandard(deviceId);
|
|
45536
45547
|
}
|
|
45537
45548
|
updateInternalState(enablePassphrase, passphraseState, deviceId, sessionId = null, featuresSessionId = null, walletType = 'hidden') {
|
|
45538
|
-
Log$
|
|
45549
|
+
Log$h.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `hasPassphraseState: ${Boolean(passphraseState)}`, `hasSessionId: ${Boolean(sessionId)}`, `hasFeaturesSessionId: ${Boolean(featuresSessionId)}`);
|
|
45539
45550
|
const cacheDeviceKey = this.getSessionCacheDeviceKey(deviceId);
|
|
45540
45551
|
if (!cacheDeviceKey)
|
|
45541
45552
|
return;
|
|
@@ -45551,7 +45562,7 @@ class Device extends events.exports {
|
|
|
45551
45562
|
deviceWalletSessionStore.deletePending(cacheDeviceKey);
|
|
45552
45563
|
}
|
|
45553
45564
|
setInternalState(state, initSession) {
|
|
45554
|
-
Log$
|
|
45565
|
+
Log$h.debug('setInternalState session param: ', `hasState: ${Boolean(state)}`, `initSession: ${initSession}`, `deviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
45555
45566
|
if (!this.passphraseState && !initSession)
|
|
45556
45567
|
return;
|
|
45557
45568
|
const deviceId = this.getSessionCacheDeviceKey();
|
|
@@ -45565,7 +45576,7 @@ class Device extends events.exports {
|
|
|
45565
45576
|
}
|
|
45566
45577
|
}
|
|
45567
45578
|
clearInternalState(_deviceId) {
|
|
45568
|
-
Log$
|
|
45579
|
+
Log$h.debug('clearInternalState param: ', _deviceId);
|
|
45569
45580
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
45570
45581
|
if (!deviceId)
|
|
45571
45582
|
return;
|
|
@@ -45640,14 +45651,14 @@ class Device extends events.exports {
|
|
|
45640
45651
|
assertExpectedDeviceIdentity();
|
|
45641
45652
|
}
|
|
45642
45653
|
catch (error) {
|
|
45643
|
-
Log$
|
|
45654
|
+
Log$h.error('Initialization failed:', error);
|
|
45644
45655
|
throw error;
|
|
45645
45656
|
}
|
|
45646
45657
|
});
|
|
45647
45658
|
}
|
|
45648
45659
|
_initializeProtocolV2(options) {
|
|
45649
45660
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45650
|
-
Log$
|
|
45661
|
+
Log$h.debug('Initialize device via Protocol V2 features adapter');
|
|
45651
45662
|
try {
|
|
45652
45663
|
const deviceInfo = yield requestProtocolV2DeviceInfo({
|
|
45653
45664
|
commands: this.commands,
|
|
@@ -45656,7 +45667,7 @@ class Device extends events.exports {
|
|
|
45656
45667
|
yield this.probeProtocolV2RuntimeState(deviceInfo, options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs);
|
|
45657
45668
|
}
|
|
45658
45669
|
catch (error) {
|
|
45659
|
-
Log$
|
|
45670
|
+
Log$h.error('Protocol V2 initialization failed:', error);
|
|
45660
45671
|
throw error;
|
|
45661
45672
|
}
|
|
45662
45673
|
});
|
|
@@ -45739,6 +45750,11 @@ class Device extends events.exports {
|
|
|
45739
45750
|
return params.includeRaw ? cloneDeviceState(this.state) : createPublicDeviceState(this.state);
|
|
45740
45751
|
});
|
|
45741
45752
|
}
|
|
45753
|
+
refreshProtocolV2SettingsAfterMutation() {
|
|
45754
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45755
|
+
return this.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
45756
|
+
});
|
|
45757
|
+
}
|
|
45742
45758
|
_updateFeatures(protoFeatures, initSession) {
|
|
45743
45759
|
var _a;
|
|
45744
45760
|
const previousDeviceId = this.getCurrentDeviceId();
|
|
@@ -45765,7 +45781,7 @@ class Device extends events.exports {
|
|
|
45765
45781
|
source,
|
|
45766
45782
|
changedKeys: result.changedKeys,
|
|
45767
45783
|
};
|
|
45768
|
-
Log$
|
|
45784
|
+
Log$h.debug('Device state updated', {
|
|
45769
45785
|
source,
|
|
45770
45786
|
revision: result.revision,
|
|
45771
45787
|
changedKeyCount: result.changedKeys.length,
|
|
@@ -45989,17 +46005,25 @@ class Device extends events.exports {
|
|
|
45989
46005
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45990
46006
|
if (this.runPromise) {
|
|
45991
46007
|
yield this.interruptionFromOutside();
|
|
45992
|
-
Log$
|
|
46008
|
+
Log$h.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
45993
46009
|
}
|
|
45994
46010
|
options = parseRunOptions(options);
|
|
45995
46011
|
const runPromise = hdShared.createDeferred();
|
|
45996
46012
|
this.runPromise = runPromise;
|
|
45997
|
-
this._runInner(fn, options, runPromise).catch(error => {
|
|
46013
|
+
const cleanupPromise = this._runInner(fn, options, runPromise).catch(error => {
|
|
45998
46014
|
if (this.runPromise === runPromise) {
|
|
45999
46015
|
this.runPromise = null;
|
|
46000
46016
|
}
|
|
46001
46017
|
runPromise.reject(error);
|
|
46002
46018
|
});
|
|
46019
|
+
this.runCleanupPromise = cleanupPromise;
|
|
46020
|
+
cleanupPromise
|
|
46021
|
+
.finally(() => {
|
|
46022
|
+
if (this.runCleanupPromise === cleanupPromise) {
|
|
46023
|
+
this.runCleanupPromise = undefined;
|
|
46024
|
+
}
|
|
46025
|
+
})
|
|
46026
|
+
.catch(() => undefined);
|
|
46003
46027
|
return runPromise.promise;
|
|
46004
46028
|
});
|
|
46005
46029
|
}
|
|
@@ -46066,7 +46090,7 @@ class Device extends events.exports {
|
|
|
46066
46090
|
yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
|
|
46067
46091
|
}
|
|
46068
46092
|
yield this.release();
|
|
46069
|
-
Log$
|
|
46093
|
+
Log$h.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
46070
46094
|
}
|
|
46071
46095
|
clearRunPromise();
|
|
46072
46096
|
return;
|
|
@@ -46076,7 +46100,7 @@ class Device extends events.exports {
|
|
|
46076
46100
|
options.keepSession === false) {
|
|
46077
46101
|
this.keepSession = false;
|
|
46078
46102
|
yield this.release();
|
|
46079
|
-
Log$
|
|
46103
|
+
Log$h.debug('release device, mainId: ', this.mainId);
|
|
46080
46104
|
}
|
|
46081
46105
|
runPromise.resolve();
|
|
46082
46106
|
clearRunPromise();
|
|
@@ -46093,21 +46117,33 @@ class Device extends events.exports {
|
|
|
46093
46117
|
});
|
|
46094
46118
|
}
|
|
46095
46119
|
interruptionFromUser() {
|
|
46096
|
-
var _a, _b;
|
|
46120
|
+
var _a, _b, _c;
|
|
46097
46121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46098
46122
|
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
|
|
46099
|
-
|
|
46100
|
-
|
|
46123
|
+
const cleanupPromise = this.runCleanupPromise;
|
|
46124
|
+
const { cancelableAction } = this;
|
|
46125
|
+
if (cancelableAction) {
|
|
46126
|
+
yield cancelableAction(error);
|
|
46127
|
+
}
|
|
46128
|
+
else if (this.isProtocolV2() &&
|
|
46129
|
+
DataManager.isBleConnect(DataManager.getSettings('env')) &&
|
|
46130
|
+
this.hasDeviceAcquire()) {
|
|
46131
|
+
yield ((_b = (_a = this.commands) === null || _a === void 0 ? void 0 : _a.cancelDevice) === null || _b === void 0 ? void 0 : _b.call(_a).catch(cancelError => {
|
|
46132
|
+
Log$h.debug('Protocol V2 BLE fallback cancel error', cancelError);
|
|
46133
|
+
}));
|
|
46134
|
+
}
|
|
46135
|
+
yield ((_c = this.commands) === null || _c === void 0 ? void 0 : _c.cancel());
|
|
46101
46136
|
if (this.runPromise) {
|
|
46102
46137
|
this.runPromise.reject(error);
|
|
46103
46138
|
this.runPromise = null;
|
|
46104
46139
|
}
|
|
46140
|
+
yield (cleanupPromise === null || cleanupPromise === void 0 ? void 0 : cleanupPromise.catch(() => undefined));
|
|
46105
46141
|
});
|
|
46106
46142
|
}
|
|
46107
46143
|
setCancelableAction(callback) {
|
|
46108
46144
|
this.cancelableAction = (e) => callback(e)
|
|
46109
46145
|
.catch(e2 => {
|
|
46110
|
-
Log$
|
|
46146
|
+
Log$h.debug('cancelableAction error', e2);
|
|
46111
46147
|
})
|
|
46112
46148
|
.finally(() => {
|
|
46113
46149
|
this.clearCancelableAction();
|
|
@@ -46390,7 +46426,7 @@ class Device extends events.exports {
|
|
|
46390
46426
|
expectedPassphraseState &&
|
|
46391
46427
|
expectedPassphraseState !== newPassphraseState;
|
|
46392
46428
|
const passphraseStateMismatch = !!expectedPassphraseState && expectedPassphraseState !== newPassphraseState;
|
|
46393
|
-
Log$
|
|
46429
|
+
Log$h.debug('Check passphrase state safety: ', {
|
|
46394
46430
|
hasExpectedPassphraseState: Boolean(expectedPassphraseState),
|
|
46395
46431
|
hasNewPassphraseState: Boolean(newPassphraseState),
|
|
46396
46432
|
passphraseStateMatches: Boolean(expectedPassphraseState) && expectedPassphraseState === newPassphraseState,
|
|
@@ -46528,7 +46564,7 @@ const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwar
|
|
|
46528
46564
|
};
|
|
46529
46565
|
};
|
|
46530
46566
|
|
|
46531
|
-
const Log$
|
|
46567
|
+
const Log$g = getLogger(exports.LoggerNames.Method);
|
|
46532
46568
|
const isEvmLedgerLegacyPathWithHighIndex = (path) => {
|
|
46533
46569
|
let addressN;
|
|
46534
46570
|
if (typeof path === 'string') {
|
|
@@ -46612,7 +46648,7 @@ class BaseMethod {
|
|
|
46612
46648
|
setContext(context) {
|
|
46613
46649
|
this.sdkInstanceId = context.sdkInstanceId;
|
|
46614
46650
|
this.instanceId = generateInstanceId('Method', this.sdkInstanceId);
|
|
46615
|
-
Log$
|
|
46651
|
+
Log$g.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
|
|
46616
46652
|
}
|
|
46617
46653
|
setDevice(device) {
|
|
46618
46654
|
var _a, _b;
|
|
@@ -46632,7 +46668,7 @@ class BaseMethod {
|
|
|
46632
46668
|
if (device.commands) {
|
|
46633
46669
|
device.commands.currentResponseID = this.responseID;
|
|
46634
46670
|
}
|
|
46635
|
-
Log$
|
|
46671
|
+
Log$g.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
|
|
46636
46672
|
}
|
|
46637
46673
|
checkFirmwareRelease() {
|
|
46638
46674
|
if (!this.device || this.device.isProtocolV2())
|
|
@@ -46707,7 +46743,7 @@ class BaseMethod {
|
|
|
46707
46743
|
checkFlag = true;
|
|
46708
46744
|
}
|
|
46709
46745
|
if (checkFlag && this.device.getCurrentSafetyChecks() === hdTransport.Enum_SafetyCheckLevel.Strict) {
|
|
46710
|
-
Log$
|
|
46746
|
+
Log$g.debug('will change safety_checks level');
|
|
46711
46747
|
yield this.device.commands.typedCall('ApplySettings', 'Success', {
|
|
46712
46748
|
safety_checks: hdTransport.Enum_SafetyCheckLevel.PromptTemporarily,
|
|
46713
46749
|
});
|
|
@@ -46783,7 +46819,7 @@ class Ping extends BaseMethod {
|
|
|
46783
46819
|
}
|
|
46784
46820
|
}
|
|
46785
46821
|
|
|
46786
|
-
const Log$
|
|
46822
|
+
const Log$f = getLogger(exports.LoggerNames.Core);
|
|
46787
46823
|
const parseInitOptions$1 = (payload) => ({
|
|
46788
46824
|
initSession: payload === null || payload === void 0 ? void 0 : payload.initSession,
|
|
46789
46825
|
passphraseState: payload === null || payload === void 0 ? void 0 : payload.passphraseState,
|
|
@@ -46809,14 +46845,14 @@ class PreInitialize extends BaseMethod {
|
|
|
46809
46845
|
}
|
|
46810
46846
|
catch (_a) {
|
|
46811
46847
|
this.device.clearPreInitialized();
|
|
46812
|
-
Log$
|
|
46848
|
+
Log$f.debug('[PRE-INIT][FAILED]');
|
|
46813
46849
|
return false;
|
|
46814
46850
|
}
|
|
46815
46851
|
});
|
|
46816
46852
|
}
|
|
46817
46853
|
}
|
|
46818
46854
|
|
|
46819
|
-
const Log$
|
|
46855
|
+
const Log$e = getLogger(exports.LoggerNames.DevicePool);
|
|
46820
46856
|
class SearchDevices extends BaseMethod {
|
|
46821
46857
|
init() {
|
|
46822
46858
|
this.useDevice = false;
|
|
@@ -46858,7 +46894,7 @@ class SearchDevices extends BaseMethod {
|
|
|
46858
46894
|
const errorCode = error && typeof error === 'object' && 'errorCode' in error
|
|
46859
46895
|
? error.errorCode
|
|
46860
46896
|
: undefined;
|
|
46861
|
-
Log$
|
|
46897
|
+
Log$e.debug('Skip unavailable device during search', Object.assign({ path: descriptor.path }, (errorCode !== undefined ? { errorCode } : {})));
|
|
46862
46898
|
}
|
|
46863
46899
|
}
|
|
46864
46900
|
return deviceList.map(device => device.toMessageObject());
|
|
@@ -47760,7 +47796,7 @@ function buildProtocolV2FirmwareRelease({ currentVersions, currentVerification =
|
|
|
47760
47796
|
release,
|
|
47761
47797
|
};
|
|
47762
47798
|
}
|
|
47763
|
-
const Log$
|
|
47799
|
+
const Log$d = getLogger(exports.LoggerNames.Method);
|
|
47764
47800
|
class CheckAllFirmwareRelease extends BaseMethod {
|
|
47765
47801
|
getSupportedProtocols() {
|
|
47766
47802
|
return ['V1', 'V2'];
|
|
@@ -47821,7 +47857,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47821
47857
|
((_c = error.params) === null || _c === void 0 ? void 0 : _c.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47822
47858
|
throw error;
|
|
47823
47859
|
}
|
|
47824
|
-
Log$
|
|
47860
|
+
Log$d.warn('[CheckAllFirmwareRelease] Optional firmware Plan is unavailable; using the legacy release result');
|
|
47825
47861
|
firmwareUpdatePlan = undefined;
|
|
47826
47862
|
}
|
|
47827
47863
|
return {
|
|
@@ -47907,7 +47943,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47907
47943
|
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47908
47944
|
throw error;
|
|
47909
47945
|
}
|
|
47910
|
-
Log$
|
|
47946
|
+
Log$d.warn('[CheckAllFirmwareRelease] Optional Protocol V2 firmware Plan is unavailable; using the release result');
|
|
47911
47947
|
firmwareUpdatePlan = undefined;
|
|
47912
47948
|
}
|
|
47913
47949
|
const firmwarePlan = summarizeProtocolV2FirmwareRelease(plan, PROTOCOL_V2_MAIN_FIRMWARE_TARGETS);
|
|
@@ -48474,7 +48510,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
48474
48510
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48475
48511
|
try {
|
|
48476
48512
|
if (this.device.isProtocolV2()) {
|
|
48477
|
-
const refreshStatusAndSettings = () => this.device.
|
|
48513
|
+
const refreshStatusAndSettings = () => this.device.refreshProtocolV2SettingsAfterMutation();
|
|
48478
48514
|
assertSettingsSupported(this.payload, DEVICE_SETTINGS_V1_ONLY_FIELDS, 'Protocol V2');
|
|
48479
48515
|
const capabilities = getDeviceSettingsCapabilities(this.device.getCurrentDeviceType(), 'V2');
|
|
48480
48516
|
assertProtocolV2SettingValues(this.payload, capabilities);
|
|
@@ -48497,14 +48533,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
48497
48533
|
const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', {
|
|
48498
48534
|
page: hdTransport.DeviceSettingsPage.DevicePassphrase,
|
|
48499
48535
|
});
|
|
48500
|
-
|
|
48501
|
-
const lockedAfterDisabling = requestedPassphrase === false &&
|
|
48502
|
-
current.status.unlocked === true &&
|
|
48503
|
-
updated.status.unlocked === false;
|
|
48504
|
-
if (updated.status.passphraseProtection !== requestedPassphrase &&
|
|
48505
|
-
!lockedAfterDisabling) {
|
|
48506
|
-
throw hdShared.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 passphrase setting did not reach the requested value.');
|
|
48507
|
-
}
|
|
48536
|
+
yield refreshStatusAndSettings();
|
|
48508
48537
|
return res.message;
|
|
48509
48538
|
}
|
|
48510
48539
|
if (requestedAirgap !== undefined) {
|
|
@@ -48893,7 +48922,7 @@ const getInfo = ({ features, updateType, targetVersion, firmwareType }) => {
|
|
|
48893
48922
|
const NEW_BOOT_UPRATE_FIRMWARE_VERSION = '2.4.5';
|
|
48894
48923
|
const SESSION_ERROR$3 = 'session not found';
|
|
48895
48924
|
const FIRMWARE_UPDATE_CONFIRM$1 = 'Firmware install confirmed';
|
|
48896
|
-
const Log$
|
|
48925
|
+
const Log$c = getLogger(exports.LoggerNames.Method);
|
|
48897
48926
|
const isDeviceDisconnectedError$1 = (error) => {
|
|
48898
48927
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
48899
48928
|
return (message.includes('device was disconnected') ||
|
|
@@ -48948,13 +48977,13 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48948
48977
|
const newFeatures = yield typedCall('GetFeatures', 'Features', {});
|
|
48949
48978
|
const deviceBootloaderVersion = getDeviceBootloaderVersion(buildProtocolV1FeaturesPayload(newFeatures.message, device.features)).join('.');
|
|
48950
48979
|
const supportUpgradeFileHeader = semver__default["default"].gte(deviceBootloaderVersion, '2.1.0');
|
|
48951
|
-
Log$
|
|
48980
|
+
Log$c.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
|
|
48952
48981
|
if (supportUpgradeFileHeader) {
|
|
48953
48982
|
const HEADER_SIZE = 1024;
|
|
48954
48983
|
if (source.size < HEADER_SIZE) {
|
|
48955
48984
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${source.size} bytes, expected at least ${HEADER_SIZE} bytes`);
|
|
48956
48985
|
}
|
|
48957
|
-
Log$
|
|
48986
|
+
Log$c.debug('Uploading firmware header:', {
|
|
48958
48987
|
size: HEADER_SIZE,
|
|
48959
48988
|
totalSize: source.size,
|
|
48960
48989
|
});
|
|
@@ -48966,18 +48995,18 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48966
48995
|
});
|
|
48967
48996
|
const isUnknownMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage');
|
|
48968
48997
|
if (headerRes.type !== 'Success' && !isUnknownMessage) {
|
|
48969
|
-
Log$
|
|
48998
|
+
Log$c.error('Firmware header upload failed:', headerRes);
|
|
48970
48999
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
|
|
48971
49000
|
}
|
|
48972
49001
|
}
|
|
48973
49002
|
catch (error) {
|
|
48974
|
-
Log$
|
|
49003
|
+
Log$c.error('Firmware header upload failed:', error);
|
|
48975
49004
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
48976
49005
|
if (!message.includes('Failure_UnknownMessage')) {
|
|
48977
49006
|
throw error;
|
|
48978
49007
|
}
|
|
48979
49008
|
}
|
|
48980
|
-
Log$
|
|
49009
|
+
Log$c.debug('Firmware header uploaded successfully');
|
|
48981
49010
|
}
|
|
48982
49011
|
}
|
|
48983
49012
|
const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
|
|
@@ -48996,7 +49025,7 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48996
49025
|
}
|
|
48997
49026
|
catch (error) {
|
|
48998
49027
|
if (isDeviceDisconnectedError$1(error)) {
|
|
48999
|
-
Log$
|
|
49028
|
+
Log$c.log('Rebooting device');
|
|
49000
49029
|
updateResponse = {
|
|
49001
49030
|
type: 'Success',
|
|
49002
49031
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49094,7 +49123,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49094
49123
|
}
|
|
49095
49124
|
catch (error) {
|
|
49096
49125
|
if (isDeviceDisconnectedError$1(error)) {
|
|
49097
|
-
Log$
|
|
49126
|
+
Log$c.log('Rebooting device');
|
|
49098
49127
|
response = {
|
|
49099
49128
|
type: 'Success',
|
|
49100
49129
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49125,7 +49154,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49125
49154
|
]);
|
|
49126
49155
|
}
|
|
49127
49156
|
catch (e) {
|
|
49128
|
-
Log$
|
|
49157
|
+
Log$c.log('catch Bluetooth error when device is restarting: ', e);
|
|
49129
49158
|
}
|
|
49130
49159
|
}
|
|
49131
49160
|
else {
|
|
@@ -49146,7 +49175,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49146
49175
|
}
|
|
49147
49176
|
catch (error) {
|
|
49148
49177
|
console.error('Device reconnect failed: ', error);
|
|
49149
|
-
Log$
|
|
49178
|
+
Log$c.error('Device reconnect failed:', error);
|
|
49150
49179
|
yield wait(1000);
|
|
49151
49180
|
}
|
|
49152
49181
|
}
|
|
@@ -49186,7 +49215,7 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
|
|
|
49186
49215
|
return result;
|
|
49187
49216
|
}
|
|
49188
49217
|
catch (error) {
|
|
49189
|
-
Log$
|
|
49218
|
+
Log$c.error(`emmcWrite error: `, error);
|
|
49190
49219
|
retryCount--;
|
|
49191
49220
|
if (retryCount === 0) {
|
|
49192
49221
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -49381,7 +49410,7 @@ class DeviceFullyUploadResource extends BaseMethod {
|
|
|
49381
49410
|
}
|
|
49382
49411
|
}
|
|
49383
49412
|
|
|
49384
|
-
const Log$
|
|
49413
|
+
const Log$b = getLogger(exports.LoggerNames.Method);
|
|
49385
49414
|
const SESSION_ERROR$2 = 'session not found';
|
|
49386
49415
|
const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
49387
49416
|
const BOOTLOADER_POLL_INITIALIZE_TIMEOUT_MS = 5000;
|
|
@@ -49459,7 +49488,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49459
49488
|
const env = DataManager.getSettings('env');
|
|
49460
49489
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
49461
49490
|
let bleProbeInFlight = false;
|
|
49462
|
-
Log$
|
|
49491
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
49463
49492
|
let isFirstCheck = true;
|
|
49464
49493
|
let checkCount = 0;
|
|
49465
49494
|
let hasPromptedWebDevice = false;
|
|
@@ -49493,10 +49522,10 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49493
49522
|
if (isFinished || isPromptingWebDevice)
|
|
49494
49523
|
return;
|
|
49495
49524
|
checkCount += 1;
|
|
49496
|
-
Log$
|
|
49525
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
49497
49526
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
49498
49527
|
isFirstCheck = false;
|
|
49499
|
-
Log$
|
|
49528
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] wait 3000ms');
|
|
49500
49529
|
yield wait(3000);
|
|
49501
49530
|
}
|
|
49502
49531
|
if (checkCount > 4 &&
|
|
@@ -49520,7 +49549,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49520
49549
|
catch (e) {
|
|
49521
49550
|
isFinished = true;
|
|
49522
49551
|
clearPollingTimers();
|
|
49523
|
-
Log$
|
|
49552
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
49524
49553
|
(_c = this.checkPromise) === null || _c === void 0 ? void 0 : _c.reject(e);
|
|
49525
49554
|
}
|
|
49526
49555
|
finally {
|
|
@@ -49542,7 +49571,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49542
49571
|
}
|
|
49543
49572
|
}
|
|
49544
49573
|
catch (e) {
|
|
49545
|
-
Log$
|
|
49574
|
+
Log$b.log('catch Bluetooth error when device is restarting: ', e);
|
|
49546
49575
|
}
|
|
49547
49576
|
finally {
|
|
49548
49577
|
bleProbeInFlight = false;
|
|
@@ -49645,7 +49674,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49645
49674
|
}
|
|
49646
49675
|
catch (error) {
|
|
49647
49676
|
if (isDeviceDisconnectedError(error)) {
|
|
49648
|
-
Log$
|
|
49677
|
+
Log$b.log('Rebooting device');
|
|
49649
49678
|
updateResponse = {
|
|
49650
49679
|
type: 'Success',
|
|
49651
49680
|
message: { message: FIRMWARE_UPDATE_CONFIRM },
|
|
@@ -49761,7 +49790,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49761
49790
|
return result;
|
|
49762
49791
|
}
|
|
49763
49792
|
catch (error) {
|
|
49764
|
-
Log$
|
|
49793
|
+
Log$b.error(`emmcWrite error: `, error);
|
|
49765
49794
|
retryCount--;
|
|
49766
49795
|
if (retryCount === 0) {
|
|
49767
49796
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -50068,7 +50097,7 @@ class GetNextU2FCounter extends BaseMethod {
|
|
|
50068
50097
|
}
|
|
50069
50098
|
}
|
|
50070
50099
|
|
|
50071
|
-
const Log$
|
|
50100
|
+
const Log$a = getLogger(exports.LoggerNames.Method);
|
|
50072
50101
|
class FirmwareUpdate extends BaseMethod {
|
|
50073
50102
|
constructor() {
|
|
50074
50103
|
super(...arguments);
|
|
@@ -50107,7 +50136,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50107
50136
|
const env = DataManager.getSettings('env');
|
|
50108
50137
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50109
50138
|
let bleProbeInFlight = false;
|
|
50110
|
-
Log$
|
|
50139
|
+
Log$a.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50111
50140
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
50112
50141
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
50113
50142
|
if (isBleReconnect) {
|
|
@@ -50123,7 +50152,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50123
50152
|
}
|
|
50124
50153
|
}
|
|
50125
50154
|
catch (e) {
|
|
50126
|
-
Log$
|
|
50155
|
+
Log$a.log('catch Bluetooth error when device is restarting: ', e);
|
|
50127
50156
|
}
|
|
50128
50157
|
finally {
|
|
50129
50158
|
bleProbeInFlight = false;
|
|
@@ -50182,7 +50211,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50182
50211
|
if (e instanceof hdShared.HardwareError) {
|
|
50183
50212
|
return Promise.reject(e);
|
|
50184
50213
|
}
|
|
50185
|
-
Log$
|
|
50214
|
+
Log$a.log('auto go to bootloader mode failed: ', e);
|
|
50186
50215
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure));
|
|
50187
50216
|
}
|
|
50188
50217
|
}
|
|
@@ -50331,7 +50360,7 @@ const readVerifiedPreparedResourceArchive = ({ preparedPlan, reader, }) => __awa
|
|
|
50331
50360
|
return verifiedEntries;
|
|
50332
50361
|
});
|
|
50333
50362
|
|
|
50334
|
-
const Log$
|
|
50363
|
+
const Log$9 = getLogger(exports.LoggerNames.Method);
|
|
50335
50364
|
const FIRMWARE_DOWNLOAD_REQUEST_OPTIONS = {
|
|
50336
50365
|
connectTimeoutMs: 60000,
|
|
50337
50366
|
readTimeoutMs: 60000,
|
|
@@ -50488,7 +50517,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50488
50517
|
const env = DataManager.getSettings('env');
|
|
50489
50518
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50490
50519
|
let probeInFlight = false;
|
|
50491
|
-
Log$
|
|
50520
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50492
50521
|
let isFirstCheck = true;
|
|
50493
50522
|
let checkCount = 0;
|
|
50494
50523
|
let hasPromptedWebDevice = false;
|
|
@@ -50523,10 +50552,10 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50523
50552
|
return;
|
|
50524
50553
|
probeInFlight = true;
|
|
50525
50554
|
checkCount += 1;
|
|
50526
|
-
Log$
|
|
50555
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
50527
50556
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
50528
50557
|
isFirstCheck = false;
|
|
50529
|
-
Log$
|
|
50558
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] wait 3000ms');
|
|
50530
50559
|
yield wait(3000);
|
|
50531
50560
|
}
|
|
50532
50561
|
if (checkCount > 4 &&
|
|
@@ -50550,7 +50579,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50550
50579
|
catch (e) {
|
|
50551
50580
|
isFinished = true;
|
|
50552
50581
|
clearPollingTimers();
|
|
50553
|
-
Log$
|
|
50582
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
50554
50583
|
(_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.reject(e);
|
|
50555
50584
|
}
|
|
50556
50585
|
finally {
|
|
@@ -50570,7 +50599,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50570
50599
|
}
|
|
50571
50600
|
}
|
|
50572
50601
|
catch (e) {
|
|
50573
|
-
Log$
|
|
50602
|
+
Log$9.log('catch Bluetooth error when device is restarting: ', e);
|
|
50574
50603
|
}
|
|
50575
50604
|
finally {
|
|
50576
50605
|
probeInFlight = false;
|
|
@@ -50865,7 +50894,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50865
50894
|
}
|
|
50866
50895
|
}
|
|
50867
50896
|
|
|
50868
|
-
const Log$
|
|
50897
|
+
const Log$8 = getLogger(exports.LoggerNames.Method);
|
|
50869
50898
|
const MIN_UPDATE_V3_BOOTLOADER_VERSION = '2.8.0';
|
|
50870
50899
|
class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
50871
50900
|
constructor() {
|
|
@@ -50983,7 +51012,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
50983
51012
|
}
|
|
50984
51013
|
run() {
|
|
50985
51014
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50986
|
-
Log$
|
|
51015
|
+
Log$8.debug('FirmwareUpdateV3 strategy: Protocol V1');
|
|
50987
51016
|
return this.runProtocolV1();
|
|
50988
51017
|
});
|
|
50989
51018
|
}
|
|
@@ -51130,7 +51159,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51130
51159
|
resourceEntries: [],
|
|
51131
51160
|
};
|
|
51132
51161
|
}
|
|
51133
|
-
Log$
|
|
51162
|
+
Log$8.warn('No resource url found');
|
|
51134
51163
|
return {
|
|
51135
51164
|
resourceBinary: null,
|
|
51136
51165
|
resourceEntries: [],
|
|
@@ -51291,7 +51320,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51291
51320
|
yield this.startEmmcFirmwareUpdate({ path: '0:updates' });
|
|
51292
51321
|
}
|
|
51293
51322
|
catch (error) {
|
|
51294
|
-
Log$
|
|
51323
|
+
Log$8.error('triggerFirmwareUpdateEmmc error: ', error);
|
|
51295
51324
|
if (error === null || error === void 0 ? void 0 : error.errorCode) {
|
|
51296
51325
|
const unexpectedError = [
|
|
51297
51326
|
hdShared.HardwareErrorCode.ActionCancelled,
|
|
@@ -51361,7 +51390,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51361
51390
|
yield hdShared.wait(1000);
|
|
51362
51391
|
}
|
|
51363
51392
|
catch (error) {
|
|
51364
|
-
Log$
|
|
51393
|
+
Log$8.log('getFeatures error', error);
|
|
51365
51394
|
let shouldReconnect = true;
|
|
51366
51395
|
const progress = this.extractUpdateModeProgress(error);
|
|
51367
51396
|
if (progress !== null) {
|
|
@@ -51460,7 +51489,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51460
51489
|
return;
|
|
51461
51490
|
}
|
|
51462
51491
|
catch (e) {
|
|
51463
|
-
Log$
|
|
51492
|
+
Log$8.log('catch Bluetooth error when device is restarting: ', e);
|
|
51464
51493
|
}
|
|
51465
51494
|
}
|
|
51466
51495
|
else {
|
|
@@ -51475,7 +51504,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51475
51504
|
yield this._promptDeviceForSwitchFirmwareWebDevice();
|
|
51476
51505
|
}
|
|
51477
51506
|
catch (e) {
|
|
51478
|
-
Log$
|
|
51507
|
+
Log$8.log('WebUSB re-authorization failed: ', e);
|
|
51479
51508
|
}
|
|
51480
51509
|
webUsbCheckCount = 0;
|
|
51481
51510
|
}
|
|
@@ -51500,7 +51529,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51500
51529
|
}
|
|
51501
51530
|
catch (error) {
|
|
51502
51531
|
console.error('Device reconnect failed: ', error);
|
|
51503
|
-
Log$
|
|
51532
|
+
Log$8.error('Device reconnect failed:', error);
|
|
51504
51533
|
yield hdShared.wait(1000);
|
|
51505
51534
|
}
|
|
51506
51535
|
}
|
|
@@ -51684,7 +51713,7 @@ function prepareFirmwareUpdateV4MemoryHost({ sdk, plan, artifacts, }) {
|
|
|
51684
51713
|
};
|
|
51685
51714
|
}
|
|
51686
51715
|
|
|
51687
|
-
const Log$
|
|
51716
|
+
const Log$7 = getLogger(exports.LoggerNames.Method);
|
|
51688
51717
|
const SESSION_ERROR$1 = 'session not found';
|
|
51689
51718
|
const PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT = 90 * 1000;
|
|
51690
51719
|
const PROTOCOL_V2_FINAL_RECONNECT_TIMEOUT = 3 * 60 * 1000;
|
|
@@ -52162,7 +52191,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52162
52191
|
}
|
|
52163
52192
|
run() {
|
|
52164
52193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52165
|
-
Log$
|
|
52194
|
+
Log$7.debug('FirmwareUpdateV4 strategy: Protocol V2');
|
|
52166
52195
|
return this.runProtocolV2();
|
|
52167
52196
|
});
|
|
52168
52197
|
}
|
|
@@ -52737,7 +52766,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52737
52766
|
: `${Math.floor(statusVersion / 0x10000) % 0x100}.${Math.floor(statusVersion / 0x100) % 0x100}.${statusVersion % 0x100}`;
|
|
52738
52767
|
if (!observedVersion) {
|
|
52739
52768
|
if (this.protocolV2FinalStatusVerified) {
|
|
52740
|
-
Log$
|
|
52769
|
+
Log$7.warn(`Protocol V2 target ${target} has no observable final version; completed target status is authoritative`);
|
|
52741
52770
|
}
|
|
52742
52771
|
else {
|
|
52743
52772
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, `Protocol V2 target ${target} has no observable final version after status fallback`);
|
|
@@ -53107,7 +53136,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53107
53136
|
return true;
|
|
53108
53137
|
}
|
|
53109
53138
|
catch (error) {
|
|
53110
|
-
Log$
|
|
53139
|
+
Log$7.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53111
53140
|
return false;
|
|
53112
53141
|
}
|
|
53113
53142
|
});
|
|
@@ -53147,7 +53176,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53147
53176
|
if (error instanceof hdShared.HardwareError) {
|
|
53148
53177
|
throw error;
|
|
53149
53178
|
}
|
|
53150
|
-
Log$
|
|
53179
|
+
Log$7.log('Protocol V2 auto go to bootloader mode failed: ', error);
|
|
53151
53180
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
53152
53181
|
}
|
|
53153
53182
|
});
|
|
@@ -53155,12 +53184,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53155
53184
|
enterProtocolV2BootloaderMode() {
|
|
53156
53185
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53157
53186
|
if (this.isProtocolV2RomloaderMode()) {
|
|
53158
|
-
Log$
|
|
53187
|
+
Log$7.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
53159
53188
|
this.protocolV2ExecutionInLoader = true;
|
|
53160
53189
|
return false;
|
|
53161
53190
|
}
|
|
53162
53191
|
if (this.isProtocolV2BootloaderMode()) {
|
|
53163
|
-
Log$
|
|
53192
|
+
Log$7.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
53164
53193
|
this.protocolV2ExecutionInLoader = true;
|
|
53165
53194
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.GoToBootloaderSuccess);
|
|
53166
53195
|
return false;
|
|
@@ -53196,7 +53225,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53196
53225
|
}
|
|
53197
53226
|
shouldReconnect = true;
|
|
53198
53227
|
lastError = error;
|
|
53199
|
-
Log$
|
|
53228
|
+
Log$7.log('Protocol V2 bootloader mode not ready, polling reconnect: ', error);
|
|
53200
53229
|
}
|
|
53201
53230
|
yield hdShared.wait(retryInterval);
|
|
53202
53231
|
}
|
|
@@ -53293,7 +53322,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53293
53322
|
for (const resource of resourceSources) {
|
|
53294
53323
|
const requiresFreshStaging = isProtocolV2BootResourcePackagePath(resource.devicePath);
|
|
53295
53324
|
if (!requiresFreshStaging && (yield this.isProtocolV2ResourceBundleUpToDate(resource))) {
|
|
53296
|
-
Log$
|
|
53325
|
+
Log$7.log(`[FirmwareUpdateV4] skip RESC bundle ${resource.name}; already up to date`);
|
|
53297
53326
|
}
|
|
53298
53327
|
else {
|
|
53299
53328
|
resourcesToSync.push(resource);
|
|
@@ -53408,7 +53437,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53408
53437
|
}
|
|
53409
53438
|
assertProtocolV2TargetStatus(statusTargets, expectedTargetIds, expectedPaths = new Map()) {
|
|
53410
53439
|
var _a, _b, _c;
|
|
53411
|
-
Log$
|
|
53440
|
+
Log$7.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateStatus records=${JSON.stringify(statusTargets)}`);
|
|
53412
53441
|
const failedTarget = statusTargets.find(target => {
|
|
53413
53442
|
var _a;
|
|
53414
53443
|
return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1) &&
|
|
@@ -53421,7 +53450,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53421
53450
|
payloadVersion: failedTarget.payload_version,
|
|
53422
53451
|
path: failedTarget.path,
|
|
53423
53452
|
});
|
|
53424
|
-
Log$
|
|
53453
|
+
Log$7.error(`[FirmwareUpdateV4] firmware install failed target=${failedTargetDetails}`);
|
|
53425
53454
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, `Protocol V2 firmware target failed: target=${failedTarget.target_id} status=${(_a = failedTarget.status) !== null && _a !== void 0 ? _a : 'unknown'} payloadVersion=${(_b = failedTarget.payload_version) !== null && _b !== void 0 ? _b : 'unknown'} path=${(_c = failedTarget.path) !== null && _c !== void 0 ? _c : 'unknown'}`);
|
|
53426
53455
|
}
|
|
53427
53456
|
const matchingTargets = statusTargets.filter(target => { var _a; return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1); });
|
|
@@ -53596,7 +53625,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53596
53625
|
if (isNormalMode &&
|
|
53597
53626
|
(installEvidenceObserved ||
|
|
53598
53627
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53599
|
-
Log$
|
|
53628
|
+
Log$7.log('[FirmwareUpdateV4] empty firmware status after confirmed App reboot; update complete');
|
|
53600
53629
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53601
53630
|
return;
|
|
53602
53631
|
}
|
|
@@ -53644,7 +53673,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53644
53673
|
if (isNormalMode &&
|
|
53645
53674
|
(installEvidenceObserved ||
|
|
53646
53675
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53647
|
-
Log$
|
|
53676
|
+
Log$7.log('[FirmwareUpdateV4] firmware status endpoint unavailable after confirmed App reboot');
|
|
53648
53677
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53649
53678
|
return;
|
|
53650
53679
|
}
|
|
@@ -53666,7 +53695,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53666
53695
|
shouldReconnect = true;
|
|
53667
53696
|
deviceInfo = undefined;
|
|
53668
53697
|
lastError = error;
|
|
53669
|
-
Log$
|
|
53698
|
+
Log$7.log('[FirmwareUpdateV4] DeviceFirmwareUpdateStatusGet unavailable during install: ', error);
|
|
53670
53699
|
}
|
|
53671
53700
|
}
|
|
53672
53701
|
}
|
|
@@ -53685,7 +53714,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53685
53714
|
shouldReconnect = true;
|
|
53686
53715
|
deviceInfo = undefined;
|
|
53687
53716
|
resetMissingTargetStatusGrace();
|
|
53688
|
-
Log$
|
|
53717
|
+
Log$7.log('Protocol V2 firmware install device readiness probe failed: ', error);
|
|
53689
53718
|
}
|
|
53690
53719
|
yield hdShared.wait(1000);
|
|
53691
53720
|
}
|
|
@@ -53698,12 +53727,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53698
53727
|
const deviceInfo = yield this.verifyProtocolV2ReconnectIdentity();
|
|
53699
53728
|
try {
|
|
53700
53729
|
if (yield this.probeProtocolV2NormalMode(deviceInfo)) {
|
|
53701
|
-
Log$
|
|
53730
|
+
Log$7.log('[FirmwareUpdateV4] device already returned to App mode; skip Normal reboot');
|
|
53702
53731
|
return;
|
|
53703
53732
|
}
|
|
53704
53733
|
}
|
|
53705
53734
|
catch (error) {
|
|
53706
|
-
Log$
|
|
53735
|
+
Log$7.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
53707
53736
|
}
|
|
53708
53737
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
53709
53738
|
this.protocolV2ExecutionInLoader = false;
|
|
@@ -53731,7 +53760,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53731
53760
|
const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
|
|
53732
53761
|
this.protocolV2LatestFinalFeatures = features;
|
|
53733
53762
|
if (firmwareVersion === '0.0.0') {
|
|
53734
|
-
Log$
|
|
53763
|
+
Log$7.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.');
|
|
53735
53764
|
}
|
|
53736
53765
|
return {
|
|
53737
53766
|
bootloaderVersion,
|
|
@@ -53780,7 +53809,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53780
53809
|
}
|
|
53781
53810
|
shouldReconnect = true;
|
|
53782
53811
|
lastError = error;
|
|
53783
|
-
Log$
|
|
53812
|
+
Log$7.log('Protocol V2 normal mode not ready, polling Ping: ', error);
|
|
53784
53813
|
}
|
|
53785
53814
|
yield hdShared.wait(1000);
|
|
53786
53815
|
}
|
|
@@ -53824,7 +53853,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53824
53853
|
if (!reconnectDevice) {
|
|
53825
53854
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
|
|
53826
53855
|
}
|
|
53827
|
-
Log$
|
|
53856
|
+
Log$7.debug('Protocol V2 firmware reconnect using matched device:', reconnectDevice.getConnectId());
|
|
53828
53857
|
this.device.updateFromCache(reconnectDevice);
|
|
53829
53858
|
yield this.ensureProtocolV2DeviceAcquired();
|
|
53830
53859
|
this.device.commands.disposed = false;
|
|
@@ -53930,7 +53959,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53930
53959
|
}
|
|
53931
53960
|
}
|
|
53932
53961
|
|
|
53933
|
-
const Log$
|
|
53962
|
+
const Log$6 = getLogger(exports.LoggerNames.Method);
|
|
53934
53963
|
class PromptWebDeviceAccess extends BaseMethod {
|
|
53935
53964
|
init() {
|
|
53936
53965
|
this.useDevice = false;
|
|
@@ -53985,7 +54014,7 @@ class PromptWebDeviceAccess extends BaseMethod {
|
|
|
53985
54014
|
return { device: null };
|
|
53986
54015
|
}
|
|
53987
54016
|
catch (error) {
|
|
53988
|
-
Log$
|
|
54017
|
+
Log$6.debug(error);
|
|
53989
54018
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
|
|
53990
54019
|
}
|
|
53991
54020
|
});
|
|
@@ -54088,7 +54117,7 @@ function decodeJpegBase64ToRgba({ jpegBase64, parameterName, expectedWidth, expe
|
|
|
54088
54117
|
return decoded;
|
|
54089
54118
|
}
|
|
54090
54119
|
|
|
54091
|
-
const Log$
|
|
54120
|
+
const Log$5 = getLogger(exports.LoggerNames.Core);
|
|
54092
54121
|
const MIN_FILE_CHUNK_SIZE = 64;
|
|
54093
54122
|
const FILE_TRANSFER_RATE_WINDOW_MS = 1000;
|
|
54094
54123
|
const FILE_TRANSFER_LOG_INTERVAL_MS = 10000;
|
|
@@ -54109,7 +54138,7 @@ function logFileTransferMetrics({ transport, status, path, transferredBytes, tot
|
|
|
54109
54138
|
const segmentedMetrics = measuredAttempts > 0
|
|
54110
54139
|
? ` hostWriteTotal=${(hostWriteElapsedMs / 1000).toFixed(2)}s responseWaitTotal=${(responseWaitElapsedMs / 1000).toFixed(2)}s measuredAttempts=${measuredAttempts}`
|
|
54111
54140
|
: '';
|
|
54112
|
-
Log$
|
|
54141
|
+
Log$5.log(`[FileWrite] metrics transport=${transport} status=${status} path=${path} bytes=${transferredBytes}/${totalBytes} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatFileTransferRate(rateBytesPerSecond)} KiB/s${segmentedMetrics}`);
|
|
54113
54142
|
}
|
|
54114
54143
|
function isProtocolV2ResponseTimeout(error) {
|
|
54115
54144
|
var _a, _b;
|
|
@@ -54200,7 +54229,7 @@ function writeProtocolV2File(options) {
|
|
|
54200
54229
|
let responseWaitElapsedMs = 0;
|
|
54201
54230
|
let measuredAttempts = 0;
|
|
54202
54231
|
const transport = getFileTransferTransport();
|
|
54203
|
-
Log$
|
|
54232
|
+
Log$5.log(`[FileWrite] started transport=${transport} path=${options.path} bytes=${dataLength} offset=${startOffset} chunk=${chunkSize}`);
|
|
54204
54233
|
try {
|
|
54205
54234
|
while (written < dataLength) {
|
|
54206
54235
|
(_c = options.throwIfAborted) === null || _c === void 0 ? void 0 : _c.call(options);
|
|
@@ -54367,6 +54396,7 @@ const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
|
|
|
54367
54396
|
const DEVICE_SETTINGS_SET_MESSAGE_TYPE = 60412;
|
|
54368
54397
|
const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE$2 = 60805;
|
|
54369
54398
|
const FILESYSTEM_DIR_MAKE_MESSAGE_TYPE = 60809;
|
|
54399
|
+
const Log$4 = getLogger(exports.LoggerNames.Method);
|
|
54370
54400
|
function normalizeFileName(fileName, data) {
|
|
54371
54401
|
if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
|
|
54372
54402
|
throw invalidParameter$1('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
|
|
@@ -54474,6 +54504,14 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
54474
54504
|
const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
|
|
54475
54505
|
settings: { wallpaper_path: this.path },
|
|
54476
54506
|
});
|
|
54507
|
+
try {
|
|
54508
|
+
yield this.device.refreshProtocolV2SettingsAfterMutation();
|
|
54509
|
+
}
|
|
54510
|
+
catch (error) {
|
|
54511
|
+
Log$4.warn('Protocol V2 wallpaper settings refresh failed after apply', {
|
|
54512
|
+
error: error instanceof Error ? error.message : String(error),
|
|
54513
|
+
});
|
|
54514
|
+
}
|
|
54477
54515
|
return {
|
|
54478
54516
|
path: this.path,
|
|
54479
54517
|
size: encoded.data.byteLength,
|
|
@@ -64995,6 +65033,7 @@ const createUiProgressMessageFilter = (intervalMs = DEFAULT_UI_PROGRESS_INTERVAL
|
|
|
64995
65033
|
|
|
64996
65034
|
const Log = getLogger(exports.LoggerNames.Core);
|
|
64997
65035
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
65036
|
+
const PRE_PENDING_CALL_TIMEOUT_MS = 15 * 1000;
|
|
64998
65037
|
const preWarmInflight = new Map();
|
|
64999
65038
|
const preWarmDoneAt = new Map();
|
|
65000
65039
|
function hasDeriveCardano(method) {
|
|
@@ -65150,29 +65189,40 @@ const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void
|
|
|
65150
65189
|
}
|
|
65151
65190
|
}
|
|
65152
65191
|
});
|
|
65153
|
-
const
|
|
65154
|
-
const
|
|
65155
|
-
setTimeout(() => reject(new Error('Request timeout')), timeout);
|
|
65156
|
-
});
|
|
65157
|
-
return Promise.race([promise, timeoutPromise]);
|
|
65158
|
-
});
|
|
65159
|
-
const waitForPendingPromise = (getPrePendingCallPromise, removePrePendingCallPromise) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65160
|
-
const pendingPromise = getPrePendingCallPromise();
|
|
65192
|
+
const waitForPendingPromise = (connectId, getPrePendingCallPromise, removePrePendingCallPromise) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65193
|
+
const pendingPromise = getPrePendingCallPromise(connectId);
|
|
65161
65194
|
if (pendingPromise) {
|
|
65162
65195
|
Log.debug('pre pending call promise before call method, wait for it');
|
|
65196
|
+
let timer;
|
|
65197
|
+
let timedOut = false;
|
|
65163
65198
|
try {
|
|
65164
|
-
yield
|
|
65199
|
+
yield Promise.race([
|
|
65200
|
+
pendingPromise,
|
|
65201
|
+
new Promise(resolve => {
|
|
65202
|
+
timer = setTimeout(() => {
|
|
65203
|
+
timedOut = true;
|
|
65204
|
+
resolve();
|
|
65205
|
+
}, PRE_PENDING_CALL_TIMEOUT_MS);
|
|
65206
|
+
}),
|
|
65207
|
+
]);
|
|
65165
65208
|
}
|
|
65166
65209
|
catch (error) {
|
|
65167
65210
|
}
|
|
65168
|
-
|
|
65211
|
+
finally {
|
|
65212
|
+
if (timer)
|
|
65213
|
+
clearTimeout(timer);
|
|
65214
|
+
removePrePendingCallPromise === null || removePrePendingCallPromise === void 0 ? void 0 : removePrePendingCallPromise(connectId, pendingPromise);
|
|
65215
|
+
}
|
|
65216
|
+
if (timedOut) {
|
|
65217
|
+
Log.warn('pre pending call promise timed out before call method', { connectId });
|
|
65218
|
+
}
|
|
65169
65219
|
Log.debug('pre pending call promise before call method done');
|
|
65170
65220
|
}
|
|
65171
65221
|
});
|
|
65172
65222
|
const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65173
|
-
var _d, _e, _f, _g, _h;
|
|
65223
|
+
var _d, _e, _f, _g, _h, _j, _k;
|
|
65174
65224
|
let messageResponse;
|
|
65175
|
-
const { requestQueue, getPrePendingCallPromise,
|
|
65225
|
+
const { requestQueue, getPrePendingCallPromise, removePrePendingCallPromise } = context;
|
|
65176
65226
|
updateMethodRequestContext(method, { status: 'running' });
|
|
65177
65227
|
const normalizePassphraseState = (s) => s || '';
|
|
65178
65228
|
const connectStateChange = normalizePassphraseState(preConnectCache.passphraseState) !==
|
|
@@ -65187,7 +65237,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65187
65237
|
if (method.connectId) {
|
|
65188
65238
|
yield context.waitForCallbackTasks(method.connectId);
|
|
65189
65239
|
}
|
|
65190
|
-
yield waitForPendingPromise(getPrePendingCallPromise,
|
|
65240
|
+
yield waitForPendingPromise((_d = method.connectId) !== null && _d !== void 0 ? _d : '', getPrePendingCallPromise, removePrePendingCallPromise);
|
|
65191
65241
|
const task = requestQueue.createTask(method);
|
|
65192
65242
|
let preWarmCallbackTask;
|
|
65193
65243
|
if (method.isPreWarmSignal && method.connectId) {
|
|
@@ -65196,9 +65246,9 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65196
65246
|
}
|
|
65197
65247
|
let device;
|
|
65198
65248
|
try {
|
|
65199
|
-
const connectId = (
|
|
65249
|
+
const connectId = (_e = method.connectId) !== null && _e !== void 0 ? _e : '';
|
|
65200
65250
|
const pollingId = pollingManager.start(connectId);
|
|
65201
|
-
device = yield ensureConnected(context, method, connectId, pollingId, (
|
|
65251
|
+
device = yield ensureConnected(context, method, connectId, pollingId, (_f = task.abortController) === null || _f === void 0 ? void 0 : _f.signal);
|
|
65202
65252
|
}
|
|
65203
65253
|
catch (e) {
|
|
65204
65254
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
@@ -65213,17 +65263,17 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65213
65263
|
requestQueue.releaseTask(method.responseID);
|
|
65214
65264
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
65215
65265
|
}
|
|
65216
|
-
if ((
|
|
65266
|
+
if ((_g = method.payload) === null || _g === void 0 ? void 0 : _g.onlyConnectBleDevice) {
|
|
65217
65267
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
65218
65268
|
Log.debug('Call API - only connect ble device: ', device === null || device === void 0 ? void 0 : device.mainId);
|
|
65219
65269
|
return createResponseMessage(method.responseID, true, null);
|
|
65220
65270
|
}
|
|
65221
65271
|
Log.debug('Call API - setDevice: ', device.mainId);
|
|
65222
|
-
(
|
|
65272
|
+
(_h = method.setDevice) === null || _h === void 0 ? void 0 : _h.call(method, device);
|
|
65223
65273
|
method.context = context;
|
|
65224
65274
|
updateMethodRequestContext(method, {
|
|
65225
65275
|
deviceInstanceId: device.instanceId,
|
|
65226
|
-
commandsInstanceId: (
|
|
65276
|
+
commandsInstanceId: (_j = device.commands) === null || _j === void 0 ? void 0 : _j.instanceId,
|
|
65227
65277
|
});
|
|
65228
65278
|
const activeRequests = getActiveRequestsByDeviceInstance(device.instanceId);
|
|
65229
65279
|
if (activeRequests.length > 0) {
|
|
@@ -65252,14 +65302,14 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65252
65302
|
if (method.connectId) {
|
|
65253
65303
|
yield context.waitForCallbackTasks(method.connectId, preWarmCallbackTask);
|
|
65254
65304
|
}
|
|
65255
|
-
yield waitForPendingPromise(getPrePendingCallPromise,
|
|
65305
|
+
yield waitForPendingPromise((_k = method.connectId) !== null && _k !== void 0 ? _k : '', getPrePendingCallPromise, removePrePendingCallPromise);
|
|
65256
65306
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65257
|
-
var
|
|
65307
|
+
var _l, _m;
|
|
65258
65308
|
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
65259
65309
|
protocolV2Operation = device.isProtocolV2();
|
|
65260
65310
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
65261
|
-
const currentFirmwareVersion = (
|
|
65262
|
-
const currentBleVersion = (
|
|
65311
|
+
const currentFirmwareVersion = (_l = device.getCurrentFirmwareVersionString()) !== null && _l !== void 0 ? _l : '0.0.0';
|
|
65312
|
+
const currentBleVersion = (_m = device.getCurrentBLEFirmwareVersionString()) !== null && _m !== void 0 ? _m : '0.0.0';
|
|
65263
65313
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
65264
65314
|
let newVersionStatus;
|
|
65265
65315
|
if (device.features && !device.isProtocolV2()) {
|
|
@@ -65337,7 +65387,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65337
65387
|
}
|
|
65338
65388
|
},
|
|
65339
65389
|
prepare: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65340
|
-
var
|
|
65390
|
+
var _o, _p, _q, _r, _s;
|
|
65341
65391
|
if (method.deviceId && method.checkDeviceId && !deviceIdCheckedDuringUnlockPreflight) {
|
|
65342
65392
|
const isSameDeviceID = yield checkLiveDeviceId(device, method.deviceId);
|
|
65343
65393
|
if (!isSameDeviceID) {
|
|
@@ -65357,7 +65407,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65357
65407
|
require: support.require,
|
|
65358
65408
|
});
|
|
65359
65409
|
}
|
|
65360
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((
|
|
65410
|
+
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_o = method.payload) === null || _o === void 0 ? void 0 : _o.passphraseState, (_p = method.payload) === null || _p === void 0 ? void 0 : _p.useEmptyPassphrase, (_q = method.payload) === null || _q === void 0 ? void 0 : _q.skipPassphraseCheck, hasDeriveCardano(method));
|
|
65361
65411
|
checkPassphraseEnableState(method, device.features);
|
|
65362
65412
|
if (!passphraseStateSafety) {
|
|
65363
65413
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -65375,7 +65425,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65375
65425
|
? e
|
|
65376
65426
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
65377
65427
|
}
|
|
65378
|
-
(
|
|
65428
|
+
(_s = (_r = method.device) === null || _r === void 0 ? void 0 : _r.commands) === null || _s === void 0 ? void 0 : _s.checkDisposed();
|
|
65379
65429
|
}),
|
|
65380
65430
|
});
|
|
65381
65431
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
@@ -65571,6 +65621,13 @@ function isRetryableBleProtocolV2ProbeError(method, error) {
|
|
|
65571
65621
|
message.includes('expected V2') &&
|
|
65572
65622
|
message.includes('did not respond to expected protocol'));
|
|
65573
65623
|
}
|
|
65624
|
+
function isMissingDetectedProtocolV2Error(method, error) {
|
|
65625
|
+
const typedError = error;
|
|
65626
|
+
return (method.payload.connectProtocol === 'V2' &&
|
|
65627
|
+
(typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.RuntimeError &&
|
|
65628
|
+
typeof typedError.message === 'string' &&
|
|
65629
|
+
typedError.message.includes('Device protocol has not been detected'));
|
|
65630
|
+
}
|
|
65574
65631
|
function connectDeviceForBle(method, device, retryCount = 0) {
|
|
65575
65632
|
var _a;
|
|
65576
65633
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -65605,7 +65662,8 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65605
65662
|
}
|
|
65606
65663
|
}
|
|
65607
65664
|
catch (err) {
|
|
65608
|
-
|
|
65665
|
+
const requiresColdReconnect = isMissingDetectedProtocolV2Error(method, err);
|
|
65666
|
+
if ((hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) || requiresColdReconnect) &&
|
|
65609
65667
|
device.mainId &&
|
|
65610
65668
|
device.deviceConnector) {
|
|
65611
65669
|
yield device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
@@ -65613,10 +65671,11 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65613
65671
|
}
|
|
65614
65672
|
if ((err.errorCode === hdShared.HardwareErrorCode.BleTimeoutError ||
|
|
65615
65673
|
err.errorCode === hdShared.HardwareErrorCode.BleConnectedError ||
|
|
65616
|
-
isRetryableBleProtocolV2ProbeError(method, err)
|
|
65674
|
+
isRetryableBleProtocolV2ProbeError(method, err) ||
|
|
65675
|
+
requiresColdReconnect) &&
|
|
65617
65676
|
retryCount < 6) {
|
|
65618
65677
|
const nextRetry = retryCount + 1;
|
|
65619
|
-
Log.debug(`Bluetooth
|
|
65678
|
+
Log.debug(`Bluetooth connection will retry, retry count: ${nextRetry}`);
|
|
65620
65679
|
yield wait(3000);
|
|
65621
65680
|
yield connectDeviceForBle(method, device, nextRetry);
|
|
65622
65681
|
}
|
|
@@ -65635,7 +65694,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65635
65694
|
Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
|
|
65636
65695
|
const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65637
65696
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65638
|
-
var
|
|
65697
|
+
var _t;
|
|
65639
65698
|
const abort = () => {
|
|
65640
65699
|
if (abortSignal && abortSignal.aborted) {
|
|
65641
65700
|
if (timer) {
|
|
@@ -65750,7 +65809,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65750
65809
|
clearTimeout(timer);
|
|
65751
65810
|
}
|
|
65752
65811
|
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
65753
|
-
if (DataManager.isBrowserWebUsb(env) && !((
|
|
65812
|
+
if (DataManager.isBrowserWebUsb(env) && !((_t = method.payload) === null || _t === void 0 ? void 0 : _t.skipWebDevicePrompt)) {
|
|
65754
65813
|
postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
|
|
65755
65814
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
|
|
65756
65815
|
}
|
|
@@ -65768,7 +65827,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65768
65827
|
return poll();
|
|
65769
65828
|
});
|
|
65770
65829
|
const cancel = (context, connectId) => {
|
|
65771
|
-
var _a, _b;
|
|
65830
|
+
var _a, _b, _c;
|
|
65772
65831
|
const { requestQueue, setPrePendingCallPromise } = context;
|
|
65773
65832
|
if (connectId) {
|
|
65774
65833
|
try {
|
|
@@ -65782,7 +65841,7 @@ const cancel = (context, connectId) => {
|
|
|
65782
65841
|
if (task && ((_a = task.method) === null || _a === void 0 ? void 0 : _a.device)) {
|
|
65783
65842
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65784
65843
|
const { device } = task.method;
|
|
65785
|
-
setPrePendingCallPromise(
|
|
65844
|
+
setPrePendingCallPromise((_b = task.method.connectId) !== null && _b !== void 0 ? _b : connectId, device.interruptionFromUser());
|
|
65786
65845
|
canceledDevices.push(device);
|
|
65787
65846
|
}
|
|
65788
65847
|
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled));
|
|
@@ -65802,7 +65861,7 @@ const cancel = (context, connectId) => {
|
|
|
65802
65861
|
for (const requestId of requestQueue.getRequestTasksId()) {
|
|
65803
65862
|
const task = requestQueue.getTask(requestId);
|
|
65804
65863
|
Log.debug('Cancel Api connect task: ', task);
|
|
65805
|
-
if (task && ((
|
|
65864
|
+
if (task && ((_c = task.method) === null || _c === void 0 ? void 0 : _c.device)) {
|
|
65806
65865
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65807
65866
|
const { device } = task.method;
|
|
65808
65867
|
device === null || device === void 0 ? void 0 : device.interruptionFromUser();
|
|
@@ -65991,6 +66050,7 @@ class Core extends events.exports {
|
|
|
65991
66050
|
constructor() {
|
|
65992
66051
|
super();
|
|
65993
66052
|
this.requestQueue = new RequestQueue();
|
|
66053
|
+
this.prePendingCallPromises = new Map();
|
|
65994
66054
|
this.methodSynchronize = getSynchronize();
|
|
65995
66055
|
this.tracingContext = createSdkTracingContext();
|
|
65996
66056
|
this.sdkInstanceId = this.tracingContext.sdkInstanceId;
|
|
@@ -66002,9 +66062,18 @@ class Core extends events.exports {
|
|
|
66002
66062
|
tracingContext: this.tracingContext,
|
|
66003
66063
|
requestQueue: this.requestQueue,
|
|
66004
66064
|
methodSynchronize: this.methodSynchronize,
|
|
66005
|
-
getPrePendingCallPromise: () => this.
|
|
66006
|
-
setPrePendingCallPromise: (promise) => {
|
|
66007
|
-
|
|
66065
|
+
getPrePendingCallPromise: (connectId) => this.prePendingCallPromises.get(connectId),
|
|
66066
|
+
setPrePendingCallPromise: (connectId, promise) => {
|
|
66067
|
+
if (!promise) {
|
|
66068
|
+
this.prePendingCallPromises.delete(connectId);
|
|
66069
|
+
return;
|
|
66070
|
+
}
|
|
66071
|
+
this.prePendingCallPromises.set(connectId, promise);
|
|
66072
|
+
},
|
|
66073
|
+
removePrePendingCallPromise: (connectId, promise) => {
|
|
66074
|
+
if (this.prePendingCallPromises.get(connectId) === promise) {
|
|
66075
|
+
this.prePendingCallPromises.delete(connectId);
|
|
66076
|
+
}
|
|
66008
66077
|
},
|
|
66009
66078
|
registerCallbackTask: (connectId, callbackPromise) => {
|
|
66010
66079
|
this.requestQueue.registerPendingCallbackTask(connectId, callbackPromise);
|
|
@@ -66098,7 +66167,7 @@ class Core extends events.exports {
|
|
|
66098
66167
|
preWarmInflight.clear();
|
|
66099
66168
|
preWarmDoneAt.clear();
|
|
66100
66169
|
preConnectCache = { passphraseState: undefined };
|
|
66101
|
-
this.
|
|
66170
|
+
this.prePendingCallPromises.clear();
|
|
66102
66171
|
this.removeAllListeners();
|
|
66103
66172
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
66104
66173
|
if (_core === this)
|