@onekeyfe/hd-core 1.2.0-alpha.2 → 1.2.0-alpha.20
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__/AllNetworkGetAddressBase.tracing.test.ts +75 -0
- package/__tests__/DeviceCommands.test.ts +285 -0
- package/__tests__/DeviceEventRegistration.test.ts +43 -0
- package/__tests__/RequestQueue.test.ts +140 -0
- package/__tests__/UploadPortfolio.test.ts +46 -0
- package/__tests__/connectSettings.test.ts +19 -0
- package/__tests__/core-dispose.test.ts +34 -0
- package/__tests__/core-error-output.test.ts +39 -0
- package/__tests__/device-features-state.test.ts +78 -0
- package/__tests__/device-identity.test.ts +30 -0
- package/__tests__/device-lifecycle-events.test.ts +117 -0
- package/__tests__/device-pool-state.test.ts +132 -0
- package/__tests__/device-settings.test.ts +286 -0
- package/__tests__/device-state-contract.test.ts +27 -0
- package/__tests__/device-state-events.test.ts +162 -0
- package/__tests__/device-state-mapper.test.ts +229 -0
- package/__tests__/device-state-projector.test.ts +94 -0
- package/__tests__/device-state-store.test.ts +82 -0
- package/__tests__/device-utils.test.ts +106 -0
- package/__tests__/device-wallet-session-store.test.ts +213 -0
- package/__tests__/deviceFeaturesUtils.test.ts +39 -0
- package/__tests__/deviceSettings.test.ts +63 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +4 -1
- package/__tests__/evmSignTypedData.test.ts +80 -0
- package/__tests__/filesystemValidation.test.ts +53 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +402 -0
- package/__tests__/get-device-state.test.ts +403 -0
- package/__tests__/homescreen.test.ts +24 -0
- package/__tests__/kaspaSignTransaction.test.ts +591 -0
- package/__tests__/logBlockEvent.test.ts +26 -0
- package/__tests__/networkUtils.test.ts +386 -0
- package/__tests__/open-wallet-session-error-response.test.ts +43 -0
- package/__tests__/open-wallet-session.test.ts +559 -0
- package/__tests__/preInitialize.test.ts +33 -0
- package/__tests__/pro2Wallpaper.test.ts +50 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +19 -0
- package/__tests__/protocol-v2.test.ts +4054 -1178
- package/__tests__/protocolV2FileWrite.test.ts +92 -0
- package/__tests__/protocolV2UiInteraction.test.ts +266 -0
- package/__tests__/public-device-state-api.test.ts +253 -0
- package/__tests__/public-pro2-api-boundary.test.ts +91 -0
- package/__tests__/refresh-device-state.test.ts +101 -0
- package/__tests__/request-context-logging.test.ts +16 -0
- package/__tests__/search-devices.test.ts +136 -0
- package/dist/api/BaseMethod.d.ts +11 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/ClearSessionCache.d.ts +9 -0
- package/dist/api/ClearSessionCache.d.ts.map +1 -0
- package/dist/api/DirList.d.ts.map +1 -1
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts +1 -0
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +2 -2
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +25 -5
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts +7 -0
- package/dist/api/GetDeviceState.d.ts.map +1 -0
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +1 -6
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts +14 -0
- package/dist/api/OpenWalletSession.d.ts.map +1 -0
- package/dist/api/PathInfo.d.ts.map +1 -1
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +3 -0
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +18 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -0
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceCancel.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts +1 -2
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +11 -3
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/helpers/filesystemValidation.d.ts +3 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -1
- package/dist/api/helpers/paramsValidator.d.ts +1 -0
- package/dist/api/helpers/paramsValidator.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +33 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
- package/dist/api/index.d.ts +15 -19
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts +5 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/kaspa/helpers/TransferSerialize.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +3 -2
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +28 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +16 -0
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +12 -0
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +26 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
- package/dist/api/protocol-v2/{FilesystemFixPermission.d.ts → FilesystemPermissionFix.d.ts} +2 -2
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +6 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +27 -19
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +1 -5
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/utils.d.ts +2 -1
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/constants/index.d.ts +2 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +19 -1
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/deviceEventRegistration.d.ts +11 -0
- package/dist/core/deviceEventRegistration.d.ts.map +1 -0
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -1
- 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 +34 -10
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +8 -6
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceFeaturesState.d.ts +4 -0
- package/dist/device/DeviceFeaturesState.d.ts.map +1 -0
- package/dist/device/DevicePool.d.ts +4 -2
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts +13 -0
- package/dist/device/DeviceStateMapper.d.ts.map +1 -0
- package/dist/device/DeviceStateProjector.d.ts +7 -0
- package/dist/device/DeviceStateProjector.d.ts.map +1 -0
- package/dist/device/DeviceStateStore.d.ts +21 -0
- package/dist/device/DeviceStateStore.d.ts.map +1 -0
- package/dist/device/DeviceWalletSessionStore.d.ts +20 -0
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -0
- package/dist/device/cloneDeviceState.d.ts +2 -0
- package/dist/device/cloneDeviceState.d.ts.map +1 -0
- package/dist/device/deviceIdentity.d.ts +5 -0
- package/dist/device/deviceIdentity.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +9 -3
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/deviceProfile/index.d.ts +0 -1
- package/dist/deviceProfile/index.d.ts.map +1 -1
- package/dist/events/call.d.ts +7 -0
- 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/device.d.ts +11 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/iframe.d.ts +1 -0
- package/dist/events/iframe.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +18 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +1351 -603
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5995 -2816
- package/dist/inject.d.ts +3 -2
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts +2 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/deviceSession.d.ts +7 -0
- package/dist/protocols/protocol-v2/deviceSession.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/features.d.ts +23 -28
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +11 -9
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +3 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +16 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +39 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +11 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +19 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -0
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +1 -2
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +9 -0
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +1 -1
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +6 -6
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getDeviceState.d.ts +12 -0
- package/dist/types/api/getDeviceState.d.ts.map +1 -0
- package/dist/types/api/getFeatures.d.ts.map +1 -1
- package/dist/types/api/getOnekeyFeatures.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +2 -10
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +26 -25
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/kaspaSignTransaction.d.ts +27 -2
- package/dist/types/api/kaspaSignTransaction.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +41 -0
- package/dist/types/api/openWalletSession.d.ts.map +1 -0
- package/dist/types/api/protocolV2.d.ts +31 -28
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/api/sessionCache.d.ts +10 -0
- package/dist/types/api/sessionCache.d.ts.map +1 -0
- package/dist/types/device.d.ts +120 -4
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +21 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/assets.d.ts +2 -1
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +13 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -0
- package/dist/utils/deviceFeaturesUtils.d.ts +13 -3
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +9 -8
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +2 -0
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +6 -5
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/networkUtils.d.ts +9 -1
- package/dist/utils/networkUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/pro2Wallpaper.d.ts +12 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -0
- package/dist/utils/tracing.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +40 -7
- package/src/api/CheckBootloaderRelease.ts +1 -2
- package/src/api/CheckFirmwareRelease.ts +1 -2
- package/src/api/ClearSessionCache.ts +28 -0
- package/src/api/DirList.ts +5 -3
- package/src/api/DirMake.ts +3 -3
- package/src/api/DirRemove.ts +3 -3
- package/src/api/FileDelete.ts +3 -3
- package/src/api/FileRead.ts +23 -7
- package/src/api/FileWrite.ts +23 -168
- package/src/api/FirmwareUpdate.ts +4 -4
- package/src/api/FirmwareUpdateV2.ts +133 -45
- package/src/api/FirmwareUpdateV3.ts +3 -5
- package/src/api/FirmwareUpdateV4.ts +1138 -357
- package/src/api/GetDeviceState.ts +55 -0
- package/src/api/GetFeatures.ts +8 -3
- package/src/api/GetOnekeyFeatures.ts +3 -72
- package/src/api/GetPassphraseState.ts +11 -18
- package/src/api/OpenWalletSession.ts +221 -0
- package/src/api/PathInfo.ts +5 -3
- package/src/api/PromptWebDeviceAccess.ts +2 -3
- package/src/api/SearchDevices.ts +29 -4
- package/src/api/UploadPortfolio.ts +50 -0
- package/src/api/alephium/AlephiumSignTransaction.ts +2 -2
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +4 -8
- package/src/api/benfen/BenfenGetAddress.ts +1 -1
- package/src/api/btc/BTCGetPublicKey.ts +1 -1
- package/src/api/cardano/CardanoSignMessage.ts +1 -1
- package/src/api/cardano/CardanoSignTransaction.ts +1 -1
- package/src/api/device/DeviceCancel.ts +1 -0
- package/src/api/device/DeviceChangePin.ts +24 -0
- package/src/api/device/DeviceFullyUploadResource.ts +4 -5
- package/src/api/device/DeviceLock.ts +1 -0
- package/src/api/device/DeviceRebootToBoardloader.ts +5 -4
- package/src/api/device/DeviceRebootToBootloader.ts +5 -4
- package/src/api/device/DeviceSettings.ts +121 -0
- package/src/api/device/DeviceUnlock.ts +9 -0
- package/src/api/device/DeviceUpdateBootloader.ts +1 -2
- package/src/api/device/DeviceWipe.ts +19 -0
- package/src/api/evm/EVMSignTypedData.ts +3 -5
- package/src/api/evm/legacyV1/getAddress.ts +2 -2
- package/src/api/evm/legacyV1/getPublicKey.ts +2 -2
- package/src/api/evm/legacyV1/signMessage.ts +2 -2
- package/src/api/evm/legacyV1/signTypedData.ts +2 -2
- package/src/api/evm/legacyV1/signTypedHash.ts +2 -2
- package/src/api/evm/legacyV1/verifyMessage.ts +2 -2
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +21 -7
- package/src/api/firmware/getBinary.ts +8 -3
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/helpers/batchGetPublickeys.ts +2 -2
- package/src/api/helpers/filesystemValidation.ts +61 -0
- package/src/api/helpers/paramsValidator.ts +1 -1
- package/src/api/helpers/protocolV2FileWrite.ts +193 -0
- package/src/api/index.ts +17 -20
- package/src/api/kaspa/KaspaSignTransaction.ts +341 -22
- package/src/api/kaspa/helpers/TransferSerialize.ts +14 -0
- package/src/api/nervos/NervosSignTransaction.ts +2 -2
- package/src/api/nexa/NexaSignTransaction.ts +1 -1
- package/src/api/protocol-v2/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +4 -4
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +7 -9
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +41 -6
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +6 -4
- package/src/api/protocol-v2/DeviceInfoGet.ts +145 -0
- package/src/api/protocol-v2/DeviceReboot.ts +5 -3
- package/src/api/protocol-v2/DeviceSettingsGet.ts +18 -0
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +70 -0
- package/src/api/protocol-v2/DeviceSettingsSet.ts +44 -0
- package/src/api/protocol-v2/DeviceStatusGet.ts +16 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +131 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +5 -2
- package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +3 -3
- package/src/api/protocol-v2/Ping.ts +1 -1
- package/src/api/protocol-v2/{GetProtoVersion.ts → ProtocolInfoRequest.ts} +3 -3
- package/src/api/protocol-v2/helpers.ts +58 -62
- package/src/api/ton/TonSignData.ts +1 -5
- package/src/api/utils.ts +7 -3
- package/src/constants/index.ts +7 -1
- package/src/core/RequestQueue.ts +124 -4
- package/src/core/deviceEventRegistration.ts +23 -0
- package/src/core/index.ts +171 -60
- package/src/data/messages/messages-protocol-v2.json +825 -709
- package/src/data/messages/messages.json +286 -1
- package/src/data-manager/DataManager.ts +13 -6
- package/src/data-manager/connectSettings.ts +4 -0
- package/src/device/Device.ts +480 -192
- package/src/device/DeviceCommands.ts +81 -25
- package/src/device/DeviceFeaturesState.ts +34 -0
- package/src/device/DevicePool.ts +67 -19
- package/src/device/DeviceStateMapper.ts +348 -0
- package/src/device/DeviceStateProjector.ts +95 -0
- package/src/device/DeviceStateStore.ts +201 -0
- package/src/device/DeviceWalletSessionStore.ts +105 -0
- package/src/device/cloneDeviceState.ts +39 -0
- package/src/device/deviceIdentity.ts +18 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +233 -209
- package/src/deviceProfile/index.ts +0 -1
- package/src/events/call.ts +6 -0
- package/src/events/core.ts +2 -0
- package/src/events/device.ts +17 -1
- package/src/events/iframe.ts +1 -0
- package/src/events/logBlockEvent.ts +8 -1
- package/src/events/ui-request.ts +24 -2
- package/src/index.ts +4 -0
- package/src/inject.ts +33 -34
- package/src/lowLevelInject.ts +3 -0
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +68 -82
- package/src/protocols/protocol-v2/firmware.ts +12 -36
- package/src/protocols/protocol-v2/index.ts +3 -1
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +61 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +210 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +76 -0
- package/src/protocols/protocol-v2/walletSession.ts +107 -0
- package/src/topLevelInject.ts +2 -0
- package/src/types/api/checkAllFirmwareRelease.ts +1 -2
- package/src/types/api/deviceSettings.ts +9 -0
- package/src/types/api/deviceUnlock.ts +1 -1
- package/src/types/api/firmwareUpdate.ts +28 -20
- package/src/types/api/getDeviceState.ts +19 -0
- package/src/types/api/getFeatures.ts +3 -0
- package/src/types/api/getOnekeyFeatures.ts +3 -0
- package/src/types/api/getPassphraseState.ts +8 -11
- package/src/types/api/index.ts +37 -53
- package/src/types/api/kaspaSignTransaction.ts +40 -2
- package/src/types/api/openWalletSession.ts +64 -0
- package/src/types/api/protocolV2.ts +88 -54
- package/src/types/api/sessionCache.ts +14 -0
- package/src/types/device.ts +167 -3
- package/src/types/params.ts +4 -0
- package/src/types/settings.ts +42 -30
- package/src/utils/assets.ts +4 -1
- package/src/utils/deviceFeaturesCompat.ts +173 -0
- package/src/utils/deviceFeaturesUtils.ts +68 -24
- package/src/utils/deviceInfoUtils.ts +26 -64
- package/src/utils/deviceSettings.ts +48 -0
- package/src/utils/deviceVersionUtils.ts +25 -44
- package/src/utils/findDefectiveBatchDevice.ts +3 -3
- package/src/utils/homescreen.ts +10 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/networkUtils.ts +270 -14
- package/src/utils/pro2Wallpaper.ts +109 -0
- package/src/utils/tracing.ts +3 -1
- package/dist/api/GetDeviceInfo.d.ts +0 -9
- package/dist/api/GetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +0 -29
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts +0 -21
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +0 -1
- package/dist/types/api/getDeviceInfo.d.ts +0 -85
- package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
- package/src/api/GetDeviceInfo.ts +0 -145
- package/src/api/protocol-v2/DevReboot.ts +0 -24
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +0 -118
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
- package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
- package/src/deviceProfile/buildDeviceProfile.ts +0 -334
- package/src/types/api/getDeviceInfo.ts +0 -99
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
resolveDeviceBleFirmwareVersion,
|
|
5
|
+
resolveDeviceBleName,
|
|
6
|
+
resolveDeviceBoardVersion,
|
|
7
|
+
resolveDeviceBootloaderVersion,
|
|
8
|
+
resolveDeviceFirmwareType,
|
|
9
|
+
resolveDeviceFirmwareVersion,
|
|
10
|
+
resolveDeviceSerialNo,
|
|
11
|
+
resolveDeviceType,
|
|
12
|
+
} from '../utils/deviceFeaturesCompat';
|
|
6
13
|
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
application?: DevFirmwareImageInfo | null;
|
|
16
|
-
bootloader?: DevFirmwareImageInfo | null;
|
|
17
|
-
bt_adv_name?: string | null;
|
|
18
|
-
bt_mac?: unknown;
|
|
19
|
-
} | null;
|
|
20
|
-
};
|
|
14
|
+
import type {
|
|
15
|
+
DeviceFirmwareImageInfo,
|
|
16
|
+
DeviceStatus,
|
|
17
|
+
ProtocolV2DeviceInfo,
|
|
18
|
+
} from '@onekeyfe/hd-transport';
|
|
19
|
+
import type { PROTO } from '../constants';
|
|
20
|
+
import type { ProtocolV2RuntimeMode } from '../protocols/protocol-v2/features';
|
|
21
|
+
import type { DeviceFeaturesMode, Features } from '../types';
|
|
21
22
|
|
|
22
23
|
type ProtocolV1FeaturesCompat = PROTO.Features &
|
|
23
24
|
Partial<PROTO.OnekeyFeatures> & {
|
|
@@ -26,7 +27,7 @@ type ProtocolV1FeaturesCompat = PROTO.Features &
|
|
|
26
27
|
onekey_serial?: string;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
const getImageVersion = (image?:
|
|
30
|
+
const getImageVersion = (image?: DeviceFirmwareImageInfo | null) => image?.version ?? null;
|
|
30
31
|
|
|
31
32
|
const bytesToHex = (value: unknown): string | undefined => {
|
|
32
33
|
if (!value) return undefined;
|
|
@@ -42,9 +43,9 @@ const bytesToHex = (value: unknown): string | undefined => {
|
|
|
42
43
|
return undefined;
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
const getImageBuildId = (image?:
|
|
46
|
+
const getImageBuildId = (image?: DeviceFirmwareImageInfo | null) => image?.build_id ?? undefined;
|
|
46
47
|
|
|
47
|
-
const getImageHash = (image?:
|
|
48
|
+
const getImageHash = (image?: DeviceFirmwareImageInfo | null) => bytesToHex(image?.hash);
|
|
48
49
|
|
|
49
50
|
const firstValue = <T>(...values: Array<T | null | undefined>) =>
|
|
50
51
|
values.find(value => value !== undefined && value !== null);
|
|
@@ -52,70 +53,15 @@ const firstValue = <T>(...values: Array<T | null | undefined>) =>
|
|
|
52
53
|
const firstMeaningfulVersion = (...versions: Array<string | null | undefined>) =>
|
|
53
54
|
versions.find(version => Boolean(version && version !== '0.0.0')) ?? null;
|
|
54
55
|
|
|
55
|
-
const versionFromParts = (major?: number | null, minor?: number | null, patch?: number | null) =>
|
|
56
|
-
[major, minor, patch].map(part => Number(part) || 0).join('.');
|
|
57
|
-
|
|
58
56
|
const getProtocolV1Mode = (features: ProtocolV1FeaturesCompat): Features['mode'] => {
|
|
59
57
|
if (features.bootloader_mode === true) return 'bootloader';
|
|
60
58
|
if (features.initialized === false) return 'notInitialized';
|
|
61
|
-
if (features.
|
|
62
|
-
return '
|
|
59
|
+
if (features.no_backup === true) return 'backupMode';
|
|
60
|
+
return 'normal';
|
|
63
61
|
};
|
|
64
62
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
switch (onekeyDeviceType) {
|
|
68
|
-
case 'CLASSIC':
|
|
69
|
-
return EDeviceType.Classic;
|
|
70
|
-
case 'CLASSIC1S':
|
|
71
|
-
return EDeviceType.Classic1s;
|
|
72
|
-
case 'MINI':
|
|
73
|
-
return EDeviceType.Mini;
|
|
74
|
-
case 'TOUCH':
|
|
75
|
-
return EDeviceType.Touch;
|
|
76
|
-
case 'PRO':
|
|
77
|
-
return EDeviceType.Pro;
|
|
78
|
-
case 'PRO2':
|
|
79
|
-
case 'pro2':
|
|
80
|
-
return EDeviceType.Pro2;
|
|
81
|
-
case 'PURE':
|
|
82
|
-
return EDeviceType.ClassicPure;
|
|
83
|
-
default:
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const serialNo = features.onekey_serial_no || features.onekey_serial || features.serial_no || '';
|
|
88
|
-
const prefix = serialNo.slice(0, 2).toLowerCase();
|
|
89
|
-
if (prefix === 'bi' || prefix === 'cl') return EDeviceType.Classic;
|
|
90
|
-
if (prefix === 'cp') return EDeviceType.ClassicPure;
|
|
91
|
-
if (prefix === 'mi') return EDeviceType.Mini;
|
|
92
|
-
if (prefix === 'tc') return EDeviceType.Touch;
|
|
93
|
-
if (prefix === 'pr') return EDeviceType.Pro;
|
|
94
|
-
if (prefix === 'p2') return EDeviceType.Pro2;
|
|
95
|
-
if (!serialNo && features.bootloader_mode === true && features.model === '1') {
|
|
96
|
-
return EDeviceType.Classic;
|
|
97
|
-
}
|
|
98
|
-
return EDeviceType.Unknown;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const getProtocolV1FirmwareType = (
|
|
102
|
-
features: ProtocolV1FeaturesCompat
|
|
103
|
-
): Features['firmwareType'] => {
|
|
104
|
-
if (features.fw_vendor === 'OneKey Bitcoin-only') return EFirmwareType.BitcoinOnly;
|
|
105
|
-
return EFirmwareType.Universal;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const getProtocolV1Label = (
|
|
109
|
-
features: ProtocolV1FeaturesCompat,
|
|
110
|
-
deviceType: Features['deviceType'],
|
|
111
|
-
bleName: string | null
|
|
112
|
-
) => {
|
|
113
|
-
if (features.label) return features.label;
|
|
114
|
-
if (bleName) return bleName;
|
|
115
|
-
if (deviceType === EDeviceType.Unknown) return null;
|
|
116
|
-
if (deviceType === EDeviceType.ClassicPure) return 'OneKey Classic 1S';
|
|
117
|
-
return `OneKey ${deviceType.charAt(0).toUpperCase()}${deviceType.slice(1)}`;
|
|
118
|
-
};
|
|
63
|
+
const getProtocolV1Label = (features: ProtocolV1FeaturesCompat) =>
|
|
64
|
+
typeof features.label === 'string' && features.label.length > 0 ? features.label : null;
|
|
119
65
|
|
|
120
66
|
export const buildProtocolV1FeaturesPayload = (
|
|
121
67
|
protocolV1Features: PROTO.Features,
|
|
@@ -123,37 +69,37 @@ export const buildProtocolV1FeaturesPayload = (
|
|
|
123
69
|
): Features => {
|
|
124
70
|
const features = protocolV1Features as ProtocolV1FeaturesCompat;
|
|
125
71
|
const firmwareVersion = firstMeaningfulVersion(
|
|
126
|
-
features
|
|
127
|
-
|
|
128
|
-
versionFromParts(features.major_version, features.minor_version, features.patch_version)
|
|
72
|
+
resolveDeviceFirmwareVersion(features),
|
|
73
|
+
previous?.firmwareVersion
|
|
129
74
|
);
|
|
130
75
|
const bootloaderVersion = firstMeaningfulVersion(
|
|
131
|
-
features
|
|
132
|
-
|
|
133
|
-
features.bootloader_mode
|
|
134
|
-
? versionFromParts(features.major_version, features.minor_version, features.patch_version)
|
|
135
|
-
: null
|
|
76
|
+
resolveDeviceBootloaderVersion(features),
|
|
77
|
+
previous?.bootloaderVersion
|
|
136
78
|
);
|
|
137
79
|
const boardVersion = firstMeaningfulVersion(
|
|
138
|
-
features
|
|
139
|
-
|
|
80
|
+
resolveDeviceBoardVersion(features),
|
|
81
|
+
previous?.boardVersion
|
|
140
82
|
);
|
|
141
|
-
const bleVersion = firstMeaningfulVersion(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
83
|
+
const bleVersion = firstMeaningfulVersion(
|
|
84
|
+
resolveDeviceBleFirmwareVersion(features),
|
|
85
|
+
previous?.bleVersion
|
|
86
|
+
);
|
|
87
|
+
const serialNo = resolveDeviceSerialNo(features);
|
|
88
|
+
const bleName = resolveDeviceBleName(features);
|
|
89
|
+
const deviceType = resolveDeviceType(features);
|
|
145
90
|
const sessionId = features.session_id ?? previous?.sessionId ?? null;
|
|
146
91
|
|
|
147
92
|
return {
|
|
93
|
+
...features,
|
|
148
94
|
protocol: 'V1',
|
|
149
95
|
protocolVersion: features.protocol_version ?? previous?.protocolVersion ?? 1,
|
|
150
96
|
deviceType,
|
|
151
|
-
firmwareType:
|
|
97
|
+
firmwareType: resolveDeviceFirmwareType(features),
|
|
152
98
|
model: features.model ?? null,
|
|
153
99
|
vendor: features.vendor ?? null,
|
|
154
100
|
deviceId: features.device_id ?? null,
|
|
155
101
|
serialNo,
|
|
156
|
-
label: getProtocolV1Label(features
|
|
102
|
+
label: getProtocolV1Label(features),
|
|
157
103
|
bleName,
|
|
158
104
|
capabilities: features.capabilities ?? [],
|
|
159
105
|
mode: getProtocolV1Mode(features),
|
|
@@ -173,111 +119,170 @@ export const buildProtocolV1FeaturesPayload = (
|
|
|
173
119
|
sdProtection: features.sd_protection ?? null,
|
|
174
120
|
wipeCodeProtection: features.wipe_code_protection ?? null,
|
|
175
121
|
passphraseAlwaysOnDevice: features.passphrase_always_on_device ?? null,
|
|
122
|
+
attachToPinEnabled: features.attach_to_pin_user ?? previous?.attachToPinEnabled ?? null,
|
|
123
|
+
unlockedAttachPin: features.unlocked_attach_pin ?? previous?.unlockedAttachPin ?? undefined,
|
|
176
124
|
safetyChecks: features.safety_checks ?? null,
|
|
177
125
|
autoLockDelayMs: features.auto_lock_delay_ms ?? null,
|
|
126
|
+
autoShutdownDelayMs: features.auto_shutdown_delay_ms ?? null,
|
|
178
127
|
displayRotation: features.display_rotation ?? null,
|
|
179
128
|
experimentalFeatures: features.experimental_features ?? null,
|
|
129
|
+
wallpaperPath: previous?.wallpaperPath ?? null,
|
|
130
|
+
brightness: features.brightness_prcent ?? previous?.brightness ?? null,
|
|
131
|
+
animationEnabled: previous?.animationEnabled ?? null,
|
|
132
|
+
tapToWake: previous?.tapToWake ?? null,
|
|
133
|
+
hapticFeedback: features.haptic_feedback ?? previous?.hapticFeedback ?? null,
|
|
134
|
+
deviceNameDisplayEnabled: previous?.deviceNameDisplayEnabled ?? null,
|
|
135
|
+
airgapMode: previous?.airgapMode ?? null,
|
|
136
|
+
fidoEnabled: previous?.fidoEnabled ?? null,
|
|
137
|
+
usbLockEnabled: previous?.usbLockEnabled ?? null,
|
|
138
|
+
randomKeypad: previous?.randomKeypad ?? null,
|
|
180
139
|
firmwareVersion,
|
|
181
140
|
bootloaderVersion,
|
|
182
141
|
boardVersion,
|
|
183
142
|
bleVersion,
|
|
184
|
-
se01Version: firstMeaningfulVersion(features.onekey_se01_version),
|
|
185
|
-
se02Version: firstMeaningfulVersion(features.onekey_se02_version),
|
|
186
|
-
se03Version: firstMeaningfulVersion(features.onekey_se03_version),
|
|
187
|
-
se04Version: firstMeaningfulVersion(features.onekey_se04_version),
|
|
188
|
-
se01BootVersion: firstMeaningfulVersion(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
143
|
+
se01Version: firstMeaningfulVersion(features.onekey_se01_version, previous?.se01Version),
|
|
144
|
+
se02Version: firstMeaningfulVersion(features.onekey_se02_version, previous?.se02Version),
|
|
145
|
+
se03Version: firstMeaningfulVersion(features.onekey_se03_version, previous?.se03Version),
|
|
146
|
+
se04Version: firstMeaningfulVersion(features.onekey_se04_version, previous?.se04Version),
|
|
147
|
+
se01BootVersion: firstMeaningfulVersion(
|
|
148
|
+
features.onekey_se01_boot_version,
|
|
149
|
+
previous?.se01BootVersion
|
|
150
|
+
),
|
|
151
|
+
se02BootVersion: firstMeaningfulVersion(
|
|
152
|
+
features.onekey_se02_boot_version,
|
|
153
|
+
previous?.se02BootVersion
|
|
154
|
+
),
|
|
155
|
+
se03BootVersion: firstMeaningfulVersion(
|
|
156
|
+
features.onekey_se03_boot_version,
|
|
157
|
+
previous?.se03BootVersion
|
|
158
|
+
),
|
|
159
|
+
se04BootVersion: firstMeaningfulVersion(
|
|
160
|
+
features.onekey_se04_boot_version,
|
|
161
|
+
previous?.se04BootVersion
|
|
162
|
+
),
|
|
163
|
+
seVersion: features.se_ver ?? previous?.seVersion ?? null,
|
|
193
164
|
verify: {
|
|
194
|
-
firmwareBuildId: features.onekey_firmware_build_id,
|
|
195
|
-
firmwareHash: features.onekey_firmware_hash,
|
|
196
|
-
bootloaderBuildId: features.onekey_boot_build_id,
|
|
197
|
-
bootloaderHash: features.onekey_boot_hash,
|
|
198
|
-
boardBuildId: features.onekey_board_build_id,
|
|
199
|
-
boardHash: features.onekey_board_hash,
|
|
200
|
-
bleBuildId: features.onekey_ble_build_id,
|
|
201
|
-
bleHash: features.onekey_ble_hash,
|
|
202
|
-
se01BuildId: features.onekey_se01_build_id,
|
|
203
|
-
se01Hash: features.onekey_se01_hash,
|
|
204
|
-
se02BuildId: features.onekey_se02_build_id,
|
|
205
|
-
se02Hash: features.onekey_se02_hash,
|
|
206
|
-
se03BuildId: features.onekey_se03_build_id,
|
|
207
|
-
se03Hash: features.onekey_se03_hash,
|
|
208
|
-
se04BuildId: features.onekey_se04_build_id,
|
|
209
|
-
se04Hash: features.onekey_se04_hash,
|
|
210
|
-
se01BootBuildId: features.onekey_se01_boot_build_id,
|
|
211
|
-
se01BootHash: features.onekey_se01_boot_hash,
|
|
212
|
-
se02BootBuildId: features.onekey_se02_boot_build_id,
|
|
213
|
-
se02BootHash: features.onekey_se02_boot_hash,
|
|
214
|
-
se03BootBuildId: features.onekey_se03_boot_build_id,
|
|
215
|
-
se03BootHash: features.onekey_se03_boot_hash,
|
|
216
|
-
se04BootBuildId: features.onekey_se04_boot_build_id,
|
|
217
|
-
se04BootHash: features.onekey_se04_boot_hash,
|
|
165
|
+
firmwareBuildId: features.onekey_firmware_build_id ?? previous?.verify?.firmwareBuildId,
|
|
166
|
+
firmwareHash: features.onekey_firmware_hash ?? previous?.verify?.firmwareHash,
|
|
167
|
+
bootloaderBuildId: features.onekey_boot_build_id ?? previous?.verify?.bootloaderBuildId,
|
|
168
|
+
bootloaderHash: features.onekey_boot_hash ?? previous?.verify?.bootloaderHash,
|
|
169
|
+
boardBuildId: features.onekey_board_build_id ?? previous?.verify?.boardBuildId,
|
|
170
|
+
boardHash: features.onekey_board_hash ?? previous?.verify?.boardHash,
|
|
171
|
+
bleBuildId: features.onekey_ble_build_id ?? previous?.verify?.bleBuildId,
|
|
172
|
+
bleHash: features.onekey_ble_hash ?? previous?.verify?.bleHash,
|
|
173
|
+
se01BuildId: features.onekey_se01_build_id ?? previous?.verify?.se01BuildId,
|
|
174
|
+
se01Hash: features.onekey_se01_hash ?? previous?.verify?.se01Hash,
|
|
175
|
+
se02BuildId: features.onekey_se02_build_id ?? previous?.verify?.se02BuildId,
|
|
176
|
+
se02Hash: features.onekey_se02_hash ?? previous?.verify?.se02Hash,
|
|
177
|
+
se03BuildId: features.onekey_se03_build_id ?? previous?.verify?.se03BuildId,
|
|
178
|
+
se03Hash: features.onekey_se03_hash ?? previous?.verify?.se03Hash,
|
|
179
|
+
se04BuildId: features.onekey_se04_build_id ?? previous?.verify?.se04BuildId,
|
|
180
|
+
se04Hash: features.onekey_se04_hash ?? previous?.verify?.se04Hash,
|
|
181
|
+
se01BootBuildId: features.onekey_se01_boot_build_id ?? previous?.verify?.se01BootBuildId,
|
|
182
|
+
se01BootHash: features.onekey_se01_boot_hash ?? previous?.verify?.se01BootHash,
|
|
183
|
+
se02BootBuildId: features.onekey_se02_boot_build_id ?? previous?.verify?.se02BootBuildId,
|
|
184
|
+
se02BootHash: features.onekey_se02_boot_hash ?? previous?.verify?.se02BootHash,
|
|
185
|
+
se03BootBuildId: features.onekey_se03_boot_build_id ?? previous?.verify?.se03BootBuildId,
|
|
186
|
+
se03BootHash: features.onekey_se03_boot_hash ?? previous?.verify?.se03BootHash,
|
|
187
|
+
se04BootBuildId: features.onekey_se04_boot_build_id ?? previous?.verify?.se04BootBuildId,
|
|
188
|
+
se04BootHash: features.onekey_se04_boot_hash ?? previous?.verify?.se04BootHash,
|
|
218
189
|
},
|
|
219
190
|
sessionId,
|
|
191
|
+
session_id: sessionId ?? undefined,
|
|
220
192
|
raw: {
|
|
221
|
-
protocolV1Features
|
|
193
|
+
protocolV1Features,
|
|
222
194
|
},
|
|
223
195
|
};
|
|
224
196
|
};
|
|
225
197
|
|
|
226
198
|
/**
|
|
227
|
-
* Protocol V2
|
|
199
|
+
* Structured Protocol V2 `Features` builder.
|
|
228
200
|
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
201
|
+
* This is the only cached Device state. Fields come from DeviceInfoGet or same-name
|
|
202
|
+
* values in the previous cache. Fields without protocol-equivalent meaning remain
|
|
203
|
+
* null or empty and never fall back to DeviceState or a transport path.
|
|
232
204
|
*/
|
|
233
|
-
export const buildProtocolV2FeaturesPayload = (
|
|
234
|
-
deviceInfo
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
205
|
+
export const buildProtocolV2FeaturesPayload = ({
|
|
206
|
+
deviceInfo,
|
|
207
|
+
deviceStatus,
|
|
208
|
+
previous,
|
|
209
|
+
runtimeMode,
|
|
210
|
+
}: {
|
|
211
|
+
deviceInfo?: ProtocolV2DeviceInfo;
|
|
212
|
+
deviceStatus?: DeviceStatus;
|
|
213
|
+
previous?: Features;
|
|
214
|
+
runtimeMode?: ProtocolV2RuntimeMode;
|
|
215
|
+
}): Features => {
|
|
216
|
+
const info = deviceInfo;
|
|
217
|
+
const fwApplication = info?.fw?.application;
|
|
218
|
+
const fwBootloader = info?.fw?.bootloader;
|
|
219
|
+
const fwBoard = info?.fw?.romloader;
|
|
220
|
+
const bleApplication = info?.coprocessor?.application;
|
|
221
|
+
const status = deviceStatus;
|
|
222
|
+
const incomingSerialNo = info?.hw?.serial_no;
|
|
223
|
+
const samePhysicalDevice =
|
|
224
|
+
!incomingSerialNo || !previous?.serialNo || incomingSerialNo === previous.serialNo;
|
|
225
|
+
const cached = samePhysicalDevice ? previous : undefined;
|
|
242
226
|
|
|
243
227
|
const firmwareVersion = firstMeaningfulVersion(
|
|
244
228
|
getImageVersion(fwApplication),
|
|
245
|
-
|
|
229
|
+
cached?.firmwareVersion
|
|
246
230
|
);
|
|
247
231
|
const bootloaderVersion = firstMeaningfulVersion(
|
|
248
232
|
getImageVersion(fwBootloader),
|
|
249
|
-
|
|
233
|
+
cached?.bootloaderVersion
|
|
250
234
|
);
|
|
251
|
-
const boardVersion = firstMeaningfulVersion(getImageVersion(fwBoard),
|
|
252
|
-
const bleVersion = firstMeaningfulVersion(getImageVersion(bleApplication),
|
|
253
|
-
const
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
235
|
+
const boardVersion = firstMeaningfulVersion(getImageVersion(fwBoard), cached?.boardVersion);
|
|
236
|
+
const bleVersion = firstMeaningfulVersion(getImageVersion(bleApplication), cached?.bleVersion);
|
|
237
|
+
const deviceId = status?.device_id ?? cached?.deviceId ?? null;
|
|
238
|
+
const serialNo = firstValue(incomingSerialNo, cached?.serialNo) ?? '';
|
|
239
|
+
const label = cached?.label ?? null;
|
|
240
|
+
const bleName = firstValue(info?.coprocessor?.bt_adv_name, cached?.bleName);
|
|
241
|
+
const initialized = firstValue(status?.init_states, cached?.initialized) ?? null;
|
|
242
|
+
// passphrase_enabled from a locked Pro2 is not authoritative. Only DeviceStatus
|
|
243
|
+
// after PIN unlock can determine the final passphrase setting.
|
|
244
|
+
let passphraseProtection = cached?.passphraseProtection ?? null;
|
|
245
|
+
if (status?.unlocked === true) {
|
|
246
|
+
passphraseProtection = status.passphrase_enabled ?? null;
|
|
247
|
+
}
|
|
248
|
+
const language = cached?.language ?? null;
|
|
249
|
+
const backupRequired = firstValue(status?.backup_required, cached?.backupRequired) ?? null;
|
|
250
|
+
const bleEnabled = cached?.bleEnabled;
|
|
251
|
+
const unlocked = firstValue(status?.unlocked, cached?.unlocked) ?? null;
|
|
252
|
+
const attachToPinEnabled = status?.attach_to_pin_enabled ?? cached?.attachToPinEnabled ?? null;
|
|
253
|
+
const unlockedAttachPin =
|
|
254
|
+
status?.unlocked_by_attach_to_pin ?? cached?.unlockedAttachPin ?? undefined;
|
|
255
|
+
const bootloaderMode = runtimeMode === 'bootloader';
|
|
256
|
+
let mode: DeviceFeaturesMode = 'unknown';
|
|
257
|
+
if (runtimeMode) {
|
|
258
|
+
mode = runtimeMode;
|
|
259
|
+
} else if (initialized === false) {
|
|
260
|
+
mode = 'notInitialized';
|
|
261
|
+
} else if (initialized === true) {
|
|
262
|
+
mode = 'normal';
|
|
263
|
+
} else if (cached?.mode === 'notInitialized' || cached?.mode === 'backupMode') {
|
|
264
|
+
mode = cached.mode;
|
|
265
|
+
} else if (cached?.mode) {
|
|
266
|
+
mode = cached.mode;
|
|
267
|
+
}
|
|
263
268
|
|
|
264
269
|
return {
|
|
265
270
|
protocol: 'V2',
|
|
266
|
-
protocolVersion: deviceInfo?.protocol_version ??
|
|
271
|
+
protocolVersion: deviceInfo?.protocol_version ?? cached?.protocolVersion ?? null,
|
|
267
272
|
deviceType: EDeviceType.Pro2,
|
|
268
|
-
firmwareType:
|
|
273
|
+
firmwareType: cached?.firmwareType ?? EFirmwareType.Universal,
|
|
269
274
|
model: 'pro2',
|
|
270
275
|
vendor: 'onekey.so',
|
|
271
|
-
deviceId
|
|
276
|
+
deviceId,
|
|
272
277
|
serialNo,
|
|
273
278
|
label,
|
|
274
279
|
bleName: bleName ?? null,
|
|
275
280
|
capabilities: [],
|
|
276
|
-
mode
|
|
281
|
+
mode,
|
|
277
282
|
initialized,
|
|
278
|
-
bootloaderMode
|
|
279
|
-
unlocked
|
|
280
|
-
firmwarePresent:
|
|
283
|
+
bootloaderMode,
|
|
284
|
+
unlocked,
|
|
285
|
+
firmwarePresent: cached?.firmwarePresent ?? null,
|
|
281
286
|
passphraseProtection,
|
|
282
287
|
pinProtection: null,
|
|
283
288
|
backupRequired,
|
|
@@ -290,78 +295,97 @@ export const buildProtocolV2FeaturesPayload = (
|
|
|
290
295
|
sdProtection: null,
|
|
291
296
|
wipeCodeProtection: null,
|
|
292
297
|
passphraseAlwaysOnDevice: null,
|
|
298
|
+
attachToPinEnabled,
|
|
293
299
|
safetyChecks: null,
|
|
294
|
-
autoLockDelayMs: null,
|
|
300
|
+
autoLockDelayMs: cached?.autoLockDelayMs ?? null,
|
|
301
|
+
autoShutdownDelayMs: cached?.autoShutdownDelayMs ?? null,
|
|
295
302
|
displayRotation: null,
|
|
296
|
-
experimentalFeatures: null,
|
|
303
|
+
experimentalFeatures: cached?.experimentalFeatures ?? null,
|
|
304
|
+
wallpaperPath: cached?.wallpaperPath ?? null,
|
|
305
|
+
brightness: cached?.brightness ?? null,
|
|
306
|
+
animationEnabled: cached?.animationEnabled ?? null,
|
|
307
|
+
tapToWake: cached?.tapToWake ?? null,
|
|
308
|
+
hapticFeedback: cached?.hapticFeedback ?? null,
|
|
309
|
+
deviceNameDisplayEnabled: cached?.deviceNameDisplayEnabled ?? null,
|
|
310
|
+
airgapMode: cached?.airgapMode ?? null,
|
|
311
|
+
fidoEnabled: cached?.fidoEnabled ?? null,
|
|
312
|
+
usbLockEnabled: cached?.usbLockEnabled ?? null,
|
|
313
|
+
randomKeypad: cached?.randomKeypad ?? null,
|
|
297
314
|
firmwareVersion,
|
|
298
315
|
bootloaderVersion,
|
|
299
316
|
boardVersion,
|
|
300
317
|
bleVersion,
|
|
301
318
|
se01Version: firstMeaningfulVersion(
|
|
302
|
-
getImageVersion(
|
|
303
|
-
|
|
319
|
+
getImageVersion(info?.se1?.application),
|
|
320
|
+
cached?.se01Version
|
|
304
321
|
),
|
|
305
322
|
se02Version: firstMeaningfulVersion(
|
|
306
|
-
getImageVersion(
|
|
307
|
-
|
|
323
|
+
getImageVersion(info?.se2?.application),
|
|
324
|
+
cached?.se02Version
|
|
308
325
|
),
|
|
309
326
|
se03Version: firstMeaningfulVersion(
|
|
310
|
-
getImageVersion(
|
|
311
|
-
|
|
327
|
+
getImageVersion(info?.se3?.application),
|
|
328
|
+
cached?.se03Version
|
|
312
329
|
),
|
|
313
330
|
se04Version: firstMeaningfulVersion(
|
|
314
|
-
getImageVersion(
|
|
315
|
-
|
|
331
|
+
getImageVersion(info?.se4?.application),
|
|
332
|
+
cached?.se04Version
|
|
316
333
|
),
|
|
317
334
|
se01BootVersion: firstMeaningfulVersion(
|
|
318
|
-
getImageVersion(
|
|
319
|
-
|
|
335
|
+
getImageVersion(info?.se1?.bootloader),
|
|
336
|
+
cached?.se01BootVersion
|
|
320
337
|
),
|
|
321
338
|
se02BootVersion: firstMeaningfulVersion(
|
|
322
|
-
getImageVersion(
|
|
323
|
-
|
|
339
|
+
getImageVersion(info?.se2?.bootloader),
|
|
340
|
+
cached?.se02BootVersion
|
|
324
341
|
),
|
|
325
342
|
se03BootVersion: firstMeaningfulVersion(
|
|
326
|
-
getImageVersion(
|
|
327
|
-
|
|
343
|
+
getImageVersion(info?.se3?.bootloader),
|
|
344
|
+
cached?.se03BootVersion
|
|
328
345
|
),
|
|
329
346
|
se04BootVersion: firstMeaningfulVersion(
|
|
330
|
-
getImageVersion(
|
|
331
|
-
|
|
347
|
+
getImageVersion(info?.se4?.bootloader),
|
|
348
|
+
cached?.se04BootVersion
|
|
332
349
|
),
|
|
333
|
-
seVersion:
|
|
350
|
+
seVersion: cached?.seVersion ?? null,
|
|
334
351
|
verify: {
|
|
335
|
-
firmwareBuildId: getImageBuildId(fwApplication) ??
|
|
336
|
-
firmwareHash: getImageHash(fwApplication) ??
|
|
337
|
-
bootloaderBuildId: getImageBuildId(fwBootloader) ??
|
|
338
|
-
bootloaderHash: getImageHash(fwBootloader) ??
|
|
339
|
-
boardBuildId: getImageBuildId(fwBoard) ??
|
|
340
|
-
boardHash: getImageHash(fwBoard) ??
|
|
341
|
-
bleBuildId: getImageBuildId(bleApplication) ??
|
|
342
|
-
bleHash: getImageHash(bleApplication) ??
|
|
343
|
-
se01BuildId: getImageBuildId(
|
|
344
|
-
se01Hash: getImageHash(
|
|
345
|
-
se02BuildId: getImageBuildId(
|
|
346
|
-
se02Hash: getImageHash(
|
|
347
|
-
se03BuildId: getImageBuildId(
|
|
348
|
-
se03Hash: getImageHash(
|
|
349
|
-
se04BuildId: getImageBuildId(
|
|
350
|
-
se04Hash: getImageHash(
|
|
351
|
-
se01BootBuildId: getImageBuildId(
|
|
352
|
-
se01BootHash: getImageHash(
|
|
353
|
-
se02BootBuildId: getImageBuildId(
|
|
354
|
-
se02BootHash: getImageHash(
|
|
355
|
-
se03BootBuildId: getImageBuildId(
|
|
356
|
-
se03BootHash: getImageHash(
|
|
357
|
-
se04BootBuildId: getImageBuildId(
|
|
358
|
-
se04BootHash: getImageHash(
|
|
352
|
+
firmwareBuildId: getImageBuildId(fwApplication) ?? cached?.verify?.firmwareBuildId,
|
|
353
|
+
firmwareHash: getImageHash(fwApplication) ?? cached?.verify?.firmwareHash,
|
|
354
|
+
bootloaderBuildId: getImageBuildId(fwBootloader) ?? cached?.verify?.bootloaderBuildId,
|
|
355
|
+
bootloaderHash: getImageHash(fwBootloader) ?? cached?.verify?.bootloaderHash,
|
|
356
|
+
boardBuildId: getImageBuildId(fwBoard) ?? cached?.verify?.boardBuildId,
|
|
357
|
+
boardHash: getImageHash(fwBoard) ?? cached?.verify?.boardHash,
|
|
358
|
+
bleBuildId: getImageBuildId(bleApplication) ?? cached?.verify?.bleBuildId,
|
|
359
|
+
bleHash: getImageHash(bleApplication) ?? cached?.verify?.bleHash,
|
|
360
|
+
se01BuildId: getImageBuildId(info?.se1?.application) ?? cached?.verify?.se01BuildId,
|
|
361
|
+
se01Hash: getImageHash(info?.se1?.application) ?? cached?.verify?.se01Hash,
|
|
362
|
+
se02BuildId: getImageBuildId(info?.se2?.application) ?? cached?.verify?.se02BuildId,
|
|
363
|
+
se02Hash: getImageHash(info?.se2?.application) ?? cached?.verify?.se02Hash,
|
|
364
|
+
se03BuildId: getImageBuildId(info?.se3?.application) ?? cached?.verify?.se03BuildId,
|
|
365
|
+
se03Hash: getImageHash(info?.se3?.application) ?? cached?.verify?.se03Hash,
|
|
366
|
+
se04BuildId: getImageBuildId(info?.se4?.application) ?? cached?.verify?.se04BuildId,
|
|
367
|
+
se04Hash: getImageHash(info?.se4?.application) ?? cached?.verify?.se04Hash,
|
|
368
|
+
se01BootBuildId: getImageBuildId(info?.se1?.bootloader) ?? cached?.verify?.se01BootBuildId,
|
|
369
|
+
se01BootHash: getImageHash(info?.se1?.bootloader) ?? cached?.verify?.se01BootHash,
|
|
370
|
+
se02BootBuildId: getImageBuildId(info?.se2?.bootloader) ?? cached?.verify?.se02BootBuildId,
|
|
371
|
+
se02BootHash: getImageHash(info?.se2?.bootloader) ?? cached?.verify?.se02BootHash,
|
|
372
|
+
se03BootBuildId: getImageBuildId(info?.se3?.bootloader) ?? cached?.verify?.se03BootBuildId,
|
|
373
|
+
se03BootHash: getImageHash(info?.se3?.bootloader) ?? cached?.verify?.se03BootHash,
|
|
374
|
+
se04BootBuildId: getImageBuildId(info?.se4?.bootloader) ?? cached?.verify?.se04BootBuildId,
|
|
375
|
+
se04BootHash: getImageHash(info?.se4?.bootloader) ?? cached?.verify?.se04BootHash,
|
|
359
376
|
},
|
|
360
|
-
sessionId:
|
|
361
|
-
|
|
362
|
-
|
|
377
|
+
sessionId: cached?.sessionId ?? null,
|
|
378
|
+
device_id: deviceId ?? undefined,
|
|
379
|
+
session_id: cached?.sessionId ?? undefined,
|
|
380
|
+
ble_name: bleName ?? undefined,
|
|
381
|
+
onekey_device_type: 'PRO2',
|
|
382
|
+
passphrase_protection: passphraseProtection ?? undefined,
|
|
383
|
+
bootloader_mode: bootloaderMode,
|
|
384
|
+
passphraseState: cached?.passphraseState,
|
|
385
|
+
unlockedAttachPin,
|
|
363
386
|
raw: {
|
|
364
387
|
protocolV2DeviceInfo: deviceInfo,
|
|
388
|
+
protocolV2DeviceStatus: deviceStatus,
|
|
365
389
|
},
|
|
366
390
|
};
|
|
367
391
|
};
|
package/src/events/call.ts
CHANGED
|
@@ -53,6 +53,12 @@ export interface IFrameCancelMessage {
|
|
|
53
53
|
payload: { connectId?: string };
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
export interface IFrameCancelOperationMessage {
|
|
57
|
+
event: typeof IFRAME.CANCEL_OPERATION;
|
|
58
|
+
type: typeof IFRAME.CANCEL_OPERATION;
|
|
59
|
+
payload: { operationId: string };
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
export interface IFrameSwitchTransportMessage {
|
|
57
63
|
event: typeof IFRAME.SWITCH_TRANSPORT;
|
|
58
64
|
type: typeof IFRAME.SWITCH_TRANSPORT;
|
package/src/events/core.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
IFrameCallMessage,
|
|
6
6
|
IFrameCallbackMessage,
|
|
7
7
|
IFrameCancelMessage,
|
|
8
|
+
IFrameCancelOperationMessage,
|
|
8
9
|
IFrameSwitchTransportMessage,
|
|
9
10
|
} from './call';
|
|
10
11
|
import type { DeviceEventMessage } from './device';
|
|
@@ -23,6 +24,7 @@ export type CoreMessage = {
|
|
|
23
24
|
| IFrameEventMessage
|
|
24
25
|
| IFrameCallMessage
|
|
25
26
|
| IFrameCancelMessage
|
|
27
|
+
| IFrameCancelOperationMessage
|
|
26
28
|
| IFrameSwitchTransportMessage
|
|
27
29
|
| IFrameCallbackMessage
|
|
28
30
|
| UiResponseMessage
|