@onekeyfe/hd-core 1.2.0-alpha.13 → 1.2.0-alpha.130
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 +694 -0
- package/__tests__/DeviceEventRegistration.test.ts +49 -0
- package/__tests__/base64Data.test.ts +69 -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 +45 -5
- package/__tests__/core-dispose.test.ts +34 -0
- package/__tests__/core-error-output.test.ts +39 -0
- package/__tests__/core-initialization.test.ts +23 -0
- package/__tests__/device-connector-protocol.test.ts +102 -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 +518 -0
- package/__tests__/device-pool-state.test.ts +191 -0
- package/__tests__/device-settings.test.ts +569 -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 +297 -0
- package/__tests__/device-state-projector.test.ts +114 -0
- package/__tests__/device-state-store.test.ts +109 -0
- package/__tests__/device-utils.test.ts +154 -0
- package/__tests__/device-wallet-session-store.test.ts +348 -1
- package/__tests__/deviceFeaturesUtils.test.ts +39 -0
- package/__tests__/devicePoolBootloaderPath.test.ts +64 -0
- package/__tests__/deviceSettings.test.ts +117 -0
- package/__tests__/deviceUploadNft.test.ts +345 -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 +171 -0
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +438 -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 +819 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +287 -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 +237 -0
- package/__tests__/firmware-update/firmware-update-v4-install-poll.test.ts +130 -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 +617 -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 +140 -1
- package/__tests__/method-protocol-support.test.ts +144 -0
- package/__tests__/networkUtils.test.ts +406 -0
- package/__tests__/open-wallet-session-error-response.test.ts +43 -0
- package/__tests__/open-wallet-session.test.ts +1899 -0
- package/__tests__/pro2Nft.test.ts +108 -0
- package/__tests__/pro2Wallpaper.test.ts +8 -19
- package/__tests__/protocol-binding.test.ts +89 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +105 -0
- package/__tests__/protocol-v2-ping.test.ts +28 -0
- package/__tests__/protocol-v2-resources.test.ts +385 -0
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +91 -0
- package/__tests__/protocol-v2-unlock-policy.test.ts +339 -0
- package/__tests__/protocol-v2.test.ts +8084 -2515
- package/__tests__/protocolV2FileWrite.test.ts +221 -3
- 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 +103 -0
- package/__tests__/request-context-logging.test.ts +16 -0
- package/__tests__/resourceBase64Boundary.test.ts +48 -0
- package/__tests__/search-devices.test.ts +191 -0
- package/__tests__/ton-sign-message.test.ts +84 -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 +14 -2
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +25 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBLEFirmwareRelease.d.ts +3 -2
- package/dist/api/CheckBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts +2 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts +3 -2
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CipherKeyValue.d.ts +1 -0
- package/dist/api/CipherKeyValue.d.ts.map +1 -1
- package/dist/api/ClearSessionCache.d.ts.map +1 -1
- package/dist/api/DetectDeviceConnectProtocol.d.ts +7 -0
- package/dist/api/DetectDeviceConnectProtocol.d.ts.map +1 -0
- package/dist/api/DirList.d.ts +1 -0
- package/dist/api/DirList.d.ts.map +1 -1
- package/dist/api/DirMake.d.ts +1 -0
- package/dist/api/DirMake.d.ts.map +1 -1
- package/dist/api/DirRemove.d.ts +1 -0
- package/dist/api/DirRemove.d.ts.map +1 -1
- package/dist/api/FileDelete.d.ts +1 -0
- package/dist/api/FileDelete.d.ts.map +1 -1
- package/dist/api/FileRead.d.ts +1 -0
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts +2 -0
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +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 +57 -14
- 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 +1 -0
- 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 +1 -2
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- 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 -3
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +72 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +38 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +15 -4
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/protocolV2Release.d.ts +33 -0
- package/dist/api/firmware/protocolV2Release.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/base64Data.d.ts +16 -0
- package/dist/api/helpers/base64Data.d.ts.map +1 -0
- 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 +11 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +5 -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 +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +4 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +2 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +2 -2
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +30 -0
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +3 -3
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -1
- package/dist/api/protocol-v2/Ping.d.ts +3 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts +1 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +2 -1
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +2 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +3 -2
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetAddress.d.ts +1 -0
- package/dist/api/starcoin/StarcoinGetAddress.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts +1 -0
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignMessage.d.ts +1 -0
- package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts +1 -0
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts +1 -0
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +1 -2
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +2 -3
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +2 -1
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +2 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +2 -1
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +2 -1
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +2 -1
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +1 -0
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +2 -1
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +2 -1
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronGetAddress.d.ts +1 -0
- package/dist/api/tron/TronGetAddress.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +6 -1
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +2 -1
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/utils.d.ts +4 -1
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/api/xrp/XrpGetAddress.d.ts +1 -0
- package/dist/api/xrp/XrpGetAddress.d.ts.map +1 -1
- package/dist/api/xrp/XrpSignTransaction.d.ts +1 -0
- package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +0 -2
- 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 -2
- 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 +14 -5
- 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 +78 -16
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +8 -6
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +4 -3
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/device/DeviceFeaturesState.d.ts +3 -0
- package/dist/device/DeviceFeaturesState.d.ts.map +1 -0
- package/dist/device/DevicePool.d.ts +6 -2
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts +13 -0
- package/dist/device/DeviceStateMapper.d.ts.map +1 -0
- package/dist/device/DeviceStateProjector.d.ts +7 -0
- package/dist/device/DeviceStateProjector.d.ts.map +1 -0
- package/dist/device/DeviceStateStore.d.ts +21 -0
- package/dist/device/DeviceStateStore.d.ts.map +1 -0
- package/dist/device/DeviceWalletSessionStore.d.ts +13 -1
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -1
- package/dist/device/cloneDeviceState.d.ts +2 -0
- package/dist/device/cloneDeviceState.d.ts.map +1 -0
- package/dist/device/deviceIdentity.d.ts +5 -0
- package/dist/device/deviceIdentity.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +8 -2
- 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/call.d.ts +0 -7
- 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 +16 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/iframe.d.ts +0 -1
- package/dist/events/iframe.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 +1764 -828
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11673 -4693
- package/dist/inject.d.ts +7 -3
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts +1 -2
- 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 +33 -22
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +2 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/resources.d.ts +12 -0
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +17 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +42 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +2 -0
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +22 -0
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +18 -4
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +48 -9
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBLEFirmwareRelease.d.ts +2 -13
- package/dist/types/api/checkBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBootloaderRelease.d.ts +2 -6
- package/dist/types/api/checkBootloaderRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareRelease.d.ts +2 -13
- package/dist/types/api/checkFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareTypeAvailable.d.ts +2 -2
- package/dist/types/api/checkFirmwareTypeAvailable.d.ts.map +1 -1
- package/dist/types/api/detectDeviceConnectProtocol.d.ts +4 -0
- package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +1 -0
- package/dist/types/api/deviceSettings.d.ts +11 -2
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +6 -2
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +8 -3
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +67 -5
- 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.map +1 -1
- package/dist/types/api/index.d.ts +25 -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 +11 -93
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/api/sessionCache.d.ts +4 -1
- package/dist/types/api/sessionCache.d.ts.map +1 -1
- package/dist/types/device.d.ts +139 -8
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +44 -16
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/assets.d.ts +2 -1
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +14 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -0
- package/dist/utils/deviceFeaturesUtils.d.ts +10 -1
- 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 +39 -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 +5 -4
- 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 +38 -0
- package/dist/utils/pro2Nft.d.ts.map +1 -0
- package/dist/utils/pro2Wallpaper.d.ts +10 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- 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 +6 -4
- package/src/api/BaseMethod.ts +45 -23
- package/src/api/CheckAllFirmwareRelease.ts +440 -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 +4 -0
- package/src/api/DetectDeviceConnectProtocol.ts +18 -0
- package/src/api/DirList.ts +9 -4
- package/src/api/DirMake.ts +7 -4
- package/src/api/DirRemove.ts +7 -4
- package/src/api/FileDelete.ts +7 -4
- package/src/api/FileRead.ts +13 -7
- package/src/api/FileWrite.ts +10 -5
- package/src/api/FirmwareUpdate.ts +30 -15
- package/src/api/FirmwareUpdateV2.ts +535 -169
- package/src/api/FirmwareUpdateV3.ts +349 -91
- package/src/api/FirmwareUpdateV4.ts +2300 -710
- 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 -12
- 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 +35 -5
- package/src/api/UploadPortfolio.ts +32 -4
- 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 +4 -0
- package/src/api/cardano/CardanoSignTransaction.ts +4 -0
- package/src/api/conflux/ConfluxGetAddress.ts +6 -0
- package/src/api/conflux/ConfluxSignMessage.ts +6 -0
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +6 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +8 -5
- package/src/api/cosmos/CosmosGetAddress.ts +4 -0
- package/src/api/cosmos/CosmosGetPublicKey.ts +4 -0
- package/src/api/cosmos/CosmosSignTransaction.ts +4 -0
- package/src/api/device/DeviceCancel.ts +5 -0
- package/src/api/device/DeviceChangePin.ts +28 -0
- package/src/api/device/DeviceFullyUploadResource.ts +4 -5
- package/src/api/device/DeviceLock.ts +5 -0
- package/src/api/device/DeviceRebootToBoardloader.ts +5 -0
- package/src/api/device/DeviceRebootToBootloader.ts +5 -0
- package/src/api/device/DeviceSettings.ts +211 -3
- 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 +196 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +214 -77
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +946 -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/base64Data.ts +85 -0
- 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 +266 -42
- package/src/api/index.ts +6 -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/DeviceFactoryInfoGet.ts +5 -2
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +6 -3
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +13 -32
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +10 -6
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +6 -3
- package/src/api/protocol-v2/DeviceInfoGet.ts +11 -18
- package/src/api/protocol-v2/DeviceReboot.ts +7 -3
- package/src/api/protocol-v2/DeviceStatusGet.ts +6 -1
- package/src/api/protocol-v2/DeviceUploadNft.ts +245 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +45 -21
- package/src/api/protocol-v2/FilesystemFormat.ts +5 -2
- package/src/api/protocol-v2/FilesystemPermissionFix.ts +5 -2
- package/src/api/protocol-v2/Ping.ts +37 -3
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +8 -3
- package/src/api/protocol-v2/helpers.ts +1 -1
- package/src/api/scdo/ScdoGetAddress.ts +0 -4
- package/src/api/scdo/ScdoSignMessage.ts +0 -4
- package/src/api/scdo/ScdoSignTransaction.ts +0 -4
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +5 -1
- package/src/api/solana/SolSignOffchainMessage.ts +5 -1
- package/src/api/solana/SolSignTransaction.ts +6 -2
- package/src/api/starcoin/StarcoinGetAddress.ts +4 -0
- package/src/api/starcoin/StarcoinGetPublicKey.ts +4 -0
- package/src/api/starcoin/StarcoinSignMessage.ts +4 -0
- package/src/api/starcoin/StarcoinSignTransaction.ts +4 -0
- package/src/api/starcoin/StarcoinVerifyMessage.ts +4 -0
- package/src/api/stellar/StellarGetAddress.ts +1 -10
- package/src/api/stellar/StellarSignTransaction.ts +1 -14
- package/src/api/sui/SuiGetAddress.ts +5 -1
- package/src/api/sui/SuiGetPublicKey.ts +5 -1
- package/src/api/sui/SuiSignMessage.ts +5 -1
- package/src/api/sui/SuiSignTransaction.ts +5 -1
- package/src/api/ton/TonGetAddress.ts +5 -1
- package/src/api/ton/TonSignData.ts +5 -1
- package/src/api/ton/TonSignMessage.ts +10 -4
- package/src/api/ton/TonSignProof.ts +5 -1
- package/src/api/tron/TronGetAddress.ts +4 -0
- package/src/api/tron/TronSignMessage.ts +19 -8
- package/src/api/tron/TronSignTransaction.ts +5 -1
- package/src/api/utils.ts +32 -3
- package/src/api/xrp/XrpGetAddress.ts +4 -0
- package/src/api/xrp/XrpSignTransaction.ts +5 -1
- package/src/constants/index.ts +1 -4
- package/src/core/RequestQueue.ts +0 -18
- package/src/core/deviceEventRegistration.ts +27 -0
- package/src/core/index.ts +419 -174
- package/src/core/uiPromiseRegistry.ts +63 -0
- package/src/data/messages/messages-protocol-v2.json +523 -449
- package/src/data/messages/messages.json +286 -1
- package/src/data-manager/DataManager.ts +162 -44
- package/src/data-manager/TransportManager.ts +7 -1
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +909 -269
- package/src/device/DeviceCommands.ts +185 -160
- package/src/device/DeviceConnector.ts +51 -21
- package/src/device/DeviceFeaturesState.ts +25 -0
- package/src/device/DevicePool.ts +105 -23
- package/src/device/DeviceStateMapper.ts +418 -0
- package/src/device/DeviceStateProjector.ts +152 -0
- package/src/device/DeviceStateStore.ts +232 -0
- package/src/device/DeviceWalletSessionStore.ts +72 -6
- package/src/device/cloneDeviceState.ts +39 -0
- package/src/device/deviceIdentity.ts +18 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +209 -191
- package/src/deviceProfile/index.ts +0 -1
- package/src/deviceProfile/protocolV2DeviceIdentity.ts +35 -0
- package/src/events/call.ts +0 -6
- package/src/events/core.ts +0 -2
- package/src/events/device.ts +22 -1
- package/src/events/iframe.ts +0 -1
- package/src/events/logBlockEvent.ts +93 -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 -4
- package/src/inject.ts +89 -55
- package/src/lowLevelInject.ts +11 -7
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +118 -52
- package/src/protocols/protocol-v2/firmware.ts +3 -1
- package/src/protocols/protocol-v2/index.ts +9 -3
- package/src/protocols/protocol-v2/resources.ts +171 -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 +136 -0
- package/src/protocols/protocol-v2/walletSession.ts +420 -49
- package/src/topLevelInject.ts +11 -6
- 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 +85 -11
- 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 +7 -0
- package/src/types/api/index.ts +43 -73
- package/src/types/api/kaspaSignTransaction.ts +60 -4
- package/src/types/api/openWalletSession.ts +54 -0
- package/src/types/api/protocolV2.ts +23 -188
- package/src/types/api/sessionCache.ts +9 -4
- package/src/types/device.ts +211 -9
- package/src/types/params.ts +9 -2
- package/src/types/settings.ts +52 -25
- package/src/utils/assets.ts +4 -1
- package/src/utils/deviceFeaturesCompat.ts +191 -0
- package/src/utils/deviceFeaturesUtils.ts +42 -9
- package/src/utils/deviceInfoUtils.ts +29 -69
- package/src/utils/deviceSettings.ts +181 -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 +26 -7
- package/src/utils/networkUtils.ts +274 -16
- package/src/utils/pro2Nft.ts +165 -0
- package/src/utils/pro2Wallpaper.ts +44 -25
- package/src/utils/tracing.ts +3 -1
- package/src/utils/uiProgressThrottle.ts +63 -0
- package/tsconfig.type-tests.json +12 -0
- package/__tests__/RequestQueue.test.ts +0 -34
- package/dist/api/GetDeviceInfo.d.ts +0 -9
- package/dist/api/GetDeviceInfo.d.ts.map +0 -1
- package/dist/api/firmware/progressThrottle.d.ts +0 -3
- package/dist/api/firmware/progressThrottle.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +0 -16
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +0 -12
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +0 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts +0 -21
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +0 -9
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +0 -1
- package/dist/types/api/getDeviceInfo.d.ts +0 -87
- package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
- package/src/api/GetDeviceInfo.ts +0 -145
- package/src/api/firmware/progressThrottle.ts +0 -44
- package/src/api/protocol-v2/DeviceSessionGet.ts +0 -15
- package/src/api/protocol-v2/DeviceSettingsGet.ts +0 -16
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +0 -59
- package/src/api/protocol-v2/DeviceSettingsSet.ts +0 -39
- package/src/deviceProfile/buildDeviceProfile.ts +0 -354
- package/src/protocols/protocol-v2/unlockRetry.ts +0 -46
- package/src/types/api/getDeviceInfo.ts +0 -101
package/src/core/index.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
|
+
import {
|
|
4
|
+
DeviceSessionPinType,
|
|
5
|
+
TRANSPORT_EVENT,
|
|
6
|
+
isProtocolV2LinkDisabledError,
|
|
7
|
+
} from '@onekeyfe/hd-transport';
|
|
3
8
|
import {
|
|
4
9
|
ERRORS,
|
|
10
|
+
ERROR_CODES_REQUIRE_DISCONNECT,
|
|
5
11
|
ERROR_CODES_REQUIRE_RELEASE,
|
|
6
12
|
HardwareError,
|
|
7
13
|
HardwareErrorCode,
|
|
@@ -14,14 +20,7 @@ import {
|
|
|
14
20
|
createNewFirmwareUnReleaseHardwareError,
|
|
15
21
|
} from '@onekeyfe/hd-shared';
|
|
16
22
|
|
|
17
|
-
import {
|
|
18
|
-
LoggerNames,
|
|
19
|
-
enableLog,
|
|
20
|
-
getLogger,
|
|
21
|
-
isMethodVersionRangeUnsupported,
|
|
22
|
-
setLoggerPostMessage,
|
|
23
|
-
wait,
|
|
24
|
-
} from '../utils';
|
|
23
|
+
import { LoggerNames, enableLog, getLogger, setLoggerPostMessage, wait } from '../utils';
|
|
25
24
|
import {
|
|
26
25
|
findDefectiveBatchDevice,
|
|
27
26
|
getDefectiveDeviceInfo,
|
|
@@ -32,10 +31,12 @@ import {
|
|
|
32
31
|
createRequestContext,
|
|
33
32
|
createSdkTracingContext,
|
|
34
33
|
formatRequestContext,
|
|
34
|
+
generateInstanceId,
|
|
35
35
|
getActiveRequestsByDeviceInstance,
|
|
36
36
|
updateRequestContext,
|
|
37
37
|
} from '../utils/tracing';
|
|
38
38
|
import { Device } from '../device/Device';
|
|
39
|
+
import { checkLiveDeviceId } from '../device/deviceIdentity';
|
|
39
40
|
import { DeviceList } from '../device/DeviceList';
|
|
40
41
|
import { DevicePool } from '../device/DevicePool';
|
|
41
42
|
import { PollingStateManager } from './PollingStateManager';
|
|
@@ -51,19 +52,33 @@ import {
|
|
|
51
52
|
createDeviceMessage,
|
|
52
53
|
createResponseMessage,
|
|
53
54
|
createUiMessage,
|
|
55
|
+
formatLogMethodLabel,
|
|
56
|
+
getLogBlockLabel,
|
|
57
|
+
getSafeLogPayload,
|
|
54
58
|
} from '../events';
|
|
55
59
|
import TransportManager from '../data-manager/TransportManager';
|
|
56
60
|
import DeviceConnector from '../device/DeviceConnector';
|
|
57
61
|
import RequestQueue from './RequestQueue';
|
|
62
|
+
import { consumeUiPromise, findUiPromiseForResponse, rejectUiPromises } from './uiPromiseRegistry';
|
|
63
|
+
import { registerHardwareUiEventListeners } from './deviceEventRegistration';
|
|
58
64
|
import { getSynchronize } from '../utils/getSynchronize';
|
|
59
|
-
import {
|
|
65
|
+
import { runMethodWithUnlockPolicy } from '../protocols/protocol-v2/unlockPolicyRunner';
|
|
66
|
+
import {
|
|
67
|
+
ProtocolV2UiInteractionCoordinator,
|
|
68
|
+
isProtocolV2UiEnabled,
|
|
69
|
+
} from '../protocols/protocol-v2/uiInteraction';
|
|
70
|
+
import { createUiProgressMessageFilter } from '../utils/uiProgressThrottle';
|
|
60
71
|
|
|
61
72
|
import type { ConnectSettings, Features, KnownDevice } from '../types';
|
|
62
73
|
import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
|
|
63
74
|
import type { DeviceEvents, InitOptions, RunOptions } from '../device/Device';
|
|
64
75
|
import type { SdkTracingContext } from '../utils/tracing';
|
|
65
76
|
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
66
|
-
import type {
|
|
77
|
+
import type {
|
|
78
|
+
LowlevelTransportSharedPlugin,
|
|
79
|
+
OneKeyDeviceInfo,
|
|
80
|
+
TransportDeviceDisconnectEvent,
|
|
81
|
+
} from '@onekeyfe/hd-transport';
|
|
67
82
|
import type { BaseMethod } from '../api/BaseMethod';
|
|
68
83
|
|
|
69
84
|
const Log = getLogger(LoggerNames.Core);
|
|
@@ -92,14 +107,15 @@ function hasDeriveCardano(method: BaseMethod): boolean {
|
|
|
92
107
|
|
|
93
108
|
const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
94
109
|
initSession: method?.payload.initSession,
|
|
95
|
-
passphraseState: method?.payload.passphraseState,
|
|
110
|
+
passphraseState: method?.payload.useEmptyPassphrase ? undefined : method?.payload.passphraseState,
|
|
96
111
|
deviceId: method?.payload.deviceId,
|
|
97
112
|
deriveCardano: method && hasDeriveCardano(method),
|
|
98
113
|
connectProtocol: method?.payload.connectProtocol,
|
|
114
|
+
forceProtocolDetection: method?.payload.forceProtocolDetection,
|
|
99
115
|
protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
|
|
100
116
|
});
|
|
101
117
|
|
|
102
|
-
let _core: Core;
|
|
118
|
+
let _core: Core | undefined;
|
|
103
119
|
let _deviceList: DeviceList | undefined;
|
|
104
120
|
let _connector: DeviceConnector | undefined;
|
|
105
121
|
let _uiPromises: UiPromise<UiPromiseResponse['type']>[] = []; // Waiting for ui response
|
|
@@ -124,6 +140,9 @@ const toError = (error: unknown): Error | undefined => {
|
|
|
124
140
|
}
|
|
125
141
|
};
|
|
126
142
|
|
|
143
|
+
const isExpectedCompatibilityError = (error: unknown) =>
|
|
144
|
+
error instanceof HardwareError && error.errorCode === HardwareErrorCode.DeviceNotSupportMethod;
|
|
145
|
+
|
|
127
146
|
const updateMethodRequestContext = (method: BaseMethod, updates: any) => {
|
|
128
147
|
if (method.requestContext) {
|
|
129
148
|
updateRequestContext(method.requestContext.responseID, updates);
|
|
@@ -143,11 +162,16 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
143
162
|
}
|
|
144
163
|
|
|
145
164
|
// find api method
|
|
146
|
-
let method
|
|
165
|
+
let method!: BaseMethod;
|
|
147
166
|
try {
|
|
148
167
|
method = findMethod(message as IFrameCallMessage);
|
|
149
168
|
method.connector = _connector;
|
|
150
|
-
|
|
169
|
+
const shouldPostMessage = createUiProgressMessageFilter();
|
|
170
|
+
method.postMessage = event => {
|
|
171
|
+
if (shouldPostMessage(event)) {
|
|
172
|
+
postMessage(event);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
151
175
|
method.setContext?.(context);
|
|
152
176
|
|
|
153
177
|
method.requestContext = createRequestContext(method.responseID, method.name, {
|
|
@@ -159,11 +183,13 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
159
183
|
|
|
160
184
|
method.init();
|
|
161
185
|
} catch (error) {
|
|
162
|
-
|
|
186
|
+
if (method) {
|
|
187
|
+
completeMethodRequestContext(method, error);
|
|
188
|
+
method.dispose();
|
|
189
|
+
}
|
|
190
|
+
return createResponseMessage(method?.responseID ?? message.id, false, { error });
|
|
163
191
|
}
|
|
164
192
|
|
|
165
|
-
DevicePool.emitter.on(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
166
|
-
|
|
167
193
|
if (!method.useDevice) {
|
|
168
194
|
updateMethodRequestContext(method, { status: 'running' });
|
|
169
195
|
try {
|
|
@@ -270,13 +296,6 @@ const handlePreWarmSignal = async (
|
|
|
270
296
|
}
|
|
271
297
|
};
|
|
272
298
|
|
|
273
|
-
const waitWithTimeout = async (promise: Promise<any>, timeout: number) => {
|
|
274
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
275
|
-
setTimeout(() => reject(new Error('Request timeout')), timeout);
|
|
276
|
-
});
|
|
277
|
-
return Promise.race([promise, timeoutPromise]);
|
|
278
|
-
};
|
|
279
|
-
|
|
280
299
|
const waitForPendingPromise = async (
|
|
281
300
|
getPrePendingCallPromise: () => Promise<void> | undefined,
|
|
282
301
|
removePrePendingCallPromise?: (promise: Promise<void> | undefined) => void
|
|
@@ -285,9 +304,9 @@ const waitForPendingPromise = async (
|
|
|
285
304
|
if (pendingPromise) {
|
|
286
305
|
Log.debug('pre pending call promise before call method, wait for it');
|
|
287
306
|
try {
|
|
288
|
-
await
|
|
307
|
+
await pendingPromise;
|
|
289
308
|
} catch (error) {
|
|
290
|
-
//
|
|
309
|
+
// Cancellation is best-effort, but its teardown must settle before reuse.
|
|
291
310
|
}
|
|
292
311
|
removePrePendingCallPromise?.(pendingPromise);
|
|
293
312
|
Log.debug('pre pending call promise before call method done');
|
|
@@ -358,7 +377,7 @@ const onCallDevice = async (
|
|
|
358
377
|
);
|
|
359
378
|
} catch (e) {
|
|
360
379
|
preWarmCallbackTask?.resolve();
|
|
361
|
-
|
|
380
|
+
Log.debug('ensureConnected error: ', e);
|
|
362
381
|
|
|
363
382
|
completeMethodRequestContext(method, e);
|
|
364
383
|
|
|
@@ -395,18 +414,28 @@ const onCallDevice = async (
|
|
|
395
414
|
);
|
|
396
415
|
}
|
|
397
416
|
|
|
398
|
-
device
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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
|
+
});
|
|
405
428
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
429
|
+
device.on(DEVICE.STATE, onDeviceStateHandler);
|
|
406
430
|
device.on(
|
|
407
431
|
DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE,
|
|
408
432
|
onSelectDeviceInBootloaderForWebDeviceHandler
|
|
409
433
|
);
|
|
434
|
+
|
|
435
|
+
const protocolV2UiCoordinator = new ProtocolV2UiInteractionCoordinator(device, postMessage);
|
|
436
|
+
let protocolV2Operation = false;
|
|
437
|
+
let protocolV2CloseEmitted = false;
|
|
438
|
+
device.beginProtocolV2UiInteraction();
|
|
410
439
|
device.on(
|
|
411
440
|
DEVICE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE,
|
|
412
441
|
onSelectDeviceForSwitchFirmwareWebDeviceHandler
|
|
@@ -421,11 +450,10 @@ const onCallDevice = async (
|
|
|
421
450
|
await waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
422
451
|
|
|
423
452
|
const inner = async (): Promise<void> => {
|
|
424
|
-
// Protocol
|
|
425
|
-
//
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
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();
|
|
429
457
|
|
|
430
458
|
// check firmware version
|
|
431
459
|
const versionRange = device.getCurrentMethodVersionRange(
|
|
@@ -436,8 +464,8 @@ const onCallDevice = async (
|
|
|
436
464
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
437
465
|
let newVersionStatus: ReturnType<typeof DataManager.getFirmwareStatus> | undefined;
|
|
438
466
|
|
|
439
|
-
//
|
|
440
|
-
// Pro2
|
|
467
|
+
// Defective-batch and forced-update gates depend on V1 features/remote config.
|
|
468
|
+
// Pro2 joins after DataManager supports its profile firmwareStatus.
|
|
441
469
|
if (device.features && !device.isProtocolV2()) {
|
|
442
470
|
await DataManager.checkAndReloadData();
|
|
443
471
|
|
|
@@ -485,10 +513,6 @@ const onCallDevice = async (
|
|
|
485
513
|
}
|
|
486
514
|
}
|
|
487
515
|
|
|
488
|
-
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
489
|
-
throw createDeviceNotSupportMethodError(method.name, deviceFirmwareType);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
516
|
if (versionRange) {
|
|
493
517
|
if (semver.valid(versionRange.min) && semver.lt(currentFirmwareVersion, versionRange.min)) {
|
|
494
518
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
@@ -539,89 +563,102 @@ const onCallDevice = async (
|
|
|
539
563
|
);
|
|
540
564
|
}
|
|
541
565
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
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
|
+
}
|
|
553
585
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
586
|
+
/**
|
|
587
|
+
* check firmware release info
|
|
588
|
+
*/
|
|
589
|
+
method.checkFirmwareRelease();
|
|
558
590
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
591
|
+
/**
|
|
592
|
+
* check additional supported feature
|
|
593
|
+
*/
|
|
594
|
+
method.checkDeviceSupportFeature();
|
|
563
595
|
|
|
564
|
-
|
|
565
|
-
|
|
596
|
+
// reconfigure messages
|
|
597
|
+
if (_deviceList && device.features && !device.isProtocolV2()) {
|
|
598
|
+
await TransportManager.reconfigure(device.features);
|
|
599
|
+
}
|
|
566
600
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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
|
+
);
|
|
577
615
|
}
|
|
578
|
-
)
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
// Check Device passphrase State
|
|
583
|
-
const passphraseStateSafety = await device.checkPassphraseStateSafety(
|
|
584
|
-
method.payload?.passphraseState,
|
|
585
|
-
method.payload?.useEmptyPassphrase,
|
|
586
|
-
method.payload?.skipPassphraseCheck
|
|
587
|
-
);
|
|
588
616
|
|
|
589
|
-
|
|
590
|
-
|
|
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
|
+
);
|
|
591
624
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
return Promise.reject(
|
|
595
|
-
ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError)
|
|
596
|
-
);
|
|
597
|
-
}
|
|
625
|
+
// Double check, handles the special case of Touch/Pro
|
|
626
|
+
checkPassphraseEnableState(method, device.features);
|
|
598
627
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
628
|
+
if (!passphraseStateSafety) {
|
|
629
|
+
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
630
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
631
|
+
}
|
|
602
632
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
? e
|
|
610
|
-
: ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
611
|
-
// messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
612
|
-
// requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
613
|
-
// return;
|
|
614
|
-
throw error;
|
|
615
|
-
}
|
|
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
|
+
}
|
|
616
639
|
|
|
617
|
-
|
|
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
|
+
}
|
|
618
648
|
|
|
619
|
-
|
|
620
|
-
|
|
649
|
+
method.device?.commands?.checkDisposed();
|
|
650
|
+
},
|
|
651
|
+
});
|
|
621
652
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
622
653
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
623
654
|
completeMethodRequestContext(method);
|
|
624
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
|
+
}
|
|
625
662
|
Log.debug(`Call API - Inner Method Run Error`, error);
|
|
626
663
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
627
664
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
@@ -634,6 +671,13 @@ const onCallDevice = async (
|
|
|
634
671
|
) {
|
|
635
672
|
throw error;
|
|
636
673
|
}
|
|
674
|
+
} finally {
|
|
675
|
+
if (isProtocolV2UiEnabled(method)) {
|
|
676
|
+
protocolV2CloseEmitted = protocolV2UiCoordinator.close({
|
|
677
|
+
ensureOperationClose: protocolV2Operation,
|
|
678
|
+
protocolV2Operation,
|
|
679
|
+
});
|
|
680
|
+
}
|
|
637
681
|
}
|
|
638
682
|
};
|
|
639
683
|
Log.debug('Call API - Device Run: ', device.mainId);
|
|
@@ -649,7 +693,9 @@ const onCallDevice = async (
|
|
|
649
693
|
try {
|
|
650
694
|
return await task.callPromise.promise;
|
|
651
695
|
} catch (e) {
|
|
652
|
-
|
|
696
|
+
if (!isExpectedCompatibilityError(e)) {
|
|
697
|
+
Log.debug('Device Run Error: ', e);
|
|
698
|
+
}
|
|
653
699
|
completeMethodRequestContext(method, e);
|
|
654
700
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
655
701
|
}
|
|
@@ -687,7 +733,17 @@ const onCallDevice = async (
|
|
|
687
733
|
|
|
688
734
|
requestQueue.releaseTask(method.responseID);
|
|
689
735
|
|
|
690
|
-
|
|
736
|
+
if (isProtocolV2UiEnabled(method)) {
|
|
737
|
+
if (!protocolV2CloseEmitted && protocolV2Operation) {
|
|
738
|
+
protocolV2CloseEmitted = protocolV2UiCoordinator.close({
|
|
739
|
+
ensureOperationClose: true,
|
|
740
|
+
protocolV2Operation: true,
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
if (!protocolV2CloseEmitted) {
|
|
744
|
+
closePopup();
|
|
745
|
+
}
|
|
746
|
+
}
|
|
691
747
|
|
|
692
748
|
cleanup();
|
|
693
749
|
|
|
@@ -843,14 +899,38 @@ function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown)
|
|
|
843
899
|
);
|
|
844
900
|
}
|
|
845
901
|
|
|
902
|
+
function isMissingDetectedProtocolError(error: unknown) {
|
|
903
|
+
const typedError = error as { errorCode?: unknown; message?: unknown };
|
|
904
|
+
return (
|
|
905
|
+
typedError?.errorCode === HardwareErrorCode.RuntimeError &&
|
|
906
|
+
typeof typedError.message === 'string' &&
|
|
907
|
+
typedError.message.includes('Device protocol has not been detected')
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
|
|
846
911
|
/**
|
|
847
912
|
* If the Bluetooth connection times out, retry up to 6 times
|
|
848
913
|
* @param retryCount - Current retry count (default 0)
|
|
849
914
|
*/
|
|
850
915
|
async function connectDeviceForBle(method: BaseMethod, device: Device, retryCount = 0) {
|
|
851
916
|
try {
|
|
852
|
-
|
|
917
|
+
if (method.payload.forceProtocolDetection && device.hasDeviceAcquire()) {
|
|
918
|
+
await device.release();
|
|
919
|
+
}
|
|
920
|
+
const shouldAcquire =
|
|
921
|
+
method.payload.forceProtocolDetection ||
|
|
922
|
+
!device.hasDeviceAcquire() ||
|
|
923
|
+
!device.commands ||
|
|
924
|
+
device.commands.disposed;
|
|
925
|
+
if (shouldAcquire) {
|
|
926
|
+
await device.acquire(method.payload.connectProtocol, {
|
|
927
|
+
forceProtocolDetection: method.payload.forceProtocolDetection,
|
|
928
|
+
});
|
|
929
|
+
}
|
|
853
930
|
if (method.payload?.onlyConnectBleDevice) {
|
|
931
|
+
if (shouldAcquire) {
|
|
932
|
+
DevicePool.emitter.emit(DEVICE.CONNECT, device);
|
|
933
|
+
}
|
|
854
934
|
return;
|
|
855
935
|
}
|
|
856
936
|
// Skip initialize if conditions are met
|
|
@@ -861,15 +941,35 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
861
941
|
passphraseState: initOptions.passphraseState,
|
|
862
942
|
});
|
|
863
943
|
}
|
|
944
|
+
if (shouldAcquire) {
|
|
945
|
+
DevicePool.emitter.emit(DEVICE.CONNECT, device);
|
|
946
|
+
}
|
|
864
947
|
} catch (err) {
|
|
948
|
+
const requiresColdReconnect = isMissingDetectedProtocolError(err);
|
|
949
|
+
// Device.run()'s REQUIRE_DISCONNECT handling never sees acquire/initialize
|
|
950
|
+
// failures, so with keep-alive a wedged link would be reused by every retry
|
|
951
|
+
// (field case: Initialize timing out at 25s per attempt, forever). Drop it
|
|
952
|
+
// here so the next retry cold-connects.
|
|
953
|
+
if (
|
|
954
|
+
(ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) || requiresColdReconnect) &&
|
|
955
|
+
device.mainId &&
|
|
956
|
+
device.deviceConnector
|
|
957
|
+
) {
|
|
958
|
+
await device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
959
|
+
// The connector only drops the link; `deviceAcquired` is reset by
|
|
960
|
+
// release()/markTransportDisconnected() alone. Leaving it set makes the
|
|
961
|
+
// next attempt skip acquire and initialize onto the link we just cut.
|
|
962
|
+
device.markTransportDisconnected();
|
|
963
|
+
}
|
|
865
964
|
if (
|
|
866
965
|
(err.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
867
966
|
err.errorCode === HardwareErrorCode.BleConnectedError ||
|
|
868
|
-
isRetryableBleProtocolV2ProbeError(method, err)
|
|
967
|
+
isRetryableBleProtocolV2ProbeError(method, err) ||
|
|
968
|
+
requiresColdReconnect) &&
|
|
869
969
|
retryCount < 6
|
|
870
970
|
) {
|
|
871
971
|
const nextRetry = retryCount + 1;
|
|
872
|
-
Log.debug(`Bluetooth
|
|
972
|
+
Log.debug(`Bluetooth connection will retry, retry count: ${nextRetry}`);
|
|
873
973
|
await wait(3000);
|
|
874
974
|
await connectDeviceForBle(method, device, nextRetry);
|
|
875
975
|
} else {
|
|
@@ -983,6 +1083,19 @@ const ensureConnected = async (
|
|
|
983
1083
|
}
|
|
984
1084
|
} catch (error) {
|
|
985
1085
|
Log.debug('device error: ', error);
|
|
1086
|
+
if (error.errorCode === HardwareErrorCode.BleUnavailableWhileUsbConnected) {
|
|
1087
|
+
reject(error);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
if (isProtocolV2LinkDisabledError(error)) {
|
|
1091
|
+
reject(
|
|
1092
|
+
ERRORS.TypedError(HardwareErrorCode.BleUnavailableWhileUsbConnected, undefined, {
|
|
1093
|
+
failureCode: error.failureCode,
|
|
1094
|
+
firmwareMessage: error.firmwareMessage,
|
|
1095
|
+
})
|
|
1096
|
+
);
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
986
1099
|
if ([HardwareErrorCode.BleCharacteristicNotifyChangeFailure].includes(error.errorCode)) {
|
|
987
1100
|
postMessage(createUiMessage(UI_REQUEST.BLUETOOTH_CHARACTERISTIC_NOTIFY_CHANGE_FAILURE));
|
|
988
1101
|
}
|
|
@@ -1155,14 +1268,16 @@ const shouldCheckPassphraseState = (method: BaseMethod, device: Device) => {
|
|
|
1155
1268
|
};
|
|
1156
1269
|
|
|
1157
1270
|
const cleanup = () => {
|
|
1271
|
+
const pendingUiPromises = _uiPromises;
|
|
1158
1272
|
_uiPromises = [];
|
|
1159
|
-
|
|
1273
|
+
rejectUiPromises(
|
|
1274
|
+
pendingUiPromises,
|
|
1275
|
+
ERRORS.TypedError(HardwareErrorCode.ActionCancelled, 'UI request was cancelled')
|
|
1276
|
+
);
|
|
1160
1277
|
};
|
|
1161
1278
|
|
|
1162
1279
|
const removeDeviceListener = (device: Device) => {
|
|
1163
1280
|
device.removeAllListeners();
|
|
1164
|
-
DevicePool.emitter.removeAllListeners(DEVICE.CONNECT);
|
|
1165
|
-
// DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
1166
1281
|
};
|
|
1167
1282
|
|
|
1168
1283
|
/**
|
|
@@ -1173,19 +1288,33 @@ const closePopup = () => {
|
|
|
1173
1288
|
};
|
|
1174
1289
|
|
|
1175
1290
|
const onDeviceConnectHandler = (device: Device) => {
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject
|
|
1291
|
+
const deviceObject = device.toMessageObject();
|
|
1292
|
+
if (!deviceObject) return;
|
|
1293
|
+
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject }));
|
|
1179
1294
|
};
|
|
1180
1295
|
|
|
1181
1296
|
const onDeviceDisconnectHandler = (device: Device) => {
|
|
1182
1297
|
device.clearPreInitialized();
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1185
|
-
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject
|
|
1298
|
+
const deviceObject = device.toMessageObject();
|
|
1299
|
+
if (!deviceObject) return;
|
|
1300
|
+
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
const onTransportDeviceDisconnectHandler = (event: TransportDeviceDisconnectEvent) => {
|
|
1304
|
+
const device =
|
|
1305
|
+
deviceCacheMap.get(event.connectId) ??
|
|
1306
|
+
DevicePool.devicesCache[event.connectId] ??
|
|
1307
|
+
DevicePool.getDeviceByPath(event.connectId);
|
|
1308
|
+
if (!device) {
|
|
1309
|
+
Log.debug('Ignoring transport disconnect for an unknown device:', event.connectId);
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
device.markTransportDisconnected();
|
|
1314
|
+
DevicePool.emitter.emit(DEVICE.DISCONNECT, device);
|
|
1186
1315
|
};
|
|
1187
1316
|
|
|
1188
|
-
const onDevicePinHandler =
|
|
1317
|
+
const onDevicePinHandler = (...[device, type, callback]: DeviceEvents['pin']) => {
|
|
1189
1318
|
Log.log('request Input PIN');
|
|
1190
1319
|
// create ui promise
|
|
1191
1320
|
const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PIN, device);
|
|
@@ -1194,12 +1323,14 @@ const onDevicePinHandler = async (...[device, type, callback]: DeviceEvents['pin
|
|
|
1194
1323
|
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1195
1324
|
device: device.toMessageObject() as unknown as KnownDevice,
|
|
1196
1325
|
type,
|
|
1326
|
+
responseCorrelation: uiPromise.responseCorrelation,
|
|
1197
1327
|
})
|
|
1198
1328
|
);
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1329
|
+
consumeUiPromise(
|
|
1330
|
+
uiPromise.promise,
|
|
1331
|
+
uiResp => callback(null, uiResp.payload),
|
|
1332
|
+
error => callback(error, '')
|
|
1333
|
+
);
|
|
1203
1334
|
};
|
|
1204
1335
|
|
|
1205
1336
|
export const onDeviceButtonHandler = (...[device, request]: [...DeviceEvents['button']]) => {
|
|
@@ -1223,7 +1354,11 @@ const onDeviceFeaturesHandler = (...[_, features]: [...DeviceEvents['features']]
|
|
|
1223
1354
|
postMessage(createDeviceMessage(DEVICE.FEATURES, { ...features }));
|
|
1224
1355
|
};
|
|
1225
1356
|
|
|
1226
|
-
const
|
|
1357
|
+
const onDeviceStateHandler = (...[_, stateEvent]: [...DeviceEvents['state']]) => {
|
|
1358
|
+
postMessage(createDeviceMessage(DEVICE.STATE, stateEvent));
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
const onDevicePassphraseHandler = (
|
|
1227
1362
|
...[device, requestPayload, callback]: DeviceEvents['passphrase']
|
|
1228
1363
|
) => {
|
|
1229
1364
|
Log.debug('onDevicePassphraseHandler');
|
|
@@ -1233,18 +1368,27 @@ const onDevicePassphraseHandler = async (
|
|
|
1233
1368
|
device: device.toMessageObject() as KnownDevice,
|
|
1234
1369
|
passphraseState: device.passphraseState,
|
|
1235
1370
|
existsAttachPinUser: requestPayload.existsAttachPinUser,
|
|
1371
|
+
deviceOnly: requestPayload.deviceOnly,
|
|
1372
|
+
source: requestPayload.source,
|
|
1373
|
+
reason: requestPayload.reason,
|
|
1374
|
+
expectedPassphraseState: requestPayload.expectedPassphraseState,
|
|
1375
|
+
...(requestPayload.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1376
|
+
responseCorrelation: uiPromise.responseCorrelation,
|
|
1236
1377
|
})
|
|
1237
1378
|
);
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1379
|
+
consumeUiPromise(
|
|
1380
|
+
uiPromise.promise,
|
|
1381
|
+
uiResp => {
|
|
1382
|
+
const { value, passphraseOnDevice, save, attachPinOnDevice } = uiResp.payload;
|
|
1383
|
+
callback({
|
|
1384
|
+
passphrase: value.normalize('NFKD'),
|
|
1385
|
+
passphraseOnDevice,
|
|
1386
|
+
attachPinOnDevice,
|
|
1387
|
+
cache: save,
|
|
1388
|
+
});
|
|
1389
|
+
},
|
|
1390
|
+
error => callback({}, error)
|
|
1391
|
+
);
|
|
1248
1392
|
};
|
|
1249
1393
|
|
|
1250
1394
|
const onEmptyPassphraseHandler = (...[_, , callback]: DeviceEvents['passphrase']) => {
|
|
@@ -1254,17 +1398,62 @@ const onEmptyPassphraseHandler = (...[_, , callback]: DeviceEvents['passphrase']
|
|
|
1254
1398
|
};
|
|
1255
1399
|
|
|
1256
1400
|
const onEnterPassphraseOnDeviceHandler = (
|
|
1257
|
-
...[device]: [...DeviceEvents['passphrase_on_device']]
|
|
1401
|
+
...[device, requestPayload]: [...DeviceEvents['passphrase_on_device']]
|
|
1258
1402
|
) => {
|
|
1259
1403
|
postMessage(
|
|
1260
1404
|
createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
1261
1405
|
device: device.toMessageObject() as KnownDevice,
|
|
1262
1406
|
passphraseState: device.passphraseState,
|
|
1407
|
+
source: requestPayload?.source,
|
|
1408
|
+
reason: requestPayload?.reason,
|
|
1409
|
+
...(requestPayload?.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1410
|
+
})
|
|
1411
|
+
);
|
|
1412
|
+
};
|
|
1413
|
+
|
|
1414
|
+
const onEnterAttachPinOnDeviceHandler = (
|
|
1415
|
+
...[device, requestPayload]: [...DeviceEvents['attach_pin_on_device']]
|
|
1416
|
+
) => {
|
|
1417
|
+
postMessage(
|
|
1418
|
+
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1419
|
+
device: device.toMessageObject() as KnownDevice,
|
|
1420
|
+
type: 'ButtonRequest_AttachPin',
|
|
1421
|
+
source: requestPayload?.source,
|
|
1422
|
+
reason: requestPayload?.reason,
|
|
1423
|
+
...(requestPayload?.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1263
1424
|
})
|
|
1264
1425
|
);
|
|
1265
1426
|
};
|
|
1266
1427
|
|
|
1267
|
-
const
|
|
1428
|
+
const onEnterPinOnDeviceHandler = (
|
|
1429
|
+
...[device, pinType, metadata]: [...DeviceEvents['pin_on_device']]
|
|
1430
|
+
) => {
|
|
1431
|
+
postMessage(
|
|
1432
|
+
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1433
|
+
device: device.toMessageObject() as KnownDevice,
|
|
1434
|
+
type:
|
|
1435
|
+
pinType === DeviceSessionPinType.AttachToPin
|
|
1436
|
+
? 'ButtonRequest_AttachPin'
|
|
1437
|
+
: 'ButtonRequest_PinEntry',
|
|
1438
|
+
source: metadata?.source,
|
|
1439
|
+
reason: metadata?.reason,
|
|
1440
|
+
deviceOnly: metadata?.deviceOnly ?? true,
|
|
1441
|
+
completion: metadata?.completion,
|
|
1442
|
+
method: metadata?.method,
|
|
1443
|
+
page: metadata?.page,
|
|
1444
|
+
operation: metadata?.operation,
|
|
1445
|
+
...(metadata?.interaction ? { interaction: metadata.interaction } : {}),
|
|
1446
|
+
})
|
|
1447
|
+
);
|
|
1448
|
+
};
|
|
1449
|
+
|
|
1450
|
+
const onPinOnDeviceCompleteHandler = (
|
|
1451
|
+
...[_, metadata]: [...DeviceEvents['pin_on_device_complete']]
|
|
1452
|
+
) => {
|
|
1453
|
+
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW, metadata));
|
|
1454
|
+
};
|
|
1455
|
+
|
|
1456
|
+
const onSelectDeviceInBootloaderForWebDeviceHandler = (
|
|
1268
1457
|
...[device, callback]: [...DeviceEvents['select_device_in_bootloader_for_web_device']]
|
|
1269
1458
|
) => {
|
|
1270
1459
|
Log.debug('onSelectDeviceInBootloaderForWebDeviceHandler');
|
|
@@ -1274,11 +1463,14 @@ const onSelectDeviceInBootloaderForWebDeviceHandler = async (
|
|
|
1274
1463
|
device: device.toMessageObject() as KnownDevice,
|
|
1275
1464
|
})
|
|
1276
1465
|
);
|
|
1277
|
-
|
|
1278
|
-
|
|
1466
|
+
consumeUiPromise(
|
|
1467
|
+
uiPromise.promise,
|
|
1468
|
+
uiResp => callback(null, uiResp.payload.deviceId),
|
|
1469
|
+
error => callback(error, '')
|
|
1470
|
+
);
|
|
1279
1471
|
};
|
|
1280
1472
|
|
|
1281
|
-
const onSelectDeviceForSwitchFirmwareWebDeviceHandler =
|
|
1473
|
+
const onSelectDeviceForSwitchFirmwareWebDeviceHandler = (
|
|
1282
1474
|
...[device, callback]: [...DeviceEvents['select_device_for_switch_firmware_web_device']]
|
|
1283
1475
|
) => {
|
|
1284
1476
|
Log.debug('onSelectDeviceForSwitchFirmwareWebDeviceHandler');
|
|
@@ -1291,8 +1483,11 @@ const onSelectDeviceForSwitchFirmwareWebDeviceHandler = async (
|
|
|
1291
1483
|
device: device.toMessageObject() as KnownDevice,
|
|
1292
1484
|
})
|
|
1293
1485
|
);
|
|
1294
|
-
|
|
1295
|
-
|
|
1486
|
+
consumeUiPromise(
|
|
1487
|
+
uiPromise.promise,
|
|
1488
|
+
uiResp => callback(null, uiResp.payload.deviceId),
|
|
1489
|
+
error => callback(error, '')
|
|
1490
|
+
);
|
|
1296
1491
|
};
|
|
1297
1492
|
|
|
1298
1493
|
/**
|
|
@@ -1311,14 +1506,21 @@ const postMessage = (message: CoreMessage) => {
|
|
|
1311
1506
|
|
|
1312
1507
|
const createUiPromise = <T extends UiPromiseResponse['type']>(promiseEvent: T, device?: Device) => {
|
|
1313
1508
|
const uiPromise: UiPromise<T> = createDeferred(promiseEvent, device);
|
|
1509
|
+
if (
|
|
1510
|
+
device &&
|
|
1511
|
+
(promiseEvent === UI_RESPONSE.RECEIVE_PIN || promiseEvent === UI_RESPONSE.RECEIVE_PASSPHRASE)
|
|
1512
|
+
) {
|
|
1513
|
+
const publicDeviceId = device.toMessageObject()?.deviceId;
|
|
1514
|
+
uiPromise.responseCorrelation = {
|
|
1515
|
+
interactionId: generateInstanceId('UiResponse', device.sdkInstanceId),
|
|
1516
|
+
deviceId: publicDeviceId || device.instanceId,
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1314
1519
|
_uiPromises.push(uiPromise as any);
|
|
1315
1520
|
|
|
1316
1521
|
return uiPromise;
|
|
1317
1522
|
};
|
|
1318
1523
|
|
|
1319
|
-
const findUiPromise = <T extends UiPromiseResponse['type']>(promiseEvent: T) =>
|
|
1320
|
-
_uiPromises.find(p => p.id === promiseEvent);
|
|
1321
|
-
|
|
1322
1524
|
const removeUiPromise = (promise: Deferred<any>) => {
|
|
1323
1525
|
_uiPromises = _uiPromises.filter(p => p !== promise);
|
|
1324
1526
|
};
|
|
@@ -1330,6 +1532,8 @@ export default class Core extends EventEmitter {
|
|
|
1330
1532
|
|
|
1331
1533
|
private requestQueue = new RequestQueue();
|
|
1332
1534
|
|
|
1535
|
+
private disposePromise?: Promise<void>;
|
|
1536
|
+
|
|
1333
1537
|
// background task
|
|
1334
1538
|
private prePendingCallPromise: Promise<void> | undefined;
|
|
1335
1539
|
|
|
@@ -1342,10 +1546,6 @@ export default class Core extends EventEmitter {
|
|
|
1342
1546
|
Log.debug(`[Core] Created SDK instance: ${this.sdkInstanceId}`);
|
|
1343
1547
|
}
|
|
1344
1548
|
|
|
1345
|
-
cancelOperation(operationId: string) {
|
|
1346
|
-
this.requestQueue.abortOperation(operationId);
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
1549
|
private getCoreContext() {
|
|
1350
1550
|
return {
|
|
1351
1551
|
sdkInstanceId: this.sdkInstanceId,
|
|
@@ -1372,11 +1572,16 @@ export default class Core extends EventEmitter {
|
|
|
1372
1572
|
case UI_RESPONSE.RECEIVE_PASSPHRASE:
|
|
1373
1573
|
case UI_RESPONSE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE:
|
|
1374
1574
|
case UI_RESPONSE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE: {
|
|
1375
|
-
const uiPromise =
|
|
1575
|
+
const uiPromise = findUiPromiseForResponse(_uiPromises, message);
|
|
1376
1576
|
if (uiPromise) {
|
|
1377
1577
|
Log.log('receive UI Response: ', message.type);
|
|
1378
1578
|
uiPromise.resolve(message);
|
|
1379
1579
|
removeUiPromise(uiPromise);
|
|
1580
|
+
} else if (
|
|
1581
|
+
message.type === UI_RESPONSE.RECEIVE_PIN ||
|
|
1582
|
+
message.type === UI_RESPONSE.RECEIVE_PASSPHRASE
|
|
1583
|
+
) {
|
|
1584
|
+
Log.warn('Ignored unmatched or ambiguous sensitive UI response:', message.type);
|
|
1380
1585
|
}
|
|
1381
1586
|
break;
|
|
1382
1587
|
}
|
|
@@ -1392,10 +1597,17 @@ export default class Core extends EventEmitter {
|
|
|
1392
1597
|
}
|
|
1393
1598
|
|
|
1394
1599
|
case IFRAME.CALL: {
|
|
1395
|
-
|
|
1600
|
+
const logBlockLabel = getLogBlockLabel(message);
|
|
1601
|
+
Log.log(
|
|
1602
|
+
formatLogMethodLabel(`[${Date.now()}][CALL_API]`, logBlockLabel),
|
|
1603
|
+
getSafeLogPayload(message, logBlockLabel)
|
|
1604
|
+
);
|
|
1396
1605
|
const response = await callAPI(this.getCoreContext(), message);
|
|
1397
1606
|
const { success, payload } = response;
|
|
1398
|
-
Log.log(
|
|
1607
|
+
Log.log(
|
|
1608
|
+
formatLogMethodLabel(`[${Date.now()}][CALL_API_RESPONSE]`, logBlockLabel),
|
|
1609
|
+
getSafeLogPayload(response, logBlockLabel)
|
|
1610
|
+
);
|
|
1399
1611
|
if (success) {
|
|
1400
1612
|
return response;
|
|
1401
1613
|
}
|
|
@@ -1414,10 +1626,6 @@ export default class Core extends EventEmitter {
|
|
|
1414
1626
|
cancel(this.getCoreContext(), message.payload.connectId);
|
|
1415
1627
|
break;
|
|
1416
1628
|
}
|
|
1417
|
-
case IFRAME.CANCEL_OPERATION: {
|
|
1418
|
-
this.cancelOperation(message.payload.operationId);
|
|
1419
|
-
break;
|
|
1420
|
-
}
|
|
1421
1629
|
case IFRAME.CALLBACK: {
|
|
1422
1630
|
Log.log('callback message: ', message);
|
|
1423
1631
|
postMessage(message);
|
|
@@ -1429,25 +1637,65 @@ export default class Core extends EventEmitter {
|
|
|
1429
1637
|
return Promise.resolve(message);
|
|
1430
1638
|
}
|
|
1431
1639
|
|
|
1432
|
-
dispose() {
|
|
1640
|
+
dispose(): Promise<void> {
|
|
1641
|
+
if (!this.disposePromise) {
|
|
1642
|
+
this.disposePromise = this.disposeResources();
|
|
1643
|
+
}
|
|
1644
|
+
return this.disposePromise;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
private async disposeResources(): Promise<void> {
|
|
1648
|
+
Log.debug(`[Core] Disposing SDK instance: ${this.sdkInstanceId}`);
|
|
1649
|
+
pollingManager.stopAll();
|
|
1650
|
+
this.requestQueue.abortAllRequests();
|
|
1651
|
+
cleanup();
|
|
1652
|
+
|
|
1653
|
+
_connector?.stop();
|
|
1654
|
+
let transportCleanup: Promise<void>;
|
|
1655
|
+
try {
|
|
1656
|
+
transportCleanup = Promise.resolve(TransportManager.getTransport()?.stop?.()).catch(error => {
|
|
1657
|
+
Log.warn('[Core] Transport cleanup failed:', error);
|
|
1658
|
+
});
|
|
1659
|
+
} catch (error) {
|
|
1660
|
+
Log.warn('[Core] Transport cleanup failed:', error);
|
|
1661
|
+
transportCleanup = Promise.resolve();
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
// Preserve synchronous dispose semantics for in-memory state and listeners.
|
|
1433
1665
|
_deviceList = undefined;
|
|
1434
1666
|
_connector = undefined;
|
|
1667
|
+
DevicePool.dispose();
|
|
1435
1668
|
deviceCacheMap.clear();
|
|
1436
1669
|
preWarmInflight.clear();
|
|
1437
1670
|
preWarmDoneAt.clear();
|
|
1438
|
-
|
|
1671
|
+
preConnectCache = { passphraseState: undefined };
|
|
1672
|
+
this.prePendingCallPromise = undefined;
|
|
1673
|
+
this.removeAllListeners();
|
|
1439
1674
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
1675
|
+
if (_core === this) _core = undefined;
|
|
1676
|
+
|
|
1677
|
+
// Transports, especially Node USB, may release native handles asynchronously.
|
|
1678
|
+
await transportCleanup;
|
|
1440
1679
|
}
|
|
1441
1680
|
}
|
|
1442
1681
|
|
|
1443
1682
|
export const initCore = () => {
|
|
1444
|
-
|
|
1445
|
-
|
|
1683
|
+
const core = new Core();
|
|
1684
|
+
_core = core;
|
|
1685
|
+
return core;
|
|
1446
1686
|
};
|
|
1447
1687
|
|
|
1448
1688
|
export const initConnector = () => {
|
|
1449
1689
|
_connector = new DeviceConnector();
|
|
1690
|
+
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
1691
|
+
DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
1692
|
+
DevicePool.emitter.removeListener(
|
|
1693
|
+
TRANSPORT_EVENT.DEVICE_DISCONNECT,
|
|
1694
|
+
onTransportDeviceDisconnectHandler
|
|
1695
|
+
);
|
|
1696
|
+
DevicePool.emitter.on(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
1450
1697
|
DevicePool.emitter.on(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
1698
|
+
DevicePool.emitter.on(TRANSPORT_EVENT.DEVICE_DISCONNECT, onTransportDeviceDisconnectHandler);
|
|
1451
1699
|
return _connector;
|
|
1452
1700
|
};
|
|
1453
1701
|
|
|
@@ -1461,12 +1709,8 @@ export const init = async (
|
|
|
1461
1709
|
plugin?: LowlevelTransportSharedPlugin
|
|
1462
1710
|
) => {
|
|
1463
1711
|
try {
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
initTransport(Transport, plugin);
|
|
1467
|
-
} catch {
|
|
1468
|
-
Log.error('DataManager.load error');
|
|
1469
|
-
}
|
|
1712
|
+
await DataManager.load(settings);
|
|
1713
|
+
initTransport(Transport, plugin);
|
|
1470
1714
|
enableLog(DataManager.getSettings('debug'));
|
|
1471
1715
|
if (DataManager.getSettings('env') !== 'react-native') {
|
|
1472
1716
|
setLoggerPostMessage(postMessage);
|
|
@@ -1477,6 +1721,7 @@ export const init = async (
|
|
|
1477
1721
|
return _core;
|
|
1478
1722
|
} catch (error) {
|
|
1479
1723
|
Log.error('core init', error);
|
|
1724
|
+
throw error;
|
|
1480
1725
|
}
|
|
1481
1726
|
};
|
|
1482
1727
|
|