@onekeyfe/hd-core 1.2.0-alpha.23 → 1.2.0-alpha.25
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 +2 -0
- package/__tests__/DeviceCommands.test.ts +35 -0
- package/__tests__/chain-params-onekey-compatibility.test.ts +229 -0
- package/__tests__/device-lifecycle-events.test.ts +59 -0
- package/__tests__/device-state-events.test.ts +124 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +3 -1
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +68 -27
- package/__tests__/firmware-update/firmware-update-plan.test.ts +28 -0
- package/__tests__/kaspa-public-types.type-test.ts +16 -0
- package/__tests__/kaspaSignTransaction.test.ts +4 -3
- package/__tests__/method-protocol-support.test.ts +113 -0
- package/__tests__/open-wallet-session.test.ts +192 -129
- package/__tests__/protocol-v2-ping.test.ts +28 -0
- package/__tests__/protocol-v2.test.ts +346 -230
- package/__tests__/public-device-state-api.test.ts +10 -8
- package/__tests__/public-pro2-api-boundary.test.ts +22 -0
- package/__tests__/tron-sign-message-init.test.ts +46 -0
- package/dist/api/BaseMethod.d.ts +6 -2
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.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/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 +1 -0
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +2 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts +1 -0
- package/dist/api/GetDeviceState.d.ts.map +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +1 -0
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts +2 -8
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/PathInfo.d.ts +1 -0
- package/dist/api/PathInfo.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/algo/AlgoGetAddress.d.ts +1 -0
- package/dist/api/algo/AlgoGetAddress.d.ts.map +1 -1
- package/dist/api/algo/AlgoSignTransaction.d.ts +1 -0
- package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +1 -0
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts +1 -0
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetPublicKey.d.ts +1 -0
- package/dist/api/aptos/AptosGetPublicKey.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignInMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignTransaction.d.ts +1 -0
- package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -0
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -0
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -0
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts +1 -0
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -0
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -0
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -0
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetAddress.d.ts +1 -0
- package/dist/api/cardano/CardanoGetAddress.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetPublicKey.d.ts +1 -0
- package/dist/api/cardano/CardanoGetPublicKey.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignMessage.d.ts +1 -0
- package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts +1 -0
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxGetAddress.d.ts +1 -0
- package/dist/api/conflux/ConfluxGetAddress.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessage.d.ts +1 -0
- package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts +1 -0
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts +1 -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/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/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/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/FirmwareUpdatePlan.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaGetAddress.d.ts +1 -0
- package/dist/api/kaspa/KaspaGetAddress.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts +1 -0
- 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.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 +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -1
- package/dist/api/protocol-v2/Ping.d.ts +3 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/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 +2 -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/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/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +3 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.d.ts +25 -25
- package/dist/index.js +669 -367
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +2 -3
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +12 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +3 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/kaspaSignTransaction.d.ts +15 -2
- package/dist/types/api/kaspaSignTransaction.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +0 -12
- package/dist/types/api/openWalletSession.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +4 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +0 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +0 -1
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +1 -0
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +21 -18
- package/src/api/CheckAllFirmwareRelease.ts +23 -3
- package/src/api/CipherKeyValue.ts +4 -0
- package/src/api/DirList.ts +4 -1
- package/src/api/DirMake.ts +4 -1
- package/src/api/DirRemove.ts +4 -1
- package/src/api/FileDelete.ts +4 -1
- package/src/api/FileRead.ts +4 -1
- package/src/api/FileWrite.ts +4 -1
- package/src/api/FirmwareUpdate.ts +0 -8
- package/src/api/FirmwareUpdateV3.ts +0 -6
- package/src/api/FirmwareUpdateV4.ts +36 -18
- package/src/api/GetDeviceState.ts +4 -0
- package/src/api/GetFeatures.ts +1 -4
- package/src/api/GetOnekeyFeatures.ts +0 -5
- package/src/api/GetPassphraseState.ts +4 -0
- package/src/api/OpenWalletSession.ts +27 -86
- package/src/api/PathInfo.ts +4 -1
- package/src/api/alephium/AlephiumGetAddress.ts +0 -4
- package/src/api/alephium/AlephiumSignMessage.ts +0 -4
- package/src/api/alephium/AlephiumSignTransaction.ts +0 -4
- package/src/api/algo/AlgoGetAddress.ts +4 -0
- package/src/api/algo/AlgoSignTransaction.ts +4 -0
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +5 -13
- 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 +8 -1
- package/src/api/btc/BTCSignMessage.ts +8 -1
- package/src/api/btc/BTCSignPsbt.ts +4 -0
- package/src/api/btc/BTCSignTransaction.ts +8 -1
- package/src/api/btc/BTCVerifyMessage.ts +8 -1
- package/src/api/btc/helpers/versionLimit.ts +7 -4
- package/src/api/cardano/CardanoGetAddress.ts +4 -0
- package/src/api/cardano/CardanoGetPublicKey.ts +4 -0
- package/src/api/cardano/CardanoSignMessage.ts +4 -0
- package/src/api/cardano/CardanoSignTransaction.ts +4 -0
- package/src/api/conflux/ConfluxGetAddress.ts +4 -0
- package/src/api/conflux/ConfluxSignMessage.ts +4 -0
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +4 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +6 -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 +4 -0
- package/src/api/device/DeviceChangePin.ts +4 -0
- package/src/api/device/DeviceLock.ts +4 -0
- package/src/api/device/DeviceRebootToBoardloader.ts +4 -0
- package/src/api/device/DeviceRebootToBootloader.ts +4 -0
- package/src/api/device/DeviceSettings.ts +4 -0
- package/src/api/device/DeviceSupportFeatures.ts +4 -0
- package/src/api/device/DeviceUnlock.ts +4 -0
- package/src/api/device/DeviceWipe.ts +4 -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 +4 -0
- package/src/api/evm/EVMGetPublicKey.ts +4 -0
- package/src/api/evm/EVMSignMessage.ts +4 -0
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -11
- package/src/api/evm/EVMSignTransaction.ts +4 -0
- package/src/api/evm/EVMSignTypedData.ts +4 -0
- package/src/api/evm/EVMVerifyMessage.ts +4 -0
- package/src/api/filecoin/FilecoinGetAddress.ts +4 -0
- package/src/api/filecoin/FilecoinSignTransaction.ts +4 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +8 -1
- package/src/api/index.ts +1 -0
- package/src/api/kaspa/KaspaGetAddress.ts +4 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +37 -15
- package/src/api/kaspa/helpers/TransferSerialize.ts +3 -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 +0 -4
- package/src/api/nexa/NexaGetAddress.ts +0 -4
- package/src/api/nexa/NexaSignTransaction.ts +0 -4
- 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 +4 -1
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +4 -1
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +4 -1
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +4 -1
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +4 -1
- package/src/api/protocol-v2/DeviceInfoGet.ts +4 -8
- package/src/api/protocol-v2/DeviceReboot.ts +4 -2
- package/src/api/protocol-v2/DeviceStatusGet.ts +4 -1
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +4 -1
- package/src/api/protocol-v2/FilesystemFormat.ts +4 -1
- package/src/api/protocol-v2/FilesystemPermissionFix.ts +4 -1
- package/src/api/protocol-v2/Ping.ts +36 -2
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +4 -1
- package/src/api/scdo/ScdoGetAddress.ts +0 -4
- package/src/api/scdo/ScdoSignMessage.ts +0 -4
- package/src/api/scdo/ScdoSignTransaction.ts +0 -4
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +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 +15 -7
- package/src/api/tron/TronSignTransaction.ts +4 -0
- package/src/api/xrp/XrpGetAddress.ts +4 -0
- package/src/api/xrp/XrpSignTransaction.ts +5 -1
- package/src/core/index.ts +43 -24
- package/src/data/messages/messages-protocol-v2.json +33 -1
- package/src/device/Device.ts +60 -62
- package/src/device/DeviceCommands.ts +19 -0
- package/src/inject.ts +2 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +20 -3
- package/src/protocols/protocol-v2/walletSession.ts +26 -8
- package/src/types/api/export.ts +2 -0
- package/src/types/api/index.ts +3 -0
- package/src/types/api/kaspaSignTransaction.ts +20 -2
- package/src/types/api/openWalletSession.ts +0 -19
- package/src/types/api/protocolV2.ts +10 -0
- package/src/types/device.ts +0 -1
- package/src/utils/deviceInfoUtils.ts +15 -6
- package/src/utils/deviceVersionUtils.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/tsconfig.type-tests.json +8 -0
package/src/device/Device.ts
CHANGED
|
@@ -3,6 +3,7 @@ import semver from 'semver';
|
|
|
3
3
|
import { DeviceRebootType, DeviceSessionPinType, Enum_Capability } from '@onekeyfe/hd-transport';
|
|
4
4
|
import {
|
|
5
5
|
EDeviceType,
|
|
6
|
+
EFirmwareType,
|
|
6
7
|
ERRORS,
|
|
7
8
|
ERROR_CODES_REQUIRE_DISCONNECT,
|
|
8
9
|
ERROR_CODES_REQUIRE_RELEASE,
|
|
@@ -12,24 +13,12 @@ import {
|
|
|
12
13
|
createDeviceNotSupportMethodError,
|
|
13
14
|
} from '@onekeyfe/hd-shared';
|
|
14
15
|
|
|
15
|
-
import {
|
|
16
|
-
LoggerNames,
|
|
17
|
-
getDeviceBLEFirmwareVersion,
|
|
18
|
-
getDeviceBleName,
|
|
19
|
-
getDeviceBootloaderVersion,
|
|
20
|
-
getDeviceFirmwareVersion,
|
|
21
|
-
getDeviceLabel,
|
|
22
|
-
getDeviceSerialNo,
|
|
23
|
-
getDeviceType,
|
|
24
|
-
getFirmwareType,
|
|
25
|
-
getLogger,
|
|
26
|
-
} from '../utils';
|
|
16
|
+
import { LoggerNames, getLogger } from '../utils';
|
|
27
17
|
import {
|
|
28
18
|
fixFeaturesFirmwareVersion,
|
|
29
19
|
getPassphraseStateWithRefreshDeviceInfo,
|
|
30
|
-
supportInputPinOnSoftware,
|
|
31
|
-
supportModifyHomescreen,
|
|
32
20
|
} from '../utils/deviceFeaturesUtils';
|
|
21
|
+
import { parseDeviceVersion } from '../utils/deviceVersionUtils';
|
|
33
22
|
import { generateInstanceId } from '../utils/tracing';
|
|
34
23
|
// eslint-disable-next-line import/no-cycle
|
|
35
24
|
import { DeviceCommands } from './DeviceCommands';
|
|
@@ -65,7 +54,6 @@ import { DEVICE, UI_REQUEST } from '../events';
|
|
|
65
54
|
import { DataManager } from '../data-manager';
|
|
66
55
|
import TransportManager from '../data-manager/TransportManager';
|
|
67
56
|
import { toHardened } from '../api/helpers/pathUtils';
|
|
68
|
-
import { existCapability } from '../utils/capabilitieUtils';
|
|
69
57
|
import {
|
|
70
58
|
PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST,
|
|
71
59
|
PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST,
|
|
@@ -298,7 +286,7 @@ export class Device extends EventEmitter {
|
|
|
298
286
|
const deviceType = this.getCurrentDeviceType();
|
|
299
287
|
|
|
300
288
|
const bleName = this.getCurrentBleName();
|
|
301
|
-
const
|
|
289
|
+
const displayName = this.getCurrentDisplayName();
|
|
302
290
|
const serialNo = this.getCurrentSerialNo();
|
|
303
291
|
const connectId = this.getConnectId();
|
|
304
292
|
const deviceId = this.getCurrentDeviceId() || null;
|
|
@@ -322,10 +310,10 @@ export class Device extends EventEmitter {
|
|
|
322
310
|
deviceId,
|
|
323
311
|
path: this.originalDescriptor?.path,
|
|
324
312
|
bleName,
|
|
325
|
-
name:
|
|
313
|
+
name: displayName || bleName || `OneKey ${deviceType?.toUpperCase()}`,
|
|
326
314
|
// Keep the legacy top-level field string-compatible while preserving
|
|
327
315
|
// the canonical nullable value at state.identity.label.
|
|
328
|
-
label:
|
|
316
|
+
label: displayName ?? '',
|
|
329
317
|
mode: this.getMode(),
|
|
330
318
|
features,
|
|
331
319
|
state,
|
|
@@ -344,6 +332,10 @@ export class Device extends EventEmitter {
|
|
|
344
332
|
// eslint-disable-next-line no-async-promise-executor
|
|
345
333
|
return new Promise<boolean>(async (resolve, reject) => {
|
|
346
334
|
if (DataManager.isBleConnect(env)) {
|
|
335
|
+
if (this.hasDeviceAcquire() && this.commands && !this.commands.disposed) {
|
|
336
|
+
resolve(true);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
347
339
|
try {
|
|
348
340
|
await this.acquire(connectProtocol);
|
|
349
341
|
resolve(true);
|
|
@@ -539,15 +531,15 @@ export class Device extends EventEmitter {
|
|
|
539
531
|
}
|
|
540
532
|
|
|
541
533
|
getCurrentDeviceType() {
|
|
542
|
-
return
|
|
534
|
+
return this.state?.identity.deviceType ?? EDeviceType.Unknown;
|
|
543
535
|
}
|
|
544
536
|
|
|
545
537
|
getCurrentDeviceId() {
|
|
546
|
-
return this.
|
|
538
|
+
return this.state?.identity.deviceId || undefined;
|
|
547
539
|
}
|
|
548
540
|
|
|
549
541
|
getCurrentSerialNo() {
|
|
550
|
-
return
|
|
542
|
+
return this.state?.identity.serialNo ?? '';
|
|
551
543
|
}
|
|
552
544
|
|
|
553
545
|
getConnectId() {
|
|
@@ -560,37 +552,54 @@ export class Device extends EventEmitter {
|
|
|
560
552
|
}
|
|
561
553
|
|
|
562
554
|
getCurrentBleName() {
|
|
563
|
-
return
|
|
555
|
+
return this.state?.identity.bleName ?? null;
|
|
564
556
|
}
|
|
565
557
|
|
|
566
558
|
getCurrentLabel() {
|
|
567
|
-
return
|
|
559
|
+
return this.state?.identity.label ?? null;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
getCurrentDisplayName() {
|
|
563
|
+
if (!this.state) return null;
|
|
564
|
+
|
|
565
|
+
const label = this.getCurrentLabel();
|
|
566
|
+
if (label) return label;
|
|
567
|
+
|
|
568
|
+
const bleName = this.getCurrentBleName();
|
|
569
|
+
if (bleName) return bleName;
|
|
570
|
+
|
|
571
|
+
const deviceType = this.getCurrentDeviceType();
|
|
572
|
+
if (deviceType === EDeviceType.ClassicPure) {
|
|
573
|
+
return 'OneKey Classic 1S';
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return `OneKey ${deviceType.charAt(0).toUpperCase() + deviceType.slice(1)}`;
|
|
568
577
|
}
|
|
569
578
|
|
|
570
579
|
getCurrentPassphraseProtection() {
|
|
571
|
-
return this.
|
|
580
|
+
return this.state?.status.passphraseProtection;
|
|
572
581
|
}
|
|
573
582
|
|
|
574
583
|
getCurrentFirmwareType() {
|
|
575
|
-
return
|
|
584
|
+
return this.state?.identity.firmwareType ?? EFirmwareType.Universal;
|
|
576
585
|
}
|
|
577
586
|
|
|
578
587
|
getCurrentFirmwareVersionString() {
|
|
579
|
-
return
|
|
588
|
+
return parseDeviceVersion(this.state?.versions.firmware).join('.');
|
|
580
589
|
}
|
|
581
590
|
|
|
582
591
|
getCurrentBLEFirmwareVersionString() {
|
|
583
|
-
if (!this.
|
|
584
|
-
return
|
|
592
|
+
if (!this.state) return undefined;
|
|
593
|
+
return parseDeviceVersion(this.state.versions.ble).join('.');
|
|
585
594
|
}
|
|
586
595
|
|
|
587
596
|
getCurrentBootloaderVersionString() {
|
|
588
|
-
if (!this.
|
|
589
|
-
return
|
|
597
|
+
if (!this.state) return undefined;
|
|
598
|
+
return parseDeviceVersion(this.state.versions.bootloader).join('.');
|
|
590
599
|
}
|
|
591
600
|
|
|
592
601
|
getCurrentSafetyChecks() {
|
|
593
|
-
return this.
|
|
602
|
+
return this.state?.settings.safetyChecks;
|
|
594
603
|
}
|
|
595
604
|
|
|
596
605
|
getCurrentMethodVersionRange(
|
|
@@ -635,8 +644,6 @@ export class Device extends EventEmitter {
|
|
|
635
644
|
}
|
|
636
645
|
|
|
637
646
|
supportInputPinOnSoftware(): SupportFeatureType {
|
|
638
|
-
if (this.features) return supportInputPinOnSoftware(this.features);
|
|
639
|
-
|
|
640
647
|
const deviceType = this.getCurrentDeviceType();
|
|
641
648
|
if (
|
|
642
649
|
deviceType === EDeviceType.Touch ||
|
|
@@ -660,8 +667,6 @@ export class Device extends EventEmitter {
|
|
|
660
667
|
return { support: true };
|
|
661
668
|
}
|
|
662
669
|
|
|
663
|
-
if (this.features) return supportModifyHomescreen(this.features);
|
|
664
|
-
|
|
665
670
|
const deviceType = this.getCurrentDeviceType();
|
|
666
671
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
667
672
|
return { support: true };
|
|
@@ -694,7 +699,7 @@ export class Device extends EventEmitter {
|
|
|
694
699
|
Log.debug(
|
|
695
700
|
'getInternalState session param: ',
|
|
696
701
|
`device_id: ${_deviceId}`,
|
|
697
|
-
`
|
|
702
|
+
`currentDeviceId: ${this.getCurrentDeviceId()}`,
|
|
698
703
|
`hasPassphraseState: ${Boolean(this.passphraseState)}`
|
|
699
704
|
);
|
|
700
705
|
|
|
@@ -745,7 +750,7 @@ export class Device extends EventEmitter {
|
|
|
745
750
|
'setInternalState session param: ',
|
|
746
751
|
`hasState: ${Boolean(state)}`,
|
|
747
752
|
`initSession: ${initSession}`,
|
|
748
|
-
`deviceId: ${this.
|
|
753
|
+
`deviceId: ${this.getCurrentDeviceId()}`,
|
|
749
754
|
`hasPassphraseState: ${Boolean(this.passphraseState)}`
|
|
750
755
|
);
|
|
751
756
|
|
|
@@ -778,7 +783,7 @@ export class Device extends EventEmitter {
|
|
|
778
783
|
if (this.isProtocolV2()) {
|
|
779
784
|
this.passphraseState = options?.passphraseState;
|
|
780
785
|
if (this.state && !options?.initSession && !this.protocolV2StateNeedsReload) {
|
|
781
|
-
if (this.
|
|
786
|
+
if (this.state.status.mode === 'bootloader' || this.state.status.mode === 'romloader') {
|
|
782
787
|
return;
|
|
783
788
|
}
|
|
784
789
|
// Normal calls reuse the cache. Explicit getDeviceState refreshes, unlock flow,
|
|
@@ -1065,6 +1070,7 @@ export class Device extends EventEmitter {
|
|
|
1065
1070
|
}
|
|
1066
1071
|
|
|
1067
1072
|
markTransportDisconnected() {
|
|
1073
|
+
this.deviceAcquired = false;
|
|
1068
1074
|
if (!this.isProtocolV2()) return;
|
|
1069
1075
|
this.protocolV2StateNeedsReload = true;
|
|
1070
1076
|
this.clearPreInitialized();
|
|
@@ -1326,20 +1332,17 @@ export class Device extends EventEmitter {
|
|
|
1326
1332
|
break;
|
|
1327
1333
|
}
|
|
1328
1334
|
|
|
1329
|
-
if (this.features?.bootloaderMode) return EOneKeyDeviceMode.bootloader;
|
|
1330
|
-
if (this.features?.initialized === false) return EOneKeyDeviceMode.notInitialized;
|
|
1331
|
-
if (this.features?.noBackup) return EOneKeyDeviceMode.backupMode;
|
|
1332
1335
|
return EOneKeyDeviceMode.normal;
|
|
1333
1336
|
}
|
|
1334
1337
|
|
|
1335
1338
|
getFirmwareVersion() {
|
|
1336
|
-
if (!this.
|
|
1337
|
-
return
|
|
1339
|
+
if (!this.state) return null;
|
|
1340
|
+
return parseDeviceVersion(this.state.versions.firmware);
|
|
1338
1341
|
}
|
|
1339
1342
|
|
|
1340
1343
|
getBLEFirmwareVersion() {
|
|
1341
|
-
if (!this.
|
|
1342
|
-
return
|
|
1344
|
+
if (!this.state) return null;
|
|
1345
|
+
return parseDeviceVersion(this.state.versions.ble);
|
|
1343
1346
|
}
|
|
1344
1347
|
|
|
1345
1348
|
isUsed() {
|
|
@@ -1357,7 +1360,7 @@ export class Device extends EventEmitter {
|
|
|
1357
1360
|
isUsedHere() {
|
|
1358
1361
|
const env = DataManager.getSettings('env');
|
|
1359
1362
|
if (DataManager.isBleConnect(env)) {
|
|
1360
|
-
return
|
|
1363
|
+
return this.deviceAcquired;
|
|
1361
1364
|
}
|
|
1362
1365
|
return this.isUsed() && this.originalDescriptor.session === this.mainId;
|
|
1363
1366
|
}
|
|
@@ -1367,19 +1370,22 @@ export class Device extends EventEmitter {
|
|
|
1367
1370
|
}
|
|
1368
1371
|
|
|
1369
1372
|
isBootloader() {
|
|
1370
|
-
|
|
1373
|
+
if (!this.state) return undefined;
|
|
1374
|
+
return this.state.status.mode === 'bootloader' || this.state.status.mode === 'romloader';
|
|
1371
1375
|
}
|
|
1372
1376
|
|
|
1373
1377
|
isInitialized() {
|
|
1374
|
-
|
|
1378
|
+
if (!this.state) return undefined;
|
|
1379
|
+
return this.state.status.initialized === true;
|
|
1375
1380
|
}
|
|
1376
1381
|
|
|
1377
1382
|
isSeedless() {
|
|
1378
|
-
|
|
1383
|
+
if (!this.state) return undefined;
|
|
1384
|
+
return this.state.status.noBackup === true;
|
|
1379
1385
|
}
|
|
1380
1386
|
|
|
1381
1387
|
isUnacquired(): boolean {
|
|
1382
|
-
return this.
|
|
1388
|
+
return this.state === undefined;
|
|
1383
1389
|
}
|
|
1384
1390
|
|
|
1385
1391
|
hasUnexpectedMode(allow: string[], require: string[]) {
|
|
@@ -1410,7 +1416,7 @@ export class Device extends EventEmitter {
|
|
|
1410
1416
|
deviceType === EDeviceType.Touch ||
|
|
1411
1417
|
deviceType === EDeviceType.Pro ||
|
|
1412
1418
|
deviceType === EDeviceType.Pro2;
|
|
1413
|
-
const unlocked = this.
|
|
1419
|
+
const unlocked = this.state?.status.unlocked;
|
|
1414
1420
|
const preCheckTouch = isModeT && unlocked === false;
|
|
1415
1421
|
const passphraseProtection = this.getCurrentPassphraseProtection();
|
|
1416
1422
|
|
|
@@ -1439,14 +1445,7 @@ export class Device extends EventEmitter {
|
|
|
1439
1445
|
async unlockDevice(pinType: DeviceSessionPinType = DeviceSessionPinType.Main) {
|
|
1440
1446
|
if (this.isProtocolV2()) {
|
|
1441
1447
|
try {
|
|
1442
|
-
await this.commands.typedCall(
|
|
1443
|
-
'DeviceSessionAskPin',
|
|
1444
|
-
'Success',
|
|
1445
|
-
{ type: pinType },
|
|
1446
|
-
{
|
|
1447
|
-
timeoutMs: 120_000,
|
|
1448
|
-
}
|
|
1449
|
-
);
|
|
1448
|
+
await this.commands.typedCall('DeviceSessionAskPin', 'Success', { type: pinType });
|
|
1450
1449
|
} catch (error) {
|
|
1451
1450
|
const errorText =
|
|
1452
1451
|
error instanceof Error
|
|
@@ -1467,8 +1466,7 @@ export class Device extends EventEmitter {
|
|
|
1467
1466
|
type => this.supportUnlockVersionRange()[type]
|
|
1468
1467
|
);
|
|
1469
1468
|
|
|
1470
|
-
const supportAttachPinCapability =
|
|
1471
|
-
this.features,
|
|
1469
|
+
const supportAttachPinCapability = this.state?.capabilities.includes(
|
|
1472
1470
|
Enum_Capability.Capability_AttachToPin
|
|
1473
1471
|
);
|
|
1474
1472
|
const supportUnlock =
|
|
@@ -1479,7 +1477,7 @@ export class Device extends EventEmitter {
|
|
|
1479
1477
|
|
|
1480
1478
|
if (supportUnlock) {
|
|
1481
1479
|
const res = await this.commands.typedCall('UnLockDevice', 'UnLockDeviceResponse');
|
|
1482
|
-
if (this.
|
|
1480
|
+
if (this.state) {
|
|
1483
1481
|
this.updateState(
|
|
1484
1482
|
{
|
|
1485
1483
|
status: {
|
|
@@ -515,6 +515,25 @@ export class DeviceCommands {
|
|
|
515
515
|
subcode,
|
|
516
516
|
firmwareMessage: message,
|
|
517
517
|
});
|
|
518
|
+
} else if (
|
|
519
|
+
DEVICE_SESSION_CALLS.has(callType) &&
|
|
520
|
+
(subcode === DeviceSessionErrorCode.DeviceSessionError_Busy ||
|
|
521
|
+
/^(?:busy|another flow in progress)$/i.test(normalizedMessage))
|
|
522
|
+
) {
|
|
523
|
+
error = ERRORS.TypedError(HardwareErrorCode.DeviceBusy, message, {
|
|
524
|
+
failureCode: code,
|
|
525
|
+
subcode,
|
|
526
|
+
firmwareMessage: message,
|
|
527
|
+
});
|
|
528
|
+
} else if (
|
|
529
|
+
callType === 'DeviceSessionAskPin' &&
|
|
530
|
+
/^passphrase disabled$/i.test(normalizedMessage)
|
|
531
|
+
) {
|
|
532
|
+
error = ERRORS.TypedError(HardwareErrorCode.DeviceNotOpenedPassphrase, message, {
|
|
533
|
+
failureCode: code,
|
|
534
|
+
subcode,
|
|
535
|
+
firmwareMessage: message,
|
|
536
|
+
});
|
|
518
537
|
} else if (
|
|
519
538
|
subcode === DeviceErrorCode.DeviceError_ActionCancelled ||
|
|
520
539
|
isLegacyProtocolV2ActionCancelledFailure
|
package/src/inject.ts
CHANGED
|
@@ -167,6 +167,8 @@ export const createCoreApi = (
|
|
|
167
167
|
|
|
168
168
|
testInitializeDeviceDuration: (connectId, params) =>
|
|
169
169
|
call({ ...params, connectId, method: 'testInitializeDeviceDuration' }),
|
|
170
|
+
testProtocolV2Ping: (connectId, params) =>
|
|
171
|
+
call({ ...params, connectId, method: 'testProtocolV2Ping' }),
|
|
170
172
|
preInitialize: (connectId, params) => call({ ...params, connectId, method: 'preInitialize' }),
|
|
171
173
|
deviceBackup: connectId => call({ connectId, method: 'deviceBackup' }),
|
|
172
174
|
deviceChangePin: (connectId, params) => call({ ...params, connectId, method: 'deviceChangePin' }),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LoggerNames, getLogger } from '../../utils';
|
|
2
2
|
import { isDeviceLockedError } from './lockedError';
|
|
3
3
|
import { isProtocolV2UiEnabled, resolveProtocolV2UiInteraction } from './uiInteraction';
|
|
4
|
+
import { restoreProtocolV2WalletSession } from './walletSession';
|
|
4
5
|
|
|
5
6
|
import type { BaseMethod } from '../../api/BaseMethod';
|
|
6
7
|
import type { Device } from '../../device/Device';
|
|
@@ -10,9 +11,14 @@ const Log = getLogger(LoggerNames.Core);
|
|
|
10
11
|
|
|
11
12
|
type RunnableMethod = Pick<
|
|
12
13
|
BaseMethod,
|
|
13
|
-
|
|
14
|
+
| 'run'
|
|
15
|
+
| 'unlockPolicy'
|
|
16
|
+
| 'protocolV2UiInteraction'
|
|
17
|
+
| 'protocolV2UiMode'
|
|
18
|
+
| 'params'
|
|
19
|
+
| 'payload'
|
|
20
|
+
| 'useDevicePassphraseState'
|
|
14
21
|
> & { name?: string };
|
|
15
|
-
type UnlockableDevice = Pick<Device, 'isProtocolV2' | 'unlockDevice' | 'features'>;
|
|
16
22
|
type UiInteractionCoordinator = Pick<
|
|
17
23
|
ProtocolV2UiInteractionCoordinator,
|
|
18
24
|
'enterMethodInteraction' | 'enterUnlockInteraction' | 'resumeMethodInteraction'
|
|
@@ -20,7 +26,7 @@ type UiInteractionCoordinator = Pick<
|
|
|
20
26
|
|
|
21
27
|
export async function runMethodWithUnlockRetry(
|
|
22
28
|
method: RunnableMethod,
|
|
23
|
-
device:
|
|
29
|
+
device: Device,
|
|
24
30
|
uiCoordinator?: UiInteractionCoordinator
|
|
25
31
|
) {
|
|
26
32
|
const shouldEmitUi = isProtocolV2UiEnabled(method);
|
|
@@ -59,6 +65,17 @@ export async function runMethodWithUnlockRetry(
|
|
|
59
65
|
}
|
|
60
66
|
await device.unlockDevice();
|
|
61
67
|
Log.debug('Protocol V2 unlock completed', { method: method.name });
|
|
68
|
+
const expectedPassphraseState = method.payload?.useEmptyPassphrase
|
|
69
|
+
? undefined
|
|
70
|
+
: method.payload?.passphraseState ?? device.passphraseState;
|
|
71
|
+
if (
|
|
72
|
+
method.useDevicePassphraseState &&
|
|
73
|
+
typeof expectedPassphraseState === 'string' &&
|
|
74
|
+
expectedPassphraseState.length > 0
|
|
75
|
+
) {
|
|
76
|
+
await restoreProtocolV2WalletSession(device, expectedPassphraseState);
|
|
77
|
+
Log.debug('Protocol V2 wallet session restored after unlock', { method: method.name });
|
|
78
|
+
}
|
|
62
79
|
if (shouldEmitUi) {
|
|
63
80
|
uiCoordinator?.resumeMethodInteraction();
|
|
64
81
|
}
|
|
@@ -36,15 +36,12 @@ const getDeviceSession = async (device: Device, request: DeviceSessionGet) => {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const askDevicePassphrase = async (device: Device) => {
|
|
39
|
+
const askDevicePassphrase = async (device: Device, passphrase?: string) => {
|
|
40
40
|
const request = () =>
|
|
41
41
|
device.commands.typedCall(
|
|
42
42
|
'DeviceSessionAskPassphrase',
|
|
43
43
|
'Success',
|
|
44
|
-
{}
|
|
45
|
-
{
|
|
46
|
-
timeoutMs: 120_000,
|
|
47
|
-
}
|
|
44
|
+
passphrase ? { passphrase } : {}
|
|
48
45
|
);
|
|
49
46
|
try {
|
|
50
47
|
return await request();
|
|
@@ -64,7 +61,10 @@ const selectDeviceSession = async (device: Device) => {
|
|
|
64
61
|
reason: 'open-wallet' as const,
|
|
65
62
|
};
|
|
66
63
|
const response = await device.commands.promptPassphrase(
|
|
67
|
-
{
|
|
64
|
+
{
|
|
65
|
+
existsAttachPinUser,
|
|
66
|
+
...metadata,
|
|
67
|
+
},
|
|
68
68
|
{ cancelDeviceOnReject: false }
|
|
69
69
|
);
|
|
70
70
|
const hasHostPassphrase =
|
|
@@ -94,8 +94,11 @@ const selectDeviceSession = async (device: Device) => {
|
|
|
94
94
|
return getDeviceSession(device, {});
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
if (hasHostPassphrase) {
|
|
98
|
+
await askDevicePassphrase(device, response.passphrase);
|
|
99
|
+
return getDeviceSession(device, {});
|
|
100
|
+
}
|
|
101
|
+
|
|
99
102
|
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, metadata);
|
|
100
103
|
await askDevicePassphrase(device);
|
|
101
104
|
return getDeviceSession(device, {});
|
|
@@ -107,6 +110,7 @@ export async function getProtocolV2WalletSession(
|
|
|
107
110
|
initSession?: boolean;
|
|
108
111
|
expectedPassphraseState?: string;
|
|
109
112
|
onlyMainPin?: boolean;
|
|
113
|
+
resumeOnly?: boolean;
|
|
110
114
|
}
|
|
111
115
|
) {
|
|
112
116
|
if (options?.initSession) {
|
|
@@ -152,6 +156,10 @@ export async function getProtocolV2WalletSession(
|
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
if (!response) {
|
|
159
|
+
if (options?.resumeOnly) {
|
|
160
|
+
device.clearInternalState();
|
|
161
|
+
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
162
|
+
}
|
|
155
163
|
response = await selectDeviceSession(device);
|
|
156
164
|
}
|
|
157
165
|
|
|
@@ -182,3 +190,13 @@ export async function getProtocolV2WalletSession(
|
|
|
182
190
|
resumed,
|
|
183
191
|
};
|
|
184
192
|
}
|
|
193
|
+
|
|
194
|
+
export async function restoreProtocolV2WalletSession(
|
|
195
|
+
device: Device,
|
|
196
|
+
expectedPassphraseState: string
|
|
197
|
+
) {
|
|
198
|
+
return getProtocolV2WalletSession(device, {
|
|
199
|
+
expectedPassphraseState,
|
|
200
|
+
resumeOnly: true,
|
|
201
|
+
});
|
|
202
|
+
}
|
package/src/types/api/export.ts
CHANGED
|
@@ -179,6 +179,8 @@ export type {
|
|
|
179
179
|
KaspaSignTransactionParams,
|
|
180
180
|
KaspaSignInputParams,
|
|
181
181
|
KaspaSignOutputParams,
|
|
182
|
+
KaspaStreamingSignInputParams,
|
|
183
|
+
KaspaStreamingSignOutputParams,
|
|
182
184
|
} from './kaspaSignTransaction';
|
|
183
185
|
|
|
184
186
|
export type { NexaAddress, NexaGetAddressParams } from './nexaGetAddress';
|
package/src/types/api/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
deviceGetOnboardingStatus,
|
|
3
3
|
deviceReboot,
|
|
4
4
|
deviceUploadWallpaper,
|
|
5
|
+
testProtocolV2Ping,
|
|
5
6
|
uploadPortfolio,
|
|
6
7
|
} from './protocolV2';
|
|
7
8
|
import type { off, on, removeAllListeners } from './event';
|
|
@@ -157,6 +158,7 @@ export type { DeviceStateScope, GetDeviceStateParams } from './getDeviceState';
|
|
|
157
158
|
export type { GetPassphraseStateParams } from './getPassphraseState';
|
|
158
159
|
export type { OpenWalletSessionParams, OpenWalletSessionPayload } from './openWalletSession';
|
|
159
160
|
export type { ClearSessionCacheParams, ClearSessionCachePayload } from './sessionCache';
|
|
161
|
+
export type { TestProtocolV2PingParams } from './protocolV2';
|
|
160
162
|
|
|
161
163
|
export type CoreApi = {
|
|
162
164
|
/**
|
|
@@ -180,6 +182,7 @@ export type CoreApi = {
|
|
|
180
182
|
* Test function
|
|
181
183
|
*/
|
|
182
184
|
testInitializeDeviceDuration: typeof testInitializeDeviceDuration;
|
|
185
|
+
testProtocolV2Ping: typeof testProtocolV2Ping;
|
|
183
186
|
preInitialize: typeof preInitialize;
|
|
184
187
|
|
|
185
188
|
/**
|
|
@@ -30,6 +30,24 @@ export type KaspaSignOutputParams = {
|
|
|
30
30
|
scriptVersion?: number;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
export type KaspaStreamingSignInputParams = Omit<KaspaSignInputParams, 'output'> & {
|
|
34
|
+
output: {
|
|
35
|
+
satoshis: number | string;
|
|
36
|
+
script?: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type KaspaStreamingSignOutputParams = {
|
|
41
|
+
satoshis: number | string;
|
|
42
|
+
// Streaming protocol describes outputs by address; the device builds the script itself.
|
|
43
|
+
// `address` for an external output, `addressN` (BIP-32 path) for a change output.
|
|
44
|
+
address?: string;
|
|
45
|
+
addressN?: string | number[];
|
|
46
|
+
// Legacy host-prehash fields, unused by the streaming protocol but kept for compatibility.
|
|
47
|
+
script?: string;
|
|
48
|
+
scriptVersion?: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
33
51
|
// Referenced (previous) transactions for the streaming protocol's input
|
|
34
52
|
// verification: the device may ask for the transactions the inputs spend from
|
|
35
53
|
// (selected by prev_tx_id) to verify input amounts on-device.
|
|
@@ -58,8 +76,8 @@ export type KaspaRefTransaction = {
|
|
|
58
76
|
|
|
59
77
|
export type KaspaSignTransactionParams = {
|
|
60
78
|
version: number;
|
|
61
|
-
inputs: KaspaSignInputParams
|
|
62
|
-
outputs: KaspaSignOutputParams
|
|
79
|
+
inputs: Array<KaspaSignInputParams | KaspaStreamingSignInputParams>;
|
|
80
|
+
outputs: Array<KaspaSignOutputParams | KaspaStreamingSignOutputParams>;
|
|
63
81
|
lockTime: number | string;
|
|
64
82
|
sigHashType?: SignatureType;
|
|
65
83
|
sigOpCount?: number;
|
|
@@ -5,35 +5,16 @@ export type OpenWalletSessionParams =
|
|
|
5
5
|
mode: 'standard';
|
|
6
6
|
deviceId?: never;
|
|
7
7
|
passphraseState?: never;
|
|
8
|
-
useEmptyPassphrase?: never;
|
|
9
|
-
initSession?: never;
|
|
10
8
|
}
|
|
11
9
|
| {
|
|
12
10
|
mode: 'select-hidden';
|
|
13
11
|
deviceId?: never;
|
|
14
12
|
passphraseState?: never;
|
|
15
|
-
useEmptyPassphrase?: never;
|
|
16
|
-
initSession?: never;
|
|
17
13
|
}
|
|
18
14
|
| {
|
|
19
15
|
mode: 'resume-hidden';
|
|
20
16
|
deviceId: string;
|
|
21
17
|
passphraseState: string;
|
|
22
|
-
useEmptyPassphrase?: never;
|
|
23
|
-
initSession?: never;
|
|
24
|
-
}
|
|
25
|
-
| {
|
|
26
|
-
/**
|
|
27
|
-
* Compatibility form. `useEmptyPassphrase: true` opens the standard wallet;
|
|
28
|
-
* otherwise `initSession: true` starts a fresh hidden-wallet selection, a
|
|
29
|
-
* complete wallet binding resumes a hidden wallet, and no binding starts the
|
|
30
|
-
* hidden-wallet selection flow.
|
|
31
|
-
*/
|
|
32
|
-
mode?: undefined;
|
|
33
|
-
useEmptyPassphrase?: boolean;
|
|
34
|
-
initSession?: boolean;
|
|
35
|
-
deviceId?: string;
|
|
36
|
-
passphraseState?: string;
|
|
37
18
|
};
|
|
38
19
|
|
|
39
20
|
type OpenWalletSessionPayloadBase = {
|
|
@@ -27,6 +27,16 @@ export type FileInfo = {
|
|
|
27
27
|
|
|
28
28
|
// ── Method signatures ─────────────────────────────────────────────────────
|
|
29
29
|
|
|
30
|
+
export type TestProtocolV2PingParams = CommonParams & {
|
|
31
|
+
/** Firmware diagnostic echo payload, limited to 63 UTF-8 bytes. */
|
|
32
|
+
message?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export declare function testProtocolV2Ping(
|
|
36
|
+
connectId: string,
|
|
37
|
+
params?: TestProtocolV2PingParams
|
|
38
|
+
): Response<Success>;
|
|
39
|
+
|
|
30
40
|
export declare function deviceReboot(
|
|
31
41
|
connectId: string,
|
|
32
42
|
params: CommonParams & DeviceRebootParams
|
package/src/types/device.ts
CHANGED
|
@@ -60,9 +60,21 @@ export const getDeviceUUID = getDeviceSerialNo;
|
|
|
60
60
|
export const getDeviceLabel = (features?: DeviceFeaturesInput) => {
|
|
61
61
|
if (!features) return null;
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const deviceType = getDeviceType(features);
|
|
64
|
+
if (deviceType == null) return null;
|
|
65
|
+
|
|
66
|
+
if ('label' in features && typeof features.label === 'string' && features.label.length > 0) {
|
|
67
|
+
return features.label;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const bleName = getDeviceBleName(features);
|
|
71
|
+
if (bleName) return bleName;
|
|
72
|
+
|
|
73
|
+
if (deviceType === EDeviceType.ClassicPure) {
|
|
74
|
+
return 'OneKey Classic 1S';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return `OneKey ${deviceType.charAt(0).toUpperCase() + deviceType.slice(1)}`;
|
|
66
78
|
};
|
|
67
79
|
|
|
68
80
|
/**
|
|
@@ -98,8 +110,5 @@ export const getMethodVersionRange = (
|
|
|
98
110
|
return undefined;
|
|
99
111
|
};
|
|
100
112
|
|
|
101
|
-
export const isMethodVersionRangeUnsupported = (versionRange?: IVersionRange): boolean =>
|
|
102
|
-
versionRange?.unsupported === true;
|
|
103
|
-
|
|
104
113
|
export const getFirmwareType = (features?: DeviceFeaturesInput) =>
|
|
105
114
|
resolveDeviceFirmwareType(features);
|
|
@@ -12,7 +12,7 @@ import type { DeviceFeaturesInput } from './deviceFeaturesCompat';
|
|
|
12
12
|
|
|
13
13
|
const EMPTY_VERSION: IVersionArray = [0, 0, 0];
|
|
14
14
|
|
|
15
|
-
const parseDeviceVersion = (version?: string | null): IVersionArray => {
|
|
15
|
+
export const parseDeviceVersion = (version?: string | null): IVersionArray => {
|
|
16
16
|
const parsed = version ? semver.parse(version) : null;
|
|
17
17
|
return parsed ? [parsed.major, parsed.minor, parsed.patch] : [...EMPTY_VERSION];
|
|
18
18
|
};
|
package/src/utils/index.ts
CHANGED