@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
|
@@ -133,14 +133,6 @@ export default class FirmwareUpdate extends BaseMethod<Params> {
|
|
|
133
133
|
const { features, commands } = device;
|
|
134
134
|
const deviceType = device.getCurrentDeviceType();
|
|
135
135
|
|
|
136
|
-
// Protocol V2 (Pro2) uses DeviceFirmwareUpdate and must not enter this legacy flow.
|
|
137
|
-
if (device.isProtocolV2()) {
|
|
138
|
-
throw ERRORS.TypedError(
|
|
139
|
-
HardwareErrorCode.RuntimeError,
|
|
140
|
-
'Protocol V2 firmware update must use firmwareUpdateV4'
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
136
|
if (!device.isBootloader() && features) {
|
|
145
137
|
const serialNo = device.getCurrentSerialNo();
|
|
146
138
|
// should go to bootloader mode manually
|
|
@@ -140,12 +140,6 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
async run() {
|
|
143
|
-
if (this.device.isProtocolV2()) {
|
|
144
|
-
throw ERRORS.TypedError(
|
|
145
|
-
HardwareErrorCode.RuntimeError,
|
|
146
|
-
'Protocol V2 firmware update must use firmwareUpdateV4'
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
143
|
Log.debug('FirmwareUpdateV3 strategy: Protocol V1');
|
|
150
144
|
return this.runProtocolV1();
|
|
151
145
|
}
|
|
@@ -2,6 +2,7 @@ import { ERRORS, HardwareError, HardwareErrorCode, wait } from '@onekeyfe/hd-sha
|
|
|
2
2
|
import {
|
|
3
3
|
DeviceRebootType,
|
|
4
4
|
PROTOCOL_V2_BLE_FILE_CHUNK_SIZE,
|
|
5
|
+
PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE,
|
|
5
6
|
PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE,
|
|
6
7
|
} from '@onekeyfe/hd-transport';
|
|
7
8
|
|
|
@@ -393,7 +394,10 @@ export const assertProtocolV2ReconnectIdentity = (
|
|
|
393
394
|
actualSerialNumber?: string
|
|
394
395
|
) => {
|
|
395
396
|
if (!expectedSerialNumber || !actualSerialNumber) {
|
|
396
|
-
|
|
397
|
+
throw ERRORS.TypedError(
|
|
398
|
+
HardwareErrorCode.DeviceNotFound,
|
|
399
|
+
'Protocol V2 reconnect physical identity is unavailable'
|
|
400
|
+
);
|
|
397
401
|
}
|
|
398
402
|
if (actualSerialNumber !== expectedSerialNumber) {
|
|
399
403
|
throw ERRORS.TypedError(
|
|
@@ -414,6 +418,10 @@ export const assertProtocolV2ReconnectIdentity = (
|
|
|
414
418
|
export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareUpdateV4Params> {
|
|
415
419
|
private protocolV2ExpectedSerialNumber?: string;
|
|
416
420
|
|
|
421
|
+
getSupportedProtocols() {
|
|
422
|
+
return ['V2'] as const;
|
|
423
|
+
}
|
|
424
|
+
|
|
417
425
|
private protocolV2PreparedSources: FirmwareByteSource[] = [];
|
|
418
426
|
|
|
419
427
|
private protocolV2ExecutionInLoader = false;
|
|
@@ -422,6 +430,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
422
430
|
|
|
423
431
|
private protocolV2LatestFinalFeatures?: Features;
|
|
424
432
|
|
|
433
|
+
private protocolV2FinalStatusVerified = false;
|
|
434
|
+
|
|
425
435
|
init() {
|
|
426
436
|
this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE];
|
|
427
437
|
this.requireDeviceMode = [];
|
|
@@ -538,13 +548,17 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
538
548
|
};
|
|
539
549
|
}
|
|
540
550
|
|
|
541
|
-
private getProtocolV2FirmwareChunkSize() {
|
|
551
|
+
private getProtocolV2FirmwareChunkSize(direction: 'read' | 'write' = 'write') {
|
|
542
552
|
const payloadChunkSize = Number(this.params?.chunkSize);
|
|
543
553
|
const env = DataManager.getSettings('env');
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
554
|
+
const isBle = this.params?.platform === 'native' || (env && DataManager.isBleConnect(env));
|
|
555
|
+
let maxChunkSize = PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
556
|
+
if (isBle) {
|
|
557
|
+
maxChunkSize =
|
|
558
|
+
direction === 'read'
|
|
559
|
+
? PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE
|
|
560
|
+
: PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
|
|
561
|
+
}
|
|
548
562
|
if (!Number.isFinite(payloadChunkSize) || payloadChunkSize <= 0) {
|
|
549
563
|
return maxChunkSize;
|
|
550
564
|
}
|
|
@@ -555,13 +569,6 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
555
569
|
}
|
|
556
570
|
|
|
557
571
|
async run() {
|
|
558
|
-
if (!this.device.isProtocolV2()) {
|
|
559
|
-
throw ERRORS.TypedError(
|
|
560
|
-
HardwareErrorCode.RuntimeError,
|
|
561
|
-
'firmwareUpdateV4 requires a Protocol V2 device'
|
|
562
|
-
);
|
|
563
|
-
}
|
|
564
|
-
|
|
565
572
|
Log.debug('FirmwareUpdateV4 strategy: Protocol V2');
|
|
566
573
|
return this.runProtocolV2();
|
|
567
574
|
}
|
|
@@ -872,9 +879,16 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
872
879
|
Math.floor(statusVersion / 0x100) % 0x100
|
|
873
880
|
}.${statusVersion % 0x100}`;
|
|
874
881
|
if (!observedVersion) {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
882
|
+
if (this.protocolV2FinalStatusVerified) {
|
|
883
|
+
Log.warn(
|
|
884
|
+
`Protocol V2 target ${target} has no observable final version; completed target status is authoritative`
|
|
885
|
+
);
|
|
886
|
+
} else {
|
|
887
|
+
throw ERRORS.TypedError(
|
|
888
|
+
HardwareErrorCode.FirmwareVerificationFailed,
|
|
889
|
+
`Protocol V2 target ${target} has no observable final version after status fallback`
|
|
890
|
+
);
|
|
891
|
+
}
|
|
878
892
|
} else if (observedVersion !== expectedVersion) {
|
|
879
893
|
throw ERRORS.TypedError(
|
|
880
894
|
HardwareErrorCode.FirmwareVerificationFailed,
|
|
@@ -944,8 +958,10 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
944
958
|
preparedPlan: this.params.preparedPlan,
|
|
945
959
|
deviceIdentity: serialNumber,
|
|
946
960
|
});
|
|
947
|
-
} else {
|
|
961
|
+
} else if (this.params?.expectedDeviceId) {
|
|
948
962
|
assertProtocolV2ReconnectIdentity(this.params?.expectedDeviceId, serialNumber);
|
|
963
|
+
} else {
|
|
964
|
+
assertProtocolV2ReconnectIdentity(serialNumber, serialNumber);
|
|
949
965
|
}
|
|
950
966
|
this.protocolV2ExpectedSerialNumber = serialNumber;
|
|
951
967
|
}
|
|
@@ -1047,7 +1063,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1047
1063
|
return null;
|
|
1048
1064
|
}
|
|
1049
1065
|
|
|
1050
|
-
const chunkSize = this.getProtocolV2FirmwareChunkSize();
|
|
1066
|
+
const chunkSize = this.getProtocolV2FirmwareChunkSize('read');
|
|
1051
1067
|
const chunks: Uint8Array[] = [];
|
|
1052
1068
|
let offset = 0;
|
|
1053
1069
|
while (offset < PROTOCOL_V2_OKPP_HEADER_SIZE) {
|
|
@@ -1745,6 +1761,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1745
1761
|
private async waitForProtocolV2FirmwareUpdateComplete(
|
|
1746
1762
|
targets: Array<{ target_id: number; path: string }>
|
|
1747
1763
|
) {
|
|
1764
|
+
this.protocolV2FinalStatusVerified = false;
|
|
1748
1765
|
const expectedTargetIds = new Set(targets.map(target => target.target_id));
|
|
1749
1766
|
const expectedPaths = new Map(targets.map(target => [target.target_id, target.path]));
|
|
1750
1767
|
const startTime = Date.now();
|
|
@@ -1774,6 +1791,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1774
1791
|
expectedPaths
|
|
1775
1792
|
)
|
|
1776
1793
|
) {
|
|
1794
|
+
this.protocolV2FinalStatusVerified = true;
|
|
1777
1795
|
return;
|
|
1778
1796
|
}
|
|
1779
1797
|
lastError = new Error('Protocol V2 firmware targets are still installing');
|
|
@@ -17,6 +17,10 @@ const isLoaderMode = (mode: string) => mode === 'bootloader' || mode === 'romloa
|
|
|
17
17
|
export default class GetDeviceState extends BaseMethod<
|
|
18
18
|
Required<Pick<GetDeviceStateParams, 'scope'>>
|
|
19
19
|
> {
|
|
20
|
+
getSupportedProtocols() {
|
|
21
|
+
return ['V1', 'V2'] as const;
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
init() {
|
|
21
25
|
const scope = (this.payload.scope ?? 'runtime') as DeviceStateScope;
|
|
22
26
|
if (!Object.prototype.hasOwnProperty.call(SCOPE_SECTIONS, scope)) {
|
package/src/api/GetFeatures.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ERRORS, HardwareErrorCode
|
|
1
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
4
4
|
import { projectFeatures } from '../device/DeviceStateProjector';
|
|
@@ -20,9 +20,6 @@ export default class GetFeatures extends BaseMethod {
|
|
|
20
20
|
if (this.payload?.detectBootloaderDevice && this.device.isBootloader()) {
|
|
21
21
|
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceDetectInBootloaderMode));
|
|
22
22
|
}
|
|
23
|
-
if (this.device.isProtocolV2()) {
|
|
24
|
-
throw createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
25
|
-
}
|
|
26
23
|
const state = await this.device.getDeviceState({
|
|
27
24
|
includeRaw: true,
|
|
28
25
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
|
-
import { createDeviceNotSupportMethodError } from '@onekeyfe/hd-shared';
|
|
3
2
|
|
|
4
3
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
5
4
|
import { fixVersion } from '../utils/deviceFeaturesUtils';
|
|
@@ -26,10 +25,6 @@ export default class GetOnekeyFeatures extends BaseMethod {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
async run() {
|
|
29
|
-
if (this.device.isProtocolV2()) {
|
|
30
|
-
throw createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
31
|
-
}
|
|
32
|
-
|
|
33
28
|
const { message } = await this.device.commands.typedCall('OnekeyGetFeatures', 'OnekeyFeatures');
|
|
34
29
|
normalizeOnekeyFirmwareVersion(message);
|
|
35
30
|
return Promise.resolve(message);
|
|
@@ -5,6 +5,10 @@ import { getPassphraseStateWithRefreshDeviceInfo } from '../utils/deviceFeatures
|
|
|
5
5
|
import { BaseMethod } from './BaseMethod';
|
|
6
6
|
|
|
7
7
|
export default class GetPassphraseState extends BaseMethod {
|
|
8
|
+
getSupportedProtocols() {
|
|
9
|
+
return ['V1', 'V2'] as const;
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
init() {
|
|
9
13
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
10
14
|
this.useDevicePassphraseState = false;
|
|
@@ -21,13 +21,6 @@ const requiredString = (value: unknown, name: string) => {
|
|
|
21
21
|
return value.trim();
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const optionalBoolean = (value: unknown, name: string) => {
|
|
25
|
-
if (value !== undefined && typeof value !== 'boolean') {
|
|
26
|
-
throw invalidParameter(`Parameter [${name}] must be a boolean.`);
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
24
|
const wasResumed = (session: unknown) =>
|
|
32
25
|
!!session &&
|
|
33
26
|
typeof session === 'object' &&
|
|
@@ -53,72 +46,31 @@ const requireHiddenWalletResponse = (session: {
|
|
|
53
46
|
};
|
|
54
47
|
};
|
|
55
48
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
passphraseState: string;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const normalizeParams = (payload: Record<string, unknown>): NormalizedOpenWalletSessionParams => {
|
|
64
|
-
if (payload.mode !== undefined) {
|
|
65
|
-
if (
|
|
66
|
-
payload.mode !== 'standard' &&
|
|
67
|
-
payload.mode !== 'select-hidden' &&
|
|
68
|
-
payload.mode !== 'resume-hidden'
|
|
69
|
-
) {
|
|
70
|
-
throw invalidParameter(
|
|
71
|
-
'Parameter [mode] must be one of standard, select-hidden, or resume-hidden.'
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
if (payload.useEmptyPassphrase !== undefined || payload.initSession !== undefined) {
|
|
75
|
-
throw invalidParameter(
|
|
76
|
-
'Parameters [useEmptyPassphrase] and [initSession] cannot be used with [mode].'
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
if (payload.mode === 'standard' || payload.mode === 'select-hidden') {
|
|
80
|
-
if (payload.deviceId !== undefined || payload.passphraseState !== undefined) {
|
|
81
|
-
throw invalidParameter(
|
|
82
|
-
'Parameters [deviceId] and [passphraseState] are only allowed with mode [resume-hidden].'
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
return { mode: payload.mode };
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
mode: 'resume-hidden',
|
|
89
|
-
deviceId: requiredString(payload.deviceId, 'deviceId'),
|
|
90
|
-
passphraseState: requiredString(payload.passphraseState, 'passphraseState'),
|
|
91
|
-
};
|
|
49
|
+
const normalizeParams = (payload: Record<string, unknown>): OpenWalletSessionParams => {
|
|
50
|
+
if (payload.mode === undefined) {
|
|
51
|
+
throw invalidParameter('Parameter [mode] is required.');
|
|
92
52
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
53
|
+
if (
|
|
54
|
+
payload.mode !== 'standard' &&
|
|
55
|
+
payload.mode !== 'select-hidden' &&
|
|
56
|
+
payload.mode !== 'resume-hidden'
|
|
57
|
+
) {
|
|
58
|
+
throw invalidParameter(
|
|
59
|
+
'Parameter [mode] must be one of standard, select-hidden, or resume-hidden.'
|
|
60
|
+
);
|
|
98
61
|
}
|
|
99
|
-
if (initSession
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
payload.passphraseState === undefined
|
|
104
|
-
? undefined
|
|
105
|
-
: requiredString(payload.passphraseState, 'passphraseState');
|
|
106
|
-
return {
|
|
107
|
-
mode: 'select-hidden',
|
|
108
|
-
...(passphraseState
|
|
109
|
-
? {
|
|
110
|
-
legacySessionToClear: {
|
|
111
|
-
deviceId,
|
|
112
|
-
passphraseState,
|
|
113
|
-
},
|
|
114
|
-
}
|
|
115
|
-
: {}),
|
|
116
|
-
};
|
|
62
|
+
if (payload.useEmptyPassphrase !== undefined || payload.initSession !== undefined) {
|
|
63
|
+
throw invalidParameter(
|
|
64
|
+
'Legacy parameters [useEmptyPassphrase] and [initSession] are not supported by openWalletSession.'
|
|
65
|
+
);
|
|
117
66
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
67
|
+
if (payload.mode === 'standard' || payload.mode === 'select-hidden') {
|
|
68
|
+
if (payload.deviceId !== undefined || payload.passphraseState !== undefined) {
|
|
69
|
+
throw invalidParameter(
|
|
70
|
+
'Parameters [deviceId] and [passphraseState] are only allowed with mode [resume-hidden].'
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return { mode: payload.mode };
|
|
122
74
|
}
|
|
123
75
|
return {
|
|
124
76
|
mode: 'resume-hidden',
|
|
@@ -127,7 +79,11 @@ const normalizeParams = (payload: Record<string, unknown>): NormalizedOpenWallet
|
|
|
127
79
|
};
|
|
128
80
|
};
|
|
129
81
|
|
|
130
|
-
export default class OpenWalletSession extends BaseMethod<
|
|
82
|
+
export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParams> {
|
|
83
|
+
getSupportedProtocols() {
|
|
84
|
+
return ['V1', 'V2'] as const;
|
|
85
|
+
}
|
|
86
|
+
|
|
131
87
|
init() {
|
|
132
88
|
this.useDevicePassphraseState = false;
|
|
133
89
|
this.skipForceUpdateCheck = true;
|
|
@@ -139,33 +95,18 @@ export default class OpenWalletSession extends BaseMethod<NormalizedOpenWalletSe
|
|
|
139
95
|
const isProtocolV2 = this.device.isProtocolV2();
|
|
140
96
|
const state = await this.device.getDeviceState({ refreshSections: ['status'] });
|
|
141
97
|
let currentDeviceId = state.identity.deviceId;
|
|
142
|
-
const { legacySessionToClear } = this.params;
|
|
143
98
|
const requireDeviceId = () => {
|
|
144
99
|
if (!currentDeviceId) {
|
|
145
100
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceInitializeFailed);
|
|
146
101
|
}
|
|
147
102
|
return currentDeviceId;
|
|
148
103
|
};
|
|
149
|
-
const clearLegacySession = () => {
|
|
150
|
-
const deviceId = requireDeviceId();
|
|
151
|
-
if (
|
|
152
|
-
legacySessionToClear &&
|
|
153
|
-
(!legacySessionToClear.deviceId || legacySessionToClear.deviceId === deviceId)
|
|
154
|
-
) {
|
|
155
|
-
deviceWalletSessionStore.delete(deviceId, legacySessionToClear.passphraseState);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
104
|
const refreshProtocolV2DeviceId = async () => {
|
|
159
105
|
const refreshedState = await this.device.getDeviceState({ refreshSections: ['status'] });
|
|
160
106
|
currentDeviceId = refreshedState.identity.deviceId;
|
|
161
|
-
clearLegacySession();
|
|
162
107
|
return requireDeviceId();
|
|
163
108
|
};
|
|
164
109
|
|
|
165
|
-
if (!isProtocolV2) {
|
|
166
|
-
clearLegacySession();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
110
|
const protocol = isProtocolV2 ? 'V2' : 'V1';
|
|
170
111
|
|
|
171
112
|
if (this.params.mode === 'standard') {
|
package/src/api/PathInfo.ts
CHANGED
|
@@ -10,9 +10,12 @@ export type PathInfoParams = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export default class PathInfo extends BaseMethod<PathInfoParams> {
|
|
13
|
+
getSupportedProtocols() {
|
|
14
|
+
return ['V2'] as const;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
init() {
|
|
14
18
|
// Protocol V2 (Pro2) only; Core rejects non-V2 devices.
|
|
15
|
-
this.requireProtocolV2 = true;
|
|
16
19
|
this.skipForceUpdateCheck = true;
|
|
17
20
|
this.useDevicePassphraseState = false;
|
|
18
21
|
this.params = {
|
|
@@ -6,6 +6,10 @@ import type { AlgorandGetAddress as HardwareAlgoGetAddress } from '@onekeyfe/hd-
|
|
|
6
6
|
import type { AlgoAddress, AlgoGetAddressParams } from '../../types';
|
|
7
7
|
|
|
8
8
|
export default class AlgoGetAddress extends BaseMethod<HardwareAlgoGetAddress[]> {
|
|
9
|
+
getSupportedProtocols() {
|
|
10
|
+
return ['V1', 'V2'] as const;
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
hasBundle = false;
|
|
10
14
|
|
|
11
15
|
init() {
|
|
@@ -7,6 +7,10 @@ import type { SolanaSignTransactionParams } from '../../types';
|
|
|
7
7
|
import type { AlgorandSignTx as HardwareAlgorandSignTx } from '@onekeyfe/hd-transport';
|
|
8
8
|
|
|
9
9
|
export default class AlgoSignTransaction extends BaseMethod<HardwareAlgorandSignTx> {
|
|
10
|
+
getSupportedProtocols() {
|
|
11
|
+
return ['V1', 'V2'] as const;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
hasBundle = false;
|
|
11
15
|
|
|
12
16
|
init() {
|
|
@@ -12,7 +12,6 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
12
12
|
import { PROTO } from '../../constants';
|
|
13
13
|
import { findMethod } from '../utils';
|
|
14
14
|
import { DEVICE, IFRAME, createUiMessage } from '../../events';
|
|
15
|
-
import { isMethodVersionRangeUnsupported } from '../../utils';
|
|
16
15
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
17
16
|
import { onDeviceButtonHandler } from '../../core';
|
|
18
17
|
import {
|
|
@@ -260,6 +259,10 @@ export default abstract class AllNetworkGetAddressBase extends BaseMethod<
|
|
|
260
259
|
chain_name?: string;
|
|
261
260
|
}[]
|
|
262
261
|
> {
|
|
262
|
+
getSupportedProtocols() {
|
|
263
|
+
return ['V1', 'V2'] as const;
|
|
264
|
+
}
|
|
265
|
+
|
|
263
266
|
abortController: AbortController | null = null;
|
|
264
267
|
|
|
265
268
|
init() {
|
|
@@ -459,13 +462,10 @@ export default abstract class AllNetworkGetAddressBase extends BaseMethod<
|
|
|
459
462
|
* @param method BaseMethod
|
|
460
463
|
*/
|
|
461
464
|
function preCheckDeviceSupport(device: Device, method: BaseMethod) {
|
|
465
|
+
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
462
466
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
463
467
|
const currentVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
464
468
|
|
|
465
|
-
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
466
|
-
throw ERRORS.createDeviceNotSupportMethodError(method.name, device.getCurrentFirmwareType());
|
|
467
|
-
}
|
|
468
|
-
|
|
469
469
|
if (
|
|
470
470
|
versionRange &&
|
|
471
471
|
semver.valid(versionRange.min) &&
|
|
@@ -505,14 +505,6 @@ function handleSkippableHardwareError(
|
|
|
505
505
|
);
|
|
506
506
|
const currentVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
507
507
|
|
|
508
|
-
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
509
|
-
error = ERRORS.createDeviceNotSupportMethodError(
|
|
510
|
-
method.name,
|
|
511
|
-
device.getCurrentFirmwareType()
|
|
512
|
-
);
|
|
513
|
-
return error;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
508
|
if (
|
|
517
509
|
versionRange &&
|
|
518
510
|
semver.valid(versionRange.min) &&
|
|
@@ -12,6 +12,10 @@ import type { AptosAddress, AptosGetAddressParams } from '../../types';
|
|
|
12
12
|
import type { AptosGetAddress as HardwareAptosGetAddress } from '@onekeyfe/hd-transport';
|
|
13
13
|
|
|
14
14
|
export default class AptosGetAddress extends BaseMethod<HardwareAptosGetAddress[]> {
|
|
15
|
+
getSupportedProtocols() {
|
|
16
|
+
return ['V1', 'V2'] as const;
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
hasBundle = false;
|
|
16
20
|
|
|
17
21
|
shouldConfirm = false;
|
|
@@ -7,6 +7,10 @@ import { batchGetPublickeys } from '../helpers/batchGetPublickeys';
|
|
|
7
7
|
import type { AptosGetAddressParams, AptosPublicKey } from '../../types';
|
|
8
8
|
|
|
9
9
|
export default class AptosGetPublicKey extends BaseMethod<any> {
|
|
10
|
+
getSupportedProtocols() {
|
|
11
|
+
return ['V1', 'V2'] as const;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
hasBundle = false;
|
|
11
15
|
|
|
12
16
|
init() {
|
|
@@ -7,6 +7,10 @@ import type { AptosSignSIWAMessage } from '@onekeyfe/hd-transport';
|
|
|
7
7
|
import type { AptosSignInMessageParams, AptosSignInMessageSignature } from '../../types';
|
|
8
8
|
|
|
9
9
|
export default class AptosSignInMessage extends BaseMethod<AptosSignSIWAMessage> {
|
|
10
|
+
getSupportedProtocols() {
|
|
11
|
+
return ['V1', 'V2'] as const;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
init() {
|
|
11
15
|
this.checkDeviceId = true;
|
|
12
16
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -7,6 +7,10 @@ import type { AptosSignMessage as HardwareAptosSignMessage } from '@onekeyfe/hd-
|
|
|
7
7
|
import type { AptosMessageSignature, AptosSignMessageParams } from '../../types';
|
|
8
8
|
|
|
9
9
|
export default class AptosSignMessage extends BaseMethod<HardwareAptosSignMessage> {
|
|
10
|
+
getSupportedProtocols() {
|
|
11
|
+
return ['V1', 'V2'] as const;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
init() {
|
|
11
15
|
this.checkDeviceId = true;
|
|
12
16
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -7,6 +7,10 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
7
7
|
import type { AptosSignTx as HardwareAptosSignTx } from '@onekeyfe/hd-transport';
|
|
8
8
|
|
|
9
9
|
export default class AptosSignTransaction extends BaseMethod<HardwareAptosSignTx> {
|
|
10
|
+
getSupportedProtocols() {
|
|
11
|
+
return ['V1', 'V2'] as const;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
init() {
|
|
11
15
|
this.checkDeviceId = true;
|
|
12
16
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
import { BaseMethod } from '../BaseMethod';
|
|
2
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
3
5
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
@@ -8,6 +10,13 @@ import { batchGetPublickeys, supportBatchPublicKeyByDevice } from '../helpers/ba
|
|
|
8
10
|
import type { BenfenAddress, BenfenGetAddressParams, DeviceFirmwareRange } from '../../types';
|
|
9
11
|
import type { BenfenGetAddress as HardwareBenfenGetAddress } from '@onekeyfe/hd-transport';
|
|
10
12
|
|
|
13
|
+
const requireAddress = (address: string | undefined): string => {
|
|
14
|
+
if (address == null) {
|
|
15
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodError, "Field 'address' is null");
|
|
16
|
+
}
|
|
17
|
+
return address;
|
|
18
|
+
};
|
|
19
|
+
|
|
11
20
|
export default class BenfenGetAddress extends BaseMethod<HardwareBenfenGetAddress[]> {
|
|
12
21
|
hasBundle = false;
|
|
13
22
|
|
|
@@ -48,10 +57,6 @@ export default class BenfenGetAddress extends BaseMethod<HardwareBenfenGetAddres
|
|
|
48
57
|
|
|
49
58
|
getVersionRange(): DeviceFirmwareRange {
|
|
50
59
|
return {
|
|
51
|
-
pro2: {
|
|
52
|
-
min: '0.0.0',
|
|
53
|
-
unsupported: true,
|
|
54
|
-
},
|
|
55
60
|
pro: {
|
|
56
61
|
min: '4.12.0',
|
|
57
62
|
},
|
|
@@ -78,8 +83,7 @@ export default class BenfenGetAddress extends BaseMethod<HardwareBenfenGetAddres
|
|
|
78
83
|
'BenfenAddress',
|
|
79
84
|
param
|
|
80
85
|
);
|
|
81
|
-
|
|
82
|
-
address = addressRes.message.address ?? '';
|
|
86
|
+
address = requireAddress(addressRes.message.address);
|
|
83
87
|
} else {
|
|
84
88
|
address = publicKeyToAddress(publicKey);
|
|
85
89
|
}
|
|
@@ -107,7 +111,7 @@ export default class BenfenGetAddress extends BaseMethod<HardwareBenfenGetAddres
|
|
|
107
111
|
);
|
|
108
112
|
const result = {
|
|
109
113
|
path: serializedPath(param.address_n),
|
|
110
|
-
address: hex2BfcAddress(res.message.address
|
|
114
|
+
address: hex2BfcAddress(requireAddress(res.message.address)),
|
|
111
115
|
};
|
|
112
116
|
if (this.shouldConfirm) {
|
|
113
117
|
this.postPreviousAddressMessage(result);
|
|
@@ -3,7 +3,10 @@ import { getScriptType, serializedPath, validatePath } from '../helpers/pathUtil
|
|
|
3
3
|
import { BaseMethod } from '../BaseMethod';
|
|
4
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
5
5
|
import { getCoinInfo } from './helpers/btcParamsUtils';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getBitcoinForkSupportedProtocols,
|
|
8
|
+
getBitcoinForkVersionRange,
|
|
9
|
+
} from './helpers/versionLimit';
|
|
7
10
|
|
|
8
11
|
import type { BTCAddress, BTCGetAddressParams } from '../../types/api/btcGetAddress';
|
|
9
12
|
import type { GetAddress } from '@onekeyfe/hd-transport';
|
|
@@ -11,6 +14,10 @@ import type { GetAddress } from '@onekeyfe/hd-transport';
|
|
|
11
14
|
export default class BTCGetAddress extends BaseMethod<GetAddress[]> {
|
|
12
15
|
hasBundle = false;
|
|
13
16
|
|
|
17
|
+
getSupportedProtocols() {
|
|
18
|
+
return getBitcoinForkSupportedProtocols(this.params?.map(param => param.coin_name) ?? []);
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
init() {
|
|
15
22
|
this.checkDeviceId = true;
|
|
16
23
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|