@onekeyfe/hd-core 1.2.0-alpha.133 → 1.2.0-alpha.134
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__/device-wallet-session-store.test.ts +79 -21
- 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 +206 -268
- 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 +42 -42
- 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;
|
|
@@ -45617,15 +45606,6 @@ class Device extends events.exports {
|
|
|
45617
45606
|
yield TransportManager.reconfigure(this.features);
|
|
45618
45607
|
});
|
|
45619
45608
|
const expectedDeviceId = options === null || options === void 0 ? void 0 : options.deviceId;
|
|
45620
|
-
if (expectedDeviceId) {
|
|
45621
|
-
this.passphraseState = undefined;
|
|
45622
|
-
const { message } = yield this.commands.typedCall('GetFeatures', 'Features', {});
|
|
45623
|
-
this._updateFeatures(message);
|
|
45624
|
-
yield TransportManager.reconfigure(this.features);
|
|
45625
|
-
if (!this.checkDeviceId(expectedDeviceId)) {
|
|
45626
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
45627
|
-
}
|
|
45628
|
-
}
|
|
45629
45609
|
this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
|
|
45630
45610
|
if (options === null || options === void 0 ? void 0 : options.initSession) {
|
|
45631
45611
|
this.clearInternalState(options === null || options === void 0 ? void 0 : options.deviceId);
|
|
@@ -45641,17 +45621,33 @@ class Device extends events.exports {
|
|
|
45641
45621
|
if (options === null || options === void 0 ? void 0 : options.deriveCardano) {
|
|
45642
45622
|
payload.derive_cardano = true;
|
|
45643
45623
|
}
|
|
45644
|
-
|
|
45624
|
+
if (this.features) {
|
|
45625
|
+
yield TransportManager.reconfigure(this.features);
|
|
45626
|
+
}
|
|
45627
|
+
const assertExpectedDeviceIdentity = () => {
|
|
45628
|
+
if (expectedDeviceId && !this.checkDeviceId(expectedDeviceId)) {
|
|
45629
|
+
this.clearInternalState();
|
|
45630
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
45631
|
+
}
|
|
45632
|
+
};
|
|
45633
|
+
try {
|
|
45634
|
+
yield callInitialize(payload, options === null || options === void 0 ? void 0 : options.initSession);
|
|
45635
|
+
}
|
|
45636
|
+
catch (error) {
|
|
45637
|
+
assertExpectedDeviceIdentity();
|
|
45638
|
+
throw error;
|
|
45639
|
+
}
|
|
45640
|
+
assertExpectedDeviceIdentity();
|
|
45645
45641
|
}
|
|
45646
45642
|
catch (error) {
|
|
45647
|
-
Log$
|
|
45643
|
+
Log$g.error('Initialization failed:', error);
|
|
45648
45644
|
throw error;
|
|
45649
45645
|
}
|
|
45650
45646
|
});
|
|
45651
45647
|
}
|
|
45652
45648
|
_initializeProtocolV2(options) {
|
|
45653
45649
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45654
|
-
Log$
|
|
45650
|
+
Log$g.debug('Initialize device via Protocol V2 features adapter');
|
|
45655
45651
|
try {
|
|
45656
45652
|
const deviceInfo = yield requestProtocolV2DeviceInfo({
|
|
45657
45653
|
commands: this.commands,
|
|
@@ -45660,7 +45656,7 @@ class Device extends events.exports {
|
|
|
45660
45656
|
yield this.probeProtocolV2RuntimeState(deviceInfo, options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs);
|
|
45661
45657
|
}
|
|
45662
45658
|
catch (error) {
|
|
45663
|
-
Log$
|
|
45659
|
+
Log$g.error('Protocol V2 initialization failed:', error);
|
|
45664
45660
|
throw error;
|
|
45665
45661
|
}
|
|
45666
45662
|
});
|
|
@@ -45743,11 +45739,6 @@ class Device extends events.exports {
|
|
|
45743
45739
|
return params.includeRaw ? cloneDeviceState(this.state) : createPublicDeviceState(this.state);
|
|
45744
45740
|
});
|
|
45745
45741
|
}
|
|
45746
|
-
refreshProtocolV2SettingsAfterMutation() {
|
|
45747
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45748
|
-
return this.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
45749
|
-
});
|
|
45750
|
-
}
|
|
45751
45742
|
_updateFeatures(protoFeatures, initSession) {
|
|
45752
45743
|
var _a;
|
|
45753
45744
|
const previousDeviceId = this.getCurrentDeviceId();
|
|
@@ -45774,7 +45765,7 @@ class Device extends events.exports {
|
|
|
45774
45765
|
source,
|
|
45775
45766
|
changedKeys: result.changedKeys,
|
|
45776
45767
|
};
|
|
45777
|
-
Log$
|
|
45768
|
+
Log$g.debug('Device state updated', {
|
|
45778
45769
|
source,
|
|
45779
45770
|
revision: result.revision,
|
|
45780
45771
|
changedKeyCount: result.changedKeys.length,
|
|
@@ -45998,25 +45989,17 @@ class Device extends events.exports {
|
|
|
45998
45989
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45999
45990
|
if (this.runPromise) {
|
|
46000
45991
|
yield this.interruptionFromOutside();
|
|
46001
|
-
Log$
|
|
45992
|
+
Log$g.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
46002
45993
|
}
|
|
46003
45994
|
options = parseRunOptions(options);
|
|
46004
45995
|
const runPromise = hdShared.createDeferred();
|
|
46005
45996
|
this.runPromise = runPromise;
|
|
46006
|
-
|
|
45997
|
+
this._runInner(fn, options, runPromise).catch(error => {
|
|
46007
45998
|
if (this.runPromise === runPromise) {
|
|
46008
45999
|
this.runPromise = null;
|
|
46009
46000
|
}
|
|
46010
46001
|
runPromise.reject(error);
|
|
46011
46002
|
});
|
|
46012
|
-
this.runCleanupPromise = cleanupPromise;
|
|
46013
|
-
cleanupPromise
|
|
46014
|
-
.finally(() => {
|
|
46015
|
-
if (this.runCleanupPromise === cleanupPromise) {
|
|
46016
|
-
this.runCleanupPromise = undefined;
|
|
46017
|
-
}
|
|
46018
|
-
})
|
|
46019
|
-
.catch(() => undefined);
|
|
46020
46003
|
return runPromise.promise;
|
|
46021
46004
|
});
|
|
46022
46005
|
}
|
|
@@ -46083,7 +46066,7 @@ class Device extends events.exports {
|
|
|
46083
46066
|
yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
|
|
46084
46067
|
}
|
|
46085
46068
|
yield this.release();
|
|
46086
|
-
Log$
|
|
46069
|
+
Log$g.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
46087
46070
|
}
|
|
46088
46071
|
clearRunPromise();
|
|
46089
46072
|
return;
|
|
@@ -46093,7 +46076,7 @@ class Device extends events.exports {
|
|
|
46093
46076
|
options.keepSession === false) {
|
|
46094
46077
|
this.keepSession = false;
|
|
46095
46078
|
yield this.release();
|
|
46096
|
-
Log$
|
|
46079
|
+
Log$g.debug('release device, mainId: ', this.mainId);
|
|
46097
46080
|
}
|
|
46098
46081
|
runPromise.resolve();
|
|
46099
46082
|
clearRunPromise();
|
|
@@ -46110,33 +46093,21 @@ class Device extends events.exports {
|
|
|
46110
46093
|
});
|
|
46111
46094
|
}
|
|
46112
46095
|
interruptionFromUser() {
|
|
46113
|
-
var _a, _b
|
|
46096
|
+
var _a, _b;
|
|
46114
46097
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46115
46098
|
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());
|
|
46099
|
+
yield ((_a = this.cancelableAction) === null || _a === void 0 ? void 0 : _a.call(this, error));
|
|
46100
|
+
yield ((_b = this.commands) === null || _b === void 0 ? void 0 : _b.cancel());
|
|
46129
46101
|
if (this.runPromise) {
|
|
46130
46102
|
this.runPromise.reject(error);
|
|
46131
46103
|
this.runPromise = null;
|
|
46132
46104
|
}
|
|
46133
|
-
yield (cleanupPromise === null || cleanupPromise === void 0 ? void 0 : cleanupPromise.catch(() => undefined));
|
|
46134
46105
|
});
|
|
46135
46106
|
}
|
|
46136
46107
|
setCancelableAction(callback) {
|
|
46137
46108
|
this.cancelableAction = (e) => callback(e)
|
|
46138
46109
|
.catch(e2 => {
|
|
46139
|
-
Log$
|
|
46110
|
+
Log$g.debug('cancelableAction error', e2);
|
|
46140
46111
|
})
|
|
46141
46112
|
.finally(() => {
|
|
46142
46113
|
this.clearCancelableAction();
|
|
@@ -46419,7 +46390,7 @@ class Device extends events.exports {
|
|
|
46419
46390
|
expectedPassphraseState &&
|
|
46420
46391
|
expectedPassphraseState !== newPassphraseState;
|
|
46421
46392
|
const passphraseStateMismatch = !!expectedPassphraseState && expectedPassphraseState !== newPassphraseState;
|
|
46422
|
-
Log$
|
|
46393
|
+
Log$g.debug('Check passphrase state safety: ', {
|
|
46423
46394
|
hasExpectedPassphraseState: Boolean(expectedPassphraseState),
|
|
46424
46395
|
hasNewPassphraseState: Boolean(newPassphraseState),
|
|
46425
46396
|
passphraseStateMatches: Boolean(expectedPassphraseState) && expectedPassphraseState === newPassphraseState,
|
|
@@ -46557,7 +46528,7 @@ const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwar
|
|
|
46557
46528
|
};
|
|
46558
46529
|
};
|
|
46559
46530
|
|
|
46560
|
-
const Log$
|
|
46531
|
+
const Log$f = getLogger(exports.LoggerNames.Method);
|
|
46561
46532
|
const isEvmLedgerLegacyPathWithHighIndex = (path) => {
|
|
46562
46533
|
let addressN;
|
|
46563
46534
|
if (typeof path === 'string') {
|
|
@@ -46641,7 +46612,7 @@ class BaseMethod {
|
|
|
46641
46612
|
setContext(context) {
|
|
46642
46613
|
this.sdkInstanceId = context.sdkInstanceId;
|
|
46643
46614
|
this.instanceId = generateInstanceId('Method', this.sdkInstanceId);
|
|
46644
|
-
Log$
|
|
46615
|
+
Log$f.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
|
|
46645
46616
|
}
|
|
46646
46617
|
setDevice(device) {
|
|
46647
46618
|
var _a, _b;
|
|
@@ -46661,7 +46632,7 @@ class BaseMethod {
|
|
|
46661
46632
|
if (device.commands) {
|
|
46662
46633
|
device.commands.currentResponseID = this.responseID;
|
|
46663
46634
|
}
|
|
46664
|
-
Log$
|
|
46635
|
+
Log$f.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
|
|
46665
46636
|
}
|
|
46666
46637
|
checkFirmwareRelease() {
|
|
46667
46638
|
if (!this.device || this.device.isProtocolV2())
|
|
@@ -46736,7 +46707,7 @@ class BaseMethod {
|
|
|
46736
46707
|
checkFlag = true;
|
|
46737
46708
|
}
|
|
46738
46709
|
if (checkFlag && this.device.getCurrentSafetyChecks() === hdTransport.Enum_SafetyCheckLevel.Strict) {
|
|
46739
|
-
Log$
|
|
46710
|
+
Log$f.debug('will change safety_checks level');
|
|
46740
46711
|
yield this.device.commands.typedCall('ApplySettings', 'Success', {
|
|
46741
46712
|
safety_checks: hdTransport.Enum_SafetyCheckLevel.PromptTemporarily,
|
|
46742
46713
|
});
|
|
@@ -46812,7 +46783,7 @@ class Ping extends BaseMethod {
|
|
|
46812
46783
|
}
|
|
46813
46784
|
}
|
|
46814
46785
|
|
|
46815
|
-
const Log$
|
|
46786
|
+
const Log$e = getLogger(exports.LoggerNames.Core);
|
|
46816
46787
|
const parseInitOptions$1 = (payload) => ({
|
|
46817
46788
|
initSession: payload === null || payload === void 0 ? void 0 : payload.initSession,
|
|
46818
46789
|
passphraseState: payload === null || payload === void 0 ? void 0 : payload.passphraseState,
|
|
@@ -46838,14 +46809,14 @@ class PreInitialize extends BaseMethod {
|
|
|
46838
46809
|
}
|
|
46839
46810
|
catch (_a) {
|
|
46840
46811
|
this.device.clearPreInitialized();
|
|
46841
|
-
Log$
|
|
46812
|
+
Log$e.debug('[PRE-INIT][FAILED]');
|
|
46842
46813
|
return false;
|
|
46843
46814
|
}
|
|
46844
46815
|
});
|
|
46845
46816
|
}
|
|
46846
46817
|
}
|
|
46847
46818
|
|
|
46848
|
-
const Log$
|
|
46819
|
+
const Log$d = getLogger(exports.LoggerNames.DevicePool);
|
|
46849
46820
|
class SearchDevices extends BaseMethod {
|
|
46850
46821
|
init() {
|
|
46851
46822
|
this.useDevice = false;
|
|
@@ -46887,7 +46858,7 @@ class SearchDevices extends BaseMethod {
|
|
|
46887
46858
|
const errorCode = error && typeof error === 'object' && 'errorCode' in error
|
|
46888
46859
|
? error.errorCode
|
|
46889
46860
|
: undefined;
|
|
46890
|
-
Log$
|
|
46861
|
+
Log$d.debug('Skip unavailable device during search', Object.assign({ path: descriptor.path }, (errorCode !== undefined ? { errorCode } : {})));
|
|
46891
46862
|
}
|
|
46892
46863
|
}
|
|
46893
46864
|
return deviceList.map(device => device.toMessageObject());
|
|
@@ -47789,7 +47760,7 @@ function buildProtocolV2FirmwareRelease({ currentVersions, currentVerification =
|
|
|
47789
47760
|
release,
|
|
47790
47761
|
};
|
|
47791
47762
|
}
|
|
47792
|
-
const Log$
|
|
47763
|
+
const Log$c = getLogger(exports.LoggerNames.Method);
|
|
47793
47764
|
class CheckAllFirmwareRelease extends BaseMethod {
|
|
47794
47765
|
getSupportedProtocols() {
|
|
47795
47766
|
return ['V1', 'V2'];
|
|
@@ -47850,7 +47821,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47850
47821
|
((_c = error.params) === null || _c === void 0 ? void 0 : _c.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47851
47822
|
throw error;
|
|
47852
47823
|
}
|
|
47853
|
-
Log$
|
|
47824
|
+
Log$c.warn('[CheckAllFirmwareRelease] Optional firmware Plan is unavailable; using the legacy release result');
|
|
47854
47825
|
firmwareUpdatePlan = undefined;
|
|
47855
47826
|
}
|
|
47856
47827
|
return {
|
|
@@ -47936,7 +47907,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47936
47907
|
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47937
47908
|
throw error;
|
|
47938
47909
|
}
|
|
47939
|
-
Log$
|
|
47910
|
+
Log$c.warn('[CheckAllFirmwareRelease] Optional Protocol V2 firmware Plan is unavailable; using the release result');
|
|
47940
47911
|
firmwareUpdatePlan = undefined;
|
|
47941
47912
|
}
|
|
47942
47913
|
const firmwarePlan = summarizeProtocolV2FirmwareRelease(plan, PROTOCOL_V2_MAIN_FIRMWARE_TARGETS);
|
|
@@ -48503,7 +48474,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
48503
48474
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48504
48475
|
try {
|
|
48505
48476
|
if (this.device.isProtocolV2()) {
|
|
48506
|
-
const refreshStatusAndSettings = () => this.device.
|
|
48477
|
+
const refreshStatusAndSettings = () => this.device.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
48507
48478
|
assertSettingsSupported(this.payload, DEVICE_SETTINGS_V1_ONLY_FIELDS, 'Protocol V2');
|
|
48508
48479
|
const capabilities = getDeviceSettingsCapabilities(this.device.getCurrentDeviceType(), 'V2');
|
|
48509
48480
|
assertProtocolV2SettingValues(this.payload, capabilities);
|
|
@@ -48526,7 +48497,14 @@ class DeviceSettings extends BaseMethod {
|
|
|
48526
48497
|
const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', {
|
|
48527
48498
|
page: hdTransport.DeviceSettingsPage.DevicePassphrase,
|
|
48528
48499
|
});
|
|
48529
|
-
yield refreshStatusAndSettings();
|
|
48500
|
+
const updated = yield refreshStatusAndSettings();
|
|
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
|
+
}
|
|
48530
48508
|
return res.message;
|
|
48531
48509
|
}
|
|
48532
48510
|
if (requestedAirgap !== undefined) {
|
|
@@ -48915,7 +48893,7 @@ const getInfo = ({ features, updateType, targetVersion, firmwareType }) => {
|
|
|
48915
48893
|
const NEW_BOOT_UPRATE_FIRMWARE_VERSION = '2.4.5';
|
|
48916
48894
|
const SESSION_ERROR$3 = 'session not found';
|
|
48917
48895
|
const FIRMWARE_UPDATE_CONFIRM$1 = 'Firmware install confirmed';
|
|
48918
|
-
const Log$
|
|
48896
|
+
const Log$b = getLogger(exports.LoggerNames.Method);
|
|
48919
48897
|
const isDeviceDisconnectedError$1 = (error) => {
|
|
48920
48898
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
48921
48899
|
return (message.includes('device was disconnected') ||
|
|
@@ -48970,13 +48948,13 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48970
48948
|
const newFeatures = yield typedCall('GetFeatures', 'Features', {});
|
|
48971
48949
|
const deviceBootloaderVersion = getDeviceBootloaderVersion(buildProtocolV1FeaturesPayload(newFeatures.message, device.features)).join('.');
|
|
48972
48950
|
const supportUpgradeFileHeader = semver__default["default"].gte(deviceBootloaderVersion, '2.1.0');
|
|
48973
|
-
Log$
|
|
48951
|
+
Log$b.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
|
|
48974
48952
|
if (supportUpgradeFileHeader) {
|
|
48975
48953
|
const HEADER_SIZE = 1024;
|
|
48976
48954
|
if (source.size < HEADER_SIZE) {
|
|
48977
48955
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${source.size} bytes, expected at least ${HEADER_SIZE} bytes`);
|
|
48978
48956
|
}
|
|
48979
|
-
Log$
|
|
48957
|
+
Log$b.debug('Uploading firmware header:', {
|
|
48980
48958
|
size: HEADER_SIZE,
|
|
48981
48959
|
totalSize: source.size,
|
|
48982
48960
|
});
|
|
@@ -48988,18 +48966,18 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48988
48966
|
});
|
|
48989
48967
|
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
48968
|
if (headerRes.type !== 'Success' && !isUnknownMessage) {
|
|
48991
|
-
Log$
|
|
48969
|
+
Log$b.error('Firmware header upload failed:', headerRes);
|
|
48992
48970
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
|
|
48993
48971
|
}
|
|
48994
48972
|
}
|
|
48995
48973
|
catch (error) {
|
|
48996
|
-
Log$
|
|
48974
|
+
Log$b.error('Firmware header upload failed:', error);
|
|
48997
48975
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
48998
48976
|
if (!message.includes('Failure_UnknownMessage')) {
|
|
48999
48977
|
throw error;
|
|
49000
48978
|
}
|
|
49001
48979
|
}
|
|
49002
|
-
Log$
|
|
48980
|
+
Log$b.debug('Firmware header uploaded successfully');
|
|
49003
48981
|
}
|
|
49004
48982
|
}
|
|
49005
48983
|
const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
|
|
@@ -49018,7 +48996,7 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
49018
48996
|
}
|
|
49019
48997
|
catch (error) {
|
|
49020
48998
|
if (isDeviceDisconnectedError$1(error)) {
|
|
49021
|
-
Log$
|
|
48999
|
+
Log$b.log('Rebooting device');
|
|
49022
49000
|
updateResponse = {
|
|
49023
49001
|
type: 'Success',
|
|
49024
49002
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49116,7 +49094,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49116
49094
|
}
|
|
49117
49095
|
catch (error) {
|
|
49118
49096
|
if (isDeviceDisconnectedError$1(error)) {
|
|
49119
|
-
Log$
|
|
49097
|
+
Log$b.log('Rebooting device');
|
|
49120
49098
|
response = {
|
|
49121
49099
|
type: 'Success',
|
|
49122
49100
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49147,7 +49125,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49147
49125
|
]);
|
|
49148
49126
|
}
|
|
49149
49127
|
catch (e) {
|
|
49150
|
-
Log$
|
|
49128
|
+
Log$b.log('catch Bluetooth error when device is restarting: ', e);
|
|
49151
49129
|
}
|
|
49152
49130
|
}
|
|
49153
49131
|
else {
|
|
@@ -49168,7 +49146,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49168
49146
|
}
|
|
49169
49147
|
catch (error) {
|
|
49170
49148
|
console.error('Device reconnect failed: ', error);
|
|
49171
|
-
Log$
|
|
49149
|
+
Log$b.error('Device reconnect failed:', error);
|
|
49172
49150
|
yield wait(1000);
|
|
49173
49151
|
}
|
|
49174
49152
|
}
|
|
@@ -49208,7 +49186,7 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
|
|
|
49208
49186
|
return result;
|
|
49209
49187
|
}
|
|
49210
49188
|
catch (error) {
|
|
49211
|
-
Log$
|
|
49189
|
+
Log$b.error(`emmcWrite error: `, error);
|
|
49212
49190
|
retryCount--;
|
|
49213
49191
|
if (retryCount === 0) {
|
|
49214
49192
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -49403,7 +49381,7 @@ class DeviceFullyUploadResource extends BaseMethod {
|
|
|
49403
49381
|
}
|
|
49404
49382
|
}
|
|
49405
49383
|
|
|
49406
|
-
const Log$
|
|
49384
|
+
const Log$a = getLogger(exports.LoggerNames.Method);
|
|
49407
49385
|
const SESSION_ERROR$2 = 'session not found';
|
|
49408
49386
|
const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
49409
49387
|
const BOOTLOADER_POLL_INITIALIZE_TIMEOUT_MS = 5000;
|
|
@@ -49481,7 +49459,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49481
49459
|
const env = DataManager.getSettings('env');
|
|
49482
49460
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
49483
49461
|
let bleProbeInFlight = false;
|
|
49484
|
-
Log$
|
|
49462
|
+
Log$a.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
49485
49463
|
let isFirstCheck = true;
|
|
49486
49464
|
let checkCount = 0;
|
|
49487
49465
|
let hasPromptedWebDevice = false;
|
|
@@ -49515,10 +49493,10 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49515
49493
|
if (isFinished || isPromptingWebDevice)
|
|
49516
49494
|
return;
|
|
49517
49495
|
checkCount += 1;
|
|
49518
|
-
Log$
|
|
49496
|
+
Log$a.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
49519
49497
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
49520
49498
|
isFirstCheck = false;
|
|
49521
|
-
Log$
|
|
49499
|
+
Log$a.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] wait 3000ms');
|
|
49522
49500
|
yield wait(3000);
|
|
49523
49501
|
}
|
|
49524
49502
|
if (checkCount > 4 &&
|
|
@@ -49542,7 +49520,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49542
49520
|
catch (e) {
|
|
49543
49521
|
isFinished = true;
|
|
49544
49522
|
clearPollingTimers();
|
|
49545
|
-
Log$
|
|
49523
|
+
Log$a.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
49546
49524
|
(_c = this.checkPromise) === null || _c === void 0 ? void 0 : _c.reject(e);
|
|
49547
49525
|
}
|
|
49548
49526
|
finally {
|
|
@@ -49564,7 +49542,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49564
49542
|
}
|
|
49565
49543
|
}
|
|
49566
49544
|
catch (e) {
|
|
49567
|
-
Log$
|
|
49545
|
+
Log$a.log('catch Bluetooth error when device is restarting: ', e);
|
|
49568
49546
|
}
|
|
49569
49547
|
finally {
|
|
49570
49548
|
bleProbeInFlight = false;
|
|
@@ -49667,7 +49645,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49667
49645
|
}
|
|
49668
49646
|
catch (error) {
|
|
49669
49647
|
if (isDeviceDisconnectedError(error)) {
|
|
49670
|
-
Log$
|
|
49648
|
+
Log$a.log('Rebooting device');
|
|
49671
49649
|
updateResponse = {
|
|
49672
49650
|
type: 'Success',
|
|
49673
49651
|
message: { message: FIRMWARE_UPDATE_CONFIRM },
|
|
@@ -49783,7 +49761,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49783
49761
|
return result;
|
|
49784
49762
|
}
|
|
49785
49763
|
catch (error) {
|
|
49786
|
-
Log$
|
|
49764
|
+
Log$a.error(`emmcWrite error: `, error);
|
|
49787
49765
|
retryCount--;
|
|
49788
49766
|
if (retryCount === 0) {
|
|
49789
49767
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -50090,7 +50068,7 @@ class GetNextU2FCounter extends BaseMethod {
|
|
|
50090
50068
|
}
|
|
50091
50069
|
}
|
|
50092
50070
|
|
|
50093
|
-
const Log$
|
|
50071
|
+
const Log$9 = getLogger(exports.LoggerNames.Method);
|
|
50094
50072
|
class FirmwareUpdate extends BaseMethod {
|
|
50095
50073
|
constructor() {
|
|
50096
50074
|
super(...arguments);
|
|
@@ -50129,7 +50107,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50129
50107
|
const env = DataManager.getSettings('env');
|
|
50130
50108
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50131
50109
|
let bleProbeInFlight = false;
|
|
50132
|
-
Log$
|
|
50110
|
+
Log$9.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50133
50111
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
50134
50112
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
50135
50113
|
if (isBleReconnect) {
|
|
@@ -50145,7 +50123,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50145
50123
|
}
|
|
50146
50124
|
}
|
|
50147
50125
|
catch (e) {
|
|
50148
|
-
Log$
|
|
50126
|
+
Log$9.log('catch Bluetooth error when device is restarting: ', e);
|
|
50149
50127
|
}
|
|
50150
50128
|
finally {
|
|
50151
50129
|
bleProbeInFlight = false;
|
|
@@ -50204,7 +50182,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50204
50182
|
if (e instanceof hdShared.HardwareError) {
|
|
50205
50183
|
return Promise.reject(e);
|
|
50206
50184
|
}
|
|
50207
|
-
Log$
|
|
50185
|
+
Log$9.log('auto go to bootloader mode failed: ', e);
|
|
50208
50186
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure));
|
|
50209
50187
|
}
|
|
50210
50188
|
}
|
|
@@ -50353,7 +50331,7 @@ const readVerifiedPreparedResourceArchive = ({ preparedPlan, reader, }) => __awa
|
|
|
50353
50331
|
return verifiedEntries;
|
|
50354
50332
|
});
|
|
50355
50333
|
|
|
50356
|
-
const Log$
|
|
50334
|
+
const Log$8 = getLogger(exports.LoggerNames.Method);
|
|
50357
50335
|
const FIRMWARE_DOWNLOAD_REQUEST_OPTIONS = {
|
|
50358
50336
|
connectTimeoutMs: 60000,
|
|
50359
50337
|
readTimeoutMs: 60000,
|
|
@@ -50510,7 +50488,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50510
50488
|
const env = DataManager.getSettings('env');
|
|
50511
50489
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50512
50490
|
let probeInFlight = false;
|
|
50513
|
-
Log$
|
|
50491
|
+
Log$8.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50514
50492
|
let isFirstCheck = true;
|
|
50515
50493
|
let checkCount = 0;
|
|
50516
50494
|
let hasPromptedWebDevice = false;
|
|
@@ -50545,10 +50523,10 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50545
50523
|
return;
|
|
50546
50524
|
probeInFlight = true;
|
|
50547
50525
|
checkCount += 1;
|
|
50548
|
-
Log$
|
|
50526
|
+
Log$8.log('FirmwareUpdateV2 [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
50549
50527
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
50550
50528
|
isFirstCheck = false;
|
|
50551
|
-
Log$
|
|
50529
|
+
Log$8.log('FirmwareUpdateV2 [checkDeviceToBootloader] wait 3000ms');
|
|
50552
50530
|
yield wait(3000);
|
|
50553
50531
|
}
|
|
50554
50532
|
if (checkCount > 4 &&
|
|
@@ -50572,7 +50550,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50572
50550
|
catch (e) {
|
|
50573
50551
|
isFinished = true;
|
|
50574
50552
|
clearPollingTimers();
|
|
50575
|
-
Log$
|
|
50553
|
+
Log$8.log('FirmwareUpdateV2 [checkDeviceToBootloader] promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
50576
50554
|
(_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.reject(e);
|
|
50577
50555
|
}
|
|
50578
50556
|
finally {
|
|
@@ -50592,7 +50570,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50592
50570
|
}
|
|
50593
50571
|
}
|
|
50594
50572
|
catch (e) {
|
|
50595
|
-
Log$
|
|
50573
|
+
Log$8.log('catch Bluetooth error when device is restarting: ', e);
|
|
50596
50574
|
}
|
|
50597
50575
|
finally {
|
|
50598
50576
|
probeInFlight = false;
|
|
@@ -50887,7 +50865,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50887
50865
|
}
|
|
50888
50866
|
}
|
|
50889
50867
|
|
|
50890
|
-
const Log$
|
|
50868
|
+
const Log$7 = getLogger(exports.LoggerNames.Method);
|
|
50891
50869
|
const MIN_UPDATE_V3_BOOTLOADER_VERSION = '2.8.0';
|
|
50892
50870
|
class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
50893
50871
|
constructor() {
|
|
@@ -51005,7 +50983,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51005
50983
|
}
|
|
51006
50984
|
run() {
|
|
51007
50985
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51008
|
-
Log$
|
|
50986
|
+
Log$7.debug('FirmwareUpdateV3 strategy: Protocol V1');
|
|
51009
50987
|
return this.runProtocolV1();
|
|
51010
50988
|
});
|
|
51011
50989
|
}
|
|
@@ -51152,7 +51130,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51152
51130
|
resourceEntries: [],
|
|
51153
51131
|
};
|
|
51154
51132
|
}
|
|
51155
|
-
Log$
|
|
51133
|
+
Log$7.warn('No resource url found');
|
|
51156
51134
|
return {
|
|
51157
51135
|
resourceBinary: null,
|
|
51158
51136
|
resourceEntries: [],
|
|
@@ -51313,7 +51291,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51313
51291
|
yield this.startEmmcFirmwareUpdate({ path: '0:updates' });
|
|
51314
51292
|
}
|
|
51315
51293
|
catch (error) {
|
|
51316
|
-
Log$
|
|
51294
|
+
Log$7.error('triggerFirmwareUpdateEmmc error: ', error);
|
|
51317
51295
|
if (error === null || error === void 0 ? void 0 : error.errorCode) {
|
|
51318
51296
|
const unexpectedError = [
|
|
51319
51297
|
hdShared.HardwareErrorCode.ActionCancelled,
|
|
@@ -51383,7 +51361,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51383
51361
|
yield hdShared.wait(1000);
|
|
51384
51362
|
}
|
|
51385
51363
|
catch (error) {
|
|
51386
|
-
Log$
|
|
51364
|
+
Log$7.log('getFeatures error', error);
|
|
51387
51365
|
let shouldReconnect = true;
|
|
51388
51366
|
const progress = this.extractUpdateModeProgress(error);
|
|
51389
51367
|
if (progress !== null) {
|
|
@@ -51482,7 +51460,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51482
51460
|
return;
|
|
51483
51461
|
}
|
|
51484
51462
|
catch (e) {
|
|
51485
|
-
Log$
|
|
51463
|
+
Log$7.log('catch Bluetooth error when device is restarting: ', e);
|
|
51486
51464
|
}
|
|
51487
51465
|
}
|
|
51488
51466
|
else {
|
|
@@ -51497,7 +51475,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51497
51475
|
yield this._promptDeviceForSwitchFirmwareWebDevice();
|
|
51498
51476
|
}
|
|
51499
51477
|
catch (e) {
|
|
51500
|
-
Log$
|
|
51478
|
+
Log$7.log('WebUSB re-authorization failed: ', e);
|
|
51501
51479
|
}
|
|
51502
51480
|
webUsbCheckCount = 0;
|
|
51503
51481
|
}
|
|
@@ -51522,7 +51500,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51522
51500
|
}
|
|
51523
51501
|
catch (error) {
|
|
51524
51502
|
console.error('Device reconnect failed: ', error);
|
|
51525
|
-
Log$
|
|
51503
|
+
Log$7.error('Device reconnect failed:', error);
|
|
51526
51504
|
yield hdShared.wait(1000);
|
|
51527
51505
|
}
|
|
51528
51506
|
}
|
|
@@ -51706,7 +51684,7 @@ function prepareFirmwareUpdateV4MemoryHost({ sdk, plan, artifacts, }) {
|
|
|
51706
51684
|
};
|
|
51707
51685
|
}
|
|
51708
51686
|
|
|
51709
|
-
const Log$
|
|
51687
|
+
const Log$6 = getLogger(exports.LoggerNames.Method);
|
|
51710
51688
|
const SESSION_ERROR$1 = 'session not found';
|
|
51711
51689
|
const PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT = 90 * 1000;
|
|
51712
51690
|
const PROTOCOL_V2_FINAL_RECONNECT_TIMEOUT = 3 * 60 * 1000;
|
|
@@ -52184,7 +52162,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52184
52162
|
}
|
|
52185
52163
|
run() {
|
|
52186
52164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52187
|
-
Log$
|
|
52165
|
+
Log$6.debug('FirmwareUpdateV4 strategy: Protocol V2');
|
|
52188
52166
|
return this.runProtocolV2();
|
|
52189
52167
|
});
|
|
52190
52168
|
}
|
|
@@ -52759,7 +52737,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52759
52737
|
: `${Math.floor(statusVersion / 0x10000) % 0x100}.${Math.floor(statusVersion / 0x100) % 0x100}.${statusVersion % 0x100}`;
|
|
52760
52738
|
if (!observedVersion) {
|
|
52761
52739
|
if (this.protocolV2FinalStatusVerified) {
|
|
52762
|
-
Log$
|
|
52740
|
+
Log$6.warn(`Protocol V2 target ${target} has no observable final version; completed target status is authoritative`);
|
|
52763
52741
|
}
|
|
52764
52742
|
else {
|
|
52765
52743
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, `Protocol V2 target ${target} has no observable final version after status fallback`);
|
|
@@ -53129,7 +53107,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53129
53107
|
return true;
|
|
53130
53108
|
}
|
|
53131
53109
|
catch (error) {
|
|
53132
|
-
Log$
|
|
53110
|
+
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53133
53111
|
return false;
|
|
53134
53112
|
}
|
|
53135
53113
|
});
|
|
@@ -53169,7 +53147,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53169
53147
|
if (error instanceof hdShared.HardwareError) {
|
|
53170
53148
|
throw error;
|
|
53171
53149
|
}
|
|
53172
|
-
Log$
|
|
53150
|
+
Log$6.log('Protocol V2 auto go to bootloader mode failed: ', error);
|
|
53173
53151
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
53174
53152
|
}
|
|
53175
53153
|
});
|
|
@@ -53177,12 +53155,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53177
53155
|
enterProtocolV2BootloaderMode() {
|
|
53178
53156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53179
53157
|
if (this.isProtocolV2RomloaderMode()) {
|
|
53180
|
-
Log$
|
|
53158
|
+
Log$6.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
53181
53159
|
this.protocolV2ExecutionInLoader = true;
|
|
53182
53160
|
return false;
|
|
53183
53161
|
}
|
|
53184
53162
|
if (this.isProtocolV2BootloaderMode()) {
|
|
53185
|
-
Log$
|
|
53163
|
+
Log$6.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
53186
53164
|
this.protocolV2ExecutionInLoader = true;
|
|
53187
53165
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.GoToBootloaderSuccess);
|
|
53188
53166
|
return false;
|
|
@@ -53218,7 +53196,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53218
53196
|
}
|
|
53219
53197
|
shouldReconnect = true;
|
|
53220
53198
|
lastError = error;
|
|
53221
|
-
Log$
|
|
53199
|
+
Log$6.log('Protocol V2 bootloader mode not ready, polling reconnect: ', error);
|
|
53222
53200
|
}
|
|
53223
53201
|
yield hdShared.wait(retryInterval);
|
|
53224
53202
|
}
|
|
@@ -53315,7 +53293,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53315
53293
|
for (const resource of resourceSources) {
|
|
53316
53294
|
const requiresFreshStaging = isProtocolV2BootResourcePackagePath(resource.devicePath);
|
|
53317
53295
|
if (!requiresFreshStaging && (yield this.isProtocolV2ResourceBundleUpToDate(resource))) {
|
|
53318
|
-
Log$
|
|
53296
|
+
Log$6.log(`[FirmwareUpdateV4] skip RESC bundle ${resource.name}; already up to date`);
|
|
53319
53297
|
}
|
|
53320
53298
|
else {
|
|
53321
53299
|
resourcesToSync.push(resource);
|
|
@@ -53430,7 +53408,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53430
53408
|
}
|
|
53431
53409
|
assertProtocolV2TargetStatus(statusTargets, expectedTargetIds, expectedPaths = new Map()) {
|
|
53432
53410
|
var _a, _b, _c;
|
|
53433
|
-
Log$
|
|
53411
|
+
Log$6.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateStatus records=${JSON.stringify(statusTargets)}`);
|
|
53434
53412
|
const failedTarget = statusTargets.find(target => {
|
|
53435
53413
|
var _a;
|
|
53436
53414
|
return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1) &&
|
|
@@ -53443,7 +53421,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53443
53421
|
payloadVersion: failedTarget.payload_version,
|
|
53444
53422
|
path: failedTarget.path,
|
|
53445
53423
|
});
|
|
53446
|
-
Log$
|
|
53424
|
+
Log$6.error(`[FirmwareUpdateV4] firmware install failed target=${failedTargetDetails}`);
|
|
53447
53425
|
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
53426
|
}
|
|
53449
53427
|
const matchingTargets = statusTargets.filter(target => { var _a; return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1); });
|
|
@@ -53618,7 +53596,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53618
53596
|
if (isNormalMode &&
|
|
53619
53597
|
(installEvidenceObserved ||
|
|
53620
53598
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53621
|
-
Log$
|
|
53599
|
+
Log$6.log('[FirmwareUpdateV4] empty firmware status after confirmed App reboot; update complete');
|
|
53622
53600
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53623
53601
|
return;
|
|
53624
53602
|
}
|
|
@@ -53666,7 +53644,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53666
53644
|
if (isNormalMode &&
|
|
53667
53645
|
(installEvidenceObserved ||
|
|
53668
53646
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53669
|
-
Log$
|
|
53647
|
+
Log$6.log('[FirmwareUpdateV4] firmware status endpoint unavailable after confirmed App reboot');
|
|
53670
53648
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53671
53649
|
return;
|
|
53672
53650
|
}
|
|
@@ -53688,7 +53666,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53688
53666
|
shouldReconnect = true;
|
|
53689
53667
|
deviceInfo = undefined;
|
|
53690
53668
|
lastError = error;
|
|
53691
|
-
Log$
|
|
53669
|
+
Log$6.log('[FirmwareUpdateV4] DeviceFirmwareUpdateStatusGet unavailable during install: ', error);
|
|
53692
53670
|
}
|
|
53693
53671
|
}
|
|
53694
53672
|
}
|
|
@@ -53707,7 +53685,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53707
53685
|
shouldReconnect = true;
|
|
53708
53686
|
deviceInfo = undefined;
|
|
53709
53687
|
resetMissingTargetStatusGrace();
|
|
53710
|
-
Log$
|
|
53688
|
+
Log$6.log('Protocol V2 firmware install device readiness probe failed: ', error);
|
|
53711
53689
|
}
|
|
53712
53690
|
yield hdShared.wait(1000);
|
|
53713
53691
|
}
|
|
@@ -53720,12 +53698,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53720
53698
|
const deviceInfo = yield this.verifyProtocolV2ReconnectIdentity();
|
|
53721
53699
|
try {
|
|
53722
53700
|
if (yield this.probeProtocolV2NormalMode(deviceInfo)) {
|
|
53723
|
-
Log$
|
|
53701
|
+
Log$6.log('[FirmwareUpdateV4] device already returned to App mode; skip Normal reboot');
|
|
53724
53702
|
return;
|
|
53725
53703
|
}
|
|
53726
53704
|
}
|
|
53727
53705
|
catch (error) {
|
|
53728
|
-
Log$
|
|
53706
|
+
Log$6.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
53729
53707
|
}
|
|
53730
53708
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
53731
53709
|
this.protocolV2ExecutionInLoader = false;
|
|
@@ -53753,7 +53731,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53753
53731
|
const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
|
|
53754
53732
|
this.protocolV2LatestFinalFeatures = features;
|
|
53755
53733
|
if (firmwareVersion === '0.0.0') {
|
|
53756
|
-
Log$
|
|
53734
|
+
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
53735
|
}
|
|
53758
53736
|
return {
|
|
53759
53737
|
bootloaderVersion,
|
|
@@ -53802,7 +53780,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53802
53780
|
}
|
|
53803
53781
|
shouldReconnect = true;
|
|
53804
53782
|
lastError = error;
|
|
53805
|
-
Log$
|
|
53783
|
+
Log$6.log('Protocol V2 normal mode not ready, polling Ping: ', error);
|
|
53806
53784
|
}
|
|
53807
53785
|
yield hdShared.wait(1000);
|
|
53808
53786
|
}
|
|
@@ -53846,7 +53824,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53846
53824
|
if (!reconnectDevice) {
|
|
53847
53825
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
|
|
53848
53826
|
}
|
|
53849
|
-
Log$
|
|
53827
|
+
Log$6.debug('Protocol V2 firmware reconnect using matched device:', reconnectDevice.getConnectId());
|
|
53850
53828
|
this.device.updateFromCache(reconnectDevice);
|
|
53851
53829
|
yield this.ensureProtocolV2DeviceAcquired();
|
|
53852
53830
|
this.device.commands.disposed = false;
|
|
@@ -53952,7 +53930,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53952
53930
|
}
|
|
53953
53931
|
}
|
|
53954
53932
|
|
|
53955
|
-
const Log$
|
|
53933
|
+
const Log$5 = getLogger(exports.LoggerNames.Method);
|
|
53956
53934
|
class PromptWebDeviceAccess extends BaseMethod {
|
|
53957
53935
|
init() {
|
|
53958
53936
|
this.useDevice = false;
|
|
@@ -54007,7 +53985,7 @@ class PromptWebDeviceAccess extends BaseMethod {
|
|
|
54007
53985
|
return { device: null };
|
|
54008
53986
|
}
|
|
54009
53987
|
catch (error) {
|
|
54010
|
-
Log$
|
|
53988
|
+
Log$5.debug(error);
|
|
54011
53989
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
|
|
54012
53990
|
}
|
|
54013
53991
|
});
|
|
@@ -54110,7 +54088,7 @@ function decodeJpegBase64ToRgba({ jpegBase64, parameterName, expectedWidth, expe
|
|
|
54110
54088
|
return decoded;
|
|
54111
54089
|
}
|
|
54112
54090
|
|
|
54113
|
-
const Log$
|
|
54091
|
+
const Log$4 = getLogger(exports.LoggerNames.Core);
|
|
54114
54092
|
const MIN_FILE_CHUNK_SIZE = 64;
|
|
54115
54093
|
const FILE_TRANSFER_RATE_WINDOW_MS = 1000;
|
|
54116
54094
|
const FILE_TRANSFER_LOG_INTERVAL_MS = 10000;
|
|
@@ -54131,7 +54109,7 @@ function logFileTransferMetrics({ transport, status, path, transferredBytes, tot
|
|
|
54131
54109
|
const segmentedMetrics = measuredAttempts > 0
|
|
54132
54110
|
? ` hostWriteTotal=${(hostWriteElapsedMs / 1000).toFixed(2)}s responseWaitTotal=${(responseWaitElapsedMs / 1000).toFixed(2)}s measuredAttempts=${measuredAttempts}`
|
|
54133
54111
|
: '';
|
|
54134
|
-
Log$
|
|
54112
|
+
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
54113
|
}
|
|
54136
54114
|
function isProtocolV2ResponseTimeout(error) {
|
|
54137
54115
|
var _a, _b;
|
|
@@ -54222,7 +54200,7 @@ function writeProtocolV2File(options) {
|
|
|
54222
54200
|
let responseWaitElapsedMs = 0;
|
|
54223
54201
|
let measuredAttempts = 0;
|
|
54224
54202
|
const transport = getFileTransferTransport();
|
|
54225
|
-
Log$
|
|
54203
|
+
Log$4.log(`[FileWrite] started transport=${transport} path=${options.path} bytes=${dataLength} offset=${startOffset} chunk=${chunkSize}`);
|
|
54226
54204
|
try {
|
|
54227
54205
|
while (written < dataLength) {
|
|
54228
54206
|
(_c = options.throwIfAborted) === null || _c === void 0 ? void 0 : _c.call(options);
|
|
@@ -54389,7 +54367,6 @@ const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
|
|
|
54389
54367
|
const DEVICE_SETTINGS_SET_MESSAGE_TYPE = 60412;
|
|
54390
54368
|
const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE$2 = 60805;
|
|
54391
54369
|
const FILESYSTEM_DIR_MAKE_MESSAGE_TYPE = 60809;
|
|
54392
|
-
const Log$4 = getLogger(exports.LoggerNames.Method);
|
|
54393
54370
|
function normalizeFileName(fileName, data) {
|
|
54394
54371
|
if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
|
|
54395
54372
|
throw invalidParameter$1('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
|
|
@@ -54497,14 +54474,6 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
54497
54474
|
const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
|
|
54498
54475
|
settings: { wallpaper_path: this.path },
|
|
54499
54476
|
});
|
|
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
54477
|
return {
|
|
54509
54478
|
path: this.path,
|
|
54510
54479
|
size: encoded.data.byteLength,
|
|
@@ -65026,7 +64995,6 @@ const createUiProgressMessageFilter = (intervalMs = DEFAULT_UI_PROGRESS_INTERVAL
|
|
|
65026
64995
|
|
|
65027
64996
|
const Log = getLogger(exports.LoggerNames.Core);
|
|
65028
64997
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
65029
|
-
const PRE_PENDING_CALL_TIMEOUT_MS = 15 * 1000;
|
|
65030
64998
|
const preWarmInflight = new Map();
|
|
65031
64999
|
const preWarmDoneAt = new Map();
|
|
65032
65000
|
function hasDeriveCardano(method) {
|
|
@@ -65182,40 +65150,29 @@ const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void
|
|
|
65182
65150
|
}
|
|
65183
65151
|
}
|
|
65184
65152
|
});
|
|
65185
|
-
const
|
|
65186
|
-
const
|
|
65153
|
+
const waitWithTimeout = (promise, timeout) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65154
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
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();
|
|
65187
65161
|
if (pendingPromise) {
|
|
65188
65162
|
Log.debug('pre pending call promise before call method, wait for it');
|
|
65189
|
-
let timer;
|
|
65190
|
-
let timedOut = false;
|
|
65191
65163
|
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
|
-
]);
|
|
65164
|
+
yield waitWithTimeout(pendingPromise, 5 * 1000);
|
|
65201
65165
|
}
|
|
65202
65166
|
catch (error) {
|
|
65203
65167
|
}
|
|
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
|
-
}
|
|
65168
|
+
removePrePendingCallPromise === null || removePrePendingCallPromise === void 0 ? void 0 : removePrePendingCallPromise(pendingPromise);
|
|
65212
65169
|
Log.debug('pre pending call promise before call method done');
|
|
65213
65170
|
}
|
|
65214
65171
|
});
|
|
65215
65172
|
const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65216
|
-
var _d, _e, _f, _g, _h
|
|
65173
|
+
var _d, _e, _f, _g, _h;
|
|
65217
65174
|
let messageResponse;
|
|
65218
|
-
const { requestQueue, getPrePendingCallPromise,
|
|
65175
|
+
const { requestQueue, getPrePendingCallPromise, setPrePendingCallPromise } = context;
|
|
65219
65176
|
updateMethodRequestContext(method, { status: 'running' });
|
|
65220
65177
|
const normalizePassphraseState = (s) => s || '';
|
|
65221
65178
|
const connectStateChange = normalizePassphraseState(preConnectCache.passphraseState) !==
|
|
@@ -65230,7 +65187,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65230
65187
|
if (method.connectId) {
|
|
65231
65188
|
yield context.waitForCallbackTasks(method.connectId);
|
|
65232
65189
|
}
|
|
65233
|
-
yield waitForPendingPromise(
|
|
65190
|
+
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
65234
65191
|
const task = requestQueue.createTask(method);
|
|
65235
65192
|
let preWarmCallbackTask;
|
|
65236
65193
|
if (method.isPreWarmSignal && method.connectId) {
|
|
@@ -65239,9 +65196,9 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65239
65196
|
}
|
|
65240
65197
|
let device;
|
|
65241
65198
|
try {
|
|
65242
|
-
const connectId = (
|
|
65199
|
+
const connectId = (_d = method.connectId) !== null && _d !== void 0 ? _d : '';
|
|
65243
65200
|
const pollingId = pollingManager.start(connectId);
|
|
65244
|
-
device = yield ensureConnected(context, method, connectId, pollingId, (
|
|
65201
|
+
device = yield ensureConnected(context, method, connectId, pollingId, (_e = task.abortController) === null || _e === void 0 ? void 0 : _e.signal);
|
|
65245
65202
|
}
|
|
65246
65203
|
catch (e) {
|
|
65247
65204
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
@@ -65256,17 +65213,17 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65256
65213
|
requestQueue.releaseTask(method.responseID);
|
|
65257
65214
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
65258
65215
|
}
|
|
65259
|
-
if ((
|
|
65216
|
+
if ((_f = method.payload) === null || _f === void 0 ? void 0 : _f.onlyConnectBleDevice) {
|
|
65260
65217
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
65261
65218
|
Log.debug('Call API - only connect ble device: ', device === null || device === void 0 ? void 0 : device.mainId);
|
|
65262
65219
|
return createResponseMessage(method.responseID, true, null);
|
|
65263
65220
|
}
|
|
65264
65221
|
Log.debug('Call API - setDevice: ', device.mainId);
|
|
65265
|
-
(
|
|
65222
|
+
(_g = method.setDevice) === null || _g === void 0 ? void 0 : _g.call(method, device);
|
|
65266
65223
|
method.context = context;
|
|
65267
65224
|
updateMethodRequestContext(method, {
|
|
65268
65225
|
deviceInstanceId: device.instanceId,
|
|
65269
|
-
commandsInstanceId: (
|
|
65226
|
+
commandsInstanceId: (_h = device.commands) === null || _h === void 0 ? void 0 : _h.instanceId,
|
|
65270
65227
|
});
|
|
65271
65228
|
const activeRequests = getActiveRequestsByDeviceInstance(device.instanceId);
|
|
65272
65229
|
if (activeRequests.length > 0) {
|
|
@@ -65295,14 +65252,14 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65295
65252
|
if (method.connectId) {
|
|
65296
65253
|
yield context.waitForCallbackTasks(method.connectId, preWarmCallbackTask);
|
|
65297
65254
|
}
|
|
65298
|
-
yield waitForPendingPromise(
|
|
65255
|
+
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
65299
65256
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65300
|
-
var
|
|
65257
|
+
var _j, _k;
|
|
65301
65258
|
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
65302
65259
|
protocolV2Operation = device.isProtocolV2();
|
|
65303
65260
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
65304
|
-
const currentFirmwareVersion = (
|
|
65305
|
-
const currentBleVersion = (
|
|
65261
|
+
const currentFirmwareVersion = (_j = device.getCurrentFirmwareVersionString()) !== null && _j !== void 0 ? _j : '0.0.0';
|
|
65262
|
+
const currentBleVersion = (_k = device.getCurrentBLEFirmwareVersionString()) !== null && _k !== void 0 ? _k : '0.0.0';
|
|
65306
65263
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
65307
65264
|
let newVersionStatus;
|
|
65308
65265
|
if (device.features && !device.isProtocolV2()) {
|
|
@@ -65380,7 +65337,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65380
65337
|
}
|
|
65381
65338
|
},
|
|
65382
65339
|
prepare: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65383
|
-
var
|
|
65340
|
+
var _l, _m, _o, _p, _q;
|
|
65384
65341
|
if (method.deviceId && method.checkDeviceId && !deviceIdCheckedDuringUnlockPreflight) {
|
|
65385
65342
|
const isSameDeviceID = yield checkLiveDeviceId(device, method.deviceId);
|
|
65386
65343
|
if (!isSameDeviceID) {
|
|
@@ -65400,7 +65357,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65400
65357
|
require: support.require,
|
|
65401
65358
|
});
|
|
65402
65359
|
}
|
|
65403
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((
|
|
65360
|
+
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
65361
|
checkPassphraseEnableState(method, device.features);
|
|
65405
65362
|
if (!passphraseStateSafety) {
|
|
65406
65363
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -65418,7 +65375,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65418
65375
|
? e
|
|
65419
65376
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
65420
65377
|
}
|
|
65421
|
-
(
|
|
65378
|
+
(_q = (_p = method.device) === null || _p === void 0 ? void 0 : _p.commands) === null || _q === void 0 ? void 0 : _q.checkDisposed();
|
|
65422
65379
|
}),
|
|
65423
65380
|
});
|
|
65424
65381
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
@@ -65614,13 +65571,6 @@ function isRetryableBleProtocolV2ProbeError(method, error) {
|
|
|
65614
65571
|
message.includes('expected V2') &&
|
|
65615
65572
|
message.includes('did not respond to expected protocol'));
|
|
65616
65573
|
}
|
|
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
65574
|
function connectDeviceForBle(method, device, retryCount = 0) {
|
|
65625
65575
|
var _a;
|
|
65626
65576
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -65655,8 +65605,7 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65655
65605
|
}
|
|
65656
65606
|
}
|
|
65657
65607
|
catch (err) {
|
|
65658
|
-
|
|
65659
|
-
if ((hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) || requiresColdReconnect) &&
|
|
65608
|
+
if (hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) &&
|
|
65660
65609
|
device.mainId &&
|
|
65661
65610
|
device.deviceConnector) {
|
|
65662
65611
|
yield device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
@@ -65664,11 +65613,10 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65664
65613
|
}
|
|
65665
65614
|
if ((err.errorCode === hdShared.HardwareErrorCode.BleTimeoutError ||
|
|
65666
65615
|
err.errorCode === hdShared.HardwareErrorCode.BleConnectedError ||
|
|
65667
|
-
isRetryableBleProtocolV2ProbeError(method, err)
|
|
65668
|
-
requiresColdReconnect) &&
|
|
65616
|
+
isRetryableBleProtocolV2ProbeError(method, err)) &&
|
|
65669
65617
|
retryCount < 6) {
|
|
65670
65618
|
const nextRetry = retryCount + 1;
|
|
65671
|
-
Log.debug(`Bluetooth
|
|
65619
|
+
Log.debug(`Bluetooth connect timeout and will retry, retry count: ${nextRetry}`);
|
|
65672
65620
|
yield wait(3000);
|
|
65673
65621
|
yield connectDeviceForBle(method, device, nextRetry);
|
|
65674
65622
|
}
|
|
@@ -65687,7 +65635,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65687
65635
|
Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
|
|
65688
65636
|
const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65689
65637
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65690
|
-
var
|
|
65638
|
+
var _r;
|
|
65691
65639
|
const abort = () => {
|
|
65692
65640
|
if (abortSignal && abortSignal.aborted) {
|
|
65693
65641
|
if (timer) {
|
|
@@ -65802,7 +65750,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65802
65750
|
clearTimeout(timer);
|
|
65803
65751
|
}
|
|
65804
65752
|
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
65805
|
-
if (DataManager.isBrowserWebUsb(env) && !((
|
|
65753
|
+
if (DataManager.isBrowserWebUsb(env) && !((_r = method.payload) === null || _r === void 0 ? void 0 : _r.skipWebDevicePrompt)) {
|
|
65806
65754
|
postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
|
|
65807
65755
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
|
|
65808
65756
|
}
|
|
@@ -65820,7 +65768,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65820
65768
|
return poll();
|
|
65821
65769
|
});
|
|
65822
65770
|
const cancel = (context, connectId) => {
|
|
65823
|
-
var _a, _b
|
|
65771
|
+
var _a, _b;
|
|
65824
65772
|
const { requestQueue, setPrePendingCallPromise } = context;
|
|
65825
65773
|
if (connectId) {
|
|
65826
65774
|
try {
|
|
@@ -65834,7 +65782,7 @@ const cancel = (context, connectId) => {
|
|
|
65834
65782
|
if (task && ((_a = task.method) === null || _a === void 0 ? void 0 : _a.device)) {
|
|
65835
65783
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65836
65784
|
const { device } = task.method;
|
|
65837
|
-
setPrePendingCallPromise(
|
|
65785
|
+
setPrePendingCallPromise(device === null || device === void 0 ? void 0 : device.interruptionFromUser());
|
|
65838
65786
|
canceledDevices.push(device);
|
|
65839
65787
|
}
|
|
65840
65788
|
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled));
|
|
@@ -65854,7 +65802,7 @@ const cancel = (context, connectId) => {
|
|
|
65854
65802
|
for (const requestId of requestQueue.getRequestTasksId()) {
|
|
65855
65803
|
const task = requestQueue.getTask(requestId);
|
|
65856
65804
|
Log.debug('Cancel Api connect task: ', task);
|
|
65857
|
-
if (task && ((
|
|
65805
|
+
if (task && ((_b = task.method) === null || _b === void 0 ? void 0 : _b.device)) {
|
|
65858
65806
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65859
65807
|
const { device } = task.method;
|
|
65860
65808
|
device === null || device === void 0 ? void 0 : device.interruptionFromUser();
|
|
@@ -66043,7 +65991,6 @@ class Core extends events.exports {
|
|
|
66043
65991
|
constructor() {
|
|
66044
65992
|
super();
|
|
66045
65993
|
this.requestQueue = new RequestQueue();
|
|
66046
|
-
this.prePendingCallPromises = new Map();
|
|
66047
65994
|
this.methodSynchronize = getSynchronize();
|
|
66048
65995
|
this.tracingContext = createSdkTracingContext();
|
|
66049
65996
|
this.sdkInstanceId = this.tracingContext.sdkInstanceId;
|
|
@@ -66055,18 +66002,9 @@ class Core extends events.exports {
|
|
|
66055
66002
|
tracingContext: this.tracingContext,
|
|
66056
66003
|
requestQueue: this.requestQueue,
|
|
66057
66004
|
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
|
-
}
|
|
66005
|
+
getPrePendingCallPromise: () => this.prePendingCallPromise,
|
|
66006
|
+
setPrePendingCallPromise: (promise) => {
|
|
66007
|
+
this.prePendingCallPromise = promise;
|
|
66070
66008
|
},
|
|
66071
66009
|
registerCallbackTask: (connectId, callbackPromise) => {
|
|
66072
66010
|
this.requestQueue.registerPendingCallbackTask(connectId, callbackPromise);
|
|
@@ -66160,7 +66098,7 @@ class Core extends events.exports {
|
|
|
66160
66098
|
preWarmInflight.clear();
|
|
66161
66099
|
preWarmDoneAt.clear();
|
|
66162
66100
|
preConnectCache = { passphraseState: undefined };
|
|
66163
|
-
this.
|
|
66101
|
+
this.prePendingCallPromise = undefined;
|
|
66164
66102
|
this.removeAllListeners();
|
|
66165
66103
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
66166
66104
|
if (_core === this)
|