@onekeyfe/hd-core 1.2.0-alpha.134 → 1.2.0-alpha.135
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 +8 -1
- package/__tests__/device-lifecycle-events.test.ts +95 -2
- package/__tests__/device-settings.test.ts +167 -9
- package/__tests__/device-wallet-session-store.test.ts +21 -79
- package/__tests__/firmware-update/firmware-update-v4-install-poll.test.ts +37 -1
- package/__tests__/protocol-v2-unlock-policy.test.ts +59 -0
- package/__tests__/protocol-v2.test.ts +86 -21
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceVerify.d.ts +1 -0
- package/dist/api/device/DeviceVerify.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +2 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +296 -247
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +25 -68
- package/src/api/device/DeviceChangePin.ts +4 -1
- package/src/api/device/DeviceSettings.ts +2 -16
- package/src/api/device/DeviceVerify.ts +9 -0
- package/src/api/device/DeviceWipe.ts +4 -1
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +11 -0
- package/src/core/index.ts +67 -25
- package/src/device/Device.ts +45 -42
- package/src/device/DeviceCommands.ts +15 -2
package/dist/index.js
CHANGED
|
@@ -2261,7 +2261,7 @@ const createLogMessage = (type, payload) => ({
|
|
|
2261
2261
|
|
|
2262
2262
|
const MAX_ENTRIES = 500;
|
|
2263
2263
|
let postMessage$1;
|
|
2264
|
-
class Log$
|
|
2264
|
+
class Log$n {
|
|
2265
2265
|
constructor(prefix, enabled) {
|
|
2266
2266
|
this.prefix = prefix;
|
|
2267
2267
|
this.enabled = enabled;
|
|
@@ -2313,7 +2313,7 @@ class Log$m {
|
|
|
2313
2313
|
}
|
|
2314
2314
|
const _logs = {};
|
|
2315
2315
|
const initLog = (prefix, enabled) => {
|
|
2316
|
-
const instance = new Log$
|
|
2316
|
+
const instance = new Log$n(prefix, !!enabled);
|
|
2317
2317
|
_logs[prefix] = instance;
|
|
2318
2318
|
return instance;
|
|
2319
2319
|
};
|
|
@@ -2711,7 +2711,7 @@ function patchFeatures(response) {
|
|
|
2711
2711
|
return response;
|
|
2712
2712
|
}
|
|
2713
2713
|
|
|
2714
|
-
const Log$
|
|
2714
|
+
const Log$m = getLogger(exports.LoggerNames.Core);
|
|
2715
2715
|
let globalInstanceCounter = 0;
|
|
2716
2716
|
let sdkInstanceCounter = 0;
|
|
2717
2717
|
function generateSdkInstanceId() {
|
|
@@ -2771,7 +2771,7 @@ function completeRequestContext(responseID, error) {
|
|
|
2771
2771
|
context.status = error ? 'error' : 'success';
|
|
2772
2772
|
if (error) {
|
|
2773
2773
|
context.error = error.message;
|
|
2774
|
-
Log$
|
|
2774
|
+
Log$m.debug(`[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`);
|
|
2775
2775
|
}
|
|
2776
2776
|
globalActiveRequests.delete(responseID);
|
|
2777
2777
|
if (context.sdkInstanceId) {
|
|
@@ -40799,7 +40799,7 @@ function selectProtocolV2ResourceManifestFiles({ manifest, targetsToUpdate, }) {
|
|
|
40799
40799
|
|
|
40800
40800
|
var _a$1;
|
|
40801
40801
|
const FIRMWARE_UPDATE_CONFIG_FRESHNESS_MS = 5 * 60 * 1000;
|
|
40802
|
-
const Log$
|
|
40802
|
+
const Log$l = getLogger(exports.LoggerNames.Core);
|
|
40803
40803
|
const FIRMWARE_FIELDS = [
|
|
40804
40804
|
'firmware',
|
|
40805
40805
|
'firmware-v1',
|
|
@@ -40880,11 +40880,11 @@ class DataManager {
|
|
|
40880
40880
|
const manifestMode = (_b = settings.firmwareManifestMode) !== null && _b !== void 0 ? _b : (settings.fetchConfig ? 'sdk-managed' : undefined);
|
|
40881
40881
|
if (settings.preloadedConfig) {
|
|
40882
40882
|
this.applyRemoteConfig(settings.preloadedConfig);
|
|
40883
|
-
Log$
|
|
40883
|
+
Log$l.log('[DataConfig] Preloaded firmware config loaded');
|
|
40884
40884
|
return true;
|
|
40885
40885
|
}
|
|
40886
40886
|
if (manifestMode === 'external-only') {
|
|
40887
|
-
Log$
|
|
40887
|
+
Log$l.warn('[DataConfig] External firmware config is unavailable; SDK-managed networking remains disabled');
|
|
40888
40888
|
return false;
|
|
40889
40889
|
}
|
|
40890
40890
|
if (manifestMode !== 'sdk-managed') {
|
|
@@ -40897,7 +40897,7 @@ class DataManager {
|
|
|
40897
40897
|
let data = null;
|
|
40898
40898
|
let fetchMethod = 'none';
|
|
40899
40899
|
if (settings.configFetcher) {
|
|
40900
|
-
Log$
|
|
40900
|
+
Log$l.debug('[DataConfig] Trying client configFetcher...');
|
|
40901
40901
|
try {
|
|
40902
40902
|
data = yield settings.configFetcher(urlWithCache);
|
|
40903
40903
|
if (data) {
|
|
@@ -40905,40 +40905,40 @@ class DataManager {
|
|
|
40905
40905
|
}
|
|
40906
40906
|
}
|
|
40907
40907
|
catch (e) {
|
|
40908
|
-
Log$
|
|
40908
|
+
Log$l.warn('[DataConfig] Client configFetcher failed:', e);
|
|
40909
40909
|
}
|
|
40910
40910
|
}
|
|
40911
40911
|
if (!data) {
|
|
40912
|
-
Log$
|
|
40912
|
+
Log$l.debug('[DataConfig] Trying SDK-managed config request...');
|
|
40913
40913
|
try {
|
|
40914
40914
|
const response = yield axios__default["default"].get(urlWithCache, {
|
|
40915
40915
|
timeout: 7000,
|
|
40916
40916
|
});
|
|
40917
40917
|
data = response.data;
|
|
40918
40918
|
fetchMethod = 'axios';
|
|
40919
|
-
Log$
|
|
40919
|
+
Log$l.log('[DataConfig] SDK-managed config request succeeded');
|
|
40920
40920
|
}
|
|
40921
40921
|
catch (e) {
|
|
40922
|
-
Log$
|
|
40922
|
+
Log$l.warn('[DataConfig] SDK-managed config request failed:', e);
|
|
40923
40923
|
}
|
|
40924
40924
|
}
|
|
40925
40925
|
if (data) {
|
|
40926
40926
|
this.applyRemoteConfig(data);
|
|
40927
|
-
Log$
|
|
40927
|
+
Log$l.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
|
|
40928
40928
|
return true;
|
|
40929
40929
|
}
|
|
40930
|
-
Log$
|
|
40930
|
+
Log$l.warn('[DataConfig] All fetch methods failed, using built-in default config');
|
|
40931
40931
|
return false;
|
|
40932
40932
|
});
|
|
40933
40933
|
}
|
|
40934
40934
|
static applyRemoteConfig(data) {
|
|
40935
40935
|
const pro2Config = this.enrichProtocolV2FirmwareReleaseInfo(data.pro2, error => {
|
|
40936
40936
|
this.protocolV2ResourcesConfigError = error;
|
|
40937
|
-
Log$
|
|
40937
|
+
Log$l.warn('[DataConfig] Ignoring invalid Pro2 release resources config:', error);
|
|
40938
40938
|
});
|
|
40939
40939
|
const neoConfig = this.enrichProtocolV2FirmwareReleaseInfo(data.neo, error => {
|
|
40940
40940
|
this.protocolV2NeoResourcesConfigError = error;
|
|
40941
|
-
Log$
|
|
40941
|
+
Log$l.warn('[DataConfig] Ignoring invalid Neo release resources config:', error);
|
|
40942
40942
|
});
|
|
40943
40943
|
this.deviceMap = {
|
|
40944
40944
|
[hdShared.EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
@@ -43108,7 +43108,7 @@ const getDefectiveDeviceInfo = (features) => {
|
|
|
43108
43108
|
};
|
|
43109
43109
|
};
|
|
43110
43110
|
|
|
43111
|
-
const Log$
|
|
43111
|
+
const Log$k = getLogger(exports.LoggerNames.DevicePool);
|
|
43112
43112
|
const canPathIdentifyDevice = (path) => !!path && !/^0+$/.test(path);
|
|
43113
43113
|
const getDiff = (current, descriptors) => {
|
|
43114
43114
|
const connected = descriptors.filter(d => current.find(x => x.path === d.path) === undefined);
|
|
@@ -43170,7 +43170,7 @@ class DevicePool extends events.exports {
|
|
|
43170
43170
|
yield this._checkDevicePool(initOptions, connectId);
|
|
43171
43171
|
return { devices, deviceList };
|
|
43172
43172
|
}
|
|
43173
|
-
Log$
|
|
43173
|
+
Log$k.debug('found device in cache, but path is different: ', connectId);
|
|
43174
43174
|
}
|
|
43175
43175
|
}
|
|
43176
43176
|
const matchedDescriptor = connectId
|
|
@@ -43273,7 +43273,7 @@ class DevicePool extends events.exports {
|
|
|
43273
43273
|
});
|
|
43274
43274
|
}
|
|
43275
43275
|
catch (error) {
|
|
43276
|
-
Log$
|
|
43276
|
+
Log$k.debug('Unable to refresh Protocol V2 device label during discovery', error);
|
|
43277
43277
|
}
|
|
43278
43278
|
});
|
|
43279
43279
|
}
|
|
@@ -43289,7 +43289,7 @@ class DevicePool extends events.exports {
|
|
|
43289
43289
|
const descriptor = this.connectedPool[i];
|
|
43290
43290
|
if (!connectId || descriptor.path === connectId) {
|
|
43291
43291
|
const device = yield this._createDevice(descriptor, initOptions);
|
|
43292
|
-
Log$
|
|
43292
|
+
Log$k.debug('emit DEVICE.CONNECT: ', device === null || device === void 0 ? void 0 : device.features);
|
|
43293
43293
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
43294
43294
|
this.connectedPool.splice(i, 1);
|
|
43295
43295
|
}
|
|
@@ -43311,9 +43311,9 @@ class DevicePool extends events.exports {
|
|
|
43311
43311
|
const diff = getDiff(this.current || [], upcoming);
|
|
43312
43312
|
this.upcoming = upcoming;
|
|
43313
43313
|
this.current = this.upcoming;
|
|
43314
|
-
Log$
|
|
43315
|
-
Log$
|
|
43316
|
-
Log$
|
|
43314
|
+
Log$k.debug('device pool -> current: ', this.current);
|
|
43315
|
+
Log$k.debug('device pool -> upcomming: ', this.upcoming);
|
|
43316
|
+
Log$k.debug('DeviceCache.reportDeviceChange diff: ', diff);
|
|
43317
43317
|
if (!diff.didUpdate) {
|
|
43318
43318
|
return;
|
|
43319
43319
|
}
|
|
@@ -43323,7 +43323,7 @@ class DevicePool extends events.exports {
|
|
|
43323
43323
|
this._addConnectedDeviceToPool(d);
|
|
43324
43324
|
return;
|
|
43325
43325
|
}
|
|
43326
|
-
Log$
|
|
43326
|
+
Log$k.debug('emit DEVICE.CONNECT: ', device.features);
|
|
43327
43327
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
43328
43328
|
});
|
|
43329
43329
|
diff.disconnected.forEach(d => {
|
|
@@ -43333,7 +43333,7 @@ class DevicePool extends events.exports {
|
|
|
43333
43333
|
this._addDisconnectedDeviceToPool(d);
|
|
43334
43334
|
return;
|
|
43335
43335
|
}
|
|
43336
|
-
Log$
|
|
43336
|
+
Log$k.debug('emit DEVICE.DISCONNECT: ', device.features);
|
|
43337
43337
|
device.markTransportDisconnected();
|
|
43338
43338
|
this.emitter.emit(DEVICE.DISCONNECT, device);
|
|
43339
43339
|
});
|
|
@@ -43371,7 +43371,7 @@ class DevicePool extends events.exports {
|
|
|
43371
43371
|
this.connectedPool = [];
|
|
43372
43372
|
this.disconnectPool = [];
|
|
43373
43373
|
this.devicesCache = {};
|
|
43374
|
-
Log$
|
|
43374
|
+
Log$k.debug('DevicePool state has been reset');
|
|
43375
43375
|
}
|
|
43376
43376
|
static dispose() {
|
|
43377
43377
|
this.resetState();
|
|
@@ -43385,7 +43385,7 @@ DevicePool.disconnectPool = [];
|
|
|
43385
43385
|
DevicePool.devicesCache = {};
|
|
43386
43386
|
DevicePool.emitter = new events.exports();
|
|
43387
43387
|
|
|
43388
|
-
const Log$
|
|
43388
|
+
const Log$j = getLogger(exports.LoggerNames.Transport);
|
|
43389
43389
|
const BleLogger = getLogger(exports.LoggerNames.HdBleTransport);
|
|
43390
43390
|
const HttpLogger = getLogger(exports.LoggerNames.HdTransportHttp);
|
|
43391
43391
|
const LowLevelLogger = getLogger(exports.LoggerNames.HdTransportLowLevel);
|
|
@@ -43395,7 +43395,7 @@ const WebUsbLogger = getLogger(exports.LoggerNames.HdTransportWebUsb);
|
|
|
43395
43395
|
const REACT_NATIVE_BLE_SCAN_TIMEOUT_MS = 3000;
|
|
43396
43396
|
class TransportManager {
|
|
43397
43397
|
static load() {
|
|
43398
|
-
Log$
|
|
43398
|
+
Log$j.debug('transport manager load');
|
|
43399
43399
|
this.defaultMessages = DataManager.getProtobufMessages();
|
|
43400
43400
|
this.currentMessages = this.defaultMessages;
|
|
43401
43401
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
@@ -43404,14 +43404,14 @@ class TransportManager {
|
|
|
43404
43404
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43405
43405
|
try {
|
|
43406
43406
|
const env = DataManager.getSettings('env');
|
|
43407
|
-
Log$
|
|
43407
|
+
Log$j.debug('Initializing transports', env);
|
|
43408
43408
|
if (env === 'react-native') {
|
|
43409
43409
|
if (!this.reactNativeInit) {
|
|
43410
43410
|
yield this.transport.init(BleLogger, DevicePool.emitter);
|
|
43411
43411
|
this.reactNativeInit = true;
|
|
43412
43412
|
}
|
|
43413
43413
|
else {
|
|
43414
|
-
Log$
|
|
43414
|
+
Log$j.debug('React Native Do Not Initializing transports');
|
|
43415
43415
|
}
|
|
43416
43416
|
}
|
|
43417
43417
|
else if (env === 'node-usb') {
|
|
@@ -43432,15 +43432,15 @@ class TransportManager {
|
|
|
43432
43432
|
else {
|
|
43433
43433
|
yield this.transport.init(HttpLogger);
|
|
43434
43434
|
}
|
|
43435
|
-
Log$
|
|
43435
|
+
Log$j.debug('Configuring transports');
|
|
43436
43436
|
yield this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
43437
43437
|
this.currentMessages = this.defaultMessages;
|
|
43438
43438
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
43439
43439
|
yield this.configureProtocolV2Messages();
|
|
43440
|
-
Log$
|
|
43440
|
+
Log$j.debug('Configuring transports done');
|
|
43441
43441
|
}
|
|
43442
43442
|
catch (error) {
|
|
43443
|
-
Log$
|
|
43443
|
+
Log$j.debug('Initializing transports error: ', error);
|
|
43444
43444
|
if (error.code === 'ECONNABORTED') {
|
|
43445
43445
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError);
|
|
43446
43446
|
}
|
|
@@ -43456,7 +43456,7 @@ class TransportManager {
|
|
|
43456
43456
|
if (this.currentMessages === messages || !messages) {
|
|
43457
43457
|
return;
|
|
43458
43458
|
}
|
|
43459
|
-
Log$
|
|
43459
|
+
Log$j.debug(`Reconfiguring transports Protocol V1 schema:${protocolV1MessageSchema}`);
|
|
43460
43460
|
try {
|
|
43461
43461
|
yield this.transport.configure(JSON.stringify(messages));
|
|
43462
43462
|
this.currentMessages = messages;
|
|
@@ -43482,9 +43482,9 @@ class TransportManager {
|
|
|
43482
43482
|
}
|
|
43483
43483
|
if (plugin) {
|
|
43484
43484
|
this.plugin = plugin;
|
|
43485
|
-
Log$
|
|
43485
|
+
Log$j.debug('set transport plugin: ', this.plugin);
|
|
43486
43486
|
}
|
|
43487
|
-
Log$
|
|
43487
|
+
Log$j.debug('set transport: ', this.transport.name, this.transport.version, this.transport.configured);
|
|
43488
43488
|
}
|
|
43489
43489
|
static getTransport() {
|
|
43490
43490
|
return this.transport;
|
|
@@ -43495,7 +43495,7 @@ class TransportManager {
|
|
|
43495
43495
|
const { configureProtocolV2 } = this.transport;
|
|
43496
43496
|
if (protocolV2Messages && typeof configureProtocolV2 === 'function') {
|
|
43497
43497
|
yield configureProtocolV2.call(this.transport, JSON.stringify(protocolV2Messages));
|
|
43498
|
-
Log$
|
|
43498
|
+
Log$j.debug('Protocol V2 messages configured');
|
|
43499
43499
|
}
|
|
43500
43500
|
});
|
|
43501
43501
|
}
|
|
@@ -43538,7 +43538,7 @@ const DEVICE_CONTROL_CALLS = new Set([
|
|
|
43538
43538
|
'DeviceCertificateSign',
|
|
43539
43539
|
'DeviceMiscUsbMscControl',
|
|
43540
43540
|
]);
|
|
43541
|
-
const isProtocolV2ActionCancelledMessage = (message) => /^(?:cancel(?:led|ed)(?: on device)?|confirm dismissed|user cancel(?:led|ed)(?:\s+.*)?)$/i.test(message);
|
|
43541
|
+
const isProtocolV2ActionCancelledMessage = (message) => /^(?:cancel(?:led|ed)(?: on device)?|confirm dismissed|update cancel(?:led|ed)|user cancel(?:led|ed)(?:\s+.*)?)$/i.test(message);
|
|
43542
43542
|
function shouldReduceDebugForCall(type) {
|
|
43543
43543
|
return HIGH_VOLUME_DEBUG_CALLS.has(type);
|
|
43544
43544
|
}
|
|
@@ -43617,7 +43617,7 @@ const cancelDeviceWithInitialize = (device) => {
|
|
|
43617
43617
|
},
|
|
43618
43618
|
}));
|
|
43619
43619
|
};
|
|
43620
|
-
const Log$
|
|
43620
|
+
const Log$i = getLogger(exports.LoggerNames.DeviceCommands);
|
|
43621
43621
|
const LogCore = getLogger(exports.LoggerNames.Core);
|
|
43622
43622
|
class DeviceCommands {
|
|
43623
43623
|
constructor(device, mainId) {
|
|
@@ -43626,7 +43626,7 @@ class DeviceCommands {
|
|
|
43626
43626
|
this.transport = TransportManager.getTransport();
|
|
43627
43627
|
this.disposed = false;
|
|
43628
43628
|
this.instanceId = generateInstanceId('DeviceCommands', device.sdkInstanceId);
|
|
43629
|
-
Log$
|
|
43629
|
+
Log$i.debug(`[DeviceCommands] Created: ${this.instanceId}, device: ${this.device.instanceId}`);
|
|
43630
43630
|
}
|
|
43631
43631
|
dispose(_cancelRequest) {
|
|
43632
43632
|
var _a, _b;
|
|
@@ -43679,6 +43679,7 @@ class DeviceCommands {
|
|
|
43679
43679
|
}
|
|
43680
43680
|
const activeCall = this.callPromise;
|
|
43681
43681
|
let timer;
|
|
43682
|
+
let timedOut = false;
|
|
43682
43683
|
const cancellation = (() => __awaiter(this, void 0, void 0, function* () {
|
|
43683
43684
|
yield this.dispose(true);
|
|
43684
43685
|
yield (activeCall === null || activeCall === void 0 ? void 0 : activeCall.catch(() => undefined));
|
|
@@ -43687,13 +43688,23 @@ class DeviceCommands {
|
|
|
43687
43688
|
yield Promise.race([
|
|
43688
43689
|
cancellation,
|
|
43689
43690
|
new Promise(resolve => {
|
|
43690
|
-
timer = setTimeout(
|
|
43691
|
+
timer = setTimeout(() => {
|
|
43692
|
+
timedOut = true;
|
|
43693
|
+
resolve();
|
|
43694
|
+
}, 10 * 1000);
|
|
43691
43695
|
}),
|
|
43692
43696
|
]);
|
|
43693
43697
|
}
|
|
43694
43698
|
finally {
|
|
43695
43699
|
if (timer)
|
|
43696
43700
|
clearTimeout(timer);
|
|
43701
|
+
if (timedOut &&
|
|
43702
|
+
this.transport.name === 'ReactNativeBleTransport' &&
|
|
43703
|
+
this.transport.disconnect) {
|
|
43704
|
+
yield this.transport.disconnect(this.mainId).catch(error => {
|
|
43705
|
+
Log$i.debug('BLE cancellation timeout disconnect error (ignored)', error);
|
|
43706
|
+
});
|
|
43707
|
+
}
|
|
43697
43708
|
if (this.callPromise === activeCall) {
|
|
43698
43709
|
this.callPromise = undefined;
|
|
43699
43710
|
}
|
|
@@ -43706,7 +43717,7 @@ class DeviceCommands {
|
|
|
43706
43717
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43707
43718
|
const shouldReduceDebug = shouldReduceDebugForCall(type);
|
|
43708
43719
|
if (!shouldReduceDebug) {
|
|
43709
|
-
Log$
|
|
43720
|
+
Log$i.debug('[DeviceCommands] [call] Sending', type, hdTransport.getSafeTransportLogPayload(msg !== null && msg !== void 0 ? msg : {}, type));
|
|
43710
43721
|
}
|
|
43711
43722
|
try {
|
|
43712
43723
|
const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
|
|
@@ -43765,10 +43776,10 @@ class DeviceCommands {
|
|
|
43765
43776
|
assertType(response, resType);
|
|
43766
43777
|
}
|
|
43767
43778
|
catch (error) {
|
|
43768
|
-
Log$
|
|
43779
|
+
Log$i.debug('DeviceCommands typedcall error: ', error);
|
|
43769
43780
|
if (error instanceof hdShared.HardwareError) {
|
|
43770
43781
|
if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
43771
|
-
Log$
|
|
43782
|
+
Log$i.debug('[DeviceCommands] [typedCall] Unexpected response type', {
|
|
43772
43783
|
request: type,
|
|
43773
43784
|
expected: resType,
|
|
43774
43785
|
received: response.type,
|
|
@@ -43802,7 +43813,7 @@ class DeviceCommands {
|
|
|
43802
43813
|
var _a;
|
|
43803
43814
|
try {
|
|
43804
43815
|
if (!shouldReduceDebugForCall(callType)) {
|
|
43805
|
-
Log$
|
|
43816
|
+
Log$i.debug('_filterCommonTypes: ', {
|
|
43806
43817
|
request: callType,
|
|
43807
43818
|
response: {
|
|
43808
43819
|
type: res.type,
|
|
@@ -44022,7 +44033,7 @@ class DeviceCommands {
|
|
|
44022
44033
|
reject(error);
|
|
44023
44034
|
});
|
|
44024
44035
|
const listenerCount = this.device.listenerCount(DEVICE.PIN);
|
|
44025
|
-
Log$
|
|
44036
|
+
Log$i.debug(`[${this.instanceId}] _promptPin called`, {
|
|
44026
44037
|
responseID: this.currentResponseID,
|
|
44027
44038
|
deviceInstanceId: this.device.instanceId,
|
|
44028
44039
|
listenerCount,
|
|
@@ -45079,7 +45090,7 @@ const parseRunOptions = (options) => {
|
|
|
45079
45090
|
options = {};
|
|
45080
45091
|
return options;
|
|
45081
45092
|
};
|
|
45082
|
-
const Log$
|
|
45093
|
+
const Log$h = getLogger(exports.LoggerNames.Device);
|
|
45083
45094
|
const isProtocolV2DeviceStatusUnsupportedError = (error) => {
|
|
45084
45095
|
var _a, _b, _c;
|
|
45085
45096
|
if (error instanceof hdShared.HardwareError) {
|
|
@@ -45140,7 +45151,7 @@ class Device extends events.exports {
|
|
|
45140
45151
|
this.sdkInstanceId = sdkInstanceId;
|
|
45141
45152
|
this.instanceId = generateInstanceId('Device', this.sdkInstanceId);
|
|
45142
45153
|
this.createdAt = Date.now();
|
|
45143
|
-
Log$
|
|
45154
|
+
Log$h.debug(`[Device] Created: ${this.instanceId}${this.sdkInstanceId ? ` for SDK: ${this.sdkInstanceId}` : ''}`);
|
|
45144
45155
|
}
|
|
45145
45156
|
static fromDescriptor(originalDescriptor, sdkInstanceId) {
|
|
45146
45157
|
const descriptor = Object.assign({}, originalDescriptor);
|
|
@@ -45231,12 +45242,12 @@ class Device extends events.exports {
|
|
|
45231
45242
|
if (DataManager.isBleConnect(env)) {
|
|
45232
45243
|
acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, strictProtocol, undefined));
|
|
45233
45244
|
this.mainId = (_b = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.uuid) !== null && _b !== void 0 ? _b : '';
|
|
45234
|
-
Log$
|
|
45245
|
+
Log$h.debug('Expected uuid:', this.mainId);
|
|
45235
45246
|
}
|
|
45236
45247
|
else {
|
|
45237
45248
|
acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, strictProtocol, undefined));
|
|
45238
45249
|
this.mainId = acquireResult;
|
|
45239
|
-
Log$
|
|
45250
|
+
Log$h.debug('Expected session id:', this.mainId);
|
|
45240
45251
|
}
|
|
45241
45252
|
const detectedProtocol = (_d = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.protocolType) !== null && _d !== void 0 ? _d : (_f = (_e = TransportManager.transport) === null || _e === void 0 ? void 0 : _e.getProtocolType) === null || _f === void 0 ? void 0 : _f.call(_e, DataManager.isBleConnect(env) ? this.originalDescriptor.id : this.originalDescriptor.path);
|
|
45242
45253
|
if ((options === null || options === void 0 ? void 0 : options.forceProtocolDetection) && !detectedProtocol) {
|
|
@@ -45263,7 +45274,7 @@ class Device extends events.exports {
|
|
|
45263
45274
|
yield ((_j = (_h = this.deviceConnector) === null || _h === void 0 ? void 0 : _h.release) === null || _j === void 0 ? void 0 : _j.call(_h, failedSession, false));
|
|
45264
45275
|
}
|
|
45265
45276
|
catch (releaseError) {
|
|
45266
|
-
Log$
|
|
45277
|
+
Log$h.debug('Failed to release an unsuccessful protocol probe', releaseError);
|
|
45267
45278
|
}
|
|
45268
45279
|
}
|
|
45269
45280
|
if (!DataManager.isBleConnect(env)) {
|
|
@@ -45292,11 +45303,11 @@ class Device extends events.exports {
|
|
|
45292
45303
|
(this.mainId && DataManager.isBleConnect(env))) {
|
|
45293
45304
|
if (this.pendingCallbackPromise) {
|
|
45294
45305
|
try {
|
|
45295
|
-
Log$
|
|
45306
|
+
Log$h.debug('Waiting for callback tasks to complete before releasing device (in release method)');
|
|
45296
45307
|
yield this.pendingCallbackPromise.promise;
|
|
45297
45308
|
}
|
|
45298
45309
|
catch (error) {
|
|
45299
|
-
Log$
|
|
45310
|
+
Log$h.error('Error waiting for callback tasks in release method:', error);
|
|
45300
45311
|
}
|
|
45301
45312
|
}
|
|
45302
45313
|
if (this.commands) {
|
|
@@ -45315,7 +45326,7 @@ class Device extends events.exports {
|
|
|
45315
45326
|
this.updateDescriptor({ session: null });
|
|
45316
45327
|
}
|
|
45317
45328
|
catch (err) {
|
|
45318
|
-
Log$
|
|
45329
|
+
Log$h.error('[Device] release error: ', err);
|
|
45319
45330
|
}
|
|
45320
45331
|
finally {
|
|
45321
45332
|
this.needReloadDevice = true;
|
|
@@ -45520,7 +45531,7 @@ class Device extends events.exports {
|
|
|
45520
45531
|
});
|
|
45521
45532
|
}
|
|
45522
45533
|
getInternalState(_deviceId) {
|
|
45523
|
-
Log$
|
|
45534
|
+
Log$h.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `currentDeviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
45524
45535
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
45525
45536
|
if (!deviceId)
|
|
45526
45537
|
return undefined;
|
|
@@ -45535,7 +45546,7 @@ class Device extends events.exports {
|
|
|
45535
45546
|
return deviceWalletSessionStore.getStandard(deviceId);
|
|
45536
45547
|
}
|
|
45537
45548
|
updateInternalState(enablePassphrase, passphraseState, deviceId, sessionId = null, featuresSessionId = null, walletType = 'hidden') {
|
|
45538
|
-
Log$
|
|
45549
|
+
Log$h.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `hasPassphraseState: ${Boolean(passphraseState)}`, `hasSessionId: ${Boolean(sessionId)}`, `hasFeaturesSessionId: ${Boolean(featuresSessionId)}`);
|
|
45539
45550
|
const cacheDeviceKey = this.getSessionCacheDeviceKey(deviceId);
|
|
45540
45551
|
if (!cacheDeviceKey)
|
|
45541
45552
|
return;
|
|
@@ -45551,7 +45562,7 @@ class Device extends events.exports {
|
|
|
45551
45562
|
deviceWalletSessionStore.deletePending(cacheDeviceKey);
|
|
45552
45563
|
}
|
|
45553
45564
|
setInternalState(state, initSession) {
|
|
45554
|
-
Log$
|
|
45565
|
+
Log$h.debug('setInternalState session param: ', `hasState: ${Boolean(state)}`, `initSession: ${initSession}`, `deviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
45555
45566
|
if (!this.passphraseState && !initSession)
|
|
45556
45567
|
return;
|
|
45557
45568
|
const deviceId = this.getSessionCacheDeviceKey();
|
|
@@ -45565,7 +45576,7 @@ class Device extends events.exports {
|
|
|
45565
45576
|
}
|
|
45566
45577
|
}
|
|
45567
45578
|
clearInternalState(_deviceId) {
|
|
45568
|
-
Log$
|
|
45579
|
+
Log$h.debug('clearInternalState param: ', _deviceId);
|
|
45569
45580
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
45570
45581
|
if (!deviceId)
|
|
45571
45582
|
return;
|
|
@@ -45606,6 +45617,15 @@ class Device extends events.exports {
|
|
|
45606
45617
|
yield TransportManager.reconfigure(this.features);
|
|
45607
45618
|
});
|
|
45608
45619
|
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
|
+
}
|
|
45609
45629
|
this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
|
|
45610
45630
|
if (options === null || options === void 0 ? void 0 : options.initSession) {
|
|
45611
45631
|
this.clearInternalState(options === null || options === void 0 ? void 0 : options.deviceId);
|
|
@@ -45621,33 +45641,17 @@ class Device extends events.exports {
|
|
|
45621
45641
|
if (options === null || options === void 0 ? void 0 : options.deriveCardano) {
|
|
45622
45642
|
payload.derive_cardano = true;
|
|
45623
45643
|
}
|
|
45624
|
-
|
|
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();
|
|
45644
|
+
yield callInitialize(payload, options === null || options === void 0 ? void 0 : options.initSession);
|
|
45641
45645
|
}
|
|
45642
45646
|
catch (error) {
|
|
45643
|
-
Log$
|
|
45647
|
+
Log$h.error('Initialization failed:', error);
|
|
45644
45648
|
throw error;
|
|
45645
45649
|
}
|
|
45646
45650
|
});
|
|
45647
45651
|
}
|
|
45648
45652
|
_initializeProtocolV2(options) {
|
|
45649
45653
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45650
|
-
Log$
|
|
45654
|
+
Log$h.debug('Initialize device via Protocol V2 features adapter');
|
|
45651
45655
|
try {
|
|
45652
45656
|
const deviceInfo = yield requestProtocolV2DeviceInfo({
|
|
45653
45657
|
commands: this.commands,
|
|
@@ -45656,7 +45660,7 @@ class Device extends events.exports {
|
|
|
45656
45660
|
yield this.probeProtocolV2RuntimeState(deviceInfo, options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs);
|
|
45657
45661
|
}
|
|
45658
45662
|
catch (error) {
|
|
45659
|
-
Log$
|
|
45663
|
+
Log$h.error('Protocol V2 initialization failed:', error);
|
|
45660
45664
|
throw error;
|
|
45661
45665
|
}
|
|
45662
45666
|
});
|
|
@@ -45739,6 +45743,11 @@ class Device extends events.exports {
|
|
|
45739
45743
|
return params.includeRaw ? cloneDeviceState(this.state) : createPublicDeviceState(this.state);
|
|
45740
45744
|
});
|
|
45741
45745
|
}
|
|
45746
|
+
refreshProtocolV2SettingsAfterMutation() {
|
|
45747
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45748
|
+
return this.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
45749
|
+
});
|
|
45750
|
+
}
|
|
45742
45751
|
_updateFeatures(protoFeatures, initSession) {
|
|
45743
45752
|
var _a;
|
|
45744
45753
|
const previousDeviceId = this.getCurrentDeviceId();
|
|
@@ -45765,7 +45774,7 @@ class Device extends events.exports {
|
|
|
45765
45774
|
source,
|
|
45766
45775
|
changedKeys: result.changedKeys,
|
|
45767
45776
|
};
|
|
45768
|
-
Log$
|
|
45777
|
+
Log$h.debug('Device state updated', {
|
|
45769
45778
|
source,
|
|
45770
45779
|
revision: result.revision,
|
|
45771
45780
|
changedKeyCount: result.changedKeys.length,
|
|
@@ -45989,17 +45998,25 @@ class Device extends events.exports {
|
|
|
45989
45998
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45990
45999
|
if (this.runPromise) {
|
|
45991
46000
|
yield this.interruptionFromOutside();
|
|
45992
|
-
Log$
|
|
46001
|
+
Log$h.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
45993
46002
|
}
|
|
45994
46003
|
options = parseRunOptions(options);
|
|
45995
46004
|
const runPromise = hdShared.createDeferred();
|
|
45996
46005
|
this.runPromise = runPromise;
|
|
45997
|
-
this._runInner(fn, options, runPromise).catch(error => {
|
|
46006
|
+
const cleanupPromise = this._runInner(fn, options, runPromise).catch(error => {
|
|
45998
46007
|
if (this.runPromise === runPromise) {
|
|
45999
46008
|
this.runPromise = null;
|
|
46000
46009
|
}
|
|
46001
46010
|
runPromise.reject(error);
|
|
46002
46011
|
});
|
|
46012
|
+
this.runCleanupPromise = cleanupPromise;
|
|
46013
|
+
cleanupPromise
|
|
46014
|
+
.finally(() => {
|
|
46015
|
+
if (this.runCleanupPromise === cleanupPromise) {
|
|
46016
|
+
this.runCleanupPromise = undefined;
|
|
46017
|
+
}
|
|
46018
|
+
})
|
|
46019
|
+
.catch(() => undefined);
|
|
46003
46020
|
return runPromise.promise;
|
|
46004
46021
|
});
|
|
46005
46022
|
}
|
|
@@ -46066,7 +46083,7 @@ class Device extends events.exports {
|
|
|
46066
46083
|
yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
|
|
46067
46084
|
}
|
|
46068
46085
|
yield this.release();
|
|
46069
|
-
Log$
|
|
46086
|
+
Log$h.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
46070
46087
|
}
|
|
46071
46088
|
clearRunPromise();
|
|
46072
46089
|
return;
|
|
@@ -46076,7 +46093,7 @@ class Device extends events.exports {
|
|
|
46076
46093
|
options.keepSession === false) {
|
|
46077
46094
|
this.keepSession = false;
|
|
46078
46095
|
yield this.release();
|
|
46079
|
-
Log$
|
|
46096
|
+
Log$h.debug('release device, mainId: ', this.mainId);
|
|
46080
46097
|
}
|
|
46081
46098
|
runPromise.resolve();
|
|
46082
46099
|
clearRunPromise();
|
|
@@ -46093,21 +46110,36 @@ class Device extends events.exports {
|
|
|
46093
46110
|
});
|
|
46094
46111
|
}
|
|
46095
46112
|
interruptionFromUser() {
|
|
46096
|
-
var _a, _b;
|
|
46113
|
+
var _a, _b, _c;
|
|
46097
46114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46098
46115
|
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
|
|
46099
|
-
|
|
46100
|
-
|
|
46116
|
+
const cleanupPromise = this.runCleanupPromise;
|
|
46117
|
+
const { cancelableAction } = this;
|
|
46118
|
+
const env = DataManager.getSettings('env');
|
|
46119
|
+
if (cancelableAction) {
|
|
46120
|
+
yield cancelableAction(error);
|
|
46121
|
+
}
|
|
46122
|
+
else if (this.isProtocolV2() &&
|
|
46123
|
+
(DataManager.isBleConnect(env) ||
|
|
46124
|
+
DataManager.isBrowserWebUsb(env) ||
|
|
46125
|
+
DataManager.isDesktopWebUsb(env)) &&
|
|
46126
|
+
this.hasDeviceAcquire()) {
|
|
46127
|
+
yield ((_b = (_a = this.commands) === null || _a === void 0 ? void 0 : _a.cancelDevice) === null || _b === void 0 ? void 0 : _b.call(_a).catch(cancelError => {
|
|
46128
|
+
Log$h.debug('Protocol V2 fallback cancel error', cancelError);
|
|
46129
|
+
}));
|
|
46130
|
+
}
|
|
46131
|
+
yield ((_c = this.commands) === null || _c === void 0 ? void 0 : _c.cancel());
|
|
46101
46132
|
if (this.runPromise) {
|
|
46102
46133
|
this.runPromise.reject(error);
|
|
46103
46134
|
this.runPromise = null;
|
|
46104
46135
|
}
|
|
46136
|
+
yield (cleanupPromise === null || cleanupPromise === void 0 ? void 0 : cleanupPromise.catch(() => undefined));
|
|
46105
46137
|
});
|
|
46106
46138
|
}
|
|
46107
46139
|
setCancelableAction(callback) {
|
|
46108
46140
|
this.cancelableAction = (e) => callback(e)
|
|
46109
46141
|
.catch(e2 => {
|
|
46110
|
-
Log$
|
|
46142
|
+
Log$h.debug('cancelableAction error', e2);
|
|
46111
46143
|
})
|
|
46112
46144
|
.finally(() => {
|
|
46113
46145
|
this.clearCancelableAction();
|
|
@@ -46390,7 +46422,7 @@ class Device extends events.exports {
|
|
|
46390
46422
|
expectedPassphraseState &&
|
|
46391
46423
|
expectedPassphraseState !== newPassphraseState;
|
|
46392
46424
|
const passphraseStateMismatch = !!expectedPassphraseState && expectedPassphraseState !== newPassphraseState;
|
|
46393
|
-
Log$
|
|
46425
|
+
Log$h.debug('Check passphrase state safety: ', {
|
|
46394
46426
|
hasExpectedPassphraseState: Boolean(expectedPassphraseState),
|
|
46395
46427
|
hasNewPassphraseState: Boolean(newPassphraseState),
|
|
46396
46428
|
passphraseStateMatches: Boolean(expectedPassphraseState) && expectedPassphraseState === newPassphraseState,
|
|
@@ -46528,7 +46560,7 @@ const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwar
|
|
|
46528
46560
|
};
|
|
46529
46561
|
};
|
|
46530
46562
|
|
|
46531
|
-
const Log$
|
|
46563
|
+
const Log$g = getLogger(exports.LoggerNames.Method);
|
|
46532
46564
|
const isEvmLedgerLegacyPathWithHighIndex = (path) => {
|
|
46533
46565
|
let addressN;
|
|
46534
46566
|
if (typeof path === 'string') {
|
|
@@ -46612,7 +46644,7 @@ class BaseMethod {
|
|
|
46612
46644
|
setContext(context) {
|
|
46613
46645
|
this.sdkInstanceId = context.sdkInstanceId;
|
|
46614
46646
|
this.instanceId = generateInstanceId('Method', this.sdkInstanceId);
|
|
46615
|
-
Log$
|
|
46647
|
+
Log$g.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
|
|
46616
46648
|
}
|
|
46617
46649
|
setDevice(device) {
|
|
46618
46650
|
var _a, _b;
|
|
@@ -46632,7 +46664,7 @@ class BaseMethod {
|
|
|
46632
46664
|
if (device.commands) {
|
|
46633
46665
|
device.commands.currentResponseID = this.responseID;
|
|
46634
46666
|
}
|
|
46635
|
-
Log$
|
|
46667
|
+
Log$g.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
|
|
46636
46668
|
}
|
|
46637
46669
|
checkFirmwareRelease() {
|
|
46638
46670
|
if (!this.device || this.device.isProtocolV2())
|
|
@@ -46707,7 +46739,7 @@ class BaseMethod {
|
|
|
46707
46739
|
checkFlag = true;
|
|
46708
46740
|
}
|
|
46709
46741
|
if (checkFlag && this.device.getCurrentSafetyChecks() === hdTransport.Enum_SafetyCheckLevel.Strict) {
|
|
46710
|
-
Log$
|
|
46742
|
+
Log$g.debug('will change safety_checks level');
|
|
46711
46743
|
yield this.device.commands.typedCall('ApplySettings', 'Success', {
|
|
46712
46744
|
safety_checks: hdTransport.Enum_SafetyCheckLevel.PromptTemporarily,
|
|
46713
46745
|
});
|
|
@@ -46783,7 +46815,7 @@ class Ping extends BaseMethod {
|
|
|
46783
46815
|
}
|
|
46784
46816
|
}
|
|
46785
46817
|
|
|
46786
|
-
const Log$
|
|
46818
|
+
const Log$f = getLogger(exports.LoggerNames.Core);
|
|
46787
46819
|
const parseInitOptions$1 = (payload) => ({
|
|
46788
46820
|
initSession: payload === null || payload === void 0 ? void 0 : payload.initSession,
|
|
46789
46821
|
passphraseState: payload === null || payload === void 0 ? void 0 : payload.passphraseState,
|
|
@@ -46809,14 +46841,14 @@ class PreInitialize extends BaseMethod {
|
|
|
46809
46841
|
}
|
|
46810
46842
|
catch (_a) {
|
|
46811
46843
|
this.device.clearPreInitialized();
|
|
46812
|
-
Log$
|
|
46844
|
+
Log$f.debug('[PRE-INIT][FAILED]');
|
|
46813
46845
|
return false;
|
|
46814
46846
|
}
|
|
46815
46847
|
});
|
|
46816
46848
|
}
|
|
46817
46849
|
}
|
|
46818
46850
|
|
|
46819
|
-
const Log$
|
|
46851
|
+
const Log$e = getLogger(exports.LoggerNames.DevicePool);
|
|
46820
46852
|
class SearchDevices extends BaseMethod {
|
|
46821
46853
|
init() {
|
|
46822
46854
|
this.useDevice = false;
|
|
@@ -46858,7 +46890,7 @@ class SearchDevices extends BaseMethod {
|
|
|
46858
46890
|
const errorCode = error && typeof error === 'object' && 'errorCode' in error
|
|
46859
46891
|
? error.errorCode
|
|
46860
46892
|
: undefined;
|
|
46861
|
-
Log$
|
|
46893
|
+
Log$e.debug('Skip unavailable device during search', Object.assign({ path: descriptor.path }, (errorCode !== undefined ? { errorCode } : {})));
|
|
46862
46894
|
}
|
|
46863
46895
|
}
|
|
46864
46896
|
return deviceList.map(device => device.toMessageObject());
|
|
@@ -47760,7 +47792,7 @@ function buildProtocolV2FirmwareRelease({ currentVersions, currentVerification =
|
|
|
47760
47792
|
release,
|
|
47761
47793
|
};
|
|
47762
47794
|
}
|
|
47763
|
-
const Log$
|
|
47795
|
+
const Log$d = getLogger(exports.LoggerNames.Method);
|
|
47764
47796
|
class CheckAllFirmwareRelease extends BaseMethod {
|
|
47765
47797
|
getSupportedProtocols() {
|
|
47766
47798
|
return ['V1', 'V2'];
|
|
@@ -47821,7 +47853,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47821
47853
|
((_c = error.params) === null || _c === void 0 ? void 0 : _c.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47822
47854
|
throw error;
|
|
47823
47855
|
}
|
|
47824
|
-
Log$
|
|
47856
|
+
Log$d.warn('[CheckAllFirmwareRelease] Optional firmware Plan is unavailable; using the legacy release result');
|
|
47825
47857
|
firmwareUpdatePlan = undefined;
|
|
47826
47858
|
}
|
|
47827
47859
|
return {
|
|
@@ -47907,7 +47939,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47907
47939
|
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
47908
47940
|
throw error;
|
|
47909
47941
|
}
|
|
47910
|
-
Log$
|
|
47942
|
+
Log$d.warn('[CheckAllFirmwareRelease] Optional Protocol V2 firmware Plan is unavailable; using the release result');
|
|
47911
47943
|
firmwareUpdatePlan = undefined;
|
|
47912
47944
|
}
|
|
47913
47945
|
const firmwarePlan = summarizeProtocolV2FirmwareRelease(plan, PROTOCOL_V2_MAIN_FIRMWARE_TARGETS);
|
|
@@ -48148,6 +48180,7 @@ class DeviceChangePin extends BaseMethod {
|
|
|
48148
48180
|
}
|
|
48149
48181
|
init() {
|
|
48150
48182
|
this.unlockPolicy = 'unlock-before-run';
|
|
48183
|
+
this.protocolV2PreUnlockPinType = hdTransport.DeviceSessionPinType.Any;
|
|
48151
48184
|
this.useDevicePassphraseState = false;
|
|
48152
48185
|
validateParams(this.payload, [{ name: 'remove', type: 'boolean' }]);
|
|
48153
48186
|
this.params = {
|
|
@@ -48474,7 +48507,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
48474
48507
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48475
48508
|
try {
|
|
48476
48509
|
if (this.device.isProtocolV2()) {
|
|
48477
|
-
const refreshStatusAndSettings = () => this.device.
|
|
48510
|
+
const refreshStatusAndSettings = () => this.device.refreshProtocolV2SettingsAfterMutation();
|
|
48478
48511
|
assertSettingsSupported(this.payload, DEVICE_SETTINGS_V1_ONLY_FIELDS, 'Protocol V2');
|
|
48479
48512
|
const capabilities = getDeviceSettingsCapabilities(this.device.getCurrentDeviceType(), 'V2');
|
|
48480
48513
|
assertProtocolV2SettingValues(this.payload, capabilities);
|
|
@@ -48497,14 +48530,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
48497
48530
|
const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', {
|
|
48498
48531
|
page: hdTransport.DeviceSettingsPage.DevicePassphrase,
|
|
48499
48532
|
});
|
|
48500
|
-
|
|
48501
|
-
const lockedAfterDisabling = requestedPassphrase === false &&
|
|
48502
|
-
current.status.unlocked === true &&
|
|
48503
|
-
updated.status.unlocked === false;
|
|
48504
|
-
if (updated.status.passphraseProtection !== requestedPassphrase &&
|
|
48505
|
-
!lockedAfterDisabling) {
|
|
48506
|
-
throw hdShared.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 passphrase setting did not reach the requested value.');
|
|
48507
|
-
}
|
|
48533
|
+
yield refreshStatusAndSettings();
|
|
48508
48534
|
return res.message;
|
|
48509
48535
|
}
|
|
48510
48536
|
if (requestedAirgap !== undefined) {
|
|
@@ -48764,7 +48790,12 @@ class DeviceSupportFeatures extends BaseMethod {
|
|
|
48764
48790
|
}
|
|
48765
48791
|
|
|
48766
48792
|
class DeviceVerify extends BaseMethod {
|
|
48793
|
+
getSupportedProtocols() {
|
|
48794
|
+
return ['V1', 'V2'];
|
|
48795
|
+
}
|
|
48767
48796
|
init() {
|
|
48797
|
+
this.unlockPolicy = 'unlock-before-run';
|
|
48798
|
+
this.protocolV2PreUnlockPinType = hdTransport.DeviceSessionPinType.Any;
|
|
48768
48799
|
this.useDevicePassphraseState = false;
|
|
48769
48800
|
validateParams(this.payload, [{ name: 'dataHex', type: 'hexString' }]);
|
|
48770
48801
|
this.params = {
|
|
@@ -48803,6 +48834,7 @@ class DeviceWipe extends BaseMethod {
|
|
|
48803
48834
|
}
|
|
48804
48835
|
init() {
|
|
48805
48836
|
this.unlockPolicy = 'unlock-before-run';
|
|
48837
|
+
this.protocolV2PreUnlockPinType = hdTransport.DeviceSessionPinType.Any;
|
|
48806
48838
|
this.useDevicePassphraseState = false;
|
|
48807
48839
|
this.protocolV2UiInteraction = {
|
|
48808
48840
|
request: 'button',
|
|
@@ -48893,7 +48925,7 @@ const getInfo = ({ features, updateType, targetVersion, firmwareType }) => {
|
|
|
48893
48925
|
const NEW_BOOT_UPRATE_FIRMWARE_VERSION = '2.4.5';
|
|
48894
48926
|
const SESSION_ERROR$3 = 'session not found';
|
|
48895
48927
|
const FIRMWARE_UPDATE_CONFIRM$1 = 'Firmware install confirmed';
|
|
48896
|
-
const Log$
|
|
48928
|
+
const Log$c = getLogger(exports.LoggerNames.Method);
|
|
48897
48929
|
const isDeviceDisconnectedError$1 = (error) => {
|
|
48898
48930
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
48899
48931
|
return (message.includes('device was disconnected') ||
|
|
@@ -48948,13 +48980,13 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48948
48980
|
const newFeatures = yield typedCall('GetFeatures', 'Features', {});
|
|
48949
48981
|
const deviceBootloaderVersion = getDeviceBootloaderVersion(buildProtocolV1FeaturesPayload(newFeatures.message, device.features)).join('.');
|
|
48950
48982
|
const supportUpgradeFileHeader = semver__default["default"].gte(deviceBootloaderVersion, '2.1.0');
|
|
48951
|
-
Log$
|
|
48983
|
+
Log$c.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
|
|
48952
48984
|
if (supportUpgradeFileHeader) {
|
|
48953
48985
|
const HEADER_SIZE = 1024;
|
|
48954
48986
|
if (source.size < HEADER_SIZE) {
|
|
48955
48987
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${source.size} bytes, expected at least ${HEADER_SIZE} bytes`);
|
|
48956
48988
|
}
|
|
48957
|
-
Log$
|
|
48989
|
+
Log$c.debug('Uploading firmware header:', {
|
|
48958
48990
|
size: HEADER_SIZE,
|
|
48959
48991
|
totalSize: source.size,
|
|
48960
48992
|
});
|
|
@@ -48966,18 +48998,18 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48966
48998
|
});
|
|
48967
48999
|
const isUnknownMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage');
|
|
48968
49000
|
if (headerRes.type !== 'Success' && !isUnknownMessage) {
|
|
48969
|
-
Log$
|
|
49001
|
+
Log$c.error('Firmware header upload failed:', headerRes);
|
|
48970
49002
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
|
|
48971
49003
|
}
|
|
48972
49004
|
}
|
|
48973
49005
|
catch (error) {
|
|
48974
|
-
Log$
|
|
49006
|
+
Log$c.error('Firmware header upload failed:', error);
|
|
48975
49007
|
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
48976
49008
|
if (!message.includes('Failure_UnknownMessage')) {
|
|
48977
49009
|
throw error;
|
|
48978
49010
|
}
|
|
48979
49011
|
}
|
|
48980
|
-
Log$
|
|
49012
|
+
Log$c.debug('Firmware header uploaded successfully');
|
|
48981
49013
|
}
|
|
48982
49014
|
}
|
|
48983
49015
|
const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
|
|
@@ -48996,7 +49028,7 @@ const uploadFirmwareFromSource = (updateType, typedCall, postMessage, device, so
|
|
|
48996
49028
|
}
|
|
48997
49029
|
catch (error) {
|
|
48998
49030
|
if (isDeviceDisconnectedError$1(error)) {
|
|
48999
|
-
Log$
|
|
49031
|
+
Log$c.log('Rebooting device');
|
|
49000
49032
|
updateResponse = {
|
|
49001
49033
|
type: 'Success',
|
|
49002
49034
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49094,7 +49126,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49094
49126
|
}
|
|
49095
49127
|
catch (error) {
|
|
49096
49128
|
if (isDeviceDisconnectedError$1(error)) {
|
|
49097
|
-
Log$
|
|
49129
|
+
Log$c.log('Rebooting device');
|
|
49098
49130
|
response = {
|
|
49099
49131
|
type: 'Success',
|
|
49100
49132
|
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
@@ -49125,7 +49157,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49125
49157
|
]);
|
|
49126
49158
|
}
|
|
49127
49159
|
catch (e) {
|
|
49128
|
-
Log$
|
|
49160
|
+
Log$c.log('catch Bluetooth error when device is restarting: ', e);
|
|
49129
49161
|
}
|
|
49130
49162
|
}
|
|
49131
49163
|
else {
|
|
@@ -49146,7 +49178,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, source, rebootOn
|
|
|
49146
49178
|
}
|
|
49147
49179
|
catch (error) {
|
|
49148
49180
|
console.error('Device reconnect failed: ', error);
|
|
49149
|
-
Log$
|
|
49181
|
+
Log$c.error('Device reconnect failed:', error);
|
|
49150
49182
|
yield wait(1000);
|
|
49151
49183
|
}
|
|
49152
49184
|
}
|
|
@@ -49186,7 +49218,7 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
|
|
|
49186
49218
|
return result;
|
|
49187
49219
|
}
|
|
49188
49220
|
catch (error) {
|
|
49189
|
-
Log$
|
|
49221
|
+
Log$c.error(`emmcWrite error: `, error);
|
|
49190
49222
|
retryCount--;
|
|
49191
49223
|
if (retryCount === 0) {
|
|
49192
49224
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -49381,7 +49413,7 @@ class DeviceFullyUploadResource extends BaseMethod {
|
|
|
49381
49413
|
}
|
|
49382
49414
|
}
|
|
49383
49415
|
|
|
49384
|
-
const Log$
|
|
49416
|
+
const Log$b = getLogger(exports.LoggerNames.Method);
|
|
49385
49417
|
const SESSION_ERROR$2 = 'session not found';
|
|
49386
49418
|
const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
49387
49419
|
const BOOTLOADER_POLL_INITIALIZE_TIMEOUT_MS = 5000;
|
|
@@ -49459,7 +49491,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49459
49491
|
const env = DataManager.getSettings('env');
|
|
49460
49492
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
49461
49493
|
let bleProbeInFlight = false;
|
|
49462
|
-
Log$
|
|
49494
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
49463
49495
|
let isFirstCheck = true;
|
|
49464
49496
|
let checkCount = 0;
|
|
49465
49497
|
let hasPromptedWebDevice = false;
|
|
@@ -49493,10 +49525,10 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49493
49525
|
if (isFinished || isPromptingWebDevice)
|
|
49494
49526
|
return;
|
|
49495
49527
|
checkCount += 1;
|
|
49496
|
-
Log$
|
|
49528
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
49497
49529
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
49498
49530
|
isFirstCheck = false;
|
|
49499
|
-
Log$
|
|
49531
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] wait 3000ms');
|
|
49500
49532
|
yield wait(3000);
|
|
49501
49533
|
}
|
|
49502
49534
|
if (checkCount > 4 &&
|
|
@@ -49520,7 +49552,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49520
49552
|
catch (e) {
|
|
49521
49553
|
isFinished = true;
|
|
49522
49554
|
clearPollingTimers();
|
|
49523
|
-
Log$
|
|
49555
|
+
Log$b.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
49524
49556
|
(_c = this.checkPromise) === null || _c === void 0 ? void 0 : _c.reject(e);
|
|
49525
49557
|
}
|
|
49526
49558
|
finally {
|
|
@@ -49542,7 +49574,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49542
49574
|
}
|
|
49543
49575
|
}
|
|
49544
49576
|
catch (e) {
|
|
49545
|
-
Log$
|
|
49577
|
+
Log$b.log('catch Bluetooth error when device is restarting: ', e);
|
|
49546
49578
|
}
|
|
49547
49579
|
finally {
|
|
49548
49580
|
bleProbeInFlight = false;
|
|
@@ -49645,7 +49677,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49645
49677
|
}
|
|
49646
49678
|
catch (error) {
|
|
49647
49679
|
if (isDeviceDisconnectedError(error)) {
|
|
49648
|
-
Log$
|
|
49680
|
+
Log$b.log('Rebooting device');
|
|
49649
49681
|
updateResponse = {
|
|
49650
49682
|
type: 'Success',
|
|
49651
49683
|
message: { message: FIRMWARE_UPDATE_CONFIRM },
|
|
@@ -49761,7 +49793,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
49761
49793
|
return result;
|
|
49762
49794
|
}
|
|
49763
49795
|
catch (error) {
|
|
49764
|
-
Log$
|
|
49796
|
+
Log$b.error(`emmcWrite error: `, error);
|
|
49765
49797
|
retryCount--;
|
|
49766
49798
|
if (retryCount === 0) {
|
|
49767
49799
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
|
|
@@ -50068,7 +50100,7 @@ class GetNextU2FCounter extends BaseMethod {
|
|
|
50068
50100
|
}
|
|
50069
50101
|
}
|
|
50070
50102
|
|
|
50071
|
-
const Log$
|
|
50103
|
+
const Log$a = getLogger(exports.LoggerNames.Method);
|
|
50072
50104
|
class FirmwareUpdate extends BaseMethod {
|
|
50073
50105
|
constructor() {
|
|
50074
50106
|
super(...arguments);
|
|
@@ -50107,7 +50139,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50107
50139
|
const env = DataManager.getSettings('env');
|
|
50108
50140
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50109
50141
|
let bleProbeInFlight = false;
|
|
50110
|
-
Log$
|
|
50142
|
+
Log$a.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50111
50143
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
50112
50144
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
50113
50145
|
if (isBleReconnect) {
|
|
@@ -50123,7 +50155,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50123
50155
|
}
|
|
50124
50156
|
}
|
|
50125
50157
|
catch (e) {
|
|
50126
|
-
Log$
|
|
50158
|
+
Log$a.log('catch Bluetooth error when device is restarting: ', e);
|
|
50127
50159
|
}
|
|
50128
50160
|
finally {
|
|
50129
50161
|
bleProbeInFlight = false;
|
|
@@ -50182,7 +50214,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
50182
50214
|
if (e instanceof hdShared.HardwareError) {
|
|
50183
50215
|
return Promise.reject(e);
|
|
50184
50216
|
}
|
|
50185
|
-
Log$
|
|
50217
|
+
Log$a.log('auto go to bootloader mode failed: ', e);
|
|
50186
50218
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure));
|
|
50187
50219
|
}
|
|
50188
50220
|
}
|
|
@@ -50331,7 +50363,7 @@ const readVerifiedPreparedResourceArchive = ({ preparedPlan, reader, }) => __awa
|
|
|
50331
50363
|
return verifiedEntries;
|
|
50332
50364
|
});
|
|
50333
50365
|
|
|
50334
|
-
const Log$
|
|
50366
|
+
const Log$9 = getLogger(exports.LoggerNames.Method);
|
|
50335
50367
|
const FIRMWARE_DOWNLOAD_REQUEST_OPTIONS = {
|
|
50336
50368
|
connectTimeoutMs: 60000,
|
|
50337
50369
|
readTimeoutMs: 60000,
|
|
@@ -50488,7 +50520,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50488
50520
|
const env = DataManager.getSettings('env');
|
|
50489
50521
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
50490
50522
|
let probeInFlight = false;
|
|
50491
|
-
Log$
|
|
50523
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
50492
50524
|
let isFirstCheck = true;
|
|
50493
50525
|
let checkCount = 0;
|
|
50494
50526
|
let hasPromptedWebDevice = false;
|
|
@@ -50523,10 +50555,10 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50523
50555
|
return;
|
|
50524
50556
|
probeInFlight = true;
|
|
50525
50557
|
checkCount += 1;
|
|
50526
|
-
Log$
|
|
50558
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
50527
50559
|
if (isTouchOrProDevice && isFirstCheck) {
|
|
50528
50560
|
isFirstCheck = false;
|
|
50529
|
-
Log$
|
|
50561
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] wait 3000ms');
|
|
50530
50562
|
yield wait(3000);
|
|
50531
50563
|
}
|
|
50532
50564
|
if (checkCount > 4 &&
|
|
@@ -50550,7 +50582,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50550
50582
|
catch (e) {
|
|
50551
50583
|
isFinished = true;
|
|
50552
50584
|
clearPollingTimers();
|
|
50553
|
-
Log$
|
|
50585
|
+
Log$9.log('FirmwareUpdateV2 [checkDeviceToBootloader] promptDeviceInBootloaderForWebDevice failed: ', e);
|
|
50554
50586
|
(_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.reject(e);
|
|
50555
50587
|
}
|
|
50556
50588
|
finally {
|
|
@@ -50570,7 +50602,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50570
50602
|
}
|
|
50571
50603
|
}
|
|
50572
50604
|
catch (e) {
|
|
50573
|
-
Log$
|
|
50605
|
+
Log$9.log('catch Bluetooth error when device is restarting: ', e);
|
|
50574
50606
|
}
|
|
50575
50607
|
finally {
|
|
50576
50608
|
probeInFlight = false;
|
|
@@ -50865,7 +50897,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
50865
50897
|
}
|
|
50866
50898
|
}
|
|
50867
50899
|
|
|
50868
|
-
const Log$
|
|
50900
|
+
const Log$8 = getLogger(exports.LoggerNames.Method);
|
|
50869
50901
|
const MIN_UPDATE_V3_BOOTLOADER_VERSION = '2.8.0';
|
|
50870
50902
|
class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
50871
50903
|
constructor() {
|
|
@@ -50983,7 +51015,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
50983
51015
|
}
|
|
50984
51016
|
run() {
|
|
50985
51017
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50986
|
-
Log$
|
|
51018
|
+
Log$8.debug('FirmwareUpdateV3 strategy: Protocol V1');
|
|
50987
51019
|
return this.runProtocolV1();
|
|
50988
51020
|
});
|
|
50989
51021
|
}
|
|
@@ -51130,7 +51162,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51130
51162
|
resourceEntries: [],
|
|
51131
51163
|
};
|
|
51132
51164
|
}
|
|
51133
|
-
Log$
|
|
51165
|
+
Log$8.warn('No resource url found');
|
|
51134
51166
|
return {
|
|
51135
51167
|
resourceBinary: null,
|
|
51136
51168
|
resourceEntries: [],
|
|
@@ -51291,7 +51323,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51291
51323
|
yield this.startEmmcFirmwareUpdate({ path: '0:updates' });
|
|
51292
51324
|
}
|
|
51293
51325
|
catch (error) {
|
|
51294
|
-
Log$
|
|
51326
|
+
Log$8.error('triggerFirmwareUpdateEmmc error: ', error);
|
|
51295
51327
|
if (error === null || error === void 0 ? void 0 : error.errorCode) {
|
|
51296
51328
|
const unexpectedError = [
|
|
51297
51329
|
hdShared.HardwareErrorCode.ActionCancelled,
|
|
@@ -51361,7 +51393,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51361
51393
|
yield hdShared.wait(1000);
|
|
51362
51394
|
}
|
|
51363
51395
|
catch (error) {
|
|
51364
|
-
Log$
|
|
51396
|
+
Log$8.log('getFeatures error', error);
|
|
51365
51397
|
let shouldReconnect = true;
|
|
51366
51398
|
const progress = this.extractUpdateModeProgress(error);
|
|
51367
51399
|
if (progress !== null) {
|
|
@@ -51460,7 +51492,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51460
51492
|
return;
|
|
51461
51493
|
}
|
|
51462
51494
|
catch (e) {
|
|
51463
|
-
Log$
|
|
51495
|
+
Log$8.log('catch Bluetooth error when device is restarting: ', e);
|
|
51464
51496
|
}
|
|
51465
51497
|
}
|
|
51466
51498
|
else {
|
|
@@ -51475,7 +51507,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51475
51507
|
yield this._promptDeviceForSwitchFirmwareWebDevice();
|
|
51476
51508
|
}
|
|
51477
51509
|
catch (e) {
|
|
51478
|
-
Log$
|
|
51510
|
+
Log$8.log('WebUSB re-authorization failed: ', e);
|
|
51479
51511
|
}
|
|
51480
51512
|
webUsbCheckCount = 0;
|
|
51481
51513
|
}
|
|
@@ -51500,7 +51532,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
51500
51532
|
}
|
|
51501
51533
|
catch (error) {
|
|
51502
51534
|
console.error('Device reconnect failed: ', error);
|
|
51503
|
-
Log$
|
|
51535
|
+
Log$8.error('Device reconnect failed:', error);
|
|
51504
51536
|
yield hdShared.wait(1000);
|
|
51505
51537
|
}
|
|
51506
51538
|
}
|
|
@@ -51684,15 +51716,14 @@ function prepareFirmwareUpdateV4MemoryHost({ sdk, plan, artifacts, }) {
|
|
|
51684
51716
|
};
|
|
51685
51717
|
}
|
|
51686
51718
|
|
|
51687
|
-
const Log$
|
|
51719
|
+
const Log$7 = getLogger(exports.LoggerNames.Method);
|
|
51688
51720
|
const SESSION_ERROR$1 = 'session not found';
|
|
51689
51721
|
const PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT = 90 * 1000;
|
|
51690
51722
|
const PROTOCOL_V2_FINAL_RECONNECT_TIMEOUT = 3 * 60 * 1000;
|
|
51691
51723
|
const PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT = 5 * 1000;
|
|
51692
51724
|
const PROTOCOL_V2_FIRMWARE_STATUS_RESPONSE_TIMEOUT = 15 * 1000;
|
|
51693
|
-
const PROTOCOL_V2_INSTALL_TIMEOUT =
|
|
51725
|
+
const PROTOCOL_V2_INSTALL_TIMEOUT = 5 * 60 * 1000;
|
|
51694
51726
|
const PROTOCOL_V2_INSTALL_STATUS_INITIAL_DELAY = 1000;
|
|
51695
|
-
const PROTOCOL_V2_MISSING_TARGET_STATUS_GRACE_TIMEOUT = 30 * 1000;
|
|
51696
51727
|
const PROTOCOL_V2_TARGET_STATUS_PENDING = 0;
|
|
51697
51728
|
const PROTOCOL_V2_TARGET_STATUS_IN_PROGRESS = 1;
|
|
51698
51729
|
const PROTOCOL_V2_TARGET_STATUS_FINISHED = 2;
|
|
@@ -51706,6 +51737,8 @@ const PROTOCOL_V2_CONNECT_SINGLE_TIMEOUT = 75 * 1000;
|
|
|
51706
51737
|
const PROTOCOL_V2_DEVICE_INFO_READY_TIMEOUT = 30 * 1000;
|
|
51707
51738
|
const PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT = 3;
|
|
51708
51739
|
const PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE = 'FirmwareInstallStatusConflict';
|
|
51740
|
+
const PROTOCOL_V2_INSTALL_FAILED_CODE = 'FirmwareInstallFailed';
|
|
51741
|
+
const PROTOCOL_V2_INSTALL_TIMEOUT_CODE = 'FirmwareInstallTimeout';
|
|
51709
51742
|
const PROTOCOL_V2_OKPP_HEADER_SIZE = 0x52a0;
|
|
51710
51743
|
const PROTOCOL_V2_OKPP_PAYLOAD_HASH_OFFSET = 0x200;
|
|
51711
51744
|
const PROTOCOL_V2_OKPP_HEADER_HASH_OFFSET = 0x240;
|
|
@@ -51861,7 +51894,8 @@ const isProtocolV2FirmwareStatusEndpointUnavailable = (error) => {
|
|
|
51861
51894
|
const isProtocolV2TerminalInstallStatusError = (error) => {
|
|
51862
51895
|
var _a;
|
|
51863
51896
|
return error instanceof hdShared.HardwareError &&
|
|
51864
|
-
(error.errorCode === hdShared.HardwareErrorCode.
|
|
51897
|
+
(error.errorCode === hdShared.HardwareErrorCode.ActionCancelled ||
|
|
51898
|
+
error.errorCode === hdShared.HardwareErrorCode.FirmwareError ||
|
|
51865
51899
|
error.errorCode === hdShared.HardwareErrorCode.FirmwareVerificationFailed ||
|
|
51866
51900
|
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE);
|
|
51867
51901
|
};
|
|
@@ -52003,6 +52037,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52003
52037
|
this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE];
|
|
52004
52038
|
this.requireDeviceMode = [];
|
|
52005
52039
|
this.unlockPolicy = 'unlock-before-run';
|
|
52040
|
+
this.protocolV2PreUnlockPinType = hdTransport.DeviceSessionPinType.Any;
|
|
52006
52041
|
this.useDevicePassphraseState = false;
|
|
52007
52042
|
this.skipForceUpdateCheck = true;
|
|
52008
52043
|
const { payload } = this;
|
|
@@ -52162,7 +52197,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52162
52197
|
}
|
|
52163
52198
|
run() {
|
|
52164
52199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52165
|
-
Log$
|
|
52200
|
+
Log$7.debug('FirmwareUpdateV4 strategy: Protocol V2');
|
|
52166
52201
|
return this.runProtocolV2();
|
|
52167
52202
|
});
|
|
52168
52203
|
}
|
|
@@ -52736,8 +52771,9 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52736
52771
|
? visibleVersions[target]
|
|
52737
52772
|
: `${Math.floor(statusVersion / 0x10000) % 0x100}.${Math.floor(statusVersion / 0x100) % 0x100}.${statusVersion % 0x100}`;
|
|
52738
52773
|
if (!observedVersion) {
|
|
52739
|
-
|
|
52740
|
-
|
|
52774
|
+
const isUnobservableApplicationSlot = applicationTargets.length > 1 && (target === 'app_v1' || target === 'app_v2');
|
|
52775
|
+
if (this.protocolV2FinalStatusVerified || isUnobservableApplicationSlot) {
|
|
52776
|
+
Log$7.warn(`Protocol V2 target ${target} has no observable final version; install completion is authoritative`);
|
|
52741
52777
|
}
|
|
52742
52778
|
else {
|
|
52743
52779
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, `Protocol V2 target ${target} has no observable final version after status fallback`);
|
|
@@ -53107,7 +53143,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53107
53143
|
return true;
|
|
53108
53144
|
}
|
|
53109
53145
|
catch (error) {
|
|
53110
|
-
Log$
|
|
53146
|
+
Log$7.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53111
53147
|
return false;
|
|
53112
53148
|
}
|
|
53113
53149
|
});
|
|
@@ -53147,7 +53183,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53147
53183
|
if (error instanceof hdShared.HardwareError) {
|
|
53148
53184
|
throw error;
|
|
53149
53185
|
}
|
|
53150
|
-
Log$
|
|
53186
|
+
Log$7.log('Protocol V2 auto go to bootloader mode failed: ', error);
|
|
53151
53187
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
53152
53188
|
}
|
|
53153
53189
|
});
|
|
@@ -53155,12 +53191,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53155
53191
|
enterProtocolV2BootloaderMode() {
|
|
53156
53192
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53157
53193
|
if (this.isProtocolV2RomloaderMode()) {
|
|
53158
|
-
Log$
|
|
53194
|
+
Log$7.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
53159
53195
|
this.protocolV2ExecutionInLoader = true;
|
|
53160
53196
|
return false;
|
|
53161
53197
|
}
|
|
53162
53198
|
if (this.isProtocolV2BootloaderMode()) {
|
|
53163
|
-
Log$
|
|
53199
|
+
Log$7.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
53164
53200
|
this.protocolV2ExecutionInLoader = true;
|
|
53165
53201
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.GoToBootloaderSuccess);
|
|
53166
53202
|
return false;
|
|
@@ -53196,7 +53232,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53196
53232
|
}
|
|
53197
53233
|
shouldReconnect = true;
|
|
53198
53234
|
lastError = error;
|
|
53199
|
-
Log$
|
|
53235
|
+
Log$7.log('Protocol V2 bootloader mode not ready, polling reconnect: ', error);
|
|
53200
53236
|
}
|
|
53201
53237
|
yield hdShared.wait(retryInterval);
|
|
53202
53238
|
}
|
|
@@ -53293,7 +53329,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53293
53329
|
for (const resource of resourceSources) {
|
|
53294
53330
|
const requiresFreshStaging = isProtocolV2BootResourcePackagePath(resource.devicePath);
|
|
53295
53331
|
if (!requiresFreshStaging && (yield this.isProtocolV2ResourceBundleUpToDate(resource))) {
|
|
53296
|
-
Log$
|
|
53332
|
+
Log$7.log(`[FirmwareUpdateV4] skip RESC bundle ${resource.name}; already up to date`);
|
|
53297
53333
|
}
|
|
53298
53334
|
else {
|
|
53299
53335
|
resourcesToSync.push(resource);
|
|
@@ -53407,8 +53443,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53407
53443
|
});
|
|
53408
53444
|
}
|
|
53409
53445
|
assertProtocolV2TargetStatus(statusTargets, expectedTargetIds, expectedPaths = new Map()) {
|
|
53410
|
-
|
|
53411
|
-
Log$6.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateStatus records=${JSON.stringify(statusTargets)}`);
|
|
53446
|
+
Log$7.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateStatus records=${JSON.stringify(statusTargets)}`);
|
|
53412
53447
|
const failedTarget = statusTargets.find(target => {
|
|
53413
53448
|
var _a;
|
|
53414
53449
|
return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1) &&
|
|
@@ -53421,8 +53456,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53421
53456
|
payloadVersion: failedTarget.payload_version,
|
|
53422
53457
|
path: failedTarget.path,
|
|
53423
53458
|
});
|
|
53424
|
-
Log$
|
|
53425
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError,
|
|
53459
|
+
Log$7.error(`[FirmwareUpdateV4] firmware install failed target=${failedTargetDetails}`);
|
|
53460
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, undefined, {
|
|
53461
|
+
firmwareUpdateCode: PROTOCOL_V2_INSTALL_FAILED_CODE,
|
|
53462
|
+
});
|
|
53426
53463
|
}
|
|
53427
53464
|
const matchingTargets = statusTargets.filter(target => { var _a; return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1); });
|
|
53428
53465
|
const seenTargetIds = new Set();
|
|
@@ -53431,7 +53468,8 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53431
53468
|
if (targetId === undefined ||
|
|
53432
53469
|
seenTargetIds.has(targetId) ||
|
|
53433
53470
|
(target.path && expectedPaths.get(targetId) && target.path !== expectedPaths.get(targetId))) {
|
|
53434
|
-
|
|
53471
|
+
Log$7.error(`[FirmwareUpdateV4] install status conflicts with target=${target.target_id}`);
|
|
53472
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, undefined, {
|
|
53435
53473
|
firmwareUpdateCode: PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE,
|
|
53436
53474
|
});
|
|
53437
53475
|
}
|
|
@@ -53524,15 +53562,8 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53524
53562
|
let lastError;
|
|
53525
53563
|
let shouldReconnect = false;
|
|
53526
53564
|
let deviceInfo;
|
|
53527
|
-
let missingTargetStatusSince;
|
|
53528
|
-
let missingTargetStatusKey;
|
|
53529
|
-
let normalModeWithoutInstallEvidenceSince;
|
|
53530
53565
|
let installEvidenceObserved = false;
|
|
53531
53566
|
let currentInstallStatusObserved = false;
|
|
53532
|
-
const resetMissingTargetStatusGrace = () => {
|
|
53533
|
-
missingTargetStatusSince = undefined;
|
|
53534
|
-
missingTargetStatusKey = undefined;
|
|
53535
|
-
};
|
|
53536
53567
|
while (Date.now() - startTime < PROTOCOL_V2_INSTALL_TIMEOUT) {
|
|
53537
53568
|
this.throwIfAborted();
|
|
53538
53569
|
try {
|
|
@@ -53552,7 +53583,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53552
53583
|
}, { timeoutMs: PROTOCOL_V2_FIRMWARE_STATUS_RESPONSE_TIMEOUT });
|
|
53553
53584
|
if (statusResponse.type === 'Success') {
|
|
53554
53585
|
installEvidenceObserved = true;
|
|
53555
|
-
resetMissingTargetStatusGrace();
|
|
53556
53586
|
lastError = new Error('Protocol V2 firmware install acknowledged; waiting for target status');
|
|
53557
53587
|
}
|
|
53558
53588
|
const statusTargets = statusResponse.type === 'DeviceFirmwareUpdateStatus'
|
|
@@ -53574,7 +53604,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53574
53604
|
if (hasMatchingTargetStatus &&
|
|
53575
53605
|
(!requireCurrentInstallStatus || currentInstallStatusObserved)) {
|
|
53576
53606
|
installEvidenceObserved = true;
|
|
53577
|
-
normalModeWithoutInstallEvidenceSince = undefined;
|
|
53578
53607
|
}
|
|
53579
53608
|
const matchingStatusTargets = statusTargets.filter(target => {
|
|
53580
53609
|
const targetId = normalizeProtocolV2TargetId(target.target_id);
|
|
@@ -53596,13 +53625,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53596
53625
|
if (isNormalMode &&
|
|
53597
53626
|
(installEvidenceObserved ||
|
|
53598
53627
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53599
|
-
Log$
|
|
53628
|
+
Log$7.log('[FirmwareUpdateV4] empty firmware status after confirmed App reboot; update complete');
|
|
53600
53629
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53601
53630
|
return;
|
|
53602
53631
|
}
|
|
53603
53632
|
}
|
|
53604
53633
|
if (statusTargets.length === 0) {
|
|
53605
|
-
resetMissingTargetStatusGrace();
|
|
53606
53634
|
if (statusResponse.type !== 'Success') {
|
|
53607
53635
|
lastError = new Error('Protocol V2 firmware update is waiting for user confirmation or target status');
|
|
53608
53636
|
}
|
|
@@ -53610,23 +53638,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53610
53638
|
else {
|
|
53611
53639
|
const missingTargetIds = this.getProtocolV2MissingTargetIds(statusTargets, expectedTargetIds);
|
|
53612
53640
|
if (missingTargetIds.length > 0) {
|
|
53613
|
-
const now = Date.now();
|
|
53614
53641
|
const missingKey = missingTargetIds.join(',');
|
|
53615
|
-
if (missingTargetStatusSince === undefined || missingTargetStatusKey !== missingKey) {
|
|
53616
|
-
missingTargetStatusSince = now;
|
|
53617
|
-
missingTargetStatusKey = missingKey;
|
|
53618
|
-
}
|
|
53619
|
-
else if (now - missingTargetStatusSince >=
|
|
53620
|
-
PROTOCOL_V2_MISSING_TARGET_STATUS_GRACE_TIMEOUT) {
|
|
53621
|
-
const reportedTargetIds = statusTargets
|
|
53622
|
-
.map(target => normalizeProtocolV2TargetId(target.target_id))
|
|
53623
|
-
.filter((targetId) => targetId !== undefined);
|
|
53624
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, `Protocol V2 firmware status is missing requested records: targetIds=${missingKey} reportedTargetIds=${reportedTargetIds.join(',')}`);
|
|
53625
|
-
}
|
|
53626
53642
|
lastError = new Error(`Protocol V2 firmware status is temporarily missing targetIds=${missingKey}`);
|
|
53627
53643
|
}
|
|
53628
53644
|
else {
|
|
53629
|
-
resetMissingTargetStatusGrace();
|
|
53630
53645
|
lastError = new Error('Protocol V2 firmware targets are still installing');
|
|
53631
53646
|
}
|
|
53632
53647
|
}
|
|
@@ -53635,7 +53650,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53635
53650
|
if (isProtocolV2TerminalInstallStatusError(error)) {
|
|
53636
53651
|
throw error;
|
|
53637
53652
|
}
|
|
53638
|
-
resetMissingTargetStatusGrace();
|
|
53639
53653
|
if (isProtocolV2FirmwareStatusEndpointUnavailable(error)) {
|
|
53640
53654
|
if (!currentDeviceInfo) {
|
|
53641
53655
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 device identity is unavailable during install polling');
|
|
@@ -53644,21 +53658,14 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53644
53658
|
if (isNormalMode &&
|
|
53645
53659
|
(installEvidenceObserved ||
|
|
53646
53660
|
this.hasProtocolV2InstallVersionChanged(expectedTargetIds))) {
|
|
53647
|
-
Log$
|
|
53661
|
+
Log$7.log('[FirmwareUpdateV4] firmware status endpoint unavailable after confirmed App reboot');
|
|
53648
53662
|
this.postProgressMessage(100, 'installingFirmware');
|
|
53649
53663
|
return;
|
|
53650
53664
|
}
|
|
53651
53665
|
if (isNormalMode) {
|
|
53652
|
-
const now = Date.now();
|
|
53653
|
-
normalModeWithoutInstallEvidenceSince !== null && normalModeWithoutInstallEvidenceSince !== void 0 ? normalModeWithoutInstallEvidenceSince : (normalModeWithoutInstallEvidenceSince = now);
|
|
53654
|
-
if (now - normalModeWithoutInstallEvidenceSince >=
|
|
53655
|
-
PROTOCOL_V2_MISSING_TARGET_STATUS_GRACE_TIMEOUT) {
|
|
53656
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, 'Protocol V2 device returned to normal mode without install ACK, target status, or version change');
|
|
53657
|
-
}
|
|
53658
53666
|
lastError = new Error('Protocol V2 device is in normal mode but installation is not yet confirmed');
|
|
53659
53667
|
}
|
|
53660
53668
|
else {
|
|
53661
|
-
normalModeWithoutInstallEvidenceSince = undefined;
|
|
53662
53669
|
lastError = new Error('Protocol V2 firmware status endpoint is unavailable while the device remains in loader mode');
|
|
53663
53670
|
}
|
|
53664
53671
|
}
|
|
@@ -53666,7 +53673,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53666
53673
|
shouldReconnect = true;
|
|
53667
53674
|
deviceInfo = undefined;
|
|
53668
53675
|
lastError = error;
|
|
53669
|
-
Log$
|
|
53676
|
+
Log$7.log('[FirmwareUpdateV4] DeviceFirmwareUpdateStatusGet unavailable during install: ', error);
|
|
53670
53677
|
}
|
|
53671
53678
|
}
|
|
53672
53679
|
}
|
|
@@ -53684,12 +53691,14 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53684
53691
|
}
|
|
53685
53692
|
shouldReconnect = true;
|
|
53686
53693
|
deviceInfo = undefined;
|
|
53687
|
-
|
|
53688
|
-
Log$6.log('Protocol V2 firmware install device readiness probe failed: ', error);
|
|
53694
|
+
Log$7.log('Protocol V2 firmware install device readiness probe failed: ', error);
|
|
53689
53695
|
}
|
|
53690
53696
|
yield hdShared.wait(1000);
|
|
53691
53697
|
}
|
|
53692
|
-
|
|
53698
|
+
Log$7.error(`[FirmwareUpdateV4] install timed out after ${PROTOCOL_V2_INSTALL_TIMEOUT / 1000}s: ${this.normalizeErrorMessage(lastError)}`);
|
|
53699
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, undefined, {
|
|
53700
|
+
firmwareUpdateCode: PROTOCOL_V2_INSTALL_TIMEOUT_CODE,
|
|
53701
|
+
});
|
|
53693
53702
|
});
|
|
53694
53703
|
}
|
|
53695
53704
|
exitProtocolV2BootloaderToNormal() {
|
|
@@ -53698,12 +53707,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53698
53707
|
const deviceInfo = yield this.verifyProtocolV2ReconnectIdentity();
|
|
53699
53708
|
try {
|
|
53700
53709
|
if (yield this.probeProtocolV2NormalMode(deviceInfo)) {
|
|
53701
|
-
Log$
|
|
53710
|
+
Log$7.log('[FirmwareUpdateV4] device already returned to App mode; skip Normal reboot');
|
|
53702
53711
|
return;
|
|
53703
53712
|
}
|
|
53704
53713
|
}
|
|
53705
53714
|
catch (error) {
|
|
53706
|
-
Log$
|
|
53715
|
+
Log$7.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
53707
53716
|
}
|
|
53708
53717
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
53709
53718
|
this.protocolV2ExecutionInLoader = false;
|
|
@@ -53731,7 +53740,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53731
53740
|
const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
|
|
53732
53741
|
this.protocolV2LatestFinalFeatures = features;
|
|
53733
53742
|
if (firmwareVersion === '0.0.0') {
|
|
53734
|
-
Log$
|
|
53743
|
+
Log$7.warn('Protocol V2 firmware update finished but app firmware version is still 0.0.0. This is allowed for Pro2 debug BLE-only update flows.');
|
|
53735
53744
|
}
|
|
53736
53745
|
return {
|
|
53737
53746
|
bootloaderVersion,
|
|
@@ -53780,7 +53789,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53780
53789
|
}
|
|
53781
53790
|
shouldReconnect = true;
|
|
53782
53791
|
lastError = error;
|
|
53783
|
-
Log$
|
|
53792
|
+
Log$7.log('Protocol V2 normal mode not ready, polling Ping: ', error);
|
|
53784
53793
|
}
|
|
53785
53794
|
yield hdShared.wait(1000);
|
|
53786
53795
|
}
|
|
@@ -53824,7 +53833,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53824
53833
|
if (!reconnectDevice) {
|
|
53825
53834
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
|
|
53826
53835
|
}
|
|
53827
|
-
Log$
|
|
53836
|
+
Log$7.debug('Protocol V2 firmware reconnect using matched device:', reconnectDevice.getConnectId());
|
|
53828
53837
|
this.device.updateFromCache(reconnectDevice);
|
|
53829
53838
|
yield this.ensureProtocolV2DeviceAcquired();
|
|
53830
53839
|
this.device.commands.disposed = false;
|
|
@@ -53930,7 +53939,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53930
53939
|
}
|
|
53931
53940
|
}
|
|
53932
53941
|
|
|
53933
|
-
const Log$
|
|
53942
|
+
const Log$6 = getLogger(exports.LoggerNames.Method);
|
|
53934
53943
|
class PromptWebDeviceAccess extends BaseMethod {
|
|
53935
53944
|
init() {
|
|
53936
53945
|
this.useDevice = false;
|
|
@@ -53985,7 +53994,7 @@ class PromptWebDeviceAccess extends BaseMethod {
|
|
|
53985
53994
|
return { device: null };
|
|
53986
53995
|
}
|
|
53987
53996
|
catch (error) {
|
|
53988
|
-
Log$
|
|
53997
|
+
Log$6.debug(error);
|
|
53989
53998
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
|
|
53990
53999
|
}
|
|
53991
54000
|
});
|
|
@@ -54088,7 +54097,7 @@ function decodeJpegBase64ToRgba({ jpegBase64, parameterName, expectedWidth, expe
|
|
|
54088
54097
|
return decoded;
|
|
54089
54098
|
}
|
|
54090
54099
|
|
|
54091
|
-
const Log$
|
|
54100
|
+
const Log$5 = getLogger(exports.LoggerNames.Core);
|
|
54092
54101
|
const MIN_FILE_CHUNK_SIZE = 64;
|
|
54093
54102
|
const FILE_TRANSFER_RATE_WINDOW_MS = 1000;
|
|
54094
54103
|
const FILE_TRANSFER_LOG_INTERVAL_MS = 10000;
|
|
@@ -54109,7 +54118,7 @@ function logFileTransferMetrics({ transport, status, path, transferredBytes, tot
|
|
|
54109
54118
|
const segmentedMetrics = measuredAttempts > 0
|
|
54110
54119
|
? ` hostWriteTotal=${(hostWriteElapsedMs / 1000).toFixed(2)}s responseWaitTotal=${(responseWaitElapsedMs / 1000).toFixed(2)}s measuredAttempts=${measuredAttempts}`
|
|
54111
54120
|
: '';
|
|
54112
|
-
Log$
|
|
54121
|
+
Log$5.log(`[FileWrite] metrics transport=${transport} status=${status} path=${path} bytes=${transferredBytes}/${totalBytes} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatFileTransferRate(rateBytesPerSecond)} KiB/s${segmentedMetrics}`);
|
|
54113
54122
|
}
|
|
54114
54123
|
function isProtocolV2ResponseTimeout(error) {
|
|
54115
54124
|
var _a, _b;
|
|
@@ -54200,7 +54209,7 @@ function writeProtocolV2File(options) {
|
|
|
54200
54209
|
let responseWaitElapsedMs = 0;
|
|
54201
54210
|
let measuredAttempts = 0;
|
|
54202
54211
|
const transport = getFileTransferTransport();
|
|
54203
|
-
Log$
|
|
54212
|
+
Log$5.log(`[FileWrite] started transport=${transport} path=${options.path} bytes=${dataLength} offset=${startOffset} chunk=${chunkSize}`);
|
|
54204
54213
|
try {
|
|
54205
54214
|
while (written < dataLength) {
|
|
54206
54215
|
(_c = options.throwIfAborted) === null || _c === void 0 ? void 0 : _c.call(options);
|
|
@@ -54367,6 +54376,7 @@ const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
|
|
|
54367
54376
|
const DEVICE_SETTINGS_SET_MESSAGE_TYPE = 60412;
|
|
54368
54377
|
const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE$2 = 60805;
|
|
54369
54378
|
const FILESYSTEM_DIR_MAKE_MESSAGE_TYPE = 60809;
|
|
54379
|
+
const Log$4 = getLogger(exports.LoggerNames.Method);
|
|
54370
54380
|
function normalizeFileName(fileName, data) {
|
|
54371
54381
|
if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
|
|
54372
54382
|
throw invalidParameter$1('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
|
|
@@ -54474,6 +54484,14 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
54474
54484
|
const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
|
|
54475
54485
|
settings: { wallpaper_path: this.path },
|
|
54476
54486
|
});
|
|
54487
|
+
try {
|
|
54488
|
+
yield this.device.refreshProtocolV2SettingsAfterMutation();
|
|
54489
|
+
}
|
|
54490
|
+
catch (error) {
|
|
54491
|
+
Log$4.warn('Protocol V2 wallpaper settings refresh failed after apply', {
|
|
54492
|
+
error: error instanceof Error ? error.message : String(error),
|
|
54493
|
+
});
|
|
54494
|
+
}
|
|
54477
54495
|
return {
|
|
54478
54496
|
path: this.path,
|
|
54479
54497
|
size: encoded.data.byteLength,
|
|
@@ -64995,6 +65013,7 @@ const createUiProgressMessageFilter = (intervalMs = DEFAULT_UI_PROGRESS_INTERVAL
|
|
|
64995
65013
|
|
|
64996
65014
|
const Log = getLogger(exports.LoggerNames.Core);
|
|
64997
65015
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
65016
|
+
const PRE_PENDING_CALL_TIMEOUT_MS = 15 * 1000;
|
|
64998
65017
|
const preWarmInflight = new Map();
|
|
64999
65018
|
const preWarmDoneAt = new Map();
|
|
65000
65019
|
function hasDeriveCardano(method) {
|
|
@@ -65150,29 +65169,40 @@ const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void
|
|
|
65150
65169
|
}
|
|
65151
65170
|
}
|
|
65152
65171
|
});
|
|
65153
|
-
const
|
|
65154
|
-
const
|
|
65155
|
-
setTimeout(() => reject(new Error('Request timeout')), timeout);
|
|
65156
|
-
});
|
|
65157
|
-
return Promise.race([promise, timeoutPromise]);
|
|
65158
|
-
});
|
|
65159
|
-
const waitForPendingPromise = (getPrePendingCallPromise, removePrePendingCallPromise) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65160
|
-
const pendingPromise = getPrePendingCallPromise();
|
|
65172
|
+
const waitForPendingPromise = (connectId, getPrePendingCallPromise, removePrePendingCallPromise) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65173
|
+
const pendingPromise = getPrePendingCallPromise(connectId);
|
|
65161
65174
|
if (pendingPromise) {
|
|
65162
65175
|
Log.debug('pre pending call promise before call method, wait for it');
|
|
65176
|
+
let timer;
|
|
65177
|
+
let timedOut = false;
|
|
65163
65178
|
try {
|
|
65164
|
-
yield
|
|
65179
|
+
yield Promise.race([
|
|
65180
|
+
pendingPromise,
|
|
65181
|
+
new Promise(resolve => {
|
|
65182
|
+
timer = setTimeout(() => {
|
|
65183
|
+
timedOut = true;
|
|
65184
|
+
resolve();
|
|
65185
|
+
}, PRE_PENDING_CALL_TIMEOUT_MS);
|
|
65186
|
+
}),
|
|
65187
|
+
]);
|
|
65165
65188
|
}
|
|
65166
65189
|
catch (error) {
|
|
65167
65190
|
}
|
|
65168
|
-
|
|
65191
|
+
finally {
|
|
65192
|
+
if (timer)
|
|
65193
|
+
clearTimeout(timer);
|
|
65194
|
+
removePrePendingCallPromise === null || removePrePendingCallPromise === void 0 ? void 0 : removePrePendingCallPromise(connectId, pendingPromise);
|
|
65195
|
+
}
|
|
65196
|
+
if (timedOut) {
|
|
65197
|
+
Log.warn('pre pending call promise timed out before call method', { connectId });
|
|
65198
|
+
}
|
|
65169
65199
|
Log.debug('pre pending call promise before call method done');
|
|
65170
65200
|
}
|
|
65171
65201
|
});
|
|
65172
65202
|
const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65173
|
-
var _d, _e, _f, _g, _h;
|
|
65203
|
+
var _d, _e, _f, _g, _h, _j, _k;
|
|
65174
65204
|
let messageResponse;
|
|
65175
|
-
const { requestQueue, getPrePendingCallPromise,
|
|
65205
|
+
const { requestQueue, getPrePendingCallPromise, removePrePendingCallPromise } = context;
|
|
65176
65206
|
updateMethodRequestContext(method, { status: 'running' });
|
|
65177
65207
|
const normalizePassphraseState = (s) => s || '';
|
|
65178
65208
|
const connectStateChange = normalizePassphraseState(preConnectCache.passphraseState) !==
|
|
@@ -65187,7 +65217,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65187
65217
|
if (method.connectId) {
|
|
65188
65218
|
yield context.waitForCallbackTasks(method.connectId);
|
|
65189
65219
|
}
|
|
65190
|
-
yield waitForPendingPromise(getPrePendingCallPromise,
|
|
65220
|
+
yield waitForPendingPromise((_d = method.connectId) !== null && _d !== void 0 ? _d : '', getPrePendingCallPromise, removePrePendingCallPromise);
|
|
65191
65221
|
const task = requestQueue.createTask(method);
|
|
65192
65222
|
let preWarmCallbackTask;
|
|
65193
65223
|
if (method.isPreWarmSignal && method.connectId) {
|
|
@@ -65196,9 +65226,9 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65196
65226
|
}
|
|
65197
65227
|
let device;
|
|
65198
65228
|
try {
|
|
65199
|
-
const connectId = (
|
|
65229
|
+
const connectId = (_e = method.connectId) !== null && _e !== void 0 ? _e : '';
|
|
65200
65230
|
const pollingId = pollingManager.start(connectId);
|
|
65201
|
-
device = yield ensureConnected(context, method, connectId, pollingId, (
|
|
65231
|
+
device = yield ensureConnected(context, method, connectId, pollingId, (_f = task.abortController) === null || _f === void 0 ? void 0 : _f.signal);
|
|
65202
65232
|
}
|
|
65203
65233
|
catch (e) {
|
|
65204
65234
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
@@ -65213,17 +65243,17 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65213
65243
|
requestQueue.releaseTask(method.responseID);
|
|
65214
65244
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
65215
65245
|
}
|
|
65216
|
-
if ((
|
|
65246
|
+
if ((_g = method.payload) === null || _g === void 0 ? void 0 : _g.onlyConnectBleDevice) {
|
|
65217
65247
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
65218
65248
|
Log.debug('Call API - only connect ble device: ', device === null || device === void 0 ? void 0 : device.mainId);
|
|
65219
65249
|
return createResponseMessage(method.responseID, true, null);
|
|
65220
65250
|
}
|
|
65221
65251
|
Log.debug('Call API - setDevice: ', device.mainId);
|
|
65222
|
-
(
|
|
65252
|
+
(_h = method.setDevice) === null || _h === void 0 ? void 0 : _h.call(method, device);
|
|
65223
65253
|
method.context = context;
|
|
65224
65254
|
updateMethodRequestContext(method, {
|
|
65225
65255
|
deviceInstanceId: device.instanceId,
|
|
65226
|
-
commandsInstanceId: (
|
|
65256
|
+
commandsInstanceId: (_j = device.commands) === null || _j === void 0 ? void 0 : _j.instanceId,
|
|
65227
65257
|
});
|
|
65228
65258
|
const activeRequests = getActiveRequestsByDeviceInstance(device.instanceId);
|
|
65229
65259
|
if (activeRequests.length > 0) {
|
|
@@ -65252,14 +65282,14 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65252
65282
|
if (method.connectId) {
|
|
65253
65283
|
yield context.waitForCallbackTasks(method.connectId, preWarmCallbackTask);
|
|
65254
65284
|
}
|
|
65255
|
-
yield waitForPendingPromise(getPrePendingCallPromise,
|
|
65285
|
+
yield waitForPendingPromise((_k = method.connectId) !== null && _k !== void 0 ? _k : '', getPrePendingCallPromise, removePrePendingCallPromise);
|
|
65256
65286
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65257
|
-
var
|
|
65287
|
+
var _l, _m;
|
|
65258
65288
|
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
65259
65289
|
protocolV2Operation = device.isProtocolV2();
|
|
65260
65290
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
65261
|
-
const currentFirmwareVersion = (
|
|
65262
|
-
const currentBleVersion = (
|
|
65291
|
+
const currentFirmwareVersion = (_l = device.getCurrentFirmwareVersionString()) !== null && _l !== void 0 ? _l : '0.0.0';
|
|
65292
|
+
const currentBleVersion = (_m = device.getCurrentBLEFirmwareVersionString()) !== null && _m !== void 0 ? _m : '0.0.0';
|
|
65263
65293
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
65264
65294
|
let newVersionStatus;
|
|
65265
65295
|
if (device.features && !device.isProtocolV2()) {
|
|
@@ -65337,7 +65367,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65337
65367
|
}
|
|
65338
65368
|
},
|
|
65339
65369
|
prepare: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65340
|
-
var
|
|
65370
|
+
var _o, _p, _q, _r, _s;
|
|
65341
65371
|
if (method.deviceId && method.checkDeviceId && !deviceIdCheckedDuringUnlockPreflight) {
|
|
65342
65372
|
const isSameDeviceID = yield checkLiveDeviceId(device, method.deviceId);
|
|
65343
65373
|
if (!isSameDeviceID) {
|
|
@@ -65357,7 +65387,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65357
65387
|
require: support.require,
|
|
65358
65388
|
});
|
|
65359
65389
|
}
|
|
65360
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((
|
|
65390
|
+
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_o = method.payload) === null || _o === void 0 ? void 0 : _o.passphraseState, (_p = method.payload) === null || _p === void 0 ? void 0 : _p.useEmptyPassphrase, (_q = method.payload) === null || _q === void 0 ? void 0 : _q.skipPassphraseCheck, hasDeriveCardano(method));
|
|
65361
65391
|
checkPassphraseEnableState(method, device.features);
|
|
65362
65392
|
if (!passphraseStateSafety) {
|
|
65363
65393
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -65375,7 +65405,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65375
65405
|
? e
|
|
65376
65406
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
65377
65407
|
}
|
|
65378
|
-
(
|
|
65408
|
+
(_s = (_r = method.device) === null || _r === void 0 ? void 0 : _r.commands) === null || _s === void 0 ? void 0 : _s.checkDisposed();
|
|
65379
65409
|
}),
|
|
65380
65410
|
});
|
|
65381
65411
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
@@ -65571,6 +65601,13 @@ function isRetryableBleProtocolV2ProbeError(method, error) {
|
|
|
65571
65601
|
message.includes('expected V2') &&
|
|
65572
65602
|
message.includes('did not respond to expected protocol'));
|
|
65573
65603
|
}
|
|
65604
|
+
function isMissingDetectedProtocolV2Error(method, error) {
|
|
65605
|
+
const typedError = error;
|
|
65606
|
+
return (method.payload.connectProtocol === 'V2' &&
|
|
65607
|
+
(typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.RuntimeError &&
|
|
65608
|
+
typeof typedError.message === 'string' &&
|
|
65609
|
+
typedError.message.includes('Device protocol has not been detected'));
|
|
65610
|
+
}
|
|
65574
65611
|
function connectDeviceForBle(method, device, retryCount = 0) {
|
|
65575
65612
|
var _a;
|
|
65576
65613
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -65605,7 +65642,8 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65605
65642
|
}
|
|
65606
65643
|
}
|
|
65607
65644
|
catch (err) {
|
|
65608
|
-
|
|
65645
|
+
const requiresColdReconnect = isMissingDetectedProtocolV2Error(method, err);
|
|
65646
|
+
if ((hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) || requiresColdReconnect) &&
|
|
65609
65647
|
device.mainId &&
|
|
65610
65648
|
device.deviceConnector) {
|
|
65611
65649
|
yield device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
@@ -65613,10 +65651,11 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65613
65651
|
}
|
|
65614
65652
|
if ((err.errorCode === hdShared.HardwareErrorCode.BleTimeoutError ||
|
|
65615
65653
|
err.errorCode === hdShared.HardwareErrorCode.BleConnectedError ||
|
|
65616
|
-
isRetryableBleProtocolV2ProbeError(method, err)
|
|
65654
|
+
isRetryableBleProtocolV2ProbeError(method, err) ||
|
|
65655
|
+
requiresColdReconnect) &&
|
|
65617
65656
|
retryCount < 6) {
|
|
65618
65657
|
const nextRetry = retryCount + 1;
|
|
65619
|
-
Log.debug(`Bluetooth
|
|
65658
|
+
Log.debug(`Bluetooth connection will retry, retry count: ${nextRetry}`);
|
|
65620
65659
|
yield wait(3000);
|
|
65621
65660
|
yield connectDeviceForBle(method, device, nextRetry);
|
|
65622
65661
|
}
|
|
@@ -65635,7 +65674,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65635
65674
|
Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
|
|
65636
65675
|
const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65637
65676
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65638
|
-
var
|
|
65677
|
+
var _t;
|
|
65639
65678
|
const abort = () => {
|
|
65640
65679
|
if (abortSignal && abortSignal.aborted) {
|
|
65641
65680
|
if (timer) {
|
|
@@ -65750,7 +65789,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65750
65789
|
clearTimeout(timer);
|
|
65751
65790
|
}
|
|
65752
65791
|
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
65753
|
-
if (DataManager.isBrowserWebUsb(env) && !((
|
|
65792
|
+
if (DataManager.isBrowserWebUsb(env) && !((_t = method.payload) === null || _t === void 0 ? void 0 : _t.skipWebDevicePrompt)) {
|
|
65754
65793
|
postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
|
|
65755
65794
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
|
|
65756
65795
|
}
|
|
@@ -65768,7 +65807,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65768
65807
|
return poll();
|
|
65769
65808
|
});
|
|
65770
65809
|
const cancel = (context, connectId) => {
|
|
65771
|
-
var _a, _b;
|
|
65810
|
+
var _a, _b, _c;
|
|
65772
65811
|
const { requestQueue, setPrePendingCallPromise } = context;
|
|
65773
65812
|
if (connectId) {
|
|
65774
65813
|
try {
|
|
@@ -65782,7 +65821,7 @@ const cancel = (context, connectId) => {
|
|
|
65782
65821
|
if (task && ((_a = task.method) === null || _a === void 0 ? void 0 : _a.device)) {
|
|
65783
65822
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65784
65823
|
const { device } = task.method;
|
|
65785
|
-
setPrePendingCallPromise(
|
|
65824
|
+
setPrePendingCallPromise((_b = task.method.connectId) !== null && _b !== void 0 ? _b : connectId, device.interruptionFromUser());
|
|
65786
65825
|
canceledDevices.push(device);
|
|
65787
65826
|
}
|
|
65788
65827
|
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled));
|
|
@@ -65802,7 +65841,7 @@ const cancel = (context, connectId) => {
|
|
|
65802
65841
|
for (const requestId of requestQueue.getRequestTasksId()) {
|
|
65803
65842
|
const task = requestQueue.getTask(requestId);
|
|
65804
65843
|
Log.debug('Cancel Api connect task: ', task);
|
|
65805
|
-
if (task && ((
|
|
65844
|
+
if (task && ((_c = task.method) === null || _c === void 0 ? void 0 : _c.device)) {
|
|
65806
65845
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65807
65846
|
const { device } = task.method;
|
|
65808
65847
|
device === null || device === void 0 ? void 0 : device.interruptionFromUser();
|
|
@@ -65991,6 +66030,7 @@ class Core extends events.exports {
|
|
|
65991
66030
|
constructor() {
|
|
65992
66031
|
super();
|
|
65993
66032
|
this.requestQueue = new RequestQueue();
|
|
66033
|
+
this.prePendingCallPromises = new Map();
|
|
65994
66034
|
this.methodSynchronize = getSynchronize();
|
|
65995
66035
|
this.tracingContext = createSdkTracingContext();
|
|
65996
66036
|
this.sdkInstanceId = this.tracingContext.sdkInstanceId;
|
|
@@ -66002,9 +66042,18 @@ class Core extends events.exports {
|
|
|
66002
66042
|
tracingContext: this.tracingContext,
|
|
66003
66043
|
requestQueue: this.requestQueue,
|
|
66004
66044
|
methodSynchronize: this.methodSynchronize,
|
|
66005
|
-
getPrePendingCallPromise: () => this.
|
|
66006
|
-
setPrePendingCallPromise: (promise) => {
|
|
66007
|
-
|
|
66045
|
+
getPrePendingCallPromise: (connectId) => this.prePendingCallPromises.get(connectId),
|
|
66046
|
+
setPrePendingCallPromise: (connectId, promise) => {
|
|
66047
|
+
if (!promise) {
|
|
66048
|
+
this.prePendingCallPromises.delete(connectId);
|
|
66049
|
+
return;
|
|
66050
|
+
}
|
|
66051
|
+
this.prePendingCallPromises.set(connectId, promise);
|
|
66052
|
+
},
|
|
66053
|
+
removePrePendingCallPromise: (connectId, promise) => {
|
|
66054
|
+
if (this.prePendingCallPromises.get(connectId) === promise) {
|
|
66055
|
+
this.prePendingCallPromises.delete(connectId);
|
|
66056
|
+
}
|
|
66008
66057
|
},
|
|
66009
66058
|
registerCallbackTask: (connectId, callbackPromise) => {
|
|
66010
66059
|
this.requestQueue.registerPendingCallbackTask(connectId, callbackPromise);
|
|
@@ -66098,7 +66147,7 @@ class Core extends events.exports {
|
|
|
66098
66147
|
preWarmInflight.clear();
|
|
66099
66148
|
preWarmDoneAt.clear();
|
|
66100
66149
|
preConnectCache = { passphraseState: undefined };
|
|
66101
|
-
this.
|
|
66150
|
+
this.prePendingCallPromises.clear();
|
|
66102
66151
|
this.removeAllListeners();
|
|
66103
66152
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
66104
66153
|
if (_core === this)
|