@onekeyfe/hd-core 1.1.34-alpha.1 → 1.1.34-alpha.3
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 +217 -0
- package/__tests__/RequestQueue.test.ts +140 -0
- package/__tests__/UploadPortfolio.test.ts +46 -0
- package/__tests__/connectSettings.test.ts +61 -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-mapper.test.ts +229 -0
- package/__tests__/device-utils.test.ts +106 -0
- package/__tests__/device-wallet-session-store.test.ts +191 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +15 -4
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/filesystemValidation.test.ts +53 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-checkpoint.test.ts +105 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +73 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +17 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +358 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-recovery.test.ts +81 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +48 -31
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +403 -0
- package/__tests__/logBlockEvent.test.ts +61 -0
- package/__tests__/logger.test.ts +34 -0
- package/__tests__/open-wallet-session.test.ts +565 -0
- package/__tests__/preInitialize.test.ts +33 -0
- package/__tests__/pro2Wallpaper.test.ts +39 -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 +6008 -0
- package/__tests__/protocolV2FileWrite.test.ts +67 -0
- package/__tests__/public-pro2-api-boundary.test.ts +66 -0
- package/__tests__/search-devices.test.ts +136 -0
- package/dist/api/BaseMethod.d.ts +12 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.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 +10 -0
- package/dist/api/DirList.d.ts.map +1 -0
- package/dist/api/DirMake.d.ts +9 -0
- package/dist/api/DirMake.d.ts.map +1 -0
- package/dist/api/DirRemove.d.ts +9 -0
- package/dist/api/DirRemove.d.ts.map +1 -0
- package/dist/api/FileDelete.d.ts +9 -0
- package/dist/api/FileDelete.d.ts.map +1 -0
- package/dist/api/FileRead.d.ts +19 -0
- package/dist/api/FileRead.d.ts.map +1 -0
- package/dist/api/FileWrite.d.ts +25 -0
- package/dist/api/FileWrite.d.ts.map +1 -0
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +14 -3
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +10 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +75 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -0
- 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.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 +10 -0
- package/dist/api/PathInfo.d.ts.map +1 -0
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +5 -1
- 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/alephium/AlephiumGetAddress.d.ts +2 -6
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts +2 -5
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts +5 -8
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts +2 -9
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts +2 -9
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts +2 -8
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts +2 -8
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -11
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -11
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -15
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -11
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -11
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -11
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.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 +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/DeviceSupportFeatures.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 +7 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceVerify.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -8
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getAddress.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getPublicKey.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signMessage.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/verifyMessage.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +26 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareCheckpoint.d.ts +15 -0
- package/dist/api/firmware/FirmwareCheckpoint.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +10 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +29 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +11 -0
- 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/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts +3 -0
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/helpers/filesystemValidation.d.ts +10 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
- 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 +29 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/lightning/LnurlAuth.d.ts +4 -0
- package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts +2 -8
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts +2 -8
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts +2 -9
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts +9 -12
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts +2 -8
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +2 -9
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +3 -0
- package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
- package/dist/api/polkadot/networks.d.ts +3 -0
- package/dist/api/polkadot/networks.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 +7 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- 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 +7 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts +28 -0
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts.map +1 -0
- 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 +6 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
- package/dist/api/protocol-v2/Ping.d.ts +8 -0
- package/dist/api/protocol-v2/Ping.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 +42 -0
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -0
- package/dist/api/scdo/ScdoGetAddress.d.ts +2 -6
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts +2 -5
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts +2 -5
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts +1 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +3 -0
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +3 -0
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +6 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +2 -1
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +3 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +3 -0
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +3 -0
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +3 -0
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +5 -2
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +3 -0
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +1 -0
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +3 -0
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +3 -0
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +3 -0
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +3 -0
- package/dist/api/tron/TronSignTransaction.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 +9 -5
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +5 -4
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +60 -16
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +16 -14
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +2 -1
- package/dist/device/DeviceConnector.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 +15 -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 +12 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -0
- package/dist/deviceProfile/index.d.ts +2 -0
- package/dist/deviceProfile/index.d.ts.map +1 -0
- 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 +1 -0
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +26 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +1797 -451
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26905 -5606
- 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 +88 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/firmware.d.ts +15 -0
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/index.d.ts +5 -0
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -0
- 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 +21 -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 +4 -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/deviceUpdateBootloader.d.ts +6 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +114 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +13 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +35 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +43 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- 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 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +48 -2
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +35 -0
- package/dist/types/api/openWalletSession.d.ts.map +1 -0
- package/dist/types/api/protocolV2.d.ts +113 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -0
- package/dist/types/api/searchDevices.d.ts +2 -2
- package/dist/types/api/searchDevices.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 +207 -5
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +3 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +33 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/capabilitieUtils.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 +17 -9
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +10 -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/findDefectiveBatchDevice.d.ts +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/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/dist/utils/versionUtils.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +60 -23
- package/src/api/CheckAllFirmwareRelease.ts +16 -3
- 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 +33 -0
- package/src/api/DirMake.ts +23 -0
- package/src/api/DirRemove.ts +23 -0
- package/src/api/FileDelete.ts +23 -0
- package/src/api/FileRead.ts +183 -0
- package/src/api/FileWrite.ts +71 -0
- package/src/api/FirmwareUpdate.ts +15 -7
- package/src/api/FirmwareUpdateV2.ts +354 -148
- package/src/api/FirmwareUpdateV3.ts +376 -62
- package/src/api/FirmwareUpdateV4.ts +2279 -0
- package/src/api/GetDeviceState.ts +55 -0
- package/src/api/GetFeatures.ts +12 -4
- package/src/api/GetOnekeyFeatures.ts +15 -3
- package/src/api/GetPassphraseState.ts +9 -10
- package/src/api/OpenWalletSession.ts +211 -0
- package/src/api/PathInfo.ts +41 -0
- package/src/api/PromptWebDeviceAccess.ts +10 -1
- package/src/api/SearchDevices.ts +33 -3
- package/src/api/UploadPortfolio.ts +50 -0
- package/src/api/alephium/AlephiumGetAddress.ts +6 -2
- package/src/api/alephium/AlephiumSignMessage.ts +6 -1
- package/src/api/alephium/AlephiumSignTransaction.ts +15 -4
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +25 -21
- package/src/api/aptos/AptosGetAddress.ts +2 -3
- package/src/api/benfen/BenfenGetAddress.ts +11 -7
- package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
- package/src/api/benfen/BenfenSignMessage.ts +6 -1
- package/src/api/benfen/BenfenSignTransaction.ts +6 -1
- package/src/api/btc/BTCGetPublicKey.ts +3 -2
- package/src/api/btc/BTCSignPsbt.ts +1 -2
- package/src/api/btc/helpers/versionLimit.ts +7 -1
- package/src/api/cardano/CardanoSignTransaction.ts +2 -4
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
- package/src/api/device/DeviceCancel.ts +1 -0
- package/src/api/device/DeviceChangePin.ts +24 -0
- package/src/api/device/DeviceFullyUploadResource.ts +6 -7
- package/src/api/device/DeviceLock.ts +2 -3
- package/src/api/device/DeviceRebootToBoardloader.ts +11 -1
- package/src/api/device/DeviceRebootToBootloader.ts +11 -1
- package/src/api/device/DeviceSettings.ts +121 -0
- package/src/api/device/DeviceSupportFeatures.ts +2 -13
- package/src/api/device/DeviceUnlock.ts +9 -0
- package/src/api/device/DeviceUpdateBootloader.ts +175 -11
- package/src/api/device/DeviceUploadResource.ts +4 -5
- package/src/api/device/DeviceVerify.ts +1 -2
- package/src/api/device/DeviceWipe.ts +19 -0
- package/src/api/dynex/DnxGetAddress.ts +6 -0
- package/src/api/dynex/DnxSignTransaction.ts +6 -0
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +3 -4
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +14 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +30 -18
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/evm/latest/signTypedHash.ts +2 -4
- package/src/api/evm/legacyV1/getAddress.ts +5 -3
- package/src/api/evm/legacyV1/getPublicKey.ts +5 -3
- package/src/api/evm/legacyV1/signMessage.ts +5 -3
- package/src/api/evm/legacyV1/signTypedData.ts +9 -8
- package/src/api/evm/legacyV1/signTypedHash.ts +7 -7
- package/src/api/evm/legacyV1/verifyMessage.ts +5 -3
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareCheckpoint.ts +188 -0
- package/src/api/firmware/FirmwareHostBinding.ts +108 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -15
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +13 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +729 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +403 -0
- package/src/api/firmware/bootloaderHelper.ts +3 -2
- package/src/api/firmware/getBinary.ts +1 -1
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/releaseHelper.ts +3 -3
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +148 -34
- package/src/api/helpers/batchGetPublickeys.ts +51 -6
- package/src/api/helpers/filesystemValidation.ts +112 -0
- package/src/api/helpers/protocolV2FileWrite.ts +193 -0
- package/src/api/index.ts +32 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +2 -3
- package/src/api/lightning/LnurlAuth.ts +4 -0
- package/src/api/neo/NeoGetAddress.ts +6 -1
- package/src/api/neo/NeoSignTransaction.ts +6 -1
- package/src/api/nervos/NervosGetAddress.ts +6 -2
- package/src/api/nervos/NervosSignTransaction.ts +14 -4
- package/src/api/nexa/NexaGetAddress.ts +6 -2
- package/src/api/nexa/NexaSignTransaction.ts +11 -12
- package/src/api/polkadot/networks.ts +9 -0
- package/src/api/protocol-v2/DeviceFactoryInfoGet.ts +20 -0
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +61 -0
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +55 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +18 -0
- package/src/api/protocol-v2/DeviceInfoGet.ts +145 -0
- package/src/api/protocol-v2/DeviceReboot.ts +26 -0
- package/src/api/protocol-v2/DeviceSessionOpen.ts +102 -0
- 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 +19 -0
- package/src/api/protocol-v2/FilesystemPermissionFix.ts +16 -0
- package/src/api/protocol-v2/Ping.ts +18 -0
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +16 -0
- package/src/api/protocol-v2/helpers.ts +203 -0
- package/src/api/scdo/ScdoGetAddress.ts +6 -2
- package/src/api/scdo/ScdoSignMessage.ts +6 -1
- package/src/api/scdo/ScdoSignTransaction.ts +6 -2
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +3 -0
- package/src/api/solana/SolSignOffchainMessage.ts +3 -0
- package/src/api/solana/SolSignTransaction.ts +6 -0
- package/src/api/stellar/StellarGetAddress.ts +10 -1
- package/src/api/stellar/StellarSignTransaction.ts +14 -1
- package/src/api/sui/SuiGetAddress.ts +5 -3
- package/src/api/sui/SuiGetPublicKey.ts +3 -0
- package/src/api/sui/SuiSignMessage.ts +3 -0
- package/src/api/sui/SuiSignTransaction.ts +14 -12
- package/src/api/ton/TonGetAddress.ts +3 -0
- package/src/api/ton/TonSignData.ts +6 -3
- package/src/api/ton/TonSignMessage.ts +6 -5
- package/src/api/ton/TonSignProof.ts +3 -0
- package/src/api/tron/TronSignMessage.ts +4 -1
- package/src/api/tron/TronSignTransaction.ts +3 -0
- package/src/api/utils.ts +7 -3
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- 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 +255 -116
- package/src/data/messages/messages-protocol-v2.json +13544 -0
- package/src/data-manager/DataManager.ts +61 -49
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +38 -12
- package/src/data-manager/connectSettings.ts +15 -0
- package/src/device/Device.ts +759 -164
- package/src/device/DeviceCommands.ts +245 -36
- package/src/device/DeviceConnector.ts +29 -4
- package/src/device/DeviceFeaturesState.ts +34 -0
- package/src/device/DevicePool.ts +69 -21
- 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 +78 -0
- package/src/device/cloneDeviceState.ts +39 -0
- package/src/device/deviceIdentity.ts +18 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +391 -0
- package/src/deviceProfile/index.ts +4 -0
- 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 +30 -0
- package/src/events/ui-request.ts +32 -2
- package/src/index.ts +9 -0
- package/src/inject.ts +75 -3
- package/src/lowLevelInject.ts +8 -1
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +163 -0
- package/src/protocols/protocol-v2/firmware.ts +21 -0
- package/src/protocols/protocol-v2/index.ts +18 -0
- 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 +202 -0
- package/src/topLevelInject.ts +7 -1
- package/src/types/api/checkAllFirmwareRelease.ts +4 -2
- package/src/types/api/deviceSettings.ts +9 -0
- package/src/types/api/deviceUnlock.ts +1 -1
- package/src/types/api/deviceUpdateBootloader.ts +10 -1
- package/src/types/api/export.ts +25 -0
- package/src/types/api/firmwareUpdate.ts +163 -1
- package/src/types/api/firmwareUpdateCapabilities.ts +13 -0
- package/src/types/api/firmwareUpdatePlan.ts +52 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +55 -0
- 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 +10 -2
- package/src/types/api/index.ts +89 -2
- package/src/types/api/openWalletSession.ts +54 -0
- package/src/types/api/protocolV2.ts +244 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/api/sessionCache.ts +14 -0
- package/src/types/device.ts +266 -5
- package/src/types/params.ts +11 -0
- package/src/types/settings.ts +54 -29
- package/src/utils/capabilitieUtils.ts +1 -2
- package/src/utils/deviceFeaturesCompat.ts +173 -0
- package/src/utils/deviceFeaturesUtils.ts +122 -84
- package/src/utils/deviceInfoUtils.ts +38 -87
- package/src/utils/deviceSettings.ts +48 -0
- package/src/utils/deviceVersionUtils.ts +25 -62
- package/src/utils/findDefectiveBatchDevice.ts +8 -8
- package/src/utils/homescreen.ts +10 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/pro2Wallpaper.ts +109 -0
- package/src/utils/tracing.ts +3 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export class DeviceWalletSessionStore {
|
|
2
|
+
private readonly walletSessions = new Map<string, Map<string, string>>();
|
|
3
|
+
|
|
4
|
+
private readonly pendingSessions = new Map<string, string>();
|
|
5
|
+
|
|
6
|
+
get(deviceKey: string, passphraseState?: string) {
|
|
7
|
+
if (!deviceKey || !passphraseState) return undefined;
|
|
8
|
+
return this.walletSessions.get(deviceKey)?.get(passphraseState);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
set(deviceKey: string, passphraseState?: string, sessionId?: string) {
|
|
12
|
+
if (!deviceKey || !passphraseState || !sessionId) return;
|
|
13
|
+
let deviceSessions = this.walletSessions.get(deviceKey);
|
|
14
|
+
if (!deviceSessions) {
|
|
15
|
+
deviceSessions = new Map<string, string>();
|
|
16
|
+
this.walletSessions.set(deviceKey, deviceSessions);
|
|
17
|
+
}
|
|
18
|
+
deviceSessions.set(passphraseState, sessionId);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
setPending(deviceKey: string, sessionId?: string) {
|
|
22
|
+
if (!deviceKey || !sessionId) return;
|
|
23
|
+
this.pendingSessions.set(deviceKey, sessionId);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getPending(deviceKey: string) {
|
|
27
|
+
if (!deviceKey) return undefined;
|
|
28
|
+
return this.pendingSessions.get(deviceKey);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
delete(deviceKey: string, passphraseState?: string) {
|
|
32
|
+
if (!deviceKey || !passphraseState) return;
|
|
33
|
+
const deviceSessions = this.walletSessions.get(deviceKey);
|
|
34
|
+
if (!deviceSessions) return;
|
|
35
|
+
deviceSessions.delete(passphraseState);
|
|
36
|
+
if (deviceSessions.size === 0) {
|
|
37
|
+
this.walletSessions.delete(deviceKey);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
deletePending(deviceKey: string) {
|
|
42
|
+
if (!deviceKey) return;
|
|
43
|
+
this.pendingSessions.delete(deviceKey);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
deleteDevice(deviceKey: string) {
|
|
47
|
+
if (!deviceKey) return;
|
|
48
|
+
this.walletSessions.delete(deviceKey);
|
|
49
|
+
this.pendingSessions.delete(deviceKey);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
migrateDeviceKey(from: string, to: string) {
|
|
53
|
+
if (!from || !to || from === to) return;
|
|
54
|
+
|
|
55
|
+
const sourceSessions = this.walletSessions.get(from);
|
|
56
|
+
if (sourceSessions) {
|
|
57
|
+
const targetSessions = this.walletSessions.get(to) ?? new Map<string, string>();
|
|
58
|
+
this.walletSessions.set(to, targetSessions);
|
|
59
|
+
sourceSessions.forEach((sessionId, passphraseState) => {
|
|
60
|
+
targetSessions.set(passphraseState, sessionId);
|
|
61
|
+
});
|
|
62
|
+
this.walletSessions.delete(from);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const pendingSession = this.pendingSessions.get(from);
|
|
66
|
+
if (pendingSession) {
|
|
67
|
+
this.pendingSessions.set(to, pendingSession);
|
|
68
|
+
this.pendingSessions.delete(from);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
clear() {
|
|
73
|
+
this.walletSessions.clear();
|
|
74
|
+
this.pendingSessions.clear();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const deviceWalletSessionStore = new DeviceWalletSessionStore();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-independent deep clone for DeviceState snapshots.
|
|
3
|
+
*
|
|
4
|
+
* Avoid the global structuredClone API because older Hermes and WebView hosts do not
|
|
5
|
+
* provide it. Explicitly clone plain objects, arrays, binary buffers, and common
|
|
6
|
+
* built-ins so initialization and state snapshots remain portable.
|
|
7
|
+
*/
|
|
8
|
+
export const cloneDeviceState = <T>(value: T): T => {
|
|
9
|
+
if (value === null || typeof value !== 'object') {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Copy underlying binary memory so external mutation cannot alter a snapshot.
|
|
14
|
+
if (value instanceof Uint8Array) {
|
|
15
|
+
return new Uint8Array(value) as unknown as T;
|
|
16
|
+
}
|
|
17
|
+
if (value instanceof ArrayBuffer) {
|
|
18
|
+
return value.slice(0) as unknown as T;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (value instanceof Date) {
|
|
22
|
+
return new Date(value.getTime()) as unknown as T;
|
|
23
|
+
}
|
|
24
|
+
if (value instanceof RegExp) {
|
|
25
|
+
return new RegExp(value.source, value.flags) as unknown as T;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
return value.map(item => cloneDeviceState(item)) as unknown as T;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Recursively copy plain objects; DeviceState has no class-instance prototypes.
|
|
33
|
+
const cloned: Record<string, unknown> = {};
|
|
34
|
+
const source = value as Record<string, unknown>;
|
|
35
|
+
for (const key of Object.keys(source)) {
|
|
36
|
+
cloned[key] = cloneDeviceState(source[key]);
|
|
37
|
+
}
|
|
38
|
+
return cloned as unknown as T;
|
|
39
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Device } from './Device';
|
|
2
|
+
|
|
3
|
+
type DeviceIdentityReader = Pick<Device, 'isProtocolV2' | 'getDeviceState' | 'checkDeviceId'>;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Protocol V2 deviceId comes from runtime state and requires a live status read.
|
|
7
|
+
* Protocol V1 reuses the identity returned by Initialize/GetFeatures.
|
|
8
|
+
*/
|
|
9
|
+
export async function checkLiveDeviceId(
|
|
10
|
+
device: DeviceIdentityReader,
|
|
11
|
+
expectedDeviceId: string
|
|
12
|
+
): Promise<boolean> {
|
|
13
|
+
if (device.isProtocolV2()) {
|
|
14
|
+
await device.getDeviceState({ refreshSections: ['status'] });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return device.checkDeviceId(expectedDeviceId);
|
|
18
|
+
}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
resolveDeviceBleFirmwareVersion,
|
|
5
|
+
resolveDeviceBleName,
|
|
6
|
+
resolveDeviceBoardVersion,
|
|
7
|
+
resolveDeviceBootloaderVersion,
|
|
8
|
+
resolveDeviceFirmwareType,
|
|
9
|
+
resolveDeviceFirmwareVersion,
|
|
10
|
+
resolveDeviceSerialNo,
|
|
11
|
+
resolveDeviceType,
|
|
12
|
+
} from '../utils/deviceFeaturesCompat';
|
|
13
|
+
|
|
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';
|
|
22
|
+
|
|
23
|
+
type ProtocolV1FeaturesCompat = PROTO.Features &
|
|
24
|
+
Partial<PROTO.OnekeyFeatures> & {
|
|
25
|
+
protocol_version?: number | null;
|
|
26
|
+
onekey_version?: string;
|
|
27
|
+
onekey_serial?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getImageVersion = (image?: DeviceFirmwareImageInfo | null) => image?.version ?? null;
|
|
31
|
+
|
|
32
|
+
const bytesToHex = (value: unknown): string | undefined => {
|
|
33
|
+
if (!value) return undefined;
|
|
34
|
+
if (typeof value === 'string') return value;
|
|
35
|
+
if (value instanceof Uint8Array) {
|
|
36
|
+
return Array.from(value)
|
|
37
|
+
.map(byte => byte.toString(16).padStart(2, '0'))
|
|
38
|
+
.join('');
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(value)) {
|
|
41
|
+
return value.map(byte => Number(byte).toString(16).padStart(2, '0')).join('');
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const getImageBuildId = (image?: DeviceFirmwareImageInfo | null) => image?.build_id ?? undefined;
|
|
47
|
+
|
|
48
|
+
const getImageHash = (image?: DeviceFirmwareImageInfo | null) => bytesToHex(image?.hash);
|
|
49
|
+
|
|
50
|
+
const firstValue = <T>(...values: Array<T | null | undefined>) =>
|
|
51
|
+
values.find(value => value !== undefined && value !== null);
|
|
52
|
+
|
|
53
|
+
const firstMeaningfulVersion = (...versions: Array<string | null | undefined>) =>
|
|
54
|
+
versions.find(version => Boolean(version && version !== '0.0.0')) ?? null;
|
|
55
|
+
|
|
56
|
+
const getProtocolV1Mode = (features: ProtocolV1FeaturesCompat): Features['mode'] => {
|
|
57
|
+
if (features.bootloader_mode === true) return 'bootloader';
|
|
58
|
+
if (features.initialized === false) return 'notInitialized';
|
|
59
|
+
if (features.no_backup === true) return 'backupMode';
|
|
60
|
+
return 'normal';
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const getProtocolV1Label = (features: ProtocolV1FeaturesCompat) =>
|
|
64
|
+
typeof features.label === 'string' && features.label.length > 0 ? features.label : null;
|
|
65
|
+
|
|
66
|
+
export const buildProtocolV1FeaturesPayload = (
|
|
67
|
+
protocolV1Features: PROTO.Features,
|
|
68
|
+
previous?: Features
|
|
69
|
+
): Features => {
|
|
70
|
+
const features = protocolV1Features as ProtocolV1FeaturesCompat;
|
|
71
|
+
const firmwareVersion = firstMeaningfulVersion(
|
|
72
|
+
resolveDeviceFirmwareVersion(features),
|
|
73
|
+
previous?.firmwareVersion
|
|
74
|
+
);
|
|
75
|
+
const bootloaderVersion = firstMeaningfulVersion(
|
|
76
|
+
resolveDeviceBootloaderVersion(features),
|
|
77
|
+
previous?.bootloaderVersion
|
|
78
|
+
);
|
|
79
|
+
const boardVersion = firstMeaningfulVersion(
|
|
80
|
+
resolveDeviceBoardVersion(features),
|
|
81
|
+
previous?.boardVersion
|
|
82
|
+
);
|
|
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);
|
|
90
|
+
const sessionId = features.session_id ?? previous?.sessionId ?? null;
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
...features,
|
|
94
|
+
protocol: 'V1',
|
|
95
|
+
protocolVersion: features.protocol_version ?? previous?.protocolVersion ?? 1,
|
|
96
|
+
deviceType,
|
|
97
|
+
firmwareType: resolveDeviceFirmwareType(features),
|
|
98
|
+
model: features.model ?? null,
|
|
99
|
+
vendor: features.vendor ?? null,
|
|
100
|
+
deviceId: features.device_id ?? null,
|
|
101
|
+
serialNo,
|
|
102
|
+
label: getProtocolV1Label(features),
|
|
103
|
+
bleName,
|
|
104
|
+
capabilities: features.capabilities ?? [],
|
|
105
|
+
mode: getProtocolV1Mode(features),
|
|
106
|
+
initialized: features.initialized ?? null,
|
|
107
|
+
bootloaderMode: features.bootloader_mode ?? null,
|
|
108
|
+
unlocked: features.unlocked ?? true,
|
|
109
|
+
firmwarePresent: features.firmware_present ?? null,
|
|
110
|
+
passphraseProtection: features.passphrase_protection ?? null,
|
|
111
|
+
pinProtection: features.pin_protection ?? null,
|
|
112
|
+
backupRequired: features.needs_backup ?? null,
|
|
113
|
+
noBackup: features.no_backup ?? null,
|
|
114
|
+
unfinishedBackup: features.unfinished_backup ?? null,
|
|
115
|
+
recoveryMode: features.recovery_mode ?? null,
|
|
116
|
+
language: features.language ?? null,
|
|
117
|
+
bleEnabled: features.ble_enable ?? null,
|
|
118
|
+
sdCardPresent: features.sd_card_present ?? null,
|
|
119
|
+
sdProtection: features.sd_protection ?? null,
|
|
120
|
+
wipeCodeProtection: features.wipe_code_protection ?? null,
|
|
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,
|
|
124
|
+
safetyChecks: features.safety_checks ?? null,
|
|
125
|
+
autoLockDelayMs: features.auto_lock_delay_ms ?? null,
|
|
126
|
+
autoShutdownDelayMs: features.auto_shutdown_delay_ms ?? null,
|
|
127
|
+
displayRotation: features.display_rotation ?? null,
|
|
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,
|
|
139
|
+
firmwareVersion,
|
|
140
|
+
bootloaderVersion,
|
|
141
|
+
boardVersion,
|
|
142
|
+
bleVersion,
|
|
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,
|
|
164
|
+
verify: {
|
|
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,
|
|
189
|
+
},
|
|
190
|
+
sessionId,
|
|
191
|
+
session_id: sessionId ?? undefined,
|
|
192
|
+
raw: {
|
|
193
|
+
protocolV1Features,
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Structured Protocol V2 `Features` builder.
|
|
200
|
+
*
|
|
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.
|
|
204
|
+
*/
|
|
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;
|
|
226
|
+
|
|
227
|
+
const firmwareVersion = firstMeaningfulVersion(
|
|
228
|
+
getImageVersion(fwApplication),
|
|
229
|
+
cached?.firmwareVersion
|
|
230
|
+
);
|
|
231
|
+
const bootloaderVersion = firstMeaningfulVersion(
|
|
232
|
+
getImageVersion(fwBootloader),
|
|
233
|
+
cached?.bootloaderVersion
|
|
234
|
+
);
|
|
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
|
+
}
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
protocol: 'V2',
|
|
271
|
+
protocolVersion: deviceInfo?.protocol_version ?? cached?.protocolVersion ?? null,
|
|
272
|
+
deviceType: EDeviceType.Pro2,
|
|
273
|
+
firmwareType: cached?.firmwareType ?? EFirmwareType.Universal,
|
|
274
|
+
model: 'pro2',
|
|
275
|
+
vendor: 'onekey.so',
|
|
276
|
+
deviceId,
|
|
277
|
+
serialNo,
|
|
278
|
+
label,
|
|
279
|
+
bleName: bleName ?? null,
|
|
280
|
+
capabilities: [],
|
|
281
|
+
mode,
|
|
282
|
+
initialized,
|
|
283
|
+
bootloaderMode,
|
|
284
|
+
unlocked,
|
|
285
|
+
firmwarePresent: cached?.firmwarePresent ?? null,
|
|
286
|
+
passphraseProtection,
|
|
287
|
+
pinProtection: null,
|
|
288
|
+
backupRequired,
|
|
289
|
+
noBackup: null,
|
|
290
|
+
unfinishedBackup: null,
|
|
291
|
+
recoveryMode: null,
|
|
292
|
+
language,
|
|
293
|
+
bleEnabled: bleEnabled ?? null,
|
|
294
|
+
sdCardPresent: null,
|
|
295
|
+
sdProtection: null,
|
|
296
|
+
wipeCodeProtection: null,
|
|
297
|
+
passphraseAlwaysOnDevice: null,
|
|
298
|
+
attachToPinEnabled,
|
|
299
|
+
safetyChecks: null,
|
|
300
|
+
autoLockDelayMs: cached?.autoLockDelayMs ?? null,
|
|
301
|
+
autoShutdownDelayMs: cached?.autoShutdownDelayMs ?? null,
|
|
302
|
+
displayRotation: 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,
|
|
314
|
+
firmwareVersion,
|
|
315
|
+
bootloaderVersion,
|
|
316
|
+
boardVersion,
|
|
317
|
+
bleVersion,
|
|
318
|
+
se01Version: firstMeaningfulVersion(
|
|
319
|
+
getImageVersion(info?.se1?.application),
|
|
320
|
+
cached?.se01Version
|
|
321
|
+
),
|
|
322
|
+
se02Version: firstMeaningfulVersion(
|
|
323
|
+
getImageVersion(info?.se2?.application),
|
|
324
|
+
cached?.se02Version
|
|
325
|
+
),
|
|
326
|
+
se03Version: firstMeaningfulVersion(
|
|
327
|
+
getImageVersion(info?.se3?.application),
|
|
328
|
+
cached?.se03Version
|
|
329
|
+
),
|
|
330
|
+
se04Version: firstMeaningfulVersion(
|
|
331
|
+
getImageVersion(info?.se4?.application),
|
|
332
|
+
cached?.se04Version
|
|
333
|
+
),
|
|
334
|
+
se01BootVersion: firstMeaningfulVersion(
|
|
335
|
+
getImageVersion(info?.se1?.bootloader),
|
|
336
|
+
cached?.se01BootVersion
|
|
337
|
+
),
|
|
338
|
+
se02BootVersion: firstMeaningfulVersion(
|
|
339
|
+
getImageVersion(info?.se2?.bootloader),
|
|
340
|
+
cached?.se02BootVersion
|
|
341
|
+
),
|
|
342
|
+
se03BootVersion: firstMeaningfulVersion(
|
|
343
|
+
getImageVersion(info?.se3?.bootloader),
|
|
344
|
+
cached?.se03BootVersion
|
|
345
|
+
),
|
|
346
|
+
se04BootVersion: firstMeaningfulVersion(
|
|
347
|
+
getImageVersion(info?.se4?.bootloader),
|
|
348
|
+
cached?.se04BootVersion
|
|
349
|
+
),
|
|
350
|
+
seVersion: cached?.seVersion ?? null,
|
|
351
|
+
verify: {
|
|
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,
|
|
376
|
+
},
|
|
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,
|
|
386
|
+
raw: {
|
|
387
|
+
protocolV2DeviceInfo: deviceInfo,
|
|
388
|
+
protocolV2DeviceStatus: deviceStatus,
|
|
389
|
+
},
|
|
390
|
+
};
|
|
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
|
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
|
package/src/events/iframe.ts
CHANGED
|
@@ -4,3 +4,33 @@ export const LogBlockEvent: Set<string> = new Set([
|
|
|
4
4
|
UI_RESPONSE.RECEIVE_PIN,
|
|
5
5
|
UI_RESPONSE.RECEIVE_PASSPHRASE,
|
|
6
6
|
]);
|
|
7
|
+
|
|
8
|
+
const LogBlockMethod: Set<string> = new Set([
|
|
9
|
+
'evmSignTypedData',
|
|
10
|
+
'deviceSessionOpen',
|
|
11
|
+
'deviceUploadWallpaper',
|
|
12
|
+
'uploadPortfolio',
|
|
13
|
+
'fileWrite',
|
|
14
|
+
'fileRead',
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
export function getLogBlockLabel(message: unknown): string | undefined {
|
|
18
|
+
if (!message || typeof message !== 'object') return undefined;
|
|
19
|
+
|
|
20
|
+
const { type, payload, method } = message as {
|
|
21
|
+
type?: string;
|
|
22
|
+
payload?: { method?: string };
|
|
23
|
+
method?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
if (type && LogBlockEvent.has(type)) {
|
|
27
|
+
return type;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const methodName = method ?? payload?.method;
|
|
31
|
+
if (methodName && LogBlockMethod.has(methodName)) {
|
|
32
|
+
return methodName;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|