@onekeyfe/hd-core 1.2.0-alpha.4 → 1.2.0-alpha.41
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 +77 -0
- package/__tests__/DeviceCommands.test.ts +517 -0
- package/__tests__/DeviceEventRegistration.test.ts +43 -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 +61 -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__/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/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +213 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +430 -0
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +458 -0
- package/__tests__/homescreen.test.ts +24 -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 +1368 -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-unlock-policy.test.ts +45 -0
- package/__tests__/protocol-v2.test.ts +6082 -2422
- 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 +106 -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/dist/api/BaseMethod.d.ts +14 -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 +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 +42 -16
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts +8 -0
- package/dist/api/GetDeviceState.d.ts.map +1 -0
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +2 -6
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts +8 -0
- package/dist/api/OpenWalletSession.d.ts.map +1 -0
- package/dist/api/PathInfo.d.ts +1 -0
- package/dist/api/PathInfo.d.ts.map +1 -1
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +3 -0
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +17 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -0
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/algo/AlgoGetAddress.d.ts +1 -0
- package/dist/api/algo/AlgoGetAddress.d.ts.map +1 -1
- package/dist/api/algo/AlgoSignTransaction.d.ts +1 -0
- package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +1 -0
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts +1 -0
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetPublicKey.d.ts +1 -0
- package/dist/api/aptos/AptosGetPublicKey.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignInMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignTransaction.d.ts +1 -0
- package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -0
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -0
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -0
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts +1 -0
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -0
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -0
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -0
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetAddress.d.ts +1 -0
- package/dist/api/cardano/CardanoGetAddress.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetPublicKey.d.ts +1 -0
- package/dist/api/cardano/CardanoGetPublicKey.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignMessage.d.ts +1 -0
- package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts +1 -0
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxGetAddress.d.ts +2 -0
- package/dist/api/conflux/ConfluxGetAddress.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessage.d.ts +2 -0
- package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts +2 -0
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts +2 -0
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosGetAddress.d.ts +1 -0
- package/dist/api/cosmos/CosmosGetAddress.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosGetPublicKey.d.ts +1 -0
- package/dist/api/cosmos/CosmosGetPublicKey.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosSignTransaction.d.ts +1 -0
- package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceCancel.d.ts +1 -0
- package/dist/api/device/DeviceCancel.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts +1 -0
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts +1 -2
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.d.ts +1 -0
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -0
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts +1 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts +1 -0
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceSupportFeatures.d.ts +1 -0
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -0
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts +1 -0
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/device/PreInitialize.d.ts +1 -0
- package/dist/api/device/PreInitialize.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMGetAddress.d.ts +1 -0
- package/dist/api/evm/EVMGetAddress.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts +1 -0
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessage.d.ts +1 -0
- package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts +1 -0
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts +1 -0
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/EVMVerifyMessage.d.ts +1 -0
- package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -1
- package/dist/api/evm/protocol.d.ts +3 -0
- package/dist/api/evm/protocol.d.ts.map +1 -0
- package/dist/api/filecoin/FilecoinGetAddress.d.ts +1 -0
- package/dist/api/filecoin/FilecoinGetAddress.d.ts.map +1 -1
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts +1 -0
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +8 -0
- 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 +25 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +30 -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/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/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 +33 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
- package/dist/api/index.d.ts +7 -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/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 +2 -3
- 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 +11 -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/DataManager.d.ts +1 -0
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +44 -14
- 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 +12 -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 +19 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +1559 -736
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9238 -3898
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/deviceSession.d.ts +7 -0
- package/dist/protocols/protocol-v2/deviceSession.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/features.d.ts +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/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.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 +39 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +4 -0
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +22 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -0
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +29 -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/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +6 -2
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +75 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/getDeviceState.d.ts +12 -0
- package/dist/types/api/getDeviceState.d.ts.map +1 -0
- package/dist/types/api/getFeatures.d.ts.map +1 -1
- package/dist/types/api/getOnekeyFeatures.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +2 -10
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +27 -31
- 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 +15 -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 +20 -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 +6 -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.map +1 -1
- package/dist/utils/index.d.ts +5 -2
- 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/pro2Wallpaper.d.ts +12 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -0
- package/dist/utils/tracing.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +52 -17
- package/src/api/CheckAllFirmwareRelease.ts +344 -4
- 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 +370 -112
- package/src/api/FirmwareUpdateV3.ts +266 -68
- package/src/api/FirmwareUpdateV4.ts +1276 -651
- 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 +30 -21
- package/src/api/OpenWalletSession.ts +214 -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 +9 -21
- 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 +13 -0
- package/src/api/device/DeviceUpdateBootloader.ts +123 -8
- package/src/api/device/DeviceWipe.ts +25 -0
- package/src/api/device/PreInitialize.ts +4 -0
- package/src/api/dynex/DnxGetAddress.ts +0 -6
- package/src/api/dynex/DnxSignTransaction.ts +0 -6
- package/src/api/evm/EVMGetAddress.ts +6 -2
- package/src/api/evm/EVMGetPublicKey.ts +6 -2
- package/src/api/evm/EVMSignMessage.ts +6 -2
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -11
- package/src/api/evm/EVMSignTransaction.ts +6 -2
- package/src/api/evm/EVMSignTypedData.ts +42 -50
- package/src/api/evm/EVMVerifyMessage.ts +6 -2
- package/src/api/evm/legacyV1/getAddress.ts +2 -2
- package/src/api/evm/legacyV1/getPublicKey.ts +2 -2
- package/src/api/evm/legacyV1/signMessage.ts +2 -2
- package/src/api/evm/legacyV1/signTypedData.ts +2 -2
- package/src/api/evm/legacyV1/signTypedHash.ts +2 -2
- package/src/api/evm/legacyV1/verifyMessage.ts +2 -2
- package/src/api/evm/protocol.ts +6 -0
- package/src/api/filecoin/FilecoinGetAddress.ts +4 -0
- package/src/api/filecoin/FilecoinSignTransaction.ts +4 -0
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +60 -3
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +745 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +392 -0
- package/src/api/firmware/getBinary.ts +8 -3
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +140 -22
- 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 +199 -0
- package/src/api/index.ts +8 -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/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 +5 -2
- 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 +23 -0
- package/src/core/index.ts +164 -53
- package/src/data/messages/messages-protocol-v2.json +1155 -481
- package/src/data/messages/messages.json +286 -1
- package/src/data-manager/DataManager.ts +39 -39
- package/src/data-manager/TransportManager.ts +1 -1
- package/src/data-manager/connectSettings.ts +15 -0
- package/src/device/Device.ts +647 -281
- 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 +18 -1
- package/src/events/logBlockEvent.ts +79 -2
- package/src/events/ui-request.ts +25 -2
- package/src/index.ts +5 -0
- package/src/inject.ts +37 -43
- package/src/lowLevelInject.ts +5 -1
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +96 -32
- package/src/protocols/protocol-v2/firmware.ts +2 -1
- package/src/protocols/protocol-v2/index.ts +8 -1
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +65 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +210 -0
- package/src/protocols/protocol-v2/unlockPolicy.ts +105 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
- package/src/protocols/protocol-v2/walletSession.ts +285 -0
- package/src/topLevelInject.ts +5 -1
- package/src/types/api/checkAllFirmwareRelease.ts +50 -4
- package/src/types/api/deviceSettings.ts +26 -2
- package/src/types/api/deviceUnlock.ts +1 -1
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +26 -0
- package/src/types/api/firmwareUpdate.ts +99 -5
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/getDeviceState.ts +19 -0
- package/src/types/api/getFeatures.ts +3 -0
- package/src/types/api/getOnekeyFeatures.ts +3 -0
- package/src/types/api/getPassphraseState.ts +9 -11
- package/src/types/api/index.ts +39 -64
- package/src/types/api/kaspaSignTransaction.ts +60 -4
- package/src/types/api/openWalletSession.ts +54 -0
- package/src/types/api/protocolV2.ts +24 -143
- 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 +30 -16
- package/src/utils/assets.ts +4 -1
- package/src/utils/deviceFeaturesCompat.ts +180 -0
- package/src/utils/deviceFeaturesUtils.ts +52 -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 +10 -0
- package/src/utils/index.ts +21 -2
- package/src/utils/networkUtils.ts +274 -16
- package/src/utils/pro2Wallpaper.ts +103 -0
- package/src/utils/tracing.ts +3 -1
- 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
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { UI_REQUEST, createUiMessage } from '../../events';
|
|
2
|
+
|
|
3
|
+
import type { CoreMessage, ProtocolV2UiCompletion } from '../../events';
|
|
4
|
+
import type { Device } from '../../device/Device';
|
|
5
|
+
import type { KnownDevice } from '../../types';
|
|
6
|
+
|
|
7
|
+
export type ProtocolV2InteractionDescriptor = {
|
|
8
|
+
request: 'button' | 'pin';
|
|
9
|
+
source: 'method-lifecycle';
|
|
10
|
+
reason:
|
|
11
|
+
| 'change-pin'
|
|
12
|
+
| 'device-unlock'
|
|
13
|
+
| 'settings-page'
|
|
14
|
+
| 'address-confirmation'
|
|
15
|
+
| 'public-key-confirmation'
|
|
16
|
+
| 'signing-confirmation'
|
|
17
|
+
| 'device-management';
|
|
18
|
+
completion: ProtocolV2UiCompletion;
|
|
19
|
+
deviceOnly: true;
|
|
20
|
+
page?: string | number;
|
|
21
|
+
operation?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type ProtocolV2InteractionMethod = {
|
|
25
|
+
name?: string;
|
|
26
|
+
params?: unknown;
|
|
27
|
+
payload?: unknown;
|
|
28
|
+
protocolV2UiInteraction?: ProtocolV2InteractionDescriptor;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type InteractionDevice = Pick<Device, 'isProtocolV2' | 'toMessageObject'>;
|
|
32
|
+
type PostMessage = (message: CoreMessage) => void;
|
|
33
|
+
|
|
34
|
+
export const isProtocolV2UiEnabled = (method: { protocolV2UiMode?: 'auto' | 'none' }) =>
|
|
35
|
+
method.protocolV2UiMode !== 'none';
|
|
36
|
+
|
|
37
|
+
const getDisplayState = (value: unknown) => {
|
|
38
|
+
const visited = new Set<object>();
|
|
39
|
+
let seen = false;
|
|
40
|
+
let enabled = false;
|
|
41
|
+
|
|
42
|
+
const visit = (current: unknown) => {
|
|
43
|
+
if (current == null || typeof current !== 'object') return;
|
|
44
|
+
if (visited.has(current)) return;
|
|
45
|
+
visited.add(current);
|
|
46
|
+
|
|
47
|
+
if (Array.isArray(current)) {
|
|
48
|
+
current.forEach(visit);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Object.entries(current).forEach(([key, item]) => {
|
|
53
|
+
if ((key === 'show_display' || key === 'showOnOneKey') && typeof item === 'boolean') {
|
|
54
|
+
seen = true;
|
|
55
|
+
enabled ||= item;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
visit(item);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
visit(value);
|
|
63
|
+
return { seen, enabled };
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const createMethodInteraction = (
|
|
67
|
+
reason: 'address-confirmation' | 'public-key-confirmation' | 'signing-confirmation',
|
|
68
|
+
operation: string
|
|
69
|
+
): ProtocolV2InteractionDescriptor => ({
|
|
70
|
+
request: 'button',
|
|
71
|
+
source: 'method-lifecycle',
|
|
72
|
+
reason,
|
|
73
|
+
completion: 'operation-completed',
|
|
74
|
+
deviceOnly: true,
|
|
75
|
+
operation,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const hasCipherConfirmation = (value: unknown): boolean => {
|
|
79
|
+
if (Array.isArray(value)) return value.some(hasCipherConfirmation);
|
|
80
|
+
if (value == null || typeof value !== 'object') return false;
|
|
81
|
+
|
|
82
|
+
const params = value as {
|
|
83
|
+
encrypt?: boolean;
|
|
84
|
+
ask_on_encrypt?: boolean;
|
|
85
|
+
ask_on_decrypt?: boolean;
|
|
86
|
+
};
|
|
87
|
+
return params.encrypt === true ? params.ask_on_encrypt === true : params.ask_on_decrypt === true;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Protocol V2 no longer relies on firmware ButtonRequest, so the SDK synthesizes
|
|
92
|
+
* compatible UI events. Explicit descriptors win; address/public-key prompts appear
|
|
93
|
+
* only when displayed, while signing emits one prompt.
|
|
94
|
+
*/
|
|
95
|
+
export const resolveProtocolV2UiInteraction = (
|
|
96
|
+
method: ProtocolV2InteractionMethod
|
|
97
|
+
): ProtocolV2InteractionDescriptor | undefined => {
|
|
98
|
+
if (method.protocolV2UiInteraction) return method.protocolV2UiInteraction;
|
|
99
|
+
|
|
100
|
+
const operation = method.name;
|
|
101
|
+
if (!operation) return undefined;
|
|
102
|
+
|
|
103
|
+
const isAddress = /getAddress(?:ByLoop)?$/i.test(operation);
|
|
104
|
+
const isPublicKey = /getPublicKey$/i.test(operation);
|
|
105
|
+
if (isAddress || isPublicKey) {
|
|
106
|
+
const paramsDisplay = getDisplayState(method.params);
|
|
107
|
+
const payloadDisplay = getDisplayState(method.payload);
|
|
108
|
+
const display = paramsDisplay.seen ? paramsDisplay : payloadDisplay;
|
|
109
|
+
|
|
110
|
+
// Address methods usually display by default; public-key methods may be silent.
|
|
111
|
+
const shouldDisplay = display.seen ? display.enabled : isAddress;
|
|
112
|
+
if (!shouldDisplay) return undefined;
|
|
113
|
+
|
|
114
|
+
return createMethodInteraction(
|
|
115
|
+
isAddress ? 'address-confirmation' : 'public-key-confirmation',
|
|
116
|
+
operation
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (/sign/i.test(operation) || /verifyMessage$/i.test(operation) || operation === 'lnurlAuth') {
|
|
121
|
+
return createMethodInteraction('signing-confirmation', operation);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (operation === 'nostrEncryptMessage' || operation === 'nostrDecryptMessage') {
|
|
125
|
+
const display = getDisplayState(method.params);
|
|
126
|
+
if (!display.enabled) return undefined;
|
|
127
|
+
return createMethodInteraction('signing-confirmation', operation);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (operation === 'cipherKeyValue' && hasCipherConfirmation(method.params)) {
|
|
131
|
+
return createMethodInteraction('signing-confirmation', operation);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return undefined;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export class ProtocolV2UiInteractionCoordinator {
|
|
138
|
+
private readonly device: InteractionDevice;
|
|
139
|
+
|
|
140
|
+
private readonly postMessage: PostMessage;
|
|
141
|
+
|
|
142
|
+
private methodInteraction?: ProtocolV2InteractionDescriptor;
|
|
143
|
+
|
|
144
|
+
private currentPhase?: string;
|
|
145
|
+
|
|
146
|
+
private opened = false;
|
|
147
|
+
|
|
148
|
+
private closed = false;
|
|
149
|
+
|
|
150
|
+
constructor(device: InteractionDevice, postMessage: PostMessage) {
|
|
151
|
+
this.device = device;
|
|
152
|
+
this.postMessage = postMessage;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
enterMethodInteraction(interaction?: ProtocolV2InteractionDescriptor) {
|
|
156
|
+
this.methodInteraction = interaction;
|
|
157
|
+
if (!interaction) return;
|
|
158
|
+
const { request, ...metadata } = interaction;
|
|
159
|
+
|
|
160
|
+
this.emit(
|
|
161
|
+
request === 'pin' ? UI_REQUEST.REQUEST_PIN : UI_REQUEST.REQUEST_BUTTON,
|
|
162
|
+
{
|
|
163
|
+
device: this.device.toMessageObject() as KnownDevice,
|
|
164
|
+
...metadata,
|
|
165
|
+
},
|
|
166
|
+
`method:${request}:${interaction.reason}:${interaction.page ?? ''}:${
|
|
167
|
+
interaction.operation ?? ''
|
|
168
|
+
}`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
enterUnlockInteraction(method?: string) {
|
|
173
|
+
this.emit(
|
|
174
|
+
UI_REQUEST.REQUEST_PIN,
|
|
175
|
+
{
|
|
176
|
+
device: this.device.toMessageObject() as KnownDevice,
|
|
177
|
+
source: 'unlock-coordinator',
|
|
178
|
+
reason: 'device-locked',
|
|
179
|
+
deviceOnly: true,
|
|
180
|
+
method,
|
|
181
|
+
},
|
|
182
|
+
`unlock:${method ?? ''}`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
resumeMethodInteraction() {
|
|
187
|
+
this.enterMethodInteraction(this.methodInteraction);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
close() {
|
|
191
|
+
if (!this.device.isProtocolV2() || !this.opened || this.closed) return;
|
|
192
|
+
this.closed = true;
|
|
193
|
+
this.postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private emit(
|
|
197
|
+
type: typeof UI_REQUEST.REQUEST_BUTTON | typeof UI_REQUEST.REQUEST_PIN,
|
|
198
|
+
payload: any,
|
|
199
|
+
phase: string
|
|
200
|
+
) {
|
|
201
|
+
if (!this.device.isProtocolV2() || this.closed || this.currentPhase === phase) return;
|
|
202
|
+
this.currentPhase = phase;
|
|
203
|
+
this.opened = true;
|
|
204
|
+
const message =
|
|
205
|
+
type === UI_REQUEST.REQUEST_BUTTON
|
|
206
|
+
? createUiMessage(UI_REQUEST.REQUEST_BUTTON, payload)
|
|
207
|
+
: createUiMessage(UI_REQUEST.REQUEST_PIN, payload);
|
|
208
|
+
this.postMessage(message);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export type UnlockPolicy = 'none' | 'unlock-before-run' | 'retry-on-locked';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Protocol V2 methods that are safe to replay after a locked response.
|
|
5
|
+
*
|
|
6
|
+
* Keep this as an exact allowlist. Name-pattern matching can silently make a new
|
|
7
|
+
* state-changing method replayable when it happens to share a suffix.
|
|
8
|
+
*/
|
|
9
|
+
export const PROTOCOL_V2_RETRY_ON_LOCKED_METHODS = [
|
|
10
|
+
'cipherKeyValue',
|
|
11
|
+
'allNetworkGetAddress',
|
|
12
|
+
'allNetworkGetAddressByLoop',
|
|
13
|
+
'btcGetAddress',
|
|
14
|
+
'btcGetPublicKey',
|
|
15
|
+
'btcSignMessage',
|
|
16
|
+
'btcSignPsbt',
|
|
17
|
+
'btcSignTransaction',
|
|
18
|
+
'btcVerifyMessage',
|
|
19
|
+
'confluxGetAddress',
|
|
20
|
+
'confluxSignMessage',
|
|
21
|
+
'confluxSignTransaction',
|
|
22
|
+
'evmGetAddress',
|
|
23
|
+
'evmGetPublicKey',
|
|
24
|
+
'evmSignMessage',
|
|
25
|
+
'evmSignTransaction',
|
|
26
|
+
'evmSignTypedData',
|
|
27
|
+
'evmVerifyMessage',
|
|
28
|
+
'starcoinGetAddress',
|
|
29
|
+
'starcoinGetPublicKey',
|
|
30
|
+
'starcoinSignMessage',
|
|
31
|
+
'starcoinSignTransaction',
|
|
32
|
+
'starcoinVerifyMessage',
|
|
33
|
+
'nemGetAddress',
|
|
34
|
+
'nemSignTransaction',
|
|
35
|
+
'solGetAddress',
|
|
36
|
+
'solSignTransaction',
|
|
37
|
+
'solSignOffchainMessage',
|
|
38
|
+
'solSignMessage',
|
|
39
|
+
'stellarGetAddress',
|
|
40
|
+
'stellarSignTransaction',
|
|
41
|
+
'tronGetAddress',
|
|
42
|
+
'tronSignMessage',
|
|
43
|
+
'tronSignTransaction',
|
|
44
|
+
'nearGetAddress',
|
|
45
|
+
'nearSignTransaction',
|
|
46
|
+
'aptosGetAddress',
|
|
47
|
+
'aptosGetPublicKey',
|
|
48
|
+
'aptosSignTransaction',
|
|
49
|
+
'aptosSignMessage',
|
|
50
|
+
'aptosSignInMessage',
|
|
51
|
+
'algoGetAddress',
|
|
52
|
+
'algoSignTransaction',
|
|
53
|
+
'cosmosGetAddress',
|
|
54
|
+
'cosmosGetPublicKey',
|
|
55
|
+
'cosmosSignTransaction',
|
|
56
|
+
'xrpGetAddress',
|
|
57
|
+
'xrpSignTransaction',
|
|
58
|
+
'suiGetAddress',
|
|
59
|
+
'suiGetPublicKey',
|
|
60
|
+
'suiSignMessage',
|
|
61
|
+
'suiSignTransaction',
|
|
62
|
+
'cardanoGetAddress',
|
|
63
|
+
'cardanoGetPublicKey',
|
|
64
|
+
'cardanoSignTransaction',
|
|
65
|
+
'cardanoSignMessage',
|
|
66
|
+
'filecoinGetAddress',
|
|
67
|
+
'filecoinSignTransaction',
|
|
68
|
+
'polkadotGetAddress',
|
|
69
|
+
'polkadotSignTransaction',
|
|
70
|
+
'kaspaGetAddress',
|
|
71
|
+
'kaspaSignTransaction',
|
|
72
|
+
'nexaGetAddress',
|
|
73
|
+
'nexaSignTransaction',
|
|
74
|
+
'nostrGetPublicKey',
|
|
75
|
+
'nostrSignEvent',
|
|
76
|
+
'nostrEncryptMessage',
|
|
77
|
+
'nostrDecryptMessage',
|
|
78
|
+
'nostrSignSchnorr',
|
|
79
|
+
'lnurlAuth',
|
|
80
|
+
'nervosGetAddress',
|
|
81
|
+
'nervosSignTransaction',
|
|
82
|
+
'dnxGetAddress',
|
|
83
|
+
'dnxSignTransaction',
|
|
84
|
+
'tonGetAddress',
|
|
85
|
+
'tonSignMessage',
|
|
86
|
+
'tonSignProof',
|
|
87
|
+
'tonSignData',
|
|
88
|
+
'scdoGetAddress',
|
|
89
|
+
'scdoSignTransaction',
|
|
90
|
+
'scdoSignMessage',
|
|
91
|
+
'alephiumGetAddress',
|
|
92
|
+
'alephiumSignTransaction',
|
|
93
|
+
'alephiumSignMessage',
|
|
94
|
+
'benfenGetAddress',
|
|
95
|
+
'benfenGetPublicKey',
|
|
96
|
+
'benfenSignMessage',
|
|
97
|
+
'benfenSignTransaction',
|
|
98
|
+
'neoGetAddress',
|
|
99
|
+
'neoSignTransaction',
|
|
100
|
+
] as const;
|
|
101
|
+
|
|
102
|
+
const retryOnLockedMethods = new Set<string>(PROTOCOL_V2_RETRY_ON_LOCKED_METHODS);
|
|
103
|
+
|
|
104
|
+
export const getProtocolV2UnlockPolicy = (methodName: string): UnlockPolicy =>
|
|
105
|
+
retryOnLockedMethods.has(methodName) ? 'retry-on-locked' : 'none';
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { LoggerNames, getLogger } from '../../utils';
|
|
2
|
+
import { isDeviceLockedError } from './lockedError';
|
|
3
|
+
import { isProtocolV2UiEnabled, resolveProtocolV2UiInteraction } from './uiInteraction';
|
|
4
|
+
import { refreshProtocolV2DeviceStatus, restoreProtocolV2WalletSession } from './walletSession';
|
|
5
|
+
|
|
6
|
+
import type { BaseMethod } from '../../api/BaseMethod';
|
|
7
|
+
import type { Device } from '../../device/Device';
|
|
8
|
+
import type { ProtocolV2UiInteractionCoordinator } from './uiInteraction';
|
|
9
|
+
|
|
10
|
+
const Log = getLogger(LoggerNames.Core);
|
|
11
|
+
|
|
12
|
+
type RunnableMethod = Pick<
|
|
13
|
+
BaseMethod,
|
|
14
|
+
| 'run'
|
|
15
|
+
| 'unlockPolicy'
|
|
16
|
+
| 'protocolV2UiInteraction'
|
|
17
|
+
| 'protocolV2UiMode'
|
|
18
|
+
| 'params'
|
|
19
|
+
| 'payload'
|
|
20
|
+
| 'useDevicePassphraseState'
|
|
21
|
+
> & { name?: string };
|
|
22
|
+
type UiInteractionCoordinator = Pick<
|
|
23
|
+
ProtocolV2UiInteractionCoordinator,
|
|
24
|
+
'enterMethodInteraction' | 'enterUnlockInteraction' | 'resumeMethodInteraction'
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
const restoreExpectedWalletSessionAfterUnlock = async (method: RunnableMethod, device: Device) => {
|
|
28
|
+
const expectedPassphraseState = method.payload?.useEmptyPassphrase
|
|
29
|
+
? undefined
|
|
30
|
+
: method.payload?.passphraseState ?? device.passphraseState;
|
|
31
|
+
if (
|
|
32
|
+
!method.useDevicePassphraseState ||
|
|
33
|
+
typeof expectedPassphraseState !== 'string' ||
|
|
34
|
+
expectedPassphraseState.length === 0
|
|
35
|
+
) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await restoreProtocolV2WalletSession(device, expectedPassphraseState);
|
|
40
|
+
Log.debug('Protocol V2 wallet session restored after unlock', { method: method.name });
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export async function runMethodWithUnlockRetry(
|
|
44
|
+
method: RunnableMethod,
|
|
45
|
+
device: Device,
|
|
46
|
+
uiCoordinator?: UiInteractionCoordinator
|
|
47
|
+
) {
|
|
48
|
+
const shouldEmitUi = isProtocolV2UiEnabled(method);
|
|
49
|
+
const isProtocolV2 = device.isProtocolV2();
|
|
50
|
+
const requiresFreshStatus =
|
|
51
|
+
isProtocolV2 &&
|
|
52
|
+
method.unlockPolicy === 'unlock-before-run' &&
|
|
53
|
+
!device.isBootloader?.() &&
|
|
54
|
+
!device.isRomloader?.();
|
|
55
|
+
|
|
56
|
+
if (requiresFreshStatus) {
|
|
57
|
+
await refreshProtocolV2DeviceStatus(device);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const shouldUnlockBeforeRun =
|
|
61
|
+
isProtocolV2 &&
|
|
62
|
+
method.unlockPolicy !== 'none' &&
|
|
63
|
+
!device.isBootloader?.() &&
|
|
64
|
+
!device.isRomloader?.() &&
|
|
65
|
+
device.features?.unlocked === false;
|
|
66
|
+
|
|
67
|
+
if (shouldUnlockBeforeRun) {
|
|
68
|
+
if (shouldEmitUi) {
|
|
69
|
+
uiCoordinator?.enterUnlockInteraction(method.name);
|
|
70
|
+
}
|
|
71
|
+
await device.unlockDevice();
|
|
72
|
+
Log.debug('Protocol V2 pre-unlock completed', { method: method.name });
|
|
73
|
+
await restoreExpectedWalletSessionAfterUnlock(method, device);
|
|
74
|
+
if (shouldEmitUi) {
|
|
75
|
+
uiCoordinator?.enterMethodInteraction(resolveProtocolV2UiInteraction(method));
|
|
76
|
+
}
|
|
77
|
+
return method.run();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (shouldEmitUi) {
|
|
81
|
+
uiCoordinator?.enterMethodInteraction(resolveProtocolV2UiInteraction(method));
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
return await method.run();
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (!isProtocolV2 || method.unlockPolicy !== 'retry-on-locked' || !isDeviceLockedError(error)) {
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
Log.debug('Protocol V2 unlock retry triggered', { method: method.name });
|
|
91
|
+
if (shouldEmitUi) {
|
|
92
|
+
uiCoordinator?.enterUnlockInteraction(method.name);
|
|
93
|
+
}
|
|
94
|
+
await device.unlockDevice();
|
|
95
|
+
Log.debug('Protocol V2 unlock completed', { method: method.name });
|
|
96
|
+
await restoreExpectedWalletSessionAfterUnlock(method, device);
|
|
97
|
+
if (shouldEmitUi) {
|
|
98
|
+
uiCoordinator?.resumeMethodInteraction();
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const response = await method.run();
|
|
102
|
+
Log.debug('Protocol V2 method retry completed', { method: method.name, success: true });
|
|
103
|
+
return response;
|
|
104
|
+
} catch (retryError) {
|
|
105
|
+
Log.debug('Protocol V2 method retry completed', { method: method.name, success: false });
|
|
106
|
+
throw retryError;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
3
|
+
|
|
4
|
+
import { DEVICE } from '../../events';
|
|
5
|
+
import { assertCompleteDeviceSession } from './deviceSession';
|
|
6
|
+
|
|
7
|
+
import type { DeviceSessionAskPassphrase, DeviceSessionGet } from '@onekeyfe/hd-transport';
|
|
8
|
+
import type { Device } from '../../device/Device';
|
|
9
|
+
|
|
10
|
+
const HOST_PASSPHRASE_MAX_BYTES = 50;
|
|
11
|
+
|
|
12
|
+
const isWalletSessionInvalidError = (error: unknown) =>
|
|
13
|
+
typeof error === 'object' &&
|
|
14
|
+
error !== null &&
|
|
15
|
+
'errorCode' in error &&
|
|
16
|
+
(error as { errorCode?: unknown }).errorCode === HardwareErrorCode.WalletSessionInvalid;
|
|
17
|
+
|
|
18
|
+
const utf8ByteLength = (value: string): number | undefined => {
|
|
19
|
+
let length = 0;
|
|
20
|
+
for (const character of value) {
|
|
21
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
22
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdfff) return undefined;
|
|
23
|
+
if (codePoint <= 0x7f) length += 1;
|
|
24
|
+
else if (codePoint <= 0x7ff) length += 2;
|
|
25
|
+
else if (codePoint <= 0xffff) length += 3;
|
|
26
|
+
else length += 4;
|
|
27
|
+
}
|
|
28
|
+
return length;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export async function requestProtocolV2DeviceStatus(device: Device) {
|
|
32
|
+
const { message } = await device.commands.typedCall('DeviceStatusGet', 'DeviceStatus', {});
|
|
33
|
+
return message;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function refreshProtocolV2DeviceStatus(device: Device) {
|
|
37
|
+
const status = await requestProtocolV2DeviceStatus(device);
|
|
38
|
+
return device.updateProtocolV2Status(status);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const negotiateEventlessWalletSession = async (device: Device) => {
|
|
42
|
+
await device.commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {
|
|
43
|
+
eventless_wallet_session: true,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const getDeviceSession = async (device: Device, request: DeviceSessionGet) =>
|
|
48
|
+
device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
|
|
49
|
+
|
|
50
|
+
const askDevicePassphrase = async (device: Device, requestPayload: DeviceSessionAskPassphrase) => {
|
|
51
|
+
await device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', requestPayload);
|
|
52
|
+
await refreshProtocolV2DeviceStatus(device);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const selectDeviceSession = async (device: Device, expectedPassphraseState?: string) => {
|
|
56
|
+
const existsAttachPinUser = device.features?.attachToPinEnabled === true;
|
|
57
|
+
const metadata = {
|
|
58
|
+
source: 'wallet-session-coordinator' as const,
|
|
59
|
+
reason: expectedPassphraseState ? ('session-recovery' as const) : ('open-wallet' as const),
|
|
60
|
+
...(expectedPassphraseState ? { expectedPassphraseState } : {}),
|
|
61
|
+
};
|
|
62
|
+
const response = await device.commands.promptPassphrase(
|
|
63
|
+
{
|
|
64
|
+
existsAttachPinUser,
|
|
65
|
+
deviceOnly: false,
|
|
66
|
+
...metadata,
|
|
67
|
+
},
|
|
68
|
+
{ cancelDeviceOnReject: false }
|
|
69
|
+
);
|
|
70
|
+
const hostPassphrase =
|
|
71
|
+
typeof response.passphrase === 'string' ? response.passphrase.normalize('NFKD') : undefined;
|
|
72
|
+
const hasHostPassphrase = typeof hostPassphrase === 'string' && hostPassphrase.length > 0;
|
|
73
|
+
const hostPassphraseByteLength = hasHostPassphrase ? utf8ByteLength(hostPassphrase) : undefined;
|
|
74
|
+
if (
|
|
75
|
+
hasHostPassphrase &&
|
|
76
|
+
(hostPassphrase.includes('\0') ||
|
|
77
|
+
hostPassphraseByteLength === undefined ||
|
|
78
|
+
hostPassphraseByteLength > HOST_PASSPHRASE_MAX_BYTES)
|
|
79
|
+
) {
|
|
80
|
+
throw ERRORS.TypedError(
|
|
81
|
+
HardwareErrorCode.RuntimeError,
|
|
82
|
+
`Host passphrase must contain 1 to ${HOST_PASSPHRASE_MAX_BYTES} valid UTF-8 bytes without NUL.`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const selections = [
|
|
86
|
+
hasHostPassphrase,
|
|
87
|
+
response.passphraseOnDevice === true,
|
|
88
|
+
response.attachPinOnDevice === true,
|
|
89
|
+
].filter(Boolean).length;
|
|
90
|
+
|
|
91
|
+
if (selections !== 1) {
|
|
92
|
+
throw ERRORS.TypedError(
|
|
93
|
+
HardwareErrorCode.RuntimeError,
|
|
94
|
+
'Wallet selection must contain exactly one passphrase access mode.'
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (response.attachPinOnDevice) {
|
|
99
|
+
if (!existsAttachPinUser) {
|
|
100
|
+
throw ERRORS.TypedError(
|
|
101
|
+
HardwareErrorCode.RuntimeError,
|
|
102
|
+
'Attach PIN wallet selection is unavailable on this device.'
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
device.emit(DEVICE.ATTACH_PIN_ON_DEVICE, device, metadata);
|
|
106
|
+
await device.unlockDevice(DeviceSessionPinType.AttachToPin);
|
|
107
|
+
return getDeviceSession(device, {});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (hasHostPassphrase) {
|
|
111
|
+
await askDevicePassphrase(device, {
|
|
112
|
+
passphrase: hostPassphrase,
|
|
113
|
+
on_device: false,
|
|
114
|
+
});
|
|
115
|
+
return getDeviceSession(device, {});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, metadata);
|
|
119
|
+
await askDevicePassphrase(device, { on_device: true });
|
|
120
|
+
return getDeviceSession(device, {});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export async function getProtocolV2WalletSession(
|
|
124
|
+
device: Device,
|
|
125
|
+
options?: {
|
|
126
|
+
forceWalletSelection?: boolean;
|
|
127
|
+
/** @deprecated 兼容旧 getPassphraseState;新流程使用 forceWalletSelection。 */
|
|
128
|
+
initSession?: boolean;
|
|
129
|
+
expectedPassphraseState?: string;
|
|
130
|
+
onlyMainPin?: boolean;
|
|
131
|
+
resumeOnly?: boolean;
|
|
132
|
+
}
|
|
133
|
+
) {
|
|
134
|
+
const forceWalletSelection =
|
|
135
|
+
options?.forceWalletSelection === true || options?.initSession === true;
|
|
136
|
+
|
|
137
|
+
if (forceWalletSelection) {
|
|
138
|
+
if (options.onlyMainPin) {
|
|
139
|
+
device.clearStandardInternalState?.();
|
|
140
|
+
} else {
|
|
141
|
+
device.clearInternalState();
|
|
142
|
+
}
|
|
143
|
+
device.passphraseState = undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
await negotiateEventlessWalletSession(device);
|
|
147
|
+
|
|
148
|
+
if (options?.onlyMainPin) {
|
|
149
|
+
device.passphraseState = undefined;
|
|
150
|
+
}
|
|
151
|
+
let expectedPassphraseState = options?.onlyMainPin
|
|
152
|
+
? undefined
|
|
153
|
+
: options?.expectedPassphraseState ?? device.passphraseState;
|
|
154
|
+
|
|
155
|
+
const cachedStandardSession = options?.onlyMainPin
|
|
156
|
+
? device.getStandardInternalState?.()
|
|
157
|
+
: undefined;
|
|
158
|
+
const cachedSessionId =
|
|
159
|
+
!options?.onlyMainPin && typeof device.getInternalState === 'function'
|
|
160
|
+
? device.getInternalState()
|
|
161
|
+
: undefined;
|
|
162
|
+
let response;
|
|
163
|
+
let resumed = false;
|
|
164
|
+
|
|
165
|
+
if (options?.onlyMainPin) {
|
|
166
|
+
expectedPassphraseState = cachedStandardSession?.passphraseState;
|
|
167
|
+
if (cachedStandardSession) {
|
|
168
|
+
try {
|
|
169
|
+
if (device.features?.unlockedAttachPin === true) {
|
|
170
|
+
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
171
|
+
}
|
|
172
|
+
response = await getDeviceSession(device, {
|
|
173
|
+
session_id: cachedStandardSession.sessionId,
|
|
174
|
+
});
|
|
175
|
+
resumed = true;
|
|
176
|
+
} catch (error) {
|
|
177
|
+
device.clearStandardInternalState?.();
|
|
178
|
+
if (!isWalletSessionInvalidError(error)) {
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
resumed = false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (!response) {
|
|
186
|
+
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
187
|
+
response = await getDeviceSession(device, {});
|
|
188
|
+
}
|
|
189
|
+
} else if (cachedSessionId && expectedPassphraseState) {
|
|
190
|
+
try {
|
|
191
|
+
response = await getDeviceSession(device, { session_id: cachedSessionId });
|
|
192
|
+
resumed = true;
|
|
193
|
+
} catch (error) {
|
|
194
|
+
device.clearInternalState();
|
|
195
|
+
if (options?.resumeOnly || !isWalletSessionInvalidError(error)) {
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
resumed = false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!response) {
|
|
203
|
+
if (options?.resumeOnly) {
|
|
204
|
+
device.clearInternalState();
|
|
205
|
+
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
206
|
+
}
|
|
207
|
+
response = await selectDeviceSession(device, expectedPassphraseState);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
let { message } = response;
|
|
211
|
+
try {
|
|
212
|
+
assertCompleteDeviceSession(message);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (options?.onlyMainPin) {
|
|
215
|
+
device.clearStandardInternalState?.();
|
|
216
|
+
} else {
|
|
217
|
+
device.clearInternalState();
|
|
218
|
+
}
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
if (expectedPassphraseState && expectedPassphraseState !== message.btc_test_address) {
|
|
222
|
+
resumed = false;
|
|
223
|
+
if (options?.resumeOnly) {
|
|
224
|
+
device.clearInternalState();
|
|
225
|
+
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
226
|
+
}
|
|
227
|
+
if (options?.onlyMainPin) {
|
|
228
|
+
device.clearStandardInternalState?.();
|
|
229
|
+
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
230
|
+
response = await getDeviceSession(device, {});
|
|
231
|
+
} else {
|
|
232
|
+
device.clearInternalState();
|
|
233
|
+
response = await selectDeviceSession(device, expectedPassphraseState);
|
|
234
|
+
}
|
|
235
|
+
message = response.message;
|
|
236
|
+
try {
|
|
237
|
+
assertCompleteDeviceSession(message);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
if (options?.onlyMainPin) {
|
|
240
|
+
device.clearStandardInternalState?.();
|
|
241
|
+
} else {
|
|
242
|
+
device.clearInternalState();
|
|
243
|
+
}
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
if (expectedPassphraseState !== message.btc_test_address) {
|
|
247
|
+
if (options?.onlyMainPin) {
|
|
248
|
+
device.clearStandardInternalState?.();
|
|
249
|
+
} else {
|
|
250
|
+
device.clearInternalState();
|
|
251
|
+
}
|
|
252
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const internalStateArgs = [
|
|
257
|
+
true,
|
|
258
|
+
message.btc_test_address,
|
|
259
|
+
device.getCurrentDeviceId(),
|
|
260
|
+
message.session_id,
|
|
261
|
+
forceWalletSelection ? null : cachedSessionId ?? null,
|
|
262
|
+
] as const;
|
|
263
|
+
if (options?.onlyMainPin) {
|
|
264
|
+
device.updateInternalState(...internalStateArgs, 'standard');
|
|
265
|
+
} else {
|
|
266
|
+
device.updateInternalState(...internalStateArgs);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
passphraseState: message.btc_test_address,
|
|
271
|
+
newSession: message.session_id,
|
|
272
|
+
unlockedAttachPin: device.features?.unlockedAttachPin ?? undefined,
|
|
273
|
+
resumed,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export async function restoreProtocolV2WalletSession(
|
|
278
|
+
device: Device,
|
|
279
|
+
expectedPassphraseState: string
|
|
280
|
+
) {
|
|
281
|
+
return getProtocolV2WalletSession(device, {
|
|
282
|
+
expectedPassphraseState,
|
|
283
|
+
resumeOnly: true,
|
|
284
|
+
});
|
|
285
|
+
}
|