@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
|
@@ -25,6 +25,7 @@ describe('AllNetworkGetAddressBase tracing', () => {
|
|
|
25
25
|
connectId: 'connect-id',
|
|
26
26
|
deviceId: 'device-id',
|
|
27
27
|
getVersionRange: jest.fn().mockReturnValue({}),
|
|
28
|
+
assertProtocolSupported: jest.fn(),
|
|
28
29
|
init: jest.fn(),
|
|
29
30
|
name: 'xrpGetAddress',
|
|
30
31
|
responseID: 42,
|
|
@@ -45,6 +46,7 @@ describe('AllNetworkGetAddressBase tracing', () => {
|
|
|
45
46
|
method.device = {
|
|
46
47
|
instanceId: deviceInstanceId,
|
|
47
48
|
getCurrentFirmwareType: jest.fn(),
|
|
49
|
+
getProtocol: jest.fn().mockReturnValue('V1'),
|
|
48
50
|
getCurrentFirmwareVersionString: jest.fn().mockReturnValue('1.0.0'),
|
|
49
51
|
getCurrentMethodVersionRange: jest
|
|
50
52
|
.fn()
|
|
@@ -103,6 +103,41 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
103
103
|
).rejects.toMatchObject({ errorCode: code });
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
+
it.each([
|
|
107
|
+
['DeviceSessionGet', 5, 'Another flow in progress'],
|
|
108
|
+
['DeviceSessionAskPin', 0, 'Busy'],
|
|
109
|
+
])('maps %s firmware busy failures to DeviceBusy', async (callType, subcode, message) => {
|
|
110
|
+
const commands = createCommands();
|
|
111
|
+
|
|
112
|
+
await expect(
|
|
113
|
+
commands._filterCommonTypes(
|
|
114
|
+
{
|
|
115
|
+
type: 'Failure',
|
|
116
|
+
message: { code: 'Failure_ProcessError', subcode, message },
|
|
117
|
+
} as any,
|
|
118
|
+
callType
|
|
119
|
+
)
|
|
120
|
+
).rejects.toMatchObject({ errorCode: HardwareErrorCode.DeviceBusy });
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('maps the current AskPin passphrase-disabled response without relying on a subcode', async () => {
|
|
124
|
+
const commands = createCommands();
|
|
125
|
+
|
|
126
|
+
await expect(
|
|
127
|
+
commands._filterCommonTypes(
|
|
128
|
+
{
|
|
129
|
+
type: 'Failure',
|
|
130
|
+
message: {
|
|
131
|
+
code: 'Failure_ProcessError',
|
|
132
|
+
subcode: 0,
|
|
133
|
+
message: 'Passphrase disabled',
|
|
134
|
+
},
|
|
135
|
+
} as any,
|
|
136
|
+
'DeviceSessionAskPin'
|
|
137
|
+
)
|
|
138
|
+
).rejects.toMatchObject({ errorCode: HardwareErrorCode.DeviceNotOpenedPassphrase });
|
|
139
|
+
});
|
|
140
|
+
|
|
106
141
|
it('rejects the Pro2 bootloader DeviceStatusGet unsupported response', async () => {
|
|
107
142
|
const commands = createCommands();
|
|
108
143
|
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
import BenfenGetAddress from '../src/api/benfen/BenfenGetAddress';
|
|
4
|
+
import ConfluxSignTransaction from '../src/api/conflux/ConfluxSignTransaction';
|
|
5
|
+
import EVMSignTransaction from '../src/api/evm/EVMSignTransaction';
|
|
6
|
+
import EVMSignMessageEIP712 from '../src/api/evm/EVMSignMessageEIP712';
|
|
7
|
+
import KaspaSignTransaction from '../src/api/kaspa/KaspaSignTransaction';
|
|
8
|
+
import XrpSignTransaction from '../src/api/xrp/XrpSignTransaction';
|
|
9
|
+
|
|
10
|
+
import type { Device } from '../src/device/Device';
|
|
11
|
+
|
|
12
|
+
jest.mock('../src/data/config', () => ({
|
|
13
|
+
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
14
|
+
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock('../src/data-manager/TransportManager', () => ({
|
|
18
|
+
getProtocolV1MessageSchema: jest.fn(() => 'v1CurrentSchema'),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock('../src/device/Device', () => ({
|
|
22
|
+
Device: jest.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const KASPA_PATH = "m/44'/111111'/0'/0/0";
|
|
26
|
+
const KASPA_SCRIPT = `20${'ab'.repeat(32)}ac`;
|
|
27
|
+
const KASPA_ADDRESS = 'kaspa:qr0lr4ml9fn3chekrqmjdkergxl93l4wrk3dankcgvjq776s9wn9jkdskewva';
|
|
28
|
+
|
|
29
|
+
const buildKaspaPayload = () => ({
|
|
30
|
+
method: 'kaspaSignTransaction',
|
|
31
|
+
version: 0,
|
|
32
|
+
lockTime: 0,
|
|
33
|
+
inputs: [
|
|
34
|
+
{
|
|
35
|
+
path: KASPA_PATH,
|
|
36
|
+
prevTxId: 'aa'.repeat(32),
|
|
37
|
+
outputIndex: 0,
|
|
38
|
+
sequenceNumber: 0,
|
|
39
|
+
output: { satoshis: 200000, script: KASPA_SCRIPT },
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
outputs: [{ satoshis: 100000, script: KASPA_SCRIPT, scriptVersion: 0 }],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('onekey public-chain parameter compatibility', () => {
|
|
46
|
+
it('keeps the historical EVM contract-deployment representation', () => {
|
|
47
|
+
const transaction = {
|
|
48
|
+
to: '',
|
|
49
|
+
value: '0x0',
|
|
50
|
+
gasPrice: '0x1',
|
|
51
|
+
gasLimit: '0x5208',
|
|
52
|
+
nonce: '0x0',
|
|
53
|
+
chainId: 1,
|
|
54
|
+
data: '0x6000',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const method = new EVMSignTransaction({
|
|
58
|
+
id: 1,
|
|
59
|
+
payload: {
|
|
60
|
+
method: 'evmSignTransaction',
|
|
61
|
+
path: "m/44'/60'/0'/0/0",
|
|
62
|
+
transaction,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
expect(() => method.init()).not.toThrow();
|
|
67
|
+
|
|
68
|
+
const { to: _to, ...transactionWithoutTo } = transaction;
|
|
69
|
+
const missingTo = new EVMSignTransaction({
|
|
70
|
+
id: 2,
|
|
71
|
+
payload: {
|
|
72
|
+
method: 'evmSignTransaction',
|
|
73
|
+
path: "m/44'/60'/0'/0/0",
|
|
74
|
+
transaction: transactionWithoutTo,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(() => missingTo.init()).toThrow('Missing required parameter: to');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('keeps Conflux to validation aligned with onekey', () => {
|
|
82
|
+
const method = new ConfluxSignTransaction({
|
|
83
|
+
id: 1,
|
|
84
|
+
payload: {
|
|
85
|
+
method: 'confluxSignTransaction',
|
|
86
|
+
path: "m/44'/503'/0'/0/0",
|
|
87
|
+
transaction: {
|
|
88
|
+
to: 'cfx:aak2rra2njvd77ezwjvx04kkds9fzagfe6d5r8e957',
|
|
89
|
+
value: '0x0',
|
|
90
|
+
gasLimit: '0x5208',
|
|
91
|
+
gasPrice: '0x1',
|
|
92
|
+
nonce: '0x0',
|
|
93
|
+
epochHeight: '0x1',
|
|
94
|
+
storageLimit: '0x0',
|
|
95
|
+
chainId: 1029,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
expect(() => method.init()).toThrow('should be [hexString]');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('keeps XRP payment amount as the historical number input', () => {
|
|
104
|
+
const createMethod = (amount: number | string) =>
|
|
105
|
+
new XrpSignTransaction({
|
|
106
|
+
id: 1,
|
|
107
|
+
payload: {
|
|
108
|
+
method: 'xrpSignTransaction',
|
|
109
|
+
path: "m/44'/144'/0'/0/0",
|
|
110
|
+
transaction: {
|
|
111
|
+
payment: {
|
|
112
|
+
amount,
|
|
113
|
+
destination: 'rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(() => createMethod(1).init()).not.toThrow();
|
|
120
|
+
expect(() => createMethod('1').init()).toThrow('should be [number]');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('keeps the Kaspa legacy schema while allowing the additive streaming shape', () => {
|
|
124
|
+
const legacyWithoutSigHash = new KaspaSignTransaction({
|
|
125
|
+
id: 1,
|
|
126
|
+
payload: buildKaspaPayload(),
|
|
127
|
+
});
|
|
128
|
+
expect(() => legacyWithoutSigHash.init()).toThrow('Missing required parameter: sigHashType');
|
|
129
|
+
|
|
130
|
+
const legacyWithoutScript = new KaspaSignTransaction({
|
|
131
|
+
id: 2,
|
|
132
|
+
payload: {
|
|
133
|
+
...buildKaspaPayload(),
|
|
134
|
+
sigHashType: 0x41,
|
|
135
|
+
outputs: [{ satoshis: 100000, scriptVersion: 0 }],
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
expect(() => legacyWithoutScript.init()).toThrow('Missing required parameter: script');
|
|
139
|
+
|
|
140
|
+
const streaming = new KaspaSignTransaction({
|
|
141
|
+
id: 3,
|
|
142
|
+
payload: {
|
|
143
|
+
...buildKaspaPayload(),
|
|
144
|
+
inputs: [
|
|
145
|
+
{
|
|
146
|
+
...buildKaspaPayload().inputs[0],
|
|
147
|
+
output: { satoshis: 200000 },
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
outputs: [{ satoshis: 100000, address: KASPA_ADDRESS }],
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
expect(() => streaming.init()).not.toThrow();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('keeps validating the Kaspa legacy input amount', () => {
|
|
157
|
+
const payload = buildKaspaPayload();
|
|
158
|
+
const method = new KaspaSignTransaction({
|
|
159
|
+
id: 1,
|
|
160
|
+
payload: {
|
|
161
|
+
...payload,
|
|
162
|
+
sigHashType: 0x41,
|
|
163
|
+
inputs: [
|
|
164
|
+
{
|
|
165
|
+
...payload.inputs[0],
|
|
166
|
+
output: { script: KASPA_SCRIPT },
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
expect(() => method.init()).toThrow('Missing required parameter: satoshis');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('keeps the deprecated EIP-712 method callable on existing Protocol V1 devices', async () => {
|
|
176
|
+
const method = new EVMSignMessageEIP712({
|
|
177
|
+
id: 1,
|
|
178
|
+
payload: {
|
|
179
|
+
method: 'evmSignMessageEIP712',
|
|
180
|
+
path: "m/44'/60'/0'/0/0",
|
|
181
|
+
domainHash: `0x${'11'.repeat(32)}`,
|
|
182
|
+
messageHash: `0x${'22'.repeat(32)}`,
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
method.init();
|
|
186
|
+
|
|
187
|
+
const typedCall = jest.fn().mockResolvedValue({
|
|
188
|
+
message: {
|
|
189
|
+
address: '0x1234',
|
|
190
|
+
signature: 'abcd',
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
method.device = {
|
|
194
|
+
commands: { typedCall },
|
|
195
|
+
getCurrentFirmwareVersionString: jest.fn(() => '4.10.0'),
|
|
196
|
+
getCurrentMethodVersionRange: jest.fn(() => undefined),
|
|
197
|
+
getCurrentFirmwareType: jest.fn(() => EFirmwareType.Universal),
|
|
198
|
+
getProtocol: jest.fn(() => 'V1'),
|
|
199
|
+
} as unknown as Device;
|
|
200
|
+
|
|
201
|
+
await expect(method.run()).resolves.toEqual({
|
|
202
|
+
address: '0x1234',
|
|
203
|
+
signature: 'abcd',
|
|
204
|
+
});
|
|
205
|
+
expect(typedCall).toHaveBeenCalledTimes(1);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('rejects a Benfen response that omits the address', async () => {
|
|
209
|
+
const method = new BenfenGetAddress({
|
|
210
|
+
id: 1,
|
|
211
|
+
payload: {
|
|
212
|
+
method: 'benfenGetAddress',
|
|
213
|
+
path: "m/44'/728'/0'/0'/0'",
|
|
214
|
+
showOnOneKey: false,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
method.init();
|
|
218
|
+
method.device = {
|
|
219
|
+
commands: {
|
|
220
|
+
typedCall: jest.fn().mockResolvedValue({ message: {} }),
|
|
221
|
+
},
|
|
222
|
+
getCurrentFirmwareVersionString: jest.fn(() => '1.0.0'),
|
|
223
|
+
getCurrentDeviceType: jest.fn(() => EDeviceType.Classic),
|
|
224
|
+
isProtocolV2: jest.fn(() => false),
|
|
225
|
+
} as unknown as Device;
|
|
226
|
+
|
|
227
|
+
await expect(method.run()).rejects.toThrow(/address/i);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TRANSPORT_EVENT } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
1
3
|
import { initConnector, initCore } from '../src/core';
|
|
2
4
|
import { DataManager } from '../src/data-manager';
|
|
3
5
|
import TransportManager from '../src/data-manager/TransportManager';
|
|
@@ -59,6 +61,63 @@ describe('public device lifecycle events', () => {
|
|
|
59
61
|
jest.restoreAllMocks();
|
|
60
62
|
});
|
|
61
63
|
|
|
64
|
+
test('registers the shared device lifecycle listeners exactly once', async () => {
|
|
65
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
66
|
+
core = initCore();
|
|
67
|
+
initConnector();
|
|
68
|
+
|
|
69
|
+
for (const id of ['first-call', 'second-call']) {
|
|
70
|
+
await core.handleMessage({
|
|
71
|
+
id,
|
|
72
|
+
event: IFRAME.CALL,
|
|
73
|
+
type: IFRAME.CALL,
|
|
74
|
+
payload: { method: 'clearSessionCache' },
|
|
75
|
+
} as CoreMessage);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
expect(DevicePool.emitter.listenerCount(DEVICE.CONNECT)).toBe(1);
|
|
79
|
+
expect(DevicePool.emitter.listenerCount(DEVICE.DISCONNECT)).toBe(1);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('converts an internal transport disconnect into a public KnownDevice snapshot', () => {
|
|
83
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
84
|
+
core = initCore();
|
|
85
|
+
initConnector();
|
|
86
|
+
const messages: CoreMessage[] = [];
|
|
87
|
+
core.on(CORE_EVENT, message => messages.push(message));
|
|
88
|
+
const device = createInitializedDevice('V2');
|
|
89
|
+
DevicePool.devicesCache['ble-connect-id'] = device;
|
|
90
|
+
|
|
91
|
+
DevicePool.emitter.emit(TRANSPORT_EVENT.DEVICE_DISCONNECT, {
|
|
92
|
+
id: 'ble-connect-id',
|
|
93
|
+
connectId: 'ble-connect-id',
|
|
94
|
+
name: 'OneKey Test BLE',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const disconnectMessage = messages.find(message => message.type === DEVICE.DISCONNECT);
|
|
98
|
+
expect(disconnectMessage?.payload.device).toMatchObject({
|
|
99
|
+
connectId: 'ble-connect-id',
|
|
100
|
+
serialNo: 'SERIAL-001',
|
|
101
|
+
state: { protocol: 'V2' },
|
|
102
|
+
});
|
|
103
|
+
expect(() => JSON.stringify(disconnectMessage?.payload.device)).not.toThrow();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('treats an acquired BLE device as reusable until the transport disconnects', async () => {
|
|
107
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('desktop-web-ble' as never);
|
|
108
|
+
const device = createInitializedDevice('V2');
|
|
109
|
+
const acquire = jest.spyOn(device, 'acquire').mockResolvedValue(undefined);
|
|
110
|
+
(device as unknown as { deviceAcquired: boolean }).deviceAcquired = true;
|
|
111
|
+
(device as any).commands = { disposed: false };
|
|
112
|
+
|
|
113
|
+
expect(device.isUsedHere()).toBe(true);
|
|
114
|
+
await expect(device.connect('V2')).resolves.toBe(true);
|
|
115
|
+
expect(acquire).not.toHaveBeenCalled();
|
|
116
|
+
|
|
117
|
+
device.markTransportDisconnected();
|
|
118
|
+
expect(device.isUsedHere()).toBe(false);
|
|
119
|
+
});
|
|
120
|
+
|
|
62
121
|
test.each([
|
|
63
122
|
['react-native', 'V1'],
|
|
64
123
|
['react-native', 'V2'],
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
2
|
+
import { Enum_SafetyCheckLevel } from '@onekeyfe/hd-transport';
|
|
3
|
+
|
|
1
4
|
import { Device } from '../src/device/Device';
|
|
2
5
|
import { DEVICE } from '../src/events';
|
|
3
6
|
import { EOneKeyDeviceMode } from '../src/types';
|
|
@@ -8,6 +11,127 @@ jest.mock('../src/data/config', () => ({
|
|
|
8
11
|
}));
|
|
9
12
|
|
|
10
13
|
describe('Device state events', () => {
|
|
14
|
+
test.each([
|
|
15
|
+
['V1', EFirmwareType.BitcoinOnly],
|
|
16
|
+
['V2', EFirmwareType.Universal],
|
|
17
|
+
] as const)(
|
|
18
|
+
'reads the current %s firmware type from canonical state',
|
|
19
|
+
(protocol, firmwareType) => {
|
|
20
|
+
const device = Device.fromDescriptor({
|
|
21
|
+
id: `device-${protocol}`,
|
|
22
|
+
path: `device-${protocol}`,
|
|
23
|
+
protocolType: protocol,
|
|
24
|
+
} as never);
|
|
25
|
+
device.updateState({ protocol, identity: { firmwareType } }, 'initialize');
|
|
26
|
+
const featuresGetter = jest.spyOn(device, 'features', 'get').mockImplementation(() => {
|
|
27
|
+
throw new Error('Legacy Features projection should not be read');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(device.getCurrentFirmwareType()).toBe(firmwareType);
|
|
31
|
+
featuresGetter.mockRestore();
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
test('keeps the universal firmware fallback before device state is initialized', () => {
|
|
36
|
+
const device = Device.fromDescriptor({ id: 'pending', path: 'pending' } as never);
|
|
37
|
+
|
|
38
|
+
expect(device.getCurrentFirmwareType()).toBe(EFirmwareType.Universal);
|
|
39
|
+
expect(device.getCurrentDeviceType()).toBe(EDeviceType.Unknown);
|
|
40
|
+
expect(device.getCurrentDeviceId()).toBeUndefined();
|
|
41
|
+
expect(device.getCurrentSerialNo()).toBe('');
|
|
42
|
+
expect(device.getCurrentBleName()).toBeNull();
|
|
43
|
+
expect(device.getCurrentLabel()).toBeNull();
|
|
44
|
+
expect(device.getCurrentFirmwareVersionString()).toBe('0.0.0');
|
|
45
|
+
expect(device.getCurrentBLEFirmwareVersionString()).toBeUndefined();
|
|
46
|
+
expect(device.getCurrentBootloaderVersionString()).toBeUndefined();
|
|
47
|
+
expect(device.getFirmwareVersion()).toBeNull();
|
|
48
|
+
expect(device.getBLEFirmwareVersion()).toBeNull();
|
|
49
|
+
expect(device.isUnacquired()).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('reads current device data from canonical state without projecting Features', () => {
|
|
53
|
+
const device = Device.fromDescriptor({
|
|
54
|
+
id: 'pro2-state',
|
|
55
|
+
path: 'pro2-state',
|
|
56
|
+
protocolType: 'V2',
|
|
57
|
+
} as never);
|
|
58
|
+
device.updateState(
|
|
59
|
+
{
|
|
60
|
+
protocol: 'V2',
|
|
61
|
+
identity: {
|
|
62
|
+
deviceType: EDeviceType.Pro2,
|
|
63
|
+
deviceId: 'wallet-id',
|
|
64
|
+
serialNo: 'SERIAL-PRO2',
|
|
65
|
+
label: null,
|
|
66
|
+
bleName: 'Pro2 1234',
|
|
67
|
+
},
|
|
68
|
+
status: {
|
|
69
|
+
mode: 'normal',
|
|
70
|
+
initialized: true,
|
|
71
|
+
unlocked: false,
|
|
72
|
+
noBackup: false,
|
|
73
|
+
passphraseProtection: false,
|
|
74
|
+
},
|
|
75
|
+
settings: { safetyChecks: Enum_SafetyCheckLevel.Strict },
|
|
76
|
+
versions: {
|
|
77
|
+
firmware: '5.1.2',
|
|
78
|
+
bootloader: '2.0.0',
|
|
79
|
+
ble: null,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
'initialize'
|
|
83
|
+
);
|
|
84
|
+
const featuresGetter = jest.spyOn(device, 'features', 'get').mockImplementation(() => {
|
|
85
|
+
throw new Error('Legacy Features projection should not be read');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(device.getCurrentDeviceType()).toBe(EDeviceType.Pro2);
|
|
89
|
+
expect(device.getCurrentDeviceId()).toBe('wallet-id');
|
|
90
|
+
expect(device.getCurrentSerialNo()).toBe('SERIAL-PRO2');
|
|
91
|
+
expect(device.getCurrentBleName()).toBe('Pro2 1234');
|
|
92
|
+
expect(device.getCurrentLabel()).toBeNull();
|
|
93
|
+
expect((device as any).getCurrentDisplayName()).toBe('Pro2 1234');
|
|
94
|
+
expect(device.getCurrentPassphraseProtection()).toBe(false);
|
|
95
|
+
expect(device.getCurrentFirmwareVersionString()).toBe('5.1.2');
|
|
96
|
+
expect(device.getCurrentBLEFirmwareVersionString()).toBe('0.0.0');
|
|
97
|
+
expect(device.getCurrentBootloaderVersionString()).toBe('2.0.0');
|
|
98
|
+
expect(device.getCurrentSafetyChecks()).toBe(Enum_SafetyCheckLevel.Strict);
|
|
99
|
+
expect(device.getFirmwareVersion()).toEqual([5, 1, 2]);
|
|
100
|
+
expect(device.getBLEFirmwareVersion()).toEqual([0, 0, 0]);
|
|
101
|
+
expect(device.isBootloader()).toBe(false);
|
|
102
|
+
expect(device.isInitialized()).toBe(true);
|
|
103
|
+
expect(device.isSeedless()).toBe(false);
|
|
104
|
+
expect(device.isUnacquired()).toBe(false);
|
|
105
|
+
expect(device.hasUsePassphrase()).toBe(true);
|
|
106
|
+
expect(device.supportInputPinOnSoftware()).toEqual({ support: false });
|
|
107
|
+
expect(device.supportModifyHomescreen()).toEqual({ support: true });
|
|
108
|
+
featuresGetter.mockRestore();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('keeps legacy display-name fallbacks separate from the canonical label', () => {
|
|
112
|
+
const device = Device.fromDescriptor({ id: 'pure', path: 'pure' } as never);
|
|
113
|
+
device.updateState(
|
|
114
|
+
{
|
|
115
|
+
protocol: 'V1',
|
|
116
|
+
identity: {
|
|
117
|
+
deviceType: EDeviceType.ClassicPure,
|
|
118
|
+
label: null,
|
|
119
|
+
bleName: null,
|
|
120
|
+
},
|
|
121
|
+
status: { mode: 'normal', initialized: true },
|
|
122
|
+
},
|
|
123
|
+
'initialize'
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
expect(device.getCurrentLabel()).toBeNull();
|
|
127
|
+
expect(device.getCurrentDisplayName()).toBe('OneKey Classic 1S');
|
|
128
|
+
expect(device.toMessageObject()).toMatchObject({
|
|
129
|
+
name: 'OneKey Classic 1S',
|
|
130
|
+
label: 'OneKey Classic 1S',
|
|
131
|
+
state: { identity: { label: null } },
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
11
135
|
test('emits only the canonical state event for Protocol V2', () => {
|
|
12
136
|
const device = Device.fromDescriptor({
|
|
13
137
|
id: 'pro2',
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Enum_SafetyCheckLevel } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
1
3
|
import AllNetworkGetAddressBase from '../src/api/allnetwork/AllNetworkGetAddressBase';
|
|
2
4
|
import EvmGetAddress from '../src/api/evm/EVMGetAddress';
|
|
3
5
|
import EVMGetPublicKey from '../src/api/evm/EVMGetPublicKey';
|
|
4
6
|
import { findMethod } from '../src/api/utils';
|
|
5
7
|
import { getDeviceType, getFirmwareType, getMethodVersionRange } from '../src/utils';
|
|
6
8
|
import { getDeviceFirmwareVersion } from '../src/utils/deviceVersionUtils';
|
|
7
|
-
import { Enum_SafetyCheckLevel } from '@onekeyfe/hd-transport';
|
|
8
9
|
|
|
9
10
|
import type { EDeviceType } from '@onekeyfe/hd-shared';
|
|
10
11
|
|
|
@@ -33,6 +34,7 @@ const createDevice = (onekeyDeviceType: string) => {
|
|
|
33
34
|
},
|
|
34
35
|
// BaseMethod reads state through Device accessors; reuse production mappers in the stub.
|
|
35
36
|
isProtocolV2: () => false,
|
|
37
|
+
getProtocol: () => 'V1' as const,
|
|
36
38
|
getCurrentDeviceType: () => getDeviceType(features as any),
|
|
37
39
|
getCurrentSafetyChecks: () => features.safety_checks,
|
|
38
40
|
getCurrentFirmwareType: () => getFirmwareType(features as any),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
1
|
+
import { ERRORS, EDeviceType, EFirmwareType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import CheckAllFirmwareRelease from '../../src/api/CheckAllFirmwareRelease';
|
|
4
4
|
import { buildFirmwareUpdatePlan } from '../../src/api/firmware/FirmwareUpdatePlan';
|
|
@@ -36,7 +36,40 @@ const mockGetFirmwareReleaseInfo = getFirmwareReleaseInfo as jest.MockedFunction
|
|
|
36
36
|
typeof getFirmwareReleaseInfo
|
|
37
37
|
>;
|
|
38
38
|
|
|
39
|
+
const noUpdate = {
|
|
40
|
+
status: 'valid' as const,
|
|
41
|
+
release: undefined,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const createMethod = (serialNo = 'device-id') => {
|
|
45
|
+
const method = new CheckAllFirmwareRelease({
|
|
46
|
+
id: 1,
|
|
47
|
+
payload: {
|
|
48
|
+
method: 'checkAllFirmwareRelease',
|
|
49
|
+
platform: 'native',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
method.init();
|
|
53
|
+
method.device = {
|
|
54
|
+
features: {
|
|
55
|
+
deviceType: EDeviceType.Classic1s,
|
|
56
|
+
serialNo,
|
|
57
|
+
firmwareType: EFirmwareType.Universal,
|
|
58
|
+
firmwareVersion: '1.0.0',
|
|
59
|
+
bootloaderVersion: '1.0.0',
|
|
60
|
+
},
|
|
61
|
+
} as typeof method.device;
|
|
62
|
+
return method;
|
|
63
|
+
};
|
|
64
|
+
|
|
39
65
|
describe('CheckAllFirmwareRelease', () => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
jest.clearAllMocks();
|
|
68
|
+
mockGetFirmwareReleaseInfo.mockReturnValue(noUpdate);
|
|
69
|
+
mockGetBootloaderReleaseInfo.mockReturnValue(noUpdate);
|
|
70
|
+
mockGetBleFirmwareReleaseInfo.mockReturnValue(noUpdate);
|
|
71
|
+
});
|
|
72
|
+
|
|
40
73
|
test('keeps release information available when an optional Plan cannot be built', async () => {
|
|
41
74
|
const firmware = {
|
|
42
75
|
status: 'outdated' as const,
|
|
@@ -45,36 +78,14 @@ describe('CheckAllFirmwareRelease', () => {
|
|
|
45
78
|
version: [3, 0, 0],
|
|
46
79
|
},
|
|
47
80
|
};
|
|
48
|
-
const noUpdate = {
|
|
49
|
-
status: 'valid' as const,
|
|
50
|
-
release: undefined,
|
|
51
|
-
};
|
|
52
81
|
mockGetFirmwareReleaseInfo.mockReturnValue(firmware);
|
|
53
|
-
mockGetBootloaderReleaseInfo.mockReturnValue(noUpdate);
|
|
54
|
-
mockGetBleFirmwareReleaseInfo.mockReturnValue(noUpdate);
|
|
55
82
|
mockBuildFirmwareUpdatePlan.mockImplementation(() => {
|
|
56
|
-
throw
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const method = new CheckAllFirmwareRelease({
|
|
60
|
-
id: 1,
|
|
61
|
-
payload: {
|
|
62
|
-
method: 'checkAllFirmwareRelease',
|
|
63
|
-
platform: 'native',
|
|
64
|
-
},
|
|
83
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Plan cannot be built', {
|
|
84
|
+
firmwareUpdateCode: 'FirmwarePlanInvalid',
|
|
85
|
+
});
|
|
65
86
|
});
|
|
66
|
-
method.init();
|
|
67
|
-
method.device = {
|
|
68
|
-
features: {
|
|
69
|
-
deviceType: EDeviceType.Classic1s,
|
|
70
|
-
serialNo: '',
|
|
71
|
-
firmwareType: EFirmwareType.Universal,
|
|
72
|
-
firmwareVersion: '1.0.0',
|
|
73
|
-
bootloaderVersion: '1.0.0',
|
|
74
|
-
},
|
|
75
|
-
} as typeof method.device;
|
|
76
87
|
|
|
77
|
-
await expect(
|
|
88
|
+
await expect(createMethod('').run()).resolves.toEqual(
|
|
78
89
|
expect.objectContaining({
|
|
79
90
|
firmware,
|
|
80
91
|
bootloader: noUpdate,
|
|
@@ -83,4 +94,34 @@ describe('CheckAllFirmwareRelease', () => {
|
|
|
83
94
|
})
|
|
84
95
|
);
|
|
85
96
|
});
|
|
97
|
+
|
|
98
|
+
test('returns an optional Plan when the builder succeeds', async () => {
|
|
99
|
+
const plan = {
|
|
100
|
+
schemaVersion: 2 as const,
|
|
101
|
+
planDigest: 'a'.repeat(64),
|
|
102
|
+
executor: 'v3' as const,
|
|
103
|
+
deviceIdentity: 'device-id',
|
|
104
|
+
deviceModel: EDeviceType.Classic1s,
|
|
105
|
+
firmwareType: EFirmwareType.Universal,
|
|
106
|
+
platform: 'native' as const,
|
|
107
|
+
artifacts: [],
|
|
108
|
+
targetsToUpdate: [],
|
|
109
|
+
};
|
|
110
|
+
mockBuildFirmwareUpdatePlan.mockReturnValue(plan);
|
|
111
|
+
|
|
112
|
+
await expect(createMethod().run()).resolves.toEqual(
|
|
113
|
+
expect.objectContaining({
|
|
114
|
+
firmwareUpdatePlan: plan,
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('does not hide unexpected Plan builder failures', async () => {
|
|
120
|
+
const unexpectedError = new Error('unexpected builder failure');
|
|
121
|
+
mockBuildFirmwareUpdatePlan.mockImplementation(() => {
|
|
122
|
+
throw unexpectedError;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
await expect(createMethod().run()).rejects.toBe(unexpectedError);
|
|
126
|
+
});
|
|
86
127
|
});
|
|
@@ -293,6 +293,34 @@ describe('buildFirmwareUpdatePlan', () => {
|
|
|
293
293
|
expect(first.planDigest).not.toBe(desktop.planDigest);
|
|
294
294
|
});
|
|
295
295
|
|
|
296
|
+
test('normalizes a malformed artifact URL to FirmwarePlanInvalid', () => {
|
|
297
|
+
let thrown: unknown;
|
|
298
|
+
try {
|
|
299
|
+
buildFirmwareUpdatePlan({
|
|
300
|
+
features: createFeatures({ deviceType: EDeviceType.Classic1s }),
|
|
301
|
+
firmwareType: EFirmwareType.Universal,
|
|
302
|
+
platform: 'native',
|
|
303
|
+
firmware: {
|
|
304
|
+
status: 'outdated',
|
|
305
|
+
release: {
|
|
306
|
+
url: 'not a url',
|
|
307
|
+
version: [3, 0, 0],
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
ble: noUpdate,
|
|
311
|
+
bootloader: noUpdate,
|
|
312
|
+
});
|
|
313
|
+
} catch (error) {
|
|
314
|
+
thrown = error;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
expect(thrown).toMatchObject({
|
|
318
|
+
params: {
|
|
319
|
+
firmwareUpdateCode: 'FirmwarePlanInvalid',
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
|
|
296
324
|
test('binds trusted artifact integrity metadata into the plan digest', () => {
|
|
297
325
|
const createPlan = (fingerprint: string) =>
|
|
298
326
|
buildFirmwareUpdatePlan({
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { KaspaSignInputParams, KaspaSignOutputParams } from '../src/types';
|
|
2
|
+
|
|
3
|
+
const input: KaspaSignInputParams = {
|
|
4
|
+
path: "m/44'/111111'/0'/0/0",
|
|
5
|
+
prevTxId: 'aa'.repeat(32),
|
|
6
|
+
outputIndex: 0,
|
|
7
|
+
sequenceNumber: 0,
|
|
8
|
+
output: { satoshis: 200000 },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const output: KaspaSignOutputParams = {
|
|
12
|
+
satoshis: 100000,
|
|
13
|
+
address: 'kaspa:example',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { input, output };
|