@onekeyfe/hd-core 1.2.0-alpha.1 → 1.2.0-alpha.100
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 +830 -0
- package/__tests__/check-firmware-release-protocol-v2.test.ts +270 -0
- package/__tests__/connectSettings.test.ts +59 -0
- 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 +478 -0
- 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 +126 -0
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/device-update-bootloader.test.ts +109 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +171 -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 +583 -0
- package/__tests__/firmware-update/firmware-prepared-resource-archive.test.ts +150 -0
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +375 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +474 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +815 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +283 -0
- package/__tests__/firmware-update/firmware-update-prepared-resource-executors.test.ts +326 -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-update-v4-parameters.test.ts +85 -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__/preInitialize.test.ts +33 -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 +124 -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 +8346 -1866
- 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 +9 -0
- package/dist/api/ClearSessionCache.d.ts.map +1 -0
- 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 +13 -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 +63 -6
- 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 +29 -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/FirmwarePreparedResourceArchive.d.ts +11 -0
- package/dist/api/firmware/FirmwarePreparedResourceArchive.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +12 -2
- 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 +38 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +17 -3
- 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 -29
- 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 +7 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +8 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +2 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +4 -2
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +29 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
- 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 +7 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
- 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 +7 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
- 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 +7 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +27 -18
- 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 +2 -5
- 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 -2
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +2 -2
- 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 +12 -4
- 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 +75 -17
- 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 +27 -0
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -0
- package/dist/device/cloneDeviceState.d.ts +2 -0
- package/dist/device/cloneDeviceState.d.ts.map +1 -0
- package/dist/device/deviceIdentity.d.ts +5 -0
- package/dist/device/deviceIdentity.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +9 -3
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/deviceProfile/index.d.ts +0 -1
- package/dist/deviceProfile/index.d.ts.map +1 -1
- package/dist/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 +1792 -750
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12615 -4679
- 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 +30 -28
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +11 -9
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +3 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/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 +27 -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 +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 +68 -6
- 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 +31 -35
- 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 +17 -88
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/api/sessionCache.d.ts +13 -0
- package/dist/types/api/sessionCache.d.ts.map +1 -0
- package/dist/types/device.d.ts +143 -10
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +2 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +71 -9
- 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 +12 -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 +442 -4
- package/src/api/CheckBLEFirmwareRelease.ts +37 -5
- package/src/api/CheckBootloaderRelease.ts +37 -5
- package/src/api/CheckFirmwareRelease.ts +36 -9
- package/src/api/CipherKeyValue.ts +4 -0
- package/src/api/ClearSessionCache.ts +32 -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 +27 -8
- package/src/api/FileWrite.ts +26 -168
- package/src/api/FirmwareUpdate.ts +30 -15
- package/src/api/FirmwareUpdateV2.ts +532 -169
- package/src/api/FirmwareUpdateV3.ts +320 -72
- package/src/api/FirmwareUpdateV4.ts +2691 -428
- 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 -18
- 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 +9 -4
- package/src/api/device/DeviceRebootToBootloader.ts +9 -4
- 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 +152 -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 +305 -0
- package/src/api/firmware/FirmwareHostBinding.ts +123 -0
- package/src/api/firmware/FirmwareMemoryHost.ts +143 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwarePreparedResourceArchive.ts +187 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +216 -65
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +945 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +486 -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 -30
- 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/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +8 -5
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +35 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +11 -10
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +45 -7
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +10 -5
- package/src/api/protocol-v2/DeviceInfoGet.ts +141 -0
- package/src/api/protocol-v2/DeviceReboot.ts +8 -4
- package/src/api/protocol-v2/DeviceStatusGet.ts +19 -0
- 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 +9 -3
- package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +7 -4
- package/src/api/protocol-v2/Ping.ts +37 -3
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +21 -0
- package/src/api/protocol-v2/helpers.ts +71 -50
- 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 +6 -6
- 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 -9
- package/src/api/tron/TronSignTransaction.ts +5 -2
- 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 +400 -157
- package/src/core/uiPromiseRegistry.ts +63 -0
- package/src/data/messages/messages-protocol-v2.json +904 -791
- package/src/data/messages/messages.json +286 -1
- package/src/data-manager/DataManager.ts +158 -40
- package/src/data-manager/TransportManager.ts +7 -1
- package/src/data-manager/connectSettings.ts +13 -4
- package/src/device/Device.ts +909 -296
- 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 +144 -0
- package/src/device/cloneDeviceState.ts +39 -0
- package/src/device/deviceIdentity.ts +18 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +243 -212
- 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 +93 -49
- package/src/lowLevelInject.ts +11 -4
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +113 -83
- package/src/protocols/protocol-v2/firmware.ts +14 -36
- package/src/protocols/protocol-v2/index.ts +8 -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 +463 -0
- 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 +7 -0
- package/src/types/api/export.ts +33 -1
- package/src/types/api/firmwareUpdate.ts +101 -19
- 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 +50 -72
- package/src/types/api/kaspaSignTransaction.ts +60 -4
- package/src/types/api/openWalletSession.ts +54 -0
- package/src/types/api/protocolV2.ts +31 -157
- package/src/types/api/sessionCache.ts +19 -0
- package/src/types/device.ts +217 -10
- package/src/types/params.ts +12 -1
- package/src/types/settings.ts +91 -42
- package/src/utils/assets.ts +4 -1
- package/src/utils/deviceFeaturesCompat.ts +191 -0
- package/src/utils/deviceFeaturesUtils.ts +85 -26
- 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/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +0 -29
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +0 -6
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts +0 -21
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +0 -1
- package/dist/types/api/getDeviceInfo.d.ts +0 -85
- package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
- package/src/api/GetDeviceInfo.ts +0 -145
- package/src/api/protocol-v2/DevReboot.ts +0 -24
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +0 -118
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
- package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
- package/src/api/protocol-v2/GetProtoVersion.ts +0 -16
- package/src/deviceProfile/buildDeviceProfile.ts +0 -333
- package/src/types/api/getDeviceInfo.ts +0 -99
package/src/core/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
|
+
import { DeviceSessionPinType, TRANSPORT_EVENT } from '@onekeyfe/hd-transport';
|
|
3
4
|
import {
|
|
4
5
|
ERRORS,
|
|
6
|
+
ERROR_CODES_REQUIRE_DISCONNECT,
|
|
5
7
|
ERROR_CODES_REQUIRE_RELEASE,
|
|
6
8
|
HardwareError,
|
|
7
9
|
HardwareErrorCode,
|
|
@@ -14,14 +16,7 @@ import {
|
|
|
14
16
|
createNewFirmwareUnReleaseHardwareError,
|
|
15
17
|
} from '@onekeyfe/hd-shared';
|
|
16
18
|
|
|
17
|
-
import {
|
|
18
|
-
LoggerNames,
|
|
19
|
-
enableLog,
|
|
20
|
-
getLogger,
|
|
21
|
-
isMethodVersionRangeUnsupported,
|
|
22
|
-
setLoggerPostMessage,
|
|
23
|
-
wait,
|
|
24
|
-
} from '../utils';
|
|
19
|
+
import { LoggerNames, enableLog, getLogger, setLoggerPostMessage, wait } from '../utils';
|
|
25
20
|
import {
|
|
26
21
|
findDefectiveBatchDevice,
|
|
27
22
|
getDefectiveDeviceInfo,
|
|
@@ -32,10 +27,12 @@ import {
|
|
|
32
27
|
createRequestContext,
|
|
33
28
|
createSdkTracingContext,
|
|
34
29
|
formatRequestContext,
|
|
30
|
+
generateInstanceId,
|
|
35
31
|
getActiveRequestsByDeviceInstance,
|
|
36
32
|
updateRequestContext,
|
|
37
33
|
} from '../utils/tracing';
|
|
38
34
|
import { Device } from '../device/Device';
|
|
35
|
+
import { checkLiveDeviceId } from '../device/deviceIdentity';
|
|
39
36
|
import { DeviceList } from '../device/DeviceList';
|
|
40
37
|
import { DevicePool } from '../device/DevicePool';
|
|
41
38
|
import { PollingStateManager } from './PollingStateManager';
|
|
@@ -51,19 +48,33 @@ import {
|
|
|
51
48
|
createDeviceMessage,
|
|
52
49
|
createResponseMessage,
|
|
53
50
|
createUiMessage,
|
|
51
|
+
formatLogMethodLabel,
|
|
52
|
+
getLogBlockLabel,
|
|
53
|
+
getSafeLogPayload,
|
|
54
54
|
} from '../events';
|
|
55
55
|
import TransportManager from '../data-manager/TransportManager';
|
|
56
56
|
import DeviceConnector from '../device/DeviceConnector';
|
|
57
57
|
import RequestQueue from './RequestQueue';
|
|
58
|
+
import { consumeUiPromise, findUiPromiseForResponse, rejectUiPromises } from './uiPromiseRegistry';
|
|
59
|
+
import { registerHardwareUiEventListeners } from './deviceEventRegistration';
|
|
58
60
|
import { getSynchronize } from '../utils/getSynchronize';
|
|
59
|
-
import {
|
|
61
|
+
import { runMethodWithUnlockPolicy } from '../protocols/protocol-v2/unlockPolicyRunner';
|
|
62
|
+
import {
|
|
63
|
+
ProtocolV2UiInteractionCoordinator,
|
|
64
|
+
isProtocolV2UiEnabled,
|
|
65
|
+
} from '../protocols/protocol-v2/uiInteraction';
|
|
66
|
+
import { createUiProgressMessageFilter } from '../utils/uiProgressThrottle';
|
|
60
67
|
|
|
61
68
|
import type { ConnectSettings, Features, KnownDevice } from '../types';
|
|
62
69
|
import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
|
|
63
70
|
import type { DeviceEvents, InitOptions, RunOptions } from '../device/Device';
|
|
64
71
|
import type { SdkTracingContext } from '../utils/tracing';
|
|
65
72
|
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
66
|
-
import type {
|
|
73
|
+
import type {
|
|
74
|
+
LowlevelTransportSharedPlugin,
|
|
75
|
+
OneKeyDeviceInfo,
|
|
76
|
+
TransportDeviceDisconnectEvent,
|
|
77
|
+
} from '@onekeyfe/hd-transport';
|
|
67
78
|
import type { BaseMethod } from '../api/BaseMethod';
|
|
68
79
|
|
|
69
80
|
const Log = getLogger(LoggerNames.Core);
|
|
@@ -92,13 +103,15 @@ function hasDeriveCardano(method: BaseMethod): boolean {
|
|
|
92
103
|
|
|
93
104
|
const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
94
105
|
initSession: method?.payload.initSession,
|
|
95
|
-
passphraseState: method?.payload.passphraseState,
|
|
106
|
+
passphraseState: method?.payload.useEmptyPassphrase ? undefined : method?.payload.passphraseState,
|
|
96
107
|
deviceId: method?.payload.deviceId,
|
|
97
108
|
deriveCardano: method && hasDeriveCardano(method),
|
|
98
109
|
connectProtocol: method?.payload.connectProtocol,
|
|
110
|
+
forceProtocolDetection: method?.payload.forceProtocolDetection,
|
|
111
|
+
protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
|
|
99
112
|
});
|
|
100
113
|
|
|
101
|
-
let _core: Core;
|
|
114
|
+
let _core: Core | undefined;
|
|
102
115
|
let _deviceList: DeviceList | undefined;
|
|
103
116
|
let _connector: DeviceConnector | undefined;
|
|
104
117
|
let _uiPromises: UiPromise<UiPromiseResponse['type']>[] = []; // Waiting for ui response
|
|
@@ -142,11 +155,16 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
142
155
|
}
|
|
143
156
|
|
|
144
157
|
// find api method
|
|
145
|
-
let method
|
|
158
|
+
let method!: BaseMethod;
|
|
146
159
|
try {
|
|
147
160
|
method = findMethod(message as IFrameCallMessage);
|
|
148
161
|
method.connector = _connector;
|
|
149
|
-
|
|
162
|
+
const shouldPostMessage = createUiProgressMessageFilter();
|
|
163
|
+
method.postMessage = event => {
|
|
164
|
+
if (shouldPostMessage(event)) {
|
|
165
|
+
postMessage(event);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
150
168
|
method.setContext?.(context);
|
|
151
169
|
|
|
152
170
|
method.requestContext = createRequestContext(method.responseID, method.name, {
|
|
@@ -158,11 +176,13 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
158
176
|
|
|
159
177
|
method.init();
|
|
160
178
|
} catch (error) {
|
|
161
|
-
|
|
179
|
+
if (method) {
|
|
180
|
+
completeMethodRequestContext(method, error);
|
|
181
|
+
method.dispose();
|
|
182
|
+
}
|
|
183
|
+
return createResponseMessage(method?.responseID ?? message.id, false, { error });
|
|
162
184
|
}
|
|
163
185
|
|
|
164
|
-
DevicePool.emitter.on(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
165
|
-
|
|
166
186
|
if (!method.useDevice) {
|
|
167
187
|
updateMethodRequestContext(method, { status: 'running' });
|
|
168
188
|
try {
|
|
@@ -223,9 +243,15 @@ const handlePreWarmSignal = async (
|
|
|
223
243
|
message: CoreMessage,
|
|
224
244
|
method: BaseMethod
|
|
225
245
|
): Promise<any> => {
|
|
246
|
+
const createAckResponse = () => {
|
|
247
|
+
completeMethodRequestContext(method);
|
|
248
|
+
method.dispose();
|
|
249
|
+
return createResponseMessage(method.responseID, true, true);
|
|
250
|
+
};
|
|
251
|
+
|
|
226
252
|
// no connectId: can't target a device safely, skip pre-warm (ack only)
|
|
227
253
|
if (!method.connectId) {
|
|
228
|
-
return
|
|
254
|
+
return createAckResponse();
|
|
229
255
|
}
|
|
230
256
|
|
|
231
257
|
const key = method.getPreWarmKey();
|
|
@@ -238,12 +264,12 @@ const handlePreWarmSignal = async (
|
|
|
238
264
|
} catch {
|
|
239
265
|
// pre-warm is best-effort; ignore its failure for the coalesced caller
|
|
240
266
|
}
|
|
241
|
-
return
|
|
267
|
+
return createAckResponse();
|
|
242
268
|
}
|
|
243
269
|
|
|
244
270
|
const doneAt = preWarmDoneAt.get(key);
|
|
245
271
|
if (typeof doneAt === 'number' && Date.now() - doneAt <= method.preWarmTtl) {
|
|
246
|
-
return
|
|
272
|
+
return createAckResponse();
|
|
247
273
|
}
|
|
248
274
|
|
|
249
275
|
const run = onCallDevice(context, message, method);
|
|
@@ -351,7 +377,7 @@ const onCallDevice = async (
|
|
|
351
377
|
);
|
|
352
378
|
} catch (e) {
|
|
353
379
|
preWarmCallbackTask?.resolve();
|
|
354
|
-
|
|
380
|
+
Log.debug('ensureConnected error: ', e);
|
|
355
381
|
|
|
356
382
|
completeMethodRequestContext(method, e);
|
|
357
383
|
|
|
@@ -388,18 +414,28 @@ const onCallDevice = async (
|
|
|
388
414
|
);
|
|
389
415
|
}
|
|
390
416
|
|
|
391
|
-
device
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
417
|
+
registerHardwareUiEventListeners(device, {
|
|
418
|
+
pin: onDevicePinHandler,
|
|
419
|
+
pinOnDevice: onEnterPinOnDeviceHandler,
|
|
420
|
+
pinOnDeviceComplete: onPinOnDeviceCompleteHandler,
|
|
421
|
+
button: onDeviceButtonHandler,
|
|
422
|
+
passphrase: message.payload.useEmptyPassphrase
|
|
423
|
+
? onEmptyPassphraseHandler
|
|
424
|
+
: onDevicePassphraseHandler,
|
|
425
|
+
passphraseOnDevice: onEnterPassphraseOnDeviceHandler,
|
|
426
|
+
attachPinOnDevice: onEnterAttachPinOnDeviceHandler,
|
|
427
|
+
});
|
|
398
428
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
429
|
+
device.on(DEVICE.STATE, onDeviceStateHandler);
|
|
399
430
|
device.on(
|
|
400
431
|
DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE,
|
|
401
432
|
onSelectDeviceInBootloaderForWebDeviceHandler
|
|
402
433
|
);
|
|
434
|
+
|
|
435
|
+
const protocolV2UiCoordinator = new ProtocolV2UiInteractionCoordinator(device, postMessage);
|
|
436
|
+
let protocolV2Operation = false;
|
|
437
|
+
let protocolV2CloseEmitted = false;
|
|
438
|
+
device.beginProtocolV2UiInteraction();
|
|
403
439
|
device.on(
|
|
404
440
|
DEVICE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE,
|
|
405
441
|
onSelectDeviceForSwitchFirmwareWebDeviceHandler
|
|
@@ -414,11 +450,10 @@ const onCallDevice = async (
|
|
|
414
450
|
await waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
415
451
|
|
|
416
452
|
const inner = async (): Promise<void> => {
|
|
417
|
-
// Protocol
|
|
418
|
-
//
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
453
|
+
// Protocol is established from an active device response during acquire/initialize.
|
|
454
|
+
// Reject unsupported methods before any method-specific device command is sent.
|
|
455
|
+
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
456
|
+
protocolV2Operation = device.isProtocolV2();
|
|
422
457
|
|
|
423
458
|
// check firmware version
|
|
424
459
|
const versionRange = device.getCurrentMethodVersionRange(
|
|
@@ -429,8 +464,8 @@ const onCallDevice = async (
|
|
|
429
464
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
430
465
|
let newVersionStatus: ReturnType<typeof DataManager.getFirmwareStatus> | undefined;
|
|
431
466
|
|
|
432
|
-
//
|
|
433
|
-
// Pro2
|
|
467
|
+
// Defective-batch and forced-update gates depend on V1 features/remote config.
|
|
468
|
+
// Pro2 joins after DataManager supports its profile firmwareStatus.
|
|
434
469
|
if (device.features && !device.isProtocolV2()) {
|
|
435
470
|
await DataManager.checkAndReloadData();
|
|
436
471
|
|
|
@@ -478,10 +513,6 @@ const onCallDevice = async (
|
|
|
478
513
|
}
|
|
479
514
|
}
|
|
480
515
|
|
|
481
|
-
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
482
|
-
throw createDeviceNotSupportMethodError(method.name, deviceFirmwareType);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
516
|
if (versionRange) {
|
|
486
517
|
if (semver.valid(versionRange.min) && semver.lt(currentFirmwareVersion, versionRange.min)) {
|
|
487
518
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
@@ -532,89 +563,102 @@ const onCallDevice = async (
|
|
|
532
563
|
);
|
|
533
564
|
}
|
|
534
565
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
566
|
+
try {
|
|
567
|
+
let deviceIdCheckedDuringUnlockPreflight = false;
|
|
568
|
+
const response = await runMethodWithUnlockPolicy<object>(method, device, {
|
|
569
|
+
uiCoordinator: protocolV2UiCoordinator,
|
|
570
|
+
afterStatusBeforeUnlock: () => {
|
|
571
|
+
if (method.deviceId && method.checkDeviceId) {
|
|
572
|
+
if (!device.checkDeviceId(method.deviceId)) {
|
|
573
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
574
|
+
}
|
|
575
|
+
deviceIdCheckedDuringUnlockPreflight = true;
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
prepare: async () => {
|
|
579
|
+
if (method.deviceId && method.checkDeviceId && !deviceIdCheckedDuringUnlockPreflight) {
|
|
580
|
+
const isSameDeviceID = await checkLiveDeviceId(device, method.deviceId);
|
|
581
|
+
if (!isSameDeviceID) {
|
|
582
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
546
585
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
586
|
+
/**
|
|
587
|
+
* check firmware release info
|
|
588
|
+
*/
|
|
589
|
+
method.checkFirmwareRelease();
|
|
551
590
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
591
|
+
/**
|
|
592
|
+
* check additional supported feature
|
|
593
|
+
*/
|
|
594
|
+
method.checkDeviceSupportFeature();
|
|
556
595
|
|
|
557
|
-
|
|
558
|
-
|
|
596
|
+
// reconfigure messages
|
|
597
|
+
if (_deviceList && device.features && !device.isProtocolV2()) {
|
|
598
|
+
await TransportManager.reconfigure(device.features);
|
|
599
|
+
}
|
|
559
600
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
601
|
+
// Check to see if it is safe to use Passphrase
|
|
602
|
+
checkPassphraseEnableState(method, device.features);
|
|
603
|
+
|
|
604
|
+
if (shouldCheckPassphraseState(method, device)) {
|
|
605
|
+
// check version
|
|
606
|
+
const support = device.supportNewPassphrase();
|
|
607
|
+
if (!support.support) {
|
|
608
|
+
throw ERRORS.TypedError(
|
|
609
|
+
HardwareErrorCode.DeviceNotSupportPassphrase,
|
|
610
|
+
`Device not support passphrase, please update to ${support.require}`,
|
|
611
|
+
{
|
|
612
|
+
require: support.require,
|
|
613
|
+
}
|
|
614
|
+
);
|
|
570
615
|
}
|
|
571
|
-
)
|
|
572
|
-
);
|
|
573
|
-
}
|
|
574
616
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
617
|
+
// Check Device passphrase State after the Protocol V2 pre-unlock gate.
|
|
618
|
+
const passphraseStateSafety = await device.checkPassphraseStateSafety(
|
|
619
|
+
method.payload?.passphraseState,
|
|
620
|
+
method.payload?.useEmptyPassphrase,
|
|
621
|
+
method.payload?.skipPassphraseCheck,
|
|
622
|
+
hasDeriveCardano(method)
|
|
623
|
+
);
|
|
581
624
|
|
|
582
|
-
|
|
583
|
-
|
|
625
|
+
// Double check, handles the special case of Touch/Pro
|
|
626
|
+
checkPassphraseEnableState(method, device.features);
|
|
584
627
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// close pin popup window
|
|
593
|
-
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW));
|
|
594
|
-
}
|
|
628
|
+
if (!passphraseStateSafety) {
|
|
629
|
+
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
630
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
631
|
+
}
|
|
595
632
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
? e
|
|
603
|
-
: ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
604
|
-
// messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
605
|
-
// requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
606
|
-
// return;
|
|
607
|
-
throw error;
|
|
608
|
-
}
|
|
633
|
+
// Protocol V2 emits the PIN phase completion from DeviceSessionAskPin.
|
|
634
|
+
// Keep the legacy compatibility close for Protocol V1 only.
|
|
635
|
+
if (!device.isProtocolV2()) {
|
|
636
|
+
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW));
|
|
637
|
+
}
|
|
638
|
+
}
|
|
609
639
|
|
|
610
|
-
|
|
640
|
+
// Automatic check safety_check level for Kovan, Ropsten, Rinkeby, Goerli test networks.
|
|
641
|
+
try {
|
|
642
|
+
await method.checkSafetyLevelOnTestNet();
|
|
643
|
+
} catch (e) {
|
|
644
|
+
throw e instanceof HardwareError
|
|
645
|
+
? e
|
|
646
|
+
: ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
647
|
+
}
|
|
611
648
|
|
|
612
|
-
|
|
613
|
-
|
|
649
|
+
method.device?.commands?.checkDisposed();
|
|
650
|
+
},
|
|
651
|
+
});
|
|
614
652
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
615
653
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
616
654
|
completeMethodRequestContext(method);
|
|
617
655
|
} catch (error) {
|
|
656
|
+
// Device.run may release the request before transport callbacks finish after a timeout.
|
|
657
|
+
// Ignore the stale callback because the caller already received the connection error.
|
|
658
|
+
if (!requestQueue.getTask(method.responseID)) {
|
|
659
|
+
Log.debug(`Call API - Ignore late inner method result`, error);
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
618
662
|
Log.debug(`Call API - Inner Method Run Error`, error);
|
|
619
663
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
620
664
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
@@ -627,6 +671,13 @@ const onCallDevice = async (
|
|
|
627
671
|
) {
|
|
628
672
|
throw error;
|
|
629
673
|
}
|
|
674
|
+
} finally {
|
|
675
|
+
if (isProtocolV2UiEnabled(method)) {
|
|
676
|
+
protocolV2CloseEmitted = protocolV2UiCoordinator.close({
|
|
677
|
+
ensureOperationClose: protocolV2Operation,
|
|
678
|
+
protocolV2Operation,
|
|
679
|
+
});
|
|
680
|
+
}
|
|
630
681
|
}
|
|
631
682
|
};
|
|
632
683
|
Log.debug('Call API - Device Run: ', device.mainId);
|
|
@@ -680,7 +731,17 @@ const onCallDevice = async (
|
|
|
680
731
|
|
|
681
732
|
requestQueue.releaseTask(method.responseID);
|
|
682
733
|
|
|
683
|
-
|
|
734
|
+
if (isProtocolV2UiEnabled(method)) {
|
|
735
|
+
if (!protocolV2CloseEmitted && protocolV2Operation) {
|
|
736
|
+
protocolV2CloseEmitted = protocolV2UiCoordinator.close({
|
|
737
|
+
ensureOperationClose: true,
|
|
738
|
+
protocolV2Operation: true,
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
if (!protocolV2CloseEmitted) {
|
|
742
|
+
closePopup();
|
|
743
|
+
}
|
|
744
|
+
}
|
|
684
745
|
|
|
685
746
|
cleanup();
|
|
686
747
|
|
|
@@ -732,6 +793,15 @@ function initDevice(method: BaseMethod) {
|
|
|
732
793
|
|
|
733
794
|
if (method.connectId) {
|
|
734
795
|
device = _deviceList.getDevice(method.connectId);
|
|
796
|
+
if (!device && method.name === 'firmwareUpdateV4' && allDevices.length === 1) {
|
|
797
|
+
const [singleDevice] = allDevices;
|
|
798
|
+
if (singleDevice.isBootloader()) {
|
|
799
|
+
Log.debug(
|
|
800
|
+
'firmwareUpdateV4 uses the only bootloader device when connectId changed after reboot'
|
|
801
|
+
);
|
|
802
|
+
device = singleDevice;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
735
805
|
} else if (allDevices.length === 1) {
|
|
736
806
|
[device] = allDevices;
|
|
737
807
|
} else if (allDevices.length > 1) {
|
|
@@ -833,8 +903,23 @@ function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown)
|
|
|
833
903
|
*/
|
|
834
904
|
async function connectDeviceForBle(method: BaseMethod, device: Device, retryCount = 0) {
|
|
835
905
|
try {
|
|
836
|
-
|
|
906
|
+
if (method.payload.forceProtocolDetection && device.hasDeviceAcquire()) {
|
|
907
|
+
await device.release();
|
|
908
|
+
}
|
|
909
|
+
const shouldAcquire =
|
|
910
|
+
method.payload.forceProtocolDetection ||
|
|
911
|
+
!device.hasDeviceAcquire() ||
|
|
912
|
+
!device.commands ||
|
|
913
|
+
device.commands.disposed;
|
|
914
|
+
if (shouldAcquire) {
|
|
915
|
+
await device.acquire(method.payload.connectProtocol, {
|
|
916
|
+
forceProtocolDetection: method.payload.forceProtocolDetection,
|
|
917
|
+
});
|
|
918
|
+
}
|
|
837
919
|
if (method.payload?.onlyConnectBleDevice) {
|
|
920
|
+
if (shouldAcquire) {
|
|
921
|
+
DevicePool.emitter.emit(DEVICE.CONNECT, device);
|
|
922
|
+
}
|
|
838
923
|
return;
|
|
839
924
|
}
|
|
840
925
|
// Skip initialize if conditions are met
|
|
@@ -845,7 +930,25 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
845
930
|
passphraseState: initOptions.passphraseState,
|
|
846
931
|
});
|
|
847
932
|
}
|
|
933
|
+
if (shouldAcquire) {
|
|
934
|
+
DevicePool.emitter.emit(DEVICE.CONNECT, device);
|
|
935
|
+
}
|
|
848
936
|
} catch (err) {
|
|
937
|
+
// Device.run()'s REQUIRE_DISCONNECT handling never sees acquire/initialize
|
|
938
|
+
// failures, so with keep-alive a wedged link would be reused by every retry
|
|
939
|
+
// (field case: Initialize timing out at 25s per attempt, forever). Drop it
|
|
940
|
+
// here so the next retry cold-connects.
|
|
941
|
+
if (
|
|
942
|
+
ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) &&
|
|
943
|
+
device.mainId &&
|
|
944
|
+
device.deviceConnector
|
|
945
|
+
) {
|
|
946
|
+
await device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
947
|
+
// The connector only drops the link; `deviceAcquired` is reset by
|
|
948
|
+
// release()/markTransportDisconnected() alone. Leaving it set makes the
|
|
949
|
+
// next attempt skip acquire and initialize onto the link we just cut.
|
|
950
|
+
device.markTransportDisconnected();
|
|
951
|
+
}
|
|
849
952
|
if (
|
|
850
953
|
(err.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
851
954
|
err.errorCode === HardwareErrorCode.BleConnectedError ||
|
|
@@ -1139,14 +1242,17 @@ const shouldCheckPassphraseState = (method: BaseMethod, device: Device) => {
|
|
|
1139
1242
|
};
|
|
1140
1243
|
|
|
1141
1244
|
const cleanup = () => {
|
|
1245
|
+
const pendingUiPromises = _uiPromises;
|
|
1142
1246
|
_uiPromises = [];
|
|
1247
|
+
rejectUiPromises(
|
|
1248
|
+
pendingUiPromises,
|
|
1249
|
+
ERRORS.TypedError(HardwareErrorCode.ActionCancelled, 'UI request was cancelled')
|
|
1250
|
+
);
|
|
1143
1251
|
Log.debug('Cleanup...');
|
|
1144
1252
|
};
|
|
1145
1253
|
|
|
1146
1254
|
const removeDeviceListener = (device: Device) => {
|
|
1147
1255
|
device.removeAllListeners();
|
|
1148
|
-
DevicePool.emitter.removeAllListeners(DEVICE.CONNECT);
|
|
1149
|
-
// DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
1150
1256
|
};
|
|
1151
1257
|
|
|
1152
1258
|
/**
|
|
@@ -1157,19 +1263,33 @@ const closePopup = () => {
|
|
|
1157
1263
|
};
|
|
1158
1264
|
|
|
1159
1265
|
const onDeviceConnectHandler = (device: Device) => {
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject
|
|
1266
|
+
const deviceObject = device.toMessageObject();
|
|
1267
|
+
if (!deviceObject) return;
|
|
1268
|
+
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject }));
|
|
1163
1269
|
};
|
|
1164
1270
|
|
|
1165
1271
|
const onDeviceDisconnectHandler = (device: Device) => {
|
|
1166
1272
|
device.clearPreInitialized();
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1169
|
-
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject
|
|
1273
|
+
const deviceObject = device.toMessageObject();
|
|
1274
|
+
if (!deviceObject) return;
|
|
1275
|
+
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|
|
1170
1276
|
};
|
|
1171
1277
|
|
|
1172
|
-
const
|
|
1278
|
+
const onTransportDeviceDisconnectHandler = (event: TransportDeviceDisconnectEvent) => {
|
|
1279
|
+
const device =
|
|
1280
|
+
deviceCacheMap.get(event.connectId) ??
|
|
1281
|
+
DevicePool.devicesCache[event.connectId] ??
|
|
1282
|
+
DevicePool.getDeviceByPath(event.connectId);
|
|
1283
|
+
if (!device) {
|
|
1284
|
+
Log.debug('Ignoring transport disconnect for an unknown device:', event.connectId);
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
device.markTransportDisconnected();
|
|
1289
|
+
DevicePool.emitter.emit(DEVICE.DISCONNECT, device);
|
|
1290
|
+
};
|
|
1291
|
+
|
|
1292
|
+
const onDevicePinHandler = (...[device, type, callback]: DeviceEvents['pin']) => {
|
|
1173
1293
|
Log.log('request Input PIN');
|
|
1174
1294
|
// create ui promise
|
|
1175
1295
|
const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PIN, device);
|
|
@@ -1178,12 +1298,14 @@ const onDevicePinHandler = async (...[device, type, callback]: DeviceEvents['pin
|
|
|
1178
1298
|
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1179
1299
|
device: device.toMessageObject() as unknown as KnownDevice,
|
|
1180
1300
|
type,
|
|
1301
|
+
responseCorrelation: uiPromise.responseCorrelation,
|
|
1181
1302
|
})
|
|
1182
1303
|
);
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1304
|
+
consumeUiPromise(
|
|
1305
|
+
uiPromise.promise,
|
|
1306
|
+
uiResp => callback(null, uiResp.payload),
|
|
1307
|
+
error => callback(error, '')
|
|
1308
|
+
);
|
|
1187
1309
|
};
|
|
1188
1310
|
|
|
1189
1311
|
export const onDeviceButtonHandler = (...[device, request]: [...DeviceEvents['button']]) => {
|
|
@@ -1207,7 +1329,11 @@ const onDeviceFeaturesHandler = (...[_, features]: [...DeviceEvents['features']]
|
|
|
1207
1329
|
postMessage(createDeviceMessage(DEVICE.FEATURES, { ...features }));
|
|
1208
1330
|
};
|
|
1209
1331
|
|
|
1210
|
-
const
|
|
1332
|
+
const onDeviceStateHandler = (...[_, stateEvent]: [...DeviceEvents['state']]) => {
|
|
1333
|
+
postMessage(createDeviceMessage(DEVICE.STATE, stateEvent));
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
const onDevicePassphraseHandler = (
|
|
1211
1337
|
...[device, requestPayload, callback]: DeviceEvents['passphrase']
|
|
1212
1338
|
) => {
|
|
1213
1339
|
Log.debug('onDevicePassphraseHandler');
|
|
@@ -1217,18 +1343,27 @@ const onDevicePassphraseHandler = async (
|
|
|
1217
1343
|
device: device.toMessageObject() as KnownDevice,
|
|
1218
1344
|
passphraseState: device.passphraseState,
|
|
1219
1345
|
existsAttachPinUser: requestPayload.existsAttachPinUser,
|
|
1346
|
+
deviceOnly: requestPayload.deviceOnly,
|
|
1347
|
+
source: requestPayload.source,
|
|
1348
|
+
reason: requestPayload.reason,
|
|
1349
|
+
expectedPassphraseState: requestPayload.expectedPassphraseState,
|
|
1350
|
+
...(requestPayload.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1351
|
+
responseCorrelation: uiPromise.responseCorrelation,
|
|
1220
1352
|
})
|
|
1221
1353
|
);
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1354
|
+
consumeUiPromise(
|
|
1355
|
+
uiPromise.promise,
|
|
1356
|
+
uiResp => {
|
|
1357
|
+
const { value, passphraseOnDevice, save, attachPinOnDevice } = uiResp.payload;
|
|
1358
|
+
callback({
|
|
1359
|
+
passphrase: value.normalize('NFKD'),
|
|
1360
|
+
passphraseOnDevice,
|
|
1361
|
+
attachPinOnDevice,
|
|
1362
|
+
cache: save,
|
|
1363
|
+
});
|
|
1364
|
+
},
|
|
1365
|
+
error => callback({}, error)
|
|
1366
|
+
);
|
|
1232
1367
|
};
|
|
1233
1368
|
|
|
1234
1369
|
const onEmptyPassphraseHandler = (...[_, , callback]: DeviceEvents['passphrase']) => {
|
|
@@ -1238,17 +1373,62 @@ const onEmptyPassphraseHandler = (...[_, , callback]: DeviceEvents['passphrase']
|
|
|
1238
1373
|
};
|
|
1239
1374
|
|
|
1240
1375
|
const onEnterPassphraseOnDeviceHandler = (
|
|
1241
|
-
...[device]: [...DeviceEvents['passphrase_on_device']]
|
|
1376
|
+
...[device, requestPayload]: [...DeviceEvents['passphrase_on_device']]
|
|
1242
1377
|
) => {
|
|
1243
1378
|
postMessage(
|
|
1244
1379
|
createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
1245
1380
|
device: device.toMessageObject() as KnownDevice,
|
|
1246
1381
|
passphraseState: device.passphraseState,
|
|
1382
|
+
source: requestPayload?.source,
|
|
1383
|
+
reason: requestPayload?.reason,
|
|
1384
|
+
...(requestPayload?.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1385
|
+
})
|
|
1386
|
+
);
|
|
1387
|
+
};
|
|
1388
|
+
|
|
1389
|
+
const onEnterAttachPinOnDeviceHandler = (
|
|
1390
|
+
...[device, requestPayload]: [...DeviceEvents['attach_pin_on_device']]
|
|
1391
|
+
) => {
|
|
1392
|
+
postMessage(
|
|
1393
|
+
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1394
|
+
device: device.toMessageObject() as KnownDevice,
|
|
1395
|
+
type: 'ButtonRequest_AttachPin',
|
|
1396
|
+
source: requestPayload?.source,
|
|
1397
|
+
reason: requestPayload?.reason,
|
|
1398
|
+
...(requestPayload?.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1399
|
+
})
|
|
1400
|
+
);
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
const onEnterPinOnDeviceHandler = (
|
|
1404
|
+
...[device, pinType, metadata]: [...DeviceEvents['pin_on_device']]
|
|
1405
|
+
) => {
|
|
1406
|
+
postMessage(
|
|
1407
|
+
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1408
|
+
device: device.toMessageObject() as KnownDevice,
|
|
1409
|
+
type:
|
|
1410
|
+
pinType === DeviceSessionPinType.AttachToPin
|
|
1411
|
+
? 'ButtonRequest_AttachPin'
|
|
1412
|
+
: 'ButtonRequest_PinEntry',
|
|
1413
|
+
source: metadata?.source,
|
|
1414
|
+
reason: metadata?.reason,
|
|
1415
|
+
deviceOnly: metadata?.deviceOnly ?? true,
|
|
1416
|
+
completion: metadata?.completion,
|
|
1417
|
+
method: metadata?.method,
|
|
1418
|
+
page: metadata?.page,
|
|
1419
|
+
operation: metadata?.operation,
|
|
1420
|
+
...(metadata?.interaction ? { interaction: metadata.interaction } : {}),
|
|
1247
1421
|
})
|
|
1248
1422
|
);
|
|
1249
1423
|
};
|
|
1250
1424
|
|
|
1251
|
-
const
|
|
1425
|
+
const onPinOnDeviceCompleteHandler = (
|
|
1426
|
+
...[_, metadata]: [...DeviceEvents['pin_on_device_complete']]
|
|
1427
|
+
) => {
|
|
1428
|
+
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW, metadata));
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
const onSelectDeviceInBootloaderForWebDeviceHandler = (
|
|
1252
1432
|
...[device, callback]: [...DeviceEvents['select_device_in_bootloader_for_web_device']]
|
|
1253
1433
|
) => {
|
|
1254
1434
|
Log.debug('onSelectDeviceInBootloaderForWebDeviceHandler');
|
|
@@ -1258,11 +1438,14 @@ const onSelectDeviceInBootloaderForWebDeviceHandler = async (
|
|
|
1258
1438
|
device: device.toMessageObject() as KnownDevice,
|
|
1259
1439
|
})
|
|
1260
1440
|
);
|
|
1261
|
-
|
|
1262
|
-
|
|
1441
|
+
consumeUiPromise(
|
|
1442
|
+
uiPromise.promise,
|
|
1443
|
+
uiResp => callback(null, uiResp.payload.deviceId),
|
|
1444
|
+
error => callback(error, '')
|
|
1445
|
+
);
|
|
1263
1446
|
};
|
|
1264
1447
|
|
|
1265
|
-
const onSelectDeviceForSwitchFirmwareWebDeviceHandler =
|
|
1448
|
+
const onSelectDeviceForSwitchFirmwareWebDeviceHandler = (
|
|
1266
1449
|
...[device, callback]: [...DeviceEvents['select_device_for_switch_firmware_web_device']]
|
|
1267
1450
|
) => {
|
|
1268
1451
|
Log.debug('onSelectDeviceForSwitchFirmwareWebDeviceHandler');
|
|
@@ -1275,8 +1458,11 @@ const onSelectDeviceForSwitchFirmwareWebDeviceHandler = async (
|
|
|
1275
1458
|
device: device.toMessageObject() as KnownDevice,
|
|
1276
1459
|
})
|
|
1277
1460
|
);
|
|
1278
|
-
|
|
1279
|
-
|
|
1461
|
+
consumeUiPromise(
|
|
1462
|
+
uiPromise.promise,
|
|
1463
|
+
uiResp => callback(null, uiResp.payload.deviceId),
|
|
1464
|
+
error => callback(error, '')
|
|
1465
|
+
);
|
|
1280
1466
|
};
|
|
1281
1467
|
|
|
1282
1468
|
/**
|
|
@@ -1295,14 +1481,21 @@ const postMessage = (message: CoreMessage) => {
|
|
|
1295
1481
|
|
|
1296
1482
|
const createUiPromise = <T extends UiPromiseResponse['type']>(promiseEvent: T, device?: Device) => {
|
|
1297
1483
|
const uiPromise: UiPromise<T> = createDeferred(promiseEvent, device);
|
|
1484
|
+
if (
|
|
1485
|
+
device &&
|
|
1486
|
+
(promiseEvent === UI_RESPONSE.RECEIVE_PIN || promiseEvent === UI_RESPONSE.RECEIVE_PASSPHRASE)
|
|
1487
|
+
) {
|
|
1488
|
+
const publicDeviceId = device.toMessageObject()?.deviceId;
|
|
1489
|
+
uiPromise.responseCorrelation = {
|
|
1490
|
+
interactionId: generateInstanceId('UiResponse', device.sdkInstanceId),
|
|
1491
|
+
deviceId: publicDeviceId || device.instanceId,
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1298
1494
|
_uiPromises.push(uiPromise as any);
|
|
1299
1495
|
|
|
1300
1496
|
return uiPromise;
|
|
1301
1497
|
};
|
|
1302
1498
|
|
|
1303
|
-
const findUiPromise = <T extends UiPromiseResponse['type']>(promiseEvent: T) =>
|
|
1304
|
-
_uiPromises.find(p => p.id === promiseEvent);
|
|
1305
|
-
|
|
1306
1499
|
const removeUiPromise = (promise: Deferred<any>) => {
|
|
1307
1500
|
_uiPromises = _uiPromises.filter(p => p !== promise);
|
|
1308
1501
|
};
|
|
@@ -1314,6 +1507,8 @@ export default class Core extends EventEmitter {
|
|
|
1314
1507
|
|
|
1315
1508
|
private requestQueue = new RequestQueue();
|
|
1316
1509
|
|
|
1510
|
+
private disposePromise?: Promise<void>;
|
|
1511
|
+
|
|
1317
1512
|
// background task
|
|
1318
1513
|
private prePendingCallPromise: Promise<void> | undefined;
|
|
1319
1514
|
|
|
@@ -1352,11 +1547,16 @@ export default class Core extends EventEmitter {
|
|
|
1352
1547
|
case UI_RESPONSE.RECEIVE_PASSPHRASE:
|
|
1353
1548
|
case UI_RESPONSE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE:
|
|
1354
1549
|
case UI_RESPONSE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE: {
|
|
1355
|
-
const uiPromise =
|
|
1550
|
+
const uiPromise = findUiPromiseForResponse(_uiPromises, message);
|
|
1356
1551
|
if (uiPromise) {
|
|
1357
1552
|
Log.log('receive UI Response: ', message.type);
|
|
1358
1553
|
uiPromise.resolve(message);
|
|
1359
1554
|
removeUiPromise(uiPromise);
|
|
1555
|
+
} else if (
|
|
1556
|
+
message.type === UI_RESPONSE.RECEIVE_PIN ||
|
|
1557
|
+
message.type === UI_RESPONSE.RECEIVE_PASSPHRASE
|
|
1558
|
+
) {
|
|
1559
|
+
Log.warn('Ignored unmatched or ambiguous sensitive UI response:', message.type);
|
|
1360
1560
|
}
|
|
1361
1561
|
break;
|
|
1362
1562
|
}
|
|
@@ -1372,10 +1572,17 @@ export default class Core extends EventEmitter {
|
|
|
1372
1572
|
}
|
|
1373
1573
|
|
|
1374
1574
|
case IFRAME.CALL: {
|
|
1375
|
-
|
|
1575
|
+
const logBlockLabel = getLogBlockLabel(message);
|
|
1576
|
+
Log.log(
|
|
1577
|
+
formatLogMethodLabel(`[${Date.now()}][CALL_API]`, logBlockLabel),
|
|
1578
|
+
getSafeLogPayload(message, logBlockLabel)
|
|
1579
|
+
);
|
|
1376
1580
|
const response = await callAPI(this.getCoreContext(), message);
|
|
1377
1581
|
const { success, payload } = response;
|
|
1378
|
-
Log.log(
|
|
1582
|
+
Log.log(
|
|
1583
|
+
formatLogMethodLabel(`[${Date.now()}][CALL_API_RESPONSE]`, logBlockLabel),
|
|
1584
|
+
getSafeLogPayload(response, logBlockLabel)
|
|
1585
|
+
);
|
|
1379
1586
|
if (success) {
|
|
1380
1587
|
return response;
|
|
1381
1588
|
}
|
|
@@ -1405,25 +1612,65 @@ export default class Core extends EventEmitter {
|
|
|
1405
1612
|
return Promise.resolve(message);
|
|
1406
1613
|
}
|
|
1407
1614
|
|
|
1408
|
-
dispose() {
|
|
1615
|
+
dispose(): Promise<void> {
|
|
1616
|
+
if (!this.disposePromise) {
|
|
1617
|
+
this.disposePromise = this.disposeResources();
|
|
1618
|
+
}
|
|
1619
|
+
return this.disposePromise;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
private async disposeResources(): Promise<void> {
|
|
1623
|
+
Log.debug(`[Core] Disposing SDK instance: ${this.sdkInstanceId}`);
|
|
1624
|
+
pollingManager.stopAll();
|
|
1625
|
+
this.requestQueue.abortAllRequests();
|
|
1626
|
+
cleanup();
|
|
1627
|
+
|
|
1628
|
+
_connector?.stop();
|
|
1629
|
+
let transportCleanup: Promise<void>;
|
|
1630
|
+
try {
|
|
1631
|
+
transportCleanup = Promise.resolve(TransportManager.getTransport()?.stop?.()).catch(error => {
|
|
1632
|
+
Log.warn('[Core] Transport cleanup failed:', error);
|
|
1633
|
+
});
|
|
1634
|
+
} catch (error) {
|
|
1635
|
+
Log.warn('[Core] Transport cleanup failed:', error);
|
|
1636
|
+
transportCleanup = Promise.resolve();
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
// Preserve synchronous dispose semantics for in-memory state and listeners.
|
|
1409
1640
|
_deviceList = undefined;
|
|
1410
1641
|
_connector = undefined;
|
|
1642
|
+
DevicePool.dispose();
|
|
1411
1643
|
deviceCacheMap.clear();
|
|
1412
1644
|
preWarmInflight.clear();
|
|
1413
1645
|
preWarmDoneAt.clear();
|
|
1414
|
-
|
|
1646
|
+
preConnectCache = { passphraseState: undefined };
|
|
1647
|
+
this.prePendingCallPromise = undefined;
|
|
1648
|
+
this.removeAllListeners();
|
|
1415
1649
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
1650
|
+
if (_core === this) _core = undefined;
|
|
1651
|
+
|
|
1652
|
+
// Transports, especially Node USB, may release native handles asynchronously.
|
|
1653
|
+
await transportCleanup;
|
|
1416
1654
|
}
|
|
1417
1655
|
}
|
|
1418
1656
|
|
|
1419
1657
|
export const initCore = () => {
|
|
1420
|
-
|
|
1421
|
-
|
|
1658
|
+
const core = new Core();
|
|
1659
|
+
_core = core;
|
|
1660
|
+
return core;
|
|
1422
1661
|
};
|
|
1423
1662
|
|
|
1424
1663
|
export const initConnector = () => {
|
|
1425
1664
|
_connector = new DeviceConnector();
|
|
1665
|
+
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
1666
|
+
DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
1667
|
+
DevicePool.emitter.removeListener(
|
|
1668
|
+
TRANSPORT_EVENT.DEVICE_DISCONNECT,
|
|
1669
|
+
onTransportDeviceDisconnectHandler
|
|
1670
|
+
);
|
|
1671
|
+
DevicePool.emitter.on(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
1426
1672
|
DevicePool.emitter.on(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
1673
|
+
DevicePool.emitter.on(TRANSPORT_EVENT.DEVICE_DISCONNECT, onTransportDeviceDisconnectHandler);
|
|
1427
1674
|
return _connector;
|
|
1428
1675
|
};
|
|
1429
1676
|
|
|
@@ -1437,13 +1684,8 @@ export const init = async (
|
|
|
1437
1684
|
plugin?: LowlevelTransportSharedPlugin
|
|
1438
1685
|
) => {
|
|
1439
1686
|
try {
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
setProtocolV2DeviceInfoMock(settings.protocolV2DeviceInfoMockEnabled ?? false);
|
|
1443
|
-
initTransport(Transport, plugin);
|
|
1444
|
-
} catch {
|
|
1445
|
-
Log.error('DataManager.load error');
|
|
1446
|
-
}
|
|
1687
|
+
await DataManager.load(settings);
|
|
1688
|
+
initTransport(Transport, plugin);
|
|
1447
1689
|
enableLog(DataManager.getSettings('debug'));
|
|
1448
1690
|
if (DataManager.getSettings('env') !== 'react-native') {
|
|
1449
1691
|
setLoggerPostMessage(postMessage);
|
|
@@ -1454,6 +1696,7 @@ export const init = async (
|
|
|
1454
1696
|
return _core;
|
|
1455
1697
|
} catch (error) {
|
|
1456
1698
|
Log.error('core init', error);
|
|
1699
|
+
throw error;
|
|
1457
1700
|
}
|
|
1458
1701
|
};
|
|
1459
1702
|
|