@onekeyfe/hd-core 1.2.0-alpha.20 → 1.2.0-alpha.21
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__/device-lifecycle-events.test.ts +1 -1
- package/__tests__/device-settings.test.ts +110 -5
- package/__tests__/device-state-events.test.ts +3 -3
- package/__tests__/device-state-mapper.test.ts +15 -3
- package/__tests__/device-state-store.test.ts +1 -1
- package/__tests__/deviceSettings.test.ts +55 -15
- package/__tests__/evmLedgerLegacySafety.test.ts +6 -5
- package/__tests__/get-device-state.test.ts +7 -0
- package/__tests__/protocol-v2.test.ts +40 -153
- package/__tests__/public-device-state-api.test.ts +19 -15
- package/__tests__/public-pro2-api-boundary.test.ts +20 -1
- package/dist/api/BaseMethod.d.ts +0 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +0 -1
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -1
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +1 -19
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +1 -1
- package/dist/device/DeviceFeaturesState.d.ts +0 -1
- package/dist/device/DeviceFeaturesState.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/events/call.d.ts +0 -7
- package/dist/events/call.d.ts.map +1 -1
- package/dist/events/core.d.ts +2 -2
- package/dist/events/core.d.ts.map +1 -1
- package/dist/events/iframe.d.ts +0 -1
- package/dist/events/iframe.d.ts.map +1 -1
- package/dist/index.d.ts +59 -55
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +169 -310
- package/dist/inject.d.ts +2 -3
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts +1 -2
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +2 -2
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +2 -2
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +1 -5
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +1 -9
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +4 -4
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +36 -7
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +3 -9
- package/src/api/UploadPortfolio.ts +2 -12
- package/src/api/device/DeviceSettings.ts +66 -5
- package/src/api/device/DeviceUnlock.ts +2 -1
- package/src/api/index.ts +0 -3
- package/src/core/RequestQueue.ts +4 -123
- package/src/core/index.ts +25 -31
- package/src/device/Device.ts +1 -1
- package/src/device/DeviceFeaturesState.ts +0 -9
- package/src/device/DeviceStateMapper.ts +8 -7
- package/src/deviceProfile/buildDeviceFeatures.ts +2 -1
- package/src/events/call.ts +0 -6
- package/src/events/core.ts +0 -2
- package/src/events/iframe.ts +0 -1
- package/src/index.ts +0 -4
- package/src/inject.ts +0 -10
- package/src/lowLevelInject.ts +0 -3
- package/src/topLevelInject.ts +0 -2
- package/src/types/api/deviceSettings.ts +17 -2
- package/src/types/api/deviceUnlock.ts +5 -2
- package/src/types/api/index.ts +0 -7
- package/src/types/api/protocolV2.ts +0 -31
- package/src/types/device.ts +5 -3
- package/src/utils/deviceSettings.ts +130 -56
- package/src/utils/index.ts +18 -1
- package/__tests__/RequestQueue.test.ts +0 -140
- package/__tests__/UploadPortfolio.test.ts +0 -46
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +0 -16
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +0 -12
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +0 -1
- package/src/api/protocol-v2/DeviceSettingsGet.ts +0 -18
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +0 -70
- package/src/api/protocol-v2/DeviceSettingsSet.ts +0 -44
package/dist/index.js
CHANGED
|
@@ -101,7 +101,7 @@ const executeCallback = (id, ...args) => {
|
|
|
101
101
|
const cleanupCallback = (id) => {
|
|
102
102
|
callbackManager.delete(id);
|
|
103
103
|
};
|
|
104
|
-
const inject = ({ call, cancel,
|
|
104
|
+
const inject = ({ call, cancel, dispose, eventEmitter, init, updateSettings, switchTransport, uiResponse, }) => {
|
|
105
105
|
const api = Object.assign({ on: (type, fn) => {
|
|
106
106
|
eventEmitter.on(type, fn);
|
|
107
107
|
}, emit: () => { }, off: (type, fn) => {
|
|
@@ -113,7 +113,6 @@ const inject = ({ call, cancel, cancelOperation, dispose, eventEmitter, init, up
|
|
|
113
113
|
dispose,
|
|
114
114
|
uiResponse,
|
|
115
115
|
cancel,
|
|
116
|
-
cancelOperation,
|
|
117
116
|
updateSettings,
|
|
118
117
|
switchTransport }, createCoreApi(call));
|
|
119
118
|
return api;
|
|
@@ -148,15 +147,12 @@ const createCoreApi = (call) => ({
|
|
|
148
147
|
deviceUploadWallpaper: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceUploadWallpaper' })),
|
|
149
148
|
deviceInfoGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceInfoGet' })),
|
|
150
149
|
deviceStatusGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceStatusGet' })),
|
|
151
|
-
deviceSettingsGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettingsGet' })),
|
|
152
150
|
protocolInfoRequest: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'protocolInfoRequest' })),
|
|
153
151
|
ping: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'ping' })),
|
|
154
152
|
deviceFirmwareUpdate: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFirmwareUpdate' })),
|
|
155
153
|
deviceGetFirmwareUpdateStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetFirmwareUpdateStatus' })),
|
|
156
154
|
deviceFactoryInfoSet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFactoryInfoSet' })),
|
|
157
155
|
deviceFactoryInfoGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFactoryInfoGet' })),
|
|
158
|
-
deviceSettingsSet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettingsSet' })),
|
|
159
|
-
deviceSettingsPageShow: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettingsPageShow' })),
|
|
160
156
|
filesystemPermissionFix: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemPermissionFix' })),
|
|
161
157
|
filesystemFormat: connectId => call({ connectId, method: 'filesystemFormat' }),
|
|
162
158
|
uploadPortfolio: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'uploadPortfolio' })),
|
|
@@ -295,7 +291,7 @@ const createCoreApi = (call) => ({
|
|
|
295
291
|
neoSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'neoSignTransaction' })),
|
|
296
292
|
});
|
|
297
293
|
|
|
298
|
-
const lowLevelInject = ({ call, cancel,
|
|
294
|
+
const lowLevelInject = ({ call, cancel, dispose, eventEmitter, init, uiResponse, updateSettings, switchTransport, addHardwareGlobalEventListener, }) => {
|
|
299
295
|
const api = Object.assign({ addHardwareGlobalEventListener, removeAllListeners: type => {
|
|
300
296
|
eventEmitter.removeAllListeners(type);
|
|
301
297
|
}, init,
|
|
@@ -303,7 +299,6 @@ const lowLevelInject = ({ call, cancel, cancelOperation, dispose, eventEmitter,
|
|
|
303
299
|
dispose,
|
|
304
300
|
uiResponse,
|
|
305
301
|
cancel,
|
|
306
|
-
cancelOperation,
|
|
307
302
|
updateSettings,
|
|
308
303
|
switchTransport, emit: () => { } }, createCoreApi(call));
|
|
309
304
|
return api;
|
|
@@ -806,7 +801,7 @@ const topLevelInject = () => {
|
|
|
806
801
|
}, call }, createCoreApi(call)), { removeAllListeners: type => {
|
|
807
802
|
eventEmitter.removeAllListeners(type);
|
|
808
803
|
lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.removeAllListeners(type);
|
|
809
|
-
}, dispose: () => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.dispose(), uiResponse: response => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.uiResponse(response), cancel: (connectId) => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.cancel(connectId),
|
|
804
|
+
}, dispose: () => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.dispose(), uiResponse: response => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.uiResponse(response), cancel: (connectId) => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.cancel(connectId), updateSettings: settings => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.updateSettings(settings)) !== null && _a !== void 0 ? _a : Promise.resolve(false); }, switchTransport: (env) => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.switchTransport(env)) !== null && _a !== void 0 ? _a : Promise.resolve({ success: false }); } });
|
|
810
805
|
return api;
|
|
811
806
|
};
|
|
812
807
|
|
|
@@ -40316,6 +40311,40 @@ function checkBootloaderLength(data) {
|
|
|
40316
40311
|
return bootloaderLength === data.byteLength;
|
|
40317
40312
|
}
|
|
40318
40313
|
|
|
40314
|
+
const DEVICE_SETTINGS_SHARED_FIELDS = [
|
|
40315
|
+
'language',
|
|
40316
|
+
'label',
|
|
40317
|
+
'usePassphrase',
|
|
40318
|
+
'autoLockDelayMs',
|
|
40319
|
+
'autoShutdownDelayMs',
|
|
40320
|
+
'hapticFeedback',
|
|
40321
|
+
'bluetoothEnabled',
|
|
40322
|
+
];
|
|
40323
|
+
const DEVICE_SETTINGS_V1_ONLY_FIELDS = [
|
|
40324
|
+
'homescreen',
|
|
40325
|
+
'passphraseSource',
|
|
40326
|
+
'displayRotation',
|
|
40327
|
+
'passphraseAlwaysOnDevice',
|
|
40328
|
+
'safetyChecks',
|
|
40329
|
+
'experimentalFeatures',
|
|
40330
|
+
'changeBrightness',
|
|
40331
|
+
];
|
|
40332
|
+
const DEVICE_SETTINGS_V2_ONLY_FIELDS = [
|
|
40333
|
+
'brightness',
|
|
40334
|
+
'airgapMode',
|
|
40335
|
+
'animationEnabled',
|
|
40336
|
+
'tapToWake',
|
|
40337
|
+
'deviceNameDisplayEnabled',
|
|
40338
|
+
'fidoEnabled',
|
|
40339
|
+
'usbLockEnabled',
|
|
40340
|
+
'randomKeypad',
|
|
40341
|
+
];
|
|
40342
|
+
const PROTOCOL_V2_NEVER_TIMEOUT_MS = 0x10000000;
|
|
40343
|
+
const normalizeSafetyCheckLevel = (value) => {
|
|
40344
|
+
if (typeof value === 'number' || value === null || value === undefined)
|
|
40345
|
+
return value;
|
|
40346
|
+
return hdTransport.Enum_SafetyCheckLevel[value];
|
|
40347
|
+
};
|
|
40319
40348
|
const LANGUAGE_LABELS = {
|
|
40320
40349
|
en: 'English',
|
|
40321
40350
|
zh_cn: '简体中文',
|
|
@@ -40343,6 +40372,8 @@ const PROTOCOL_V2_LANGUAGE_BY_KEY = {
|
|
|
40343
40372
|
pt_br: 'pt-Latn-BR',
|
|
40344
40373
|
};
|
|
40345
40374
|
const mapLanguageToProtocolV2 = (language) => { var _a; return language ? (_a = PROTOCOL_V2_LANGUAGE_BY_KEY[language]) !== null && _a !== void 0 ? _a : language : undefined; };
|
|
40375
|
+
const PROTOCOL_V2_LANGUAGE_KEY_BY_TAG = Object.fromEntries(Object.entries(PROTOCOL_V2_LANGUAGE_BY_KEY).map(([key, tag]) => [tag, key]));
|
|
40376
|
+
const mapLanguageFromProtocolV2 = (language) => { var _a; return language ? (_a = PROTOCOL_V2_LANGUAGE_KEY_BY_TAG[language]) !== null && _a !== void 0 ? _a : language : undefined; };
|
|
40346
40377
|
const PRO2_LANGUAGE_OPTIONS = [
|
|
40347
40378
|
...Object.entries(LANGUAGE_LABELS).map(([code, label]) => ({ code, label })),
|
|
40348
40379
|
{ code: 'zh-Hant-TW', label: '繁體中文(台灣)' },
|
|
@@ -40375,80 +40406,67 @@ const getLanguageConfig = (deviceType) => {
|
|
|
40375
40406
|
}
|
|
40376
40407
|
return keys.map(key => ({ code: key, label: LANGUAGE_LABELS[key] }));
|
|
40377
40408
|
};
|
|
40378
|
-
const
|
|
40379
|
-
|
|
40409
|
+
const durationOption = (valueMs) => {
|
|
40410
|
+
if (valueMs === 0 || valueMs === PROTOCOL_V2_NEVER_TIMEOUT_MS) {
|
|
40411
|
+
return { label: 'Never', valueMs };
|
|
40412
|
+
}
|
|
40413
|
+
if (valueMs < 60000) {
|
|
40414
|
+
return { label: `${valueMs / 1000} seconds`, valueMs };
|
|
40415
|
+
}
|
|
40416
|
+
const minutes = valueMs / 60000;
|
|
40417
|
+
return { label: `${minutes} ${minutes === 1 ? 'minute' : 'minutes'}`, valueMs };
|
|
40418
|
+
};
|
|
40419
|
+
const withNever = (values, protocol) => [...values, protocol === 'V2' ? PROTOCOL_V2_NEVER_TIMEOUT_MS : 0].map(durationOption);
|
|
40420
|
+
const getAutoLockOptions = (deviceType, protocol) => {
|
|
40421
|
+
switch (deviceType) {
|
|
40380
40422
|
case hdShared.EDeviceType.Mini:
|
|
40381
40423
|
case hdShared.EDeviceType.Classic:
|
|
40382
40424
|
case hdShared.EDeviceType.Classic1s:
|
|
40383
40425
|
case hdShared.EDeviceType.ClassicPure:
|
|
40384
|
-
return [
|
|
40385
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
40386
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
40387
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
40388
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
40389
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
40390
|
-
];
|
|
40426
|
+
return withNever([60000, 120000, 300000, 600000], protocol);
|
|
40391
40427
|
case hdShared.EDeviceType.Touch:
|
|
40392
40428
|
case hdShared.EDeviceType.Pro:
|
|
40393
|
-
return [
|
|
40394
|
-
{ seconds: 30, minute: 0, hour: 0, day: 0 },
|
|
40395
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
40396
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
40397
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
40398
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
40399
|
-
{ seconds: 0, minute: 30, hour: 0, day: 0 },
|
|
40400
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
40401
|
-
];
|
|
40402
40429
|
case hdShared.EDeviceType.Pro2:
|
|
40403
|
-
return [
|
|
40404
|
-
{ seconds: 30, minute: 0, hour: 0, day: 0 },
|
|
40405
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
40406
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
40407
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
40408
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
40409
|
-
{ seconds: 0, minute: 30, hour: 0, day: 0 },
|
|
40410
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
40411
|
-
];
|
|
40430
|
+
return withNever([30000, 60000, 120000, 300000, 600000, 1800000], protocol);
|
|
40412
40431
|
default:
|
|
40413
40432
|
return [];
|
|
40414
40433
|
}
|
|
40415
40434
|
};
|
|
40416
|
-
const getAutoShutDownOptions = (
|
|
40417
|
-
switch (
|
|
40435
|
+
const getAutoShutDownOptions = (deviceType, protocol) => {
|
|
40436
|
+
switch (deviceType) {
|
|
40418
40437
|
case hdShared.EDeviceType.Mini:
|
|
40419
40438
|
return [];
|
|
40420
40439
|
case hdShared.EDeviceType.Classic:
|
|
40421
40440
|
case hdShared.EDeviceType.Classic1s:
|
|
40422
40441
|
case hdShared.EDeviceType.ClassicPure:
|
|
40423
|
-
return [
|
|
40424
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
40425
|
-
{ seconds: 0, minute: 3, hour: 0, day: 0 },
|
|
40426
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
40427
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
40428
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
40429
|
-
];
|
|
40442
|
+
return withNever([60000, 180000, 300000, 600000], protocol);
|
|
40430
40443
|
case hdShared.EDeviceType.Touch:
|
|
40431
40444
|
case hdShared.EDeviceType.Pro:
|
|
40432
|
-
return [
|
|
40433
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
40434
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
40435
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
40436
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
40437
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
40438
|
-
];
|
|
40445
|
+
return withNever([60000, 120000, 300000, 600000], protocol);
|
|
40439
40446
|
case hdShared.EDeviceType.Pro2:
|
|
40440
|
-
return [
|
|
40441
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
40442
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
40443
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
40444
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
40445
|
-
{ seconds: 0, minute: 30, hour: 0, day: 0 },
|
|
40446
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
40447
|
-
];
|
|
40447
|
+
return withNever([60000, 120000, 300000, 600000, 1800000], protocol);
|
|
40448
40448
|
default:
|
|
40449
40449
|
return [];
|
|
40450
40450
|
}
|
|
40451
40451
|
};
|
|
40452
|
+
const getDeviceSettingsCapabilities = (deviceType, protocol) => ({
|
|
40453
|
+
protocol,
|
|
40454
|
+
supportedFields: protocol === 'V2'
|
|
40455
|
+
? [...DEVICE_SETTINGS_SHARED_FIELDS, ...DEVICE_SETTINGS_V2_ONLY_FIELDS]
|
|
40456
|
+
: [...DEVICE_SETTINGS_SHARED_FIELDS, ...DEVICE_SETTINGS_V1_ONLY_FIELDS],
|
|
40457
|
+
languageOptions: getLanguageConfig(deviceType),
|
|
40458
|
+
autoLockDelayOptions: getAutoLockOptions(deviceType, protocol),
|
|
40459
|
+
autoShutdownDelayOptions: getAutoShutDownOptions(deviceType, protocol),
|
|
40460
|
+
ranges: protocol === 'V2' ? { brightness: { min: 10, max: 100 } } : {},
|
|
40461
|
+
safetyCheckOptions: protocol === 'V1'
|
|
40462
|
+
? [
|
|
40463
|
+
{ label: 'Strict', value: hdTransport.Enum_SafetyCheckLevel.Strict },
|
|
40464
|
+
{ label: 'Prompt Always', value: hdTransport.Enum_SafetyCheckLevel.PromptAlways },
|
|
40465
|
+
{ label: 'Prompt Temporarily', value: hdTransport.Enum_SafetyCheckLevel.PromptTemporarily },
|
|
40466
|
+
]
|
|
40467
|
+
: [],
|
|
40468
|
+
onDeviceConfirmationFields: protocol === 'V2' ? ['usePassphrase', 'airgapMode'] : [],
|
|
40469
|
+
});
|
|
40452
40470
|
|
|
40453
40471
|
const PRO2_WALLPAPER_WIDTH = 604;
|
|
40454
40472
|
const PRO2_WALLPAPER_HEIGHT = 1024;
|
|
@@ -40976,7 +40994,6 @@ const IFRAME = {
|
|
|
40976
40994
|
INIT_BRIDGE: 'iframe-init-bridge',
|
|
40977
40995
|
CALL: 'iframe-call',
|
|
40978
40996
|
CANCEL: 'iframe-cancel',
|
|
40979
|
-
CANCEL_OPERATION: 'iframe-cancel-operation',
|
|
40980
40997
|
SWITCH_TRANSPORT: 'iframe-switch-transport',
|
|
40981
40998
|
CALLBACK: 'iframe-callback',
|
|
40982
40999
|
};
|
|
@@ -42090,7 +42107,7 @@ const buildProtocolV1FeaturesPayload = (protocolV1Features, previous) => {
|
|
|
42090
42107
|
const bleName = resolveDeviceBleName(features);
|
|
42091
42108
|
const deviceType = resolveDeviceType(features);
|
|
42092
42109
|
const sessionId = (_b = (_a = features.session_id) !== null && _a !== void 0 ? _a : previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _b !== void 0 ? _b : null;
|
|
42093
|
-
return Object.assign(Object.assign({}, features), { protocol: 'V1', protocolVersion: (_d = (_c = features.protocol_version) !== null && _c !== void 0 ? _c : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _d !== void 0 ? _d : 1, deviceType, firmwareType: resolveDeviceFirmwareType(features), model: (_e = features.model) !== null && _e !== void 0 ? _e : null, vendor: (_f = features.vendor) !== null && _f !== void 0 ? _f : null, deviceId: (_g = features.device_id) !== null && _g !== void 0 ? _g : null, serialNo, label: getProtocolV1Label(features), bleName, capabilities: (_h = features.capabilities) !== null && _h !== void 0 ? _h : [], mode: getProtocolV1Mode(features), initialized: (_j = features.initialized) !== null && _j !== void 0 ? _j : null, bootloaderMode: (_k = features.bootloader_mode) !== null && _k !== void 0 ? _k : null, unlocked: (_l = features.unlocked) !== null && _l !== void 0 ? _l : true, firmwarePresent: (_m = features.firmware_present) !== null && _m !== void 0 ? _m : null, passphraseProtection: (_o = features.passphrase_protection) !== null && _o !== void 0 ? _o : null, pinProtection: (_p = features.pin_protection) !== null && _p !== void 0 ? _p : null, backupRequired: (_q = features.needs_backup) !== null && _q !== void 0 ? _q : null, noBackup: (_r = features.no_backup) !== null && _r !== void 0 ? _r : null, unfinishedBackup: (_s = features.unfinished_backup) !== null && _s !== void 0 ? _s : null, recoveryMode: (_t = features.recovery_mode) !== null && _t !== void 0 ? _t : null, language: (_u = features.language) !== null && _u !== void 0 ? _u : null, bleEnabled: (_v = features.ble_enable) !== null && _v !== void 0 ? _v : null, sdCardPresent: (_w = features.sd_card_present) !== null && _w !== void 0 ? _w : null, sdProtection: (_x = features.sd_protection) !== null && _x !== void 0 ? _x : null, wipeCodeProtection: (_y = features.wipe_code_protection) !== null && _y !== void 0 ? _y : null, passphraseAlwaysOnDevice: (_z = features.passphrase_always_on_device) !== null && _z !== void 0 ? _z : null, attachToPinEnabled: (_1 = (_0 = features.attach_to_pin_user) !== null && _0 !== void 0 ? _0 : previous === null || previous === void 0 ? void 0 : previous.attachToPinEnabled) !== null && _1 !== void 0 ? _1 : null, unlockedAttachPin: (_3 = (_2 = features.unlocked_attach_pin) !== null && _2 !== void 0 ? _2 : previous === null || previous === void 0 ? void 0 : previous.unlockedAttachPin) !== null && _3 !== void 0 ? _3 : undefined, safetyChecks: (_4 = features.safety_checks) !== null && _4 !== void 0 ? _4 : null, autoLockDelayMs: (_5 = features.auto_lock_delay_ms) !== null && _5 !== void 0 ? _5 : null, autoShutdownDelayMs: (_6 = features.auto_shutdown_delay_ms) !== null && _6 !== void 0 ? _6 : null, displayRotation: (_7 = features.display_rotation) !== null && _7 !== void 0 ? _7 : null, experimentalFeatures: (_8 = features.experimental_features) !== null && _8 !== void 0 ? _8 : null, wallpaperPath: (_9 = previous === null || previous === void 0 ? void 0 : previous.wallpaperPath) !== null && _9 !== void 0 ? _9 : null, brightness: (_11 = (_10 = features.brightness_prcent) !== null && _10 !== void 0 ? _10 : previous === null || previous === void 0 ? void 0 : previous.brightness) !== null && _11 !== void 0 ? _11 : null, animationEnabled: (_12 = previous === null || previous === void 0 ? void 0 : previous.animationEnabled) !== null && _12 !== void 0 ? _12 : null, tapToWake: (_13 = previous === null || previous === void 0 ? void 0 : previous.tapToWake) !== null && _13 !== void 0 ? _13 : null, hapticFeedback: (_15 = (_14 = features.haptic_feedback) !== null && _14 !== void 0 ? _14 : previous === null || previous === void 0 ? void 0 : previous.hapticFeedback) !== null && _15 !== void 0 ? _15 : null, deviceNameDisplayEnabled: (_16 = previous === null || previous === void 0 ? void 0 : previous.deviceNameDisplayEnabled) !== null && _16 !== void 0 ? _16 : null, airgapMode: (_17 = previous === null || previous === void 0 ? void 0 : previous.airgapMode) !== null && _17 !== void 0 ? _17 : null, fidoEnabled: (_18 = previous === null || previous === void 0 ? void 0 : previous.fidoEnabled) !== null && _18 !== void 0 ? _18 : null, usbLockEnabled: (_19 = previous === null || previous === void 0 ? void 0 : previous.usbLockEnabled) !== null && _19 !== void 0 ? _19 : null, randomKeypad: (_20 = previous === null || previous === void 0 ? void 0 : previous.randomKeypad) !== null && _20 !== void 0 ? _20 : null, firmwareVersion,
|
|
42110
|
+
return Object.assign(Object.assign({}, features), { protocol: 'V1', protocolVersion: (_d = (_c = features.protocol_version) !== null && _c !== void 0 ? _c : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _d !== void 0 ? _d : 1, deviceType, firmwareType: resolveDeviceFirmwareType(features), model: (_e = features.model) !== null && _e !== void 0 ? _e : null, vendor: (_f = features.vendor) !== null && _f !== void 0 ? _f : null, deviceId: (_g = features.device_id) !== null && _g !== void 0 ? _g : null, serialNo, label: getProtocolV1Label(features), bleName, capabilities: (_h = features.capabilities) !== null && _h !== void 0 ? _h : [], mode: getProtocolV1Mode(features), initialized: (_j = features.initialized) !== null && _j !== void 0 ? _j : null, bootloaderMode: (_k = features.bootloader_mode) !== null && _k !== void 0 ? _k : null, unlocked: (_l = features.unlocked) !== null && _l !== void 0 ? _l : true, firmwarePresent: (_m = features.firmware_present) !== null && _m !== void 0 ? _m : null, passphraseProtection: (_o = features.passphrase_protection) !== null && _o !== void 0 ? _o : null, pinProtection: (_p = features.pin_protection) !== null && _p !== void 0 ? _p : null, backupRequired: (_q = features.needs_backup) !== null && _q !== void 0 ? _q : null, noBackup: (_r = features.no_backup) !== null && _r !== void 0 ? _r : null, unfinishedBackup: (_s = features.unfinished_backup) !== null && _s !== void 0 ? _s : null, recoveryMode: (_t = features.recovery_mode) !== null && _t !== void 0 ? _t : null, language: (_u = features.language) !== null && _u !== void 0 ? _u : null, bleEnabled: (_v = features.ble_enable) !== null && _v !== void 0 ? _v : null, sdCardPresent: (_w = features.sd_card_present) !== null && _w !== void 0 ? _w : null, sdProtection: (_x = features.sd_protection) !== null && _x !== void 0 ? _x : null, wipeCodeProtection: (_y = features.wipe_code_protection) !== null && _y !== void 0 ? _y : null, passphraseAlwaysOnDevice: (_z = features.passphrase_always_on_device) !== null && _z !== void 0 ? _z : null, attachToPinEnabled: (_1 = (_0 = features.attach_to_pin_user) !== null && _0 !== void 0 ? _0 : previous === null || previous === void 0 ? void 0 : previous.attachToPinEnabled) !== null && _1 !== void 0 ? _1 : null, unlockedAttachPin: (_3 = (_2 = features.unlocked_attach_pin) !== null && _2 !== void 0 ? _2 : previous === null || previous === void 0 ? void 0 : previous.unlockedAttachPin) !== null && _3 !== void 0 ? _3 : undefined, safetyChecks: (_4 = normalizeSafetyCheckLevel(features.safety_checks)) !== null && _4 !== void 0 ? _4 : null, autoLockDelayMs: (_5 = features.auto_lock_delay_ms) !== null && _5 !== void 0 ? _5 : null, autoShutdownDelayMs: (_6 = features.auto_shutdown_delay_ms) !== null && _6 !== void 0 ? _6 : null, displayRotation: (_7 = features.display_rotation) !== null && _7 !== void 0 ? _7 : null, experimentalFeatures: (_8 = features.experimental_features) !== null && _8 !== void 0 ? _8 : null, wallpaperPath: (_9 = previous === null || previous === void 0 ? void 0 : previous.wallpaperPath) !== null && _9 !== void 0 ? _9 : null, brightness: (_11 = (_10 = features.brightness_prcent) !== null && _10 !== void 0 ? _10 : previous === null || previous === void 0 ? void 0 : previous.brightness) !== null && _11 !== void 0 ? _11 : null, animationEnabled: (_12 = previous === null || previous === void 0 ? void 0 : previous.animationEnabled) !== null && _12 !== void 0 ? _12 : null, tapToWake: (_13 = previous === null || previous === void 0 ? void 0 : previous.tapToWake) !== null && _13 !== void 0 ? _13 : null, hapticFeedback: (_15 = (_14 = features.haptic_feedback) !== null && _14 !== void 0 ? _14 : previous === null || previous === void 0 ? void 0 : previous.hapticFeedback) !== null && _15 !== void 0 ? _15 : null, deviceNameDisplayEnabled: (_16 = previous === null || previous === void 0 ? void 0 : previous.deviceNameDisplayEnabled) !== null && _16 !== void 0 ? _16 : null, airgapMode: (_17 = previous === null || previous === void 0 ? void 0 : previous.airgapMode) !== null && _17 !== void 0 ? _17 : null, fidoEnabled: (_18 = previous === null || previous === void 0 ? void 0 : previous.fidoEnabled) !== null && _18 !== void 0 ? _18 : null, usbLockEnabled: (_19 = previous === null || previous === void 0 ? void 0 : previous.usbLockEnabled) !== null && _19 !== void 0 ? _19 : null, randomKeypad: (_20 = previous === null || previous === void 0 ? void 0 : previous.randomKeypad) !== null && _20 !== void 0 ? _20 : null, firmwareVersion,
|
|
42094
42111
|
bootloaderVersion,
|
|
42095
42112
|
boardVersion,
|
|
42096
42113
|
bleVersion, se01Version: firstMeaningfulVersion(features.onekey_se01_version, previous === null || previous === void 0 ? void 0 : previous.se01Version), se02Version: firstMeaningfulVersion(features.onekey_se02_version, previous === null || previous === void 0 ? void 0 : previous.se02Version), se03Version: firstMeaningfulVersion(features.onekey_se03_version, previous === null || previous === void 0 ? void 0 : previous.se03Version), se04Version: firstMeaningfulVersion(features.onekey_se04_version, previous === null || previous === void 0 ? void 0 : previous.se04Version), se01BootVersion: firstMeaningfulVersion(features.onekey_se01_boot_version, previous === null || previous === void 0 ? void 0 : previous.se01BootVersion), se02BootVersion: firstMeaningfulVersion(features.onekey_se02_boot_version, previous === null || previous === void 0 ? void 0 : previous.se02BootVersion), se03BootVersion: firstMeaningfulVersion(features.onekey_se03_boot_version, previous === null || previous === void 0 ? void 0 : previous.se03BootVersion), se04BootVersion: firstMeaningfulVersion(features.onekey_se04_boot_version, previous === null || previous === void 0 ? void 0 : previous.se04BootVersion), seVersion: (_22 = (_21 = features.se_ver) !== null && _21 !== void 0 ? _21 : previous === null || previous === void 0 ? void 0 : previous.seVersion) !== null && _22 !== void 0 ? _22 : null, verify: {
|
|
@@ -42378,19 +42395,19 @@ const mapApplySettingsToState = (settings) => {
|
|
|
42378
42395
|
autoShutdownDelayMs: settings.auto_shutdown_delay_ms,
|
|
42379
42396
|
displayRotation: settings.display_rotation,
|
|
42380
42397
|
passphraseAlwaysOnDevice: settings.passphrase_always_on_device,
|
|
42381
|
-
safetyChecks: settings.safety_checks,
|
|
42398
|
+
safetyChecks: normalizeSafetyCheckLevel(settings.safety_checks),
|
|
42382
42399
|
experimentalFeatures: settings.experimental_features,
|
|
42383
42400
|
hapticFeedback: settings.haptic_feedback,
|
|
42401
|
+
bleEnabled: settings.use_ble,
|
|
42384
42402
|
});
|
|
42385
42403
|
return Object.assign(Object.assign(Object.assign({}, (Object.keys(identity).length ? { identity } : {})), (Object.keys(status).length ? { status } : {})), (Object.keys(stateSettings).length ? { settings: stateSettings } : {}));
|
|
42386
42404
|
};
|
|
42387
42405
|
const mapDeviceSettingsToState = (settings) => {
|
|
42388
|
-
const settingsWithExperimental = settings;
|
|
42389
42406
|
const identity = definedEntries({ label: settings.label });
|
|
42390
42407
|
const status = definedEntries({ passphraseProtection: settings.passphrase_enable });
|
|
42391
42408
|
const stateSettings = definedEntries({
|
|
42392
42409
|
bleEnabled: settings.bt_enable,
|
|
42393
|
-
language: settings.language,
|
|
42410
|
+
language: mapLanguageFromProtocolV2(settings.language),
|
|
42394
42411
|
wallpaperPath: settings.wallpaper_path,
|
|
42395
42412
|
brightness: settings.brightness,
|
|
42396
42413
|
autoLockDelayMs: settings.autolock_delay_ms,
|
|
@@ -42401,7 +42418,6 @@ const mapDeviceSettingsToState = (settings) => {
|
|
|
42401
42418
|
deviceNameDisplayEnabled: settings.device_name_display_enabled,
|
|
42402
42419
|
airgapMode: settings.airgap_mode,
|
|
42403
42420
|
fidoEnabled: settings.fido_enabled,
|
|
42404
|
-
experimentalFeatures: settingsWithExperimental.experimental_features,
|
|
42405
42421
|
usbLockEnabled: settings.usb_lock_enable,
|
|
42406
42422
|
randomKeypad: settings.random_keypad,
|
|
42407
42423
|
});
|
|
@@ -43350,7 +43366,7 @@ class Device extends events.exports {
|
|
|
43350
43366
|
}
|
|
43351
43367
|
if (refresh.has('settings') && ((_c = this.state) === null || _c === void 0 ? void 0 : _c.status.mode) === 'normal') {
|
|
43352
43368
|
const { message } = yield this.commands.typedCall('DeviceSettingsGet', 'DeviceSettings', {});
|
|
43353
|
-
this.updateState(mapDeviceSettingsToState(message), '
|
|
43369
|
+
this.updateState(mapDeviceSettingsToState(message), 'settings-read');
|
|
43354
43370
|
}
|
|
43355
43371
|
}
|
|
43356
43372
|
if (!this.state) {
|
|
@@ -44004,7 +44020,6 @@ class BaseMethod {
|
|
|
44004
44020
|
}
|
|
44005
44021
|
}
|
|
44006
44022
|
constructor(message) {
|
|
44007
|
-
this.executionPriority = 'normal';
|
|
44008
44023
|
this.shouldEnsureConnected = true;
|
|
44009
44024
|
this.checkDeviceId = false;
|
|
44010
44025
|
this.useDevicePassphraseState = true;
|
|
@@ -44136,10 +44151,10 @@ class BaseMethod {
|
|
|
44136
44151
|
if (this.shouldPromptSafetyCheckForEvmLedgerLegacyPath()) {
|
|
44137
44152
|
checkFlag = true;
|
|
44138
44153
|
}
|
|
44139
|
-
if (checkFlag && this.device.getCurrentSafetyChecks() ===
|
|
44154
|
+
if (checkFlag && this.device.getCurrentSafetyChecks() === hdTransport.Enum_SafetyCheckLevel.Strict) {
|
|
44140
44155
|
Log$d.debug('will change safety_checks level');
|
|
44141
44156
|
yield this.device.commands.typedCall('ApplySettings', 'Success', {
|
|
44142
|
-
safety_checks:
|
|
44157
|
+
safety_checks: hdTransport.Enum_SafetyCheckLevel.PromptTemporarily,
|
|
44143
44158
|
});
|
|
44144
44159
|
this.temporarySafetyCheckPrompted = true;
|
|
44145
44160
|
return true;
|
|
@@ -45331,6 +45346,30 @@ const getProtocolV2SettingsBehavior = (operation) => {
|
|
|
45331
45346
|
};
|
|
45332
45347
|
};
|
|
45333
45348
|
|
|
45349
|
+
const assertSettingsSupported = (payload, unsupported, protocol) => {
|
|
45350
|
+
const provided = unsupported.filter(key => payload[key] !== undefined);
|
|
45351
|
+
if (provided.length > 0) {
|
|
45352
|
+
throw invalidParameter(`${protocol} does not support settings: ${provided.join(', ')}.`);
|
|
45353
|
+
}
|
|
45354
|
+
};
|
|
45355
|
+
const assertProtocolV2SettingValues = (payload, capabilities) => {
|
|
45356
|
+
const brightnessRange = capabilities.ranges.brightness;
|
|
45357
|
+
if (payload.brightness !== undefined &&
|
|
45358
|
+
brightnessRange &&
|
|
45359
|
+
(payload.brightness < brightnessRange.min || payload.brightness > brightnessRange.max)) {
|
|
45360
|
+
throw invalidParameter(`Protocol V2 brightness must be between ${brightnessRange.min} and ${brightnessRange.max}.`);
|
|
45361
|
+
}
|
|
45362
|
+
const delayFields = [
|
|
45363
|
+
['autoLockDelayMs', capabilities.autoLockDelayOptions],
|
|
45364
|
+
['autoShutdownDelayMs', capabilities.autoShutdownDelayOptions],
|
|
45365
|
+
];
|
|
45366
|
+
delayFields.forEach(([field, options]) => {
|
|
45367
|
+
const value = payload[field];
|
|
45368
|
+
if (value !== undefined && !options.some(option => option.valueMs === value)) {
|
|
45369
|
+
throw invalidParameter(`Protocol V2 ${field} must be one of: ${options.map(option => option.valueMs).join(', ')}.`);
|
|
45370
|
+
}
|
|
45371
|
+
});
|
|
45372
|
+
};
|
|
45334
45373
|
const settingsPageForPayload = (payload) => {
|
|
45335
45374
|
if (payload.usePassphrase !== undefined) {
|
|
45336
45375
|
return hdTransport.DeviceSettingsPage.DevicePassphrase;
|
|
@@ -45367,7 +45406,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
45367
45406
|
{ name: 'usbLockEnabled', type: 'boolean' },
|
|
45368
45407
|
{ name: 'randomKeypad', type: 'boolean' },
|
|
45369
45408
|
]);
|
|
45370
|
-
this.params = Object.assign(Object.assign({ language: this.payload.language, label: this.payload.label, use_passphrase: this.payload.usePassphrase, homescreen: this.payload.homescreen, _passphrase_source: this.payload.passphraseSource, auto_lock_delay_ms: this.payload.autoLockDelayMs, display_rotation: this.payload.displayRotation, passphrase_always_on_device: this.payload.passphraseAlwaysOnDevice, safety_checks: this.payload.safetyChecks, experimental_features: this.payload.experimentalFeatures, auto_shutdown_delay_ms: this.payload.autoShutdownDelayMs }, (this.payload.changeBrightness
|
|
45409
|
+
this.params = Object.assign(Object.assign({ language: this.payload.language, label: this.payload.label, use_passphrase: this.payload.usePassphrase, homescreen: this.payload.homescreen, _passphrase_source: this.payload.passphraseSource, auto_lock_delay_ms: this.payload.autoLockDelayMs, display_rotation: this.payload.displayRotation, passphrase_always_on_device: this.payload.passphraseAlwaysOnDevice, safety_checks: this.payload.safetyChecks, experimental_features: this.payload.experimentalFeatures, auto_shutdown_delay_ms: this.payload.autoShutdownDelayMs, use_ble: this.payload.bluetoothEnabled }, (this.payload.changeBrightness
|
|
45371
45410
|
? { change_brightness: this.payload.changeBrightness }
|
|
45372
45411
|
: undefined)), { haptic_feedback: this.payload.hapticFeedback });
|
|
45373
45412
|
const page = settingsPageForPayload(this.payload);
|
|
@@ -45403,6 +45442,9 @@ class DeviceSettings extends BaseMethod {
|
|
|
45403
45442
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45404
45443
|
try {
|
|
45405
45444
|
if (this.device.isProtocolV2()) {
|
|
45445
|
+
assertSettingsSupported(this.payload, DEVICE_SETTINGS_V1_ONLY_FIELDS, 'Protocol V2');
|
|
45446
|
+
const capabilities = getDeviceSettingsCapabilities(this.device.getCurrentDeviceType(), 'V2');
|
|
45447
|
+
assertProtocolV2SettingValues(this.payload, capabilities);
|
|
45406
45448
|
const settings = mapCommonSettingsToProtocolV2(this.payload);
|
|
45407
45449
|
const requestedPassphrase = this.payload.usePassphrase;
|
|
45408
45450
|
const requestedAirgap = this.payload.airgapMode;
|
|
@@ -45448,14 +45490,19 @@ class DeviceSettings extends BaseMethod {
|
|
|
45448
45490
|
const res = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
|
|
45449
45491
|
settings,
|
|
45450
45492
|
});
|
|
45451
|
-
this.device.updateState(mapDeviceSettingsToState(settings), '
|
|
45493
|
+
this.device.updateState(mapDeviceSettingsToState(settings), 'settings-write');
|
|
45452
45494
|
return res.message;
|
|
45453
45495
|
}
|
|
45454
|
-
|
|
45455
|
-
|
|
45496
|
+
assertSettingsSupported(this.payload, DEVICE_SETTINGS_V2_ONLY_FIELDS, 'Protocol V1');
|
|
45497
|
+
const capabilities = getDeviceSettingsCapabilities(this.device.getCurrentDeviceType(), 'V1');
|
|
45498
|
+
if (this.payload.safetyChecks !== undefined &&
|
|
45499
|
+
!capabilities.safetyCheckOptions.some(option => option.value === this.payload.safetyChecks)) {
|
|
45500
|
+
throw invalidParameter(`Protocol V1 safetyChecks must be one of: ${capabilities.safetyCheckOptions
|
|
45501
|
+
.map(option => option.value)
|
|
45502
|
+
.join(', ')}.`);
|
|
45456
45503
|
}
|
|
45457
45504
|
const res = yield this.device.commands.typedCall('ApplySettings', 'Success', Object.assign({}, this.params));
|
|
45458
|
-
this.device.updateState(mapApplySettingsToState(this.params), '
|
|
45505
|
+
this.device.updateState(mapApplySettingsToState(this.params), 'settings-write');
|
|
45459
45506
|
return res.message;
|
|
45460
45507
|
}
|
|
45461
45508
|
catch (error) {
|
|
@@ -46696,7 +46743,8 @@ class DeviceUnlock extends BaseMethod {
|
|
|
46696
46743
|
}
|
|
46697
46744
|
run() {
|
|
46698
46745
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46699
|
-
|
|
46746
|
+
yield this.device.unlockDevice();
|
|
46747
|
+
return this.device.getDeviceState();
|
|
46700
46748
|
});
|
|
46701
46749
|
}
|
|
46702
46750
|
}
|
|
@@ -49365,23 +49413,6 @@ class DeviceStatusGet extends BaseMethod {
|
|
|
49365
49413
|
}
|
|
49366
49414
|
}
|
|
49367
49415
|
|
|
49368
|
-
class DeviceSettingsGet extends BaseMethod {
|
|
49369
|
-
init() {
|
|
49370
|
-
this.requireProtocolV2 = true;
|
|
49371
|
-
this.unlockPolicy = 'none';
|
|
49372
|
-
this.skipForceUpdateCheck = true;
|
|
49373
|
-
this.useDevicePassphraseState = false;
|
|
49374
|
-
this.params = undefined;
|
|
49375
|
-
}
|
|
49376
|
-
run() {
|
|
49377
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49378
|
-
const res = yield this.device.commands.typedCall('DeviceSettingsGet', 'DeviceSettings', {});
|
|
49379
|
-
this.device.updateState(mapDeviceSettingsToState(res.message), 'apply-settings');
|
|
49380
|
-
return Promise.resolve(res.message);
|
|
49381
|
-
});
|
|
49382
|
-
}
|
|
49383
|
-
}
|
|
49384
|
-
|
|
49385
49416
|
class ProtocolInfoRequest extends BaseMethod {
|
|
49386
49417
|
init() {
|
|
49387
49418
|
this.requireProtocolV2 = true;
|
|
@@ -49539,77 +49570,6 @@ class DeviceFactoryInfoGet extends BaseMethod {
|
|
|
49539
49570
|
}
|
|
49540
49571
|
}
|
|
49541
49572
|
|
|
49542
|
-
class DeviceSettingsSet extends BaseMethod {
|
|
49543
|
-
init() {
|
|
49544
|
-
const { settings } = this.payload;
|
|
49545
|
-
if (!settings || typeof settings !== 'object' || Array.isArray(settings)) {
|
|
49546
|
-
throw invalidParameter('Parameter [settings] must be an object.');
|
|
49547
|
-
}
|
|
49548
|
-
const _a = settings, supported = __rest(_a, ["passphrase_enable", "airgap_mode"]);
|
|
49549
|
-
if (Object.keys(supported).length === 0) {
|
|
49550
|
-
throw invalidParameter('Parameter [settings] must contain at least one supported setting.');
|
|
49551
|
-
}
|
|
49552
|
-
this.requireProtocolV2 = true;
|
|
49553
|
-
const behavior = getProtocolV2SettingsBehavior({ kind: 'direct', settings: supported });
|
|
49554
|
-
this.unlockPolicy = behavior.unlockPolicy;
|
|
49555
|
-
this.skipForceUpdateCheck = true;
|
|
49556
|
-
this.useDevicePassphraseState = false;
|
|
49557
|
-
this.params = { settings: supported };
|
|
49558
|
-
this.protocolV2UiInteraction = behavior.uiInteraction;
|
|
49559
|
-
}
|
|
49560
|
-
run() {
|
|
49561
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49562
|
-
const res = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', this.params);
|
|
49563
|
-
this.device.updateState(mapDeviceSettingsToState(this.params.settings), 'apply-settings');
|
|
49564
|
-
return Promise.resolve(res.message);
|
|
49565
|
-
});
|
|
49566
|
-
}
|
|
49567
|
-
}
|
|
49568
|
-
|
|
49569
|
-
const SUPPORTED_PAGES = new Set([
|
|
49570
|
-
hdTransport.DeviceSettingsPage.DeviceReset,
|
|
49571
|
-
hdTransport.DeviceSettingsPage.DevicePinChange,
|
|
49572
|
-
hdTransport.DeviceSettingsPage.DevicePassphrase,
|
|
49573
|
-
hdTransport.DeviceSettingsPage.DeviceAirgap,
|
|
49574
|
-
]);
|
|
49575
|
-
function normalizePage(value) {
|
|
49576
|
-
const page = typeof value === 'string' ? hdTransport.DeviceSettingsPage[value] : value;
|
|
49577
|
-
if (page !== undefined && SUPPORTED_PAGES.has(page)) {
|
|
49578
|
-
return page;
|
|
49579
|
-
}
|
|
49580
|
-
throw invalidParameter('Parameter [page] must be DeviceReset, DevicePinChange, DevicePassphrase, or DeviceAirgap.');
|
|
49581
|
-
}
|
|
49582
|
-
class DeviceSettingsPageShow extends BaseMethod {
|
|
49583
|
-
init() {
|
|
49584
|
-
var _a;
|
|
49585
|
-
this.requireProtocolV2 = true;
|
|
49586
|
-
this.skipForceUpdateCheck = true;
|
|
49587
|
-
this.useDevicePassphraseState = false;
|
|
49588
|
-
this.params = {
|
|
49589
|
-
page: normalizePage(this.payload.page),
|
|
49590
|
-
field_name: (_a = this.payload.field_name) !== null && _a !== void 0 ? _a : this.payload.fieldName,
|
|
49591
|
-
};
|
|
49592
|
-
const behavior = getProtocolV2SettingsBehavior({
|
|
49593
|
-
kind: 'page',
|
|
49594
|
-
page: this.params.page,
|
|
49595
|
-
});
|
|
49596
|
-
this.unlockPolicy = behavior.unlockPolicy;
|
|
49597
|
-
this.protocolV2UiInteraction = behavior.uiInteraction;
|
|
49598
|
-
}
|
|
49599
|
-
run() {
|
|
49600
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49601
|
-
const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', this.params);
|
|
49602
|
-
if (this.params.page === hdTransport.DeviceSettingsPage.DevicePassphrase) {
|
|
49603
|
-
yield this.device.getDeviceState({ refreshSections: ['status'] });
|
|
49604
|
-
}
|
|
49605
|
-
else if (this.params.page === hdTransport.DeviceSettingsPage.DeviceAirgap) {
|
|
49606
|
-
yield this.device.getDeviceState({ refreshSections: ['settings'] });
|
|
49607
|
-
}
|
|
49608
|
-
return Promise.resolve(res.message);
|
|
49609
|
-
});
|
|
49610
|
-
}
|
|
49611
|
-
}
|
|
49612
|
-
|
|
49613
49573
|
class FilesystemPermissionFix extends BaseMethod {
|
|
49614
49574
|
init() {
|
|
49615
49575
|
this.requireProtocolV2 = true;
|
|
@@ -49921,16 +49881,11 @@ class PathInfo extends BaseMethod {
|
|
|
49921
49881
|
|
|
49922
49882
|
const PORTFOLIO_PENDING_PATH = 'vol1:/portfolio/portfolio.okpkg.pending';
|
|
49923
49883
|
const PORTFOLIO_CHUNK_SIZE = 2048;
|
|
49924
|
-
const PORTFOLIO_RESPONSE_TIMEOUT_MS = 5000;
|
|
49925
|
-
const PORTFOLIO_MAX_ABORT_LATENCY_MS = PORTFOLIO_RESPONSE_TIMEOUT_MS * 2 + 2000;
|
|
49926
49884
|
class UploadPortfolio extends FileWrite {
|
|
49927
49885
|
init() {
|
|
49928
49886
|
const { packageBytes, timeoutMs } = this.payload;
|
|
49929
|
-
|
|
49930
|
-
this.payload = Object.assign(Object.assign({}, this.payload), { path: PORTFOLIO_PENDING_PATH, offset: 0, data: packageBytes, chunkSize: PORTFOLIO_CHUNK_SIZE, overwrite: true, append: false, emitProgress: false, timeoutMs: responseTimeoutMs });
|
|
49887
|
+
this.payload = Object.assign(Object.assign({}, this.payload), { path: PORTFOLIO_PENDING_PATH, offset: 0, data: packageBytes, chunkSize: PORTFOLIO_CHUNK_SIZE, overwrite: true, append: false, emitProgress: false, timeoutMs });
|
|
49931
49888
|
super.init();
|
|
49932
|
-
this.executionPriority = 'background';
|
|
49933
|
-
this.maxAbortLatencyMs = PORTFOLIO_MAX_ABORT_LATENCY_MS;
|
|
49934
49889
|
this.unlockPolicy = 'retry-on-locked';
|
|
49935
49890
|
this.protocolV2UiMode = 'none';
|
|
49936
49891
|
}
|
|
@@ -49941,8 +49896,7 @@ class UploadPortfolio extends FileWrite {
|
|
|
49941
49896
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49942
49897
|
const stagedFile = yield _super.run.call(this);
|
|
49943
49898
|
this.throwIfAborted();
|
|
49944
|
-
|
|
49945
|
-
yield this.device.commands.typedCall('PortfolioUpdate', 'Success', {}, { timeoutMs });
|
|
49899
|
+
yield this.device.commands.typedCall('PortfolioUpdate', 'Success', {});
|
|
49946
49900
|
return Object.assign(Object.assign({}, stagedFile), { portfolioUpdated: true });
|
|
49947
49901
|
});
|
|
49948
49902
|
}
|
|
@@ -59378,15 +59332,12 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
59378
59332
|
deviceUploadWallpaper: DeviceUploadWallpaper,
|
|
59379
59333
|
deviceInfoGet: DeviceInfoGet,
|
|
59380
59334
|
deviceStatusGet: DeviceStatusGet,
|
|
59381
|
-
deviceSettingsGet: DeviceSettingsGet,
|
|
59382
59335
|
protocolInfoRequest: ProtocolInfoRequest,
|
|
59383
59336
|
ping: Ping,
|
|
59384
59337
|
deviceFirmwareUpdate: DeviceFirmwareUpdate,
|
|
59385
59338
|
deviceGetFirmwareUpdateStatus: DeviceGetFirmwareUpdateStatus,
|
|
59386
59339
|
deviceFactoryInfoSet: DeviceFactoryInfoSet,
|
|
59387
59340
|
deviceFactoryInfoGet: DeviceFactoryInfoGet,
|
|
59388
|
-
deviceSettingsSet: DeviceSettingsSet,
|
|
59389
|
-
deviceSettingsPageShow: DeviceSettingsPageShow,
|
|
59390
59341
|
filesystemPermissionFix: FilesystemPermissionFix,
|
|
59391
59342
|
filesystemFormat: FilesystemFormat,
|
|
59392
59343
|
fileRead: FileRead,
|
|
@@ -59638,13 +59589,9 @@ class DeviceConnector {
|
|
|
59638
59589
|
}
|
|
59639
59590
|
|
|
59640
59591
|
const Log$2 = getLogger(exports.LoggerNames.Core);
|
|
59641
|
-
const OPERATION_PRE_CANCEL_TTL_MS = 30000;
|
|
59642
|
-
const DEFAULT_BACKGROUND_PREEMPT_TIMEOUT_MS = 5500;
|
|
59643
59592
|
class RequestQueue {
|
|
59644
59593
|
constructor() {
|
|
59645
59594
|
this.requestQueue = new Map();
|
|
59646
|
-
this.operationRequestIds = new Map();
|
|
59647
|
-
this.pendingOperationCancellations = new Map();
|
|
59648
59595
|
this.pendingCallbackTasks = new Map();
|
|
59649
59596
|
this.generateRequestId = (method) => {
|
|
59650
59597
|
if (method && method.responseID != null) {
|
|
@@ -59653,89 +59600,17 @@ class RequestQueue {
|
|
|
59653
59600
|
return Date.now();
|
|
59654
59601
|
};
|
|
59655
59602
|
}
|
|
59656
|
-
prunePendingOperationCancellations(now = Date.now()) {
|
|
59657
|
-
this.pendingOperationCancellations.forEach((expiresAt, operationId) => {
|
|
59658
|
-
if (expiresAt <= now) {
|
|
59659
|
-
this.pendingOperationCancellations.delete(operationId);
|
|
59660
|
-
}
|
|
59661
|
-
});
|
|
59662
|
-
}
|
|
59663
59603
|
createTask(method) {
|
|
59664
|
-
var _a;
|
|
59665
59604
|
const requestId = this.generateRequestId(method);
|
|
59666
59605
|
if (method && method.responseID !== requestId) {
|
|
59667
59606
|
method.responseID = requestId;
|
|
59668
59607
|
}
|
|
59669
59608
|
const abortController = new AbortController();
|
|
59670
59609
|
method.abortSignal = abortController.signal;
|
|
59671
|
-
const task = {
|
|
59672
|
-
id: requestId,
|
|
59673
|
-
method,
|
|
59674
|
-
abortController,
|
|
59675
|
-
settled: hdShared.createDeferred(),
|
|
59676
|
-
released: hdShared.createDeferred(),
|
|
59677
|
-
};
|
|
59610
|
+
const task = { id: requestId, method, abortController };
|
|
59678
59611
|
this.requestQueue.set(requestId, task);
|
|
59679
|
-
const operationId = (_a = method.payload) === null || _a === void 0 ? void 0 : _a.operationId;
|
|
59680
|
-
if (typeof operationId === 'string' && operationId) {
|
|
59681
|
-
this.operationRequestIds.set(operationId, requestId);
|
|
59682
|
-
this.prunePendingOperationCancellations();
|
|
59683
|
-
if (this.pendingOperationCancellations.delete(operationId)) {
|
|
59684
|
-
abortController.abort();
|
|
59685
|
-
}
|
|
59686
|
-
}
|
|
59687
59612
|
return task;
|
|
59688
59613
|
}
|
|
59689
|
-
admitTask(method, options = {}) {
|
|
59690
|
-
var _a;
|
|
59691
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59692
|
-
const activeTasks = Array.from(this.requestQueue.values()).filter(task => task.method.connectId === method.connectId);
|
|
59693
|
-
if (method.executionPriority === 'background') {
|
|
59694
|
-
if (activeTasks.length) {
|
|
59695
|
-
Log$2.debug(`Reject background method ${method.name}: device is occupied by ${activeTasks[0].method.name}`);
|
|
59696
|
-
return { status: 'busy', blockingTask: activeTasks[0] };
|
|
59697
|
-
}
|
|
59698
|
-
return { status: 'reserved', task: this.createTask(method) };
|
|
59699
|
-
}
|
|
59700
|
-
const backgroundTasks = activeTasks.filter(task => task.method.executionPriority === 'background');
|
|
59701
|
-
if (!backgroundTasks.length) {
|
|
59702
|
-
return { status: 'reserved', task: this.createTask(method) };
|
|
59703
|
-
}
|
|
59704
|
-
Log$2.debug(`Preempt ${backgroundTasks.length} background request(s) for user method ${method.name}`);
|
|
59705
|
-
backgroundTasks.forEach(task => { var _a; return (_a = task.abortController) === null || _a === void 0 ? void 0 : _a.abort(); });
|
|
59706
|
-
const timeoutMs = (_a = options.backgroundPreemptTimeoutMs) !== null && _a !== void 0 ? _a : Math.max(DEFAULT_BACKGROUND_PREEMPT_TIMEOUT_MS, ...backgroundTasks.map(task => { var _a; return (_a = task.method.maxAbortLatencyMs) !== null && _a !== void 0 ? _a : 0; }));
|
|
59707
|
-
const released = yield this.waitForTasksReleased(backgroundTasks, timeoutMs);
|
|
59708
|
-
if (!released) {
|
|
59709
|
-
Log$2.warn(`Background request cleanup timed out before user method ${method.name}`);
|
|
59710
|
-
return { status: 'busy', blockingTask: backgroundTasks[0] };
|
|
59711
|
-
}
|
|
59712
|
-
return { status: 'reserved', task: this.createTask(method) };
|
|
59713
|
-
});
|
|
59714
|
-
}
|
|
59715
|
-
waitForTasksReleased(tasks, timeoutMs) {
|
|
59716
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59717
|
-
let timer;
|
|
59718
|
-
const timeoutPromise = new Promise(resolve => {
|
|
59719
|
-
timer = setTimeout(() => resolve(false), timeoutMs);
|
|
59720
|
-
});
|
|
59721
|
-
const releasedPromise = Promise.all(tasks.map(task => task.released.promise)).then(() => true);
|
|
59722
|
-
const released = yield Promise.race([releasedPromise, timeoutPromise]);
|
|
59723
|
-
if (timer) {
|
|
59724
|
-
clearTimeout(timer);
|
|
59725
|
-
}
|
|
59726
|
-
return released;
|
|
59727
|
-
});
|
|
59728
|
-
}
|
|
59729
|
-
abortOperation(operationId) {
|
|
59730
|
-
const requestId = this.operationRequestIds.get(operationId);
|
|
59731
|
-
if (requestId !== undefined) {
|
|
59732
|
-
return this.abortRequest(requestId);
|
|
59733
|
-
}
|
|
59734
|
-
const now = Date.now();
|
|
59735
|
-
this.prunePendingOperationCancellations(now);
|
|
59736
|
-
this.pendingOperationCancellations.set(operationId, now + OPERATION_PRE_CANCEL_TTL_MS);
|
|
59737
|
-
return false;
|
|
59738
|
-
}
|
|
59739
59614
|
getTask(requestId) {
|
|
59740
59615
|
return this.requestQueue.get(requestId);
|
|
59741
59616
|
}
|
|
@@ -59771,7 +59646,6 @@ class RequestQueue {
|
|
|
59771
59646
|
count++;
|
|
59772
59647
|
}
|
|
59773
59648
|
});
|
|
59774
|
-
this.pendingOperationCancellations.clear();
|
|
59775
59649
|
return count;
|
|
59776
59650
|
}
|
|
59777
59651
|
getRequestTasksId() {
|
|
@@ -59782,27 +59656,18 @@ class RequestQueue {
|
|
|
59782
59656
|
const request = this.requestQueue.get(requestId);
|
|
59783
59657
|
if (request) {
|
|
59784
59658
|
(_a = request.callPromise) === null || _a === void 0 ? void 0 : _a.resolve(response);
|
|
59785
|
-
request.settled.resolve();
|
|
59786
59659
|
}
|
|
59660
|
+
this.releaseTask(requestId);
|
|
59787
59661
|
}
|
|
59788
59662
|
rejectRequest(requestId, error) {
|
|
59789
59663
|
var _a;
|
|
59790
59664
|
const request = this.requestQueue.get(requestId);
|
|
59791
59665
|
if (request) {
|
|
59792
59666
|
(_a = request.callPromise) === null || _a === void 0 ? void 0 : _a.reject(error);
|
|
59793
|
-
request.settled.resolve();
|
|
59794
59667
|
}
|
|
59668
|
+
this.releaseTask(requestId);
|
|
59795
59669
|
}
|
|
59796
59670
|
releaseTask(requestId) {
|
|
59797
|
-
var _a;
|
|
59798
|
-
const task = this.requestQueue.get(requestId);
|
|
59799
|
-
const operationId = (_a = task === null || task === void 0 ? void 0 : task.method.payload) === null || _a === void 0 ? void 0 : _a.operationId;
|
|
59800
|
-
if (typeof operationId === 'string' &&
|
|
59801
|
-
this.operationRequestIds.get(operationId) === requestId) {
|
|
59802
|
-
this.operationRequestIds.delete(operationId);
|
|
59803
|
-
}
|
|
59804
|
-
task === null || task === void 0 ? void 0 : task.settled.resolve();
|
|
59805
|
-
task === null || task === void 0 ? void 0 : task.released.resolve();
|
|
59806
59671
|
this.requestQueue.delete(requestId);
|
|
59807
59672
|
}
|
|
59808
59673
|
registerPendingCallbackTask(connectId, callbackPromise) {
|
|
@@ -60091,7 +59956,7 @@ const completeMethodRequestContext = (method, error) => {
|
|
|
60091
59956
|
completeRequestContext(method.requestContext.responseID, toError(error));
|
|
60092
59957
|
};
|
|
60093
59958
|
const callAPI = (context, message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60094
|
-
var _a, _b
|
|
59959
|
+
var _a, _b;
|
|
60095
59960
|
if (!message.id || !message.payload || message.type !== IFRAME.CALL) {
|
|
60096
59961
|
return Promise.reject(hdShared.ERRORS.TypedError('on call: message.id or message.payload is missing'));
|
|
60097
59962
|
}
|
|
@@ -60128,18 +59993,23 @@ const callAPI = (context, message) => __awaiter(void 0, void 0, void 0, function
|
|
|
60128
59993
|
return createResponseMessage(method.responseID, false, { error });
|
|
60129
59994
|
}
|
|
60130
59995
|
}
|
|
60131
|
-
if (method.isPreWarmSignal) {
|
|
60132
|
-
return handlePreWarmSignal(context, message, method);
|
|
60133
|
-
}
|
|
60134
59996
|
const { requestQueue, methodSynchronize } = context;
|
|
60135
|
-
const
|
|
60136
|
-
|
|
60137
|
-
|
|
60138
|
-
|
|
60139
|
-
|
|
60140
|
-
|
|
59997
|
+
const error = yield methodSynchronize(() => {
|
|
59998
|
+
for (const requestId of requestQueue.getRequestTasksId()) {
|
|
59999
|
+
const task = requestQueue.getTask(requestId);
|
|
60000
|
+
Log.debug('pre request task: ', `task?.id: ${task === null || task === void 0 ? void 0 : task.id},
|
|
60001
|
+
task?.method.connectId: ${task === null || task === void 0 ? void 0 : task.method.connectId},
|
|
60002
|
+
task?.method.deviceId: ${task === null || task === void 0 ? void 0 : task.method.deviceId},
|
|
60003
|
+
task?.method.name: ${task === null || task === void 0 ? void 0 : task.method.name}`);
|
|
60004
|
+
}
|
|
60005
|
+
return null;
|
|
60006
|
+
});
|
|
60007
|
+
if (error) {
|
|
60141
60008
|
return createResponseMessage(method.responseID, false, { error });
|
|
60142
60009
|
}
|
|
60010
|
+
if (method.isPreWarmSignal) {
|
|
60011
|
+
return handlePreWarmSignal(context, message, method);
|
|
60012
|
+
}
|
|
60143
60013
|
return onCallDevice(context, message, method);
|
|
60144
60014
|
});
|
|
60145
60015
|
const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -60158,7 +60028,7 @@ const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void
|
|
|
60158
60028
|
try {
|
|
60159
60029
|
yield inflight;
|
|
60160
60030
|
}
|
|
60161
|
-
catch (
|
|
60031
|
+
catch (_c) {
|
|
60162
60032
|
}
|
|
60163
60033
|
return createAckResponse();
|
|
60164
60034
|
}
|
|
@@ -60201,7 +60071,7 @@ const waitForPendingPromise = (getPrePendingCallPromise, removePrePendingCallPro
|
|
|
60201
60071
|
}
|
|
60202
60072
|
});
|
|
60203
60073
|
const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60204
|
-
var
|
|
60074
|
+
var _d, _e, _f, _g, _h;
|
|
60205
60075
|
let messageResponse;
|
|
60206
60076
|
const { requestQueue, getPrePendingCallPromise, setPrePendingCallPromise } = context;
|
|
60207
60077
|
updateMethodRequestContext(method, { status: 'running' });
|
|
@@ -60219,7 +60089,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60219
60089
|
yield context.waitForCallbackTasks(method.connectId);
|
|
60220
60090
|
}
|
|
60221
60091
|
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
60222
|
-
const task =
|
|
60092
|
+
const task = requestQueue.createTask(method);
|
|
60223
60093
|
let preWarmCallbackTask;
|
|
60224
60094
|
if (method.isPreWarmSignal && method.connectId) {
|
|
60225
60095
|
preWarmCallbackTask = hdShared.createDeferred();
|
|
@@ -60227,9 +60097,9 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60227
60097
|
}
|
|
60228
60098
|
let device;
|
|
60229
60099
|
try {
|
|
60230
|
-
const connectId = (
|
|
60100
|
+
const connectId = (_d = method.connectId) !== null && _d !== void 0 ? _d : '';
|
|
60231
60101
|
const pollingId = pollingManager.start(connectId);
|
|
60232
|
-
device = yield ensureConnected(context, method, connectId, pollingId, (
|
|
60102
|
+
device = yield ensureConnected(context, method, connectId, pollingId, (_e = task.abortController) === null || _e === void 0 ? void 0 : _e.signal);
|
|
60233
60103
|
}
|
|
60234
60104
|
catch (e) {
|
|
60235
60105
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
@@ -60244,21 +60114,17 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60244
60114
|
requestQueue.releaseTask(method.responseID);
|
|
60245
60115
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
60246
60116
|
}
|
|
60247
|
-
if ((
|
|
60117
|
+
if ((_f = method.payload) === null || _f === void 0 ? void 0 : _f.onlyConnectBleDevice) {
|
|
60248
60118
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
60249
60119
|
Log.debug('Call API - only connect ble device: ', device === null || device === void 0 ? void 0 : device.mainId);
|
|
60250
|
-
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
60251
|
-
requestQueue.releaseTask(method.responseID);
|
|
60252
|
-
completeMethodRequestContext(method);
|
|
60253
|
-
method.dispose();
|
|
60254
60120
|
return createResponseMessage(method.responseID, true, null);
|
|
60255
60121
|
}
|
|
60256
60122
|
Log.debug('Call API - setDevice: ', device.mainId);
|
|
60257
|
-
(
|
|
60123
|
+
(_g = method.setDevice) === null || _g === void 0 ? void 0 : _g.call(method, device);
|
|
60258
60124
|
method.context = context;
|
|
60259
60125
|
updateMethodRequestContext(method, {
|
|
60260
60126
|
deviceInstanceId: device.instanceId,
|
|
60261
|
-
commandsInstanceId: (
|
|
60127
|
+
commandsInstanceId: (_h = device.commands) === null || _h === void 0 ? void 0 : _h.instanceId,
|
|
60262
60128
|
});
|
|
60263
60129
|
const activeRequests = getActiveRequestsByDeviceInstance(device.instanceId);
|
|
60264
60130
|
if (activeRequests.length > 0) {
|
|
@@ -60284,13 +60150,13 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60284
60150
|
}
|
|
60285
60151
|
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
60286
60152
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60287
|
-
var
|
|
60153
|
+
var _j, _k, _l, _m, _o, _p, _q;
|
|
60288
60154
|
if (method.requireProtocolV2 && !device.isProtocolV2()) {
|
|
60289
60155
|
throw hdShared.createDeviceNotSupportMethodError(method.name, device.getCurrentFirmwareType());
|
|
60290
60156
|
}
|
|
60291
60157
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
60292
|
-
const currentFirmwareVersion = (
|
|
60293
|
-
const currentBleVersion = (
|
|
60158
|
+
const currentFirmwareVersion = (_j = device.getCurrentFirmwareVersionString()) !== null && _j !== void 0 ? _j : '0.0.0';
|
|
60159
|
+
const currentBleVersion = (_k = device.getCurrentBLEFirmwareVersionString()) !== null && _k !== void 0 ? _k : '0.0.0';
|
|
60294
60160
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
60295
60161
|
let newVersionStatus;
|
|
60296
60162
|
if (device.features && !device.isProtocolV2()) {
|
|
@@ -60377,7 +60243,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60377
60243
|
require: support.require,
|
|
60378
60244
|
}));
|
|
60379
60245
|
}
|
|
60380
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((
|
|
60246
|
+
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_l = method.payload) === null || _l === void 0 ? void 0 : _l.passphraseState, (_m = method.payload) === null || _m === void 0 ? void 0 : _m.useEmptyPassphrase, (_o = method.payload) === null || _o === void 0 ? void 0 : _o.skipPassphraseCheck);
|
|
60381
60247
|
checkPassphraseEnableState(method, device.features);
|
|
60382
60248
|
if (!passphraseStateSafety) {
|
|
60383
60249
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -60394,7 +60260,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60394
60260
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
60395
60261
|
throw error;
|
|
60396
60262
|
}
|
|
60397
|
-
(
|
|
60263
|
+
(_q = (_p = method.device) === null || _p === void 0 ? void 0 : _p.commands) === null || _q === void 0 ? void 0 : _q.checkDisposed();
|
|
60398
60264
|
try {
|
|
60399
60265
|
const response = yield runMethodWithUnlockRetry(method, device, protocolV2UiCoordinator);
|
|
60400
60266
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
@@ -60417,9 +60283,8 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60417
60283
|
});
|
|
60418
60284
|
Log.debug('Call API - Device Run: ', device.mainId);
|
|
60419
60285
|
const runOptions = Object.assign({ keepSession: method.payload.keepSession, skipInitialize: canSkipInitialize(method, device) }, parseInitOptions(method));
|
|
60420
|
-
const
|
|
60421
|
-
task.callPromise = hdShared.createDeferred();
|
|
60422
|
-
deviceRunPromise.catch(error => { var _a; return (_a = task.callPromise) === null || _a === void 0 ? void 0 : _a.reject(error); });
|
|
60286
|
+
const deviceRun = () => device.run(inner, runOptions);
|
|
60287
|
+
task.callPromise = hdShared.createDeferred(deviceRun);
|
|
60423
60288
|
try {
|
|
60424
60289
|
return yield task.callPromise.promise;
|
|
60425
60290
|
}
|
|
@@ -60428,9 +60293,6 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60428
60293
|
completeMethodRequestContext(method, e);
|
|
60429
60294
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
60430
60295
|
}
|
|
60431
|
-
finally {
|
|
60432
|
-
yield deviceRunPromise.catch(() => undefined);
|
|
60433
|
-
}
|
|
60434
60296
|
}
|
|
60435
60297
|
catch (error) {
|
|
60436
60298
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
@@ -60616,7 +60478,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
60616
60478
|
Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
|
|
60617
60479
|
const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60618
60480
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60619
|
-
var
|
|
60481
|
+
var _r;
|
|
60620
60482
|
const abort = () => {
|
|
60621
60483
|
if (abortSignal && abortSignal.aborted) {
|
|
60622
60484
|
if (timer) {
|
|
@@ -60720,7 +60582,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
60720
60582
|
clearTimeout(timer);
|
|
60721
60583
|
}
|
|
60722
60584
|
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
60723
|
-
if (DataManager.isBrowserWebUsb(env) && !((
|
|
60585
|
+
if (DataManager.isBrowserWebUsb(env) && !((_r = method.payload) === null || _r === void 0 ? void 0 : _r.skipWebDevicePrompt)) {
|
|
60724
60586
|
postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
|
|
60725
60587
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
|
|
60726
60588
|
}
|
|
@@ -60957,9 +60819,6 @@ class Core extends events.exports {
|
|
|
60957
60819
|
this.sdkInstanceId = this.tracingContext.sdkInstanceId;
|
|
60958
60820
|
Log.debug(`[Core] Created SDK instance: ${this.sdkInstanceId}`);
|
|
60959
60821
|
}
|
|
60960
|
-
cancelOperation(operationId) {
|
|
60961
|
-
this.requestQueue.abortOperation(operationId);
|
|
60962
|
-
}
|
|
60963
60822
|
getCoreContext() {
|
|
60964
60823
|
return {
|
|
60965
60824
|
sdkInstanceId: this.sdkInstanceId,
|
|
@@ -61018,10 +60877,6 @@ class Core extends events.exports {
|
|
|
61018
60877
|
cancel(this.getCoreContext(), message.payload.connectId);
|
|
61019
60878
|
break;
|
|
61020
60879
|
}
|
|
61021
|
-
case IFRAME.CANCEL_OPERATION: {
|
|
61022
|
-
this.cancelOperation(message.payload.operationId);
|
|
61023
|
-
break;
|
|
61024
|
-
}
|
|
61025
60880
|
case IFRAME.CALLBACK: {
|
|
61026
60881
|
Log.log('callback message: ', message);
|
|
61027
60882
|
postMessage(message);
|
|
@@ -61090,7 +60945,7 @@ const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0,
|
|
|
61090
60945
|
yield DataManager.load(settings);
|
|
61091
60946
|
initTransport(Transport, plugin);
|
|
61092
60947
|
}
|
|
61093
|
-
catch (
|
|
60948
|
+
catch (_s) {
|
|
61094
60949
|
Log.error('DataManager.load error');
|
|
61095
60950
|
}
|
|
61096
60951
|
enableLog(DataManager.getSettings('debug'));
|
|
@@ -61114,18 +60969,17 @@ const switchTransport = ({ env, Transport, plugin, }) => {
|
|
|
61114
60969
|
initConnector();
|
|
61115
60970
|
};
|
|
61116
60971
|
|
|
61117
|
-
const HardwareSdk = ({ init, call, dispose, eventEmitter, uiResponse, cancel,
|
|
60972
|
+
const HardwareSdk = ({ init, call, dispose, eventEmitter, uiResponse, cancel, updateSettings, switchTransport, }) => inject({
|
|
61118
60973
|
init,
|
|
61119
60974
|
call,
|
|
61120
60975
|
dispose,
|
|
61121
60976
|
eventEmitter,
|
|
61122
60977
|
uiResponse,
|
|
61123
60978
|
cancel,
|
|
61124
|
-
cancelOperation,
|
|
61125
60979
|
updateSettings,
|
|
61126
60980
|
switchTransport,
|
|
61127
60981
|
});
|
|
61128
|
-
const HardwareSDKLowLevel = ({ init, call, dispose, eventEmitter, addHardwareGlobalEventListener, uiResponse, cancel,
|
|
60982
|
+
const HardwareSDKLowLevel = ({ init, call, dispose, eventEmitter, addHardwareGlobalEventListener, uiResponse, cancel, updateSettings, switchTransport, }) => lowLevelInject({
|
|
61129
60983
|
init,
|
|
61130
60984
|
call,
|
|
61131
60985
|
dispose,
|
|
@@ -61133,7 +60987,6 @@ const HardwareSDKLowLevel = ({ init, call, dispose, eventEmitter, addHardwareGlo
|
|
|
61133
60987
|
addHardwareGlobalEventListener,
|
|
61134
60988
|
uiResponse,
|
|
61135
60989
|
cancel,
|
|
61136
|
-
cancelOperation,
|
|
61137
60990
|
updateSettings,
|
|
61138
60991
|
switchTransport,
|
|
61139
60992
|
});
|
|
@@ -61160,6 +61013,9 @@ exports.Core = Core;
|
|
|
61160
61013
|
exports.DEFAULT_PRIORITY = DEFAULT_PRIORITY;
|
|
61161
61014
|
exports.DEVICE = DEVICE;
|
|
61162
61015
|
exports.DEVICE_EVENT = DEVICE_EVENT;
|
|
61016
|
+
exports.DEVICE_SETTINGS_SHARED_FIELDS = DEVICE_SETTINGS_SHARED_FIELDS;
|
|
61017
|
+
exports.DEVICE_SETTINGS_V1_ONLY_FIELDS = DEVICE_SETTINGS_V1_ONLY_FIELDS;
|
|
61018
|
+
exports.DEVICE_SETTINGS_V2_ONLY_FIELDS = DEVICE_SETTINGS_V2_ONLY_FIELDS;
|
|
61163
61019
|
exports.DataManager = DataManager;
|
|
61164
61020
|
exports.DeviceModelToTypes = DeviceModelToTypes;
|
|
61165
61021
|
exports.DeviceTypeToModels = DeviceTypeToModels;
|
|
@@ -61173,6 +61029,7 @@ exports.LOG_EVENT = LOG_EVENT;
|
|
|
61173
61029
|
exports.LogBlockEvent = LogBlockEvent;
|
|
61174
61030
|
exports.PRO2_WALLPAPER_HEIGHT = PRO2_WALLPAPER_HEIGHT;
|
|
61175
61031
|
exports.PRO2_WALLPAPER_WIDTH = PRO2_WALLPAPER_WIDTH;
|
|
61032
|
+
exports.PROTOCOL_V2_NEVER_TIMEOUT_MS = PROTOCOL_V2_NEVER_TIMEOUT_MS;
|
|
61176
61033
|
exports.RESPONSE_EVENT = RESPONSE_EVENT;
|
|
61177
61034
|
exports.UI_EVENT = UI_EVENT;
|
|
61178
61035
|
exports.UI_REQUEST = UI_REQUEST;
|
|
@@ -61210,6 +61067,7 @@ exports.getDeviceBootloaderVersion = getDeviceBootloaderVersion;
|
|
|
61210
61067
|
exports.getDeviceFirmwareVersion = getDeviceFirmwareVersion;
|
|
61211
61068
|
exports.getDeviceLabel = getDeviceLabel;
|
|
61212
61069
|
exports.getDeviceSerialNo = getDeviceSerialNo;
|
|
61070
|
+
exports.getDeviceSettingsCapabilities = getDeviceSettingsCapabilities;
|
|
61213
61071
|
exports.getDeviceType = getDeviceType;
|
|
61214
61072
|
exports.getDeviceTypeByBleName = getDeviceTypeByBleName;
|
|
61215
61073
|
exports.getDeviceUUID = getDeviceUUID;
|
|
@@ -61236,6 +61094,7 @@ exports.isBleConnect = isBleConnect;
|
|
|
61236
61094
|
exports.isMethodVersionRangeUnsupported = isMethodVersionRangeUnsupported;
|
|
61237
61095
|
exports.isValidVersionArray = isValidVersionArray;
|
|
61238
61096
|
exports.isValidVersionString = isValidVersionString;
|
|
61097
|
+
exports.normalizeSafetyCheckLevel = normalizeSafetyCheckLevel;
|
|
61239
61098
|
exports.normalizeVersionArray = normalizeVersionArray;
|
|
61240
61099
|
exports.parseConnectSettings = parseConnectSettings;
|
|
61241
61100
|
exports.parseMessage = parseMessage;
|