@onekeyfe/hd-core 1.2.0-alpha.2 → 1.2.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +75 -0
- package/__tests__/DeviceCommands.test.ts +285 -0
- package/__tests__/DeviceEventRegistration.test.ts +43 -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 +391 -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 +241 -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 +103 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +10 -6
- 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 +410 -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 +3954 -1191
- package/__tests__/protocolV2FileWrite.test.ts +92 -0
- package/__tests__/protocolV2UiInteraction.test.ts +266 -0
- package/__tests__/public-device-state-api.test.ts +257 -0
- package/__tests__/public-pro2-api-boundary.test.ts +110 -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 +8 -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 +17 -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 +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 +12 -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/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.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 +3 -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 +35 -11
- 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 +3 -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/device.d.ts +11 -2
- package/dist/events/device.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 +1361 -609
- package/dist/index.js +5898 -2860
- package/dist/inject.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/types/api/checkAllFirmwareRelease.d.ts +1 -2
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +11 -2
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +2 -2
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/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 +22 -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 +23 -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 +121 -5
- 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 +38 -7
- 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 +5 -2
- 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 +36 -9
- 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 +40 -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 +183 -1
- package/src/api/device/DeviceUnlock.ts +11 -1
- 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 +14 -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/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 +1 -0
- package/src/core/deviceEventRegistration.ts +23 -0
- package/src/core/index.ts +140 -35
- 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 +25 -0
- package/src/device/DevicePool.ts +67 -19
- package/src/device/DeviceStateMapper.ts +349 -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 +235 -210
- package/src/deviceProfile/index.ts +0 -1
- package/src/events/device.ts +17 -1
- package/src/events/logBlockEvent.ts +8 -1
- package/src/events/ui-request.ts +24 -2
- package/src/inject.ts +23 -34
- 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/types/api/checkAllFirmwareRelease.ts +1 -2
- package/src/types/api/deviceSettings.ts +26 -2
- package/src/types/api/deviceUnlock.ts +5 -2
- 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 +30 -53
- package/src/types/api/kaspaSignTransaction.ts +40 -2
- package/src/types/api/openWalletSession.ts +64 -0
- package/src/types/api/protocolV2.ts +58 -55
- package/src/types/api/sessionCache.ts +14 -0
- package/src/types/device.ts +170 -4
- 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 +161 -39
- 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 +21 -1
- 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,25 @@
|
|
|
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';
|
|
13
|
+
import { normalizeSafetyCheckLevel } from '../utils/deviceSettings';
|
|
6
14
|
|
|
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
|
-
};
|
|
15
|
+
import type {
|
|
16
|
+
DeviceFirmwareImageInfo,
|
|
17
|
+
DeviceStatus,
|
|
18
|
+
ProtocolV2DeviceInfo,
|
|
19
|
+
} from '@onekeyfe/hd-transport';
|
|
20
|
+
import type { PROTO } from '../constants';
|
|
21
|
+
import type { ProtocolV2RuntimeMode } from '../protocols/protocol-v2/features';
|
|
22
|
+
import type { DeviceFeaturesMode, Features } from '../types';
|
|
21
23
|
|
|
22
24
|
type ProtocolV1FeaturesCompat = PROTO.Features &
|
|
23
25
|
Partial<PROTO.OnekeyFeatures> & {
|
|
@@ -26,7 +28,7 @@ type ProtocolV1FeaturesCompat = PROTO.Features &
|
|
|
26
28
|
onekey_serial?: string;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
const getImageVersion = (image?:
|
|
31
|
+
const getImageVersion = (image?: DeviceFirmwareImageInfo | null) => image?.version ?? null;
|
|
30
32
|
|
|
31
33
|
const bytesToHex = (value: unknown): string | undefined => {
|
|
32
34
|
if (!value) return undefined;
|
|
@@ -42,9 +44,9 @@ const bytesToHex = (value: unknown): string | undefined => {
|
|
|
42
44
|
return undefined;
|
|
43
45
|
};
|
|
44
46
|
|
|
45
|
-
const getImageBuildId = (image?:
|
|
47
|
+
const getImageBuildId = (image?: DeviceFirmwareImageInfo | null) => image?.build_id ?? undefined;
|
|
46
48
|
|
|
47
|
-
const getImageHash = (image?:
|
|
49
|
+
const getImageHash = (image?: DeviceFirmwareImageInfo | null) => bytesToHex(image?.hash);
|
|
48
50
|
|
|
49
51
|
const firstValue = <T>(...values: Array<T | null | undefined>) =>
|
|
50
52
|
values.find(value => value !== undefined && value !== null);
|
|
@@ -52,70 +54,15 @@ const firstValue = <T>(...values: Array<T | null | undefined>) =>
|
|
|
52
54
|
const firstMeaningfulVersion = (...versions: Array<string | null | undefined>) =>
|
|
53
55
|
versions.find(version => Boolean(version && version !== '0.0.0')) ?? null;
|
|
54
56
|
|
|
55
|
-
const versionFromParts = (major?: number | null, minor?: number | null, patch?: number | null) =>
|
|
56
|
-
[major, minor, patch].map(part => Number(part) || 0).join('.');
|
|
57
|
-
|
|
58
57
|
const getProtocolV1Mode = (features: ProtocolV1FeaturesCompat): Features['mode'] => {
|
|
59
58
|
if (features.bootloader_mode === true) return 'bootloader';
|
|
60
59
|
if (features.initialized === false) return 'notInitialized';
|
|
61
|
-
if (features.
|
|
62
|
-
return '
|
|
60
|
+
if (features.no_backup === true) return 'backupMode';
|
|
61
|
+
return 'normal';
|
|
63
62
|
};
|
|
64
63
|
|
|
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
|
-
};
|
|
64
|
+
const getProtocolV1Label = (features: ProtocolV1FeaturesCompat) =>
|
|
65
|
+
typeof features.label === 'string' && features.label.length > 0 ? features.label : null;
|
|
119
66
|
|
|
120
67
|
export const buildProtocolV1FeaturesPayload = (
|
|
121
68
|
protocolV1Features: PROTO.Features,
|
|
@@ -123,37 +70,37 @@ export const buildProtocolV1FeaturesPayload = (
|
|
|
123
70
|
): Features => {
|
|
124
71
|
const features = protocolV1Features as ProtocolV1FeaturesCompat;
|
|
125
72
|
const firmwareVersion = firstMeaningfulVersion(
|
|
126
|
-
features
|
|
127
|
-
|
|
128
|
-
versionFromParts(features.major_version, features.minor_version, features.patch_version)
|
|
73
|
+
resolveDeviceFirmwareVersion(features),
|
|
74
|
+
previous?.firmwareVersion
|
|
129
75
|
);
|
|
130
76
|
const bootloaderVersion = firstMeaningfulVersion(
|
|
131
|
-
features
|
|
132
|
-
|
|
133
|
-
features.bootloader_mode
|
|
134
|
-
? versionFromParts(features.major_version, features.minor_version, features.patch_version)
|
|
135
|
-
: null
|
|
77
|
+
resolveDeviceBootloaderVersion(features),
|
|
78
|
+
previous?.bootloaderVersion
|
|
136
79
|
);
|
|
137
80
|
const boardVersion = firstMeaningfulVersion(
|
|
138
|
-
features
|
|
139
|
-
|
|
81
|
+
resolveDeviceBoardVersion(features),
|
|
82
|
+
previous?.boardVersion
|
|
140
83
|
);
|
|
141
|
-
const bleVersion = firstMeaningfulVersion(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
84
|
+
const bleVersion = firstMeaningfulVersion(
|
|
85
|
+
resolveDeviceBleFirmwareVersion(features),
|
|
86
|
+
previous?.bleVersion
|
|
87
|
+
);
|
|
88
|
+
const serialNo = resolveDeviceSerialNo(features);
|
|
89
|
+
const bleName = resolveDeviceBleName(features);
|
|
90
|
+
const deviceType = resolveDeviceType(features);
|
|
145
91
|
const sessionId = features.session_id ?? previous?.sessionId ?? null;
|
|
146
92
|
|
|
147
93
|
return {
|
|
94
|
+
...features,
|
|
148
95
|
protocol: 'V1',
|
|
149
96
|
protocolVersion: features.protocol_version ?? previous?.protocolVersion ?? 1,
|
|
150
97
|
deviceType,
|
|
151
|
-
firmwareType:
|
|
98
|
+
firmwareType: resolveDeviceFirmwareType(features),
|
|
152
99
|
model: features.model ?? null,
|
|
153
100
|
vendor: features.vendor ?? null,
|
|
154
101
|
deviceId: features.device_id ?? null,
|
|
155
102
|
serialNo,
|
|
156
|
-
label: getProtocolV1Label(features
|
|
103
|
+
label: getProtocolV1Label(features),
|
|
157
104
|
bleName,
|
|
158
105
|
capabilities: features.capabilities ?? [],
|
|
159
106
|
mode: getProtocolV1Mode(features),
|
|
@@ -173,111 +120,170 @@ export const buildProtocolV1FeaturesPayload = (
|
|
|
173
120
|
sdProtection: features.sd_protection ?? null,
|
|
174
121
|
wipeCodeProtection: features.wipe_code_protection ?? null,
|
|
175
122
|
passphraseAlwaysOnDevice: features.passphrase_always_on_device ?? null,
|
|
176
|
-
|
|
123
|
+
attachToPinEnabled: features.attach_to_pin_user ?? previous?.attachToPinEnabled ?? null,
|
|
124
|
+
unlockedAttachPin: features.unlocked_attach_pin ?? previous?.unlockedAttachPin ?? undefined,
|
|
125
|
+
safetyChecks: normalizeSafetyCheckLevel(features.safety_checks) ?? null,
|
|
177
126
|
autoLockDelayMs: features.auto_lock_delay_ms ?? null,
|
|
127
|
+
autoShutdownDelayMs: features.auto_shutdown_delay_ms ?? null,
|
|
178
128
|
displayRotation: features.display_rotation ?? null,
|
|
179
129
|
experimentalFeatures: features.experimental_features ?? null,
|
|
130
|
+
wallpaperPath: previous?.wallpaperPath ?? null,
|
|
131
|
+
brightness: features.brightness_prcent ?? previous?.brightness ?? null,
|
|
132
|
+
animationEnabled: previous?.animationEnabled ?? null,
|
|
133
|
+
tapToWake: previous?.tapToWake ?? null,
|
|
134
|
+
hapticFeedback: features.haptic_feedback ?? previous?.hapticFeedback ?? null,
|
|
135
|
+
deviceNameDisplayEnabled: previous?.deviceNameDisplayEnabled ?? null,
|
|
136
|
+
airgapMode: previous?.airgapMode ?? null,
|
|
137
|
+
fidoEnabled: previous?.fidoEnabled ?? null,
|
|
138
|
+
usbLockEnabled: previous?.usbLockEnabled ?? null,
|
|
139
|
+
randomKeypad: previous?.randomKeypad ?? null,
|
|
180
140
|
firmwareVersion,
|
|
181
141
|
bootloaderVersion,
|
|
182
142
|
boardVersion,
|
|
183
143
|
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
|
-
|
|
144
|
+
se01Version: firstMeaningfulVersion(features.onekey_se01_version, previous?.se01Version),
|
|
145
|
+
se02Version: firstMeaningfulVersion(features.onekey_se02_version, previous?.se02Version),
|
|
146
|
+
se03Version: firstMeaningfulVersion(features.onekey_se03_version, previous?.se03Version),
|
|
147
|
+
se04Version: firstMeaningfulVersion(features.onekey_se04_version, previous?.se04Version),
|
|
148
|
+
se01BootVersion: firstMeaningfulVersion(
|
|
149
|
+
features.onekey_se01_boot_version,
|
|
150
|
+
previous?.se01BootVersion
|
|
151
|
+
),
|
|
152
|
+
se02BootVersion: firstMeaningfulVersion(
|
|
153
|
+
features.onekey_se02_boot_version,
|
|
154
|
+
previous?.se02BootVersion
|
|
155
|
+
),
|
|
156
|
+
se03BootVersion: firstMeaningfulVersion(
|
|
157
|
+
features.onekey_se03_boot_version,
|
|
158
|
+
previous?.se03BootVersion
|
|
159
|
+
),
|
|
160
|
+
se04BootVersion: firstMeaningfulVersion(
|
|
161
|
+
features.onekey_se04_boot_version,
|
|
162
|
+
previous?.se04BootVersion
|
|
163
|
+
),
|
|
164
|
+
seVersion: features.se_ver ?? previous?.seVersion ?? null,
|
|
193
165
|
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,
|
|
166
|
+
firmwareBuildId: features.onekey_firmware_build_id ?? previous?.verify?.firmwareBuildId,
|
|
167
|
+
firmwareHash: features.onekey_firmware_hash ?? previous?.verify?.firmwareHash,
|
|
168
|
+
bootloaderBuildId: features.onekey_boot_build_id ?? previous?.verify?.bootloaderBuildId,
|
|
169
|
+
bootloaderHash: features.onekey_boot_hash ?? previous?.verify?.bootloaderHash,
|
|
170
|
+
boardBuildId: features.onekey_board_build_id ?? previous?.verify?.boardBuildId,
|
|
171
|
+
boardHash: features.onekey_board_hash ?? previous?.verify?.boardHash,
|
|
172
|
+
bleBuildId: features.onekey_ble_build_id ?? previous?.verify?.bleBuildId,
|
|
173
|
+
bleHash: features.onekey_ble_hash ?? previous?.verify?.bleHash,
|
|
174
|
+
se01BuildId: features.onekey_se01_build_id ?? previous?.verify?.se01BuildId,
|
|
175
|
+
se01Hash: features.onekey_se01_hash ?? previous?.verify?.se01Hash,
|
|
176
|
+
se02BuildId: features.onekey_se02_build_id ?? previous?.verify?.se02BuildId,
|
|
177
|
+
se02Hash: features.onekey_se02_hash ?? previous?.verify?.se02Hash,
|
|
178
|
+
se03BuildId: features.onekey_se03_build_id ?? previous?.verify?.se03BuildId,
|
|
179
|
+
se03Hash: features.onekey_se03_hash ?? previous?.verify?.se03Hash,
|
|
180
|
+
se04BuildId: features.onekey_se04_build_id ?? previous?.verify?.se04BuildId,
|
|
181
|
+
se04Hash: features.onekey_se04_hash ?? previous?.verify?.se04Hash,
|
|
182
|
+
se01BootBuildId: features.onekey_se01_boot_build_id ?? previous?.verify?.se01BootBuildId,
|
|
183
|
+
se01BootHash: features.onekey_se01_boot_hash ?? previous?.verify?.se01BootHash,
|
|
184
|
+
se02BootBuildId: features.onekey_se02_boot_build_id ?? previous?.verify?.se02BootBuildId,
|
|
185
|
+
se02BootHash: features.onekey_se02_boot_hash ?? previous?.verify?.se02BootHash,
|
|
186
|
+
se03BootBuildId: features.onekey_se03_boot_build_id ?? previous?.verify?.se03BootBuildId,
|
|
187
|
+
se03BootHash: features.onekey_se03_boot_hash ?? previous?.verify?.se03BootHash,
|
|
188
|
+
se04BootBuildId: features.onekey_se04_boot_build_id ?? previous?.verify?.se04BootBuildId,
|
|
189
|
+
se04BootHash: features.onekey_se04_boot_hash ?? previous?.verify?.se04BootHash,
|
|
218
190
|
},
|
|
219
191
|
sessionId,
|
|
192
|
+
session_id: sessionId ?? undefined,
|
|
220
193
|
raw: {
|
|
221
|
-
protocolV1Features
|
|
194
|
+
protocolV1Features,
|
|
222
195
|
},
|
|
223
196
|
};
|
|
224
197
|
};
|
|
225
198
|
|
|
226
199
|
/**
|
|
227
|
-
* Protocol V2
|
|
200
|
+
* Structured Protocol V2 `Features` builder.
|
|
228
201
|
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
202
|
+
* This is the only cached Device state. Fields come from DeviceInfoGet or same-name
|
|
203
|
+
* values in the previous cache. Fields without protocol-equivalent meaning remain
|
|
204
|
+
* null or empty and never fall back to DeviceState or a transport path.
|
|
232
205
|
*/
|
|
233
|
-
export const buildProtocolV2FeaturesPayload = (
|
|
234
|
-
deviceInfo
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
206
|
+
export const buildProtocolV2FeaturesPayload = ({
|
|
207
|
+
deviceInfo,
|
|
208
|
+
deviceStatus,
|
|
209
|
+
previous,
|
|
210
|
+
runtimeMode,
|
|
211
|
+
}: {
|
|
212
|
+
deviceInfo?: ProtocolV2DeviceInfo;
|
|
213
|
+
deviceStatus?: DeviceStatus;
|
|
214
|
+
previous?: Features;
|
|
215
|
+
runtimeMode?: ProtocolV2RuntimeMode;
|
|
216
|
+
}): Features => {
|
|
217
|
+
const info = deviceInfo;
|
|
218
|
+
const fwApplication = info?.fw?.application;
|
|
219
|
+
const fwBootloader = info?.fw?.bootloader;
|
|
220
|
+
const fwBoard = info?.fw?.romloader;
|
|
221
|
+
const bleApplication = info?.coprocessor?.application;
|
|
222
|
+
const status = deviceStatus;
|
|
223
|
+
const incomingSerialNo = info?.hw?.serial_no;
|
|
224
|
+
const samePhysicalDevice =
|
|
225
|
+
!incomingSerialNo || !previous?.serialNo || incomingSerialNo === previous.serialNo;
|
|
226
|
+
const cached = samePhysicalDevice ? previous : undefined;
|
|
242
227
|
|
|
243
228
|
const firmwareVersion = firstMeaningfulVersion(
|
|
244
229
|
getImageVersion(fwApplication),
|
|
245
|
-
|
|
230
|
+
cached?.firmwareVersion
|
|
246
231
|
);
|
|
247
232
|
const bootloaderVersion = firstMeaningfulVersion(
|
|
248
233
|
getImageVersion(fwBootloader),
|
|
249
|
-
|
|
234
|
+
cached?.bootloaderVersion
|
|
250
235
|
);
|
|
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
|
-
|
|
236
|
+
const boardVersion = firstMeaningfulVersion(getImageVersion(fwBoard), cached?.boardVersion);
|
|
237
|
+
const bleVersion = firstMeaningfulVersion(getImageVersion(bleApplication), cached?.bleVersion);
|
|
238
|
+
const deviceId = status?.device_id ?? cached?.deviceId ?? null;
|
|
239
|
+
const serialNo = firstValue(incomingSerialNo, cached?.serialNo) ?? '';
|
|
240
|
+
const label = cached?.label ?? null;
|
|
241
|
+
const bleName = firstValue(info?.coprocessor?.bt_adv_name, cached?.bleName);
|
|
242
|
+
const initialized = firstValue(status?.init_states, cached?.initialized) ?? null;
|
|
243
|
+
// passphrase_enabled from a locked Pro2 is not authoritative. Only DeviceStatus
|
|
244
|
+
// after PIN unlock can determine the final passphrase setting.
|
|
245
|
+
let passphraseProtection = cached?.passphraseProtection ?? null;
|
|
246
|
+
if (status?.unlocked === true) {
|
|
247
|
+
passphraseProtection = status.passphrase_enabled ?? null;
|
|
248
|
+
}
|
|
249
|
+
const language = cached?.language ?? null;
|
|
250
|
+
const backupRequired = firstValue(status?.backup_required, cached?.backupRequired) ?? null;
|
|
251
|
+
const bleEnabled = cached?.bleEnabled;
|
|
252
|
+
const unlocked = firstValue(status?.unlocked, cached?.unlocked) ?? null;
|
|
253
|
+
const attachToPinEnabled = status?.attach_to_pin_enabled ?? cached?.attachToPinEnabled ?? null;
|
|
254
|
+
const unlockedAttachPin =
|
|
255
|
+
status?.unlocked_by_attach_to_pin ?? cached?.unlockedAttachPin ?? undefined;
|
|
256
|
+
const bootloaderMode = runtimeMode === 'bootloader';
|
|
257
|
+
let mode: DeviceFeaturesMode = 'unknown';
|
|
258
|
+
if (runtimeMode) {
|
|
259
|
+
mode = runtimeMode;
|
|
260
|
+
} else if (initialized === false) {
|
|
261
|
+
mode = 'notInitialized';
|
|
262
|
+
} else if (initialized === true) {
|
|
263
|
+
mode = 'normal';
|
|
264
|
+
} else if (cached?.mode === 'notInitialized' || cached?.mode === 'backupMode') {
|
|
265
|
+
mode = cached.mode;
|
|
266
|
+
} else if (cached?.mode) {
|
|
267
|
+
mode = cached.mode;
|
|
268
|
+
}
|
|
263
269
|
|
|
264
270
|
return {
|
|
265
271
|
protocol: 'V2',
|
|
266
|
-
protocolVersion: deviceInfo?.protocol_version ??
|
|
272
|
+
protocolVersion: deviceInfo?.protocol_version ?? cached?.protocolVersion ?? null,
|
|
267
273
|
deviceType: EDeviceType.Pro2,
|
|
268
|
-
firmwareType:
|
|
274
|
+
firmwareType: cached?.firmwareType ?? EFirmwareType.Universal,
|
|
269
275
|
model: 'pro2',
|
|
270
276
|
vendor: 'onekey.so',
|
|
271
|
-
deviceId
|
|
277
|
+
deviceId,
|
|
272
278
|
serialNo,
|
|
273
279
|
label,
|
|
274
280
|
bleName: bleName ?? null,
|
|
275
281
|
capabilities: [],
|
|
276
|
-
mode
|
|
282
|
+
mode,
|
|
277
283
|
initialized,
|
|
278
|
-
bootloaderMode
|
|
279
|
-
unlocked
|
|
280
|
-
firmwarePresent:
|
|
284
|
+
bootloaderMode,
|
|
285
|
+
unlocked,
|
|
286
|
+
firmwarePresent: cached?.firmwarePresent ?? null,
|
|
281
287
|
passphraseProtection,
|
|
282
288
|
pinProtection: null,
|
|
283
289
|
backupRequired,
|
|
@@ -290,78 +296,97 @@ export const buildProtocolV2FeaturesPayload = (
|
|
|
290
296
|
sdProtection: null,
|
|
291
297
|
wipeCodeProtection: null,
|
|
292
298
|
passphraseAlwaysOnDevice: null,
|
|
299
|
+
attachToPinEnabled,
|
|
293
300
|
safetyChecks: null,
|
|
294
|
-
autoLockDelayMs: null,
|
|
301
|
+
autoLockDelayMs: cached?.autoLockDelayMs ?? null,
|
|
302
|
+
autoShutdownDelayMs: cached?.autoShutdownDelayMs ?? null,
|
|
295
303
|
displayRotation: null,
|
|
296
|
-
experimentalFeatures: null,
|
|
304
|
+
experimentalFeatures: cached?.experimentalFeatures ?? null,
|
|
305
|
+
wallpaperPath: cached?.wallpaperPath ?? null,
|
|
306
|
+
brightness: cached?.brightness ?? null,
|
|
307
|
+
animationEnabled: cached?.animationEnabled ?? null,
|
|
308
|
+
tapToWake: cached?.tapToWake ?? null,
|
|
309
|
+
hapticFeedback: cached?.hapticFeedback ?? null,
|
|
310
|
+
deviceNameDisplayEnabled: cached?.deviceNameDisplayEnabled ?? null,
|
|
311
|
+
airgapMode: cached?.airgapMode ?? null,
|
|
312
|
+
fidoEnabled: cached?.fidoEnabled ?? null,
|
|
313
|
+
usbLockEnabled: cached?.usbLockEnabled ?? null,
|
|
314
|
+
randomKeypad: cached?.randomKeypad ?? null,
|
|
297
315
|
firmwareVersion,
|
|
298
316
|
bootloaderVersion,
|
|
299
317
|
boardVersion,
|
|
300
318
|
bleVersion,
|
|
301
319
|
se01Version: firstMeaningfulVersion(
|
|
302
|
-
getImageVersion(
|
|
303
|
-
|
|
320
|
+
getImageVersion(info?.se1?.application),
|
|
321
|
+
cached?.se01Version
|
|
304
322
|
),
|
|
305
323
|
se02Version: firstMeaningfulVersion(
|
|
306
|
-
getImageVersion(
|
|
307
|
-
|
|
324
|
+
getImageVersion(info?.se2?.application),
|
|
325
|
+
cached?.se02Version
|
|
308
326
|
),
|
|
309
327
|
se03Version: firstMeaningfulVersion(
|
|
310
|
-
getImageVersion(
|
|
311
|
-
|
|
328
|
+
getImageVersion(info?.se3?.application),
|
|
329
|
+
cached?.se03Version
|
|
312
330
|
),
|
|
313
331
|
se04Version: firstMeaningfulVersion(
|
|
314
|
-
getImageVersion(
|
|
315
|
-
|
|
332
|
+
getImageVersion(info?.se4?.application),
|
|
333
|
+
cached?.se04Version
|
|
316
334
|
),
|
|
317
335
|
se01BootVersion: firstMeaningfulVersion(
|
|
318
|
-
getImageVersion(
|
|
319
|
-
|
|
336
|
+
getImageVersion(info?.se1?.bootloader),
|
|
337
|
+
cached?.se01BootVersion
|
|
320
338
|
),
|
|
321
339
|
se02BootVersion: firstMeaningfulVersion(
|
|
322
|
-
getImageVersion(
|
|
323
|
-
|
|
340
|
+
getImageVersion(info?.se2?.bootloader),
|
|
341
|
+
cached?.se02BootVersion
|
|
324
342
|
),
|
|
325
343
|
se03BootVersion: firstMeaningfulVersion(
|
|
326
|
-
getImageVersion(
|
|
327
|
-
|
|
344
|
+
getImageVersion(info?.se3?.bootloader),
|
|
345
|
+
cached?.se03BootVersion
|
|
328
346
|
),
|
|
329
347
|
se04BootVersion: firstMeaningfulVersion(
|
|
330
|
-
getImageVersion(
|
|
331
|
-
|
|
348
|
+
getImageVersion(info?.se4?.bootloader),
|
|
349
|
+
cached?.se04BootVersion
|
|
332
350
|
),
|
|
333
|
-
seVersion:
|
|
351
|
+
seVersion: cached?.seVersion ?? null,
|
|
334
352
|
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(
|
|
353
|
+
firmwareBuildId: getImageBuildId(fwApplication) ?? cached?.verify?.firmwareBuildId,
|
|
354
|
+
firmwareHash: getImageHash(fwApplication) ?? cached?.verify?.firmwareHash,
|
|
355
|
+
bootloaderBuildId: getImageBuildId(fwBootloader) ?? cached?.verify?.bootloaderBuildId,
|
|
356
|
+
bootloaderHash: getImageHash(fwBootloader) ?? cached?.verify?.bootloaderHash,
|
|
357
|
+
boardBuildId: getImageBuildId(fwBoard) ?? cached?.verify?.boardBuildId,
|
|
358
|
+
boardHash: getImageHash(fwBoard) ?? cached?.verify?.boardHash,
|
|
359
|
+
bleBuildId: getImageBuildId(bleApplication) ?? cached?.verify?.bleBuildId,
|
|
360
|
+
bleHash: getImageHash(bleApplication) ?? cached?.verify?.bleHash,
|
|
361
|
+
se01BuildId: getImageBuildId(info?.se1?.application) ?? cached?.verify?.se01BuildId,
|
|
362
|
+
se01Hash: getImageHash(info?.se1?.application) ?? cached?.verify?.se01Hash,
|
|
363
|
+
se02BuildId: getImageBuildId(info?.se2?.application) ?? cached?.verify?.se02BuildId,
|
|
364
|
+
se02Hash: getImageHash(info?.se2?.application) ?? cached?.verify?.se02Hash,
|
|
365
|
+
se03BuildId: getImageBuildId(info?.se3?.application) ?? cached?.verify?.se03BuildId,
|
|
366
|
+
se03Hash: getImageHash(info?.se3?.application) ?? cached?.verify?.se03Hash,
|
|
367
|
+
se04BuildId: getImageBuildId(info?.se4?.application) ?? cached?.verify?.se04BuildId,
|
|
368
|
+
se04Hash: getImageHash(info?.se4?.application) ?? cached?.verify?.se04Hash,
|
|
369
|
+
se01BootBuildId: getImageBuildId(info?.se1?.bootloader) ?? cached?.verify?.se01BootBuildId,
|
|
370
|
+
se01BootHash: getImageHash(info?.se1?.bootloader) ?? cached?.verify?.se01BootHash,
|
|
371
|
+
se02BootBuildId: getImageBuildId(info?.se2?.bootloader) ?? cached?.verify?.se02BootBuildId,
|
|
372
|
+
se02BootHash: getImageHash(info?.se2?.bootloader) ?? cached?.verify?.se02BootHash,
|
|
373
|
+
se03BootBuildId: getImageBuildId(info?.se3?.bootloader) ?? cached?.verify?.se03BootBuildId,
|
|
374
|
+
se03BootHash: getImageHash(info?.se3?.bootloader) ?? cached?.verify?.se03BootHash,
|
|
375
|
+
se04BootBuildId: getImageBuildId(info?.se4?.bootloader) ?? cached?.verify?.se04BootBuildId,
|
|
376
|
+
se04BootHash: getImageHash(info?.se4?.bootloader) ?? cached?.verify?.se04BootHash,
|
|
359
377
|
},
|
|
360
|
-
sessionId:
|
|
361
|
-
|
|
362
|
-
|
|
378
|
+
sessionId: cached?.sessionId ?? null,
|
|
379
|
+
device_id: deviceId ?? undefined,
|
|
380
|
+
session_id: cached?.sessionId ?? undefined,
|
|
381
|
+
ble_name: bleName ?? undefined,
|
|
382
|
+
onekey_device_type: 'PRO2',
|
|
383
|
+
passphrase_protection: passphraseProtection ?? undefined,
|
|
384
|
+
bootloader_mode: bootloaderMode,
|
|
385
|
+
passphraseState: cached?.passphraseState,
|
|
386
|
+
unlockedAttachPin,
|
|
363
387
|
raw: {
|
|
364
388
|
protocolV2DeviceInfo: deviceInfo,
|
|
389
|
+
protocolV2DeviceStatus: deviceStatus,
|
|
365
390
|
},
|
|
366
391
|
};
|
|
367
392
|
};
|
package/src/events/device.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { MessageFactoryFn } from './utils';
|
|
2
2
|
import type { PROTO } from '../constants';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
KnownDevice as Device,
|
|
5
|
+
DeviceStateEvent,
|
|
6
|
+
Features,
|
|
7
|
+
SupportFeatures,
|
|
8
|
+
} from '../types/device';
|
|
4
9
|
|
|
5
10
|
export const DEVICE_EVENT = 'DEVICE_EVENT';
|
|
6
11
|
export const DEVICE = {
|
|
@@ -23,12 +28,14 @@ export const DEVICE = {
|
|
|
23
28
|
PIN: 'pin',
|
|
24
29
|
PASSPHRASE: 'passphrase',
|
|
25
30
|
PASSPHRASE_ON_DEVICE: 'passphrase_on_device',
|
|
31
|
+
ATTACH_PIN_ON_DEVICE: 'attach_pin_on_device',
|
|
26
32
|
WORD: 'word',
|
|
27
33
|
SUPPORT_FEATURES: 'support_features',
|
|
28
34
|
SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE: 'select_device_in_bootloader_for_web_device',
|
|
29
35
|
SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE: 'select_device_for_switch_firmware_web_device',
|
|
30
36
|
|
|
31
37
|
FEATURES: 'features',
|
|
38
|
+
STATE: 'state',
|
|
32
39
|
} as const;
|
|
33
40
|
|
|
34
41
|
export interface DeviceConnnectRequest {
|
|
@@ -47,6 +54,9 @@ export interface DeviceButtonRequestPayload extends Omit<PROTO.ButtonRequest, 'c
|
|
|
47
54
|
|
|
48
55
|
export type PassphraseRequestPayload = {
|
|
49
56
|
existsAttachPinUser?: boolean;
|
|
57
|
+
source?: 'wallet-session-coordinator';
|
|
58
|
+
reason?: 'open-wallet' | 'session-recovery';
|
|
59
|
+
expectedPassphraseState?: string;
|
|
50
60
|
};
|
|
51
61
|
|
|
52
62
|
export interface DeviceButtonRequest {
|
|
@@ -61,6 +71,11 @@ export interface DeviceSendFeatures {
|
|
|
61
71
|
payload: DeviceFeaturesPayload;
|
|
62
72
|
}
|
|
63
73
|
|
|
74
|
+
export interface DeviceSendState {
|
|
75
|
+
type: typeof DEVICE.STATE;
|
|
76
|
+
payload: DeviceStateEvent;
|
|
77
|
+
}
|
|
78
|
+
|
|
64
79
|
export type DeviceSupportFeaturesPayload = SupportFeatures & { device: Device | null };
|
|
65
80
|
export interface DeviceSendSupportFeatures {
|
|
66
81
|
type: typeof DEVICE.SUPPORT_FEATURES;
|
|
@@ -69,6 +84,7 @@ export interface DeviceSendSupportFeatures {
|
|
|
69
84
|
|
|
70
85
|
export type DeviceEvent =
|
|
71
86
|
| DeviceButtonRequest
|
|
87
|
+
| DeviceSendState
|
|
72
88
|
| DeviceSendFeatures
|
|
73
89
|
| DeviceSendSupportFeatures
|
|
74
90
|
| DeviceDisconnnectRequest
|
|
@@ -5,7 +5,14 @@ export const LogBlockEvent: Set<string> = new Set([
|
|
|
5
5
|
UI_RESPONSE.RECEIVE_PASSPHRASE,
|
|
6
6
|
]);
|
|
7
7
|
|
|
8
|
-
const LogBlockMethod: Set<string> = new Set([
|
|
8
|
+
const LogBlockMethod: Set<string> = new Set([
|
|
9
|
+
'evmSignTypedData',
|
|
10
|
+
'openWalletSession',
|
|
11
|
+
'deviceUploadWallpaper',
|
|
12
|
+
'uploadPortfolio',
|
|
13
|
+
'fileWrite',
|
|
14
|
+
'fileRead',
|
|
15
|
+
]);
|
|
9
16
|
|
|
10
17
|
export function getLogBlockLabel(message: unknown): string | undefined {
|
|
11
18
|
if (!message || typeof message !== 'object') return undefined;
|