@onekeyfe/hd-core 1.2.0-alpha.9 → 1.2.0-alpha.90
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 +390 -0
- package/__tests__/DeviceCommands.test.ts +563 -0
- package/__tests__/DeviceEventRegistration.test.ts +49 -0
- package/__tests__/chain-params-onekey-compatibility.test.ts +229 -0
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +825 -0
- package/__tests__/check-firmware-release-protocol-v2.test.ts +199 -0
- package/__tests__/connectSettings.test.ts +45 -5
- package/__tests__/core-dispose.test.ts +34 -0
- package/__tests__/core-error-output.test.ts +39 -0
- package/__tests__/core-initialization.test.ts +23 -0
- package/__tests__/device-connector-protocol.test.ts +81 -0
- package/__tests__/device-features-state.test.ts +78 -0
- package/__tests__/device-identity.test.ts +52 -0
- package/__tests__/device-initialize-timeout.test.ts +56 -0
- package/__tests__/device-lifecycle-events.test.ts +351 -0
- package/__tests__/device-pool-state.test.ts +166 -0
- package/__tests__/device-settings.test.ts +437 -0
- package/__tests__/device-state-contract.test.ts +28 -0
- package/__tests__/device-state-events.test.ts +286 -0
- package/__tests__/device-state-mapper.test.ts +288 -0
- package/__tests__/device-state-projector.test.ts +114 -0
- package/__tests__/device-state-store.test.ts +109 -0
- package/__tests__/device-utils.test.ts +154 -0
- package/__tests__/device-wallet-session-store.test.ts +348 -1
- package/__tests__/deviceFeaturesUtils.test.ts +39 -0
- package/__tests__/devicePoolBootloaderPath.test.ts +64 -0
- package/__tests__/deviceSettings.test.ts +113 -0
- package/__tests__/deviceUploadNft.test.ts +316 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +12 -6
- package/__tests__/evmSignTransaction.test.ts +69 -0
- package/__tests__/evmSignTypedData.test.ts +80 -0
- package/__tests__/filesystemValidation.test.ts +53 -0
- package/__tests__/firmware-memory-host.test.ts +112 -0
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/device-update-bootloader.test.ts +91 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +79 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-prepared-host-digest.test.ts +209 -0
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +394 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +654 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +283 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +457 -0
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +121 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +578 -0
- package/__tests__/homescreen.test.ts +81 -0
- package/__tests__/kaspa-public-types.type-test.ts +16 -0
- package/__tests__/kaspa-use-tweak-pro2.test.ts +20 -0
- package/__tests__/kaspaSignTransaction.test.ts +578 -0
- package/__tests__/known-device-public-types.type-test.ts +3 -0
- package/__tests__/logBlockEvent.test.ts +128 -1
- package/__tests__/method-protocol-support.test.ts +144 -0
- package/__tests__/networkUtils.test.ts +406 -0
- package/__tests__/open-wallet-session-error-response.test.ts +43 -0
- package/__tests__/open-wallet-session.test.ts +1899 -0
- package/__tests__/pro2Nft.test.ts +108 -0
- package/__tests__/pro2Wallpaper.test.ts +39 -0
- package/__tests__/protocol-binding.test.ts +89 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +66 -0
- package/__tests__/protocol-v2-ping.test.ts +28 -0
- package/__tests__/protocol-v2-resources.test.ts +270 -0
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +91 -0
- package/__tests__/protocol-v2-unlock-policy.test.ts +308 -0
- package/__tests__/protocol-v2.test.ts +6669 -1759
- package/__tests__/protocolV2FileWrite.test.ts +285 -0
- package/__tests__/protocolV2UiInteraction.test.ts +329 -0
- package/__tests__/public-device-state-api.test.ts +275 -0
- package/__tests__/public-pro2-api-boundary.test.ts +107 -0
- package/__tests__/refresh-device-state.test.ts +101 -0
- package/__tests__/request-context-logging.test.ts +16 -0
- package/__tests__/search-devices.test.ts +145 -0
- package/__tests__/tron-sign-message-init.test.ts +74 -0
- package/__tests__/uiProgressThrottle.test.ts +74 -0
- package/__tests__/uiPromiseRegistry.test.ts +115 -0
- package/dist/api/BaseMethod.d.ts +16 -1
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +25 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBLEFirmwareRelease.d.ts +3 -2
- package/dist/api/CheckBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts +2 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts +3 -2
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CipherKeyValue.d.ts +1 -0
- package/dist/api/CipherKeyValue.d.ts.map +1 -1
- package/dist/api/ClearSessionCache.d.ts.map +1 -1
- package/dist/api/DetectDeviceConnectProtocol.d.ts +7 -0
- package/dist/api/DetectDeviceConnectProtocol.d.ts.map +1 -0
- package/dist/api/DirList.d.ts +1 -0
- package/dist/api/DirList.d.ts.map +1 -1
- package/dist/api/DirMake.d.ts +1 -0
- package/dist/api/DirMake.d.ts.map +1 -1
- package/dist/api/DirRemove.d.ts +1 -0
- package/dist/api/DirRemove.d.ts.map +1 -1
- package/dist/api/FileDelete.d.ts +1 -0
- package/dist/api/FileDelete.d.ts.map +1 -1
- package/dist/api/FileRead.d.ts +1 -0
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts +2 -0
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +12 -2
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +46 -16
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts +8 -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 +2 -6
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts +8 -0
- package/dist/api/OpenWalletSession.d.ts.map +1 -0
- package/dist/api/PathInfo.d.ts +1 -0
- package/dist/api/PathInfo.d.ts.map +1 -1
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +3 -0
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +17 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -0
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/algo/AlgoGetAddress.d.ts +1 -0
- package/dist/api/algo/AlgoGetAddress.d.ts.map +1 -1
- package/dist/api/algo/AlgoSignTransaction.d.ts +1 -0
- package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +1 -0
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts +1 -0
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetPublicKey.d.ts +1 -0
- package/dist/api/aptos/AptosGetPublicKey.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignInMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignTransaction.d.ts +1 -0
- package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -0
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -0
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -0
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts +1 -0
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -0
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -0
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -0
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetAddress.d.ts +1 -0
- package/dist/api/cardano/CardanoGetAddress.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetPublicKey.d.ts +1 -0
- package/dist/api/cardano/CardanoGetPublicKey.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignMessage.d.ts +1 -0
- package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts +1 -0
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxGetAddress.d.ts +2 -0
- package/dist/api/conflux/ConfluxGetAddress.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessage.d.ts +2 -0
- package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts +2 -0
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts +2 -0
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosGetAddress.d.ts +1 -0
- package/dist/api/cosmos/CosmosGetAddress.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosGetPublicKey.d.ts +1 -0
- package/dist/api/cosmos/CosmosGetPublicKey.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosSignTransaction.d.ts +1 -0
- package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceCancel.d.ts +1 -0
- package/dist/api/device/DeviceCancel.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts +1 -0
- 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 +1 -0
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -0
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts +1 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts +1 -0
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceSupportFeatures.d.ts +1 -0
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +3 -2
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts +1 -0
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/device/PreInitialize.d.ts +1 -0
- package/dist/api/device/PreInitialize.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/EVMGetAddress.d.ts +1 -0
- package/dist/api/evm/EVMGetAddress.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts +1 -0
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessage.d.ts +1 -0
- package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts +1 -0
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts +1 -0
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/EVMVerifyMessage.d.ts +1 -0
- package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -1
- package/dist/api/evm/protocol.d.ts +3 -0
- package/dist/api/evm/protocol.d.ts.map +1 -0
- package/dist/api/filecoin/FilecoinGetAddress.d.ts +1 -0
- package/dist/api/filecoin/FilecoinGetAddress.d.ts.map +1 -1
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts +1 -0
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareMemoryHost.d.ts +22 -0
- package/dist/api/firmware/FirmwareMemoryHost.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +12 -3
- 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 +72 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +32 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +14 -4
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/protocolV2Release.d.ts +33 -0
- package/dist/api/firmware/protocolV2Release.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/filesystemValidation.d.ts +3 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -1
- package/dist/api/helpers/paramsValidator.d.ts +1 -0
- package/dist/api/helpers/paramsValidator.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +43 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
- package/dist/api/index.d.ts +8 -27
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaGetAddress.d.ts +4 -0
- package/dist/api/kaspa/KaspaGetAddress.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts +9 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/kaspa/helpers/TransferSerialize.d.ts.map +1 -1
- package/dist/api/lightning/LnurlAuth.d.ts +0 -4
- package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
- package/dist/api/near/NearGetAddress.d.ts +1 -0
- package/dist/api/near/NearGetAddress.d.ts.map +1 -1
- package/dist/api/near/NearSignTransaction.d.ts +1 -0
- package/dist/api/near/NearSignTransaction.d.ts.map +1 -1
- package/dist/api/nem/NEMGetAddress.d.ts +1 -0
- package/dist/api/nem/NEMGetAddress.d.ts.map +1 -1
- package/dist/api/nem/NEMSignTransaction.d.ts +1 -0
- package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +1 -0
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/nostr/NostrDecryptMessage.d.ts +1 -0
- package/dist/api/nostr/NostrDecryptMessage.d.ts.map +1 -1
- package/dist/api/nostr/NostrEncryptMessage.d.ts +1 -0
- package/dist/api/nostr/NostrEncryptMessage.d.ts.map +1 -1
- package/dist/api/nostr/NostrGetPublicKey.d.ts +1 -0
- package/dist/api/nostr/NostrGetPublicKey.d.ts.map +1 -1
- package/dist/api/nostr/NostrSignEvent.d.ts +1 -0
- package/dist/api/nostr/NostrSignEvent.d.ts.map +1 -1
- package/dist/api/nostr/NostrSignSchnorr.d.ts +1 -0
- package/dist/api/nostr/NostrSignSchnorr.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +2 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotSignTransaction.d.ts +1 -0
- package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/networks.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +31 -0
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +27 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -1
- package/dist/api/protocol-v2/Ping.d.ts +3 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- 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 +2 -1
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +2 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +3 -2
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetAddress.d.ts +1 -0
- package/dist/api/starcoin/StarcoinGetAddress.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts +1 -0
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignMessage.d.ts +1 -0
- package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts +1 -0
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts +1 -0
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +1 -2
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +2 -3
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +2 -1
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +2 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +2 -1
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +2 -1
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +2 -1
- 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 +2 -1
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +2 -1
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronGetAddress.d.ts +1 -0
- package/dist/api/tron/TronGetAddress.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +6 -1
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +2 -1
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/utils.d.ts +4 -1
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/api/xrp/XrpGetAddress.d.ts +1 -0
- package/dist/api/xrp/XrpGetAddress.d.ts.map +1 -1
- package/dist/api/xrp/XrpSignTransaction.d.ts +1 -0
- package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/deviceEventRegistration.d.ts +13 -0
- package/dist/core/deviceEventRegistration.d.ts.map +1 -0
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/uiPromiseRegistry.d.ts +6 -0
- package/dist/core/uiPromiseRegistry.d.ts.map +1 -0
- package/dist/data-manager/DataManager.d.ts +11 -3
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- 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 +71 -16
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +8 -6
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +4 -3
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/device/DeviceFeaturesState.d.ts +3 -0
- package/dist/device/DeviceFeaturesState.d.ts.map +1 -0
- package/dist/device/DevicePool.d.ts +6 -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 +13 -1
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -1
- package/dist/device/cloneDeviceState.d.ts +2 -0
- package/dist/device/cloneDeviceState.d.ts.map +1 -0
- package/dist/device/deviceIdentity.d.ts +5 -0
- package/dist/device/deviceIdentity.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +9 -3
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/deviceProfile/index.d.ts +0 -1
- package/dist/deviceProfile/index.d.ts.map +1 -1
- package/dist/deviceProfile/protocolV2DeviceIdentity.d.ts +7 -0
- package/dist/deviceProfile/protocolV2DeviceIdentity.d.ts.map +1 -0
- package/dist/events/device.d.ts +16 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts +2 -0
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-promise.d.ts +4 -2
- package/dist/events/ui-promise.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +50 -4
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +10 -2
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +1786 -776
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11556 -4498
- package/dist/inject.d.ts +6 -1
- package/dist/inject.d.ts.map +1 -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 +21 -17
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +2 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/resources.d.ts +12 -0
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +17 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +42 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +2 -0
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +22 -0
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +18 -4
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +48 -9
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBLEFirmwareRelease.d.ts +2 -13
- package/dist/types/api/checkBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBootloaderRelease.d.ts +2 -6
- package/dist/types/api/checkBootloaderRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareRelease.d.ts +2 -13
- package/dist/types/api/checkFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareTypeAvailable.d.ts +2 -2
- package/dist/types/api/checkFirmwareTypeAvailable.d.ts.map +1 -1
- package/dist/types/api/detectDeviceConnectProtocol.d.ts +4 -0
- package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +1 -0
- package/dist/types/api/deviceSettings.d.ts +11 -2
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +6 -2
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +8 -3
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +76 -2
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/getDeviceState.d.ts +12 -0
- package/dist/types/api/getDeviceState.d.ts.map +1 -0
- package/dist/types/api/getFeatures.d.ts.map +1 -1
- package/dist/types/api/getOnekeyFeatures.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +2 -10
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +29 -33
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/kaspaSignTransaction.d.ts +42 -4
- package/dist/types/api/kaspaSignTransaction.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 +18 -88
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/api/sessionCache.d.ts +4 -1
- package/dist/types/api/sessionCache.d.ts.map +1 -1
- package/dist/types/device.d.ts +142 -10
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +59 -16
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/assets.d.ts +2 -1
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +14 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -0
- package/dist/utils/deviceFeaturesUtils.d.ts +10 -3
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +9 -9
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +38 -7
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +7 -5
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts +4 -0
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +6 -3
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/networkUtils.d.ts +10 -1
- package/dist/utils/networkUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/pro2Nft.d.ts +31 -0
- package/dist/utils/pro2Nft.d.ts.map +1 -0
- package/dist/utils/pro2Wallpaper.d.ts +22 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -0
- package/dist/utils/tracing.d.ts.map +1 -1
- package/dist/utils/uiProgressThrottle.d.ts +3 -0
- package/dist/utils/uiProgressThrottle.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +53 -20
- package/src/api/CheckAllFirmwareRelease.ts +437 -4
- package/src/api/CheckBLEFirmwareRelease.ts +37 -5
- package/src/api/CheckBootloaderRelease.ts +36 -5
- package/src/api/CheckFirmwareRelease.ts +35 -8
- package/src/api/CipherKeyValue.ts +4 -0
- package/src/api/ClearSessionCache.ts +4 -0
- package/src/api/DetectDeviceConnectProtocol.ts +18 -0
- package/src/api/DirList.ts +9 -4
- package/src/api/DirMake.ts +7 -4
- package/src/api/DirRemove.ts +7 -4
- package/src/api/FileDelete.ts +7 -4
- package/src/api/FileRead.ts +13 -7
- package/src/api/FileWrite.ts +26 -181
- package/src/api/FirmwareUpdate.ts +30 -15
- package/src/api/FirmwareUpdateV2.ts +390 -115
- package/src/api/FirmwareUpdateV3.ts +281 -71
- package/src/api/FirmwareUpdateV4.ts +2005 -732
- package/src/api/GetDeviceState.ts +59 -0
- package/src/api/GetFeatures.ts +6 -4
- package/src/api/GetOnekeyFeatures.ts +1 -75
- package/src/api/GetPassphraseState.ts +36 -21
- package/src/api/OpenWalletSession.ts +268 -0
- package/src/api/PathInfo.ts +9 -4
- package/src/api/PromptWebDeviceAccess.ts +2 -7
- package/src/api/SearchDevices.ts +31 -4
- package/src/api/UploadPortfolio.ts +58 -0
- package/src/api/alephium/AlephiumGetAddress.ts +0 -4
- package/src/api/alephium/AlephiumSignMessage.ts +0 -4
- package/src/api/alephium/AlephiumSignTransaction.ts +2 -6
- package/src/api/algo/AlgoGetAddress.ts +4 -0
- package/src/api/algo/AlgoSignTransaction.ts +4 -0
- package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +45 -32
- package/src/api/aptos/AptosGetAddress.ts +4 -0
- package/src/api/aptos/AptosGetPublicKey.ts +4 -0
- package/src/api/aptos/AptosSignInMessage.ts +4 -0
- package/src/api/aptos/AptosSignMessage.ts +4 -0
- package/src/api/aptos/AptosSignTransaction.ts +4 -0
- package/src/api/benfen/BenfenGetAddress.ts +11 -7
- package/src/api/benfen/BenfenGetPublicKey.ts +0 -4
- package/src/api/benfen/BenfenSignMessage.ts +0 -4
- package/src/api/benfen/BenfenSignTransaction.ts +0 -4
- package/src/api/btc/BTCGetAddress.ts +8 -1
- package/src/api/btc/BTCGetPublicKey.ts +9 -2
- package/src/api/btc/BTCSignMessage.ts +8 -1
- package/src/api/btc/BTCSignPsbt.ts +4 -0
- package/src/api/btc/BTCSignTransaction.ts +8 -1
- package/src/api/btc/BTCVerifyMessage.ts +8 -1
- package/src/api/btc/helpers/versionLimit.ts +7 -4
- package/src/api/cardano/CardanoGetAddress.ts +4 -0
- package/src/api/cardano/CardanoGetPublicKey.ts +4 -0
- package/src/api/cardano/CardanoSignMessage.ts +5 -1
- package/src/api/cardano/CardanoSignTransaction.ts +5 -1
- package/src/api/conflux/ConfluxGetAddress.ts +6 -0
- package/src/api/conflux/ConfluxSignMessage.ts +6 -0
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +6 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +8 -5
- package/src/api/cosmos/CosmosGetAddress.ts +4 -0
- package/src/api/cosmos/CosmosGetPublicKey.ts +4 -0
- package/src/api/cosmos/CosmosSignTransaction.ts +4 -0
- package/src/api/device/DeviceCancel.ts +5 -0
- package/src/api/device/DeviceChangePin.ts +28 -0
- package/src/api/device/DeviceFullyUploadResource.ts +4 -5
- package/src/api/device/DeviceLock.ts +5 -0
- package/src/api/device/DeviceRebootToBoardloader.ts +5 -0
- package/src/api/device/DeviceRebootToBootloader.ts +5 -0
- package/src/api/device/DeviceSettings.ts +195 -1
- package/src/api/device/DeviceSupportFeatures.ts +4 -0
- package/src/api/device/DeviceUnlock.ts +21 -3
- package/src/api/device/DeviceUpdateBootloader.ts +133 -8
- package/src/api/device/DeviceWipe.ts +25 -0
- package/src/api/device/PreInitialize.ts +4 -0
- package/src/api/dynex/DnxGetAddress.ts +0 -6
- package/src/api/dynex/DnxSignTransaction.ts +0 -6
- package/src/api/evm/EVMGetAddress.ts +6 -2
- package/src/api/evm/EVMGetPublicKey.ts +6 -2
- package/src/api/evm/EVMSignMessage.ts +6 -2
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -11
- package/src/api/evm/EVMSignTransaction.ts +6 -2
- package/src/api/evm/EVMSignTypedData.ts +42 -50
- package/src/api/evm/EVMVerifyMessage.ts +6 -2
- package/src/api/evm/legacyV1/getAddress.ts +2 -2
- package/src/api/evm/legacyV1/getPublicKey.ts +2 -2
- package/src/api/evm/legacyV1/signMessage.ts +2 -2
- package/src/api/evm/legacyV1/signTypedData.ts +2 -2
- package/src/api/evm/legacyV1/signTypedHash.ts +2 -2
- package/src/api/evm/legacyV1/verifyMessage.ts +2 -2
- package/src/api/evm/protocol.ts +6 -0
- package/src/api/filecoin/FilecoinGetAddress.ts +4 -0
- package/src/api/filecoin/FilecoinSignTransaction.ts +4 -0
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +113 -0
- package/src/api/firmware/FirmwareMemoryHost.ts +142 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +102 -16
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +910 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +456 -0
- package/src/api/firmware/getBinary.ts +8 -3
- package/src/api/firmware/protocolV2Release.ts +168 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +157 -26
- package/src/api/helpers/batchGetPublickeys.ts +2 -2
- package/src/api/helpers/filesystemValidation.ts +61 -0
- package/src/api/helpers/paramsValidator.ts +1 -1
- package/src/api/helpers/protocolV2FileWrite.ts +392 -0
- package/src/api/index.ts +9 -28
- package/src/api/kaspa/KaspaGetAddress.ts +7 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +369 -29
- package/src/api/kaspa/helpers/TransferSerialize.ts +17 -7
- package/src/api/lightning/LnurlAuth.ts +0 -4
- package/src/api/near/NearGetAddress.ts +4 -0
- package/src/api/near/NearSignTransaction.ts +4 -0
- package/src/api/nem/NEMGetAddress.ts +4 -0
- package/src/api/nem/NEMSignTransaction.ts +4 -0
- package/src/api/neo/NeoGetAddress.ts +0 -4
- package/src/api/neo/NeoSignTransaction.ts +0 -4
- package/src/api/nervos/NervosGetAddress.ts +0 -4
- package/src/api/nervos/NervosSignTransaction.ts +2 -6
- package/src/api/nexa/NexaGetAddress.ts +0 -4
- package/src/api/nexa/NexaSignTransaction.ts +3 -5
- package/src/api/nostr/NostrDecryptMessage.ts +4 -0
- package/src/api/nostr/NostrEncryptMessage.ts +4 -0
- package/src/api/nostr/NostrGetPublicKey.ts +4 -0
- package/src/api/nostr/NostrSignEvent.ts +4 -0
- package/src/api/nostr/NostrSignSchnorr.ts +4 -0
- package/src/api/polkadot/PolkadotGetAddress.ts +4 -0
- package/src/api/polkadot/PolkadotSignTransaction.ts +4 -0
- package/src/api/polkadot/networks.ts +3 -3
- package/src/api/protocol-v2/DeviceFactoryInfoGet.ts +5 -2
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +5 -2
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +8 -5
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +10 -6
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +21 -0
- package/src/api/protocol-v2/DeviceInfoGet.ts +8 -15
- package/src/api/protocol-v2/DeviceReboot.ts +7 -3
- package/src/api/protocol-v2/DeviceStatusGet.ts +6 -1
- package/src/api/protocol-v2/DeviceUploadNft.ts +197 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +134 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +5 -2
- package/src/api/protocol-v2/FilesystemPermissionFix.ts +5 -2
- package/src/api/protocol-v2/Ping.ts +37 -3
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +8 -3
- package/src/api/protocol-v2/helpers.ts +1 -4
- package/src/api/scdo/ScdoGetAddress.ts +0 -4
- package/src/api/scdo/ScdoSignMessage.ts +0 -4
- package/src/api/scdo/ScdoSignTransaction.ts +0 -4
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +5 -1
- package/src/api/solana/SolSignOffchainMessage.ts +5 -1
- package/src/api/solana/SolSignTransaction.ts +6 -2
- package/src/api/starcoin/StarcoinGetAddress.ts +4 -0
- package/src/api/starcoin/StarcoinGetPublicKey.ts +4 -0
- package/src/api/starcoin/StarcoinSignMessage.ts +4 -0
- package/src/api/starcoin/StarcoinSignTransaction.ts +4 -0
- package/src/api/starcoin/StarcoinVerifyMessage.ts +4 -0
- package/src/api/stellar/StellarGetAddress.ts +1 -10
- package/src/api/stellar/StellarSignTransaction.ts +1 -14
- package/src/api/sui/SuiGetAddress.ts +5 -1
- package/src/api/sui/SuiGetPublicKey.ts +5 -1
- package/src/api/sui/SuiSignMessage.ts +5 -1
- package/src/api/sui/SuiSignTransaction.ts +5 -1
- package/src/api/ton/TonGetAddress.ts +5 -1
- package/src/api/ton/TonSignData.ts +5 -1
- package/src/api/ton/TonSignMessage.ts +5 -1
- package/src/api/ton/TonSignProof.ts +5 -1
- package/src/api/tron/TronGetAddress.ts +4 -0
- package/src/api/tron/TronSignMessage.ts +19 -8
- package/src/api/tron/TronSignTransaction.ts +5 -1
- package/src/api/utils.ts +32 -3
- package/src/api/xrp/XrpGetAddress.ts +4 -0
- package/src/api/xrp/XrpSignTransaction.ts +5 -1
- package/src/constants/index.ts +1 -4
- package/src/core/RequestQueue.ts +1 -0
- package/src/core/deviceEventRegistration.ts +27 -0
- package/src/core/index.ts +381 -152
- package/src/core/uiPromiseRegistry.ts +63 -0
- package/src/data/messages/messages-protocol-v2.json +1113 -547
- package/src/data/messages/messages.json +286 -9
- package/src/data-manager/DataManager.ts +154 -43
- package/src/data-manager/TransportManager.ts +7 -1
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +858 -264
- package/src/device/DeviceCommands.ts +193 -158
- package/src/device/DeviceConnector.ts +44 -21
- package/src/device/DeviceFeaturesState.ts +25 -0
- package/src/device/DevicePool.ts +101 -23
- package/src/device/DeviceStateMapper.ts +416 -0
- package/src/device/DeviceStateProjector.ts +152 -0
- package/src/device/DeviceStateStore.ts +232 -0
- package/src/device/DeviceWalletSessionStore.ts +72 -6
- package/src/device/cloneDeviceState.ts +39 -0
- package/src/device/deviceIdentity.ts +18 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +223 -189
- package/src/deviceProfile/index.ts +0 -1
- package/src/deviceProfile/protocolV2DeviceIdentity.ts +35 -0
- package/src/events/device.ts +22 -1
- package/src/events/logBlockEvent.ts +80 -2
- package/src/events/ui-promise.ts +4 -2
- package/src/events/ui-request.ts +61 -4
- package/src/events/ui-response.ts +12 -2
- package/src/index.ts +17 -0
- package/src/inject.ts +94 -47
- package/src/lowLevelInject.ts +11 -4
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +100 -33
- package/src/protocols/protocol-v2/firmware.ts +3 -1
- package/src/protocols/protocol-v2/index.ts +7 -1
- package/src/protocols/protocol-v2/resources.ts +210 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +65 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +250 -0
- package/src/protocols/protocol-v2/unlockPolicy.ts +1 -0
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +131 -0
- package/src/protocols/protocol-v2/walletSession.ts +422 -42
- package/src/topLevelInject.ts +11 -4
- package/src/types/api/checkAllFirmwareRelease.ts +72 -9
- package/src/types/api/checkBLEFirmwareRelease.ts +4 -13
- package/src/types/api/checkBootloaderRelease.ts +2 -6
- package/src/types/api/checkFirmwareRelease.ts +2 -13
- package/src/types/api/checkFirmwareTypeAvailable.ts +2 -2
- package/src/types/api/detectDeviceConnectProtocol.ts +6 -0
- package/src/types/api/deviceSettings.ts +26 -2
- package/src/types/api/deviceUnlock.ts +13 -2
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +33 -1
- package/src/types/api/firmwareUpdate.ts +105 -9
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -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 +9 -11
- package/src/types/api/index.ts +49 -68
- package/src/types/api/kaspaSignTransaction.ts +60 -4
- package/src/types/api/openWalletSession.ts +54 -0
- package/src/types/api/protocolV2.ts +33 -155
- package/src/types/api/sessionCache.ts +9 -4
- package/src/types/device.ts +216 -10
- package/src/types/params.ts +9 -2
- package/src/types/settings.ts +67 -25
- package/src/utils/assets.ts +4 -1
- package/src/utils/deviceFeaturesCompat.ts +191 -0
- package/src/utils/deviceFeaturesUtils.ts +45 -17
- package/src/utils/deviceInfoUtils.ts +29 -69
- package/src/utils/deviceSettings.ts +174 -39
- package/src/utils/deviceVersionUtils.ts +25 -44
- package/src/utils/findDefectiveBatchDevice.ts +3 -3
- package/src/utils/homescreen.ts +40 -0
- package/src/utils/index.ts +27 -3
- package/src/utils/networkUtils.ts +274 -16
- package/src/utils/pro2Nft.ts +142 -0
- package/src/utils/pro2Wallpaper.ts +130 -0
- package/src/utils/tracing.ts +3 -1
- package/src/utils/uiProgressThrottle.ts +63 -0
- package/tsconfig.type-tests.json +12 -0
- package/dist/api/GetDeviceInfo.d.ts +0 -9
- package/dist/api/GetDeviceInfo.d.ts.map +0 -1
- package/dist/api/firmware/progressThrottle.d.ts +0 -3
- package/dist/api/firmware/progressThrottle.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts +0 -9
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts +0 -21
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +0 -1
- package/dist/types/api/getDeviceInfo.d.ts +0 -87
- package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
- package/src/api/GetDeviceInfo.ts +0 -145
- package/src/api/firmware/progressThrottle.ts +0 -44
- package/src/api/protocol-v2/DeviceSessionGet.ts +0 -26
- package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
- package/src/deviceProfile/buildDeviceProfile.ts +0 -352
- package/src/types/api/getDeviceInfo.ts +0 -101
|
@@ -0,0 +1,910 @@
|
|
|
1
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
2
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
3
|
+
import { EDeviceType, EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
|
|
6
|
+
import { getDeviceType, getDeviceUUID } from '../../utils/deviceInfoUtils';
|
|
7
|
+
import { resolveDeviceBootloaderMode } from '../../utils/deviceFeaturesCompat';
|
|
8
|
+
import {
|
|
9
|
+
getDeviceBootloaderVersion,
|
|
10
|
+
getDeviceFirmwareVersion,
|
|
11
|
+
} from '../../utils/deviceVersionUtils';
|
|
12
|
+
|
|
13
|
+
import type { FirmwareUpdateV4Target } from '../../types/api/firmwareUpdate';
|
|
14
|
+
import type {
|
|
15
|
+
FirmwareUpdatePlan,
|
|
16
|
+
FirmwareUpdatePlanArtifact,
|
|
17
|
+
FirmwareUpdatePlanForceTarget,
|
|
18
|
+
FirmwareUpdatePlanTarget,
|
|
19
|
+
} from '../../types/api/firmwareUpdatePlan';
|
|
20
|
+
import type { Features, IProtocolV2ResourceSource } from '../../types';
|
|
21
|
+
|
|
22
|
+
type FirmwareUpdatePlatform = 'native' | 'desktop' | 'ext' | 'web' | 'web-embed';
|
|
23
|
+
|
|
24
|
+
type ReleaseRecord = {
|
|
25
|
+
url?: unknown;
|
|
26
|
+
webUpdate?: unknown;
|
|
27
|
+
resource?: unknown;
|
|
28
|
+
fullResource?: unknown;
|
|
29
|
+
fullResourceRange?: unknown;
|
|
30
|
+
bootloaderResource?: unknown;
|
|
31
|
+
version?: unknown;
|
|
32
|
+
components?: unknown;
|
|
33
|
+
installOrder?: unknown;
|
|
34
|
+
fingerprint?: unknown;
|
|
35
|
+
fingerprintWeb?: unknown;
|
|
36
|
+
expectedSize?: unknown;
|
|
37
|
+
resourceFingerprint?: unknown;
|
|
38
|
+
resourceExpectedSize?: unknown;
|
|
39
|
+
fullResourceFingerprint?: unknown;
|
|
40
|
+
fullResourceExpectedSize?: unknown;
|
|
41
|
+
bootloaderFingerprint?: unknown;
|
|
42
|
+
bootloaderExpectedSize?: unknown;
|
|
43
|
+
bootloaderVersion?: unknown;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type ReleaseSelection = {
|
|
47
|
+
shouldUpdate?: boolean;
|
|
48
|
+
status?: unknown;
|
|
49
|
+
release?: unknown;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const PROTOCOL_V2_TARGETS: Readonly<
|
|
53
|
+
Record<string, Exclude<FirmwareUpdatePlanTarget, 'firmware' | 'ble' | 'bootloader' | 'resource'>>
|
|
54
|
+
> = {
|
|
55
|
+
BOOTLOADER: 'boot',
|
|
56
|
+
APPLICATION_P1: 'app_v1',
|
|
57
|
+
APPLICATION_P2: 'app_v2',
|
|
58
|
+
COPROCESSOR: 'coprocessor',
|
|
59
|
+
SE01: 'se01',
|
|
60
|
+
SE02: 'se02',
|
|
61
|
+
SE03: 'se03',
|
|
62
|
+
SE04: 'se04',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const PROTOCOL_V2_FIRMWARE_UPDATE_TARGETS = new Set<FirmwareUpdateV4Target>([
|
|
66
|
+
...Object.values(PROTOCOL_V2_TARGETS),
|
|
67
|
+
'resource',
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
const asRecord = (value: unknown): Record<string, unknown> | undefined =>
|
|
71
|
+
value && typeof value === 'object' && !Array.isArray(value)
|
|
72
|
+
? (value as Record<string, unknown>)
|
|
73
|
+
: undefined;
|
|
74
|
+
|
|
75
|
+
const asRelease = (release: ReleaseSelection | undefined): ReleaseRecord | undefined =>
|
|
76
|
+
asRecord(release?.release) as ReleaseRecord | undefined;
|
|
77
|
+
|
|
78
|
+
const asString = (value: unknown): string | undefined =>
|
|
79
|
+
typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
80
|
+
|
|
81
|
+
const asVersion = (value: unknown): string | undefined => {
|
|
82
|
+
if (
|
|
83
|
+
!Array.isArray(value) ||
|
|
84
|
+
value.length !== 3 ||
|
|
85
|
+
value.some(part => typeof part !== 'number' || !Number.isSafeInteger(part) || part < 0)
|
|
86
|
+
) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
return value.join('.');
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const asIntegrity = ({
|
|
93
|
+
size,
|
|
94
|
+
sha256: value,
|
|
95
|
+
}: {
|
|
96
|
+
size: unknown;
|
|
97
|
+
sha256: unknown;
|
|
98
|
+
}): Pick<FirmwareUpdatePlanArtifact, 'expectedSize' | 'expectedSha256'> => {
|
|
99
|
+
const sha256Value =
|
|
100
|
+
typeof value === 'string' && /^[a-f0-9]{64}$/iu.test(value) ? value.toLowerCase() : undefined;
|
|
101
|
+
return {
|
|
102
|
+
...(Number.isSafeInteger(size) && (size as number) > 0 ? { expectedSize: size as number } : {}),
|
|
103
|
+
...(sha256Value ? { expectedSha256: sha256Value } : {}),
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const isUpgrade = (release: ReleaseSelection | undefined): boolean =>
|
|
108
|
+
release?.status === 'required' ||
|
|
109
|
+
release?.status === 'outdated' ||
|
|
110
|
+
release?.shouldUpdate === true;
|
|
111
|
+
|
|
112
|
+
const assertArtifactUrl = (value: unknown, label: string): string => {
|
|
113
|
+
const raw = asString(value);
|
|
114
|
+
if (!raw) {
|
|
115
|
+
throw ERRORS.TypedError(
|
|
116
|
+
HardwareErrorCode.RuntimeError,
|
|
117
|
+
`${label} has no downloadable artifact`,
|
|
118
|
+
{ firmwareUpdateCode: 'FirmwarePlanInvalid' }
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
let parsed: URL;
|
|
122
|
+
try {
|
|
123
|
+
parsed = new URL(raw);
|
|
124
|
+
} catch {
|
|
125
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `${label} URL is invalid`, {
|
|
126
|
+
firmwareUpdateCode: 'FirmwarePlanInvalid',
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (
|
|
130
|
+
parsed.protocol !== 'https:' ||
|
|
131
|
+
parsed.port !== '' ||
|
|
132
|
+
parsed.username ||
|
|
133
|
+
parsed.password ||
|
|
134
|
+
parsed.hash
|
|
135
|
+
) {
|
|
136
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `${label} URL is not canonical HTTPS`, {
|
|
137
|
+
firmwareUpdateCode: 'FirmwarePlanInvalid',
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return raw;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const canonicalizeFirmwareUpdateContract = (value: unknown): unknown => {
|
|
144
|
+
if (Array.isArray(value)) {
|
|
145
|
+
return value.map(canonicalizeFirmwareUpdateContract);
|
|
146
|
+
}
|
|
147
|
+
if (value && typeof value === 'object') {
|
|
148
|
+
return Object.keys(value as Record<string, unknown>)
|
|
149
|
+
.sort()
|
|
150
|
+
.reduce<Record<string, unknown>>((result, key) => {
|
|
151
|
+
const item = (value as Record<string, unknown>)[key];
|
|
152
|
+
if (item !== undefined) {
|
|
153
|
+
result[key] = canonicalizeFirmwareUpdateContract(item);
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
}, {});
|
|
157
|
+
}
|
|
158
|
+
return value;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const digestFirmwareUpdateContract = (value: unknown): string =>
|
|
162
|
+
bytesToHex(
|
|
163
|
+
sha256(new TextEncoder().encode(JSON.stringify(canonicalizeFirmwareUpdateContract(value))))
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const digestFirmwareUpdatePlan = (plan: Omit<FirmwareUpdatePlan, 'planDigest'>): string =>
|
|
167
|
+
digestFirmwareUpdateContract(plan);
|
|
168
|
+
|
|
169
|
+
const planError = (message: string): never => {
|
|
170
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, message, {
|
|
171
|
+
firmwareUpdateCode: 'FirmwarePlanInvalid',
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const FIRMWARE_UPDATE_PLAN_FORCE_TARGETS = new Set<FirmwareUpdatePlanForceTarget>([
|
|
176
|
+
'firmware',
|
|
177
|
+
'ble',
|
|
178
|
+
'bootloader',
|
|
179
|
+
'resource',
|
|
180
|
+
]);
|
|
181
|
+
|
|
182
|
+
export const validateFirmwareUpdatePlanForceTargets = (
|
|
183
|
+
value: unknown
|
|
184
|
+
): FirmwareUpdatePlanForceTarget[] => {
|
|
185
|
+
if (value === undefined) {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
if (
|
|
189
|
+
!Array.isArray(value) ||
|
|
190
|
+
value.length > FIRMWARE_UPDATE_PLAN_FORCE_TARGETS.size ||
|
|
191
|
+
value.some(target => !FIRMWARE_UPDATE_PLAN_FORCE_TARGETS.has(target)) ||
|
|
192
|
+
new Set(value).size !== value.length
|
|
193
|
+
) {
|
|
194
|
+
return planError('Firmware update force targets are invalid');
|
|
195
|
+
}
|
|
196
|
+
return [...value] as FirmwareUpdatePlanForceTarget[];
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const validateProtocolV2FirmwareUpdateTargets = (
|
|
200
|
+
value: unknown
|
|
201
|
+
): FirmwareUpdateV4Target[] => {
|
|
202
|
+
if (value === undefined) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
if (
|
|
206
|
+
!Array.isArray(value) ||
|
|
207
|
+
value.length > PROTOCOL_V2_FIRMWARE_UPDATE_TARGETS.size ||
|
|
208
|
+
value.some(target => !PROTOCOL_V2_FIRMWARE_UPDATE_TARGETS.has(target)) ||
|
|
209
|
+
new Set(value).size !== value.length
|
|
210
|
+
) {
|
|
211
|
+
return planError('Protocol V2 firmware update targets are invalid');
|
|
212
|
+
}
|
|
213
|
+
return [...value] as FirmwareUpdateV4Target[];
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const assertExactKeys = (
|
|
217
|
+
value: Record<string, unknown>,
|
|
218
|
+
required: readonly string[],
|
|
219
|
+
optional: readonly string[] = []
|
|
220
|
+
) => {
|
|
221
|
+
const allowed = new Set([...required, ...optional]);
|
|
222
|
+
if (
|
|
223
|
+
required.some(key => !Object.prototype.hasOwnProperty.call(value, key)) ||
|
|
224
|
+
Object.keys(value).some(key => !allowed.has(key))
|
|
225
|
+
) {
|
|
226
|
+
planError('Firmware update plan contains an invalid field set');
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const assertBoundedString = (value: unknown, label: string, maxLength = 256): string => {
|
|
231
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > maxLength) {
|
|
232
|
+
return planError(`Firmware update plan ${label} is invalid`);
|
|
233
|
+
}
|
|
234
|
+
return value;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const FIRMWARE_UPDATE_PLAN_TARGETS = new Set<FirmwareUpdatePlanTarget>([
|
|
238
|
+
'firmware',
|
|
239
|
+
'ble',
|
|
240
|
+
'bootloader',
|
|
241
|
+
'resource',
|
|
242
|
+
'boot',
|
|
243
|
+
'app_v1',
|
|
244
|
+
'app_v2',
|
|
245
|
+
'coprocessor',
|
|
246
|
+
'se01',
|
|
247
|
+
'se02',
|
|
248
|
+
'se03',
|
|
249
|
+
'se04',
|
|
250
|
+
]);
|
|
251
|
+
|
|
252
|
+
export const FIRMWARE_UPDATE_PLAN_ROLES = new Set([
|
|
253
|
+
'firmware',
|
|
254
|
+
'ble',
|
|
255
|
+
'bootloader',
|
|
256
|
+
'resource',
|
|
257
|
+
'component',
|
|
258
|
+
'resourceBundle',
|
|
259
|
+
]);
|
|
260
|
+
|
|
261
|
+
const PLAN_CONTAINERS = new Set(['raw', 'zip']);
|
|
262
|
+
|
|
263
|
+
const PLAN_PLATFORMS = new Set<FirmwareUpdatePlatform>([
|
|
264
|
+
'native',
|
|
265
|
+
'desktop',
|
|
266
|
+
'ext',
|
|
267
|
+
'web',
|
|
268
|
+
'web-embed',
|
|
269
|
+
]);
|
|
270
|
+
|
|
271
|
+
export const assertFirmwareUpdatePlan = (value: unknown): FirmwareUpdatePlan => {
|
|
272
|
+
const plan = asRecord(value);
|
|
273
|
+
if (!plan) {
|
|
274
|
+
return planError('Firmware update plan must be an object');
|
|
275
|
+
}
|
|
276
|
+
assertExactKeys(plan, [
|
|
277
|
+
'schemaVersion',
|
|
278
|
+
'planDigest',
|
|
279
|
+
'executor',
|
|
280
|
+
'deviceIdentity',
|
|
281
|
+
'deviceModel',
|
|
282
|
+
'firmwareType',
|
|
283
|
+
'platform',
|
|
284
|
+
'artifacts',
|
|
285
|
+
'targetsToUpdate',
|
|
286
|
+
]);
|
|
287
|
+
if (
|
|
288
|
+
plan.schemaVersion !== 2 ||
|
|
289
|
+
typeof plan.planDigest !== 'string' ||
|
|
290
|
+
!/^[a-f0-9]{64}$/u.test(plan.planDigest) ||
|
|
291
|
+
(plan.executor !== 'v2' && plan.executor !== 'v3' && plan.executor !== 'v4') ||
|
|
292
|
+
!PLAN_PLATFORMS.has(plan.platform as FirmwareUpdatePlatform) ||
|
|
293
|
+
(plan.firmwareType !== EFirmwareType.Universal &&
|
|
294
|
+
plan.firmwareType !== EFirmwareType.BitcoinOnly)
|
|
295
|
+
) {
|
|
296
|
+
return planError('Firmware update plan header is invalid');
|
|
297
|
+
}
|
|
298
|
+
assertBoundedString(plan.deviceIdentity, 'device identity');
|
|
299
|
+
assertBoundedString(plan.deviceModel, 'device model', 64);
|
|
300
|
+
if (!Array.isArray(plan.artifacts) || plan.artifacts.length > 128) {
|
|
301
|
+
return planError('Firmware update plan artifact set is invalid');
|
|
302
|
+
}
|
|
303
|
+
const artifactIds = new Set<string>();
|
|
304
|
+
const artifactTargets = new Set<FirmwareUpdatePlanTarget>();
|
|
305
|
+
for (const item of plan.artifacts) {
|
|
306
|
+
const artifact = asRecord(item);
|
|
307
|
+
if (!artifact) {
|
|
308
|
+
return planError('Firmware update plan artifact is invalid');
|
|
309
|
+
}
|
|
310
|
+
assertExactKeys(
|
|
311
|
+
artifact,
|
|
312
|
+
['artifactId', 'role', 'target', 'url', 'container'],
|
|
313
|
+
['logicalName', 'expectedSize', 'expectedSha256', 'targetVersion']
|
|
314
|
+
);
|
|
315
|
+
const artifactId = assertBoundedString(artifact.artifactId, 'artifact id', 160);
|
|
316
|
+
if (artifactIds.has(artifactId)) {
|
|
317
|
+
return planError('Firmware update plan contains duplicate artifact ids');
|
|
318
|
+
}
|
|
319
|
+
artifactIds.add(artifactId);
|
|
320
|
+
if (
|
|
321
|
+
!FIRMWARE_UPDATE_PLAN_ROLES.has(artifact.role as string) ||
|
|
322
|
+
!FIRMWARE_UPDATE_PLAN_TARGETS.has(artifact.target as FirmwareUpdatePlanTarget) ||
|
|
323
|
+
!PLAN_CONTAINERS.has(artifact.container as string)
|
|
324
|
+
) {
|
|
325
|
+
return planError('Firmware update plan artifact contract is invalid');
|
|
326
|
+
}
|
|
327
|
+
artifactTargets.add(artifact.target as FirmwareUpdatePlanTarget);
|
|
328
|
+
assertArtifactUrl(artifact.url, `Firmware artifact ${artifactId}`);
|
|
329
|
+
if (artifact.logicalName !== undefined) {
|
|
330
|
+
assertBoundedString(artifact.logicalName, 'logical name', 256);
|
|
331
|
+
}
|
|
332
|
+
if (
|
|
333
|
+
artifact.expectedSize !== undefined &&
|
|
334
|
+
(!Number.isSafeInteger(artifact.expectedSize) || (artifact.expectedSize as number) <= 0)
|
|
335
|
+
) {
|
|
336
|
+
return planError('Firmware update plan artifact size is invalid');
|
|
337
|
+
}
|
|
338
|
+
if (
|
|
339
|
+
artifact.expectedSha256 !== undefined &&
|
|
340
|
+
(typeof artifact.expectedSha256 !== 'string' ||
|
|
341
|
+
!/^[a-f0-9]{64}$/u.test(artifact.expectedSha256))
|
|
342
|
+
) {
|
|
343
|
+
return planError('Firmware update plan artifact digest is invalid');
|
|
344
|
+
}
|
|
345
|
+
if (artifact.targetVersion !== undefined) {
|
|
346
|
+
assertBoundedString(artifact.targetVersion, 'target version', 64);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (
|
|
350
|
+
!Array.isArray(plan.targetsToUpdate) ||
|
|
351
|
+
plan.targetsToUpdate.some(
|
|
352
|
+
target => !FIRMWARE_UPDATE_PLAN_TARGETS.has(target as FirmwareUpdatePlanTarget)
|
|
353
|
+
) ||
|
|
354
|
+
new Set(plan.targetsToUpdate).size !== plan.targetsToUpdate.length ||
|
|
355
|
+
plan.targetsToUpdate.length !== artifactTargets.size ||
|
|
356
|
+
plan.targetsToUpdate.some(target => !artifactTargets.has(target as FirmwareUpdatePlanTarget))
|
|
357
|
+
) {
|
|
358
|
+
return planError('Firmware update plan targets are invalid');
|
|
359
|
+
}
|
|
360
|
+
const legacyTargets = new Set<FirmwareUpdatePlanTarget>([
|
|
361
|
+
'firmware',
|
|
362
|
+
'ble',
|
|
363
|
+
'bootloader',
|
|
364
|
+
'resource',
|
|
365
|
+
]);
|
|
366
|
+
const legacyOnlyTargets = new Set<FirmwareUpdatePlanTarget>(['firmware', 'ble', 'bootloader']);
|
|
367
|
+
if (
|
|
368
|
+
((plan.executor === 'v2' || plan.executor === 'v3') &&
|
|
369
|
+
plan.targetsToUpdate.some(
|
|
370
|
+
target => !legacyTargets.has(target as FirmwareUpdatePlanTarget)
|
|
371
|
+
)) ||
|
|
372
|
+
(plan.executor === 'v4' &&
|
|
373
|
+
plan.targetsToUpdate.some(target =>
|
|
374
|
+
legacyOnlyTargets.has(target as FirmwareUpdatePlanTarget)
|
|
375
|
+
)) ||
|
|
376
|
+
// V2 仅在 bootloader 恢复时允许缺少身份;V4 设备在尚未写入序列号时也可升级。
|
|
377
|
+
// 这类 Plan 仍通过设备型号、目标、工件摘要与 preparedPlanDigest 进行约束。
|
|
378
|
+
(plan.artifacts.length > 0 &&
|
|
379
|
+
(plan.platform === 'native' || plan.platform === 'desktop') &&
|
|
380
|
+
plan.executor === 'v3' &&
|
|
381
|
+
plan.deviceIdentity === 'unavailable')
|
|
382
|
+
) {
|
|
383
|
+
return planError('Firmware update plan executor contract is invalid');
|
|
384
|
+
}
|
|
385
|
+
const { planDigest, ...withoutDigest } = plan as unknown as FirmwareUpdatePlan;
|
|
386
|
+
if (digestFirmwareUpdatePlan(withoutDigest) !== planDigest) {
|
|
387
|
+
return planError('Firmware update plan digest is invalid');
|
|
388
|
+
}
|
|
389
|
+
return plan as unknown as FirmwareUpdatePlan;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const selectResourceUrl = ({
|
|
393
|
+
release,
|
|
394
|
+
features,
|
|
395
|
+
platform,
|
|
396
|
+
}: {
|
|
397
|
+
release: ReleaseRecord;
|
|
398
|
+
features: Features;
|
|
399
|
+
platform: FirmwareUpdatePlatform;
|
|
400
|
+
}): string | undefined => {
|
|
401
|
+
const resource = asString(release.resource);
|
|
402
|
+
const fullResource = asString(release.fullResource);
|
|
403
|
+
const range = release.fullResourceRange;
|
|
404
|
+
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
405
|
+
const targetVersion = asVersion(release.version);
|
|
406
|
+
if (
|
|
407
|
+
platform === 'desktop' &&
|
|
408
|
+
fullResource &&
|
|
409
|
+
targetVersion &&
|
|
410
|
+
Array.isArray(range) &&
|
|
411
|
+
range.length === 2 &&
|
|
412
|
+
typeof range[0] === 'string' &&
|
|
413
|
+
typeof range[1] === 'string' &&
|
|
414
|
+
semver.valid(currentVersion) &&
|
|
415
|
+
semver.valid(targetVersion) &&
|
|
416
|
+
semver.valid(range[0]) &&
|
|
417
|
+
semver.valid(range[1]) &&
|
|
418
|
+
semver.lt(currentVersion, range[0]) &&
|
|
419
|
+
semver.gte(targetVersion, range[1])
|
|
420
|
+
) {
|
|
421
|
+
return fullResource;
|
|
422
|
+
}
|
|
423
|
+
return resource;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const getExecutor = (features: Features): FirmwareUpdatePlan['executor'] => {
|
|
427
|
+
const deviceType = getDeviceType(features);
|
|
428
|
+
if (deviceType === EDeviceType.Pro2 || deviceType === EDeviceType.Neo) {
|
|
429
|
+
return 'v4';
|
|
430
|
+
}
|
|
431
|
+
if (
|
|
432
|
+
deviceType === EDeviceType.Pro &&
|
|
433
|
+
semver.gte(getDeviceBootloaderVersion(features).join('.'), '2.8.0')
|
|
434
|
+
) {
|
|
435
|
+
return 'v3';
|
|
436
|
+
}
|
|
437
|
+
return 'v2';
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
const buildProtocolV2Artifacts = (
|
|
441
|
+
release: ReleaseRecord,
|
|
442
|
+
{
|
|
443
|
+
includeComponents = true,
|
|
444
|
+
componentTargets: selectedComponentTargets,
|
|
445
|
+
}: {
|
|
446
|
+
includeComponents?: boolean;
|
|
447
|
+
componentTargets?: ReadonlySet<FirmwareUpdatePlanTarget>;
|
|
448
|
+
} = {}
|
|
449
|
+
): {
|
|
450
|
+
artifacts: FirmwareUpdatePlanArtifact[];
|
|
451
|
+
targets: FirmwareUpdatePlanTarget[];
|
|
452
|
+
} => {
|
|
453
|
+
const components = asRecord(release.components);
|
|
454
|
+
if (includeComponents && !components) {
|
|
455
|
+
throw ERRORS.TypedError(
|
|
456
|
+
HardwareErrorCode.RuntimeError,
|
|
457
|
+
'Protocol V2 release has no component set',
|
|
458
|
+
{ firmwareUpdateCode: 'FirmwarePlanInvalid' }
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
const installOrder = Array.isArray(release.installOrder)
|
|
462
|
+
? release.installOrder.filter((key): key is string => typeof key === 'string')
|
|
463
|
+
: [];
|
|
464
|
+
const componentKeys =
|
|
465
|
+
includeComponents && components
|
|
466
|
+
? [...installOrder, ...Object.keys(components).filter(key => !installOrder.includes(key))]
|
|
467
|
+
: [];
|
|
468
|
+
const selectedComponentKeys = selectedComponentTargets
|
|
469
|
+
? componentKeys.filter(key => {
|
|
470
|
+
const component = asRecord(components?.[key]);
|
|
471
|
+
const targetName = asString(component?.target)?.toUpperCase();
|
|
472
|
+
const target = targetName ? PROTOCOL_V2_TARGETS[targetName] : undefined;
|
|
473
|
+
return !!target && selectedComponentTargets.has(target);
|
|
474
|
+
})
|
|
475
|
+
: componentKeys;
|
|
476
|
+
const artifacts: FirmwareUpdatePlanArtifact[] = [];
|
|
477
|
+
const targets: FirmwareUpdatePlanTarget[] = [];
|
|
478
|
+
const componentTargetSet = new Set<FirmwareUpdatePlanTarget>();
|
|
479
|
+
for (const key of selectedComponentKeys) {
|
|
480
|
+
const component = asRecord(components?.[key]);
|
|
481
|
+
const targetName = asString(component?.target)?.toUpperCase();
|
|
482
|
+
const target = targetName ? PROTOCOL_V2_TARGETS[targetName] : undefined;
|
|
483
|
+
if (targetName === 'ROMLOADER') {
|
|
484
|
+
throw ERRORS.TypedError(
|
|
485
|
+
HardwareErrorCode.RuntimeError,
|
|
486
|
+
'Protocol V2 ROMLOADER requires its dedicated loader flow',
|
|
487
|
+
{ firmwareUpdateCode: 'FirmwarePlanInvalid' }
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
if (!component || !target) {
|
|
491
|
+
throw ERRORS.TypedError(
|
|
492
|
+
HardwareErrorCode.RuntimeError,
|
|
493
|
+
`Protocol V2 component ${key} has an unsupported target`,
|
|
494
|
+
{ firmwareUpdateCode: 'FirmwarePlanInvalid' }
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
if (componentTargetSet.has(target)) {
|
|
498
|
+
throw ERRORS.TypedError(
|
|
499
|
+
HardwareErrorCode.RuntimeError,
|
|
500
|
+
`Protocol V2 component ${key} duplicates target ${target}`,
|
|
501
|
+
{ firmwareUpdateCode: 'FirmwarePlanInvalid' }
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
componentTargetSet.add(target);
|
|
505
|
+
const integrity = asIntegrity({
|
|
506
|
+
size: component.expectedSize,
|
|
507
|
+
sha256: component.fingerprint,
|
|
508
|
+
});
|
|
509
|
+
if (integrity.expectedSize === undefined || integrity.expectedSha256 === undefined) {
|
|
510
|
+
planError(`Protocol V2 component ${key} integrity metadata is invalid`);
|
|
511
|
+
}
|
|
512
|
+
artifacts.push({
|
|
513
|
+
artifactId: `component:${target}`,
|
|
514
|
+
role: 'component',
|
|
515
|
+
target,
|
|
516
|
+
url: assertArtifactUrl(component.url, `Protocol V2 component ${key}`),
|
|
517
|
+
container: 'raw',
|
|
518
|
+
logicalName: key,
|
|
519
|
+
...integrity,
|
|
520
|
+
...(asVersion(component.version) ? { targetVersion: asVersion(component.version) } : {}),
|
|
521
|
+
});
|
|
522
|
+
targets.push(target);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return { artifacts, targets: [...new Set(targets)] };
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
const isForcedTargetRepresented = ({
|
|
529
|
+
executor,
|
|
530
|
+
forcedTarget,
|
|
531
|
+
artifacts,
|
|
532
|
+
targetsToUpdate,
|
|
533
|
+
}: {
|
|
534
|
+
executor: FirmwareUpdatePlan['executor'];
|
|
535
|
+
forcedTarget: FirmwareUpdatePlanForceTarget;
|
|
536
|
+
artifacts: readonly FirmwareUpdatePlanArtifact[];
|
|
537
|
+
targetsToUpdate: readonly FirmwareUpdatePlanTarget[];
|
|
538
|
+
}): boolean => {
|
|
539
|
+
if (executor !== 'v4') {
|
|
540
|
+
return artifacts.some(
|
|
541
|
+
artifact => artifact.target === forcedTarget && targetsToUpdate.includes(forcedTarget)
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
if (forcedTarget === 'firmware') {
|
|
545
|
+
return artifacts.some(
|
|
546
|
+
artifact => artifact.role === 'component' && targetsToUpdate.includes(artifact.target)
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
if (forcedTarget === 'resource') {
|
|
550
|
+
return artifacts.some(
|
|
551
|
+
artifact =>
|
|
552
|
+
artifact.role === 'resourceBundle' &&
|
|
553
|
+
artifact.target === 'resource' &&
|
|
554
|
+
targetsToUpdate.includes('resource')
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
return false;
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
const assertForcedTargetsRepresented = ({
|
|
561
|
+
executor,
|
|
562
|
+
forcedTargets,
|
|
563
|
+
artifacts,
|
|
564
|
+
targetsToUpdate,
|
|
565
|
+
}: {
|
|
566
|
+
executor: FirmwareUpdatePlan['executor'];
|
|
567
|
+
forcedTargets: readonly FirmwareUpdatePlanForceTarget[];
|
|
568
|
+
artifacts: readonly FirmwareUpdatePlanArtifact[];
|
|
569
|
+
targetsToUpdate: readonly FirmwareUpdatePlanTarget[];
|
|
570
|
+
}) => {
|
|
571
|
+
for (const forcedTarget of forcedTargets) {
|
|
572
|
+
if (
|
|
573
|
+
!isForcedTargetRepresented({
|
|
574
|
+
executor,
|
|
575
|
+
forcedTarget,
|
|
576
|
+
artifacts,
|
|
577
|
+
targetsToUpdate,
|
|
578
|
+
})
|
|
579
|
+
) {
|
|
580
|
+
planError(`Forced firmware update target ${forcedTarget} is not represented by the plan`);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
const finalizeFirmwareUpdatePlan = ({
|
|
586
|
+
features,
|
|
587
|
+
firmwareType,
|
|
588
|
+
platform,
|
|
589
|
+
artifacts,
|
|
590
|
+
targetsToUpdate,
|
|
591
|
+
}: {
|
|
592
|
+
features: Features;
|
|
593
|
+
firmwareType: EFirmwareType;
|
|
594
|
+
platform: FirmwareUpdatePlatform;
|
|
595
|
+
artifacts: FirmwareUpdatePlanArtifact[];
|
|
596
|
+
targetsToUpdate: FirmwareUpdatePlanTarget[];
|
|
597
|
+
}): FirmwareUpdatePlan => {
|
|
598
|
+
const executor = getExecutor(features);
|
|
599
|
+
const bootloaderMode = resolveDeviceBootloaderMode(features);
|
|
600
|
+
// 'unavailable' is the reserved degraded-identity sentinel; a device-reported
|
|
601
|
+
// serial must never be able to collide with it.
|
|
602
|
+
const reportedIdentity = getDeviceUUID(features);
|
|
603
|
+
const deviceIdentity = reportedIdentity === 'unavailable' ? '' : reportedIdentity;
|
|
604
|
+
// Classic 系列仅在 bootloader 恢复时允许缺少身份;部分尚未完成产线写号的
|
|
605
|
+
// Pro2/Neo(V4)在正常模式下也可能没有序列号,因此允许使用降级身份。
|
|
606
|
+
const allowsUnavailableIdentity = (bootloaderMode && executor === 'v2') || executor === 'v4';
|
|
607
|
+
if (
|
|
608
|
+
artifacts.length > 0 &&
|
|
609
|
+
(platform === 'native' || platform === 'desktop') &&
|
|
610
|
+
!deviceIdentity &&
|
|
611
|
+
!allowsUnavailableIdentity
|
|
612
|
+
) {
|
|
613
|
+
throw ERRORS.TypedError(
|
|
614
|
+
HardwareErrorCode.RuntimeError,
|
|
615
|
+
'Prepared firmware update requires a stable device identity',
|
|
616
|
+
{ firmwareUpdateCode: 'FirmwarePlanInvalid' }
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
const planWithoutDigest: Omit<FirmwareUpdatePlan, 'planDigest'> = {
|
|
620
|
+
schemaVersion: 2,
|
|
621
|
+
executor,
|
|
622
|
+
deviceIdentity: deviceIdentity || 'unavailable',
|
|
623
|
+
deviceModel: String(getDeviceType(features)),
|
|
624
|
+
firmwareType,
|
|
625
|
+
platform,
|
|
626
|
+
artifacts,
|
|
627
|
+
targetsToUpdate,
|
|
628
|
+
};
|
|
629
|
+
return assertFirmwareUpdatePlan({
|
|
630
|
+
...planWithoutDigest,
|
|
631
|
+
planDigest: digestFirmwareUpdatePlan(planWithoutDigest),
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
export type ProtocolV2LocalFirmwareUpdatePlanArtifact = {
|
|
636
|
+
artifactId: string;
|
|
637
|
+
target: Exclude<FirmwareUpdateV4Target, 'boot_resources'>;
|
|
638
|
+
container: 'raw' | 'zip';
|
|
639
|
+
logicalName: string;
|
|
640
|
+
expectedSize: number;
|
|
641
|
+
expectedSha256: string;
|
|
642
|
+
targetVersion?: string;
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
export const buildProtocolV2LocalFirmwareUpdatePlan = ({
|
|
646
|
+
features,
|
|
647
|
+
firmwareType,
|
|
648
|
+
platform,
|
|
649
|
+
artifacts,
|
|
650
|
+
}: {
|
|
651
|
+
features: Features;
|
|
652
|
+
firmwareType: EFirmwareType;
|
|
653
|
+
platform: FirmwareUpdatePlatform;
|
|
654
|
+
artifacts: ProtocolV2LocalFirmwareUpdatePlanArtifact[];
|
|
655
|
+
}): FirmwareUpdatePlan => {
|
|
656
|
+
if (artifacts.length === 0) {
|
|
657
|
+
return planError('Protocol V2 local firmware plan has no artifacts');
|
|
658
|
+
}
|
|
659
|
+
const plan = finalizeFirmwareUpdatePlan({
|
|
660
|
+
features,
|
|
661
|
+
firmwareType,
|
|
662
|
+
platform,
|
|
663
|
+
artifacts: artifacts.map(artifact => ({
|
|
664
|
+
...artifact,
|
|
665
|
+
role: artifact.target === 'resource' ? 'resourceBundle' : 'component',
|
|
666
|
+
url: `https://local-firmware.invalid/${encodeURIComponent(artifact.artifactId)}`,
|
|
667
|
+
})),
|
|
668
|
+
targetsToUpdate: artifacts.map(artifact => artifact.target),
|
|
669
|
+
});
|
|
670
|
+
if (plan.executor !== 'v4') {
|
|
671
|
+
return planError('Protocol V2 local firmware plan requires executor v4');
|
|
672
|
+
}
|
|
673
|
+
return plan;
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
export const buildProtocolV2FirmwareUpdatePlan = ({
|
|
677
|
+
features,
|
|
678
|
+
firmwareType,
|
|
679
|
+
platform,
|
|
680
|
+
release,
|
|
681
|
+
targetsToUpdate,
|
|
682
|
+
forceUpdateTargets,
|
|
683
|
+
resourceArchive,
|
|
684
|
+
}: {
|
|
685
|
+
features: Features;
|
|
686
|
+
firmwareType: EFirmwareType;
|
|
687
|
+
platform: FirmwareUpdatePlatform;
|
|
688
|
+
release: ReleaseRecord | undefined;
|
|
689
|
+
targetsToUpdate: readonly FirmwareUpdateV4Target[];
|
|
690
|
+
forceUpdateTargets?: FirmwareUpdatePlanForceTarget[];
|
|
691
|
+
resourceArchive: IProtocolV2ResourceSource | undefined;
|
|
692
|
+
}): FirmwareUpdatePlan => {
|
|
693
|
+
const validatedForceTargets = validateFirmwareUpdatePlanForceTargets(forceUpdateTargets);
|
|
694
|
+
if (validatedForceTargets.some(target => target === 'ble' || target === 'bootloader')) {
|
|
695
|
+
planError('Protocol V2 does not support forced BLE or legacy bootloader targets');
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
const requestedComponentTargets = new Set<FirmwareUpdatePlanTarget>(
|
|
699
|
+
targetsToUpdate.filter(target => target !== 'resource')
|
|
700
|
+
);
|
|
701
|
+
if (
|
|
702
|
+
getDeviceType(features) === EDeviceType.Neo &&
|
|
703
|
+
(requestedComponentTargets.has('se03') || requestedComponentTargets.has('se04'))
|
|
704
|
+
) {
|
|
705
|
+
planError('Neo does not support Protocol V2 targets se03 or se04');
|
|
706
|
+
}
|
|
707
|
+
const protocolV2 = buildProtocolV2Artifacts(release ?? {}, {
|
|
708
|
+
includeComponents: requestedComponentTargets.size > 0,
|
|
709
|
+
componentTargets: requestedComponentTargets,
|
|
710
|
+
});
|
|
711
|
+
const resourceRequested = targetsToUpdate.includes('resource');
|
|
712
|
+
if (resourceRequested) {
|
|
713
|
+
const archive = resourceArchive;
|
|
714
|
+
if (!archive) {
|
|
715
|
+
return planError('Protocol V2 resource target has no resource archive');
|
|
716
|
+
}
|
|
717
|
+
const integrity = asIntegrity({
|
|
718
|
+
size: archive.archiveSize,
|
|
719
|
+
sha256: archive.archiveSha256,
|
|
720
|
+
});
|
|
721
|
+
if (integrity.expectedSize === undefined || integrity.expectedSha256 === undefined) {
|
|
722
|
+
planError('Protocol V2 resource archive integrity metadata is invalid');
|
|
723
|
+
}
|
|
724
|
+
protocolV2.artifacts.push({
|
|
725
|
+
artifactId: 'resource:archive',
|
|
726
|
+
role: 'resourceBundle',
|
|
727
|
+
target: 'resource',
|
|
728
|
+
url: assertArtifactUrl(archive.archiveUrl, 'Protocol V2 resource archive'),
|
|
729
|
+
container: 'zip',
|
|
730
|
+
logicalName: 'protocol-v2-resource-archive',
|
|
731
|
+
...integrity,
|
|
732
|
+
});
|
|
733
|
+
protocolV2.targets.push('resource');
|
|
734
|
+
}
|
|
735
|
+
const representedTargets = new Set(protocolV2.targets);
|
|
736
|
+
const missingTarget = Array.from(requestedComponentTargets).find(
|
|
737
|
+
target => !representedTargets.has(target)
|
|
738
|
+
);
|
|
739
|
+
if (missingTarget) {
|
|
740
|
+
planError(`Protocol V2 release does not contain requested target ${missingTarget}`);
|
|
741
|
+
}
|
|
742
|
+
if (validatedForceTargets.includes('firmware') && protocolV2.targets.length === 0) {
|
|
743
|
+
planError('Forced firmware update target firmware is not represented by the plan');
|
|
744
|
+
}
|
|
745
|
+
if (validatedForceTargets.includes('resource') && !resourceArchive) {
|
|
746
|
+
planError('Forced firmware update target resource has no Protocol V2 resource archive');
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
return finalizeFirmwareUpdatePlan({
|
|
750
|
+
features,
|
|
751
|
+
firmwareType,
|
|
752
|
+
platform,
|
|
753
|
+
artifacts: protocolV2.artifacts,
|
|
754
|
+
targetsToUpdate: protocolV2.targets,
|
|
755
|
+
});
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
export const buildFirmwareUpdatePlan = ({
|
|
759
|
+
features,
|
|
760
|
+
firmwareType,
|
|
761
|
+
platform,
|
|
762
|
+
firmware,
|
|
763
|
+
ble,
|
|
764
|
+
bootloader,
|
|
765
|
+
forceUpdateTargets,
|
|
766
|
+
}: {
|
|
767
|
+
features: Features;
|
|
768
|
+
firmwareType: EFirmwareType;
|
|
769
|
+
platform: FirmwareUpdatePlatform;
|
|
770
|
+
firmware: ReleaseSelection;
|
|
771
|
+
ble: ReleaseSelection;
|
|
772
|
+
bootloader?: ReleaseSelection;
|
|
773
|
+
forceUpdateTargets?: FirmwareUpdatePlanForceTarget[];
|
|
774
|
+
}): FirmwareUpdatePlan => {
|
|
775
|
+
const executor = getExecutor(features);
|
|
776
|
+
let artifacts: FirmwareUpdatePlanArtifact[] = [];
|
|
777
|
+
let targetsToUpdate: FirmwareUpdatePlanTarget[] = [];
|
|
778
|
+
const firmwareRelease = asRelease(firmware);
|
|
779
|
+
const validatedForceTargets = validateFirmwareUpdatePlanForceTargets(forceUpdateTargets);
|
|
780
|
+
const forcedTargets = new Set(validatedForceTargets);
|
|
781
|
+
const bootloaderMode = resolveDeviceBootloaderMode(features);
|
|
782
|
+
// Bootloader recovery: an erased device reports firmware status 'none', a device
|
|
783
|
+
// with intact firmware in bootloader mode reports 'unknown' (version fields carry
|
|
784
|
+
// the bootloader version), and neither can report its BLE version — yet the app
|
|
785
|
+
// treats bootloader mode as a mandatory reinstall. Only bootloader mode may treat
|
|
786
|
+
// these statuses as install targets: in normal mode 'none' also describes devices
|
|
787
|
+
// without the component at all (e.g. Mini has no BLE) and must stay excluded.
|
|
788
|
+
const isRecoveryInstall = (release: ReleaseSelection | undefined): boolean =>
|
|
789
|
+
bootloaderMode &&
|
|
790
|
+
(release?.status === 'none' || release?.status === 'unknown') &&
|
|
791
|
+
!!asRelease(release);
|
|
792
|
+
const shouldUpdateFirmware =
|
|
793
|
+
isUpgrade(firmware) || isRecoveryInstall(firmware) || forcedTargets.has('firmware');
|
|
794
|
+
const shouldUpdateResource = isUpgrade(firmware) || forcedTargets.has('resource');
|
|
795
|
+
|
|
796
|
+
if (
|
|
797
|
+
executor === 'v4' &&
|
|
798
|
+
validatedForceTargets.some(target => target === 'ble' || target === 'bootloader')
|
|
799
|
+
) {
|
|
800
|
+
planError('Protocol V2 does not support forced BLE or legacy bootloader targets');
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
if (executor === 'v4' && (shouldUpdateFirmware || shouldUpdateResource)) {
|
|
804
|
+
const protocolV2 = buildProtocolV2Artifacts(firmwareRelease ?? {}, {
|
|
805
|
+
includeComponents: shouldUpdateFirmware,
|
|
806
|
+
});
|
|
807
|
+
artifacts = protocolV2.artifacts;
|
|
808
|
+
targetsToUpdate = protocolV2.targets;
|
|
809
|
+
} else {
|
|
810
|
+
if (isUpgrade(bootloader) || forcedTargets.has('bootloader')) {
|
|
811
|
+
artifacts.push({
|
|
812
|
+
artifactId: 'bootloader',
|
|
813
|
+
role: 'bootloader',
|
|
814
|
+
target: 'bootloader',
|
|
815
|
+
url: assertArtifactUrl(asRelease(bootloader)?.bootloaderResource, 'Bootloader release'),
|
|
816
|
+
container: 'raw',
|
|
817
|
+
...asIntegrity({
|
|
818
|
+
size: asRelease(bootloader)?.bootloaderExpectedSize,
|
|
819
|
+
sha256: asRelease(bootloader)?.bootloaderFingerprint,
|
|
820
|
+
}),
|
|
821
|
+
...(asVersion(asRelease(bootloader)?.bootloaderVersion)
|
|
822
|
+
? {
|
|
823
|
+
targetVersion: asVersion(asRelease(bootloader)?.bootloaderVersion),
|
|
824
|
+
}
|
|
825
|
+
: {}),
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
if (shouldUpdateFirmware || shouldUpdateResource) {
|
|
829
|
+
if (!firmwareRelease) {
|
|
830
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Firmware release is invalid', {
|
|
831
|
+
firmwareUpdateCode: 'FirmwarePlanInvalid',
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
if (shouldUpdateFirmware) {
|
|
835
|
+
artifacts.push({
|
|
836
|
+
artifactId: 'firmware',
|
|
837
|
+
role: 'firmware',
|
|
838
|
+
target: 'firmware',
|
|
839
|
+
url: assertArtifactUrl(firmwareRelease.url, 'Firmware release'),
|
|
840
|
+
container: 'raw',
|
|
841
|
+
...asIntegrity({
|
|
842
|
+
size: firmwareRelease.expectedSize,
|
|
843
|
+
sha256: firmwareRelease.fingerprint,
|
|
844
|
+
}),
|
|
845
|
+
...(asVersion(firmwareRelease.version)
|
|
846
|
+
? { targetVersion: asVersion(firmwareRelease.version) }
|
|
847
|
+
: {}),
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
if (shouldUpdateResource) {
|
|
851
|
+
const resourceUrl = selectResourceUrl({
|
|
852
|
+
release: firmwareRelease,
|
|
853
|
+
features,
|
|
854
|
+
platform,
|
|
855
|
+
});
|
|
856
|
+
if (resourceUrl) {
|
|
857
|
+
artifacts.push({
|
|
858
|
+
artifactId: 'resource',
|
|
859
|
+
role: 'resource',
|
|
860
|
+
target: 'resource',
|
|
861
|
+
url: assertArtifactUrl(resourceUrl, 'Firmware resource release'),
|
|
862
|
+
container: 'zip',
|
|
863
|
+
...asIntegrity({
|
|
864
|
+
size:
|
|
865
|
+
resourceUrl === asString(firmwareRelease.fullResource)
|
|
866
|
+
? firmwareRelease.fullResourceExpectedSize
|
|
867
|
+
: firmwareRelease.resourceExpectedSize,
|
|
868
|
+
sha256:
|
|
869
|
+
resourceUrl === asString(firmwareRelease.fullResource)
|
|
870
|
+
? firmwareRelease.fullResourceFingerprint
|
|
871
|
+
: firmwareRelease.resourceFingerprint,
|
|
872
|
+
}),
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (isUpgrade(ble) || isRecoveryInstall(ble) || forcedTargets.has('ble')) {
|
|
878
|
+
const bleRelease = asRelease(ble);
|
|
879
|
+
artifacts.push({
|
|
880
|
+
artifactId: 'ble',
|
|
881
|
+
role: 'ble',
|
|
882
|
+
target: 'ble',
|
|
883
|
+
url: assertArtifactUrl(bleRelease?.webUpdate ?? bleRelease?.url, 'BLE release'),
|
|
884
|
+
container: 'raw',
|
|
885
|
+
...asIntegrity({
|
|
886
|
+
size: bleRelease?.expectedSize,
|
|
887
|
+
sha256: bleRelease?.fingerprintWeb ?? bleRelease?.fingerprint,
|
|
888
|
+
}),
|
|
889
|
+
...(asVersion(bleRelease?.version)
|
|
890
|
+
? { targetVersion: asVersion(bleRelease?.version) }
|
|
891
|
+
: {}),
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
targetsToUpdate = [...new Set(artifacts.map(artifact => artifact.target))];
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
assertForcedTargetsRepresented({
|
|
898
|
+
executor,
|
|
899
|
+
forcedTargets: validatedForceTargets,
|
|
900
|
+
artifacts,
|
|
901
|
+
targetsToUpdate,
|
|
902
|
+
});
|
|
903
|
+
return finalizeFirmwareUpdatePlan({
|
|
904
|
+
features,
|
|
905
|
+
firmwareType,
|
|
906
|
+
platform,
|
|
907
|
+
artifacts,
|
|
908
|
+
targetsToUpdate,
|
|
909
|
+
});
|
|
910
|
+
};
|