@onekeyfe/hd-core 1.2.0-alpha.133 → 1.2.0-alpha.133-ok59992
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 +0 -7
- package/__tests__/device-lifecycle-events.test.ts +2 -91
- package/__tests__/device-settings.test.ts +9 -167
- package/__tests__/protocol-v2.test.ts +1 -34
- 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 +1 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +0 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +189 -258
- package/package.json +4 -4
- package/src/api/device/DeviceSettings.ts +16 -2
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +0 -11
- package/src/core/index.ts +25 -67
- package/src/device/Device.ts +2 -30
- package/src/device/DeviceCommands.ts +1 -14
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$m {
|
|
2265
2265
|
constructor(prefix, enabled) {
|
|
2266
2266
|
this.prefix = prefix;
|
|
2267
2267
|
this.enabled = enabled;
|
|
@@ -2313,7 +2313,7 @@ class Log$n {
|
|
|
2313
2313
|
}
|
|
2314
2314
|
const _logs = {};
|
|
2315
2315
|
const initLog = (prefix, enabled) => {
|
|
2316
|
-
const instance = new Log$
|
|
2316
|
+
const instance = new Log$m(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$l = 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$l.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$k = 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$k.log('[DataConfig] Preloaded firmware config loaded');
|
|
40884
40884
|
return true;
|
|
40885
40885
|
}
|
|
40886
40886
|
if (manifestMode === 'external-only') {
|
|
40887
|
-
Log$
|
|
40887
|
+
Log$k.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$k.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$k.warn('[DataConfig] Client configFetcher failed:', e);
|
|
40909
40909
|
}
|
|
40910
40910
|
}
|
|
40911
40911
|
if (!data) {
|
|
40912
|
-
Log$
|
|
40912
|
+
Log$k.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$k.log('[DataConfig] SDK-managed config request succeeded');
|
|
40920
40920
|
}
|
|
40921
40921
|
catch (e) {
|
|
40922
|
-
Log$
|
|
40922
|
+
Log$k.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$k.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
|
|
40928
40928
|
return true;
|
|
40929
40929
|
}
|
|
40930
|
-
Log$
|
|
40930
|
+
Log$k.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$k.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$k.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$j = 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$j.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$j.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$j.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$j.debug('device pool -> current: ', this.current);
|
|
43315
|
+
Log$j.debug('device pool -> upcomming: ', this.upcoming);
|
|
43316
|
+
Log$j.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$j.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$j.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$j.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$i = 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$i.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$i.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$i.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$i.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$i.debug('Configuring transports done');
|
|
43441
43441
|
}
|
|
43442
43442
|
catch (error) {
|
|
43443
|
-
Log$
|
|
43443
|
+
Log$i.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$i.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$i.debug('set transport plugin: ', this.plugin);
|
|
43486
43486
|
}
|
|
43487
|
-
Log$
|
|
43487
|
+
Log$i.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$i.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$h = 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$h.debug(`[DeviceCommands] Created: ${this.instanceId}, device: ${this.device.instanceId}`);
|
|
43630
43630
|
}
|
|
43631
43631
|
dispose(_cancelRequest) {
|
|
43632
43632
|
var _a, _b;
|
|
@@ -43679,7 +43679,6 @@ class DeviceCommands {
|
|
|
43679
43679
|
}
|
|
43680
43680
|
const activeCall = this.callPromise;
|
|
43681
43681
|
let timer;
|
|
43682
|
-
let timedOut = false;
|
|
43683
43682
|
const cancellation = (() => __awaiter(this, void 0, void 0, function* () {
|
|
43684
43683
|
yield this.dispose(true);
|
|
43685
43684
|
yield (activeCall === null || activeCall === void 0 ? void 0 : activeCall.catch(() => undefined));
|
|
@@ -43688,23 +43687,13 @@ class DeviceCommands {
|
|
|
43688
43687
|
yield Promise.race([
|
|
43689
43688
|
cancellation,
|
|
43690
43689
|
new Promise(resolve => {
|
|
43691
|
-
timer = setTimeout(
|
|
43692
|
-
timedOut = true;
|
|
43693
|
-
resolve();
|
|
43694
|
-
}, 10 * 1000);
|
|
43690
|
+
timer = setTimeout(resolve, 10 * 1000);
|
|
43695
43691
|
}),
|
|
43696
43692
|
]);
|
|
43697
43693
|
}
|
|
43698
43694
|
finally {
|
|
43699
43695
|
if (timer)
|
|
43700
43696
|
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
|
-
}
|
|
43708
43697
|
if (this.callPromise === activeCall) {
|
|
43709
43698
|
this.callPromise = undefined;
|
|
43710
43699
|
}
|
|
@@ -43717,7 +43706,7 @@ class DeviceCommands {
|
|
|
43717
43706
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43718
43707
|
const shouldReduceDebug = shouldReduceDebugForCall(type);
|
|
43719
43708
|
if (!shouldReduceDebug) {
|
|
43720
|
-
Log$
|
|
43709
|
+
Log$h.debug('[DeviceCommands] [call] Sending', type, hdTransport.getSafeTransportLogPayload(msg !== null && msg !== void 0 ? msg : {}, type));
|
|
43721
43710
|
}
|
|
43722
43711
|
try {
|
|
43723
43712
|
const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
|
|
@@ -43776,10 +43765,10 @@ class DeviceCommands {
|
|
|
43776
43765
|
assertType(response, resType);
|
|
43777
43766
|
}
|
|
43778
43767
|
catch (error) {
|
|
43779
|
-
Log$
|
|
43768
|
+
Log$h.debug('DeviceCommands typedcall error: ', error);
|
|
43780
43769
|
if (error instanceof hdShared.HardwareError) {
|
|
43781
43770
|
if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
43782
|
-
Log$
|
|
43771
|
+
Log$h.debug('[DeviceCommands] [typedCall] Unexpected response type', {
|
|
43783
43772
|
request: type,
|
|
43784
43773
|
expected: resType,
|
|
43785
43774
|
received: response.type,
|
|
@@ -43813,7 +43802,7 @@ class DeviceCommands {
|
|
|
43813
43802
|
var _a;
|
|
43814
43803
|
try {
|
|
43815
43804
|
if (!shouldReduceDebugForCall(callType)) {
|
|
43816
|
-
Log$
|
|
43805
|
+
Log$h.debug('_filterCommonTypes: ', {
|
|
43817
43806
|
request: callType,
|
|
43818
43807
|
response: {
|
|
43819
43808
|
type: res.type,
|
|
@@ -44033,7 +44022,7 @@ class DeviceCommands {
|
|
|
44033
44022
|
reject(error);
|
|
44034
44023
|
});
|
|
44035
44024
|
const listenerCount = this.device.listenerCount(DEVICE.PIN);
|
|
44036
|
-
Log$
|
|
44025
|
+
Log$h.debug(`[${this.instanceId}] _promptPin called`, {
|
|
44037
44026
|
responseID: this.currentResponseID,
|
|
44038
44027
|
deviceInstanceId: this.device.instanceId,
|
|
44039
44028
|
listenerCount,
|
|
@@ -45090,7 +45079,7 @@ const parseRunOptions = (options) => {
|
|
|
45090
45079
|
options = {};
|
|
45091
45080
|
return options;
|
|
45092
45081
|
};
|
|
45093
|
-
const Log$
|
|
45082
|
+
const Log$g = getLogger(exports.LoggerNames.Device);
|
|
45094
45083
|
const isProtocolV2DeviceStatusUnsupportedError = (error) => {
|
|
45095
45084
|
var _a, _b, _c;
|
|
45096
45085
|
if (error instanceof hdShared.HardwareError) {
|
|
@@ -45151,7 +45140,7 @@ class Device extends events.exports {
|
|
|
45151
45140
|
this.sdkInstanceId = sdkInstanceId;
|
|
45152
45141
|
this.instanceId = generateInstanceId('Device', this.sdkInstanceId);
|
|
45153
45142
|
this.createdAt = Date.now();
|
|
45154
|
-
Log$
|
|
45143
|
+
Log$g.debug(`[Device] Created: ${this.instanceId}${this.sdkInstanceId ? ` for SDK: ${this.sdkInstanceId}` : ''}`);
|
|
45155
45144
|
}
|
|
45156
45145
|
static fromDescriptor(originalDescriptor, sdkInstanceId) {
|
|
45157
45146
|
const descriptor = Object.assign({}, originalDescriptor);
|
|
@@ -45242,12 +45231,12 @@ class Device extends events.exports {
|
|
|
45242
45231
|
if (DataManager.isBleConnect(env)) {
|
|
45243
45232
|
acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, strictProtocol, undefined));
|
|
45244
45233
|
this.mainId = (_b = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.uuid) !== null && _b !== void 0 ? _b : '';
|
|
45245
|
-
Log$
|
|
45234
|
+
Log$g.debug('Expected uuid:', this.mainId);
|
|
45246
45235
|
}
|
|
45247
45236
|
else {
|
|
45248
45237
|
acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, strictProtocol, undefined));
|
|
45249
45238
|
this.mainId = acquireResult;
|
|
45250
|
-
Log$
|
|
45239
|
+
Log$g.debug('Expected session id:', this.mainId);
|
|
45251
45240
|
}
|
|
45252
45241
|
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);
|
|
45253
45242
|
if ((options === null || options === void 0 ? void 0 : options.forceProtocolDetection) && !detectedProtocol) {
|
|
@@ -45274,7 +45263,7 @@ class Device extends events.exports {
|
|
|
45274
45263
|
yield ((_j = (_h = this.deviceConnector) === null || _h === void 0 ? void 0 : _h.release) === null || _j === void 0 ? void 0 : _j.call(_h, failedSession, false));
|
|
45275
45264
|
}
|
|
45276
45265
|
catch (releaseError) {
|
|
45277
|
-
Log$
|
|
45266
|
+
Log$g.debug('Failed to release an unsuccessful protocol probe', releaseError);
|
|
45278
45267
|
}
|
|
45279
45268
|
}
|
|
45280
45269
|
if (!DataManager.isBleConnect(env)) {
|
|
@@ -45303,11 +45292,11 @@ class Device extends events.exports {
|
|
|
45303
45292
|
(this.mainId && DataManager.isBleConnect(env))) {
|
|
45304
45293
|
if (this.pendingCallbackPromise) {
|
|
45305
45294
|
try {
|
|
45306
|
-
Log$
|
|
45295
|
+
Log$g.debug('Waiting for callback tasks to complete before releasing device (in release method)');
|
|
45307
45296
|
yield this.pendingCallbackPromise.promise;
|
|
45308
45297
|
}
|
|
45309
45298
|
catch (error) {
|
|
45310
|
-
Log$
|
|
45299
|
+
Log$g.error('Error waiting for callback tasks in release method:', error);
|
|
45311
45300
|
}
|
|
45312
45301
|
}
|
|
45313
45302
|
if (this.commands) {
|
|
@@ -45326,7 +45315,7 @@ class Device extends events.exports {
|
|
|
45326
45315
|
this.updateDescriptor({ session: null });
|
|
45327
45316
|
}
|
|
45328
45317
|
catch (err) {
|
|
45329
|
-
Log$
|
|
45318
|
+
Log$g.error('[Device] release error: ', err);
|
|
45330
45319
|
}
|
|
45331
45320
|
finally {
|
|
45332
45321
|
this.needReloadDevice = true;
|
|
@@ -45531,7 +45520,7 @@ class Device extends events.exports {
|
|
|
45531
45520
|
});
|
|
45532
45521
|
}
|
|
45533
45522
|
getInternalState(_deviceId) {
|
|
45534
|
-
Log$
|
|
45523
|
+
Log$g.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `currentDeviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
45535
45524
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
45536
45525
|
if (!deviceId)
|
|
45537
45526
|
return undefined;
|
|
@@ -45546,7 +45535,7 @@ class Device extends events.exports {
|
|
|
45546
45535
|
return deviceWalletSessionStore.getStandard(deviceId);
|
|
45547
45536
|
}
|
|
45548
45537
|
updateInternalState(enablePassphrase, passphraseState, deviceId, sessionId = null, featuresSessionId = null, walletType = 'hidden') {
|
|
45549
|
-
Log$
|
|
45538
|
+
Log$g.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `hasPassphraseState: ${Boolean(passphraseState)}`, `hasSessionId: ${Boolean(sessionId)}`, `hasFeaturesSessionId: ${Boolean(featuresSessionId)}`);
|
|
45550
45539
|
const cacheDeviceKey = this.getSessionCacheDeviceKey(deviceId);
|
|
45551
45540
|
if (!cacheDeviceKey)
|
|
45552
45541
|
return;
|
|
@@ -45562,7 +45551,7 @@ class Device extends events.exports {
|
|
|
45562
45551
|
deviceWalletSessionStore.deletePending(cacheDeviceKey);
|
|
45563
45552
|
}
|
|
45564
45553
|
setInternalState(state, initSession) {
|
|
45565
|
-
Log$
|
|
45554
|
+
Log$g.debug('setInternalState session param: ', `hasState: ${Boolean(state)}`, `initSession: ${initSession}`, `deviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
45566
45555
|
if (!this.passphraseState && !initSession)
|
|
45567
45556
|
return;
|
|
45568
45557
|
const deviceId = this.getSessionCacheDeviceKey();
|
|
@@ -45576,7 +45565,7 @@ class Device extends events.exports {
|
|
|
45576
45565
|
}
|
|
45577
45566
|
}
|
|
45578
45567
|
clearInternalState(_deviceId) {
|
|
45579
|
-
Log$
|
|
45568
|
+
Log$g.debug('clearInternalState param: ', _deviceId);
|
|
45580
45569
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
45581
45570
|
if (!deviceId)
|
|
45582
45571
|
return;
|
|
@@ -45644,14 +45633,14 @@ class Device extends events.exports {
|
|
|
45644
45633
|
yield callInitialize(payload, options === null || options === void 0 ? void 0 : options.initSession);
|
|
45645
45634
|
}
|
|
45646
45635
|
catch (error) {
|
|
45647
|
-
Log$
|
|
45636
|
+
Log$g.error('Initialization failed:', error);
|
|
45648
45637
|
throw error;
|
|
45649
45638
|
}
|
|
45650
45639
|
});
|
|
45651
45640
|
}
|
|
45652
45641
|
_initializeProtocolV2(options) {
|
|
45653
45642
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45654
|
-
Log$
|
|
45643
|
+
Log$g.debug('Initialize device via Protocol V2 features adapter');
|
|
45655
45644
|
try {
|
|
45656
45645
|
const deviceInfo = yield requestProtocolV2DeviceInfo({
|
|
45657
45646
|
commands: this.commands,
|
|
@@ -45660,7 +45649,7 @@ class Device extends events.exports {
|
|
|
45660
45649
|
yield this.probeProtocolV2RuntimeState(deviceInfo, options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs);
|
|
45661
45650
|
}
|
|
45662
45651
|
catch (error) {
|
|
45663
|
-
Log$
|
|
45652
|
+
Log$g.error('Protocol V2 initialization failed:', error);
|
|
45664
45653
|
throw error;
|
|
45665
45654
|
}
|
|
45666
45655
|
});
|
|
@@ -45743,11 +45732,6 @@ class Device extends events.exports {
|
|
|
45743
45732
|
return params.includeRaw ? cloneDeviceState(this.state) : createPublicDeviceState(this.state);
|
|
45744
45733
|
});
|
|
45745
45734
|
}
|
|
45746
|
-
refreshProtocolV2SettingsAfterMutation() {
|
|
45747
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45748
|
-
return this.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
45749
|
-
});
|
|
45750
|
-
}
|
|
45751
45735
|
_updateFeatures(protoFeatures, initSession) {
|
|
45752
45736
|
var _a;
|
|
45753
45737
|
const previousDeviceId = this.getCurrentDeviceId();
|
|
@@ -45774,7 +45758,7 @@ class Device extends events.exports {
|
|
|
45774
45758
|
source,
|
|
45775
45759
|
changedKeys: result.changedKeys,
|
|
45776
45760
|
};
|
|
45777
|
-
Log$
|
|
45761
|
+
Log$g.debug('Device state updated', {
|
|
45778
45762
|
source,
|
|
45779
45763
|
revision: result.revision,
|
|
45780
45764
|
changedKeyCount: result.changedKeys.length,
|
|
@@ -45998,25 +45982,17 @@ class Device extends events.exports {
|
|
|
45998
45982
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45999
45983
|
if (this.runPromise) {
|
|
46000
45984
|
yield this.interruptionFromOutside();
|
|
46001
|
-
Log$
|
|
45985
|
+
Log$g.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
46002
45986
|
}
|
|
46003
45987
|
options = parseRunOptions(options);
|
|
46004
45988
|
const runPromise = hdShared.createDeferred();
|
|
46005
45989
|
this.runPromise = runPromise;
|
|
46006
|
-
|
|
45990
|
+
this._runInner(fn, options, runPromise).catch(error => {
|
|
46007
45991
|
if (this.runPromise === runPromise) {
|
|
46008
45992
|
this.runPromise = null;
|
|
46009
45993
|
}
|
|
46010
45994
|
runPromise.reject(error);
|
|
46011
45995
|
});
|
|
46012
|
-
this.runCleanupPromise = cleanupPromise;
|
|
46013
|
-
cleanupPromise
|
|
46014
|
-
.finally(() => {
|
|
46015
|
-
if (this.runCleanupPromise === cleanupPromise) {
|
|
46016
|
-
this.runCleanupPromise = undefined;
|
|
46017
|
-
}
|
|
46018
|
-
})
|
|
46019
|
-
.catch(() => undefined);
|
|
46020
45996
|
return runPromise.promise;
|
|
46021
45997
|
});
|
|
46022
45998
|
}
|
|
@@ -46083,7 +46059,7 @@ class Device extends events.exports {
|
|
|
46083
46059
|
yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
|
|
46084
46060
|
}
|
|
46085
46061
|
yield this.release();
|
|
46086
|
-
Log$
|
|
46062
|
+
Log$g.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
46087
46063
|
}
|
|
46088
46064
|
clearRunPromise();
|
|
46089
46065
|
return;
|
|
@@ -46093,7 +46069,7 @@ class Device extends events.exports {
|
|
|
46093
46069
|
options.keepSession === false) {
|
|
46094
46070
|
this.keepSession = false;
|
|
46095
46071
|
yield this.release();
|
|
46096
|
-
Log$
|
|
46072
|
+
Log$g.debug('release device, mainId: ', this.mainId);
|
|
46097
46073
|
}
|
|
46098
46074
|
runPromise.resolve();
|
|
46099
46075
|
clearRunPromise();
|
|
@@ -46110,33 +46086,21 @@ class Device extends events.exports {
|
|
|
46110
46086
|
});
|
|
46111
46087
|
}
|
|
46112
46088
|
interruptionFromUser() {
|
|
46113
|
-
var _a, _b
|
|
46089
|
+
var _a, _b;
|
|
46114
46090
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46115
46091
|
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
|
|
46116
|
-
|
|
46117
|
-
|
|
46118
|
-
if (cancelableAction) {
|
|
46119
|
-
yield cancelableAction(error);
|
|
46120
|
-
}
|
|
46121
|
-
else if (this.isProtocolV2() &&
|
|
46122
|
-
DataManager.isBleConnect(DataManager.getSettings('env')) &&
|
|
46123
|
-
this.hasDeviceAcquire()) {
|
|
46124
|
-
yield ((_b = (_a = this.commands) === null || _a === void 0 ? void 0 : _a.cancelDevice) === null || _b === void 0 ? void 0 : _b.call(_a).catch(cancelError => {
|
|
46125
|
-
Log$h.debug('Protocol V2 BLE fallback cancel error', cancelError);
|
|
46126
|
-
}));
|
|
46127
|
-
}
|
|
46128
|
-
yield ((_c = this.commands) === null || _c === void 0 ? void 0 : _c.cancel());
|
|
46092
|
+
yield ((_a = this.cancelableAction) === null || _a === void 0 ? void 0 : _a.call(this, error));
|
|
46093
|
+
yield ((_b = this.commands) === null || _b === void 0 ? void 0 : _b.cancel());
|
|
46129
46094
|
if (this.runPromise) {
|
|
46130
46095
|
this.runPromise.reject(error);
|
|
46131
46096
|
this.runPromise = null;
|
|
46132
46097
|
}
|
|
46133
|
-
yield (cleanupPromise === null || cleanupPromise === void 0 ? void 0 : cleanupPromise.catch(() => undefined));
|
|
46134
46098
|
});
|
|
46135
46099
|
}
|
|
46136
46100
|
setCancelableAction(callback) {
|
|
46137
46101
|
this.cancelableAction = (e) => callback(e)
|
|
46138
46102
|
.catch(e2 => {
|
|
46139
|
-
Log$
|
|
46103
|
+
Log$g.debug('cancelableAction error', e2);
|
|
46140
46104
|
})
|
|
46141
46105
|
.finally(() => {
|
|
46142
46106
|
this.clearCancelableAction();
|
|
@@ -46419,7 +46383,7 @@ class Device extends events.exports {
|
|
|
46419
46383
|
expectedPassphraseState &&
|
|
46420
46384
|
expectedPassphraseState !== newPassphraseState;
|
|
46421
46385
|
const passphraseStateMismatch = !!expectedPassphraseState && expectedPassphraseState !== newPassphraseState;
|
|
46422
|
-
Log$
|
|
46386
|
+
Log$g.debug('Check passphrase state safety: ', {
|
|
46423
46387
|
hasExpectedPassphraseState: Boolean(expectedPassphraseState),
|
|
46424
46388
|
hasNewPassphraseState: Boolean(newPassphraseState),
|
|
46425
46389
|
passphraseStateMatches: Boolean(expectedPassphraseState) && expectedPassphraseState === newPassphraseState,
|
|
@@ -46557,7 +46521,7 @@ const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwar
|
|
|
46557
46521
|
};
|
|
46558
46522
|
};
|
|
46559
46523
|
|
|
46560
|
-
const Log$
|
|
46524
|
+
const Log$f = getLogger(exports.LoggerNames.Method);
|
|
46561
46525
|
const isEvmLedgerLegacyPathWithHighIndex = (path) => {
|
|
46562
46526
|
let addressN;
|
|
46563
46527
|
if (typeof path === 'string') {
|
|
@@ -46641,7 +46605,7 @@ class BaseMethod {
|
|
|
46641
46605
|
setContext(context) {
|
|
46642
46606
|
this.sdkInstanceId = context.sdkInstanceId;
|
|
46643
46607
|
this.instanceId = generateInstanceId('Method', this.sdkInstanceId);
|
|
46644
|
-
Log$
|
|
46608
|
+
Log$f.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
|
|
46645
46609
|
}
|
|
46646
46610
|
setDevice(device) {
|
|
46647
46611
|
var _a, _b;
|
|
@@ -46661,7 +46625,7 @@ class BaseMethod {
|
|
|
46661
46625
|
if (device.commands) {
|
|
46662
46626
|
device.commands.currentResponseID = this.responseID;
|
|
46663
46627
|
}
|
|
46664
|
-
Log$
|
|
46628
|
+
Log$f.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
|
|
46665
46629
|
}
|
|
46666
46630
|
checkFirmwareRelease() {
|
|
46667
46631
|
if (!this.device || this.device.isProtocolV2())
|
|
@@ -46736,7 +46700,7 @@ class BaseMethod {
|
|
|
46736
46700
|
checkFlag = true;
|
|
46737
46701
|
}
|
|
46738
46702
|
if (checkFlag && this.device.getCurrentSafetyChecks() === hdTransport.Enum_SafetyCheckLevel.Strict) {
|
|
46739
|
-
Log$
|
|
46703
|
+
Log$f.debug('will change safety_checks level');
|
|
46740
46704
|
yield this.device.commands.typedCall('ApplySettings', 'Success', {
|
|
46741
46705
|
safety_checks: hdTransport.Enum_SafetyCheckLevel.PromptTemporarily,
|
|
46742
46706
|
});
|
|
@@ -46812,7 +46776,7 @@ class Ping extends BaseMethod {
|
|
|
46812
46776
|
}
|
|
46813
46777
|
}
|
|
46814
46778
|
|
|
46815
|
-
const Log$
|
|
46779
|
+
const Log$e = getLogger(exports.LoggerNames.Core);
|
|
46816
46780
|
const parseInitOptions$1 = (payload) => ({
|
|
46817
46781
|
initSession: payload === null || payload === void 0 ? void 0 : payload.initSession,
|
|
46818
46782
|
passphraseState: payload === null || payload === void 0 ? void 0 : payload.passphraseState,
|
|
@@ -46838,14 +46802,14 @@ class PreInitialize extends BaseMethod {
|
|
|
46838
46802
|
}
|
|
46839
46803
|
catch (_a) {
|
|
46840
46804
|
this.device.clearPreInitialized();
|
|
46841
|
-
Log$
|
|
46805
|
+
Log$e.debug('[PRE-INIT][FAILED]');
|
|
46842
46806
|
return false;
|
|
46843
46807
|
}
|
|
46844
46808
|
});
|
|
46845
46809
|
}
|
|
46846
46810
|
}
|
|
46847
46811
|
|
|
46848
|
-
const Log$
|
|
46812
|
+
const Log$d = getLogger(exports.LoggerNames.DevicePool);
|
|
46849
46813
|
class SearchDevices extends BaseMethod {
|
|
46850
46814
|
init() {
|
|
46851
46815
|
this.useDevice = false;
|
|
@@ -46887,7 +46851,7 @@ class SearchDevices extends BaseMethod {
|
|
|
46887
46851
|
const errorCode = error && typeof error === 'object' && 'errorCode' in error
|
|
46888
46852
|
? error.errorCode
|
|
46889
46853
|
: undefined;
|
|
46890
|
-
Log$
|
|
46854
|
+
Log$d.debug('Skip unavailable device during search', Object.assign({ path: descriptor.path }, (errorCode !== undefined ? { errorCode } : {})));
|
|
46891
46855
|
}
|
|
46892
46856
|
}
|
|
46893
46857
|
return deviceList.map(device => device.toMessageObject());
|
|
@@ -47789,7 +47753,7 @@ function buildProtocolV2FirmwareRelease({ currentVersions, currentVerification =
|
|
|
47789
47753
|
release,
|
|
47790
47754
|
};
|
|
47791
47755
|
}
|
|
47792
|
-
const Log$
|
|
47756
|
+
const Log$c = getLogger(exports.LoggerNames.Method);
|
|
47793
47757
|
class CheckAllFirmwareRelease extends BaseMethod {
|
|
47794
47758
|
getSupportedProtocols() {
|
|
47795
47759
|
return ['V1', 'V2'];
|
|
@@ -47850,7 +47814,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47850
47814
|
((_c = error.params) === null || _c === void 0 ? void 0 : _c.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47851
47815
|
throw error;
|
|
47852
47816
|
}
|
|
47853
|
-
Log$
|
|
47817
|
+
Log$c.warn('[CheckAllFirmwareRelease] Optional firmware Plan is unavailable; using the legacy release result');
|
|
47854
47818
|
firmwareUpdatePlan = undefined;
|
|
47855
47819
|
}
|
|
47856
47820
|
return {
|
|
@@ -47936,7 +47900,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47936
47900
|
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47937
47901
|
throw error;
|
|
47938
47902
|
}
|
|
47939
|
-
Log$
|
|
47903
|
+
Log$c.warn('[CheckAllFirmwareRelease] Optional Protocol V2 firmware Plan is unavailable; using the release result');
|
|
47940
47904
|
firmwareUpdatePlan = undefined;
|
|
47941
47905
|
}
|
|
47942
47906
|
const firmwarePlan = summarizeProtocolV2FirmwareRelease(plan, PROTOCOL_V2_MAIN_FIRMWARE_TARGETS);
|
|
@@ -48503,7 +48467,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
48503
48467
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48504
48468
|
try {
|
|
48505
48469
|
if (this.device.isProtocolV2()) {
|
|
48506
|
-
const refreshStatusAndSettings = () => this.device.
|
|
48470
|
+
const refreshStatusAndSettings = () => this.device.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
48507
48471
|
assertSettingsSupported(this.payload, DEVICE_SETTINGS_V1_ONLY_FIELDS, 'Protocol V2');
|
|
48508
48472
|
const capabilities = getDeviceSettingsCapabilities(this.device.getCurrentDeviceType(), 'V2');
|
|
48509
48473
|
assertProtocolV2SettingValues(this.payload, capabilities);
|
|
@@ -48526,7 +48490,14 @@ class DeviceSettings extends BaseMethod {
|
|
|
48526
48490
|
const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', {
|
|
48527
48491
|
page: hdTransport.DeviceSettingsPage.DevicePassphrase,
|
|
48528
48492
|
});
|
|
48529
|
-
yield refreshStatusAndSettings();
|
|
48493
|
+
const updated = yield refreshStatusAndSettings();
|
|
48494
|
+
const lockedAfterDisabling = requestedPassphrase === false &&
|
|
48495
|
+
current.status.unlocked === true &&
|
|
48496
|
+
updated.status.unlocked === false;
|
|
48497
|
+
if (updated.status.passphraseProtection !== requestedPassphrase &&
|
|
48498
|
+
!lockedAfterDisabling) {
|
|
48499
|
+
throw hdShared.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 passphrase setting did not reach the requested value.');
|
|
48500
|
+
}
|
|
48530
48501
|
return res.message;
|
|
48531
48502
|
}
|
|
48532
48503
|
if (requestedAirgap !== undefined) {
|
|
@@ -48915,7 +48886,7 @@ const getInfo = ({ features, updateType, targetVersion, firmwareType }) => {
|
|
|
48915
48886
|
const NEW_BOOT_UPRATE_FIRMWARE_VERSION = '2.4.5';
|
|
48916
48887
|
const SESSION_ERROR$3 = 'session not found';
|
|
48917
48888
|
const FIRMWARE_UPDATE_CONFIRM$1 = 'Firmware install confirmed';
|
|
48918
|
-
const Log$
|
|
48889
|
+
const Log$b = getLogger(exports.LoggerNames.Method);
|
|
48919
48890
|
const isDeviceDisconnectedError$1 = (error) => {
|
|
48920
48891
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
48921
48892
|
return (message.includes('device was disconnected') ||
|
|
@@ -48970,13 +48941,13 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48970
48941
|
const newFeatures = yield typedCall('GetFeatures', 'Features', {});
|
|
48971
48942
|
const deviceBootloaderVersion = getDeviceBootloaderVersion(buildProtocolV1FeaturesPayload(newFeatures.message, device.features)).join('.');
|
|
48972
48943
|
const supportUpgradeFileHeader = semver__default["default"].gte(deviceBootloaderVersion, '2.1.0');
|
|
48973
|
-
Log$
|
|
48944
|
+
Log$b.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
|
|
48974
48945
|
if (supportUpgradeFileHeader) {
|
|
48975
48946
|
const HEADER_SIZE = 1024;
|
|
48976
48947
|
if (source.size < HEADER_SIZE) {
|
|
48977
48948
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${source.size} bytes, expected at least ${HEADER_SIZE} bytes`);
|
|
48978
48949
|
}
|
|
48979
|
-
Log$
|
|
48950
|
+
Log$b.debug('Uploading firmware header:', {
|
|
48980
48951
|
size: HEADER_SIZE,
|
|
48981
48952
|
totalSize: source.size,
|
|
48982
48953
|
});
|
|
@@ -48988,18 +48959,18 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48988
48959
|
});
|
|
48989
48960
|
const isUnknownMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage');
|
|
48990
48961
|
if (headerRes.type !== 'Success' && !isUnknownMessage) {
|
|
48991
|
-
Log$
|
|
48962
|
+
Log$b.error('Firmware header upload failed:', headerRes);
|
|
48992
48963
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
|
|
48993
48964
|
}
|
|
48994
48965
|
}
|
|
48995
48966
|
catch (error) {
|
|
48996
|
-
Log$
|
|
48967
|
+
Log$b.error('Firmware header upload failed:', error);
|
|
48997
48968
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
48998
48969
|
if (!message.includes('Failure_UnknownMessage')) {
|
|
48999
48970
|
throw error;
|
|
49000
48971
|
}
|
|
49001
48972
|
}
|
|
49002
|
-
Log$
|
|
48973
|
+
Log$b.debug('Firmware header uploaded successfully');
|
|
49003
48974
|
}
|
|
49004
48975
|
}
|
|
49005
48976
|
const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
|
|
@@ -49018,7 +48989,7 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
49018
48989
|
}
|
|
49019
48990
|
catch (error) {
|
|
49020
48991
|
if (isDeviceDisconnectedError$1(error)) {
|
|
49021
|
-
Log$
|
|
48992
|
+
Log$b.log('Rebooting device');
|
|
49022
48993
|
updateResponse = {
|
|
49023
48994
|
type: 'Success',
|
|
49024
48995
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49116,7 +49087,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49116
49087
|
}
|
|
49117
49088
|
catch (error) {
|
|
49118
49089
|
if (isDeviceDisconnectedError$1(error)) {
|
|
49119
|
-
Log$
|
|
49090
|
+
Log$b.log('Rebooting device');
|
|
49120
49091
|
response = {
|
|
49121
49092
|
type: 'Success',
|
|
49122
49093
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49147,7 +49118,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49147
49118
|
]);
|
|
49148
49119
|
}
|
|
49149
49120
|
catch (e) {
|
|
49150
|
-
Log$
|
|
49121
|
+
Log$b.log('catch Bluetooth error when device is restarting: ', e);
|
|
49151
49122
|
}
|
|
49152
49123
|
}
|
|
49153
49124
|
else {
|
|
@@ -49168,7 +49139,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49168
49139
|
}
|
|
49169
49140
|
catch (error) {
|
|
49170
49141
|
console.error('Device reconnect failed: ', error);
|
|
49171
|
-
Log$
|
|
49142
|
+
Log$b.error('Device reconnect failed:', error);
|
|
49172
49143
|
yield wait(1000);
|
|
49173
49144
|
}
|
|
49174
49145
|
}
|
|
@@ -49208,7 +49179,7 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
|
|
|
49208
49179
|
return result;
|
|
49209
49180
|
}
|
|
49210
49181
|
catch (error) {
|
|
49211
|
-
Log$
|
|
49182
|
+
Log$b.error(`emmcWrite error: `, error);
|
|
49212
49183
|
retryCount--;
|
|
49213
49184
|
if (retryCount === 0) {
|
|
49214
49185
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -49403,7 +49374,7 @@ class DeviceFullyUploadResource extends BaseMethod {
|
|
|
49403
49374
|
}
|
|
49404
49375
|
}
|
|
49405
49376
|
|
|
49406
|
-
const Log$
|
|
49377
|
+
const Log$a = getLogger(exports.LoggerNames.Method);
|
|
49407
49378
|
const SESSION_ERROR$2 = 'session not found';
|
|
49408
49379
|
const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
49409
49380
|
const BOOTLOADER_POLL_INITIALIZE_TIMEOUT_MS = 5000;
|
|
@@ -49481,7 +49452,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49481
49452
|
const env = DataManager.getSettings('env');
|
|
49482
49453
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
49483
49454
|
let bleProbeInFlight = false;
|
|
49484
|
-
Log$
|
|
49455
|
+
Log$a.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
49485
49456
|
let isFirstCheck = true;
|
|
49486
49457
|
let checkCount = 0;
|
|
49487
49458
|
let hasPromptedWebDevice = false;
|
|
@@ -49515,10 +49486,10 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49515
49486
|
if (isFinished || isPromptingWebDevice)
|
|
49516
49487
|
return;
|
|
49517
49488
|
checkCount += 1;
|
|
49518
|
-
Log$
|
|
49489
|
+
Log$a.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
49519
49490
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
49520
49491
|
isFirstCheck = false;
|
|
49521
|
-
Log$
|
|
49492
|
+
Log$a.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] wait 3000ms');
|
|
49522
49493
|
yield wait(3000);
|
|
49523
49494
|
}
|
|
49524
49495
|
if (checkCount > 4 &&
|
|
@@ -49542,7 +49513,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49542
49513
|
catch (e) {
|
|
49543
49514
|
isFinished = true;
|
|
49544
49515
|
clearPollingTimers();
|
|
49545
|
-
Log$
|
|
49516
|
+
Log$a.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
49546
49517
|
(_c = this.checkPromise) === null || _c === void 0 ? void 0 : _c.reject(e);
|
|
49547
49518
|
}
|
|
49548
49519
|
finally {
|
|
@@ -49564,7 +49535,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49564
49535
|
}
|
|
49565
49536
|
}
|
|
49566
49537
|
catch (e) {
|
|
49567
|
-
Log$
|
|
49538
|
+
Log$a.log('catch Bluetooth error when device is restarting: ', e);
|
|
49568
49539
|
}
|
|
49569
49540
|
finally {
|
|
49570
49541
|
bleProbeInFlight = false;
|
|
@@ -49667,7 +49638,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49667
49638
|
}
|
|
49668
49639
|
catch (error) {
|
|
49669
49640
|
if (isDeviceDisconnectedError(error)) {
|
|
49670
|
-
Log$
|
|
49641
|
+
Log$a.log('Rebooting device');
|
|
49671
49642
|
updateResponse = {
|
|
49672
49643
|
type: 'Success',
|
|
49673
49644
|
message: { message: FIRMWARE_UPDATE_CONFIRM },
|
|
@@ -49783,7 +49754,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49783
49754
|
return result;
|
|
49784
49755
|
}
|
|
49785
49756
|
catch (error) {
|
|
49786
|
-
Log$
|
|
49757
|
+
Log$a.error(`emmcWrite error: `, error);
|
|
49787
49758
|
retryCount--;
|
|
49788
49759
|
if (retryCount === 0) {
|
|
49789
49760
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -50090,7 +50061,7 @@ class GetNextU2FCounter extends BaseMethod {
|
|
|
50090
50061
|
}
|
|
50091
50062
|
}
|
|
50092
50063
|
|
|
50093
|
-
const Log$
|
|
50064
|
+
const Log$9 = getLogger(exports.LoggerNames.Method);
|
|
50094
50065
|
class FirmwareUpdate extends BaseMethod {
|
|
50095
50066
|
constructor() {
|
|
50096
50067
|
super(...arguments);
|
|
@@ -50129,7 +50100,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50129
50100
|
const env = DataManager.getSettings('env');
|
|
50130
50101
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50131
50102
|
let bleProbeInFlight = false;
|
|
50132
|
-
Log$
|
|
50103
|
+
Log$9.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50133
50104
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
50134
50105
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
50135
50106
|
if (isBleReconnect) {
|
|
@@ -50145,7 +50116,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50145
50116
|
}
|
|
50146
50117
|
}
|
|
50147
50118
|
catch (e) {
|
|
50148
|
-
Log$
|
|
50119
|
+
Log$9.log('catch Bluetooth error when device is restarting: ', e);
|
|
50149
50120
|
}
|
|
50150
50121
|
finally {
|
|
50151
50122
|
bleProbeInFlight = false;
|
|
@@ -50204,7 +50175,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50204
50175
|
if (e instanceof hdShared.HardwareError) {
|
|
50205
50176
|
return Promise.reject(e);
|
|
50206
50177
|
}
|
|
50207
|
-
Log$
|
|
50178
|
+
Log$9.log('auto go to bootloader mode failed: ', e);
|
|
50208
50179
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure));
|
|
50209
50180
|
}
|
|
50210
50181
|
}
|
|
@@ -50353,7 +50324,7 @@ const readVerifiedPreparedResourceArchive = ({ preparedPlan, reader, }) => __awa
|
|
|
50353
50324
|
return verifiedEntries;
|
|
50354
50325
|
});
|
|
50355
50326
|
|
|
50356
|
-
const Log$
|
|
50327
|
+
const Log$8 = getLogger(exports.LoggerNames.Method);
|
|
50357
50328
|
const FIRMWARE_DOWNLOAD_REQUEST_OPTIONS = {
|
|
50358
50329
|
connectTimeoutMs: 60000,
|
|
50359
50330
|
readTimeoutMs: 60000,
|
|
@@ -50510,7 +50481,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50510
50481
|
const env = DataManager.getSettings('env');
|
|
50511
50482
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50512
50483
|
let probeInFlight = false;
|
|
50513
|
-
Log$
|
|
50484
|
+
Log$8.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50514
50485
|
let isFirstCheck = true;
|
|
50515
50486
|
let checkCount = 0;
|
|
50516
50487
|
let hasPromptedWebDevice = false;
|
|
@@ -50545,10 +50516,10 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50545
50516
|
return;
|
|
50546
50517
|
probeInFlight = true;
|
|
50547
50518
|
checkCount += 1;
|
|
50548
|
-
Log$
|
|
50519
|
+
Log$8.log('FirmwareUpdateV2 [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
50549
50520
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
50550
50521
|
isFirstCheck = false;
|
|
50551
|
-
Log$
|
|
50522
|
+
Log$8.log('FirmwareUpdateV2 [checkDeviceToBootloader] wait 3000ms');
|
|
50552
50523
|
yield wait(3000);
|
|
50553
50524
|
}
|
|
50554
50525
|
if (checkCount > 4 &&
|
|
@@ -50572,7 +50543,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50572
50543
|
catch (e) {
|
|
50573
50544
|
isFinished = true;
|
|
50574
50545
|
clearPollingTimers();
|
|
50575
|
-
Log$
|
|
50546
|
+
Log$8.log('FirmwareUpdateV2 [checkDeviceToBootloader] promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
50576
50547
|
(_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.reject(e);
|
|
50577
50548
|
}
|
|
50578
50549
|
finally {
|
|
@@ -50592,7 +50563,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50592
50563
|
}
|
|
50593
50564
|
}
|
|
50594
50565
|
catch (e) {
|
|
50595
|
-
Log$
|
|
50566
|
+
Log$8.log('catch Bluetooth error when device is restarting: ', e);
|
|
50596
50567
|
}
|
|
50597
50568
|
finally {
|
|
50598
50569
|
probeInFlight = false;
|
|
@@ -50887,7 +50858,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50887
50858
|
}
|
|
50888
50859
|
}
|
|
50889
50860
|
|
|
50890
|
-
const Log$
|
|
50861
|
+
const Log$7 = getLogger(exports.LoggerNames.Method);
|
|
50891
50862
|
const MIN_UPDATE_V3_BOOTLOADER_VERSION = '2.8.0';
|
|
50892
50863
|
class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
50893
50864
|
constructor() {
|
|
@@ -51005,7 +50976,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51005
50976
|
}
|
|
51006
50977
|
run() {
|
|
51007
50978
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51008
|
-
Log$
|
|
50979
|
+
Log$7.debug('FirmwareUpdateV3 strategy: Protocol V1');
|
|
51009
50980
|
return this.runProtocolV1();
|
|
51010
50981
|
});
|
|
51011
50982
|
}
|
|
@@ -51152,7 +51123,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51152
51123
|
resourceEntries: [],
|
|
51153
51124
|
};
|
|
51154
51125
|
}
|
|
51155
|
-
Log$
|
|
51126
|
+
Log$7.warn('No resource url found');
|
|
51156
51127
|
return {
|
|
51157
51128
|
resourceBinary: null,
|
|
51158
51129
|
resourceEntries: [],
|
|
@@ -51313,7 +51284,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51313
51284
|
yield this.startEmmcFirmwareUpdate({ path: '0:updates' });
|
|
51314
51285
|
}
|
|
51315
51286
|
catch (error) {
|
|
51316
|
-
Log$
|
|
51287
|
+
Log$7.error('triggerFirmwareUpdateEmmc error: ', error);
|
|
51317
51288
|
if (error === null || error === void 0 ? void 0 : error.errorCode) {
|
|
51318
51289
|
const unexpectedError = [
|
|
51319
51290
|
hdShared.HardwareErrorCode.ActionCancelled,
|
|
@@ -51383,7 +51354,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51383
51354
|
yield hdShared.wait(1000);
|
|
51384
51355
|
}
|
|
51385
51356
|
catch (error) {
|
|
51386
|
-
Log$
|
|
51357
|
+
Log$7.log('getFeatures error', error);
|
|
51387
51358
|
let shouldReconnect = true;
|
|
51388
51359
|
const progress = this.extractUpdateModeProgress(error);
|
|
51389
51360
|
if (progress !== null) {
|
|
@@ -51482,7 +51453,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51482
51453
|
return;
|
|
51483
51454
|
}
|
|
51484
51455
|
catch (e) {
|
|
51485
|
-
Log$
|
|
51456
|
+
Log$7.log('catch Bluetooth error when device is restarting: ', e);
|
|
51486
51457
|
}
|
|
51487
51458
|
}
|
|
51488
51459
|
else {
|
|
@@ -51497,7 +51468,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51497
51468
|
yield this._promptDeviceForSwitchFirmwareWebDevice();
|
|
51498
51469
|
}
|
|
51499
51470
|
catch (e) {
|
|
51500
|
-
Log$
|
|
51471
|
+
Log$7.log('WebUSB re-authorization failed: ', e);
|
|
51501
51472
|
}
|
|
51502
51473
|
webUsbCheckCount = 0;
|
|
51503
51474
|
}
|
|
@@ -51522,7 +51493,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51522
51493
|
}
|
|
51523
51494
|
catch (error) {
|
|
51524
51495
|
console.error('Device reconnect failed: ', error);
|
|
51525
|
-
Log$
|
|
51496
|
+
Log$7.error('Device reconnect failed:', error);
|
|
51526
51497
|
yield hdShared.wait(1000);
|
|
51527
51498
|
}
|
|
51528
51499
|
}
|
|
@@ -51706,7 +51677,7 @@ function prepareFirmwareUpdateV4MemoryHost({ sdk, plan, artifacts, }) {
|
|
|
51706
51677
|
};
|
|
51707
51678
|
}
|
|
51708
51679
|
|
|
51709
|
-
const Log$
|
|
51680
|
+
const Log$6 = getLogger(exports.LoggerNames.Method);
|
|
51710
51681
|
const SESSION_ERROR$1 = 'session not found';
|
|
51711
51682
|
const PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT = 90 * 1000;
|
|
51712
51683
|
const PROTOCOL_V2_FINAL_RECONNECT_TIMEOUT = 3 * 60 * 1000;
|
|
@@ -52184,7 +52155,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52184
52155
|
}
|
|
52185
52156
|
run() {
|
|
52186
52157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52187
|
-
Log$
|
|
52158
|
+
Log$6.debug('FirmwareUpdateV4 strategy: Protocol V2');
|
|
52188
52159
|
return this.runProtocolV2();
|
|
52189
52160
|
});
|
|
52190
52161
|
}
|
|
@@ -52759,7 +52730,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52759
52730
|
: `${Math.floor(statusVersion / 0x10000) % 0x100}.${Math.floor(statusVersion / 0x100) % 0x100}.${statusVersion % 0x100}`;
|
|
52760
52731
|
if (!observedVersion) {
|
|
52761
52732
|
if (this.protocolV2FinalStatusVerified) {
|
|
52762
|
-
Log$
|
|
52733
|
+
Log$6.warn(`Protocol V2 target ${target} has no observable final version; completed target status is authoritative`);
|
|
52763
52734
|
}
|
|
52764
52735
|
else {
|
|
52765
52736
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, `Protocol V2 target ${target} has no observable final version after status fallback`);
|
|
@@ -53129,7 +53100,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53129
53100
|
return true;
|
|
53130
53101
|
}
|
|
53131
53102
|
catch (error) {
|
|
53132
|
-
Log$
|
|
53103
|
+
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53133
53104
|
return false;
|
|
53134
53105
|
}
|
|
53135
53106
|
});
|
|
@@ -53169,7 +53140,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53169
53140
|
if (error instanceof hdShared.HardwareError) {
|
|
53170
53141
|
throw error;
|
|
53171
53142
|
}
|
|
53172
|
-
Log$
|
|
53143
|
+
Log$6.log('Protocol V2 auto go to bootloader mode failed: ', error);
|
|
53173
53144
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
53174
53145
|
}
|
|
53175
53146
|
});
|
|
@@ -53177,12 +53148,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53177
53148
|
enterProtocolV2BootloaderMode() {
|
|
53178
53149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53179
53150
|
if (this.isProtocolV2RomloaderMode()) {
|
|
53180
|
-
Log$
|
|
53151
|
+
Log$6.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
53181
53152
|
this.protocolV2ExecutionInLoader = true;
|
|
53182
53153
|
return false;
|
|
53183
53154
|
}
|
|
53184
53155
|
if (this.isProtocolV2BootloaderMode()) {
|
|
53185
|
-
Log$
|
|
53156
|
+
Log$6.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
53186
53157
|
this.protocolV2ExecutionInLoader = true;
|
|
53187
53158
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.GoToBootloaderSuccess);
|
|
53188
53159
|
return false;
|
|
@@ -53218,7 +53189,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53218
53189
|
}
|
|
53219
53190
|
shouldReconnect = true;
|
|
53220
53191
|
lastError = error;
|
|
53221
|
-
Log$
|
|
53192
|
+
Log$6.log('Protocol V2 bootloader mode not ready, polling reconnect: ', error);
|
|
53222
53193
|
}
|
|
53223
53194
|
yield hdShared.wait(retryInterval);
|
|
53224
53195
|
}
|
|
@@ -53315,7 +53286,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53315
53286
|
for (const resource of resourceSources) {
|
|
53316
53287
|
const requiresFreshStaging = isProtocolV2BootResourcePackagePath(resource.devicePath);
|
|
53317
53288
|
if (!requiresFreshStaging && (yield this.isProtocolV2ResourceBundleUpToDate(resource))) {
|
|
53318
|
-
Log$
|
|
53289
|
+
Log$6.log(`[FirmwareUpdateV4] skip RESC bundle ${resource.name}; already up to date`);
|
|
53319
53290
|
}
|
|
53320
53291
|
else {
|
|
53321
53292
|
resourcesToSync.push(resource);
|
|
@@ -53430,7 +53401,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53430
53401
|
}
|
|
53431
53402
|
assertProtocolV2TargetStatus(statusTargets, expectedTargetIds, expectedPaths = new Map()) {
|
|
53432
53403
|
var _a, _b, _c;
|
|
53433
|
-
Log$
|
|
53404
|
+
Log$6.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateStatus records=${JSON.stringify(statusTargets)}`);
|
|
53434
53405
|
const failedTarget = statusTargets.find(target => {
|
|
53435
53406
|
var _a;
|
|
53436
53407
|
return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1) &&
|
|
@@ -53443,7 +53414,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53443
53414
|
payloadVersion: failedTarget.payload_version,
|
|
53444
53415
|
path: failedTarget.path,
|
|
53445
53416
|
});
|
|
53446
|
-
Log$
|
|
53417
|
+
Log$6.error(`[FirmwareUpdateV4] firmware install failed target=${failedTargetDetails}`);
|
|
53447
53418
|
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'}`);
|
|
53448
53419
|
}
|
|
53449
53420
|
const matchingTargets = statusTargets.filter(target => { var _a; return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1); });
|
|
@@ -53618,7 +53589,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53618
53589
|
if (isNormalMode &&
|
|
53619
53590
|
(installEvidenceObserved ||
|
|
53620
53591
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53621
|
-
Log$
|
|
53592
|
+
Log$6.log('[FirmwareUpdateV4] empty firmware status after confirmed App reboot; update complete');
|
|
53622
53593
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53623
53594
|
return;
|
|
53624
53595
|
}
|
|
@@ -53666,7 +53637,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53666
53637
|
if (isNormalMode &&
|
|
53667
53638
|
(installEvidenceObserved ||
|
|
53668
53639
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53669
|
-
Log$
|
|
53640
|
+
Log$6.log('[FirmwareUpdateV4] firmware status endpoint unavailable after confirmed App reboot');
|
|
53670
53641
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53671
53642
|
return;
|
|
53672
53643
|
}
|
|
@@ -53688,7 +53659,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53688
53659
|
shouldReconnect = true;
|
|
53689
53660
|
deviceInfo = undefined;
|
|
53690
53661
|
lastError = error;
|
|
53691
|
-
Log$
|
|
53662
|
+
Log$6.log('[FirmwareUpdateV4] DeviceFirmwareUpdateStatusGet unavailable during install: ', error);
|
|
53692
53663
|
}
|
|
53693
53664
|
}
|
|
53694
53665
|
}
|
|
@@ -53707,7 +53678,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53707
53678
|
shouldReconnect = true;
|
|
53708
53679
|
deviceInfo = undefined;
|
|
53709
53680
|
resetMissingTargetStatusGrace();
|
|
53710
|
-
Log$
|
|
53681
|
+
Log$6.log('Protocol V2 firmware install device readiness probe failed: ', error);
|
|
53711
53682
|
}
|
|
53712
53683
|
yield hdShared.wait(1000);
|
|
53713
53684
|
}
|
|
@@ -53720,12 +53691,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53720
53691
|
const deviceInfo = yield this.verifyProtocolV2ReconnectIdentity();
|
|
53721
53692
|
try {
|
|
53722
53693
|
if (yield this.probeProtocolV2NormalMode(deviceInfo)) {
|
|
53723
|
-
Log$
|
|
53694
|
+
Log$6.log('[FirmwareUpdateV4] device already returned to App mode; skip Normal reboot');
|
|
53724
53695
|
return;
|
|
53725
53696
|
}
|
|
53726
53697
|
}
|
|
53727
53698
|
catch (error) {
|
|
53728
|
-
Log$
|
|
53699
|
+
Log$6.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
53729
53700
|
}
|
|
53730
53701
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
53731
53702
|
this.protocolV2ExecutionInLoader = false;
|
|
@@ -53753,7 +53724,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53753
53724
|
const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
|
|
53754
53725
|
this.protocolV2LatestFinalFeatures = features;
|
|
53755
53726
|
if (firmwareVersion === '0.0.0') {
|
|
53756
|
-
Log$
|
|
53727
|
+
Log$6.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.');
|
|
53757
53728
|
}
|
|
53758
53729
|
return {
|
|
53759
53730
|
bootloaderVersion,
|
|
@@ -53802,7 +53773,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53802
53773
|
}
|
|
53803
53774
|
shouldReconnect = true;
|
|
53804
53775
|
lastError = error;
|
|
53805
|
-
Log$
|
|
53776
|
+
Log$6.log('Protocol V2 normal mode not ready, polling Ping: ', error);
|
|
53806
53777
|
}
|
|
53807
53778
|
yield hdShared.wait(1000);
|
|
53808
53779
|
}
|
|
@@ -53846,7 +53817,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53846
53817
|
if (!reconnectDevice) {
|
|
53847
53818
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
|
|
53848
53819
|
}
|
|
53849
|
-
Log$
|
|
53820
|
+
Log$6.debug('Protocol V2 firmware reconnect using matched device:', reconnectDevice.getConnectId());
|
|
53850
53821
|
this.device.updateFromCache(reconnectDevice);
|
|
53851
53822
|
yield this.ensureProtocolV2DeviceAcquired();
|
|
53852
53823
|
this.device.commands.disposed = false;
|
|
@@ -53952,7 +53923,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53952
53923
|
}
|
|
53953
53924
|
}
|
|
53954
53925
|
|
|
53955
|
-
const Log$
|
|
53926
|
+
const Log$5 = getLogger(exports.LoggerNames.Method);
|
|
53956
53927
|
class PromptWebDeviceAccess extends BaseMethod {
|
|
53957
53928
|
init() {
|
|
53958
53929
|
this.useDevice = false;
|
|
@@ -54007,7 +53978,7 @@ class PromptWebDeviceAccess extends BaseMethod {
|
|
|
54007
53978
|
return { device: null };
|
|
54008
53979
|
}
|
|
54009
53980
|
catch (error) {
|
|
54010
|
-
Log$
|
|
53981
|
+
Log$5.debug(error);
|
|
54011
53982
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
|
|
54012
53983
|
}
|
|
54013
53984
|
});
|
|
@@ -54110,7 +54081,7 @@ function decodeJpegBase64ToRgba({ jpegBase64, parameterName, expectedWidth, expe
|
|
|
54110
54081
|
return decoded;
|
|
54111
54082
|
}
|
|
54112
54083
|
|
|
54113
|
-
const Log$
|
|
54084
|
+
const Log$4 = getLogger(exports.LoggerNames.Core);
|
|
54114
54085
|
const MIN_FILE_CHUNK_SIZE = 64;
|
|
54115
54086
|
const FILE_TRANSFER_RATE_WINDOW_MS = 1000;
|
|
54116
54087
|
const FILE_TRANSFER_LOG_INTERVAL_MS = 10000;
|
|
@@ -54131,7 +54102,7 @@ function logFileTransferMetrics({ transport, status, path, transferredBytes, tot
|
|
|
54131
54102
|
const segmentedMetrics = measuredAttempts > 0
|
|
54132
54103
|
? ` hostWriteTotal=${(hostWriteElapsedMs / 1000).toFixed(2)}s responseWaitTotal=${(responseWaitElapsedMs / 1000).toFixed(2)}s measuredAttempts=${measuredAttempts}`
|
|
54133
54104
|
: '';
|
|
54134
|
-
Log$
|
|
54105
|
+
Log$4.log(`[FileWrite] metrics transport=${transport} status=${status} path=${path} bytes=${transferredBytes}/${totalBytes} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatFileTransferRate(rateBytesPerSecond)} KiB/s${segmentedMetrics}`);
|
|
54135
54106
|
}
|
|
54136
54107
|
function isProtocolV2ResponseTimeout(error) {
|
|
54137
54108
|
var _a, _b;
|
|
@@ -54222,7 +54193,7 @@ function writeProtocolV2File(options) {
|
|
|
54222
54193
|
let responseWaitElapsedMs = 0;
|
|
54223
54194
|
let measuredAttempts = 0;
|
|
54224
54195
|
const transport = getFileTransferTransport();
|
|
54225
|
-
Log$
|
|
54196
|
+
Log$4.log(`[FileWrite] started transport=${transport} path=${options.path} bytes=${dataLength} offset=${startOffset} chunk=${chunkSize}`);
|
|
54226
54197
|
try {
|
|
54227
54198
|
while (written < dataLength) {
|
|
54228
54199
|
(_c = options.throwIfAborted) === null || _c === void 0 ? void 0 : _c.call(options);
|
|
@@ -54389,7 +54360,6 @@ const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
|
|
|
54389
54360
|
const DEVICE_SETTINGS_SET_MESSAGE_TYPE = 60412;
|
|
54390
54361
|
const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE$2 = 60805;
|
|
54391
54362
|
const FILESYSTEM_DIR_MAKE_MESSAGE_TYPE = 60809;
|
|
54392
|
-
const Log$4 = getLogger(exports.LoggerNames.Method);
|
|
54393
54363
|
function normalizeFileName(fileName, data) {
|
|
54394
54364
|
if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
|
|
54395
54365
|
throw invalidParameter$1('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
|
|
@@ -54497,14 +54467,6 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
54497
54467
|
const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
|
|
54498
54468
|
settings: { wallpaper_path: this.path },
|
|
54499
54469
|
});
|
|
54500
|
-
try {
|
|
54501
|
-
yield this.device.refreshProtocolV2SettingsAfterMutation();
|
|
54502
|
-
}
|
|
54503
|
-
catch (error) {
|
|
54504
|
-
Log$4.warn('Protocol V2 wallpaper settings refresh failed after apply', {
|
|
54505
|
-
error: error instanceof Error ? error.message : String(error),
|
|
54506
|
-
});
|
|
54507
|
-
}
|
|
54508
54470
|
return {
|
|
54509
54471
|
path: this.path,
|
|
54510
54472
|
size: encoded.data.byteLength,
|
|
@@ -65026,7 +64988,6 @@ const createUiProgressMessageFilter = (intervalMs = DEFAULT_UI_PROGRESS_INTERVAL
|
|
|
65026
64988
|
|
|
65027
64989
|
const Log = getLogger(exports.LoggerNames.Core);
|
|
65028
64990
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
65029
|
-
const PRE_PENDING_CALL_TIMEOUT_MS = 15 * 1000;
|
|
65030
64991
|
const preWarmInflight = new Map();
|
|
65031
64992
|
const preWarmDoneAt = new Map();
|
|
65032
64993
|
function hasDeriveCardano(method) {
|
|
@@ -65182,40 +65143,29 @@ const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void
|
|
|
65182
65143
|
}
|
|
65183
65144
|
}
|
|
65184
65145
|
});
|
|
65185
|
-
const
|
|
65186
|
-
const
|
|
65146
|
+
const waitWithTimeout = (promise, timeout) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65147
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
65148
|
+
setTimeout(() => reject(new Error('Request timeout')), timeout);
|
|
65149
|
+
});
|
|
65150
|
+
return Promise.race([promise, timeoutPromise]);
|
|
65151
|
+
});
|
|
65152
|
+
const waitForPendingPromise = (getPrePendingCallPromise, removePrePendingCallPromise) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65153
|
+
const pendingPromise = getPrePendingCallPromise();
|
|
65187
65154
|
if (pendingPromise) {
|
|
65188
65155
|
Log.debug('pre pending call promise before call method, wait for it');
|
|
65189
|
-
let timer;
|
|
65190
|
-
let timedOut = false;
|
|
65191
65156
|
try {
|
|
65192
|
-
yield
|
|
65193
|
-
pendingPromise,
|
|
65194
|
-
new Promise(resolve => {
|
|
65195
|
-
timer = setTimeout(() => {
|
|
65196
|
-
timedOut = true;
|
|
65197
|
-
resolve();
|
|
65198
|
-
}, PRE_PENDING_CALL_TIMEOUT_MS);
|
|
65199
|
-
}),
|
|
65200
|
-
]);
|
|
65157
|
+
yield waitWithTimeout(pendingPromise, 5 * 1000);
|
|
65201
65158
|
}
|
|
65202
65159
|
catch (error) {
|
|
65203
65160
|
}
|
|
65204
|
-
|
|
65205
|
-
if (timer)
|
|
65206
|
-
clearTimeout(timer);
|
|
65207
|
-
removePrePendingCallPromise === null || removePrePendingCallPromise === void 0 ? void 0 : removePrePendingCallPromise(connectId, pendingPromise);
|
|
65208
|
-
}
|
|
65209
|
-
if (timedOut) {
|
|
65210
|
-
Log.warn('pre pending call promise timed out before call method', { connectId });
|
|
65211
|
-
}
|
|
65161
|
+
removePrePendingCallPromise === null || removePrePendingCallPromise === void 0 ? void 0 : removePrePendingCallPromise(pendingPromise);
|
|
65212
65162
|
Log.debug('pre pending call promise before call method done');
|
|
65213
65163
|
}
|
|
65214
65164
|
});
|
|
65215
65165
|
const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65216
|
-
var _d, _e, _f, _g, _h
|
|
65166
|
+
var _d, _e, _f, _g, _h;
|
|
65217
65167
|
let messageResponse;
|
|
65218
|
-
const { requestQueue, getPrePendingCallPromise,
|
|
65168
|
+
const { requestQueue, getPrePendingCallPromise, setPrePendingCallPromise } = context;
|
|
65219
65169
|
updateMethodRequestContext(method, { status: 'running' });
|
|
65220
65170
|
const normalizePassphraseState = (s) => s || '';
|
|
65221
65171
|
const connectStateChange = normalizePassphraseState(preConnectCache.passphraseState) !==
|
|
@@ -65230,7 +65180,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65230
65180
|
if (method.connectId) {
|
|
65231
65181
|
yield context.waitForCallbackTasks(method.connectId);
|
|
65232
65182
|
}
|
|
65233
|
-
yield waitForPendingPromise(
|
|
65183
|
+
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
65234
65184
|
const task = requestQueue.createTask(method);
|
|
65235
65185
|
let preWarmCallbackTask;
|
|
65236
65186
|
if (method.isPreWarmSignal && method.connectId) {
|
|
@@ -65239,9 +65189,9 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65239
65189
|
}
|
|
65240
65190
|
let device;
|
|
65241
65191
|
try {
|
|
65242
|
-
const connectId = (
|
|
65192
|
+
const connectId = (_d = method.connectId) !== null && _d !== void 0 ? _d : '';
|
|
65243
65193
|
const pollingId = pollingManager.start(connectId);
|
|
65244
|
-
device = yield ensureConnected(context, method, connectId, pollingId, (
|
|
65194
|
+
device = yield ensureConnected(context, method, connectId, pollingId, (_e = task.abortController) === null || _e === void 0 ? void 0 : _e.signal);
|
|
65245
65195
|
}
|
|
65246
65196
|
catch (e) {
|
|
65247
65197
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
@@ -65256,17 +65206,17 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65256
65206
|
requestQueue.releaseTask(method.responseID);
|
|
65257
65207
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
65258
65208
|
}
|
|
65259
|
-
if ((
|
|
65209
|
+
if ((_f = method.payload) === null || _f === void 0 ? void 0 : _f.onlyConnectBleDevice) {
|
|
65260
65210
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
65261
65211
|
Log.debug('Call API - only connect ble device: ', device === null || device === void 0 ? void 0 : device.mainId);
|
|
65262
65212
|
return createResponseMessage(method.responseID, true, null);
|
|
65263
65213
|
}
|
|
65264
65214
|
Log.debug('Call API - setDevice: ', device.mainId);
|
|
65265
|
-
(
|
|
65215
|
+
(_g = method.setDevice) === null || _g === void 0 ? void 0 : _g.call(method, device);
|
|
65266
65216
|
method.context = context;
|
|
65267
65217
|
updateMethodRequestContext(method, {
|
|
65268
65218
|
deviceInstanceId: device.instanceId,
|
|
65269
|
-
commandsInstanceId: (
|
|
65219
|
+
commandsInstanceId: (_h = device.commands) === null || _h === void 0 ? void 0 : _h.instanceId,
|
|
65270
65220
|
});
|
|
65271
65221
|
const activeRequests = getActiveRequestsByDeviceInstance(device.instanceId);
|
|
65272
65222
|
if (activeRequests.length > 0) {
|
|
@@ -65295,14 +65245,14 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65295
65245
|
if (method.connectId) {
|
|
65296
65246
|
yield context.waitForCallbackTasks(method.connectId, preWarmCallbackTask);
|
|
65297
65247
|
}
|
|
65298
|
-
yield waitForPendingPromise(
|
|
65248
|
+
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
65299
65249
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65300
|
-
var
|
|
65250
|
+
var _j, _k;
|
|
65301
65251
|
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
65302
65252
|
protocolV2Operation = device.isProtocolV2();
|
|
65303
65253
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
65304
|
-
const currentFirmwareVersion = (
|
|
65305
|
-
const currentBleVersion = (
|
|
65254
|
+
const currentFirmwareVersion = (_j = device.getCurrentFirmwareVersionString()) !== null && _j !== void 0 ? _j : '0.0.0';
|
|
65255
|
+
const currentBleVersion = (_k = device.getCurrentBLEFirmwareVersionString()) !== null && _k !== void 0 ? _k : '0.0.0';
|
|
65306
65256
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
65307
65257
|
let newVersionStatus;
|
|
65308
65258
|
if (device.features && !device.isProtocolV2()) {
|
|
@@ -65380,7 +65330,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65380
65330
|
}
|
|
65381
65331
|
},
|
|
65382
65332
|
prepare: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65383
|
-
var
|
|
65333
|
+
var _l, _m, _o, _p, _q;
|
|
65384
65334
|
if (method.deviceId && method.checkDeviceId && !deviceIdCheckedDuringUnlockPreflight) {
|
|
65385
65335
|
const isSameDeviceID = yield checkLiveDeviceId(device, method.deviceId);
|
|
65386
65336
|
if (!isSameDeviceID) {
|
|
@@ -65400,7 +65350,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65400
65350
|
require: support.require,
|
|
65401
65351
|
});
|
|
65402
65352
|
}
|
|
65403
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((
|
|
65353
|
+
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_l = method.payload) === null || _l === void 0 ? void 0 : _l.passphraseState, (_m = method.payload) === null || _m === void 0 ? void 0 : _m.useEmptyPassphrase, (_o = method.payload) === null || _o === void 0 ? void 0 : _o.skipPassphraseCheck, hasDeriveCardano(method));
|
|
65404
65354
|
checkPassphraseEnableState(method, device.features);
|
|
65405
65355
|
if (!passphraseStateSafety) {
|
|
65406
65356
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -65418,7 +65368,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65418
65368
|
? e
|
|
65419
65369
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
65420
65370
|
}
|
|
65421
|
-
(
|
|
65371
|
+
(_q = (_p = method.device) === null || _p === void 0 ? void 0 : _p.commands) === null || _q === void 0 ? void 0 : _q.checkDisposed();
|
|
65422
65372
|
}),
|
|
65423
65373
|
});
|
|
65424
65374
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
@@ -65614,13 +65564,6 @@ function isRetryableBleProtocolV2ProbeError(method, error) {
|
|
|
65614
65564
|
message.includes('expected V2') &&
|
|
65615
65565
|
message.includes('did not respond to expected protocol'));
|
|
65616
65566
|
}
|
|
65617
|
-
function isMissingDetectedProtocolV2Error(method, error) {
|
|
65618
|
-
const typedError = error;
|
|
65619
|
-
return (method.payload.connectProtocol === 'V2' &&
|
|
65620
|
-
(typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.RuntimeError &&
|
|
65621
|
-
typeof typedError.message === 'string' &&
|
|
65622
|
-
typedError.message.includes('Device protocol has not been detected'));
|
|
65623
|
-
}
|
|
65624
65567
|
function connectDeviceForBle(method, device, retryCount = 0) {
|
|
65625
65568
|
var _a;
|
|
65626
65569
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -65655,8 +65598,7 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65655
65598
|
}
|
|
65656
65599
|
}
|
|
65657
65600
|
catch (err) {
|
|
65658
|
-
|
|
65659
|
-
if ((hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) || requiresColdReconnect) &&
|
|
65601
|
+
if (hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) &&
|
|
65660
65602
|
device.mainId &&
|
|
65661
65603
|
device.deviceConnector) {
|
|
65662
65604
|
yield device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
@@ -65664,11 +65606,10 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65664
65606
|
}
|
|
65665
65607
|
if ((err.errorCode === hdShared.HardwareErrorCode.BleTimeoutError ||
|
|
65666
65608
|
err.errorCode === hdShared.HardwareErrorCode.BleConnectedError ||
|
|
65667
|
-
isRetryableBleProtocolV2ProbeError(method, err)
|
|
65668
|
-
requiresColdReconnect) &&
|
|
65609
|
+
isRetryableBleProtocolV2ProbeError(method, err)) &&
|
|
65669
65610
|
retryCount < 6) {
|
|
65670
65611
|
const nextRetry = retryCount + 1;
|
|
65671
|
-
Log.debug(`Bluetooth
|
|
65612
|
+
Log.debug(`Bluetooth connect timeout and will retry, retry count: ${nextRetry}`);
|
|
65672
65613
|
yield wait(3000);
|
|
65673
65614
|
yield connectDeviceForBle(method, device, nextRetry);
|
|
65674
65615
|
}
|
|
@@ -65687,7 +65628,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65687
65628
|
Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
|
|
65688
65629
|
const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65689
65630
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65690
|
-
var
|
|
65631
|
+
var _r;
|
|
65691
65632
|
const abort = () => {
|
|
65692
65633
|
if (abortSignal && abortSignal.aborted) {
|
|
65693
65634
|
if (timer) {
|
|
@@ -65802,7 +65743,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65802
65743
|
clearTimeout(timer);
|
|
65803
65744
|
}
|
|
65804
65745
|
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
65805
|
-
if (DataManager.isBrowserWebUsb(env) && !((
|
|
65746
|
+
if (DataManager.isBrowserWebUsb(env) && !((_r = method.payload) === null || _r === void 0 ? void 0 : _r.skipWebDevicePrompt)) {
|
|
65806
65747
|
postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
|
|
65807
65748
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
|
|
65808
65749
|
}
|
|
@@ -65820,7 +65761,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65820
65761
|
return poll();
|
|
65821
65762
|
});
|
|
65822
65763
|
const cancel = (context, connectId) => {
|
|
65823
|
-
var _a, _b
|
|
65764
|
+
var _a, _b;
|
|
65824
65765
|
const { requestQueue, setPrePendingCallPromise } = context;
|
|
65825
65766
|
if (connectId) {
|
|
65826
65767
|
try {
|
|
@@ -65834,7 +65775,7 @@ const cancel = (context, connectId) => {
|
|
|
65834
65775
|
if (task && ((_a = task.method) === null || _a === void 0 ? void 0 : _a.device)) {
|
|
65835
65776
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65836
65777
|
const { device } = task.method;
|
|
65837
|
-
setPrePendingCallPromise(
|
|
65778
|
+
setPrePendingCallPromise(device === null || device === void 0 ? void 0 : device.interruptionFromUser());
|
|
65838
65779
|
canceledDevices.push(device);
|
|
65839
65780
|
}
|
|
65840
65781
|
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled));
|
|
@@ -65854,7 +65795,7 @@ const cancel = (context, connectId) => {
|
|
|
65854
65795
|
for (const requestId of requestQueue.getRequestTasksId()) {
|
|
65855
65796
|
const task = requestQueue.getTask(requestId);
|
|
65856
65797
|
Log.debug('Cancel Api connect task: ', task);
|
|
65857
|
-
if (task && ((
|
|
65798
|
+
if (task && ((_b = task.method) === null || _b === void 0 ? void 0 : _b.device)) {
|
|
65858
65799
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65859
65800
|
const { device } = task.method;
|
|
65860
65801
|
device === null || device === void 0 ? void 0 : device.interruptionFromUser();
|
|
@@ -66043,7 +65984,6 @@ class Core extends events.exports {
|
|
|
66043
65984
|
constructor() {
|
|
66044
65985
|
super();
|
|
66045
65986
|
this.requestQueue = new RequestQueue();
|
|
66046
|
-
this.prePendingCallPromises = new Map();
|
|
66047
65987
|
this.methodSynchronize = getSynchronize();
|
|
66048
65988
|
this.tracingContext = createSdkTracingContext();
|
|
66049
65989
|
this.sdkInstanceId = this.tracingContext.sdkInstanceId;
|
|
@@ -66055,18 +65995,9 @@ class Core extends events.exports {
|
|
|
66055
65995
|
tracingContext: this.tracingContext,
|
|
66056
65996
|
requestQueue: this.requestQueue,
|
|
66057
65997
|
methodSynchronize: this.methodSynchronize,
|
|
66058
|
-
getPrePendingCallPromise: (
|
|
66059
|
-
setPrePendingCallPromise: (
|
|
66060
|
-
|
|
66061
|
-
this.prePendingCallPromises.delete(connectId);
|
|
66062
|
-
return;
|
|
66063
|
-
}
|
|
66064
|
-
this.prePendingCallPromises.set(connectId, promise);
|
|
66065
|
-
},
|
|
66066
|
-
removePrePendingCallPromise: (connectId, promise) => {
|
|
66067
|
-
if (this.prePendingCallPromises.get(connectId) === promise) {
|
|
66068
|
-
this.prePendingCallPromises.delete(connectId);
|
|
66069
|
-
}
|
|
65998
|
+
getPrePendingCallPromise: () => this.prePendingCallPromise,
|
|
65999
|
+
setPrePendingCallPromise: (promise) => {
|
|
66000
|
+
this.prePendingCallPromise = promise;
|
|
66070
66001
|
},
|
|
66071
66002
|
registerCallbackTask: (connectId, callbackPromise) => {
|
|
66072
66003
|
this.requestQueue.registerPendingCallbackTask(connectId, callbackPromise);
|
|
@@ -66160,7 +66091,7 @@ class Core extends events.exports {
|
|
|
66160
66091
|
preWarmInflight.clear();
|
|
66161
66092
|
preWarmDoneAt.clear();
|
|
66162
66093
|
preConnectCache = { passphraseState: undefined };
|
|
66163
|
-
this.
|
|
66094
|
+
this.prePendingCallPromise = undefined;
|
|
66164
66095
|
this.removeAllListeners();
|
|
66165
66096
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
66166
66097
|
if (_core === this)
|