@onekeyfe/hd-core 1.2.0-alpha.20 → 1.2.0-alpha.22
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 +87 -2
- package/__tests__/connectSettings.test.ts +47 -5
- package/__tests__/device-identity.test.ts +24 -2
- package/__tests__/device-lifecycle-events.test.ts +1 -1
- package/__tests__/device-settings.test.ts +111 -6
- 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__/device-wallet-session-store.test.ts +111 -7
- package/__tests__/deviceSettings.test.ts +55 -15
- package/__tests__/evmLedgerLegacySafety.test.ts +6 -5
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +326 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +39 -30
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +7 -0
- package/__tests__/open-wallet-session.test.ts +253 -13
- package/__tests__/pro2Wallpaper.test.ts +7 -18
- package/__tests__/protocol-v2-unlock-policy.test.ts +45 -0
- package/__tests__/protocol-v2.test.ts +439 -282
- package/__tests__/public-device-state-api.test.ts +79 -68
- package/__tests__/public-pro2-api-boundary.test.ts +22 -29
- package/dist/api/BaseMethod.d.ts +2 -4
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/ClearSessionCache.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +11 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +29 -10
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.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/conflux/ConfluxGetAddress.d.ts +1 -0
- package/dist/api/conflux/ConfluxGetAddress.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessage.d.ts +1 -0
- package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts +1 -0
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts +1 -0
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +26 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +7 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +24 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +7 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -20
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +1 -0
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +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/data-manager/DataManager.d.ts +1 -0
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +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/device/DeviceStateProjector.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/events/logBlockEvent.d.ts.map +1 -1
- package/dist/index.d.ts +320 -277
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3210 -1856
- 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/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +4 -0
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +3 -0
- package/dist/types/api/checkAllFirmwareRelease.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/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +69 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +27 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +10 -23
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +1 -0
- package/dist/types/api/openWalletSession.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +3 -84
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/api/sessionCache.d.ts +4 -1
- package/dist/types/api/sessionCache.d.ts.map +1 -1
- package/dist/types/device.d.ts +4 -4
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/settings.d.ts +13 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.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/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +11 -12
- package/src/api/CheckAllFirmwareRelease.ts +16 -3
- package/src/api/ClearSessionCache.ts +4 -0
- package/src/api/FirmwareUpdate.ts +8 -1
- package/src/api/FirmwareUpdateV2.ts +284 -119
- package/src/api/FirmwareUpdateV3.ts +248 -55
- package/src/api/FirmwareUpdateV4.ts +816 -328
- package/src/api/OpenWalletSession.ts +74 -25
- package/src/api/UploadPortfolio.ts +3 -13
- package/src/api/conflux/ConfluxGetAddress.ts +2 -0
- package/src/api/conflux/ConfluxSignMessage.ts +2 -0
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +2 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +2 -0
- package/src/api/device/DeviceChangePin.ts +1 -1
- package/src/api/device/DeviceSettings.ts +66 -5
- package/src/api/device/DeviceUpdateBootloader.ts +114 -6
- package/src/api/device/DeviceWipe.ts +1 -1
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +50 -0
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +621 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +378 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +140 -22
- package/src/api/helpers/protocolV2FileWrite.ts +6 -0
- package/src/api/index.ts +0 -21
- package/src/api/nexa/NexaSignTransaction.ts +2 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +1 -1
- package/src/core/RequestQueue.ts +4 -123
- package/src/core/index.ts +25 -31
- package/src/data/messages/messages-protocol-v2.json +77 -4
- package/src/data-manager/DataManager.ts +33 -33
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +51 -61
- package/src/device/DeviceCommands.ts +58 -14
- package/src/device/DeviceFeaturesState.ts +0 -9
- package/src/device/DeviceStateMapper.ts +26 -8
- package/src/device/DeviceStateProjector.ts +7 -1
- 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/events/logBlockEvent.ts +1 -0
- package/src/index.ts +5 -4
- package/src/inject.ts +22 -35
- package/src/lowLevelInject.ts +5 -4
- package/src/protocols/protocol-v2/deviceSession.ts +1 -1
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +2 -2
- package/src/protocols/protocol-v2/unlockPolicy.ts +105 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +1 -3
- package/src/protocols/protocol-v2/walletSession.ts +68 -12
- package/src/topLevelInject.ts +5 -3
- package/src/types/api/checkAllFirmwareRelease.ts +3 -0
- package/src/types/api/deviceSettings.ts +17 -2
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -0
- package/src/types/api/firmwareUpdate.ts +76 -0
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +36 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/index.ts +14 -41
- package/src/types/api/openWalletSession.ts +2 -0
- package/src/types/api/protocolV2.ts +3 -187
- package/src/types/api/sessionCache.ts +9 -4
- package/src/types/device.ts +5 -3
- package/src/types/settings.ts +13 -0
- package/src/utils/deviceFeaturesUtils.ts +5 -1
- 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/src/types/api/index.ts
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
deviceFactoryInfoGet,
|
|
3
|
-
deviceFactoryInfoSet,
|
|
4
|
-
deviceFirmwareUpdate,
|
|
5
|
-
deviceGetFirmwareUpdateStatus,
|
|
6
2
|
deviceGetOnboardingStatus,
|
|
7
|
-
deviceInfoGet,
|
|
8
3
|
deviceReboot,
|
|
9
|
-
deviceSettingsGet,
|
|
10
|
-
deviceSettingsPageShow,
|
|
11
|
-
deviceSettingsSet,
|
|
12
|
-
deviceStatusGet,
|
|
13
4
|
deviceUploadWallpaper,
|
|
14
|
-
dirList,
|
|
15
|
-
dirMake,
|
|
16
|
-
dirRemove,
|
|
17
|
-
fileDelete,
|
|
18
|
-
fileRead,
|
|
19
|
-
fileWrite,
|
|
20
|
-
filesystemFormat,
|
|
21
|
-
filesystemPermissionFix,
|
|
22
|
-
pathInfo,
|
|
23
|
-
ping,
|
|
24
|
-
protocolInfoRequest,
|
|
25
5
|
uploadPortfolio,
|
|
26
6
|
} from './protocolV2';
|
|
27
7
|
import type { off, on, removeAllListeners } from './event';
|
|
@@ -49,7 +29,15 @@ import type {
|
|
|
49
29
|
firmwareUpdateV2,
|
|
50
30
|
firmwareUpdateV3,
|
|
51
31
|
firmwareUpdateV4,
|
|
32
|
+
getFirmwareUpdateHostBindingGeneration,
|
|
33
|
+
registerFirmwareUpdateHostBinding,
|
|
34
|
+
unregisterFirmwareUpdateHostBinding,
|
|
52
35
|
} from './firmwareUpdate';
|
|
36
|
+
import type { getFirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
|
|
37
|
+
import type {
|
|
38
|
+
prepareFirmwareUpdatePlan,
|
|
39
|
+
validateFirmwareUpdatePreparedPlan,
|
|
40
|
+
} from './firmwareUpdatePreparedPlan';
|
|
53
41
|
import type { promptWebDeviceAccess } from './promptWebDeviceAccess';
|
|
54
42
|
import type { deviceReset } from './deviceReset';
|
|
55
43
|
import type { deviceRecovery } from './deviceRecovery';
|
|
@@ -183,7 +171,6 @@ export type CoreApi = {
|
|
|
183
171
|
call: (params: any) => Promise<any>;
|
|
184
172
|
uiResponse: typeof uiResponse;
|
|
185
173
|
cancel: (connectId?: string) => void;
|
|
186
|
-
cancelOperation: (operationId: string) => void;
|
|
187
174
|
updateSettings: typeof updateSettings;
|
|
188
175
|
switchTransport: (env: ConnectSettings['env']) => Promise<{ success: boolean }>;
|
|
189
176
|
getLogs: typeof getLogs;
|
|
@@ -240,6 +227,12 @@ export type CoreApi = {
|
|
|
240
227
|
firmwareUpdateV2: typeof firmwareUpdateV2;
|
|
241
228
|
firmwareUpdateV3: typeof firmwareUpdateV3;
|
|
242
229
|
firmwareUpdateV4: typeof firmwareUpdateV4;
|
|
230
|
+
registerFirmwareUpdateHostBinding: typeof registerFirmwareUpdateHostBinding;
|
|
231
|
+
unregisterFirmwareUpdateHostBinding: typeof unregisterFirmwareUpdateHostBinding;
|
|
232
|
+
getFirmwareUpdateHostBindingGeneration: typeof getFirmwareUpdateHostBindingGeneration;
|
|
233
|
+
getFirmwareUpdateCapabilities: typeof getFirmwareUpdateCapabilities;
|
|
234
|
+
prepareFirmwareUpdatePlan: typeof prepareFirmwareUpdatePlan;
|
|
235
|
+
validateFirmwareUpdatePreparedPlan: typeof validateFirmwareUpdatePreparedPlan;
|
|
243
236
|
cipherKeyValue: typeof cipherKeyValue;
|
|
244
237
|
|
|
245
238
|
/**
|
|
@@ -248,27 +241,7 @@ export type CoreApi = {
|
|
|
248
241
|
deviceReboot: typeof deviceReboot;
|
|
249
242
|
deviceGetOnboardingStatus: typeof deviceGetOnboardingStatus;
|
|
250
243
|
deviceUploadWallpaper: typeof deviceUploadWallpaper;
|
|
251
|
-
deviceInfoGet: typeof deviceInfoGet;
|
|
252
|
-
deviceStatusGet: typeof deviceStatusGet;
|
|
253
|
-
deviceSettingsGet: typeof deviceSettingsGet;
|
|
254
|
-
protocolInfoRequest: typeof protocolInfoRequest;
|
|
255
|
-
ping: typeof ping;
|
|
256
|
-
deviceFirmwareUpdate: typeof deviceFirmwareUpdate;
|
|
257
|
-
deviceGetFirmwareUpdateStatus: typeof deviceGetFirmwareUpdateStatus;
|
|
258
|
-
deviceFactoryInfoSet: typeof deviceFactoryInfoSet;
|
|
259
|
-
deviceFactoryInfoGet: typeof deviceFactoryInfoGet;
|
|
260
|
-
deviceSettingsSet: typeof deviceSettingsSet;
|
|
261
|
-
deviceSettingsPageShow: typeof deviceSettingsPageShow;
|
|
262
|
-
filesystemPermissionFix: typeof filesystemPermissionFix;
|
|
263
|
-
filesystemFormat: typeof filesystemFormat;
|
|
264
244
|
uploadPortfolio: typeof uploadPortfolio;
|
|
265
|
-
fileRead: typeof fileRead;
|
|
266
|
-
fileWrite: typeof fileWrite;
|
|
267
|
-
fileDelete: typeof fileDelete;
|
|
268
|
-
dirList: typeof dirList;
|
|
269
|
-
dirMake: typeof dirMake;
|
|
270
|
-
dirRemove: typeof dirRemove;
|
|
271
|
-
pathInfo: typeof pathInfo;
|
|
272
245
|
|
|
273
246
|
/**
|
|
274
247
|
* All network function
|
|
@@ -40,6 +40,8 @@ type OpenWalletSessionPayloadBase = {
|
|
|
40
40
|
protocol: 'V1' | 'V2';
|
|
41
41
|
deviceId: string;
|
|
42
42
|
resumed: boolean;
|
|
43
|
+
/** Forwarded only when the firmware response contains a wallet session id. */
|
|
44
|
+
sessionId?: string;
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
export type OpenWalletSessionPayload = OpenWalletSessionPayloadBase &
|
|
@@ -1,47 +1,13 @@
|
|
|
1
1
|
import type { CommonParams, Response } from '../params';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
DeviceFactoryInfo,
|
|
5
|
-
DeviceFirmwareUpdateStatus,
|
|
6
|
-
DeviceSettings,
|
|
7
|
-
DeviceStatus,
|
|
8
|
-
ProtocolInfo,
|
|
9
|
-
ProtocolV2DeviceInfo,
|
|
10
|
-
Success,
|
|
11
|
-
} from '@onekeyfe/hd-transport';
|
|
12
|
-
import type {
|
|
13
|
-
DeviceFactoryInfoSetParams,
|
|
14
|
-
DeviceFirmwareUpdateParams,
|
|
15
|
-
DeviceFirmwareUpdateStatusGetParams,
|
|
16
|
-
DeviceRebootParams,
|
|
17
|
-
} from '../../api/protocol-v2/helpers';
|
|
18
|
-
import type { DeviceInfoGetParams } from '../../api/protocol-v2/DeviceInfoGet';
|
|
19
|
-
import type { DeviceSettingsSetParams } from '../../api/protocol-v2/DeviceSettingsSet';
|
|
20
|
-
import type { DeviceSettingsPageShowParams } from '../../api/protocol-v2/DeviceSettingsPageShow';
|
|
2
|
+
import type { DevOnboardingStatus, Success } from '@onekeyfe/hd-transport';
|
|
3
|
+
import type { DeviceRebootParams } from '../../api/protocol-v2/helpers';
|
|
21
4
|
import type {
|
|
22
5
|
DeviceUploadWallpaperParams,
|
|
23
6
|
DeviceUploadWallpaperResponse,
|
|
24
7
|
} from '../../api/protocol-v2/DeviceUploadWallpaper';
|
|
25
8
|
|
|
26
9
|
// Re-export implementation parameter types as the single source of truth.
|
|
27
|
-
export type {
|
|
28
|
-
DeviceFirmwareTargetInput,
|
|
29
|
-
DeviceFirmwareUpdateParams,
|
|
30
|
-
DeviceFirmwareUpdateStatusGetParams,
|
|
31
|
-
DeviceRebootParams,
|
|
32
|
-
DeviceFactoryInfoSetParams,
|
|
33
|
-
RebootTypeInput,
|
|
34
|
-
} from '../../api/protocol-v2/helpers';
|
|
35
|
-
export type {
|
|
36
|
-
DeviceInfoGetParams,
|
|
37
|
-
DeviceInfoGetTargets,
|
|
38
|
-
DeviceInfoGetTypes,
|
|
39
|
-
} from '../../api/protocol-v2/DeviceInfoGet';
|
|
40
|
-
export type { DeviceSettingsSetParams } from '../../api/protocol-v2/DeviceSettingsSet';
|
|
41
|
-
export type {
|
|
42
|
-
DeviceSettingsPageShowParams,
|
|
43
|
-
SupportedDeviceSettingsPage,
|
|
44
|
-
} from '../../api/protocol-v2/DeviceSettingsPageShow';
|
|
10
|
+
export type { DeviceRebootParams, RebootTypeInput } from '../../api/protocol-v2/helpers';
|
|
45
11
|
export type {
|
|
46
12
|
DeviceUploadWallpaperParams,
|
|
47
13
|
DeviceUploadWallpaperResponse,
|
|
@@ -49,8 +15,6 @@ export type {
|
|
|
49
15
|
|
|
50
16
|
// ── Shared response shapes (Protocol V2 file system) ────────────────────
|
|
51
17
|
|
|
52
|
-
export type FileOpSuccess = { message?: string };
|
|
53
|
-
|
|
54
18
|
export type FileInfo = {
|
|
55
19
|
path: string;
|
|
56
20
|
offset: number;
|
|
@@ -61,60 +25,8 @@ export type FileInfo = {
|
|
|
61
25
|
chunks?: number;
|
|
62
26
|
};
|
|
63
27
|
|
|
64
|
-
export type DirInfo = {
|
|
65
|
-
path: string;
|
|
66
|
-
child_dirs?: string;
|
|
67
|
-
child_files?: string;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// All FilesystemPathInfo proto fields are required; keep this type aligned.
|
|
71
|
-
export type PathInfoResult = {
|
|
72
|
-
exist: boolean;
|
|
73
|
-
size: number;
|
|
74
|
-
year: number;
|
|
75
|
-
month: number;
|
|
76
|
-
day: number;
|
|
77
|
-
hour: number;
|
|
78
|
-
minute: number;
|
|
79
|
-
second: number;
|
|
80
|
-
readonly: boolean;
|
|
81
|
-
hidden: boolean;
|
|
82
|
-
system: boolean;
|
|
83
|
-
archive: boolean;
|
|
84
|
-
directory: boolean;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
28
|
// ── Method signatures ─────────────────────────────────────────────────────
|
|
88
29
|
|
|
89
|
-
/** @deprecated Development-only raw Protocol V2 command. Use `getDeviceState`. */
|
|
90
|
-
export declare function deviceInfoGet(
|
|
91
|
-
connectId: string,
|
|
92
|
-
params?: CommonParams & DeviceInfoGetParams
|
|
93
|
-
): Response<ProtocolV2DeviceInfo>;
|
|
94
|
-
|
|
95
|
-
/** @deprecated Development-only raw Protocol V2 command. Use `getDeviceState`. */
|
|
96
|
-
export declare function deviceStatusGet(
|
|
97
|
-
connectId: string,
|
|
98
|
-
params?: CommonParams
|
|
99
|
-
): Response<DeviceStatus>;
|
|
100
|
-
|
|
101
|
-
/** @deprecated Development-only raw Protocol V2 command. Use `getDeviceState`. */
|
|
102
|
-
export declare function deviceSettingsGet(
|
|
103
|
-
connectId: string,
|
|
104
|
-
params?: CommonParams
|
|
105
|
-
): Response<DeviceSettings>;
|
|
106
|
-
|
|
107
|
-
/** @deprecated Development-only raw Protocol V2 command. */
|
|
108
|
-
export declare function protocolInfoRequest(
|
|
109
|
-
connectId: string,
|
|
110
|
-
params?: CommonParams
|
|
111
|
-
): Response<ProtocolInfo>;
|
|
112
|
-
|
|
113
|
-
export declare function ping(
|
|
114
|
-
connectId: string,
|
|
115
|
-
params?: CommonParams & { message?: string }
|
|
116
|
-
): Response<Success>;
|
|
117
|
-
|
|
118
30
|
export declare function deviceReboot(
|
|
119
31
|
connectId: string,
|
|
120
32
|
params: CommonParams & DeviceRebootParams
|
|
@@ -125,111 +37,15 @@ export declare function deviceGetOnboardingStatus(
|
|
|
125
37
|
params?: CommonParams
|
|
126
38
|
): Response<DevOnboardingStatus>;
|
|
127
39
|
|
|
128
|
-
export declare function deviceFirmwareUpdate(
|
|
129
|
-
connectId: string,
|
|
130
|
-
params: CommonParams & DeviceFirmwareUpdateParams
|
|
131
|
-
): Response<Success | DeviceFirmwareUpdateStatus>;
|
|
132
|
-
|
|
133
|
-
export declare function deviceGetFirmwareUpdateStatus(
|
|
134
|
-
connectId: string,
|
|
135
|
-
params?: CommonParams & DeviceFirmwareUpdateStatusGetParams
|
|
136
|
-
): Response<DeviceFirmwareUpdateStatus>;
|
|
137
|
-
|
|
138
|
-
export declare function deviceFactoryInfoSet(
|
|
139
|
-
connectId: string,
|
|
140
|
-
params: CommonParams & DeviceFactoryInfoSetParams
|
|
141
|
-
): Response<Success>;
|
|
142
|
-
|
|
143
|
-
export declare function deviceFactoryInfoGet(
|
|
144
|
-
connectId: string,
|
|
145
|
-
params?: CommonParams
|
|
146
|
-
): Response<DeviceFactoryInfo>;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @deprecated Use the protocol-independent `deviceSettings`.
|
|
150
|
-
*/
|
|
151
|
-
export declare function deviceSettingsSet(
|
|
152
|
-
connectId: string,
|
|
153
|
-
params: CommonParams & DeviceSettingsSetParams
|
|
154
|
-
): Response<Success>;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* @deprecated Use `deviceSettings`, `deviceChangePin`, or `deviceWipe`.
|
|
158
|
-
*/
|
|
159
|
-
export declare function deviceSettingsPageShow(
|
|
160
|
-
connectId: string,
|
|
161
|
-
params: CommonParams & DeviceSettingsPageShowParams
|
|
162
|
-
): Response<Success>;
|
|
163
|
-
|
|
164
40
|
export declare function deviceUploadWallpaper(
|
|
165
41
|
connectId: string,
|
|
166
42
|
params: CommonParams & DeviceUploadWallpaperParams
|
|
167
43
|
): Response<DeviceUploadWallpaperResponse>;
|
|
168
44
|
|
|
169
|
-
export declare function filesystemPermissionFix(
|
|
170
|
-
connectId: string,
|
|
171
|
-
params?: CommonParams
|
|
172
|
-
): Response<Success>;
|
|
173
|
-
|
|
174
|
-
export declare function fileRead(
|
|
175
|
-
connectId: string,
|
|
176
|
-
params: {
|
|
177
|
-
path: string;
|
|
178
|
-
offset?: number;
|
|
179
|
-
totalSize?: number;
|
|
180
|
-
chunkLen?: number;
|
|
181
|
-
uiPercentage?: number;
|
|
182
|
-
}
|
|
183
|
-
): Response<FileInfo>;
|
|
184
|
-
|
|
185
|
-
export declare function fileWrite(
|
|
186
|
-
connectId: string,
|
|
187
|
-
params: {
|
|
188
|
-
path: string;
|
|
189
|
-
offset?: number;
|
|
190
|
-
totalSize?: number;
|
|
191
|
-
chunkSize?: number;
|
|
192
|
-
chunkLen?: number;
|
|
193
|
-
data: ArrayBuffer | Uint8Array | Blob | string;
|
|
194
|
-
overwrite?: boolean;
|
|
195
|
-
append?: boolean;
|
|
196
|
-
uiPercentage?: number;
|
|
197
|
-
timeoutMs?: number | string;
|
|
198
|
-
}
|
|
199
|
-
): Response<FileInfo>;
|
|
200
|
-
|
|
201
|
-
export declare function fileDelete(
|
|
202
|
-
connectId: string,
|
|
203
|
-
params: { path: string }
|
|
204
|
-
): Response<FileOpSuccess>;
|
|
205
|
-
|
|
206
|
-
export declare function dirList(
|
|
207
|
-
connectId: string,
|
|
208
|
-
params: { path: string; depth?: number }
|
|
209
|
-
): Response<DirInfo>;
|
|
210
|
-
|
|
211
|
-
export declare function dirMake(
|
|
212
|
-
connectId: string,
|
|
213
|
-
params: { path: string }
|
|
214
|
-
): Response<FileOpSuccess>;
|
|
215
|
-
|
|
216
|
-
export declare function dirRemove(
|
|
217
|
-
connectId: string,
|
|
218
|
-
params: { path: string }
|
|
219
|
-
): Response<FileOpSuccess>;
|
|
220
|
-
|
|
221
|
-
export declare function pathInfo(
|
|
222
|
-
connectId: string,
|
|
223
|
-
params: { path: string; timeoutMs?: number | string }
|
|
224
|
-
): Response<PathInfoResult>;
|
|
225
|
-
|
|
226
45
|
export declare function uploadPortfolio(
|
|
227
46
|
connectId: string,
|
|
228
47
|
params: {
|
|
229
|
-
operationId?: string;
|
|
230
48
|
packageBytes: ArrayBuffer | Uint8Array | Blob;
|
|
231
49
|
timeoutMs?: number | string;
|
|
232
50
|
}
|
|
233
51
|
): Response<FileInfo & { portfolioUpdated: true }>;
|
|
234
|
-
|
|
235
|
-
export declare function filesystemFormat(connectId: string): Response<Success>;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { Response } from '../params';
|
|
2
2
|
|
|
3
|
-
export type ClearSessionCacheParams =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export type ClearSessionCacheParams =
|
|
4
|
+
| {
|
|
5
|
+
deviceId?: never;
|
|
6
|
+
passphraseState?: never;
|
|
7
|
+
}
|
|
8
|
+
| {
|
|
9
|
+
deviceId: string;
|
|
10
|
+
passphraseState?: string;
|
|
11
|
+
};
|
|
7
12
|
|
|
8
13
|
export type ClearSessionCachePayload = {
|
|
9
14
|
cleared: true;
|
package/src/types/device.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { EDeviceType, type EFirmwareType } from '@onekeyfe/hd-shared';
|
|
|
3
3
|
import type { IVersionArray } from './settings';
|
|
4
4
|
import type { PROTO } from '../constants';
|
|
5
5
|
import type {
|
|
6
|
+
Enum_SafetyCheckLevel,
|
|
6
7
|
OneKeyDeviceCommType,
|
|
7
8
|
ProtocolV2DeviceInfo,
|
|
8
9
|
DeviceStatus as ProtocolV2DeviceStatus,
|
|
@@ -164,7 +165,8 @@ export type DeviceStateUpdateSource =
|
|
|
164
165
|
| 'initialize'
|
|
165
166
|
| 'device-info'
|
|
166
167
|
| 'device-status'
|
|
167
|
-
| '
|
|
168
|
+
| 'settings-read'
|
|
169
|
+
| 'settings-write'
|
|
168
170
|
| 'change-pin'
|
|
169
171
|
| 'lock'
|
|
170
172
|
| 'unlock'
|
|
@@ -207,7 +209,7 @@ export type DeviceStateSettings = {
|
|
|
207
209
|
sdProtection: boolean | null;
|
|
208
210
|
wipeCodeProtection: boolean | null;
|
|
209
211
|
passphraseAlwaysOnDevice: boolean | null;
|
|
210
|
-
safetyChecks:
|
|
212
|
+
safetyChecks: Enum_SafetyCheckLevel | null;
|
|
211
213
|
autoLockDelayMs: number | null;
|
|
212
214
|
autoShutdownDelayMs: number | null;
|
|
213
215
|
displayRotation: number | null;
|
|
@@ -306,7 +308,7 @@ export type NormalizedFeatures = {
|
|
|
306
308
|
wipeCodeProtection: boolean | null;
|
|
307
309
|
passphraseAlwaysOnDevice: boolean | null;
|
|
308
310
|
attachToPinEnabled?: boolean | null;
|
|
309
|
-
safetyChecks:
|
|
311
|
+
safetyChecks: Enum_SafetyCheckLevel | null;
|
|
310
312
|
autoLockDelayMs: number | null;
|
|
311
313
|
autoShutdownDelayMs: number | null;
|
|
312
314
|
displayRotation: number | null;
|
package/src/types/settings.ts
CHANGED
|
@@ -31,6 +31,8 @@ export type ConnectSettings = {
|
|
|
31
31
|
timestamp: number;
|
|
32
32
|
isFrame?: boolean;
|
|
33
33
|
preRelease?: boolean;
|
|
34
|
+
firmwareManifestMode?: 'sdk-managed' | 'external-only';
|
|
35
|
+
preloadedConfig?: RemoteConfigResponse;
|
|
34
36
|
fetchConfig?: boolean;
|
|
35
37
|
extension?: string;
|
|
36
38
|
configFetcher?: (url: string) => Promise<RemoteConfigResponse | null>;
|
|
@@ -55,6 +57,7 @@ export type IProtocolV2FirmwareComponent = {
|
|
|
55
57
|
target: IProtocolV2FirmwareComponentTarget;
|
|
56
58
|
url: string;
|
|
57
59
|
fingerprint?: string;
|
|
60
|
+
expectedSize?: number;
|
|
58
61
|
version?: IVersionArray;
|
|
59
62
|
};
|
|
60
63
|
|
|
@@ -64,6 +67,8 @@ export type IProtocolV2ResourceBundle = {
|
|
|
64
67
|
name: string;
|
|
65
68
|
/** Download URL. */
|
|
66
69
|
url: string;
|
|
70
|
+
fingerprint?: string;
|
|
71
|
+
expectedSize?: number;
|
|
67
72
|
/** Device target path, such as vol0:/bundles/images/images.okpkg. */
|
|
68
73
|
devicePath: string;
|
|
69
74
|
/** okpkg payload_version used to skip matching content after FileRead. */
|
|
@@ -85,10 +90,16 @@ export type IFirmwareReleaseInfo = {
|
|
|
85
90
|
firmwareType?: EFirmwareType;
|
|
86
91
|
/** Firmware UI resource */
|
|
87
92
|
resource?: string;
|
|
93
|
+
resourceFingerprint?: string;
|
|
94
|
+
resourceExpectedSize?: number;
|
|
88
95
|
/** Firmware full UI resource */
|
|
89
96
|
fullResource?: string;
|
|
97
|
+
fullResourceFingerprint?: string;
|
|
98
|
+
fullResourceExpectedSize?: number;
|
|
90
99
|
fullResourceRange?: string[];
|
|
91
100
|
bootloaderResource?: string;
|
|
101
|
+
bootloaderFingerprint?: string;
|
|
102
|
+
bootloaderExpectedSize?: number;
|
|
92
103
|
bootloaderVersion?: IVersionArray;
|
|
93
104
|
displayBootloaderVersion?: IVersionArray;
|
|
94
105
|
bootloaderRelatedFirmwareVersion?: IVersionArray;
|
|
@@ -101,6 +112,7 @@ export type IFirmwareReleaseInfo = {
|
|
|
101
112
|
[k in ILocale]: string;
|
|
102
113
|
};
|
|
103
114
|
fingerprint: string;
|
|
115
|
+
expectedSize?: number;
|
|
104
116
|
version: IVersionArray;
|
|
105
117
|
changelog: {
|
|
106
118
|
[k in ILocale]: string;
|
|
@@ -116,6 +128,7 @@ export type IBLEFirmwareReleaseInfo = {
|
|
|
116
128
|
webUpdate: string;
|
|
117
129
|
fingerprint: string;
|
|
118
130
|
fingerprintWeb: string;
|
|
131
|
+
expectedSize?: number;
|
|
119
132
|
version: IVersionArray;
|
|
120
133
|
changelog: {
|
|
121
134
|
[k in ILocale]: string;
|
|
@@ -156,12 +156,16 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
156
156
|
|
|
157
157
|
// Attach to pin try to fix internal state
|
|
158
158
|
const deviceId = device.getCurrentDeviceId();
|
|
159
|
+
let existingSessionId: string | null | undefined;
|
|
160
|
+
if (!options?.initSession && typeof device.getInternalState === 'function') {
|
|
161
|
+
existingSessionId = device.getInternalState();
|
|
162
|
+
}
|
|
159
163
|
device.updateInternalState(
|
|
160
164
|
device.getCurrentPassphraseProtection() ?? false,
|
|
161
165
|
passphraseState,
|
|
162
166
|
deviceId,
|
|
163
167
|
newSession,
|
|
164
|
-
options?.initSession ? null :
|
|
168
|
+
options?.initSession ? null : existingSessionId
|
|
165
169
|
);
|
|
166
170
|
|
|
167
171
|
return {
|
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
2
|
+
import { Enum_SafetyCheckLevel } from '@onekeyfe/hd-transport';
|
|
2
3
|
|
|
3
4
|
import type { IDeviceType } from '../types';
|
|
5
|
+
import type { DeviceSettingsParams } from '../types/api/deviceSettings';
|
|
6
|
+
import type { SafetyCheckLevel } from '@onekeyfe/hd-transport';
|
|
7
|
+
|
|
8
|
+
export type DeviceSettingsProtocol = 'V1' | 'V2';
|
|
9
|
+
export type DeviceSettingsField = keyof DeviceSettingsParams;
|
|
10
|
+
|
|
11
|
+
export const DEVICE_SETTINGS_SHARED_FIELDS = [
|
|
12
|
+
'language',
|
|
13
|
+
'label',
|
|
14
|
+
'usePassphrase',
|
|
15
|
+
'autoLockDelayMs',
|
|
16
|
+
'autoShutdownDelayMs',
|
|
17
|
+
'hapticFeedback',
|
|
18
|
+
'bluetoothEnabled',
|
|
19
|
+
] as const satisfies readonly DeviceSettingsField[];
|
|
20
|
+
|
|
21
|
+
export const DEVICE_SETTINGS_V1_ONLY_FIELDS = [
|
|
22
|
+
'homescreen',
|
|
23
|
+
'passphraseSource',
|
|
24
|
+
'displayRotation',
|
|
25
|
+
'passphraseAlwaysOnDevice',
|
|
26
|
+
'safetyChecks',
|
|
27
|
+
'experimentalFeatures',
|
|
28
|
+
'changeBrightness',
|
|
29
|
+
] as const satisfies readonly DeviceSettingsField[];
|
|
30
|
+
|
|
31
|
+
export const DEVICE_SETTINGS_V2_ONLY_FIELDS = [
|
|
32
|
+
'brightness',
|
|
33
|
+
'airgapMode',
|
|
34
|
+
'animationEnabled',
|
|
35
|
+
'tapToWake',
|
|
36
|
+
'deviceNameDisplayEnabled',
|
|
37
|
+
'fidoEnabled',
|
|
38
|
+
'usbLockEnabled',
|
|
39
|
+
'randomKeypad',
|
|
40
|
+
] as const satisfies readonly DeviceSettingsField[];
|
|
41
|
+
|
|
42
|
+
export const PROTOCOL_V2_NEVER_TIMEOUT_MS = 0x10000000;
|
|
43
|
+
|
|
44
|
+
export const normalizeSafetyCheckLevel = (
|
|
45
|
+
value: SafetyCheckLevel | null | undefined
|
|
46
|
+
): Enum_SafetyCheckLevel | null | undefined => {
|
|
47
|
+
if (typeof value === 'number' || value === null || value === undefined) return value;
|
|
48
|
+
return Enum_SafetyCheckLevel[value];
|
|
49
|
+
};
|
|
4
50
|
|
|
5
51
|
export const LANGUAGE_LABELS = {
|
|
6
52
|
en: 'English',
|
|
@@ -36,6 +82,13 @@ export const PROTOCOL_V2_LANGUAGE_BY_KEY: Record<LanguageKey, string> = {
|
|
|
36
82
|
export const mapLanguageToProtocolV2 = (language?: string) =>
|
|
37
83
|
language ? PROTOCOL_V2_LANGUAGE_BY_KEY[language as LanguageKey] ?? language : undefined;
|
|
38
84
|
|
|
85
|
+
const PROTOCOL_V2_LANGUAGE_KEY_BY_TAG = Object.fromEntries(
|
|
86
|
+
Object.entries(PROTOCOL_V2_LANGUAGE_BY_KEY).map(([key, tag]) => [tag, key])
|
|
87
|
+
) as Record<string, LanguageKey>;
|
|
88
|
+
|
|
89
|
+
export const mapLanguageFromProtocolV2 = (language?: string) =>
|
|
90
|
+
language ? PROTOCOL_V2_LANGUAGE_KEY_BY_TAG[language] ?? language : undefined;
|
|
91
|
+
|
|
39
92
|
const PRO2_LANGUAGE_OPTIONS = [
|
|
40
93
|
...Object.entries(LANGUAGE_LABELS).map(([code, label]) => ({ code, label })),
|
|
41
94
|
{ code: 'zh-Hant-TW', label: '繁體中文(台灣)' },
|
|
@@ -73,85 +126,106 @@ export const getLanguageConfig = (deviceType: IDeviceType): Record<string, strin
|
|
|
73
126
|
return keys.map(key => ({ code: key, label: LANGUAGE_LABELS[key] }));
|
|
74
127
|
};
|
|
75
128
|
|
|
76
|
-
export type
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
129
|
+
export type DeviceSettingsDurationOption = {
|
|
130
|
+
label: string;
|
|
131
|
+
valueMs: number;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type DeviceSettingsValueOption<T> = {
|
|
135
|
+
label: string;
|
|
136
|
+
value: T;
|
|
81
137
|
};
|
|
82
138
|
|
|
83
|
-
|
|
84
|
-
|
|
139
|
+
const durationOption = (valueMs: number): DeviceSettingsDurationOption => {
|
|
140
|
+
if (valueMs === 0 || valueMs === PROTOCOL_V2_NEVER_TIMEOUT_MS) {
|
|
141
|
+
return { label: 'Never', valueMs };
|
|
142
|
+
}
|
|
143
|
+
if (valueMs < 60_000) {
|
|
144
|
+
return { label: `${valueMs / 1000} seconds`, valueMs };
|
|
145
|
+
}
|
|
146
|
+
const minutes = valueMs / 60_000;
|
|
147
|
+
return { label: `${minutes} ${minutes === 1 ? 'minute' : 'minutes'}`, valueMs };
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const withNever = (
|
|
151
|
+
values: readonly number[],
|
|
152
|
+
protocol: DeviceSettingsProtocol
|
|
153
|
+
): DeviceSettingsDurationOption[] =>
|
|
154
|
+
[...values, protocol === 'V2' ? PROTOCOL_V2_NEVER_TIMEOUT_MS : 0].map(durationOption);
|
|
155
|
+
|
|
156
|
+
export const getAutoLockOptions = (
|
|
157
|
+
deviceType: IDeviceType,
|
|
158
|
+
protocol: DeviceSettingsProtocol
|
|
159
|
+
): DeviceSettingsDurationOption[] => {
|
|
160
|
+
switch (deviceType) {
|
|
85
161
|
case EDeviceType.Mini:
|
|
86
162
|
case EDeviceType.Classic:
|
|
87
163
|
case EDeviceType.Classic1s:
|
|
88
164
|
case EDeviceType.ClassicPure:
|
|
89
|
-
return [
|
|
90
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
91
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
92
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
93
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
94
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
95
|
-
];
|
|
165
|
+
return withNever([60_000, 120_000, 300_000, 600_000], protocol);
|
|
96
166
|
case EDeviceType.Touch:
|
|
97
167
|
case EDeviceType.Pro:
|
|
98
|
-
return [
|
|
99
|
-
{ seconds: 30, minute: 0, hour: 0, day: 0 },
|
|
100
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
101
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
102
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
103
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
104
|
-
{ seconds: 0, minute: 30, hour: 0, day: 0 },
|
|
105
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
106
|
-
];
|
|
107
168
|
case EDeviceType.Pro2:
|
|
108
|
-
return [
|
|
109
|
-
{ seconds: 30, minute: 0, hour: 0, day: 0 },
|
|
110
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
111
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
112
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
113
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
114
|
-
{ seconds: 0, minute: 30, hour: 0, day: 0 },
|
|
115
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
116
|
-
];
|
|
169
|
+
return withNever([30_000, 60_000, 120_000, 300_000, 600_000, 1_800_000], protocol);
|
|
117
170
|
default:
|
|
118
171
|
return [];
|
|
119
172
|
}
|
|
120
173
|
};
|
|
121
174
|
|
|
122
|
-
export const getAutoShutDownOptions = (
|
|
123
|
-
|
|
175
|
+
export const getAutoShutDownOptions = (
|
|
176
|
+
deviceType: IDeviceType,
|
|
177
|
+
protocol: DeviceSettingsProtocol
|
|
178
|
+
): DeviceSettingsDurationOption[] => {
|
|
179
|
+
switch (deviceType) {
|
|
124
180
|
case EDeviceType.Mini:
|
|
125
181
|
return [];
|
|
126
182
|
case EDeviceType.Classic:
|
|
127
183
|
case EDeviceType.Classic1s:
|
|
128
184
|
case EDeviceType.ClassicPure:
|
|
129
|
-
return [
|
|
130
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
131
|
-
{ seconds: 0, minute: 3, hour: 0, day: 0 },
|
|
132
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
133
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
134
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
135
|
-
];
|
|
185
|
+
return withNever([60_000, 180_000, 300_000, 600_000], protocol);
|
|
136
186
|
case EDeviceType.Touch:
|
|
137
187
|
case EDeviceType.Pro:
|
|
138
|
-
return [
|
|
139
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
140
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
141
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
142
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
143
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
144
|
-
];
|
|
188
|
+
return withNever([60_000, 120_000, 300_000, 600_000], protocol);
|
|
145
189
|
case EDeviceType.Pro2:
|
|
146
|
-
return [
|
|
147
|
-
{ seconds: 0, minute: 1, hour: 0, day: 0 },
|
|
148
|
-
{ seconds: 0, minute: 2, hour: 0, day: 0 },
|
|
149
|
-
{ seconds: 0, minute: 5, hour: 0, day: 0 },
|
|
150
|
-
{ seconds: 0, minute: 10, hour: 0, day: 0 },
|
|
151
|
-
{ seconds: 0, minute: 30, hour: 0, day: 0 },
|
|
152
|
-
{ seconds: 0, minute: 0, hour: 0, day: 0 },
|
|
153
|
-
];
|
|
190
|
+
return withNever([60_000, 120_000, 300_000, 600_000, 1_800_000], protocol);
|
|
154
191
|
default:
|
|
155
192
|
return [];
|
|
156
193
|
}
|
|
157
194
|
};
|
|
195
|
+
|
|
196
|
+
export type DeviceSettingsCapabilities = {
|
|
197
|
+
protocol: DeviceSettingsProtocol;
|
|
198
|
+
supportedFields: readonly DeviceSettingsField[];
|
|
199
|
+
languageOptions: ReadonlyArray<Record<string, string>>;
|
|
200
|
+
autoLockDelayOptions: readonly DeviceSettingsDurationOption[];
|
|
201
|
+
autoShutdownDelayOptions: readonly DeviceSettingsDurationOption[];
|
|
202
|
+
ranges: {
|
|
203
|
+
brightness?: { min: number; max: number };
|
|
204
|
+
};
|
|
205
|
+
safetyCheckOptions: ReadonlyArray<DeviceSettingsValueOption<Enum_SafetyCheckLevel>>;
|
|
206
|
+
onDeviceConfirmationFields: readonly DeviceSettingsField[];
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const getDeviceSettingsCapabilities = (
|
|
210
|
+
deviceType: IDeviceType,
|
|
211
|
+
protocol: DeviceSettingsProtocol
|
|
212
|
+
): DeviceSettingsCapabilities => ({
|
|
213
|
+
protocol,
|
|
214
|
+
supportedFields:
|
|
215
|
+
protocol === 'V2'
|
|
216
|
+
? [...DEVICE_SETTINGS_SHARED_FIELDS, ...DEVICE_SETTINGS_V2_ONLY_FIELDS]
|
|
217
|
+
: [...DEVICE_SETTINGS_SHARED_FIELDS, ...DEVICE_SETTINGS_V1_ONLY_FIELDS],
|
|
218
|
+
languageOptions: getLanguageConfig(deviceType),
|
|
219
|
+
autoLockDelayOptions: getAutoLockOptions(deviceType, protocol),
|
|
220
|
+
autoShutdownDelayOptions: getAutoShutDownOptions(deviceType, protocol),
|
|
221
|
+
ranges: protocol === 'V2' ? { brightness: { min: 10, max: 100 } } : {},
|
|
222
|
+
safetyCheckOptions:
|
|
223
|
+
protocol === 'V1'
|
|
224
|
+
? [
|
|
225
|
+
{ label: 'Strict', value: Enum_SafetyCheckLevel.Strict },
|
|
226
|
+
{ label: 'Prompt Always', value: Enum_SafetyCheckLevel.PromptAlways },
|
|
227
|
+
{ label: 'Prompt Temporarily', value: Enum_SafetyCheckLevel.PromptTemporarily },
|
|
228
|
+
]
|
|
229
|
+
: [],
|
|
230
|
+
onDeviceConfirmationFields: protocol === 'V2' ? ['usePassphrase', 'airgapMode'] : [],
|
|
231
|
+
});
|