@onekeyfe/hd-core 1.2.0-alpha.4 → 1.2.0-alpha.40
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 +155 -0
- package/__tests__/DeviceCommands.test.ts +517 -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 +282 -0
- package/__tests__/connectSettings.test.ts +19 -0
- package/__tests__/core-dispose.test.ts +34 -0
- package/__tests__/core-error-output.test.ts +39 -0
- package/__tests__/device-features-state.test.ts +78 -0
- package/__tests__/device-identity.test.ts +52 -0
- package/__tests__/device-lifecycle-events.test.ts +249 -0
- package/__tests__/device-pool-state.test.ts +144 -0
- package/__tests__/device-settings.test.ts +416 -0
- package/__tests__/device-state-contract.test.ts +27 -0
- package/__tests__/device-state-events.test.ts +286 -0
- package/__tests__/device-state-mapper.test.ts +261 -0
- package/__tests__/device-state-projector.test.ts +94 -0
- package/__tests__/device-state-store.test.ts +82 -0
- package/__tests__/device-utils.test.ts +107 -0
- package/__tests__/device-wallet-session-store.test.ts +478 -0
- package/__tests__/deviceFeaturesUtils.test.ts +39 -0
- package/__tests__/deviceSettings.test.ts +103 -0
- package/__tests__/deviceUploadNft.test.ts +187 -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-update/firmware-update-v2-download-before-boot.test.ts +402 -0
- package/__tests__/get-device-state.test.ts +578 -0
- package/__tests__/homescreen.test.ts +64 -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 +601 -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 +113 -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 +1609 -0
- package/__tests__/pro2Nft.test.ts +108 -0
- package/__tests__/pro2Wallpaper.test.ts +39 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +37 -0
- package/__tests__/protocol-v2-ping.test.ts +28 -0
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +56 -0
- package/__tests__/protocol-v2-unlock-policy.test.ts +96 -0
- package/__tests__/protocol-v2.test.ts +5748 -2387
- package/__tests__/protocolV2FileWrite.test.ts +92 -0
- package/__tests__/protocolV2UiInteraction.test.ts +266 -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 +136 -0
- package/__tests__/tron-sign-message-init.test.ts +74 -0
- package/__tests__/uiProgressThrottle.test.ts +74 -0
- package/dist/api/BaseMethod.d.ts +16 -1
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +24 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/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/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 +2 -2
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +23 -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 +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 +1 -0
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -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/getBinary.d.ts +8 -4
- package/dist/api/firmware/getBinary.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 +35 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
- package/dist/api/index.d.ts +8 -25
- 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 +1 -0
- 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/protocol-v2/DeviceFactoryInfoGet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +4 -2
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
- 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 +27 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -1
- package/dist/api/protocol-v2/Ping.d.ts +3 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts +4 -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 +1 -0
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -0
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +1 -0
- 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 +1 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +1 -0
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +1 -0
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +1 -0
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +1 -0
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +1 -0
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +1 -0
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +1 -0
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +1 -0
- 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 +5 -0
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +1 -0
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/utils.d.ts +2 -1
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/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/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +64 -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 +1 -1
- 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 +5 -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-request.d.ts +46 -4
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +1442 -712
- package/dist/index.js +7497 -3705
- package/dist/inject.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 +25 -17
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +1 -0
- 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/settingsUnlockPolicy.d.ts +17 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +39 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/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 +25 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -0
- package/dist/types/api/checkAllFirmwareRelease.d.ts +25 -4
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +3 -2
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +6 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- 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 +19 -30
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/kaspaSignTransaction.d.ts +42 -4
- package/dist/types/api/kaspaSignTransaction.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +35 -0
- package/dist/types/api/openWalletSession.d.ts.map +1 -0
- package/dist/types/api/protocolV2.d.ts +18 -84
- 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 +132 -8
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +7 -14
- 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 +13 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -0
- package/dist/utils/deviceFeaturesUtils.d.ts +8 -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 +29 -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 +296 -1
- package/src/api/CheckBootloaderRelease.ts +1 -2
- package/src/api/CheckFirmwareRelease.ts +1 -2
- package/src/api/CipherKeyValue.ts +4 -0
- package/src/api/ClearSessionCache.ts +32 -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 +15 -9
- package/src/api/FileWrite.ts +26 -181
- package/src/api/FirmwareUpdate.ts +11 -12
- package/src/api/FirmwareUpdateV2.ts +132 -52
- package/src/api/FirmwareUpdateV3.ts +3 -11
- package/src/api/FirmwareUpdateV4.ts +693 -535
- package/src/api/GetDeviceState.ts +59 -0
- package/src/api/GetFeatures.ts +6 -4
- package/src/api/GetOnekeyFeatures.ts +1 -75
- package/src/api/GetPassphraseState.ts +36 -21
- package/src/api/OpenWalletSession.ts +251 -0
- package/src/api/PathInfo.ts +9 -4
- package/src/api/PromptWebDeviceAccess.ts +2 -7
- package/src/api/SearchDevices.ts +29 -4
- package/src/api/UploadPortfolio.ts +40 -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/AllNetworkGetAddressBase.ts +41 -32
- package/src/api/aptos/AptosGetAddress.ts +4 -0
- package/src/api/aptos/AptosGetPublicKey.ts +4 -0
- package/src/api/aptos/AptosSignInMessage.ts +4 -0
- package/src/api/aptos/AptosSignMessage.ts +4 -0
- package/src/api/aptos/AptosSignTransaction.ts +4 -0
- package/src/api/benfen/BenfenGetAddress.ts +11 -7
- package/src/api/benfen/BenfenGetPublicKey.ts +0 -4
- package/src/api/benfen/BenfenSignMessage.ts +0 -4
- package/src/api/benfen/BenfenSignTransaction.ts +0 -4
- package/src/api/btc/BTCGetAddress.ts +8 -1
- package/src/api/btc/BTCGetPublicKey.ts +9 -2
- package/src/api/btc/BTCSignMessage.ts +8 -1
- package/src/api/btc/BTCSignPsbt.ts +4 -0
- package/src/api/btc/BTCSignTransaction.ts +8 -1
- package/src/api/btc/BTCVerifyMessage.ts +8 -1
- package/src/api/btc/helpers/versionLimit.ts +7 -4
- package/src/api/cardano/CardanoGetAddress.ts +4 -0
- package/src/api/cardano/CardanoGetPublicKey.ts +4 -0
- package/src/api/cardano/CardanoSignMessage.ts +5 -1
- package/src/api/cardano/CardanoSignTransaction.ts +5 -1
- package/src/api/conflux/ConfluxGetAddress.ts +6 -0
- package/src/api/conflux/ConfluxSignMessage.ts +6 -0
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +6 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +8 -5
- package/src/api/cosmos/CosmosGetAddress.ts +4 -0
- package/src/api/cosmos/CosmosGetPublicKey.ts +4 -0
- package/src/api/cosmos/CosmosSignTransaction.ts +4 -0
- package/src/api/device/DeviceCancel.ts +5 -0
- package/src/api/device/DeviceChangePin.ts +28 -0
- package/src/api/device/DeviceFullyUploadResource.ts +4 -5
- package/src/api/device/DeviceLock.ts +5 -0
- package/src/api/device/DeviceRebootToBoardloader.ts +5 -0
- package/src/api/device/DeviceRebootToBootloader.ts +5 -0
- package/src/api/device/DeviceSettings.ts +194 -1
- package/src/api/device/DeviceSupportFeatures.ts +4 -0
- package/src/api/device/DeviceUnlock.ts +14 -1
- package/src/api/device/DeviceUpdateBootloader.ts +1 -2
- 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/FirmwareUpdateBaseMethod.ts +3 -3
- package/src/api/firmware/getBinary.ts +8 -3
- 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 +206 -0
- package/src/api/index.ts +9 -26
- package/src/api/kaspa/KaspaGetAddress.ts +7 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +380 -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/protocol-v2/DeviceFactoryInfoGet.ts +5 -2
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +5 -2
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +8 -5
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +43 -5
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +21 -0
- package/src/api/protocol-v2/DeviceInfoGet.ts +8 -15
- package/src/api/protocol-v2/DeviceReboot.ts +7 -3
- package/src/api/protocol-v2/DeviceStatusGet.ts +19 -0
- package/src/api/protocol-v2/DeviceUploadNft.ts +166 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +134 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +9 -3
- 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 +21 -16
- 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 +4 -0
- package/src/api/solana/SolSignOffchainMessage.ts +4 -0
- package/src/api/solana/SolSignTransaction.ts +4 -0
- 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 +4 -0
- package/src/api/sui/SuiGetPublicKey.ts +4 -0
- package/src/api/sui/SuiSignMessage.ts +4 -0
- package/src/api/sui/SuiSignTransaction.ts +4 -0
- package/src/api/ton/TonGetAddress.ts +4 -0
- package/src/api/ton/TonSignData.ts +5 -1
- package/src/api/ton/TonSignMessage.ts +4 -0
- package/src/api/ton/TonSignProof.ts +4 -0
- package/src/api/tron/TronGetAddress.ts +4 -0
- package/src/api/tron/TronSignMessage.ts +18 -7
- package/src/api/tron/TronSignTransaction.ts +4 -0
- package/src/api/utils.ts +7 -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 +274 -120
- package/src/data/messages/messages-protocol-v2.json +1161 -477
- package/src/data/messages/messages.json +286 -1
- package/src/data-manager/DataManager.ts +6 -6
- package/src/data-manager/TransportManager.ts +1 -1
- package/src/data-manager/connectSettings.ts +4 -0
- package/src/device/Device.ts +820 -282
- package/src/device/DeviceCommands.ts +166 -158
- package/src/device/DeviceConnector.ts +10 -7
- package/src/device/DeviceFeaturesState.ts +25 -0
- package/src/device/DevicePool.ts +66 -16
- package/src/device/DeviceStateMapper.ts +374 -0
- package/src/device/DeviceStateProjector.ts +94 -0
- package/src/device/DeviceStateStore.ts +201 -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 +224 -190
- package/src/deviceProfile/index.ts +0 -1
- package/src/deviceProfile/protocolV2DeviceIdentity.ts +32 -0
- package/src/events/device.ts +22 -1
- package/src/events/logBlockEvent.ts +80 -2
- package/src/events/ui-request.ts +57 -4
- package/src/inject.ts +16 -41
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +103 -32
- package/src/protocols/protocol-v2/firmware.ts +2 -1
- package/src/protocols/protocol-v2/index.ts +8 -1
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +65 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +236 -0
- package/src/protocols/protocol-v2/unlockPolicy.ts +1 -0
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +117 -0
- package/src/protocols/protocol-v2/walletSession.ts +360 -0
- package/src/types/api/checkAllFirmwareRelease.ts +46 -4
- package/src/types/api/deviceSettings.ts +26 -2
- package/src/types/api/deviceUnlock.ts +1 -1
- package/src/types/api/export.ts +8 -0
- package/src/types/api/firmwareUpdate.ts +23 -5
- 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 +27 -64
- package/src/types/api/kaspaSignTransaction.ts +60 -4
- package/src/types/api/openWalletSession.ts +54 -0
- package/src/types/api/protocolV2.ts +33 -139
- package/src/types/api/sessionCache.ts +19 -0
- package/src/types/device.ts +185 -7
- package/src/types/params.ts +3 -2
- package/src/types/settings.ts +17 -16
- package/src/utils/assets.ts +4 -1
- package/src/utils/deviceFeaturesCompat.ts +180 -0
- package/src/utils/deviceFeaturesUtils.ts +56 -45
- package/src/utils/deviceInfoUtils.ts +27 -69
- package/src/utils/deviceSettings.ts +171 -39
- package/src/utils/deviceVersionUtils.ts +25 -44
- package/src/utils/findDefectiveBatchDevice.ts +3 -3
- package/src/utils/homescreen.ts +36 -0
- package/src/utils/index.ts +27 -3
- package/src/utils/networkUtils.ts +274 -16
- package/src/utils/pro2Nft.ts +91 -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/FilesystemDiskControl.d.ts +0 -13
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts +0 -21
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +0 -1
- package/dist/types/api/getDeviceInfo.d.ts +0 -87
- package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
- package/src/api/GetDeviceInfo.ts +0 -145
- package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
- package/src/deviceProfile/buildDeviceProfile.ts +0 -352
- package/src/types/api/getDeviceInfo.ts +0 -101
package/src/core/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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,
|
|
5
6
|
ERROR_CODES_REQUIRE_RELEASE,
|
|
@@ -14,14 +15,7 @@ import {
|
|
|
14
15
|
createNewFirmwareUnReleaseHardwareError,
|
|
15
16
|
} from '@onekeyfe/hd-shared';
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
-
LoggerNames,
|
|
19
|
-
enableLog,
|
|
20
|
-
getLogger,
|
|
21
|
-
isMethodVersionRangeUnsupported,
|
|
22
|
-
setLoggerPostMessage,
|
|
23
|
-
wait,
|
|
24
|
-
} from '../utils';
|
|
18
|
+
import { LoggerNames, enableLog, getLogger, setLoggerPostMessage, wait } from '../utils';
|
|
25
19
|
import {
|
|
26
20
|
findDefectiveBatchDevice,
|
|
27
21
|
getDefectiveDeviceInfo,
|
|
@@ -36,6 +30,7 @@ import {
|
|
|
36
30
|
updateRequestContext,
|
|
37
31
|
} from '../utils/tracing';
|
|
38
32
|
import { Device } from '../device/Device';
|
|
33
|
+
import { checkLiveDeviceId } from '../device/deviceIdentity';
|
|
39
34
|
import { DeviceList } from '../device/DeviceList';
|
|
40
35
|
import { DevicePool } from '../device/DevicePool';
|
|
41
36
|
import { PollingStateManager } from './PollingStateManager';
|
|
@@ -51,18 +46,32 @@ import {
|
|
|
51
46
|
createDeviceMessage,
|
|
52
47
|
createResponseMessage,
|
|
53
48
|
createUiMessage,
|
|
49
|
+
formatLogMethodLabel,
|
|
50
|
+
getLogBlockLabel,
|
|
51
|
+
getSafeLogPayload,
|
|
54
52
|
} from '../events';
|
|
55
53
|
import TransportManager from '../data-manager/TransportManager';
|
|
56
54
|
import DeviceConnector from '../device/DeviceConnector';
|
|
57
55
|
import RequestQueue from './RequestQueue';
|
|
56
|
+
import { registerHardwareUiEventListeners } from './deviceEventRegistration';
|
|
58
57
|
import { getSynchronize } from '../utils/getSynchronize';
|
|
58
|
+
import { runMethodWithUnlockPolicy } from '../protocols/protocol-v2/unlockPolicyRunner';
|
|
59
|
+
import {
|
|
60
|
+
ProtocolV2UiInteractionCoordinator,
|
|
61
|
+
isProtocolV2UiEnabled,
|
|
62
|
+
} from '../protocols/protocol-v2/uiInteraction';
|
|
63
|
+
import { createUiProgressMessageFilter } from '../utils/uiProgressThrottle';
|
|
59
64
|
|
|
60
65
|
import type { ConnectSettings, Features, KnownDevice } from '../types';
|
|
61
66
|
import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
|
|
62
67
|
import type { DeviceEvents, InitOptions, RunOptions } from '../device/Device';
|
|
63
68
|
import type { SdkTracingContext } from '../utils/tracing';
|
|
64
69
|
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
65
|
-
import type {
|
|
70
|
+
import type {
|
|
71
|
+
LowlevelTransportSharedPlugin,
|
|
72
|
+
OneKeyDeviceInfo,
|
|
73
|
+
TransportDeviceDisconnectEvent,
|
|
74
|
+
} from '@onekeyfe/hd-transport';
|
|
66
75
|
import type { BaseMethod } from '../api/BaseMethod';
|
|
67
76
|
|
|
68
77
|
const Log = getLogger(LoggerNames.Core);
|
|
@@ -91,14 +100,14 @@ function hasDeriveCardano(method: BaseMethod): boolean {
|
|
|
91
100
|
|
|
92
101
|
const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
93
102
|
initSession: method?.payload.initSession,
|
|
94
|
-
passphraseState: method?.payload.passphraseState,
|
|
103
|
+
passphraseState: method?.payload.useEmptyPassphrase ? undefined : method?.payload.passphraseState,
|
|
95
104
|
deviceId: method?.payload.deviceId,
|
|
96
105
|
deriveCardano: method && hasDeriveCardano(method),
|
|
97
106
|
connectProtocol: method?.payload.connectProtocol,
|
|
98
107
|
protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
|
|
99
108
|
});
|
|
100
109
|
|
|
101
|
-
let _core: Core;
|
|
110
|
+
let _core: Core | undefined;
|
|
102
111
|
let _deviceList: DeviceList | undefined;
|
|
103
112
|
let _connector: DeviceConnector | undefined;
|
|
104
113
|
let _uiPromises: UiPromise<UiPromiseResponse['type']>[] = []; // Waiting for ui response
|
|
@@ -142,11 +151,16 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
142
151
|
}
|
|
143
152
|
|
|
144
153
|
// find api method
|
|
145
|
-
let method
|
|
154
|
+
let method!: BaseMethod;
|
|
146
155
|
try {
|
|
147
156
|
method = findMethod(message as IFrameCallMessage);
|
|
148
157
|
method.connector = _connector;
|
|
149
|
-
|
|
158
|
+
const shouldPostMessage = createUiProgressMessageFilter();
|
|
159
|
+
method.postMessage = event => {
|
|
160
|
+
if (shouldPostMessage(event)) {
|
|
161
|
+
postMessage(event);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
150
164
|
method.setContext?.(context);
|
|
151
165
|
|
|
152
166
|
method.requestContext = createRequestContext(method.responseID, method.name, {
|
|
@@ -158,11 +172,13 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
158
172
|
|
|
159
173
|
method.init();
|
|
160
174
|
} catch (error) {
|
|
161
|
-
|
|
175
|
+
if (method) {
|
|
176
|
+
completeMethodRequestContext(method, error);
|
|
177
|
+
method.dispose();
|
|
178
|
+
}
|
|
179
|
+
return createResponseMessage(method?.responseID ?? message.id, false, { error });
|
|
162
180
|
}
|
|
163
181
|
|
|
164
|
-
DevicePool.emitter.on(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
165
|
-
|
|
166
182
|
if (!method.useDevice) {
|
|
167
183
|
updateMethodRequestContext(method, { status: 'running' });
|
|
168
184
|
try {
|
|
@@ -357,7 +373,7 @@ const onCallDevice = async (
|
|
|
357
373
|
);
|
|
358
374
|
} catch (e) {
|
|
359
375
|
preWarmCallbackTask?.resolve();
|
|
360
|
-
|
|
376
|
+
Log.debug('ensureConnected error: ', e);
|
|
361
377
|
|
|
362
378
|
completeMethodRequestContext(method, e);
|
|
363
379
|
|
|
@@ -394,18 +410,26 @@ const onCallDevice = async (
|
|
|
394
410
|
);
|
|
395
411
|
}
|
|
396
412
|
|
|
397
|
-
device
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
413
|
+
registerHardwareUiEventListeners(device, {
|
|
414
|
+
pin: onDevicePinHandler,
|
|
415
|
+
pinOnDevice: onEnterPinOnDeviceHandler,
|
|
416
|
+
pinOnDeviceComplete: onPinOnDeviceCompleteHandler,
|
|
417
|
+
button: onDeviceButtonHandler,
|
|
418
|
+
passphrase: message.payload.useEmptyPassphrase
|
|
419
|
+
? onEmptyPassphraseHandler
|
|
420
|
+
: onDevicePassphraseHandler,
|
|
421
|
+
passphraseOnDevice: onEnterPassphraseOnDeviceHandler,
|
|
422
|
+
attachPinOnDevice: onEnterAttachPinOnDeviceHandler,
|
|
423
|
+
});
|
|
404
424
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
425
|
+
device.on(DEVICE.STATE, onDeviceStateHandler);
|
|
405
426
|
device.on(
|
|
406
427
|
DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE,
|
|
407
428
|
onSelectDeviceInBootloaderForWebDeviceHandler
|
|
408
429
|
);
|
|
430
|
+
|
|
431
|
+
const protocolV2UiCoordinator = new ProtocolV2UiInteractionCoordinator(device, postMessage);
|
|
432
|
+
device.beginProtocolV2UiInteraction();
|
|
409
433
|
device.on(
|
|
410
434
|
DEVICE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE,
|
|
411
435
|
onSelectDeviceForSwitchFirmwareWebDeviceHandler
|
|
@@ -420,11 +444,9 @@ const onCallDevice = async (
|
|
|
420
444
|
await waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
421
445
|
|
|
422
446
|
const inner = async (): Promise<void> => {
|
|
423
|
-
// Protocol
|
|
424
|
-
//
|
|
425
|
-
|
|
426
|
-
throw createDeviceNotSupportMethodError(method.name, device.getCurrentFirmwareType());
|
|
427
|
-
}
|
|
447
|
+
// Protocol is established from an active device response during acquire/initialize.
|
|
448
|
+
// Reject unsupported methods before any method-specific device command is sent.
|
|
449
|
+
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
428
450
|
|
|
429
451
|
// check firmware version
|
|
430
452
|
const versionRange = device.getCurrentMethodVersionRange(
|
|
@@ -435,8 +457,8 @@ const onCallDevice = async (
|
|
|
435
457
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
436
458
|
let newVersionStatus: ReturnType<typeof DataManager.getFirmwareStatus> | undefined;
|
|
437
459
|
|
|
438
|
-
//
|
|
439
|
-
// Pro2
|
|
460
|
+
// Defective-batch and forced-update gates depend on V1 features/remote config.
|
|
461
|
+
// Pro2 joins after DataManager supports its profile firmwareStatus.
|
|
440
462
|
if (device.features && !device.isProtocolV2()) {
|
|
441
463
|
await DataManager.checkAndReloadData();
|
|
442
464
|
|
|
@@ -484,10 +506,6 @@ const onCallDevice = async (
|
|
|
484
506
|
}
|
|
485
507
|
}
|
|
486
508
|
|
|
487
|
-
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
488
|
-
throw createDeviceNotSupportMethodError(method.name, deviceFirmwareType);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
509
|
if (versionRange) {
|
|
492
510
|
if (semver.valid(versionRange.min) && semver.lt(currentFirmwareVersion, versionRange.min)) {
|
|
493
511
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
@@ -538,85 +556,92 @@ const onCallDevice = async (
|
|
|
538
556
|
);
|
|
539
557
|
}
|
|
540
558
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
559
|
+
try {
|
|
560
|
+
let deviceIdCheckedDuringUnlockPreflight = false;
|
|
561
|
+
const response = await runMethodWithUnlockPolicy<object>(method, device, {
|
|
562
|
+
uiCoordinator: protocolV2UiCoordinator,
|
|
563
|
+
afterStatusBeforeUnlock: () => {
|
|
564
|
+
if (method.deviceId && method.checkDeviceId) {
|
|
565
|
+
if (!device.checkDeviceId(method.deviceId)) {
|
|
566
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
567
|
+
}
|
|
568
|
+
deviceIdCheckedDuringUnlockPreflight = true;
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
prepare: async () => {
|
|
572
|
+
if (method.deviceId && method.checkDeviceId && !deviceIdCheckedDuringUnlockPreflight) {
|
|
573
|
+
const isSameDeviceID = await checkLiveDeviceId(device, method.deviceId);
|
|
574
|
+
if (!isSameDeviceID) {
|
|
575
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
552
578
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
579
|
+
/**
|
|
580
|
+
* check firmware release info
|
|
581
|
+
*/
|
|
582
|
+
method.checkFirmwareRelease();
|
|
557
583
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
584
|
+
/**
|
|
585
|
+
* check additional supported feature
|
|
586
|
+
*/
|
|
587
|
+
method.checkDeviceSupportFeature();
|
|
562
588
|
|
|
563
|
-
|
|
564
|
-
|
|
589
|
+
// reconfigure messages
|
|
590
|
+
if (_deviceList && device.features && !device.isProtocolV2()) {
|
|
591
|
+
await TransportManager.reconfigure(device.features);
|
|
592
|
+
}
|
|
565
593
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
594
|
+
// Check to see if it is safe to use Passphrase
|
|
595
|
+
checkPassphraseEnableState(method, device.features);
|
|
596
|
+
|
|
597
|
+
if (shouldCheckPassphraseState(method, device)) {
|
|
598
|
+
// check version
|
|
599
|
+
const support = device.supportNewPassphrase();
|
|
600
|
+
if (!support.support) {
|
|
601
|
+
throw ERRORS.TypedError(
|
|
602
|
+
HardwareErrorCode.DeviceNotSupportPassphrase,
|
|
603
|
+
`Device not support passphrase, please update to ${support.require}`,
|
|
604
|
+
{
|
|
605
|
+
require: support.require,
|
|
606
|
+
}
|
|
607
|
+
);
|
|
576
608
|
}
|
|
577
|
-
)
|
|
578
|
-
);
|
|
579
|
-
}
|
|
580
609
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
// Double check, handles the special case of Touch/Pro
|
|
589
|
-
checkPassphraseEnableState(method, device.features);
|
|
610
|
+
// Check Device passphrase State after the Protocol V2 pre-unlock gate.
|
|
611
|
+
const passphraseStateSafety = await device.checkPassphraseStateSafety(
|
|
612
|
+
method.payload?.passphraseState,
|
|
613
|
+
method.payload?.useEmptyPassphrase,
|
|
614
|
+
method.payload?.skipPassphraseCheck,
|
|
615
|
+
hasDeriveCardano(method)
|
|
616
|
+
);
|
|
590
617
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
return Promise.reject(
|
|
594
|
-
ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError)
|
|
595
|
-
);
|
|
596
|
-
}
|
|
618
|
+
// Double check, handles the special case of Touch/Pro
|
|
619
|
+
checkPassphraseEnableState(method, device.features);
|
|
597
620
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
621
|
+
if (!passphraseStateSafety) {
|
|
622
|
+
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
623
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
624
|
+
}
|
|
601
625
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
? e
|
|
609
|
-
: ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
610
|
-
// messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
611
|
-
// requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
612
|
-
// return;
|
|
613
|
-
throw error;
|
|
614
|
-
}
|
|
626
|
+
// Protocol V2 emits the PIN phase completion from DeviceSessionAskPin.
|
|
627
|
+
// Keep the legacy compatibility close for Protocol V1 only.
|
|
628
|
+
if (!device.isProtocolV2()) {
|
|
629
|
+
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW));
|
|
630
|
+
}
|
|
631
|
+
}
|
|
615
632
|
|
|
616
|
-
|
|
633
|
+
// Automatic check safety_check level for Kovan, Ropsten, Rinkeby, Goerli test networks.
|
|
634
|
+
try {
|
|
635
|
+
await method.checkSafetyLevelOnTestNet();
|
|
636
|
+
} catch (e) {
|
|
637
|
+
throw e instanceof HardwareError
|
|
638
|
+
? e
|
|
639
|
+
: ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
640
|
+
}
|
|
617
641
|
|
|
618
|
-
|
|
619
|
-
|
|
642
|
+
method.device?.commands?.checkDisposed();
|
|
643
|
+
},
|
|
644
|
+
});
|
|
620
645
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
621
646
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
622
647
|
completeMethodRequestContext(method);
|
|
@@ -633,6 +658,8 @@ const onCallDevice = async (
|
|
|
633
658
|
) {
|
|
634
659
|
throw error;
|
|
635
660
|
}
|
|
661
|
+
} finally {
|
|
662
|
+
protocolV2UiCoordinator.close();
|
|
636
663
|
}
|
|
637
664
|
};
|
|
638
665
|
Log.debug('Call API - Device Run: ', device.mainId);
|
|
@@ -686,7 +713,9 @@ const onCallDevice = async (
|
|
|
686
713
|
|
|
687
714
|
requestQueue.releaseTask(method.responseID);
|
|
688
715
|
|
|
689
|
-
|
|
716
|
+
if (isProtocolV2UiEnabled(method)) {
|
|
717
|
+
closePopup();
|
|
718
|
+
}
|
|
690
719
|
|
|
691
720
|
cleanup();
|
|
692
721
|
|
|
@@ -848,8 +877,15 @@ function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown)
|
|
|
848
877
|
*/
|
|
849
878
|
async function connectDeviceForBle(method: BaseMethod, device: Device, retryCount = 0) {
|
|
850
879
|
try {
|
|
851
|
-
|
|
880
|
+
const shouldAcquire =
|
|
881
|
+
!device.hasDeviceAcquire() || !device.commands || device.commands.disposed;
|
|
882
|
+
if (shouldAcquire) {
|
|
883
|
+
await device.acquire(method.payload.connectProtocol);
|
|
884
|
+
}
|
|
852
885
|
if (method.payload?.onlyConnectBleDevice) {
|
|
886
|
+
if (shouldAcquire) {
|
|
887
|
+
DevicePool.emitter.emit(DEVICE.CONNECT, device);
|
|
888
|
+
}
|
|
853
889
|
return;
|
|
854
890
|
}
|
|
855
891
|
// Skip initialize if conditions are met
|
|
@@ -860,6 +896,9 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
860
896
|
passphraseState: initOptions.passphraseState,
|
|
861
897
|
});
|
|
862
898
|
}
|
|
899
|
+
if (shouldAcquire) {
|
|
900
|
+
DevicePool.emitter.emit(DEVICE.CONNECT, device);
|
|
901
|
+
}
|
|
863
902
|
} catch (err) {
|
|
864
903
|
if (
|
|
865
904
|
(err.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
@@ -1160,8 +1199,6 @@ const cleanup = () => {
|
|
|
1160
1199
|
|
|
1161
1200
|
const removeDeviceListener = (device: Device) => {
|
|
1162
1201
|
device.removeAllListeners();
|
|
1163
|
-
DevicePool.emitter.removeAllListeners(DEVICE.CONNECT);
|
|
1164
|
-
// DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
1165
1202
|
};
|
|
1166
1203
|
|
|
1167
1204
|
/**
|
|
@@ -1172,16 +1209,30 @@ const closePopup = () => {
|
|
|
1172
1209
|
};
|
|
1173
1210
|
|
|
1174
1211
|
const onDeviceConnectHandler = (device: Device) => {
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject
|
|
1212
|
+
const deviceObject = device.toMessageObject();
|
|
1213
|
+
if (!deviceObject) return;
|
|
1214
|
+
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject }));
|
|
1178
1215
|
};
|
|
1179
1216
|
|
|
1180
1217
|
const onDeviceDisconnectHandler = (device: Device) => {
|
|
1181
1218
|
device.clearPreInitialized();
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1184
|
-
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject
|
|
1219
|
+
const deviceObject = device.toMessageObject();
|
|
1220
|
+
if (!deviceObject) return;
|
|
1221
|
+
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|
|
1222
|
+
};
|
|
1223
|
+
|
|
1224
|
+
const onTransportDeviceDisconnectHandler = (event: TransportDeviceDisconnectEvent) => {
|
|
1225
|
+
const device =
|
|
1226
|
+
deviceCacheMap.get(event.connectId) ??
|
|
1227
|
+
DevicePool.devicesCache[event.connectId] ??
|
|
1228
|
+
DevicePool.getDeviceByPath(event.connectId);
|
|
1229
|
+
if (!device) {
|
|
1230
|
+
Log.debug('Ignoring transport disconnect for an unknown device:', event.connectId);
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
device.markTransportDisconnected();
|
|
1235
|
+
DevicePool.emitter.emit(DEVICE.DISCONNECT, device);
|
|
1185
1236
|
};
|
|
1186
1237
|
|
|
1187
1238
|
const onDevicePinHandler = async (...[device, type, callback]: DeviceEvents['pin']) => {
|
|
@@ -1222,6 +1273,10 @@ const onDeviceFeaturesHandler = (...[_, features]: [...DeviceEvents['features']]
|
|
|
1222
1273
|
postMessage(createDeviceMessage(DEVICE.FEATURES, { ...features }));
|
|
1223
1274
|
};
|
|
1224
1275
|
|
|
1276
|
+
const onDeviceStateHandler = (...[_, stateEvent]: [...DeviceEvents['state']]) => {
|
|
1277
|
+
postMessage(createDeviceMessage(DEVICE.STATE, stateEvent));
|
|
1278
|
+
};
|
|
1279
|
+
|
|
1225
1280
|
const onDevicePassphraseHandler = async (
|
|
1226
1281
|
...[device, requestPayload, callback]: DeviceEvents['passphrase']
|
|
1227
1282
|
) => {
|
|
@@ -1232,6 +1287,11 @@ const onDevicePassphraseHandler = async (
|
|
|
1232
1287
|
device: device.toMessageObject() as KnownDevice,
|
|
1233
1288
|
passphraseState: device.passphraseState,
|
|
1234
1289
|
existsAttachPinUser: requestPayload.existsAttachPinUser,
|
|
1290
|
+
deviceOnly: requestPayload.deviceOnly,
|
|
1291
|
+
source: requestPayload.source,
|
|
1292
|
+
reason: requestPayload.reason,
|
|
1293
|
+
expectedPassphraseState: requestPayload.expectedPassphraseState,
|
|
1294
|
+
...(requestPayload.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1235
1295
|
})
|
|
1236
1296
|
);
|
|
1237
1297
|
// wait for passphrase
|
|
@@ -1253,16 +1313,61 @@ const onEmptyPassphraseHandler = (...[_, , callback]: DeviceEvents['passphrase']
|
|
|
1253
1313
|
};
|
|
1254
1314
|
|
|
1255
1315
|
const onEnterPassphraseOnDeviceHandler = (
|
|
1256
|
-
...[device]: [...DeviceEvents['passphrase_on_device']]
|
|
1316
|
+
...[device, requestPayload]: [...DeviceEvents['passphrase_on_device']]
|
|
1257
1317
|
) => {
|
|
1258
1318
|
postMessage(
|
|
1259
1319
|
createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
1260
1320
|
device: device.toMessageObject() as KnownDevice,
|
|
1261
1321
|
passphraseState: device.passphraseState,
|
|
1322
|
+
source: requestPayload?.source,
|
|
1323
|
+
reason: requestPayload?.reason,
|
|
1324
|
+
...(requestPayload?.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1325
|
+
})
|
|
1326
|
+
);
|
|
1327
|
+
};
|
|
1328
|
+
|
|
1329
|
+
const onEnterAttachPinOnDeviceHandler = (
|
|
1330
|
+
...[device, requestPayload]: [...DeviceEvents['attach_pin_on_device']]
|
|
1331
|
+
) => {
|
|
1332
|
+
postMessage(
|
|
1333
|
+
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1334
|
+
device: device.toMessageObject() as KnownDevice,
|
|
1335
|
+
type: 'ButtonRequest_AttachPin',
|
|
1336
|
+
source: requestPayload?.source,
|
|
1337
|
+
reason: requestPayload?.reason,
|
|
1338
|
+
...(requestPayload?.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1262
1339
|
})
|
|
1263
1340
|
);
|
|
1264
1341
|
};
|
|
1265
1342
|
|
|
1343
|
+
const onEnterPinOnDeviceHandler = (
|
|
1344
|
+
...[device, pinType, metadata]: [...DeviceEvents['pin_on_device']]
|
|
1345
|
+
) => {
|
|
1346
|
+
postMessage(
|
|
1347
|
+
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1348
|
+
device: device.toMessageObject() as KnownDevice,
|
|
1349
|
+
type:
|
|
1350
|
+
pinType === DeviceSessionPinType.AttachToPin
|
|
1351
|
+
? 'ButtonRequest_AttachPin'
|
|
1352
|
+
: 'ButtonRequest_PinEntry',
|
|
1353
|
+
source: metadata?.source,
|
|
1354
|
+
reason: metadata?.reason,
|
|
1355
|
+
deviceOnly: metadata?.deviceOnly ?? true,
|
|
1356
|
+
completion: metadata?.completion,
|
|
1357
|
+
method: metadata?.method,
|
|
1358
|
+
page: metadata?.page,
|
|
1359
|
+
operation: metadata?.operation,
|
|
1360
|
+
...(metadata?.interaction ? { interaction: metadata.interaction } : {}),
|
|
1361
|
+
})
|
|
1362
|
+
);
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
const onPinOnDeviceCompleteHandler = (
|
|
1366
|
+
...[_, metadata]: [...DeviceEvents['pin_on_device_complete']]
|
|
1367
|
+
) => {
|
|
1368
|
+
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW, metadata));
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1266
1371
|
const onSelectDeviceInBootloaderForWebDeviceHandler = async (
|
|
1267
1372
|
...[device, callback]: [...DeviceEvents['select_device_in_bootloader_for_web_device']]
|
|
1268
1373
|
) => {
|
|
@@ -1329,6 +1434,8 @@ export default class Core extends EventEmitter {
|
|
|
1329
1434
|
|
|
1330
1435
|
private requestQueue = new RequestQueue();
|
|
1331
1436
|
|
|
1437
|
+
private disposePromise?: Promise<void>;
|
|
1438
|
+
|
|
1332
1439
|
// background task
|
|
1333
1440
|
private prePendingCallPromise: Promise<void> | undefined;
|
|
1334
1441
|
|
|
@@ -1387,10 +1494,17 @@ export default class Core extends EventEmitter {
|
|
|
1387
1494
|
}
|
|
1388
1495
|
|
|
1389
1496
|
case IFRAME.CALL: {
|
|
1390
|
-
|
|
1497
|
+
const logBlockLabel = getLogBlockLabel(message);
|
|
1498
|
+
Log.log(
|
|
1499
|
+
formatLogMethodLabel(`[${Date.now()}][CALL_API]`, logBlockLabel),
|
|
1500
|
+
getSafeLogPayload(message, logBlockLabel)
|
|
1501
|
+
);
|
|
1391
1502
|
const response = await callAPI(this.getCoreContext(), message);
|
|
1392
1503
|
const { success, payload } = response;
|
|
1393
|
-
Log.log(
|
|
1504
|
+
Log.log(
|
|
1505
|
+
formatLogMethodLabel(`[${Date.now()}][CALL_API_RESPONSE]`, logBlockLabel),
|
|
1506
|
+
getSafeLogPayload(response, logBlockLabel)
|
|
1507
|
+
);
|
|
1394
1508
|
if (success) {
|
|
1395
1509
|
return response;
|
|
1396
1510
|
}
|
|
@@ -1420,25 +1534,65 @@ export default class Core extends EventEmitter {
|
|
|
1420
1534
|
return Promise.resolve(message);
|
|
1421
1535
|
}
|
|
1422
1536
|
|
|
1423
|
-
dispose() {
|
|
1537
|
+
dispose(): Promise<void> {
|
|
1538
|
+
if (!this.disposePromise) {
|
|
1539
|
+
this.disposePromise = this.disposeResources();
|
|
1540
|
+
}
|
|
1541
|
+
return this.disposePromise;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
private async disposeResources(): Promise<void> {
|
|
1545
|
+
Log.debug(`[Core] Disposing SDK instance: ${this.sdkInstanceId}`);
|
|
1546
|
+
pollingManager.stopAll();
|
|
1547
|
+
this.requestQueue.abortAllRequests();
|
|
1548
|
+
cleanup();
|
|
1549
|
+
|
|
1550
|
+
_connector?.stop();
|
|
1551
|
+
let transportCleanup: Promise<void>;
|
|
1552
|
+
try {
|
|
1553
|
+
transportCleanup = Promise.resolve(TransportManager.getTransport()?.stop?.()).catch(error => {
|
|
1554
|
+
Log.warn('[Core] Transport cleanup failed:', error);
|
|
1555
|
+
});
|
|
1556
|
+
} catch (error) {
|
|
1557
|
+
Log.warn('[Core] Transport cleanup failed:', error);
|
|
1558
|
+
transportCleanup = Promise.resolve();
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
// Preserve synchronous dispose semantics for in-memory state and listeners.
|
|
1424
1562
|
_deviceList = undefined;
|
|
1425
1563
|
_connector = undefined;
|
|
1564
|
+
DevicePool.dispose();
|
|
1426
1565
|
deviceCacheMap.clear();
|
|
1427
1566
|
preWarmInflight.clear();
|
|
1428
1567
|
preWarmDoneAt.clear();
|
|
1429
|
-
|
|
1568
|
+
preConnectCache = { passphraseState: undefined };
|
|
1569
|
+
this.prePendingCallPromise = undefined;
|
|
1570
|
+
this.removeAllListeners();
|
|
1430
1571
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
1572
|
+
if (_core === this) _core = undefined;
|
|
1573
|
+
|
|
1574
|
+
// Transports, especially Node USB, may release native handles asynchronously.
|
|
1575
|
+
await transportCleanup;
|
|
1431
1576
|
}
|
|
1432
1577
|
}
|
|
1433
1578
|
|
|
1434
1579
|
export const initCore = () => {
|
|
1435
|
-
|
|
1436
|
-
|
|
1580
|
+
const core = new Core();
|
|
1581
|
+
_core = core;
|
|
1582
|
+
return core;
|
|
1437
1583
|
};
|
|
1438
1584
|
|
|
1439
1585
|
export const initConnector = () => {
|
|
1440
1586
|
_connector = new DeviceConnector();
|
|
1587
|
+
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
1588
|
+
DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
1589
|
+
DevicePool.emitter.removeListener(
|
|
1590
|
+
TRANSPORT_EVENT.DEVICE_DISCONNECT,
|
|
1591
|
+
onTransportDeviceDisconnectHandler
|
|
1592
|
+
);
|
|
1593
|
+
DevicePool.emitter.on(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
1441
1594
|
DevicePool.emitter.on(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
1595
|
+
DevicePool.emitter.on(TRANSPORT_EVENT.DEVICE_DISCONNECT, onTransportDeviceDisconnectHandler);
|
|
1442
1596
|
return _connector;
|
|
1443
1597
|
};
|
|
1444
1598
|
|