@onekeyfe/hd-core 1.1.34-alpha.2 → 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 -5611
- 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 +253 -125
- 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,188 @@
|
|
|
1
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
FirmwareCheckpoint,
|
|
5
|
+
FirmwareCheckpointParams,
|
|
6
|
+
FirmwareCheckpointStage,
|
|
7
|
+
} from '../../types/api/firmwareUpdate';
|
|
8
|
+
|
|
9
|
+
const CHECKPOINT_TIMEOUT_MS = 5000;
|
|
10
|
+
const MAX_CHECKPOINT_TARGET_LENGTH = 160;
|
|
11
|
+
|
|
12
|
+
type FirmwareCheckpointState = {
|
|
13
|
+
latestSequence: number;
|
|
14
|
+
tail: Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const checkpointStateBySink = new WeakMap<
|
|
18
|
+
NonNullable<FirmwareCheckpointParams['checkpointSink']>,
|
|
19
|
+
FirmwareCheckpointState
|
|
20
|
+
>();
|
|
21
|
+
|
|
22
|
+
const checkpointError = (message: string) =>
|
|
23
|
+
ERRORS.TypedError(HardwareErrorCode.RuntimeError, message, {
|
|
24
|
+
firmwareUpdateCode: 'FirmwareCheckpointRejected',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const validateFirmwareCheckpoint = (value: unknown): FirmwareCheckpoint => {
|
|
28
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
29
|
+
throw checkpointError('Firmware resume checkpoint is invalid');
|
|
30
|
+
}
|
|
31
|
+
const checkpoint = value as Partial<FirmwareCheckpoint>;
|
|
32
|
+
const allowedKeys = new Set([
|
|
33
|
+
'schemaVersion',
|
|
34
|
+
'sequence',
|
|
35
|
+
'stage',
|
|
36
|
+
'destructiveActionStarted',
|
|
37
|
+
'target',
|
|
38
|
+
'epoch',
|
|
39
|
+
]);
|
|
40
|
+
if (
|
|
41
|
+
Object.keys(checkpoint).some(key => !allowedKeys.has(key)) ||
|
|
42
|
+
!['schemaVersion', 'sequence', 'stage', 'destructiveActionStarted'].every(key =>
|
|
43
|
+
Object.prototype.hasOwnProperty.call(checkpoint, key)
|
|
44
|
+
) ||
|
|
45
|
+
checkpoint.schemaVersion !== 1 ||
|
|
46
|
+
!Number.isSafeInteger(checkpoint.sequence) ||
|
|
47
|
+
(checkpoint.sequence as number) < 1 ||
|
|
48
|
+
![
|
|
49
|
+
'EPOCH_STARTED',
|
|
50
|
+
'EPOCH_COMPLETED',
|
|
51
|
+
'BEFORE_DEVICE_MODE_CHANGE',
|
|
52
|
+
'FILE_TRANSFER_STARTED',
|
|
53
|
+
'FILE_TRANSFER_COMPLETED',
|
|
54
|
+
'INSTALL_REQUESTED',
|
|
55
|
+
'INSTALL_ACCEPTED',
|
|
56
|
+
'FINAL_VERIFIED',
|
|
57
|
+
].includes(checkpoint.stage as string) ||
|
|
58
|
+
checkpoint.destructiveActionStarted !== true ||
|
|
59
|
+
(checkpoint.target !== undefined &&
|
|
60
|
+
(!checkpoint.target ||
|
|
61
|
+
checkpoint.target.length > MAX_CHECKPOINT_TARGET_LENGTH ||
|
|
62
|
+
/(?:https?|file):\/\//iu.test(checkpoint.target) ||
|
|
63
|
+
/^(?:\/|[A-Za-z]:[\\/])/u.test(checkpoint.target))) ||
|
|
64
|
+
(checkpoint.epoch !== undefined &&
|
|
65
|
+
(!Number.isSafeInteger(checkpoint.epoch) || checkpoint.epoch < 0))
|
|
66
|
+
) {
|
|
67
|
+
throw checkpointError('Firmware resume checkpoint fields are invalid');
|
|
68
|
+
}
|
|
69
|
+
return checkpoint as FirmwareCheckpoint;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const validateCheckpointParams = (params: FirmwareCheckpointParams, required: boolean) => {
|
|
73
|
+
const { checkpointSequenceStart, checkpointSink } = params;
|
|
74
|
+
const resumeCheckpoint =
|
|
75
|
+
params.resumeCheckpoint === undefined
|
|
76
|
+
? undefined
|
|
77
|
+
: validateFirmwareCheckpoint(params.resumeCheckpoint);
|
|
78
|
+
if (
|
|
79
|
+
checkpointSequenceStart !== undefined &&
|
|
80
|
+
(!Number.isSafeInteger(checkpointSequenceStart) || checkpointSequenceStart < 0)
|
|
81
|
+
) {
|
|
82
|
+
throw checkpointError('Firmware checkpoint sequence is invalid');
|
|
83
|
+
}
|
|
84
|
+
if (
|
|
85
|
+
checkpointSink !== undefined &&
|
|
86
|
+
(typeof checkpointSink !== 'object' ||
|
|
87
|
+
checkpointSink === null ||
|
|
88
|
+
typeof checkpointSink.commit !== 'function')
|
|
89
|
+
) {
|
|
90
|
+
throw checkpointError('Firmware checkpoint sink is invalid');
|
|
91
|
+
}
|
|
92
|
+
if (required && !checkpointSink) {
|
|
93
|
+
throw checkpointError('Prepared firmware update requires a checkpoint sink');
|
|
94
|
+
}
|
|
95
|
+
if (resumeCheckpoint && checkpointSequenceStart !== resumeCheckpoint.sequence) {
|
|
96
|
+
throw checkpointError('Firmware checkpoint sequence does not match recovery state');
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const waitForCheckpoint = async (commit: Promise<void>) => {
|
|
101
|
+
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
|
102
|
+
try {
|
|
103
|
+
await Promise.race([
|
|
104
|
+
commit,
|
|
105
|
+
new Promise<never>((_, reject) => {
|
|
106
|
+
timeoutId = setTimeout(
|
|
107
|
+
() => reject(checkpointError('Firmware checkpoint commit timed out')),
|
|
108
|
+
CHECKPOINT_TIMEOUT_MS
|
|
109
|
+
);
|
|
110
|
+
}),
|
|
111
|
+
]);
|
|
112
|
+
} finally {
|
|
113
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export class FirmwareCheckpointWriter {
|
|
118
|
+
private readonly sink: FirmwareCheckpointParams['checkpointSink'];
|
|
119
|
+
|
|
120
|
+
private readonly sequenceStart: number;
|
|
121
|
+
|
|
122
|
+
constructor(params: FirmwareCheckpointParams, { required = false } = {}) {
|
|
123
|
+
validateCheckpointParams(params, required);
|
|
124
|
+
this.sink = params.checkpointSink;
|
|
125
|
+
this.sequenceStart = params.checkpointSequenceStart ?? 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async commit({
|
|
129
|
+
stage,
|
|
130
|
+
target,
|
|
131
|
+
epoch,
|
|
132
|
+
}: {
|
|
133
|
+
stage: FirmwareCheckpointStage;
|
|
134
|
+
target?: string;
|
|
135
|
+
epoch?: number;
|
|
136
|
+
}): Promise<void> {
|
|
137
|
+
if (!this.sink) return;
|
|
138
|
+
if (
|
|
139
|
+
(target !== undefined &&
|
|
140
|
+
(!target ||
|
|
141
|
+
target.length > MAX_CHECKPOINT_TARGET_LENGTH ||
|
|
142
|
+
/(?:https?|file):\/\//iu.test(target) ||
|
|
143
|
+
/^(?:\/|[A-Za-z]:[\\/])/u.test(target))) ||
|
|
144
|
+
(epoch !== undefined && (!Number.isSafeInteger(epoch) || epoch < 0))
|
|
145
|
+
) {
|
|
146
|
+
throw checkpointError('Firmware checkpoint metadata is invalid');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let state = checkpointStateBySink.get(this.sink);
|
|
150
|
+
if (!state) {
|
|
151
|
+
state = {
|
|
152
|
+
latestSequence: this.sequenceStart,
|
|
153
|
+
tail: Promise.resolve(),
|
|
154
|
+
};
|
|
155
|
+
checkpointStateBySink.set(this.sink, state);
|
|
156
|
+
} else if (this.sequenceStart > state.latestSequence) {
|
|
157
|
+
state.latestSequence = this.sequenceStart;
|
|
158
|
+
}
|
|
159
|
+
const activeState = state;
|
|
160
|
+
|
|
161
|
+
const queuedCommit = activeState.tail.then(async () => {
|
|
162
|
+
const sequence = activeState.latestSequence + 1;
|
|
163
|
+
const checkpoint: FirmwareCheckpoint = {
|
|
164
|
+
schemaVersion: 1,
|
|
165
|
+
sequence,
|
|
166
|
+
stage,
|
|
167
|
+
destructiveActionStarted: true,
|
|
168
|
+
...(target ? { target } : {}),
|
|
169
|
+
...(epoch !== undefined ? { epoch } : {}),
|
|
170
|
+
};
|
|
171
|
+
try {
|
|
172
|
+
await this.sink?.commit(checkpoint);
|
|
173
|
+
activeState.latestSequence = sequence;
|
|
174
|
+
} catch (error) {
|
|
175
|
+
throw checkpointError(
|
|
176
|
+
`Firmware checkpoint commit was rejected: ${
|
|
177
|
+
error instanceof Error ? error.message : 'unknown error'
|
|
178
|
+
}`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Keep the real commit serialized even when the caller's timeout fires. A
|
|
184
|
+
// later call cannot overtake an unresolved or late checkpoint write.
|
|
185
|
+
activeState.tail = queuedCommit.catch(() => undefined);
|
|
186
|
+
await waitForCheckpoint(queuedCommit);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
import type { FirmwareUpdateHostBinding } from '../../types/api/firmwareUpdate';
|
|
4
|
+
|
|
5
|
+
const bindingError = (message: string): never => {
|
|
6
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, message, {
|
|
7
|
+
firmwareUpdateCode: 'FirmwareArtifactReaderInvalid',
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
class FirmwareHostBindingRegistry {
|
|
12
|
+
private generation = 0;
|
|
13
|
+
|
|
14
|
+
private binding?: FirmwareUpdateHostBinding;
|
|
15
|
+
|
|
16
|
+
register(binding: FirmwareUpdateHostBinding): number {
|
|
17
|
+
if (
|
|
18
|
+
!binding ||
|
|
19
|
+
typeof binding.artifactReader?.open !== 'function' ||
|
|
20
|
+
typeof binding.artifactReader.read !== 'function' ||
|
|
21
|
+
typeof binding.artifactReader.close !== 'function' ||
|
|
22
|
+
typeof binding.checkpointSink?.commit !== 'function'
|
|
23
|
+
) {
|
|
24
|
+
return bindingError('Firmware host binding is invalid');
|
|
25
|
+
}
|
|
26
|
+
this.generation += 1;
|
|
27
|
+
this.binding = binding;
|
|
28
|
+
return this.generation;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
unregister(generation?: number): boolean {
|
|
32
|
+
if (generation !== undefined && generation !== this.generation) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
this.generation += 1;
|
|
36
|
+
this.binding = undefined;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getGeneration(): number {
|
|
41
|
+
return this.generation;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resolve(generation: number): FirmwareUpdateHostBinding {
|
|
45
|
+
if (
|
|
46
|
+
!Number.isSafeInteger(generation) ||
|
|
47
|
+
generation <= 0 ||
|
|
48
|
+
generation !== this.generation ||
|
|
49
|
+
!this.binding
|
|
50
|
+
) {
|
|
51
|
+
return bindingError(`Firmware host binding generation ${generation} is stale`);
|
|
52
|
+
}
|
|
53
|
+
const { binding } = this;
|
|
54
|
+
const assertCurrent = () => {
|
|
55
|
+
if (generation !== this.generation || binding !== this.binding) {
|
|
56
|
+
bindingError(`Firmware host binding generation ${generation} is stale`);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
artifactReader: {
|
|
61
|
+
open: async input => {
|
|
62
|
+
assertCurrent();
|
|
63
|
+
const opened = await binding.artifactReader.open(input);
|
|
64
|
+
try {
|
|
65
|
+
assertCurrent();
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (opened?.readerId) {
|
|
68
|
+
await binding.artifactReader
|
|
69
|
+
.close({ readerId: opened.readerId })
|
|
70
|
+
.catch(() => undefined);
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
return opened;
|
|
75
|
+
},
|
|
76
|
+
read: async input => {
|
|
77
|
+
assertCurrent();
|
|
78
|
+
const result = await binding.artifactReader.read(input);
|
|
79
|
+
assertCurrent();
|
|
80
|
+
return result;
|
|
81
|
+
},
|
|
82
|
+
close: input => binding.artifactReader.close(input),
|
|
83
|
+
},
|
|
84
|
+
checkpointSink: {
|
|
85
|
+
commit: async checkpoint => {
|
|
86
|
+
assertCurrent();
|
|
87
|
+
await binding.checkpointSink.commit(checkpoint);
|
|
88
|
+
assertCurrent();
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const firmwareHostBindingRegistry = new FirmwareHostBindingRegistry();
|
|
96
|
+
|
|
97
|
+
export const registerFirmwareUpdateHostBinding = (binding: FirmwareUpdateHostBinding): number =>
|
|
98
|
+
firmwareHostBindingRegistry.register(binding);
|
|
99
|
+
|
|
100
|
+
export const unregisterFirmwareUpdateHostBinding = (generation?: number): boolean =>
|
|
101
|
+
firmwareHostBindingRegistry.unregister(generation);
|
|
102
|
+
|
|
103
|
+
export const getFirmwareUpdateHostBindingGeneration = (): number =>
|
|
104
|
+
firmwareHostBindingRegistry.getGeneration();
|
|
105
|
+
|
|
106
|
+
export const resolveFirmwareUpdateHostBinding = (
|
|
107
|
+
generation: number | undefined
|
|
108
|
+
): FirmwareUpdateHostBinding => firmwareHostBindingRegistry.resolve(generation ?? Number.NaN);
|
|
@@ -8,12 +8,15 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import { FirmwareUpdateTipMessage, UI_REQUEST, createUiMessage } from '../../events/ui-request';
|
|
10
10
|
import { DevicePool } from '../../device/DevicePool';
|
|
11
|
-
import { LoggerNames,
|
|
11
|
+
import { LoggerNames, getLogger, wait } from '../../utils';
|
|
12
12
|
import { DeviceModelToTypes } from '../../types';
|
|
13
13
|
import { DataManager } from '../../data-manager';
|
|
14
14
|
import { BaseMethod } from '../BaseMethod';
|
|
15
15
|
import { DEVICE } from '../../events';
|
|
16
|
+
import { createFirmwareProgressThrottle } from './progressThrottle';
|
|
17
|
+
import { writeFirmwareByteSource } from './FirmwareArtifactSource';
|
|
16
18
|
|
|
19
|
+
import type { FirmwareCheckpointWriter } from './FirmwareCheckpoint';
|
|
17
20
|
import type {
|
|
18
21
|
IFirmwareUpdateProgressType,
|
|
19
22
|
IFirmwareUpdateTipMessage,
|
|
@@ -23,6 +26,7 @@ import type { RebootType } from '@onekeyfe/hd-transport';
|
|
|
23
26
|
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
24
27
|
import type { KnownDevice } from '../../types';
|
|
25
28
|
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
29
|
+
import type { FirmwareByteSource } from './FirmwareArtifactSource';
|
|
26
30
|
|
|
27
31
|
const Log = getLogger(LoggerNames.Method);
|
|
28
32
|
const SESSION_ERROR = 'session not found';
|
|
@@ -40,6 +44,8 @@ const isDeviceDisconnectedError = (error: unknown) => {
|
|
|
40
44
|
export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
41
45
|
checkPromise: Deferred<any> | null = null;
|
|
42
46
|
|
|
47
|
+
private shouldPostFirmwareProgress = createFirmwareProgressThrottle();
|
|
48
|
+
|
|
43
49
|
init(): void {}
|
|
44
50
|
|
|
45
51
|
run(): Promise<any> {
|
|
@@ -83,6 +89,10 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
83
89
|
* @param progress Post the percentage of the progress
|
|
84
90
|
*/
|
|
85
91
|
postProgressMessage = (progress: number, progressType: IFirmwareUpdateProgressType) => {
|
|
92
|
+
if (!this.shouldPostFirmwareProgress(progress, progressType)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
86
96
|
this.postMessage(
|
|
87
97
|
createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
|
|
88
98
|
device: this.device.toMessageObject() as KnownDevice,
|
|
@@ -138,12 +148,14 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
138
148
|
// check device goto bootloader mode
|
|
139
149
|
let isFirstCheck = true;
|
|
140
150
|
let checkCount = 0;
|
|
151
|
+
let hasPromptedWebDevice = false;
|
|
152
|
+
let isPromptingWebDevice = false;
|
|
141
153
|
// eslint-disable-next-line prefer-const
|
|
142
154
|
let timeoutTimer: ReturnType<typeof setTimeout> | undefined;
|
|
143
155
|
|
|
144
156
|
const isTouchOrProDevice =
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
this?.device?.getCurrentDeviceType() === EDeviceType.Touch ||
|
|
158
|
+
this?.device?.getCurrentDeviceType() === EDeviceType.Pro;
|
|
147
159
|
|
|
148
160
|
const intervalTimer: ReturnType<typeof setInterval> | undefined = setInterval(
|
|
149
161
|
async () => {
|
|
@@ -158,23 +170,28 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
158
170
|
if (
|
|
159
171
|
checkCount > 4 &&
|
|
160
172
|
DataManager.isBrowserWebUsb(DataManager.getSettings('env')) &&
|
|
161
|
-
!this.payload.skipWebDevicePrompt
|
|
173
|
+
!this.payload.skipWebDevicePrompt &&
|
|
174
|
+
!hasPromptedWebDevice &&
|
|
175
|
+
!isPromptingWebDevice
|
|
162
176
|
) {
|
|
163
|
-
|
|
164
|
-
clearTimeout(timeoutTimer);
|
|
165
|
-
|
|
177
|
+
isPromptingWebDevice = true;
|
|
166
178
|
try {
|
|
167
179
|
this.postTipMessage(FirmwareUpdateTipMessage.SelectDeviceInBootloaderForWebDevice);
|
|
168
180
|
const confirmed = await this._promptDeviceInBootloaderForWebDevice();
|
|
181
|
+
hasPromptedWebDevice = true;
|
|
169
182
|
if (confirmed) {
|
|
170
183
|
await this._checkDeviceInBootloaderMode(connectId, intervalTimer, timeoutTimer);
|
|
171
184
|
}
|
|
172
185
|
} catch (e) {
|
|
186
|
+
clearInterval(intervalTimer);
|
|
187
|
+
clearTimeout(timeoutTimer);
|
|
173
188
|
Log.log(
|
|
174
189
|
'FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ',
|
|
175
190
|
e
|
|
176
191
|
);
|
|
177
192
|
this.checkPromise?.reject(e);
|
|
193
|
+
} finally {
|
|
194
|
+
isPromptingWebDevice = false;
|
|
178
195
|
}
|
|
179
196
|
return;
|
|
180
197
|
}
|
|
@@ -187,7 +204,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
187
204
|
true
|
|
188
205
|
);
|
|
189
206
|
await this.device.initialize();
|
|
190
|
-
if (this.device.
|
|
207
|
+
if (this.device.isBootloader()) {
|
|
191
208
|
clearInterval(intervalTimer);
|
|
192
209
|
this.checkPromise?.resolve(true);
|
|
193
210
|
}
|
|
@@ -220,7 +237,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
220
237
|
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
221
238
|
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, connectId);
|
|
222
239
|
|
|
223
|
-
if (deviceList.length === 1 && deviceList[0]?.
|
|
240
|
+
if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
|
|
224
241
|
// should update current device from cache
|
|
225
242
|
// because device was reboot and had some new requests
|
|
226
243
|
this.device.updateFromCache(deviceList[0]);
|
|
@@ -234,14 +251,17 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
234
251
|
return false;
|
|
235
252
|
}
|
|
236
253
|
|
|
237
|
-
async enterBootloaderMode() {
|
|
254
|
+
async enterBootloaderMode(checkpointWriter?: FirmwareCheckpointWriter) {
|
|
238
255
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
239
|
-
if (this.device.features && !this.device.
|
|
240
|
-
const
|
|
241
|
-
const deviceType =
|
|
256
|
+
if (this.device.features && !this.device.isBootloader()) {
|
|
257
|
+
const serialNo = this.device.getCurrentSerialNo();
|
|
258
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
242
259
|
// auto go to bootloader mode
|
|
243
260
|
try {
|
|
244
261
|
this.postTipMessage(FirmwareUpdateTipMessage.AutoRebootToBootloader);
|
|
262
|
+
await checkpointWriter?.commit({
|
|
263
|
+
stage: 'BEFORE_DEVICE_MODE_CHANGE',
|
|
264
|
+
});
|
|
245
265
|
const bootRes = await typedCall('DeviceBackToBoot', 'Success');
|
|
246
266
|
// @ts-expect-error
|
|
247
267
|
if (bootRes.type === 'CallMethodError') {
|
|
@@ -252,7 +272,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
252
272
|
|
|
253
273
|
// force clean classic device cache so that the device can initialize again
|
|
254
274
|
if (DeviceModelToTypes.model_classic.includes(deviceType)) {
|
|
255
|
-
DevicePool.clearDeviceCache(
|
|
275
|
+
DevicePool.clearDeviceCache(serialNo);
|
|
256
276
|
}
|
|
257
277
|
delete DevicePool.devicesCache[''];
|
|
258
278
|
await this.checkPromise?.promise;
|
|
@@ -373,6 +393,54 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
373
393
|
return totalSize !== undefined ? (processedSize ?? 0) + payload.byteLength : 0;
|
|
374
394
|
}
|
|
375
395
|
|
|
396
|
+
async emmcCommonUpdateProcessFromSource({
|
|
397
|
+
source,
|
|
398
|
+
filePath,
|
|
399
|
+
processedSize,
|
|
400
|
+
totalSize,
|
|
401
|
+
}: {
|
|
402
|
+
source: FirmwareByteSource;
|
|
403
|
+
filePath: string;
|
|
404
|
+
processedSize?: number;
|
|
405
|
+
totalSize?: number;
|
|
406
|
+
}) {
|
|
407
|
+
if (!filePath.startsWith('0:')) {
|
|
408
|
+
throw new Error('filePath must start with 0:');
|
|
409
|
+
}
|
|
410
|
+
const env = DataManager.getSettings('env');
|
|
411
|
+
const chunkSize = 1024 * (DataManager.isBleConnect(env) ? 16 : 128);
|
|
412
|
+
|
|
413
|
+
await writeFirmwareByteSource({
|
|
414
|
+
source,
|
|
415
|
+
chunkSize,
|
|
416
|
+
write: async ({ data, sourceOffset, length, first }) => {
|
|
417
|
+
const progress =
|
|
418
|
+
totalSize !== undefined && processedSize !== undefined
|
|
419
|
+
? Math.min(Math.ceil(((processedSize + sourceOffset + length) / totalSize) * 100), 99)
|
|
420
|
+
: Math.min(Math.ceil(((sourceOffset + length) / source.size) * 100), 99);
|
|
421
|
+
const writeRes = await this.emmcFileWriteWithRetry(
|
|
422
|
+
filePath,
|
|
423
|
+
length,
|
|
424
|
+
sourceOffset,
|
|
425
|
+
data,
|
|
426
|
+
first,
|
|
427
|
+
progress
|
|
428
|
+
);
|
|
429
|
+
if (!writeRes) {
|
|
430
|
+
throw ERRORS.TypedError(
|
|
431
|
+
HardwareErrorCode.EmmcFileWriteFirmwareError,
|
|
432
|
+
'transfer data error'
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
const processedBytes = Number(writeRes.message.processed_byte);
|
|
436
|
+
this.postProgressMessage(progress, 'transferData');
|
|
437
|
+
return Number.isFinite(processedBytes) ? processedBytes : length;
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
return totalSize !== undefined ? (processedSize ?? 0) + source.size : 0;
|
|
442
|
+
}
|
|
443
|
+
|
|
376
444
|
async emmcFileWriteWithRetry(
|
|
377
445
|
filePath: string,
|
|
378
446
|
chunkLength: number,
|
|
@@ -436,7 +504,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
436
504
|
const deviceDiff = await this.device.deviceConnector?.enumerate();
|
|
437
505
|
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
438
506
|
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, undefined);
|
|
439
|
-
if (deviceList.length === 1 && deviceList[0]?.
|
|
507
|
+
if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
|
|
440
508
|
this.device.updateFromCache(deviceList[0]);
|
|
441
509
|
await this.device.acquire();
|
|
442
510
|
this.device.getCommands().mainId = this.device.mainId ?? '';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FirmwareUpdateCapabilities } from '../../types/api/firmwareUpdateCapabilities';
|
|
2
|
+
|
|
3
|
+
export const getFirmwareUpdateCapabilities = (): FirmwareUpdateCapabilities => ({
|
|
4
|
+
planSchemaVersion: 1,
|
|
5
|
+
preparedPlanSchemaVersion: 1,
|
|
6
|
+
hostBindingProtocolVersion: 1,
|
|
7
|
+
checkpointSchemaVersion: 1,
|
|
8
|
+
manifestModes: ['external-only', 'sdk-managed'],
|
|
9
|
+
supportsArtifactReader: true,
|
|
10
|
+
supportsAwaitableCheckpoint: true,
|
|
11
|
+
supportsResume: true,
|
|
12
|
+
supportsReconciliation: true,
|
|
13
|
+
});
|