@onekeyfe/hd-core 1.1.34-alpha.1 → 1.1.34-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +75 -0
- package/__tests__/DeviceCommands.test.ts +217 -0
- package/__tests__/RequestQueue.test.ts +140 -0
- package/__tests__/UploadPortfolio.test.ts +46 -0
- package/__tests__/connectSettings.test.ts +61 -0
- package/__tests__/device-lifecycle-events.test.ts +117 -0
- package/__tests__/device-pool-state.test.ts +132 -0
- package/__tests__/device-settings.test.ts +286 -0
- package/__tests__/device-state-mapper.test.ts +229 -0
- package/__tests__/device-utils.test.ts +106 -0
- package/__tests__/device-wallet-session-store.test.ts +191 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +15 -4
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/filesystemValidation.test.ts +53 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-checkpoint.test.ts +105 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +73 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +17 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +358 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-recovery.test.ts +81 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +48 -31
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +403 -0
- package/__tests__/logBlockEvent.test.ts +61 -0
- package/__tests__/logger.test.ts +34 -0
- package/__tests__/open-wallet-session.test.ts +565 -0
- package/__tests__/preInitialize.test.ts +33 -0
- package/__tests__/pro2Wallpaper.test.ts +39 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +19 -0
- package/__tests__/protocol-v2.test.ts +6008 -0
- package/__tests__/protocolV2FileWrite.test.ts +67 -0
- package/__tests__/public-pro2-api-boundary.test.ts +66 -0
- package/__tests__/search-devices.test.ts +136 -0
- package/dist/api/BaseMethod.d.ts +12 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/ClearSessionCache.d.ts +9 -0
- package/dist/api/ClearSessionCache.d.ts.map +1 -0
- package/dist/api/DirList.d.ts +10 -0
- package/dist/api/DirList.d.ts.map +1 -0
- package/dist/api/DirMake.d.ts +9 -0
- package/dist/api/DirMake.d.ts.map +1 -0
- package/dist/api/DirRemove.d.ts +9 -0
- package/dist/api/DirRemove.d.ts.map +1 -0
- package/dist/api/FileDelete.d.ts +9 -0
- package/dist/api/FileDelete.d.ts.map +1 -0
- package/dist/api/FileRead.d.ts +19 -0
- package/dist/api/FileRead.d.ts.map +1 -0
- package/dist/api/FileWrite.d.ts +25 -0
- package/dist/api/FileWrite.d.ts.map +1 -0
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +14 -3
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +10 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +75 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -0
- package/dist/api/GetDeviceState.d.ts +7 -0
- package/dist/api/GetDeviceState.d.ts.map +1 -0
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts +14 -0
- package/dist/api/OpenWalletSession.d.ts.map +1 -0
- package/dist/api/PathInfo.d.ts +10 -0
- package/dist/api/PathInfo.d.ts.map +1 -0
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +5 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +18 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -0
- package/dist/api/alephium/AlephiumGetAddress.d.ts +2 -6
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts +2 -5
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts +5 -8
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts +2 -9
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts +2 -9
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts +2 -8
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts +2 -8
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -11
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -11
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -15
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -11
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -11
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -11
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceCancel.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts +1 -2
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -1
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +7 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceVerify.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -8
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getAddress.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getPublicKey.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signMessage.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/verifyMessage.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +26 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareCheckpoint.d.ts +15 -0
- package/dist/api/firmware/FirmwareCheckpoint.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +10 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +29 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +11 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts +3 -0
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/helpers/filesystemValidation.d.ts +10 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts +33 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
- package/dist/api/index.d.ts +29 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/lightning/LnurlAuth.d.ts +4 -0
- package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts +2 -8
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts +2 -8
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts +2 -9
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts +9 -12
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts +2 -8
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +2 -9
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +3 -0
- package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
- package/dist/api/polkadot/networks.d.ts +3 -0
- package/dist/api/polkadot/networks.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +28 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts +28 -0
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +16 -0
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +12 -0
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +26 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
- package/dist/api/protocol-v2/Ping.d.ts +8 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +6 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +42 -0
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -0
- package/dist/api/scdo/ScdoGetAddress.d.ts +2 -6
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts +2 -5
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts +2 -5
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts +1 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +3 -0
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +3 -0
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +6 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +2 -1
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +3 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +3 -0
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +3 -0
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +3 -0
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +5 -2
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +3 -0
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +1 -0
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +3 -0
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +3 -0
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +3 -0
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +3 -0
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/utils.d.ts +2 -1
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/constants/index.d.ts +2 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +19 -1
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/deviceEventRegistration.d.ts +11 -0
- package/dist/core/deviceEventRegistration.d.ts.map +1 -0
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +9 -5
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +5 -4
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +60 -16
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +16 -14
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +2 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/device/DeviceFeaturesState.d.ts +4 -0
- package/dist/device/DeviceFeaturesState.d.ts.map +1 -0
- package/dist/device/DevicePool.d.ts +4 -2
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts +13 -0
- package/dist/device/DeviceStateMapper.d.ts.map +1 -0
- package/dist/device/DeviceStateProjector.d.ts +7 -0
- package/dist/device/DeviceStateProjector.d.ts.map +1 -0
- package/dist/device/DeviceStateStore.d.ts +21 -0
- package/dist/device/DeviceStateStore.d.ts.map +1 -0
- package/dist/device/DeviceWalletSessionStore.d.ts +15 -0
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -0
- package/dist/device/cloneDeviceState.d.ts +2 -0
- package/dist/device/cloneDeviceState.d.ts.map +1 -0
- package/dist/device/deviceIdentity.d.ts +5 -0
- package/dist/device/deviceIdentity.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +12 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -0
- package/dist/deviceProfile/index.d.ts +2 -0
- package/dist/deviceProfile/index.d.ts.map +1 -0
- package/dist/events/call.d.ts +7 -0
- package/dist/events/call.d.ts.map +1 -1
- package/dist/events/core.d.ts +2 -2
- package/dist/events/core.d.ts.map +1 -1
- package/dist/events/device.d.ts +11 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/iframe.d.ts +1 -0
- package/dist/events/iframe.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts +1 -0
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +26 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +1797 -451
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26905 -5606
- package/dist/inject.d.ts +3 -2
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts +2 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/deviceSession.d.ts +7 -0
- package/dist/protocols/protocol-v2/deviceSession.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/features.d.ts +88 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/firmware.d.ts +15 -0
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/index.d.ts +5 -0
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +16 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +39 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +11 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +21 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -0
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +4 -2
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +9 -0
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +1 -1
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +114 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +13 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +35 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +43 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/getDeviceState.d.ts +12 -0
- package/dist/types/api/getDeviceState.d.ts.map +1 -0
- package/dist/types/api/getFeatures.d.ts.map +1 -1
- package/dist/types/api/getOnekeyFeatures.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +2 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +48 -2
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +35 -0
- package/dist/types/api/openWalletSession.d.ts.map +1 -0
- package/dist/types/api/protocolV2.d.ts +113 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -0
- package/dist/types/api/searchDevices.d.ts +2 -2
- package/dist/types/api/searchDevices.d.ts.map +1 -1
- package/dist/types/api/sessionCache.d.ts +10 -0
- package/dist/types/api/sessionCache.d.ts.map +1 -0
- package/dist/types/device.d.ts +207 -5
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +3 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +33 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/capabilitieUtils.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +13 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -0
- package/dist/utils/deviceFeaturesUtils.d.ts +17 -9
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +10 -8
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +2 -0
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +6 -5
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/findDefectiveBatchDevice.d.ts +1 -1
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/pro2Wallpaper.d.ts +12 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -0
- package/dist/utils/tracing.d.ts.map +1 -1
- package/dist/utils/versionUtils.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +60 -23
- package/src/api/CheckAllFirmwareRelease.ts +16 -3
- package/src/api/CheckBootloaderRelease.ts +1 -2
- package/src/api/CheckFirmwareRelease.ts +1 -2
- package/src/api/ClearSessionCache.ts +28 -0
- package/src/api/DirList.ts +33 -0
- package/src/api/DirMake.ts +23 -0
- package/src/api/DirRemove.ts +23 -0
- package/src/api/FileDelete.ts +23 -0
- package/src/api/FileRead.ts +183 -0
- package/src/api/FileWrite.ts +71 -0
- package/src/api/FirmwareUpdate.ts +15 -7
- package/src/api/FirmwareUpdateV2.ts +354 -148
- package/src/api/FirmwareUpdateV3.ts +376 -62
- package/src/api/FirmwareUpdateV4.ts +2279 -0
- package/src/api/GetDeviceState.ts +55 -0
- package/src/api/GetFeatures.ts +12 -4
- package/src/api/GetOnekeyFeatures.ts +15 -3
- package/src/api/GetPassphraseState.ts +9 -10
- package/src/api/OpenWalletSession.ts +211 -0
- package/src/api/PathInfo.ts +41 -0
- package/src/api/PromptWebDeviceAccess.ts +10 -1
- package/src/api/SearchDevices.ts +33 -3
- package/src/api/UploadPortfolio.ts +50 -0
- package/src/api/alephium/AlephiumGetAddress.ts +6 -2
- package/src/api/alephium/AlephiumSignMessage.ts +6 -1
- package/src/api/alephium/AlephiumSignTransaction.ts +15 -4
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +25 -21
- package/src/api/aptos/AptosGetAddress.ts +2 -3
- package/src/api/benfen/BenfenGetAddress.ts +11 -7
- package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
- package/src/api/benfen/BenfenSignMessage.ts +6 -1
- package/src/api/benfen/BenfenSignTransaction.ts +6 -1
- package/src/api/btc/BTCGetPublicKey.ts +3 -2
- package/src/api/btc/BTCSignPsbt.ts +1 -2
- package/src/api/btc/helpers/versionLimit.ts +7 -1
- package/src/api/cardano/CardanoSignTransaction.ts +2 -4
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
- package/src/api/device/DeviceCancel.ts +1 -0
- package/src/api/device/DeviceChangePin.ts +24 -0
- package/src/api/device/DeviceFullyUploadResource.ts +6 -7
- package/src/api/device/DeviceLock.ts +2 -3
- package/src/api/device/DeviceRebootToBoardloader.ts +11 -1
- package/src/api/device/DeviceRebootToBootloader.ts +11 -1
- package/src/api/device/DeviceSettings.ts +121 -0
- package/src/api/device/DeviceSupportFeatures.ts +2 -13
- package/src/api/device/DeviceUnlock.ts +9 -0
- package/src/api/device/DeviceUpdateBootloader.ts +175 -11
- package/src/api/device/DeviceUploadResource.ts +4 -5
- package/src/api/device/DeviceVerify.ts +1 -2
- package/src/api/device/DeviceWipe.ts +19 -0
- package/src/api/dynex/DnxGetAddress.ts +6 -0
- package/src/api/dynex/DnxSignTransaction.ts +6 -0
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +3 -4
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +14 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +30 -18
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/evm/latest/signTypedHash.ts +2 -4
- package/src/api/evm/legacyV1/getAddress.ts +5 -3
- package/src/api/evm/legacyV1/getPublicKey.ts +5 -3
- package/src/api/evm/legacyV1/signMessage.ts +5 -3
- package/src/api/evm/legacyV1/signTypedData.ts +9 -8
- package/src/api/evm/legacyV1/signTypedHash.ts +7 -7
- package/src/api/evm/legacyV1/verifyMessage.ts +5 -3
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareCheckpoint.ts +188 -0
- package/src/api/firmware/FirmwareHostBinding.ts +108 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -15
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +13 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +729 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +403 -0
- package/src/api/firmware/bootloaderHelper.ts +3 -2
- package/src/api/firmware/getBinary.ts +1 -1
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/releaseHelper.ts +3 -3
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +148 -34
- package/src/api/helpers/batchGetPublickeys.ts +51 -6
- package/src/api/helpers/filesystemValidation.ts +112 -0
- package/src/api/helpers/protocolV2FileWrite.ts +193 -0
- package/src/api/index.ts +32 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +2 -3
- package/src/api/lightning/LnurlAuth.ts +4 -0
- package/src/api/neo/NeoGetAddress.ts +6 -1
- package/src/api/neo/NeoSignTransaction.ts +6 -1
- package/src/api/nervos/NervosGetAddress.ts +6 -2
- package/src/api/nervos/NervosSignTransaction.ts +14 -4
- package/src/api/nexa/NexaGetAddress.ts +6 -2
- package/src/api/nexa/NexaSignTransaction.ts +11 -12
- package/src/api/polkadot/networks.ts +9 -0
- package/src/api/protocol-v2/DeviceFactoryInfoGet.ts +20 -0
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +61 -0
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +55 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +18 -0
- package/src/api/protocol-v2/DeviceInfoGet.ts +145 -0
- package/src/api/protocol-v2/DeviceReboot.ts +26 -0
- package/src/api/protocol-v2/DeviceSessionOpen.ts +102 -0
- package/src/api/protocol-v2/DeviceSettingsGet.ts +18 -0
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +70 -0
- package/src/api/protocol-v2/DeviceSettingsSet.ts +44 -0
- package/src/api/protocol-v2/DeviceStatusGet.ts +16 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +131 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +19 -0
- package/src/api/protocol-v2/FilesystemPermissionFix.ts +16 -0
- package/src/api/protocol-v2/Ping.ts +18 -0
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +16 -0
- package/src/api/protocol-v2/helpers.ts +203 -0
- package/src/api/scdo/ScdoGetAddress.ts +6 -2
- package/src/api/scdo/ScdoSignMessage.ts +6 -1
- package/src/api/scdo/ScdoSignTransaction.ts +6 -2
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +3 -0
- package/src/api/solana/SolSignOffchainMessage.ts +3 -0
- package/src/api/solana/SolSignTransaction.ts +6 -0
- package/src/api/stellar/StellarGetAddress.ts +10 -1
- package/src/api/stellar/StellarSignTransaction.ts +14 -1
- package/src/api/sui/SuiGetAddress.ts +5 -3
- package/src/api/sui/SuiGetPublicKey.ts +3 -0
- package/src/api/sui/SuiSignMessage.ts +3 -0
- package/src/api/sui/SuiSignTransaction.ts +14 -12
- package/src/api/ton/TonGetAddress.ts +3 -0
- package/src/api/ton/TonSignData.ts +6 -3
- package/src/api/ton/TonSignMessage.ts +6 -5
- package/src/api/ton/TonSignProof.ts +3 -0
- package/src/api/tron/TronSignMessage.ts +4 -1
- package/src/api/tron/TronSignTransaction.ts +3 -0
- package/src/api/utils.ts +7 -3
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/constants/index.ts +7 -1
- package/src/core/RequestQueue.ts +124 -4
- package/src/core/deviceEventRegistration.ts +23 -0
- package/src/core/index.ts +255 -116
- package/src/data/messages/messages-protocol-v2.json +13544 -0
- package/src/data-manager/DataManager.ts +61 -49
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +38 -12
- package/src/data-manager/connectSettings.ts +15 -0
- package/src/device/Device.ts +759 -164
- package/src/device/DeviceCommands.ts +245 -36
- package/src/device/DeviceConnector.ts +29 -4
- package/src/device/DeviceFeaturesState.ts +34 -0
- package/src/device/DevicePool.ts +69 -21
- package/src/device/DeviceStateMapper.ts +348 -0
- package/src/device/DeviceStateProjector.ts +95 -0
- package/src/device/DeviceStateStore.ts +201 -0
- package/src/device/DeviceWalletSessionStore.ts +78 -0
- package/src/device/cloneDeviceState.ts +39 -0
- package/src/device/deviceIdentity.ts +18 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +391 -0
- package/src/deviceProfile/index.ts +4 -0
- package/src/events/call.ts +6 -0
- package/src/events/core.ts +2 -0
- package/src/events/device.ts +17 -1
- package/src/events/iframe.ts +1 -0
- package/src/events/logBlockEvent.ts +30 -0
- package/src/events/ui-request.ts +32 -2
- package/src/index.ts +9 -0
- package/src/inject.ts +75 -3
- package/src/lowLevelInject.ts +8 -1
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +163 -0
- package/src/protocols/protocol-v2/firmware.ts +21 -0
- package/src/protocols/protocol-v2/index.ts +18 -0
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +61 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +210 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +76 -0
- package/src/protocols/protocol-v2/walletSession.ts +202 -0
- package/src/topLevelInject.ts +7 -1
- package/src/types/api/checkAllFirmwareRelease.ts +4 -2
- package/src/types/api/deviceSettings.ts +9 -0
- package/src/types/api/deviceUnlock.ts +1 -1
- package/src/types/api/deviceUpdateBootloader.ts +10 -1
- package/src/types/api/export.ts +25 -0
- package/src/types/api/firmwareUpdate.ts +163 -1
- package/src/types/api/firmwareUpdateCapabilities.ts +13 -0
- package/src/types/api/firmwareUpdatePlan.ts +52 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +55 -0
- package/src/types/api/getDeviceState.ts +19 -0
- package/src/types/api/getFeatures.ts +3 -0
- package/src/types/api/getOnekeyFeatures.ts +3 -0
- package/src/types/api/getPassphraseState.ts +10 -2
- package/src/types/api/index.ts +89 -2
- package/src/types/api/openWalletSession.ts +54 -0
- package/src/types/api/protocolV2.ts +244 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/api/sessionCache.ts +14 -0
- package/src/types/device.ts +266 -5
- package/src/types/params.ts +11 -0
- package/src/types/settings.ts +54 -29
- package/src/utils/capabilitieUtils.ts +1 -2
- package/src/utils/deviceFeaturesCompat.ts +173 -0
- package/src/utils/deviceFeaturesUtils.ts +122 -84
- package/src/utils/deviceInfoUtils.ts +38 -87
- package/src/utils/deviceSettings.ts +48 -0
- package/src/utils/deviceVersionUtils.ts +25 -62
- package/src/utils/findDefectiveBatchDevice.ts +8 -8
- package/src/utils/homescreen.ts +10 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/pro2Wallpaper.ts +109 -0
- package/src/utils/tracing.ts +3 -1
|
@@ -14,27 +14,44 @@ import { BaseMethod } from './BaseMethod';
|
|
|
14
14
|
import { validateParams } from './helpers/paramsValidator';
|
|
15
15
|
import { DevicePool } from '../device/DevicePool';
|
|
16
16
|
import { getBinary, getInfo, getSysResourceBinary } from './firmware/getBinary';
|
|
17
|
-
import { updateResources, uploadFirmware } from './firmware/uploadFirmware';
|
|
18
17
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
getLogger,
|
|
25
|
-
wait,
|
|
26
|
-
} from '../utils';
|
|
18
|
+
updateResources,
|
|
19
|
+
updateResourcesFromSources,
|
|
20
|
+
uploadFirmwareFromSource,
|
|
21
|
+
} from './firmware/uploadFirmware';
|
|
22
|
+
import { LoggerNames, getLogger, wait } from '../utils';
|
|
27
23
|
import { FirmwareUpdateTipMessage, createUiMessage } from '../events/ui-request';
|
|
28
24
|
import { DeviceModelToTypes } from '../types';
|
|
29
25
|
import { DataManager } from '../data-manager';
|
|
30
26
|
import { DEVICE } from '../events';
|
|
27
|
+
import { type FirmwareByteSource, openFirmwareByteSource } from './firmware/FirmwareArtifactSource';
|
|
28
|
+
import { FirmwareCheckpointWriter } from './firmware/FirmwareCheckpoint';
|
|
29
|
+
import { resolveFirmwareUpdateHostBinding } from './firmware/FirmwareHostBinding';
|
|
30
|
+
import {
|
|
31
|
+
assertFirmwareUpdatePreparedPlanBinding,
|
|
32
|
+
getFirmwareUpdateResourceName,
|
|
33
|
+
} from './firmware/FirmwareUpdatePreparedPlan';
|
|
31
34
|
|
|
32
35
|
import type { Features, KnownDevice } from '../types';
|
|
33
|
-
import type { Device } from '../device/Device';
|
|
34
36
|
import type { FirmwareBinary } from './firmware/getBinary';
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
import type {
|
|
38
|
+
FirmwareArtifactReader,
|
|
39
|
+
FirmwareArtifactReference,
|
|
40
|
+
FirmwareCheckpointParams,
|
|
41
|
+
} from '../types/api/firmwareUpdate';
|
|
42
|
+
import type { FirmwareUpdatePreparedPlan } from '../types/api/firmwareUpdatePreparedPlan';
|
|
43
|
+
|
|
44
|
+
type Params = FirmwareCheckpointParams & {
|
|
37
45
|
binary?: ArrayBuffer;
|
|
46
|
+
artifact?: FirmwareArtifactReference;
|
|
47
|
+
resourceArtifact?: FirmwareArtifactReference;
|
|
48
|
+
resourceEntries?: Array<{
|
|
49
|
+
entryName: string;
|
|
50
|
+
artifact: FirmwareArtifactReference;
|
|
51
|
+
}>;
|
|
52
|
+
artifactReader?: FirmwareArtifactReader;
|
|
53
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
54
|
+
platform?: FirmwareUpdatePreparedPlan['platform'];
|
|
38
55
|
version?: number[];
|
|
39
56
|
updateType: 'firmware' | 'ble';
|
|
40
57
|
forcedUpdateRes?: boolean;
|
|
@@ -115,6 +132,13 @@ const normalizeFirmwareBinary = (binary: unknown): FirmwareBinary | undefined =>
|
|
|
115
132
|
return normalized.buffer;
|
|
116
133
|
};
|
|
117
134
|
|
|
135
|
+
const toArrayBuffer = (binary: FirmwareBinary): ArrayBuffer => {
|
|
136
|
+
if (binary instanceof ArrayBuffer) {
|
|
137
|
+
return binary;
|
|
138
|
+
}
|
|
139
|
+
return new Uint8Array(binary.buffer, binary.byteOffset, binary.byteLength).slice().buffer;
|
|
140
|
+
};
|
|
141
|
+
|
|
118
142
|
export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
119
143
|
checkPromise: Deferred<any> | null = null;
|
|
120
144
|
|
|
@@ -161,6 +185,42 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
161
185
|
binary: payload.binary,
|
|
162
186
|
};
|
|
163
187
|
}
|
|
188
|
+
|
|
189
|
+
if ('artifact' in payload) {
|
|
190
|
+
const hostBinding = resolveFirmwareUpdateHostBinding(payload.hostBindingGeneration);
|
|
191
|
+
const target = payload.isUpdateBootloader ? 'bootloader' : payload.updateType;
|
|
192
|
+
const resourceBindings = [
|
|
193
|
+
...(payload.resourceArtifact
|
|
194
|
+
? [{ target: 'resource' as const, artifact: payload.resourceArtifact }]
|
|
195
|
+
: []),
|
|
196
|
+
...(payload.resourceEntries ?? []).map(
|
|
197
|
+
(entry: { entryName: string; artifact: FirmwareArtifactReference }) => ({
|
|
198
|
+
target: 'resource' as const,
|
|
199
|
+
entryName: entry.entryName,
|
|
200
|
+
artifact: entry.artifact,
|
|
201
|
+
})
|
|
202
|
+
),
|
|
203
|
+
];
|
|
204
|
+
assertFirmwareUpdatePreparedPlanBinding({
|
|
205
|
+
preparedPlan: payload.preparedPlan,
|
|
206
|
+
executor: 'v2',
|
|
207
|
+
platform: payload.platform,
|
|
208
|
+
scopeTargets: [target, ...(target === 'firmware' ? (['resource'] as const) : [])],
|
|
209
|
+
bindings: [{ target, artifact: payload.artifact }, ...resourceBindings],
|
|
210
|
+
});
|
|
211
|
+
this.params = {
|
|
212
|
+
...this.params,
|
|
213
|
+
preparedPlan: payload.preparedPlan,
|
|
214
|
+
hostBindingGeneration: payload.hostBindingGeneration,
|
|
215
|
+
artifact: payload.artifact,
|
|
216
|
+
resourceArtifact: payload.resourceArtifact,
|
|
217
|
+
resourceEntries: payload.resourceEntries,
|
|
218
|
+
artifactReader: hostBinding.artifactReader,
|
|
219
|
+
checkpointSink: hostBinding.checkpointSink,
|
|
220
|
+
checkpointSequenceStart: payload.checkpointSequenceStart,
|
|
221
|
+
resumeCheckpoint: payload.resumeCheckpoint,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
164
224
|
}
|
|
165
225
|
|
|
166
226
|
postTipMessage = (message: string) => {
|
|
@@ -174,7 +234,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
174
234
|
);
|
|
175
235
|
};
|
|
176
236
|
|
|
177
|
-
private async _promptDeviceInBootloaderForWebDevice(
|
|
237
|
+
private async _promptDeviceInBootloaderForWebDevice() {
|
|
178
238
|
return new Promise((resolve, reject) => {
|
|
179
239
|
if (this.device.listenerCount(DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE) > 0) {
|
|
180
240
|
this.device.emit(
|
|
@@ -205,9 +265,8 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
205
265
|
// eslint-disable-next-line prefer-const
|
|
206
266
|
let timeoutTimer: ReturnType<typeof setTimeout> | undefined;
|
|
207
267
|
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
getDeviceType(this?.device?.features) === EDeviceType.Pro;
|
|
268
|
+
const deviceType = this.device?.getCurrentDeviceType();
|
|
269
|
+
const isTouchOrProDevice = deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro;
|
|
211
270
|
|
|
212
271
|
const intervalTimer: ReturnType<typeof setInterval> | undefined = setInterval(
|
|
213
272
|
async () => {
|
|
@@ -229,9 +288,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
229
288
|
|
|
230
289
|
try {
|
|
231
290
|
this.postTipMessage(FirmwareUpdateTipMessage.SelectDeviceInBootloaderForWebDevice);
|
|
232
|
-
const confirmed = await this._promptDeviceInBootloaderForWebDevice(
|
|
233
|
-
device: this.device,
|
|
234
|
-
});
|
|
291
|
+
const confirmed = await this._promptDeviceInBootloaderForWebDevice();
|
|
235
292
|
if (confirmed) {
|
|
236
293
|
await this._checkDeviceInBootloaderMode(connectId, intervalTimer, timeoutTimer);
|
|
237
294
|
}
|
|
@@ -253,7 +310,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
253
310
|
true
|
|
254
311
|
);
|
|
255
312
|
await this.device.initialize();
|
|
256
|
-
if (this.device.
|
|
313
|
+
if (this.device.isBootloader()) {
|
|
257
314
|
clearInterval(intervalTimer);
|
|
258
315
|
this.checkPromise?.resolve(true);
|
|
259
316
|
}
|
|
@@ -286,7 +343,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
286
343
|
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
287
344
|
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, connectId);
|
|
288
345
|
|
|
289
|
-
if (deviceList.length === 1 && deviceList[0]?.
|
|
346
|
+
if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
|
|
290
347
|
// should update current device from cache
|
|
291
348
|
// because device was reboot and had some new requests
|
|
292
349
|
this.device.updateFromCache(deviceList[0]);
|
|
@@ -300,22 +357,22 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
300
357
|
return false;
|
|
301
358
|
}
|
|
302
359
|
|
|
303
|
-
isEnteredManuallyBoot(
|
|
304
|
-
const deviceType =
|
|
360
|
+
isEnteredManuallyBoot() {
|
|
361
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
305
362
|
const isMini = deviceType === EDeviceType.Mini;
|
|
306
363
|
const isBoot183ClassicUpBle =
|
|
307
364
|
this.params.updateType === 'firmware' &&
|
|
308
365
|
deviceType === EDeviceType.Classic &&
|
|
309
|
-
|
|
366
|
+
this.device.getCurrentBootloaderVersionString() === '1.8.3';
|
|
310
367
|
return isMini || isBoot183ClassicUpBle;
|
|
311
368
|
}
|
|
312
369
|
|
|
313
|
-
isSupportResourceUpdate(
|
|
370
|
+
isSupportResourceUpdate(updateType: string) {
|
|
314
371
|
if (updateType !== 'firmware') return false;
|
|
315
372
|
|
|
316
|
-
const deviceType =
|
|
373
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
317
374
|
const isTouchMode = deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro;
|
|
318
|
-
const currentVersion =
|
|
375
|
+
const currentVersion = this.device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
319
376
|
|
|
320
377
|
return isTouchMode && semver.gte(currentVersion, '3.2.0');
|
|
321
378
|
}
|
|
@@ -326,8 +383,8 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
326
383
|
*/
|
|
327
384
|
checkVersionForCopyTouchResource(features: Features | undefined, firmwareType: EFirmwareType) {
|
|
328
385
|
if (!features) return;
|
|
329
|
-
const deviceType =
|
|
330
|
-
const currentVersion =
|
|
386
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
387
|
+
const currentVersion = this.device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
331
388
|
const targetVersion = this.params.version?.join('.');
|
|
332
389
|
const { updateType } = this.params;
|
|
333
390
|
|
|
@@ -351,153 +408,302 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
351
408
|
async run() {
|
|
352
409
|
const { device, params } = this;
|
|
353
410
|
const { features, commands } = device;
|
|
354
|
-
const deviceType =
|
|
411
|
+
const deviceType = device.getCurrentDeviceType();
|
|
412
|
+
const checkpointWriter = new FirmwareCheckpointWriter(params, {
|
|
413
|
+
required: !!params.artifactReader,
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
// Protocol V2 (Pro2) uses DeviceFirmwareUpdate and must not enter this legacy flow.
|
|
417
|
+
if (device.isProtocolV2()) {
|
|
418
|
+
throw ERRORS.TypedError(
|
|
419
|
+
HardwareErrorCode.RuntimeError,
|
|
420
|
+
'Protocol V2 firmware update must use firmwareUpdateV4'
|
|
421
|
+
);
|
|
422
|
+
}
|
|
355
423
|
|
|
356
|
-
const deviceFirmwareType =
|
|
424
|
+
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
357
425
|
const firmwareType = params.firmwareType ?? deviceFirmwareType;
|
|
358
426
|
|
|
359
427
|
this.checkVersionForCopyTouchResource(features, firmwareType);
|
|
360
428
|
|
|
361
|
-
let
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (params.binary !== undefined) {
|
|
369
|
-
preparedBinary = normalizeFirmwareBinary(params.binary);
|
|
370
|
-
if (!preparedBinary) {
|
|
371
|
-
throw new Error('firmware binary is empty or invalid');
|
|
429
|
+
let preparedSource: FirmwareByteSource | undefined;
|
|
430
|
+
try {
|
|
431
|
+
const acquireFirmwareSource = async (): Promise<FirmwareByteSource> => {
|
|
432
|
+
try {
|
|
433
|
+
if (preparedSource) {
|
|
434
|
+
return preparedSource;
|
|
372
435
|
}
|
|
373
|
-
return preparedBinary;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if (!device.features) {
|
|
377
|
-
throw ERRORS.TypedError(
|
|
378
|
-
HardwareErrorCode.RuntimeError,
|
|
379
|
-
'no features found for this device'
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
436
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return preparedBinary;
|
|
398
|
-
} catch (err) {
|
|
399
|
-
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateDownloadFailed, err.message ?? err);
|
|
400
|
-
}
|
|
401
|
-
};
|
|
437
|
+
if (params.binary !== undefined) {
|
|
438
|
+
const binary = normalizeFirmwareBinary(params.binary);
|
|
439
|
+
if (!binary) {
|
|
440
|
+
throw new Error('firmware binary is empty or invalid');
|
|
441
|
+
}
|
|
442
|
+
const source = await openFirmwareByteSource({
|
|
443
|
+
binary: toArrayBuffer(binary),
|
|
444
|
+
});
|
|
445
|
+
if (!source) {
|
|
446
|
+
throw new Error('firmware binary is empty or invalid');
|
|
447
|
+
}
|
|
448
|
+
preparedSource = source;
|
|
449
|
+
return source;
|
|
450
|
+
}
|
|
402
451
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
452
|
+
if (params.artifact) {
|
|
453
|
+
const source = await openFirmwareByteSource({
|
|
454
|
+
artifact: params.artifact,
|
|
455
|
+
reader: params.artifactReader,
|
|
456
|
+
});
|
|
457
|
+
if (!source) {
|
|
458
|
+
throw new Error('firmware artifact is not prepared');
|
|
459
|
+
}
|
|
460
|
+
preparedSource = source;
|
|
461
|
+
return source;
|
|
462
|
+
}
|
|
409
463
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
features,
|
|
415
|
-
forcedUpdateRes: params.forcedUpdateRes,
|
|
416
|
-
firmwareType,
|
|
417
|
-
});
|
|
418
|
-
if (resourceUrl) {
|
|
419
|
-
this.postTipMessage('DownloadLatestUiResource');
|
|
420
|
-
const resource = await getSysResourceBinary(resourceUrl);
|
|
421
|
-
this.postTipMessage('DownloadLatestUiResourceSuccess');
|
|
422
|
-
if (resource) {
|
|
423
|
-
await updateResources(
|
|
424
|
-
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
425
|
-
this.postMessage,
|
|
426
|
-
device,
|
|
427
|
-
resource.binary
|
|
464
|
+
if (!device.features) {
|
|
465
|
+
throw ERRORS.TypedError(
|
|
466
|
+
HardwareErrorCode.RuntimeError,
|
|
467
|
+
'no features found for this device'
|
|
428
468
|
);
|
|
429
469
|
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
470
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
471
|
+
if (
|
|
472
|
+
params.artifactReader ||
|
|
473
|
+
DataManager.getSettings('firmwareManifestMode') === 'external-only'
|
|
474
|
+
) {
|
|
475
|
+
throw ERRORS.TypedError(
|
|
476
|
+
HardwareErrorCode.RuntimeError,
|
|
477
|
+
'Firmware must be prepared by the external firmware host',
|
|
478
|
+
{
|
|
479
|
+
firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
|
|
480
|
+
artifactName: 'firmware',
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
}
|
|
438
484
|
|
|
439
|
-
|
|
440
|
-
|
|
485
|
+
this.postTipMessage('DownloadFirmware');
|
|
486
|
+
const firmware = await getBinary({
|
|
487
|
+
features: device.features,
|
|
488
|
+
version: params.version,
|
|
489
|
+
updateType: params.updateType,
|
|
490
|
+
isUpdateBootloader: params.isUpdateBootloader,
|
|
491
|
+
firmwareType,
|
|
492
|
+
requestOptions: FIRMWARE_DOWNLOAD_REQUEST_OPTIONS,
|
|
493
|
+
});
|
|
494
|
+
const binary = normalizeFirmwareBinary(firmware.binary);
|
|
495
|
+
if (!binary) {
|
|
496
|
+
throw new Error('downloaded firmware binary is empty or invalid');
|
|
497
|
+
}
|
|
498
|
+
const source = await openFirmwareByteSource({
|
|
499
|
+
binary: toArrayBuffer(binary),
|
|
500
|
+
});
|
|
501
|
+
if (!source) {
|
|
502
|
+
throw new Error('downloaded firmware binary is empty or invalid');
|
|
503
|
+
}
|
|
504
|
+
preparedSource = source;
|
|
505
|
+
this.postTipMessage('DownloadFirmwareSuccess');
|
|
506
|
+
return source;
|
|
507
|
+
} catch (err) {
|
|
508
|
+
throw ERRORS.TypedError(
|
|
509
|
+
HardwareErrorCode.FirmwareUpdateDownloadFailed,
|
|
510
|
+
err.message ?? err
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
441
514
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
if (bootRes.type === 'CallMethodError') {
|
|
448
|
-
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
515
|
+
if (!device.isBootloader() && features) {
|
|
516
|
+
const serialNo = device.getCurrentSerialNo();
|
|
517
|
+
// should go to bootloader mode manually
|
|
518
|
+
if (this.isEnteredManuallyBoot()) {
|
|
519
|
+
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateManuallyEnterBoot);
|
|
449
520
|
}
|
|
450
|
-
this.postTipMessage('GoToBootloaderSuccess');
|
|
451
|
-
this.checkDeviceToBootloader(this.payload.connectId);
|
|
452
521
|
|
|
453
|
-
//
|
|
454
|
-
|
|
455
|
-
|
|
522
|
+
// All network-backed input must be ready before the first device mutation.
|
|
523
|
+
await acquireFirmwareSource();
|
|
524
|
+
|
|
525
|
+
// check & upgrade firmware resource
|
|
526
|
+
if (this.isSupportResourceUpdate(params.updateType)) {
|
|
527
|
+
this.postTipMessage('CheckLatestUiResource');
|
|
528
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
529
|
+
features,
|
|
530
|
+
forcedUpdateRes: params.forcedUpdateRes,
|
|
531
|
+
firmwareType,
|
|
532
|
+
});
|
|
533
|
+
if (resourceUrl) {
|
|
534
|
+
this.postTipMessage('DownloadLatestUiResource');
|
|
535
|
+
if (params.resourceEntries?.length) {
|
|
536
|
+
const sources: Array<{
|
|
537
|
+
entryName: string;
|
|
538
|
+
source: FirmwareByteSource;
|
|
539
|
+
}> = [];
|
|
540
|
+
try {
|
|
541
|
+
for (const entry of params.resourceEntries) {
|
|
542
|
+
const resourceName = getFirmwareUpdateResourceName(entry.entryName);
|
|
543
|
+
const source = await openFirmwareByteSource({
|
|
544
|
+
artifact: entry.artifact,
|
|
545
|
+
reader: params.artifactReader,
|
|
546
|
+
});
|
|
547
|
+
if (!source) {
|
|
548
|
+
throw new Error('Firmware resource entry is not prepared');
|
|
549
|
+
}
|
|
550
|
+
sources.push({ entryName: resourceName, source });
|
|
551
|
+
}
|
|
552
|
+
await checkpointWriter.commit({
|
|
553
|
+
stage: 'FILE_TRANSFER_STARTED',
|
|
554
|
+
target: 'resource',
|
|
555
|
+
});
|
|
556
|
+
await updateResourcesFromSources(
|
|
557
|
+
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
558
|
+
this.postMessage,
|
|
559
|
+
device,
|
|
560
|
+
sources.map(entry => ({
|
|
561
|
+
entryName: entry.entryName,
|
|
562
|
+
source: entry.source,
|
|
563
|
+
}))
|
|
564
|
+
);
|
|
565
|
+
await checkpointWriter.commit({
|
|
566
|
+
stage: 'FILE_TRANSFER_COMPLETED',
|
|
567
|
+
target: 'resource',
|
|
568
|
+
});
|
|
569
|
+
} finally {
|
|
570
|
+
await Promise.all(
|
|
571
|
+
sources.map(entry => entry.source.close().catch(() => undefined))
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
this.postTipMessage('DownloadLatestUiResourceSuccess');
|
|
575
|
+
} else {
|
|
576
|
+
let resourceBinary: ArrayBuffer | Buffer;
|
|
577
|
+
if (params.resourceArtifact) {
|
|
578
|
+
throw ERRORS.TypedError(
|
|
579
|
+
HardwareErrorCode.RuntimeError,
|
|
580
|
+
'Firmware resource archive must be materialized into prepared entries',
|
|
581
|
+
{
|
|
582
|
+
firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
|
|
583
|
+
artifactName: 'resource',
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
} else {
|
|
587
|
+
if (
|
|
588
|
+
params.artifactReader ||
|
|
589
|
+
DataManager.getSettings('firmwareManifestMode') === 'external-only'
|
|
590
|
+
) {
|
|
591
|
+
throw ERRORS.TypedError(
|
|
592
|
+
HardwareErrorCode.RuntimeError,
|
|
593
|
+
'Firmware resource must be prepared by the external firmware host',
|
|
594
|
+
{
|
|
595
|
+
firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
|
|
596
|
+
artifactName: 'resource',
|
|
597
|
+
}
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
resourceBinary = (await getSysResourceBinary(resourceUrl)).binary;
|
|
601
|
+
}
|
|
602
|
+
this.postTipMessage('DownloadLatestUiResourceSuccess');
|
|
603
|
+
await checkpointWriter.commit({
|
|
604
|
+
stage: 'FILE_TRANSFER_STARTED',
|
|
605
|
+
target: 'resource',
|
|
606
|
+
});
|
|
607
|
+
await updateResources(
|
|
608
|
+
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
609
|
+
this.postMessage,
|
|
610
|
+
device,
|
|
611
|
+
resourceBinary
|
|
612
|
+
);
|
|
613
|
+
await checkpointWriter.commit({
|
|
614
|
+
stage: 'FILE_TRANSFER_COMPLETED',
|
|
615
|
+
target: 'resource',
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
456
619
|
}
|
|
457
|
-
delete DevicePool.devicesCache[''];
|
|
458
|
-
await this.checkPromise?.promise;
|
|
459
|
-
this.checkPromise = null;
|
|
460
620
|
|
|
461
621
|
// check if the device commands has been disposed
|
|
462
622
|
this.device?.commands?.checkDisposed();
|
|
463
623
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
624
|
+
// The request may outlive the current transport command instance.
|
|
625
|
+
this.device?.commands?.checkDisposed();
|
|
626
|
+
|
|
627
|
+
// auto go to bootloader mode
|
|
628
|
+
try {
|
|
629
|
+
this.postTipMessage('AutoRebootToBootloader');
|
|
630
|
+
await checkpointWriter.commit({
|
|
631
|
+
stage: 'BEFORE_DEVICE_MODE_CHANGE',
|
|
632
|
+
target: params.isUpdateBootloader ? 'bootloader' : params.updateType,
|
|
633
|
+
});
|
|
634
|
+
const bootRes = await commands.typedCall('DeviceBackToBoot', 'Success');
|
|
635
|
+
// @ts-expect-error
|
|
636
|
+
if (bootRes.type === 'CallMethodError') {
|
|
637
|
+
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
638
|
+
}
|
|
639
|
+
this.postTipMessage('GoToBootloaderSuccess');
|
|
640
|
+
this.checkDeviceToBootloader(this.payload.connectId);
|
|
641
|
+
|
|
642
|
+
// force clean classic device cache so that the device can initialize again
|
|
643
|
+
if (DeviceModelToTypes.model_classic.includes(deviceType)) {
|
|
644
|
+
DevicePool.clearDeviceCache(serialNo);
|
|
645
|
+
}
|
|
646
|
+
delete DevicePool.devicesCache[''];
|
|
647
|
+
await this.checkPromise?.promise;
|
|
648
|
+
this.checkPromise = null;
|
|
649
|
+
|
|
650
|
+
// check if the device commands has been disposed
|
|
651
|
+
this.device?.commands?.checkDisposed();
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Touch 1 with bootloader v2.5.0 issue: BLE chip need more time for looking up name, here change the delay time to 3000ms after rebooting.
|
|
655
|
+
*/
|
|
656
|
+
const isTouch = DeviceModelToTypes.model_touch.includes(deviceType);
|
|
657
|
+
await wait(isTouch ? 3000 : 1500);
|
|
658
|
+
} catch (e) {
|
|
659
|
+
if (e instanceof HardwareError) {
|
|
660
|
+
return Promise.reject(e);
|
|
661
|
+
}
|
|
662
|
+
console.log('auto go to bootloader mode failed: ', e);
|
|
663
|
+
return Promise.reject(
|
|
664
|
+
ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure)
|
|
665
|
+
);
|
|
472
666
|
}
|
|
473
|
-
console.log('auto go to bootloader mode failed: ', e);
|
|
474
|
-
return Promise.reject(
|
|
475
|
-
ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure)
|
|
476
|
-
);
|
|
477
667
|
}
|
|
478
|
-
}
|
|
479
668
|
|
|
480
|
-
|
|
481
|
-
|
|
669
|
+
// Devices already in bootloader mode still acquire through the same helper.
|
|
670
|
+
const source = await acquireFirmwareSource();
|
|
482
671
|
|
|
483
|
-
|
|
484
|
-
|
|
672
|
+
// check if the device commands has been disposed
|
|
673
|
+
this.device?.commands?.checkDisposed();
|
|
485
674
|
|
|
486
|
-
|
|
675
|
+
await this.device.acquire();
|
|
676
|
+
|
|
677
|
+
const target = params.isUpdateBootloader ? 'bootloader' : params.updateType;
|
|
678
|
+
await checkpointWriter.commit({
|
|
679
|
+
stage: 'FILE_TRANSFER_STARTED',
|
|
680
|
+
target,
|
|
681
|
+
});
|
|
682
|
+
const response = await uploadFirmwareFromSource(
|
|
683
|
+
params.updateType,
|
|
684
|
+
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
685
|
+
this.postMessage,
|
|
686
|
+
device,
|
|
687
|
+
source,
|
|
688
|
+
true,
|
|
689
|
+
params.isUpdateBootloader
|
|
690
|
+
);
|
|
691
|
+
await checkpointWriter.commit({
|
|
692
|
+
stage: 'FILE_TRANSFER_COMPLETED',
|
|
693
|
+
target,
|
|
694
|
+
});
|
|
487
695
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
this.postMessage,
|
|
492
|
-
device,
|
|
493
|
-
{ payload: binary, rebootOnSuccess: true },
|
|
494
|
-
params.isUpdateBootloader
|
|
495
|
-
);
|
|
696
|
+
if (this.connectId) {
|
|
697
|
+
DevicePool.clearDeviceCache(this.connectId);
|
|
698
|
+
}
|
|
496
699
|
|
|
497
|
-
|
|
498
|
-
|
|
700
|
+
await checkpointWriter.commit({
|
|
701
|
+
stage: 'FINAL_VERIFIED',
|
|
702
|
+
target,
|
|
703
|
+
});
|
|
704
|
+
return response;
|
|
705
|
+
} finally {
|
|
706
|
+
await preparedSource?.close().catch(() => undefined);
|
|
499
707
|
}
|
|
500
|
-
|
|
501
|
-
return response;
|
|
502
708
|
}
|
|
503
709
|
}
|