@onekeyfe/hd-core 1.2.0-alpha.23 → 1.2.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +2 -0
- package/__tests__/DeviceCommands.test.ts +35 -0
- package/__tests__/chain-params-onekey-compatibility.test.ts +229 -0
- package/__tests__/device-lifecycle-events.test.ts +59 -0
- package/__tests__/device-state-events.test.ts +124 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +3 -1
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +68 -27
- package/__tests__/firmware-update/firmware-update-plan.test.ts +28 -0
- package/__tests__/kaspa-public-types.type-test.ts +16 -0
- package/__tests__/kaspaSignTransaction.test.ts +4 -3
- package/__tests__/method-protocol-support.test.ts +113 -0
- package/__tests__/open-wallet-session.test.ts +192 -129
- package/__tests__/protocol-v2-ping.test.ts +28 -0
- package/__tests__/protocol-v2.test.ts +346 -230
- package/__tests__/public-device-state-api.test.ts +10 -8
- package/__tests__/public-pro2-api-boundary.test.ts +22 -0
- package/__tests__/tron-sign-message-init.test.ts +46 -0
- package/dist/api/BaseMethod.d.ts +6 -2
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CipherKeyValue.d.ts +1 -0
- package/dist/api/CipherKeyValue.d.ts.map +1 -1
- package/dist/api/DirList.d.ts +1 -0
- package/dist/api/DirList.d.ts.map +1 -1
- package/dist/api/DirMake.d.ts +1 -0
- package/dist/api/DirMake.d.ts.map +1 -1
- package/dist/api/DirRemove.d.ts +1 -0
- package/dist/api/DirRemove.d.ts.map +1 -1
- package/dist/api/FileDelete.d.ts +1 -0
- package/dist/api/FileDelete.d.ts.map +1 -1
- package/dist/api/FileRead.d.ts +1 -0
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts +1 -0
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +2 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts +1 -0
- package/dist/api/GetDeviceState.d.ts.map +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +1 -0
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts +2 -8
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/PathInfo.d.ts +1 -0
- package/dist/api/PathInfo.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/algo/AlgoGetAddress.d.ts +1 -0
- package/dist/api/algo/AlgoGetAddress.d.ts.map +1 -1
- package/dist/api/algo/AlgoSignTransaction.d.ts +1 -0
- package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +1 -0
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts +1 -0
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetPublicKey.d.ts +1 -0
- package/dist/api/aptos/AptosGetPublicKey.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignInMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignTransaction.d.ts +1 -0
- package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -0
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -0
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -0
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts +1 -0
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -0
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -0
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -0
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetAddress.d.ts +1 -0
- package/dist/api/cardano/CardanoGetAddress.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetPublicKey.d.ts +1 -0
- package/dist/api/cardano/CardanoGetPublicKey.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignMessage.d.ts +1 -0
- package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts +1 -0
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxGetAddress.d.ts +1 -0
- package/dist/api/conflux/ConfluxGetAddress.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessage.d.ts +1 -0
- package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts +1 -0
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts +1 -0
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosGetAddress.d.ts +1 -0
- package/dist/api/cosmos/CosmosGetAddress.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosGetPublicKey.d.ts +1 -0
- package/dist/api/cosmos/CosmosGetPublicKey.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosSignTransaction.d.ts +1 -0
- package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceCancel.d.ts +1 -0
- package/dist/api/device/DeviceCancel.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts +1 -0
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.d.ts +1 -0
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -0
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts +1 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts +1 -0
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceSupportFeatures.d.ts +1 -0
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -0
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts +1 -0
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/device/PreInitialize.d.ts +1 -0
- package/dist/api/device/PreInitialize.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMGetAddress.d.ts +1 -0
- package/dist/api/evm/EVMGetAddress.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts +1 -0
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessage.d.ts +1 -0
- package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts +1 -0
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts +1 -0
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/EVMVerifyMessage.d.ts +1 -0
- package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -1
- package/dist/api/filecoin/FilecoinGetAddress.d.ts +1 -0
- package/dist/api/filecoin/FilecoinGetAddress.d.ts.map +1 -1
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts +1 -0
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaGetAddress.d.ts +1 -0
- package/dist/api/kaspa/KaspaGetAddress.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts +1 -0
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/kaspa/helpers/TransferSerialize.d.ts.map +1 -1
- package/dist/api/lightning/LnurlAuth.d.ts +0 -4
- package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
- package/dist/api/near/NearGetAddress.d.ts +1 -0
- package/dist/api/near/NearGetAddress.d.ts.map +1 -1
- package/dist/api/near/NearSignTransaction.d.ts +1 -0
- package/dist/api/near/NearSignTransaction.d.ts.map +1 -1
- package/dist/api/nem/NEMGetAddress.d.ts +1 -0
- package/dist/api/nem/NEMGetAddress.d.ts.map +1 -1
- package/dist/api/nem/NEMSignTransaction.d.ts +1 -0
- package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/nostr/NostrDecryptMessage.d.ts +1 -0
- package/dist/api/nostr/NostrDecryptMessage.d.ts.map +1 -1
- package/dist/api/nostr/NostrEncryptMessage.d.ts +1 -0
- package/dist/api/nostr/NostrEncryptMessage.d.ts.map +1 -1
- package/dist/api/nostr/NostrGetPublicKey.d.ts +1 -0
- package/dist/api/nostr/NostrGetPublicKey.d.ts.map +1 -1
- package/dist/api/nostr/NostrSignEvent.d.ts +1 -0
- package/dist/api/nostr/NostrSignEvent.d.ts.map +1 -1
- package/dist/api/nostr/NostrSignSchnorr.d.ts +1 -0
- package/dist/api/nostr/NostrSignSchnorr.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -0
- package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotSignTransaction.d.ts +1 -0
- package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -1
- package/dist/api/protocol-v2/Ping.d.ts +3 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts +1 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +1 -0
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -0
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +1 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetAddress.d.ts +1 -0
- package/dist/api/starcoin/StarcoinGetAddress.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts +1 -0
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignMessage.d.ts +1 -0
- package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts +1 -0
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts +1 -0
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +1 -2
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +1 -0
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +1 -0
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +1 -0
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +1 -0
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +1 -0
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +1 -0
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +1 -0
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +1 -0
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronGetAddress.d.ts +1 -0
- package/dist/api/tron/TronGetAddress.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +2 -0
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +1 -0
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/xrp/XrpGetAddress.d.ts +1 -0
- package/dist/api/xrp/XrpGetAddress.d.ts.map +1 -1
- package/dist/api/xrp/XrpSignTransaction.d.ts +1 -0
- package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +3 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.d.ts +25 -25
- package/dist/index.js +669 -367
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +2 -3
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +12 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +3 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/kaspaSignTransaction.d.ts +15 -2
- package/dist/types/api/kaspaSignTransaction.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +0 -12
- package/dist/types/api/openWalletSession.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +4 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +0 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +0 -1
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +1 -0
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +21 -18
- package/src/api/CheckAllFirmwareRelease.ts +23 -3
- package/src/api/CipherKeyValue.ts +4 -0
- package/src/api/DirList.ts +4 -1
- package/src/api/DirMake.ts +4 -1
- package/src/api/DirRemove.ts +4 -1
- package/src/api/FileDelete.ts +4 -1
- package/src/api/FileRead.ts +4 -1
- package/src/api/FileWrite.ts +4 -1
- package/src/api/FirmwareUpdate.ts +0 -8
- package/src/api/FirmwareUpdateV3.ts +0 -6
- package/src/api/FirmwareUpdateV4.ts +36 -18
- package/src/api/GetDeviceState.ts +4 -0
- package/src/api/GetFeatures.ts +1 -4
- package/src/api/GetOnekeyFeatures.ts +0 -5
- package/src/api/GetPassphraseState.ts +4 -0
- package/src/api/OpenWalletSession.ts +27 -86
- package/src/api/PathInfo.ts +4 -1
- package/src/api/alephium/AlephiumGetAddress.ts +0 -4
- package/src/api/alephium/AlephiumSignMessage.ts +0 -4
- package/src/api/alephium/AlephiumSignTransaction.ts +0 -4
- package/src/api/algo/AlgoGetAddress.ts +4 -0
- package/src/api/algo/AlgoSignTransaction.ts +4 -0
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +5 -13
- package/src/api/aptos/AptosGetAddress.ts +4 -0
- package/src/api/aptos/AptosGetPublicKey.ts +4 -0
- package/src/api/aptos/AptosSignInMessage.ts +4 -0
- package/src/api/aptos/AptosSignMessage.ts +4 -0
- package/src/api/aptos/AptosSignTransaction.ts +4 -0
- package/src/api/benfen/BenfenGetAddress.ts +11 -7
- package/src/api/benfen/BenfenGetPublicKey.ts +0 -4
- package/src/api/benfen/BenfenSignMessage.ts +0 -4
- package/src/api/benfen/BenfenSignTransaction.ts +0 -4
- package/src/api/btc/BTCGetAddress.ts +8 -1
- package/src/api/btc/BTCGetPublicKey.ts +8 -1
- package/src/api/btc/BTCSignMessage.ts +8 -1
- package/src/api/btc/BTCSignPsbt.ts +4 -0
- package/src/api/btc/BTCSignTransaction.ts +8 -1
- package/src/api/btc/BTCVerifyMessage.ts +8 -1
- package/src/api/btc/helpers/versionLimit.ts +7 -4
- package/src/api/cardano/CardanoGetAddress.ts +4 -0
- package/src/api/cardano/CardanoGetPublicKey.ts +4 -0
- package/src/api/cardano/CardanoSignMessage.ts +4 -0
- package/src/api/cardano/CardanoSignTransaction.ts +4 -0
- package/src/api/conflux/ConfluxGetAddress.ts +4 -0
- package/src/api/conflux/ConfluxSignMessage.ts +4 -0
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +4 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +6 -5
- package/src/api/cosmos/CosmosGetAddress.ts +4 -0
- package/src/api/cosmos/CosmosGetPublicKey.ts +4 -0
- package/src/api/cosmos/CosmosSignTransaction.ts +4 -0
- package/src/api/device/DeviceCancel.ts +4 -0
- package/src/api/device/DeviceChangePin.ts +4 -0
- package/src/api/device/DeviceLock.ts +4 -0
- package/src/api/device/DeviceRebootToBoardloader.ts +4 -0
- package/src/api/device/DeviceRebootToBootloader.ts +4 -0
- package/src/api/device/DeviceSettings.ts +4 -0
- package/src/api/device/DeviceSupportFeatures.ts +4 -0
- package/src/api/device/DeviceUnlock.ts +4 -0
- package/src/api/device/DeviceWipe.ts +4 -0
- package/src/api/device/PreInitialize.ts +4 -0
- package/src/api/dynex/DnxGetAddress.ts +0 -6
- package/src/api/dynex/DnxSignTransaction.ts +0 -6
- package/src/api/evm/EVMGetAddress.ts +4 -0
- package/src/api/evm/EVMGetPublicKey.ts +4 -0
- package/src/api/evm/EVMSignMessage.ts +4 -0
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -11
- package/src/api/evm/EVMSignTransaction.ts +4 -0
- package/src/api/evm/EVMSignTypedData.ts +4 -0
- package/src/api/evm/EVMVerifyMessage.ts +4 -0
- package/src/api/filecoin/FilecoinGetAddress.ts +4 -0
- package/src/api/filecoin/FilecoinSignTransaction.ts +4 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +8 -1
- package/src/api/index.ts +1 -0
- package/src/api/kaspa/KaspaGetAddress.ts +4 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +37 -15
- package/src/api/kaspa/helpers/TransferSerialize.ts +3 -7
- package/src/api/lightning/LnurlAuth.ts +0 -4
- package/src/api/near/NearGetAddress.ts +4 -0
- package/src/api/near/NearSignTransaction.ts +4 -0
- package/src/api/nem/NEMGetAddress.ts +4 -0
- package/src/api/nem/NEMSignTransaction.ts +4 -0
- package/src/api/neo/NeoGetAddress.ts +0 -4
- package/src/api/neo/NeoSignTransaction.ts +0 -4
- package/src/api/nervos/NervosGetAddress.ts +0 -4
- package/src/api/nervos/NervosSignTransaction.ts +0 -4
- package/src/api/nexa/NexaGetAddress.ts +0 -4
- package/src/api/nexa/NexaSignTransaction.ts +0 -4
- package/src/api/nostr/NostrDecryptMessage.ts +4 -0
- package/src/api/nostr/NostrEncryptMessage.ts +4 -0
- package/src/api/nostr/NostrGetPublicKey.ts +4 -0
- package/src/api/nostr/NostrSignEvent.ts +4 -0
- package/src/api/nostr/NostrSignSchnorr.ts +4 -0
- package/src/api/polkadot/PolkadotGetAddress.ts +4 -0
- package/src/api/polkadot/PolkadotSignTransaction.ts +4 -0
- package/src/api/protocol-v2/DeviceFactoryInfoGet.ts +4 -1
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +4 -1
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +4 -1
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +4 -1
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +4 -1
- package/src/api/protocol-v2/DeviceInfoGet.ts +4 -8
- package/src/api/protocol-v2/DeviceReboot.ts +4 -2
- package/src/api/protocol-v2/DeviceStatusGet.ts +4 -1
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +4 -1
- package/src/api/protocol-v2/FilesystemFormat.ts +4 -1
- package/src/api/protocol-v2/FilesystemPermissionFix.ts +4 -1
- package/src/api/protocol-v2/Ping.ts +36 -2
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +4 -1
- package/src/api/scdo/ScdoGetAddress.ts +0 -4
- package/src/api/scdo/ScdoSignMessage.ts +0 -4
- package/src/api/scdo/ScdoSignTransaction.ts +0 -4
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +4 -0
- package/src/api/solana/SolSignOffchainMessage.ts +4 -0
- package/src/api/solana/SolSignTransaction.ts +4 -0
- package/src/api/starcoin/StarcoinGetAddress.ts +4 -0
- package/src/api/starcoin/StarcoinGetPublicKey.ts +4 -0
- package/src/api/starcoin/StarcoinSignMessage.ts +4 -0
- package/src/api/starcoin/StarcoinSignTransaction.ts +4 -0
- package/src/api/starcoin/StarcoinVerifyMessage.ts +4 -0
- package/src/api/stellar/StellarGetAddress.ts +1 -10
- package/src/api/stellar/StellarSignTransaction.ts +1 -14
- package/src/api/sui/SuiGetAddress.ts +4 -0
- package/src/api/sui/SuiGetPublicKey.ts +4 -0
- package/src/api/sui/SuiSignMessage.ts +4 -0
- package/src/api/sui/SuiSignTransaction.ts +4 -0
- package/src/api/ton/TonGetAddress.ts +4 -0
- package/src/api/ton/TonSignData.ts +5 -1
- package/src/api/ton/TonSignMessage.ts +4 -0
- package/src/api/ton/TonSignProof.ts +4 -0
- package/src/api/tron/TronGetAddress.ts +4 -0
- package/src/api/tron/TronSignMessage.ts +15 -7
- package/src/api/tron/TronSignTransaction.ts +4 -0
- package/src/api/xrp/XrpGetAddress.ts +4 -0
- package/src/api/xrp/XrpSignTransaction.ts +5 -1
- package/src/core/index.ts +43 -24
- package/src/data/messages/messages-protocol-v2.json +33 -1
- package/src/device/Device.ts +60 -62
- package/src/device/DeviceCommands.ts +19 -0
- package/src/inject.ts +2 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +20 -3
- package/src/protocols/protocol-v2/walletSession.ts +26 -8
- package/src/types/api/export.ts +2 -0
- package/src/types/api/index.ts +3 -0
- package/src/types/api/kaspaSignTransaction.ts +20 -2
- package/src/types/api/openWalletSession.ts +0 -19
- package/src/types/api/protocolV2.ts +10 -0
- package/src/types/device.ts +0 -1
- package/src/utils/deviceInfoUtils.ts +15 -6
- package/src/utils/deviceVersionUtils.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/tsconfig.type-tests.json +8 -0
package/dist/index.js
CHANGED
|
@@ -437,9 +437,19 @@ const getDeviceUUID = getDeviceSerialNo;
|
|
|
437
437
|
const getDeviceLabel = (features) => {
|
|
438
438
|
if (!features)
|
|
439
439
|
return null;
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
440
|
+
const deviceType = getDeviceType(features);
|
|
441
|
+
if (deviceType == null)
|
|
442
|
+
return null;
|
|
443
|
+
if ('label' in features && typeof features.label === 'string' && features.label.length > 0) {
|
|
444
|
+
return features.label;
|
|
445
|
+
}
|
|
446
|
+
const bleName = getDeviceBleName(features);
|
|
447
|
+
if (bleName)
|
|
448
|
+
return bleName;
|
|
449
|
+
if (deviceType === hdShared.EDeviceType.ClassicPure) {
|
|
450
|
+
return 'OneKey Classic 1S';
|
|
451
|
+
}
|
|
452
|
+
return `OneKey ${deviceType.charAt(0).toUpperCase() + deviceType.slice(1)}`;
|
|
443
453
|
};
|
|
444
454
|
const getMethodVersionRange = (features, getVersionRange) => {
|
|
445
455
|
const deviceType = getDeviceType(features);
|
|
@@ -463,7 +473,6 @@ const getMethodVersionRange = (features, getVersionRange) => {
|
|
|
463
473
|
}
|
|
464
474
|
return undefined;
|
|
465
475
|
};
|
|
466
|
-
const isMethodVersionRangeUnsupported = (versionRange) => (versionRange === null || versionRange === void 0 ? void 0 : versionRange.unsupported) === true;
|
|
467
476
|
const getFirmwareType = (features) => resolveDeviceFirmwareType(features);
|
|
468
477
|
|
|
469
478
|
const EMPTY_VERSION = [0, 0, 0];
|
|
@@ -511,7 +520,15 @@ const assertArtifactUrl = (value, label) => {
|
|
|
511
520
|
if (!raw) {
|
|
512
521
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `${label} has no downloadable artifact`, { firmwareUpdateCode: 'FirmwarePlanInvalid' });
|
|
513
522
|
}
|
|
514
|
-
|
|
523
|
+
let parsed;
|
|
524
|
+
try {
|
|
525
|
+
parsed = new URL(raw);
|
|
526
|
+
}
|
|
527
|
+
catch (_a) {
|
|
528
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `${label} URL is invalid`, {
|
|
529
|
+
firmwareUpdateCode: 'FirmwarePlanInvalid',
|
|
530
|
+
});
|
|
531
|
+
}
|
|
515
532
|
if (parsed.protocol !== 'https:' ||
|
|
516
533
|
parsed.port !== '' ||
|
|
517
534
|
parsed.username ||
|
|
@@ -1254,6 +1271,7 @@ const createCoreApi = (call) => ({
|
|
|
1254
1271
|
checkFirmwareTypeAvailable: params => call(Object.assign(Object.assign({}, params), { method: 'checkFirmwareTypeAvailable' })),
|
|
1255
1272
|
cipherKeyValue: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'cipherKeyValue' })),
|
|
1256
1273
|
testInitializeDeviceDuration: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'testInitializeDeviceDuration' })),
|
|
1274
|
+
testProtocolV2Ping: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'testProtocolV2Ping' })),
|
|
1257
1275
|
preInitialize: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'preInitialize' })),
|
|
1258
1276
|
deviceBackup: connectId => call({ connectId, method: 'deviceBackup' }),
|
|
1259
1277
|
deviceChangePin: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceChangePin' })),
|
|
@@ -1922,7 +1940,7 @@ const createLogMessage = (type, payload) => ({
|
|
|
1922
1940
|
|
|
1923
1941
|
const MAX_ENTRIES = 500;
|
|
1924
1942
|
let postMessage$1;
|
|
1925
|
-
class Log$
|
|
1943
|
+
class Log$l {
|
|
1926
1944
|
constructor(prefix, enabled) {
|
|
1927
1945
|
this.prefix = prefix;
|
|
1928
1946
|
this.enabled = enabled;
|
|
@@ -1974,7 +1992,7 @@ class Log$k {
|
|
|
1974
1992
|
}
|
|
1975
1993
|
const _logs = {};
|
|
1976
1994
|
const initLog = (prefix, enabled) => {
|
|
1977
|
-
const instance = new Log$
|
|
1995
|
+
const instance = new Log$l(prefix, !!enabled);
|
|
1978
1996
|
_logs[prefix] = instance;
|
|
1979
1997
|
return instance;
|
|
1980
1998
|
};
|
|
@@ -2372,7 +2390,7 @@ function patchFeatures(response) {
|
|
|
2372
2390
|
return response;
|
|
2373
2391
|
}
|
|
2374
2392
|
|
|
2375
|
-
const Log$
|
|
2393
|
+
const Log$k = getLogger(exports.LoggerNames.Core);
|
|
2376
2394
|
let globalInstanceCounter = 0;
|
|
2377
2395
|
let sdkInstanceCounter = 0;
|
|
2378
2396
|
function generateSdkInstanceId() {
|
|
@@ -2432,7 +2450,7 @@ function completeRequestContext(responseID, error) {
|
|
|
2432
2450
|
context.status = error ? 'error' : 'success';
|
|
2433
2451
|
if (error) {
|
|
2434
2452
|
context.error = error.message;
|
|
2435
|
-
Log$
|
|
2453
|
+
Log$k.debug(`[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`);
|
|
2436
2454
|
}
|
|
2437
2455
|
globalActiveRequests.delete(responseID);
|
|
2438
2456
|
if (context.sdkInstanceId) {
|
|
@@ -38249,6 +38267,33 @@ var nested = {
|
|
|
38249
38267
|
}
|
|
38250
38268
|
}
|
|
38251
38269
|
},
|
|
38270
|
+
UiAnimationType: {
|
|
38271
|
+
values: {
|
|
38272
|
+
Unknown: 0,
|
|
38273
|
+
Signing: 1
|
|
38274
|
+
}
|
|
38275
|
+
},
|
|
38276
|
+
UiAnimationCommand: {
|
|
38277
|
+
values: {
|
|
38278
|
+
CommandUnknown: 0,
|
|
38279
|
+
Start: 1,
|
|
38280
|
+
Stop: 2,
|
|
38281
|
+
Refresh: 3
|
|
38282
|
+
}
|
|
38283
|
+
},
|
|
38284
|
+
UiAnimationRequest: {
|
|
38285
|
+
fields: {
|
|
38286
|
+
command: {
|
|
38287
|
+
rule: "required",
|
|
38288
|
+
type: "UiAnimationCommand",
|
|
38289
|
+
id: 1
|
|
38290
|
+
},
|
|
38291
|
+
type: {
|
|
38292
|
+
type: "UiAnimationType",
|
|
38293
|
+
id: 2
|
|
38294
|
+
}
|
|
38295
|
+
}
|
|
38296
|
+
},
|
|
38252
38297
|
ViewAmount: {
|
|
38253
38298
|
fields: {
|
|
38254
38299
|
is_unlimited: {
|
|
@@ -39230,6 +39275,10 @@ var nested = {
|
|
|
39230
39275
|
},
|
|
39231
39276
|
DeviceSessionAskPassphrase: {
|
|
39232
39277
|
fields: {
|
|
39278
|
+
passphrase: {
|
|
39279
|
+
type: "string",
|
|
39280
|
+
id: 1
|
|
39281
|
+
}
|
|
39233
39282
|
}
|
|
39234
39283
|
},
|
|
39235
39284
|
DeviceSessionAskPin_FailureSubCodes: {
|
|
@@ -40352,7 +40401,7 @@ const findLatestRelease = (releases) => {
|
|
|
40352
40401
|
};
|
|
40353
40402
|
|
|
40354
40403
|
var _a$1;
|
|
40355
|
-
const Log$
|
|
40404
|
+
const Log$j = getLogger(exports.LoggerNames.Core);
|
|
40356
40405
|
const FIRMWARE_FIELDS = [
|
|
40357
40406
|
'firmware',
|
|
40358
40407
|
'firmware-v1',
|
|
@@ -40410,7 +40459,7 @@ class DataManager {
|
|
|
40410
40459
|
const manifestMode = (_b = settings.firmwareManifestMode) !== null && _b !== void 0 ? _b : (settings.fetchConfig ? 'sdk-managed' : undefined);
|
|
40411
40460
|
if (settings.preloadedConfig) {
|
|
40412
40461
|
this.applyRemoteConfig(settings.preloadedConfig);
|
|
40413
|
-
Log$
|
|
40462
|
+
Log$j.log('[DataConfig] Preloaded firmware config loaded');
|
|
40414
40463
|
return;
|
|
40415
40464
|
}
|
|
40416
40465
|
if (manifestMode === 'external-only') {
|
|
@@ -40425,32 +40474,32 @@ class DataManager {
|
|
|
40425
40474
|
const urlWithCache = `${url}?noCache=${getTimeStamp()}`;
|
|
40426
40475
|
let data = null;
|
|
40427
40476
|
if (settings.configFetcher) {
|
|
40428
|
-
Log$
|
|
40477
|
+
Log$j.debug('[DataConfig] Trying client configFetcher...');
|
|
40429
40478
|
try {
|
|
40430
40479
|
data = yield settings.configFetcher(urlWithCache);
|
|
40431
40480
|
}
|
|
40432
40481
|
catch (e) {
|
|
40433
|
-
Log$
|
|
40482
|
+
Log$j.warn('[DataConfig] Client configFetcher failed:', e);
|
|
40434
40483
|
}
|
|
40435
40484
|
}
|
|
40436
40485
|
if (!data) {
|
|
40437
|
-
Log$
|
|
40486
|
+
Log$j.debug('[DataConfig] Trying SDK-managed config request...');
|
|
40438
40487
|
try {
|
|
40439
40488
|
const response = yield axios__default["default"].get(urlWithCache, {
|
|
40440
40489
|
timeout: 7000,
|
|
40441
40490
|
});
|
|
40442
40491
|
data = response.data;
|
|
40443
|
-
Log$
|
|
40492
|
+
Log$j.log('[DataConfig] SDK-managed config request succeeded');
|
|
40444
40493
|
}
|
|
40445
40494
|
catch (e) {
|
|
40446
|
-
Log$
|
|
40495
|
+
Log$j.warn('[DataConfig] SDK-managed config request failed:', e);
|
|
40447
40496
|
}
|
|
40448
40497
|
}
|
|
40449
40498
|
if (data) {
|
|
40450
40499
|
this.applyRemoteConfig(data);
|
|
40451
40500
|
}
|
|
40452
40501
|
else {
|
|
40453
|
-
Log$
|
|
40502
|
+
Log$j.warn('[DataConfig] SDK-managed config request failed, using built-in default config');
|
|
40454
40503
|
}
|
|
40455
40504
|
});
|
|
40456
40505
|
}
|
|
@@ -40963,10 +41012,8 @@ const getDeviceSession = (device, request) => __awaiter(void 0, void 0, void 0,
|
|
|
40963
41012
|
return device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
|
|
40964
41013
|
}
|
|
40965
41014
|
});
|
|
40966
|
-
const askDevicePassphrase = (device) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40967
|
-
const request = () => device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', {}
|
|
40968
|
-
timeoutMs: 120000,
|
|
40969
|
-
});
|
|
41015
|
+
const askDevicePassphrase = (device, passphrase) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41016
|
+
const request = () => device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', passphrase ? { passphrase } : {});
|
|
40970
41017
|
try {
|
|
40971
41018
|
return yield request();
|
|
40972
41019
|
}
|
|
@@ -40985,7 +41032,7 @@ const selectDeviceSession = (device) => __awaiter(void 0, void 0, void 0, functi
|
|
|
40985
41032
|
source: 'wallet-session-coordinator',
|
|
40986
41033
|
reason: 'open-wallet',
|
|
40987
41034
|
};
|
|
40988
|
-
const response = yield device.commands.promptPassphrase(Object.assign({ existsAttachPinUser
|
|
41035
|
+
const response = yield device.commands.promptPassphrase(Object.assign({ existsAttachPinUser }, metadata), { cancelDeviceOnReject: false });
|
|
40989
41036
|
const hasHostPassphrase = typeof response.passphrase === 'string' && response.passphrase.length > 0;
|
|
40990
41037
|
const selections = [
|
|
40991
41038
|
hasHostPassphrase,
|
|
@@ -41003,6 +41050,10 @@ const selectDeviceSession = (device) => __awaiter(void 0, void 0, void 0, functi
|
|
|
41003
41050
|
yield device.unlockDevice(hdTransport.DeviceSessionPinType.AttachToPin);
|
|
41004
41051
|
return getDeviceSession(device, {});
|
|
41005
41052
|
}
|
|
41053
|
+
if (hasHostPassphrase) {
|
|
41054
|
+
yield askDevicePassphrase(device, response.passphrase);
|
|
41055
|
+
return getDeviceSession(device, {});
|
|
41056
|
+
}
|
|
41006
41057
|
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, metadata);
|
|
41007
41058
|
yield askDevicePassphrase(device);
|
|
41008
41059
|
return getDeviceSession(device, {});
|
|
@@ -41046,6 +41097,10 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
41046
41097
|
}
|
|
41047
41098
|
}
|
|
41048
41099
|
if (!response) {
|
|
41100
|
+
if (options === null || options === void 0 ? void 0 : options.resumeOnly) {
|
|
41101
|
+
device.clearInternalState();
|
|
41102
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WalletSessionInvalid);
|
|
41103
|
+
}
|
|
41049
41104
|
response = yield selectDeviceSession(device);
|
|
41050
41105
|
}
|
|
41051
41106
|
const { message } = response;
|
|
@@ -41069,6 +41124,14 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
41069
41124
|
};
|
|
41070
41125
|
});
|
|
41071
41126
|
}
|
|
41127
|
+
function restoreProtocolV2WalletSession(device, expectedPassphraseState) {
|
|
41128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41129
|
+
return getProtocolV2WalletSession(device, {
|
|
41130
|
+
expectedPassphraseState,
|
|
41131
|
+
resumeOnly: true,
|
|
41132
|
+
});
|
|
41133
|
+
});
|
|
41134
|
+
}
|
|
41072
41135
|
|
|
41073
41136
|
const getSupportProtocolV1MessageSchema = (features) => {
|
|
41074
41137
|
var _a;
|
|
@@ -41205,16 +41268,6 @@ const getPassphraseState = (device, options) => __awaiter(void 0, void 0, void 0
|
|
|
41205
41268
|
unlockedAttachPin: undefined,
|
|
41206
41269
|
};
|
|
41207
41270
|
});
|
|
41208
|
-
const supportModifyHomescreen = (features) => {
|
|
41209
|
-
if (!features)
|
|
41210
|
-
return { support: false };
|
|
41211
|
-
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
41212
|
-
const deviceType = getDeviceType(features);
|
|
41213
|
-
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
41214
|
-
return { support: true };
|
|
41215
|
-
}
|
|
41216
|
-
return { support: semver__default["default"].gte(currentVersion, '3.4.0') };
|
|
41217
|
-
};
|
|
41218
41271
|
const getLatestFirmwareField = (firmwareType) => {
|
|
41219
41272
|
if (firmwareType === 'bitcoinonly') {
|
|
41220
41273
|
return `firmware-btc-v8`;
|
|
@@ -42086,7 +42139,7 @@ const getDefectiveDeviceInfo = (features) => {
|
|
|
42086
42139
|
};
|
|
42087
42140
|
};
|
|
42088
42141
|
|
|
42089
|
-
const Log$
|
|
42142
|
+
const Log$i = getLogger(exports.LoggerNames.DevicePool);
|
|
42090
42143
|
const getDiff = (current, descriptors) => {
|
|
42091
42144
|
const connected = descriptors.filter(d => current.find(x => x.path === d.path) === undefined);
|
|
42092
42145
|
const disconnected = current.filter(d => descriptors.find(x => x.path === d.path) === undefined);
|
|
@@ -42144,7 +42197,7 @@ class DevicePool extends events.exports {
|
|
|
42144
42197
|
yield this._checkDevicePool(initOptions, connectId);
|
|
42145
42198
|
return { devices, deviceList };
|
|
42146
42199
|
}
|
|
42147
|
-
Log$
|
|
42200
|
+
Log$i.debug('found device in cache, but path is different: ', connectId);
|
|
42148
42201
|
}
|
|
42149
42202
|
}
|
|
42150
42203
|
const matchedDescriptor = connectId
|
|
@@ -42231,7 +42284,7 @@ class DevicePool extends events.exports {
|
|
|
42231
42284
|
yield device.getDeviceState({ refreshSections: ['settings'] });
|
|
42232
42285
|
}
|
|
42233
42286
|
catch (error) {
|
|
42234
|
-
Log$
|
|
42287
|
+
Log$i.debug('Unable to refresh Protocol V2 device label during discovery', error);
|
|
42235
42288
|
}
|
|
42236
42289
|
});
|
|
42237
42290
|
}
|
|
@@ -42247,7 +42300,7 @@ class DevicePool extends events.exports {
|
|
|
42247
42300
|
const descriptor = this.connectedPool[i];
|
|
42248
42301
|
if (!connectId || descriptor.path === connectId) {
|
|
42249
42302
|
const device = yield this._createDevice(descriptor, initOptions);
|
|
42250
|
-
Log$
|
|
42303
|
+
Log$i.debug('emit DEVICE.CONNECT: ', device === null || device === void 0 ? void 0 : device.features);
|
|
42251
42304
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
42252
42305
|
this.connectedPool.splice(i, 1);
|
|
42253
42306
|
}
|
|
@@ -42269,9 +42322,9 @@ class DevicePool extends events.exports {
|
|
|
42269
42322
|
const diff = getDiff(this.current || [], upcoming);
|
|
42270
42323
|
this.upcoming = upcoming;
|
|
42271
42324
|
this.current = this.upcoming;
|
|
42272
|
-
Log$
|
|
42273
|
-
Log$
|
|
42274
|
-
Log$
|
|
42325
|
+
Log$i.debug('device pool -> current: ', this.current);
|
|
42326
|
+
Log$i.debug('device pool -> upcomming: ', this.upcoming);
|
|
42327
|
+
Log$i.debug('DeviceCache.reportDeviceChange diff: ', diff);
|
|
42275
42328
|
if (!diff.didUpdate) {
|
|
42276
42329
|
return;
|
|
42277
42330
|
}
|
|
@@ -42281,7 +42334,7 @@ class DevicePool extends events.exports {
|
|
|
42281
42334
|
this._addConnectedDeviceToPool(d);
|
|
42282
42335
|
return;
|
|
42283
42336
|
}
|
|
42284
|
-
Log$
|
|
42337
|
+
Log$i.debug('emit DEVICE.CONNECT: ', device.features);
|
|
42285
42338
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
42286
42339
|
});
|
|
42287
42340
|
diff.disconnected.forEach(d => {
|
|
@@ -42291,7 +42344,7 @@ class DevicePool extends events.exports {
|
|
|
42291
42344
|
this._addDisconnectedDeviceToPool(d);
|
|
42292
42345
|
return;
|
|
42293
42346
|
}
|
|
42294
|
-
Log$
|
|
42347
|
+
Log$i.debug('emit DEVICE.DISCONNECT: ', device.features);
|
|
42295
42348
|
device.markTransportDisconnected();
|
|
42296
42349
|
this.emitter.emit(DEVICE.DISCONNECT, device);
|
|
42297
42350
|
});
|
|
@@ -42328,7 +42381,7 @@ class DevicePool extends events.exports {
|
|
|
42328
42381
|
this.disconnectPool = [];
|
|
42329
42382
|
this.devicesCache = {};
|
|
42330
42383
|
this.emitter.removeAllListeners();
|
|
42331
|
-
Log$
|
|
42384
|
+
Log$i.debug('DevicePool state has been reset');
|
|
42332
42385
|
}
|
|
42333
42386
|
}
|
|
42334
42387
|
DevicePool.current = null;
|
|
@@ -42338,7 +42391,7 @@ DevicePool.disconnectPool = [];
|
|
|
42338
42391
|
DevicePool.devicesCache = {};
|
|
42339
42392
|
DevicePool.emitter = new events.exports();
|
|
42340
42393
|
|
|
42341
|
-
const Log$
|
|
42394
|
+
const Log$h = getLogger(exports.LoggerNames.Transport);
|
|
42342
42395
|
const BleLogger = getLogger(exports.LoggerNames.HdBleTransport);
|
|
42343
42396
|
const HttpLogger = getLogger(exports.LoggerNames.HdTransportHttp);
|
|
42344
42397
|
const LowLevelLogger = getLogger(exports.LoggerNames.HdTransportLowLevel);
|
|
@@ -42348,7 +42401,7 @@ const WebUsbLogger = getLogger(exports.LoggerNames.HdTransportWebUsb);
|
|
|
42348
42401
|
const REACT_NATIVE_BLE_SCAN_TIMEOUT_MS = 8000;
|
|
42349
42402
|
class TransportManager {
|
|
42350
42403
|
static load() {
|
|
42351
|
-
Log$
|
|
42404
|
+
Log$h.debug('transport manager load');
|
|
42352
42405
|
this.defaultMessages = DataManager.getProtobufMessages();
|
|
42353
42406
|
this.currentMessages = this.defaultMessages;
|
|
42354
42407
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
@@ -42357,14 +42410,14 @@ class TransportManager {
|
|
|
42357
42410
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42358
42411
|
try {
|
|
42359
42412
|
const env = DataManager.getSettings('env');
|
|
42360
|
-
Log$
|
|
42413
|
+
Log$h.debug('Initializing transports', env);
|
|
42361
42414
|
if (env === 'react-native') {
|
|
42362
42415
|
if (!this.reactNativeInit) {
|
|
42363
42416
|
yield this.transport.init(BleLogger, DevicePool.emitter);
|
|
42364
42417
|
this.reactNativeInit = true;
|
|
42365
42418
|
}
|
|
42366
42419
|
else {
|
|
42367
|
-
Log$
|
|
42420
|
+
Log$h.debug('React Native Do Not Initializing transports');
|
|
42368
42421
|
}
|
|
42369
42422
|
}
|
|
42370
42423
|
else if (env === 'node-usb') {
|
|
@@ -42385,15 +42438,15 @@ class TransportManager {
|
|
|
42385
42438
|
else {
|
|
42386
42439
|
yield this.transport.init(HttpLogger);
|
|
42387
42440
|
}
|
|
42388
|
-
Log$
|
|
42441
|
+
Log$h.debug('Configuring transports');
|
|
42389
42442
|
yield this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
42390
42443
|
this.currentMessages = this.defaultMessages;
|
|
42391
42444
|
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
42392
42445
|
yield this.configureProtocolV2Messages();
|
|
42393
|
-
Log$
|
|
42446
|
+
Log$h.debug('Configuring transports done');
|
|
42394
42447
|
}
|
|
42395
42448
|
catch (error) {
|
|
42396
|
-
Log$
|
|
42449
|
+
Log$h.debug('Initializing transports error: ', error);
|
|
42397
42450
|
if (error.code === 'ECONNABORTED') {
|
|
42398
42451
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError);
|
|
42399
42452
|
}
|
|
@@ -42409,7 +42462,7 @@ class TransportManager {
|
|
|
42409
42462
|
if (this.currentMessages === messages || !messages) {
|
|
42410
42463
|
return;
|
|
42411
42464
|
}
|
|
42412
|
-
Log$
|
|
42465
|
+
Log$h.debug(`Reconfiguring transports Protocol V1 schema:${protocolV1MessageSchema}`);
|
|
42413
42466
|
try {
|
|
42414
42467
|
yield this.transport.configure(JSON.stringify(messages));
|
|
42415
42468
|
this.currentMessages = messages;
|
|
@@ -42432,9 +42485,9 @@ class TransportManager {
|
|
|
42432
42485
|
}
|
|
42433
42486
|
if (plugin) {
|
|
42434
42487
|
this.plugin = plugin;
|
|
42435
|
-
Log$
|
|
42488
|
+
Log$h.debug('set transport plugin: ', this.plugin);
|
|
42436
42489
|
}
|
|
42437
|
-
Log$
|
|
42490
|
+
Log$h.debug('set transport: ', this.transport.name, this.transport.version, this.transport.configured);
|
|
42438
42491
|
}
|
|
42439
42492
|
static getTransport() {
|
|
42440
42493
|
return this.transport;
|
|
@@ -42445,7 +42498,7 @@ class TransportManager {
|
|
|
42445
42498
|
const { configureProtocolV2 } = this.transport;
|
|
42446
42499
|
if (protocolV2Messages && typeof configureProtocolV2 === 'function') {
|
|
42447
42500
|
yield configureProtocolV2.call(this.transport, JSON.stringify(protocolV2Messages));
|
|
42448
|
-
Log$
|
|
42501
|
+
Log$h.debug('Protocol V2 messages configured');
|
|
42449
42502
|
}
|
|
42450
42503
|
});
|
|
42451
42504
|
}
|
|
@@ -42556,7 +42609,7 @@ const cancelDeviceWithInitialize = (device) => {
|
|
|
42556
42609
|
},
|
|
42557
42610
|
}));
|
|
42558
42611
|
};
|
|
42559
|
-
const Log$
|
|
42612
|
+
const Log$g = getLogger(exports.LoggerNames.DeviceCommands);
|
|
42560
42613
|
const LogCore = getLogger(exports.LoggerNames.Core);
|
|
42561
42614
|
class DeviceCommands {
|
|
42562
42615
|
constructor(device, mainId) {
|
|
@@ -42565,7 +42618,7 @@ class DeviceCommands {
|
|
|
42565
42618
|
this.transport = TransportManager.getTransport();
|
|
42566
42619
|
this.disposed = false;
|
|
42567
42620
|
this.instanceId = generateInstanceId('DeviceCommands', device.sdkInstanceId);
|
|
42568
|
-
Log$
|
|
42621
|
+
Log$g.debug(`[DeviceCommands] Created: ${this.instanceId}, device: ${this.device.instanceId}`);
|
|
42569
42622
|
}
|
|
42570
42623
|
dispose(_cancelRequest) {
|
|
42571
42624
|
var _a, _b;
|
|
@@ -42645,7 +42698,7 @@ class DeviceCommands {
|
|
|
42645
42698
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42646
42699
|
const shouldReduceDebug = shouldReduceDebugForCall(type);
|
|
42647
42700
|
if (!shouldReduceDebug) {
|
|
42648
|
-
Log$
|
|
42701
|
+
Log$g.debug('[DeviceCommands] [call] Sending', type);
|
|
42649
42702
|
}
|
|
42650
42703
|
try {
|
|
42651
42704
|
const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
|
|
@@ -42706,10 +42759,10 @@ class DeviceCommands {
|
|
|
42706
42759
|
assertType(response, resType);
|
|
42707
42760
|
}
|
|
42708
42761
|
catch (error) {
|
|
42709
|
-
Log$
|
|
42762
|
+
Log$g.debug('DeviceCommands typedcall error: ', error);
|
|
42710
42763
|
if (error instanceof hdShared.HardwareError) {
|
|
42711
42764
|
if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
42712
|
-
Log$
|
|
42765
|
+
Log$g.debug('[DeviceCommands] [typedCall] Unexpected response type', {
|
|
42713
42766
|
request: type,
|
|
42714
42767
|
expected: resType,
|
|
42715
42768
|
received: response.type,
|
|
@@ -42743,7 +42796,7 @@ class DeviceCommands {
|
|
|
42743
42796
|
var _a;
|
|
42744
42797
|
try {
|
|
42745
42798
|
if (!shouldReduceDebugForCall(callType)) {
|
|
42746
|
-
Log$
|
|
42799
|
+
Log$g.debug('_filterCommonTypes: ', {
|
|
42747
42800
|
request: callType,
|
|
42748
42801
|
response: res.type,
|
|
42749
42802
|
});
|
|
@@ -42824,6 +42877,23 @@ class DeviceCommands {
|
|
|
42824
42877
|
firmwareMessage: message,
|
|
42825
42878
|
});
|
|
42826
42879
|
}
|
|
42880
|
+
else if (DEVICE_SESSION_CALLS.has(callType) &&
|
|
42881
|
+
(subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_Busy ||
|
|
42882
|
+
/^(?:busy|another flow in progress)$/i.test(normalizedMessage))) {
|
|
42883
|
+
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceBusy, message, {
|
|
42884
|
+
failureCode: code,
|
|
42885
|
+
subcode,
|
|
42886
|
+
firmwareMessage: message,
|
|
42887
|
+
});
|
|
42888
|
+
}
|
|
42889
|
+
else if (callType === 'DeviceSessionAskPin' &&
|
|
42890
|
+
/^passphrase disabled$/i.test(normalizedMessage)) {
|
|
42891
|
+
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotOpenedPassphrase, message, {
|
|
42892
|
+
failureCode: code,
|
|
42893
|
+
subcode,
|
|
42894
|
+
firmwareMessage: message,
|
|
42895
|
+
});
|
|
42896
|
+
}
|
|
42827
42897
|
else if (subcode === hdTransport.DeviceErrorCode.DeviceError_ActionCancelled ||
|
|
42828
42898
|
isLegacyProtocolV2ActionCancelledFailure) {
|
|
42829
42899
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.ActionCancelled, message, {
|
|
@@ -42927,7 +42997,7 @@ class DeviceCommands {
|
|
|
42927
42997
|
reject(error);
|
|
42928
42998
|
});
|
|
42929
42999
|
const listenerCount = this.device.listenerCount(DEVICE.PIN);
|
|
42930
|
-
Log$
|
|
43000
|
+
Log$g.debug(`[${this.instanceId}] _promptPin called`, {
|
|
42931
43001
|
responseID: this.currentResponseID,
|
|
42932
43002
|
deviceInstanceId: this.device.instanceId,
|
|
42933
43003
|
listenerCount,
|
|
@@ -43746,7 +43816,7 @@ const parseRunOptions = (options) => {
|
|
|
43746
43816
|
options = {};
|
|
43747
43817
|
return options;
|
|
43748
43818
|
};
|
|
43749
|
-
const Log$
|
|
43819
|
+
const Log$f = getLogger(exports.LoggerNames.Device);
|
|
43750
43820
|
function preloadSessionCache(deviceId, passphraseState, sessionId) {
|
|
43751
43821
|
deviceWalletSessionStore.set(deviceId, passphraseState, sessionId);
|
|
43752
43822
|
}
|
|
@@ -43790,7 +43860,7 @@ class Device extends events.exports {
|
|
|
43790
43860
|
this.sdkInstanceId = sdkInstanceId;
|
|
43791
43861
|
this.instanceId = generateInstanceId('Device', this.sdkInstanceId);
|
|
43792
43862
|
this.createdAt = Date.now();
|
|
43793
|
-
Log$
|
|
43863
|
+
Log$f.debug(`[Device] Created: ${this.instanceId}${this.sdkInstanceId ? ` for SDK: ${this.sdkInstanceId}` : ''}`);
|
|
43794
43864
|
}
|
|
43795
43865
|
static fromDescriptor(originalDescriptor, sdkInstanceId) {
|
|
43796
43866
|
const descriptor = Object.assign({}, originalDescriptor);
|
|
@@ -43803,7 +43873,7 @@ class Device extends events.exports {
|
|
|
43803
43873
|
const env = DataManager.getSettings('env');
|
|
43804
43874
|
const deviceType = this.getCurrentDeviceType();
|
|
43805
43875
|
const bleName = this.getCurrentBleName();
|
|
43806
|
-
const
|
|
43876
|
+
const displayName = this.getCurrentDisplayName();
|
|
43807
43877
|
const serialNo = this.getCurrentSerialNo();
|
|
43808
43878
|
const connectId = this.getConnectId();
|
|
43809
43879
|
const deviceId = this.getCurrentDeviceId() || null;
|
|
@@ -43821,8 +43891,8 @@ class Device extends events.exports {
|
|
|
43821
43891
|
deviceId,
|
|
43822
43892
|
path: (_a = this.originalDescriptor) === null || _a === void 0 ? void 0 : _a.path,
|
|
43823
43893
|
bleName,
|
|
43824
|
-
name:
|
|
43825
|
-
label:
|
|
43894
|
+
name: displayName || bleName || `OneKey ${deviceType === null || deviceType === void 0 ? void 0 : deviceType.toUpperCase()}`,
|
|
43895
|
+
label: displayName !== null && displayName !== void 0 ? displayName : '',
|
|
43826
43896
|
mode: this.getMode(),
|
|
43827
43897
|
features,
|
|
43828
43898
|
state,
|
|
@@ -43835,6 +43905,10 @@ class Device extends events.exports {
|
|
|
43835
43905
|
const env = DataManager.getSettings('env');
|
|
43836
43906
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
43837
43907
|
if (DataManager.isBleConnect(env)) {
|
|
43908
|
+
if (this.hasDeviceAcquire() && this.commands && !this.commands.disposed) {
|
|
43909
|
+
resolve(true);
|
|
43910
|
+
return;
|
|
43911
|
+
}
|
|
43838
43912
|
try {
|
|
43839
43913
|
yield this.acquire(connectProtocol);
|
|
43840
43914
|
resolve(true);
|
|
@@ -43872,12 +43946,12 @@ class Device extends events.exports {
|
|
|
43872
43946
|
if (DataManager.isBleConnect(env)) {
|
|
43873
43947
|
acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, expectedProtocol));
|
|
43874
43948
|
this.mainId = (_b = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.uuid) !== null && _b !== void 0 ? _b : '';
|
|
43875
|
-
Log$
|
|
43949
|
+
Log$f.debug('Expected uuid:', this.mainId);
|
|
43876
43950
|
}
|
|
43877
43951
|
else {
|
|
43878
43952
|
acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, expectedProtocol));
|
|
43879
43953
|
this.mainId = acquireResult;
|
|
43880
|
-
Log$
|
|
43954
|
+
Log$f.debug('Expected session id:', this.mainId);
|
|
43881
43955
|
}
|
|
43882
43956
|
this.deviceAcquired = true;
|
|
43883
43957
|
this.updateDescriptor({ [mainIdKey]: this.mainId });
|
|
@@ -43912,11 +43986,11 @@ class Device extends events.exports {
|
|
|
43912
43986
|
(this.mainId && DataManager.isBleConnect(env))) {
|
|
43913
43987
|
if (this.pendingCallbackPromise) {
|
|
43914
43988
|
try {
|
|
43915
|
-
Log$
|
|
43989
|
+
Log$f.debug('Waiting for callback tasks to complete before releasing device (in release method)');
|
|
43916
43990
|
yield this.pendingCallbackPromise.promise;
|
|
43917
43991
|
}
|
|
43918
43992
|
catch (error) {
|
|
43919
|
-
Log$
|
|
43993
|
+
Log$f.error('Error waiting for callback tasks in release method:', error);
|
|
43920
43994
|
}
|
|
43921
43995
|
}
|
|
43922
43996
|
if (this.commands) {
|
|
@@ -43935,7 +44009,7 @@ class Device extends events.exports {
|
|
|
43935
44009
|
this.updateDescriptor({ session: null });
|
|
43936
44010
|
}
|
|
43937
44011
|
catch (err) {
|
|
43938
|
-
Log$
|
|
44012
|
+
Log$f.error('[Device] release error: ', err);
|
|
43939
44013
|
}
|
|
43940
44014
|
finally {
|
|
43941
44015
|
this.needReloadDevice = true;
|
|
@@ -43994,14 +44068,16 @@ class Device extends events.exports {
|
|
|
43994
44068
|
return this.getProtocol() === 'V2';
|
|
43995
44069
|
}
|
|
43996
44070
|
getCurrentDeviceType() {
|
|
43997
|
-
|
|
44071
|
+
var _a, _b;
|
|
44072
|
+
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.identity.deviceType) !== null && _b !== void 0 ? _b : hdShared.EDeviceType.Unknown;
|
|
43998
44073
|
}
|
|
43999
44074
|
getCurrentDeviceId() {
|
|
44000
44075
|
var _a;
|
|
44001
|
-
return ((_a = this.
|
|
44076
|
+
return ((_a = this.state) === null || _a === void 0 ? void 0 : _a.identity.deviceId) || undefined;
|
|
44002
44077
|
}
|
|
44003
44078
|
getCurrentSerialNo() {
|
|
44004
|
-
|
|
44079
|
+
var _a, _b;
|
|
44080
|
+
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.identity.serialNo) !== null && _b !== void 0 ? _b : '';
|
|
44005
44081
|
}
|
|
44006
44082
|
getConnectId() {
|
|
44007
44083
|
const serialNo = this.getCurrentSerialNo();
|
|
@@ -44010,35 +44086,53 @@ class Device extends events.exports {
|
|
|
44010
44086
|
return this.originalDescriptor.path || this.originalDescriptor.id || '';
|
|
44011
44087
|
}
|
|
44012
44088
|
getCurrentBleName() {
|
|
44013
|
-
|
|
44089
|
+
var _a, _b;
|
|
44090
|
+
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.identity.bleName) !== null && _b !== void 0 ? _b : null;
|
|
44014
44091
|
}
|
|
44015
44092
|
getCurrentLabel() {
|
|
44016
|
-
|
|
44093
|
+
var _a, _b;
|
|
44094
|
+
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.identity.label) !== null && _b !== void 0 ? _b : null;
|
|
44095
|
+
}
|
|
44096
|
+
getCurrentDisplayName() {
|
|
44097
|
+
if (!this.state)
|
|
44098
|
+
return null;
|
|
44099
|
+
const label = this.getCurrentLabel();
|
|
44100
|
+
if (label)
|
|
44101
|
+
return label;
|
|
44102
|
+
const bleName = this.getCurrentBleName();
|
|
44103
|
+
if (bleName)
|
|
44104
|
+
return bleName;
|
|
44105
|
+
const deviceType = this.getCurrentDeviceType();
|
|
44106
|
+
if (deviceType === hdShared.EDeviceType.ClassicPure) {
|
|
44107
|
+
return 'OneKey Classic 1S';
|
|
44108
|
+
}
|
|
44109
|
+
return `OneKey ${deviceType.charAt(0).toUpperCase() + deviceType.slice(1)}`;
|
|
44017
44110
|
}
|
|
44018
44111
|
getCurrentPassphraseProtection() {
|
|
44019
44112
|
var _a;
|
|
44020
|
-
return (_a = this.
|
|
44113
|
+
return (_a = this.state) === null || _a === void 0 ? void 0 : _a.status.passphraseProtection;
|
|
44021
44114
|
}
|
|
44022
44115
|
getCurrentFirmwareType() {
|
|
44023
|
-
|
|
44116
|
+
var _a, _b;
|
|
44117
|
+
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.identity.firmwareType) !== null && _b !== void 0 ? _b : hdShared.EFirmwareType.Universal;
|
|
44024
44118
|
}
|
|
44025
44119
|
getCurrentFirmwareVersionString() {
|
|
44026
44120
|
var _a;
|
|
44027
|
-
return (_a =
|
|
44121
|
+
return parseDeviceVersion((_a = this.state) === null || _a === void 0 ? void 0 : _a.versions.firmware).join('.');
|
|
44028
44122
|
}
|
|
44029
44123
|
getCurrentBLEFirmwareVersionString() {
|
|
44030
|
-
if (!this.
|
|
44124
|
+
if (!this.state)
|
|
44031
44125
|
return undefined;
|
|
44032
|
-
return
|
|
44126
|
+
return parseDeviceVersion(this.state.versions.ble).join('.');
|
|
44033
44127
|
}
|
|
44034
44128
|
getCurrentBootloaderVersionString() {
|
|
44035
|
-
if (!this.
|
|
44129
|
+
if (!this.state)
|
|
44036
44130
|
return undefined;
|
|
44037
|
-
return
|
|
44131
|
+
return parseDeviceVersion(this.state.versions.bootloader).join('.');
|
|
44038
44132
|
}
|
|
44039
44133
|
getCurrentSafetyChecks() {
|
|
44040
44134
|
var _a;
|
|
44041
|
-
return (_a = this.
|
|
44135
|
+
return (_a = this.state) === null || _a === void 0 ? void 0 : _a.settings.safetyChecks;
|
|
44042
44136
|
}
|
|
44043
44137
|
getCurrentMethodVersionRange(getVersionRange) {
|
|
44044
44138
|
var _a;
|
|
@@ -44075,8 +44169,6 @@ class Device extends events.exports {
|
|
|
44075
44169
|
};
|
|
44076
44170
|
}
|
|
44077
44171
|
supportInputPinOnSoftware() {
|
|
44078
|
-
if (this.features)
|
|
44079
|
-
return supportInputPinOnSoftware(this.features);
|
|
44080
44172
|
const deviceType = this.getCurrentDeviceType();
|
|
44081
44173
|
if (deviceType === hdShared.EDeviceType.Touch ||
|
|
44082
44174
|
deviceType === hdShared.EDeviceType.Pro ||
|
|
@@ -44093,8 +44185,6 @@ class Device extends events.exports {
|
|
|
44093
44185
|
if (this.isProtocolV2()) {
|
|
44094
44186
|
return { support: true };
|
|
44095
44187
|
}
|
|
44096
|
-
if (this.features)
|
|
44097
|
-
return supportModifyHomescreen(this.features);
|
|
44098
44188
|
const deviceType = this.getCurrentDeviceType();
|
|
44099
44189
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
44100
44190
|
return { support: true };
|
|
@@ -44121,8 +44211,7 @@ class Device extends events.exports {
|
|
|
44121
44211
|
});
|
|
44122
44212
|
}
|
|
44123
44213
|
getInternalState(_deviceId) {
|
|
44124
|
-
|
|
44125
|
-
Log$e.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
44214
|
+
Log$f.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `currentDeviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
44126
44215
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
44127
44216
|
if (!deviceId)
|
|
44128
44217
|
return undefined;
|
|
@@ -44131,7 +44220,7 @@ class Device extends events.exports {
|
|
|
44131
44220
|
return deviceWalletSessionStore.get(deviceId, this.passphraseState);
|
|
44132
44221
|
}
|
|
44133
44222
|
updateInternalState(enablePassphrase, passphraseState, deviceId, sessionId = null, featuresSessionId = null) {
|
|
44134
|
-
Log$
|
|
44223
|
+
Log$f.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `hasPassphraseState: ${Boolean(passphraseState)}`, `hasSessionId: ${Boolean(sessionId)}`, `hasFeaturesSessionId: ${Boolean(featuresSessionId)}`);
|
|
44135
44224
|
const cacheDeviceKey = this.getSessionCacheDeviceKey(deviceId);
|
|
44136
44225
|
if (!cacheDeviceKey)
|
|
44137
44226
|
return;
|
|
@@ -44142,8 +44231,7 @@ class Device extends events.exports {
|
|
|
44142
44231
|
deviceWalletSessionStore.deletePending(cacheDeviceKey);
|
|
44143
44232
|
}
|
|
44144
44233
|
setInternalState(state, initSession) {
|
|
44145
|
-
|
|
44146
|
-
Log$e.debug('setInternalState session param: ', `hasState: ${Boolean(state)}`, `initSession: ${initSession}`, `deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
44234
|
+
Log$f.debug('setInternalState session param: ', `hasState: ${Boolean(state)}`, `initSession: ${initSession}`, `deviceId: ${this.getCurrentDeviceId()}`, `hasPassphraseState: ${Boolean(this.passphraseState)}`);
|
|
44147
44235
|
if (!this.passphraseState && !initSession)
|
|
44148
44236
|
return;
|
|
44149
44237
|
const deviceId = this.getSessionCacheDeviceKey();
|
|
@@ -44157,7 +44245,7 @@ class Device extends events.exports {
|
|
|
44157
44245
|
}
|
|
44158
44246
|
}
|
|
44159
44247
|
clearInternalState(_deviceId) {
|
|
44160
|
-
Log$
|
|
44248
|
+
Log$f.debug('clearInternalState param: ', _deviceId);
|
|
44161
44249
|
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
44162
44250
|
if (!deviceId)
|
|
44163
44251
|
return;
|
|
@@ -44167,12 +44255,11 @@ class Device extends events.exports {
|
|
|
44167
44255
|
}
|
|
44168
44256
|
}
|
|
44169
44257
|
initialize(options) {
|
|
44170
|
-
var _a;
|
|
44171
44258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44172
44259
|
if (this.isProtocolV2()) {
|
|
44173
44260
|
this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
|
|
44174
44261
|
if (this.state && !(options === null || options === void 0 ? void 0 : options.initSession) && !this.protocolV2StateNeedsReload) {
|
|
44175
|
-
if (
|
|
44262
|
+
if (this.state.status.mode === 'bootloader' || this.state.status.mode === 'romloader') {
|
|
44176
44263
|
return;
|
|
44177
44264
|
}
|
|
44178
44265
|
return;
|
|
@@ -44224,24 +44311,24 @@ class Device extends events.exports {
|
|
|
44224
44311
|
}
|
|
44225
44312
|
}
|
|
44226
44313
|
catch (error) {
|
|
44227
|
-
Log$
|
|
44314
|
+
Log$f.error('Initialization failed:', error);
|
|
44228
44315
|
throw error;
|
|
44229
44316
|
}
|
|
44230
44317
|
});
|
|
44231
44318
|
}
|
|
44232
44319
|
_initializeProtocolV2(options) {
|
|
44233
44320
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44234
|
-
Log$
|
|
44321
|
+
Log$f.debug('Initialize device via Protocol V2 features adapter');
|
|
44235
44322
|
try {
|
|
44236
44323
|
const deviceInfo = yield requestProtocolV2DeviceInfo({
|
|
44237
44324
|
commands: this.commands,
|
|
44238
44325
|
timeoutMs: options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs,
|
|
44239
44326
|
});
|
|
44240
44327
|
const features = yield this.probeProtocolV2RuntimeState(deviceInfo, options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs);
|
|
44241
|
-
Log$
|
|
44328
|
+
Log$f.debug('Protocol V2 features:', features);
|
|
44242
44329
|
}
|
|
44243
44330
|
catch (error) {
|
|
44244
|
-
Log$
|
|
44331
|
+
Log$f.error('Protocol V2 initialization failed:', error);
|
|
44245
44332
|
throw error;
|
|
44246
44333
|
}
|
|
44247
44334
|
});
|
|
@@ -44349,7 +44436,7 @@ class Device extends events.exports {
|
|
|
44349
44436
|
source,
|
|
44350
44437
|
changedKeys: result.changedKeys,
|
|
44351
44438
|
};
|
|
44352
|
-
Log$
|
|
44439
|
+
Log$f.debug('Device state patch committed', {
|
|
44353
44440
|
source,
|
|
44354
44441
|
keys: result.changedKeys,
|
|
44355
44442
|
});
|
|
@@ -44384,7 +44471,7 @@ class Device extends events.exports {
|
|
|
44384
44471
|
deviceInfo,
|
|
44385
44472
|
deviceStatusAvailable: false,
|
|
44386
44473
|
});
|
|
44387
|
-
Log$
|
|
44474
|
+
Log$f.debug('Protocol V2 DeviceStatusGet unavailable; use temporary loader fallback', {
|
|
44388
44475
|
runtimeMode,
|
|
44389
44476
|
error: error instanceof Error ? error.message : String(error),
|
|
44390
44477
|
});
|
|
@@ -44415,6 +44502,7 @@ class Device extends events.exports {
|
|
|
44415
44502
|
return this.updateProtocolV2Features(previousDeviceInfo, Object.assign(Object.assign({}, previousStatus), status));
|
|
44416
44503
|
}
|
|
44417
44504
|
markTransportDisconnected() {
|
|
44505
|
+
this.deviceAcquired = false;
|
|
44418
44506
|
if (!this.isProtocolV2())
|
|
44419
44507
|
return;
|
|
44420
44508
|
this.protocolV2StateNeedsReload = true;
|
|
@@ -44499,7 +44587,7 @@ class Device extends events.exports {
|
|
|
44499
44587
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44500
44588
|
if (this.runPromise) {
|
|
44501
44589
|
yield this.interruptionFromOutside();
|
|
44502
|
-
Log$
|
|
44590
|
+
Log$f.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
44503
44591
|
}
|
|
44504
44592
|
options = parseRunOptions(options);
|
|
44505
44593
|
const runPromise = hdShared.createDeferred();
|
|
@@ -44571,7 +44659,7 @@ class Device extends events.exports {
|
|
|
44571
44659
|
yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
|
|
44572
44660
|
}
|
|
44573
44661
|
yield this.release();
|
|
44574
|
-
Log$
|
|
44662
|
+
Log$f.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
44575
44663
|
}
|
|
44576
44664
|
clearRunPromise();
|
|
44577
44665
|
return;
|
|
@@ -44581,7 +44669,7 @@ class Device extends events.exports {
|
|
|
44581
44669
|
options.keepSession === false) {
|
|
44582
44670
|
this.keepSession = false;
|
|
44583
44671
|
yield this.release();
|
|
44584
|
-
Log$
|
|
44672
|
+
Log$f.debug('release device, mainId: ', this.mainId);
|
|
44585
44673
|
}
|
|
44586
44674
|
runPromise.resolve();
|
|
44587
44675
|
clearRunPromise();
|
|
@@ -44612,7 +44700,7 @@ class Device extends events.exports {
|
|
|
44612
44700
|
setCancelableAction(callback) {
|
|
44613
44701
|
this.cancelableAction = (e) => callback(e)
|
|
44614
44702
|
.catch(e2 => {
|
|
44615
|
-
Log$
|
|
44703
|
+
Log$f.debug('cancelableAction error', e2);
|
|
44616
44704
|
})
|
|
44617
44705
|
.finally(() => {
|
|
44618
44706
|
this.clearCancelableAction();
|
|
@@ -44622,7 +44710,7 @@ class Device extends events.exports {
|
|
|
44622
44710
|
this.cancelableAction = undefined;
|
|
44623
44711
|
}
|
|
44624
44712
|
getMode() {
|
|
44625
|
-
var _a
|
|
44713
|
+
var _a;
|
|
44626
44714
|
switch ((_a = this.state) === null || _a === void 0 ? void 0 : _a.status.mode) {
|
|
44627
44715
|
case 'bootloader':
|
|
44628
44716
|
case 'romloader':
|
|
@@ -44634,23 +44722,17 @@ class Device extends events.exports {
|
|
|
44634
44722
|
case 'normal':
|
|
44635
44723
|
return exports.EOneKeyDeviceMode.normal;
|
|
44636
44724
|
}
|
|
44637
|
-
if ((_b = this.features) === null || _b === void 0 ? void 0 : _b.bootloaderMode)
|
|
44638
|
-
return exports.EOneKeyDeviceMode.bootloader;
|
|
44639
|
-
if (((_c = this.features) === null || _c === void 0 ? void 0 : _c.initialized) === false)
|
|
44640
|
-
return exports.EOneKeyDeviceMode.notInitialized;
|
|
44641
|
-
if ((_d = this.features) === null || _d === void 0 ? void 0 : _d.noBackup)
|
|
44642
|
-
return exports.EOneKeyDeviceMode.backupMode;
|
|
44643
44725
|
return exports.EOneKeyDeviceMode.normal;
|
|
44644
44726
|
}
|
|
44645
44727
|
getFirmwareVersion() {
|
|
44646
|
-
if (!this.
|
|
44728
|
+
if (!this.state)
|
|
44647
44729
|
return null;
|
|
44648
|
-
return
|
|
44730
|
+
return parseDeviceVersion(this.state.versions.firmware);
|
|
44649
44731
|
}
|
|
44650
44732
|
getBLEFirmwareVersion() {
|
|
44651
|
-
if (!this.
|
|
44733
|
+
if (!this.state)
|
|
44652
44734
|
return null;
|
|
44653
|
-
return
|
|
44735
|
+
return parseDeviceVersion(this.state.versions.ble);
|
|
44654
44736
|
}
|
|
44655
44737
|
isUsed() {
|
|
44656
44738
|
return typeof this.originalDescriptor.session === 'string';
|
|
@@ -44665,7 +44747,7 @@ class Device extends events.exports {
|
|
|
44665
44747
|
isUsedHere() {
|
|
44666
44748
|
const env = DataManager.getSettings('env');
|
|
44667
44749
|
if (DataManager.isBleConnect(env)) {
|
|
44668
|
-
return
|
|
44750
|
+
return this.deviceAcquired;
|
|
44669
44751
|
}
|
|
44670
44752
|
return this.isUsed() && this.originalDescriptor.session === this.mainId;
|
|
44671
44753
|
}
|
|
@@ -44673,16 +44755,22 @@ class Device extends events.exports {
|
|
|
44673
44755
|
return this.isUsed() && !this.isUsedHere();
|
|
44674
44756
|
}
|
|
44675
44757
|
isBootloader() {
|
|
44676
|
-
|
|
44758
|
+
if (!this.state)
|
|
44759
|
+
return undefined;
|
|
44760
|
+
return this.state.status.mode === 'bootloader' || this.state.status.mode === 'romloader';
|
|
44677
44761
|
}
|
|
44678
44762
|
isInitialized() {
|
|
44679
|
-
|
|
44763
|
+
if (!this.state)
|
|
44764
|
+
return undefined;
|
|
44765
|
+
return this.state.status.initialized === true;
|
|
44680
44766
|
}
|
|
44681
44767
|
isSeedless() {
|
|
44682
|
-
|
|
44768
|
+
if (!this.state)
|
|
44769
|
+
return undefined;
|
|
44770
|
+
return this.state.status.noBackup === true;
|
|
44683
44771
|
}
|
|
44684
44772
|
isUnacquired() {
|
|
44685
|
-
return this.
|
|
44773
|
+
return this.state === undefined;
|
|
44686
44774
|
}
|
|
44687
44775
|
hasUnexpectedMode(allow, require) {
|
|
44688
44776
|
if (!this.isUnacquired()) {
|
|
@@ -44707,7 +44795,7 @@ class Device extends events.exports {
|
|
|
44707
44795
|
const isModeT = deviceType === hdShared.EDeviceType.Touch ||
|
|
44708
44796
|
deviceType === hdShared.EDeviceType.Pro ||
|
|
44709
44797
|
deviceType === hdShared.EDeviceType.Pro2;
|
|
44710
|
-
const unlocked = (_a = this.
|
|
44798
|
+
const unlocked = (_a = this.state) === null || _a === void 0 ? void 0 : _a.status.unlocked;
|
|
44711
44799
|
const preCheckTouch = isModeT && unlocked === false;
|
|
44712
44800
|
const passphraseProtection = this.getCurrentPassphraseProtection();
|
|
44713
44801
|
return Boolean(passphraseProtection === true || preCheckTouch);
|
|
@@ -44730,13 +44818,11 @@ class Device extends events.exports {
|
|
|
44730
44818
|
};
|
|
44731
44819
|
}
|
|
44732
44820
|
unlockDevice(pinType = hdTransport.DeviceSessionPinType.Main) {
|
|
44733
|
-
var _a, _b, _c;
|
|
44821
|
+
var _a, _b, _c, _d;
|
|
44734
44822
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44735
44823
|
if (this.isProtocolV2()) {
|
|
44736
44824
|
try {
|
|
44737
|
-
yield this.commands.typedCall('DeviceSessionAskPin', 'Success', { type: pinType }
|
|
44738
|
-
timeoutMs: 120000,
|
|
44739
|
-
});
|
|
44825
|
+
yield this.commands.typedCall('DeviceSessionAskPin', 'Success', { type: pinType });
|
|
44740
44826
|
}
|
|
44741
44827
|
catch (error) {
|
|
44742
44828
|
const errorText = error instanceof Error
|
|
@@ -44752,14 +44838,14 @@ class Device extends events.exports {
|
|
|
44752
44838
|
}
|
|
44753
44839
|
const firmwareVersion = (_c = this.getCurrentFirmwareVersionString()) !== null && _c !== void 0 ? _c : '0.0.0';
|
|
44754
44840
|
const versionRange = this.getCurrentMethodVersionRange(type => this.supportUnlockVersionRange()[type]);
|
|
44755
|
-
const supportAttachPinCapability =
|
|
44841
|
+
const supportAttachPinCapability = (_d = this.state) === null || _d === void 0 ? void 0 : _d.capabilities.includes(hdTransport.Enum_Capability.Capability_AttachToPin);
|
|
44756
44842
|
const supportUnlock = supportAttachPinCapability ||
|
|
44757
44843
|
(versionRange &&
|
|
44758
44844
|
semver__default["default"].valid(firmwareVersion) &&
|
|
44759
44845
|
semver__default["default"].gte(firmwareVersion, versionRange.min));
|
|
44760
44846
|
if (supportUnlock) {
|
|
44761
44847
|
const res = yield this.commands.typedCall('UnLockDevice', 'UnLockDeviceResponse');
|
|
44762
|
-
if (this.
|
|
44848
|
+
if (this.state) {
|
|
44763
44849
|
this.updateState({
|
|
44764
44850
|
status: {
|
|
44765
44851
|
unlocked: res.message.unlocked == null ? null : res.message.unlocked,
|
|
@@ -44801,7 +44887,7 @@ class Device extends events.exports {
|
|
|
44801
44887
|
expectedPassphraseState &&
|
|
44802
44888
|
expectedPassphraseState !== newPassphraseState;
|
|
44803
44889
|
const passphraseStateMismatch = !!expectedPassphraseState && expectedPassphraseState !== newPassphraseState;
|
|
44804
|
-
Log$
|
|
44890
|
+
Log$f.debug('Check passphrase state safety: ', {
|
|
44805
44891
|
hasExpectedPassphraseState: Boolean(expectedPassphraseState),
|
|
44806
44892
|
hasNewPassphraseState: Boolean(newPassphraseState),
|
|
44807
44893
|
passphraseStateMatches: Boolean(expectedPassphraseState) && expectedPassphraseState === newPassphraseState,
|
|
@@ -45034,7 +45120,7 @@ const PROTOCOL_V2_RETRY_ON_LOCKED_METHODS = [
|
|
|
45034
45120
|
const retryOnLockedMethods = new Set(PROTOCOL_V2_RETRY_ON_LOCKED_METHODS);
|
|
45035
45121
|
const getProtocolV2UnlockPolicy = (methodName) => retryOnLockedMethods.has(methodName) ? 'retry-on-locked' : 'none';
|
|
45036
45122
|
|
|
45037
|
-
const Log$
|
|
45123
|
+
const Log$e = getLogger(exports.LoggerNames.Method);
|
|
45038
45124
|
const isEvmLedgerLegacyPathWithHighIndex = (path) => {
|
|
45039
45125
|
let addressN;
|
|
45040
45126
|
if (typeof path === 'string') {
|
|
@@ -45067,6 +45153,17 @@ class BaseMethod {
|
|
|
45067
45153
|
this.name,
|
|
45068
45154
|
].join('|');
|
|
45069
45155
|
}
|
|
45156
|
+
getSupportedProtocols() {
|
|
45157
|
+
return ['V1'];
|
|
45158
|
+
}
|
|
45159
|
+
supportsProtocol(protocol) {
|
|
45160
|
+
return this.getSupportedProtocols().includes(protocol);
|
|
45161
|
+
}
|
|
45162
|
+
assertProtocolSupported(protocol, firmwareType) {
|
|
45163
|
+
if (!this.supportsProtocol(protocol)) {
|
|
45164
|
+
throw hdShared.createDeviceNotSupportMethodError(this.name, firmwareType);
|
|
45165
|
+
}
|
|
45166
|
+
}
|
|
45070
45167
|
throwIfAborted() {
|
|
45071
45168
|
var _a;
|
|
45072
45169
|
if ((_a = this.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
@@ -45082,7 +45179,6 @@ class BaseMethod {
|
|
|
45082
45179
|
this.isPreWarmSignal = false;
|
|
45083
45180
|
this.preWarmTtl = 60 * 1000;
|
|
45084
45181
|
this.strictCheckDeviceSupport = false;
|
|
45085
|
-
this.requireProtocolV2 = false;
|
|
45086
45182
|
this.unlockPolicy = 'none';
|
|
45087
45183
|
this.protocolV2UiMode = 'auto';
|
|
45088
45184
|
this.temporarySafetyCheckPrompted = false;
|
|
@@ -45109,7 +45205,7 @@ class BaseMethod {
|
|
|
45109
45205
|
setContext(context) {
|
|
45110
45206
|
this.sdkInstanceId = context.sdkInstanceId;
|
|
45111
45207
|
this.instanceId = generateInstanceId('Method', this.sdkInstanceId);
|
|
45112
|
-
Log$
|
|
45208
|
+
Log$e.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
|
|
45113
45209
|
}
|
|
45114
45210
|
setDevice(device) {
|
|
45115
45211
|
var _a, _b;
|
|
@@ -45129,7 +45225,7 @@ class BaseMethod {
|
|
|
45129
45225
|
if (device.commands) {
|
|
45130
45226
|
device.commands.currentResponseID = this.responseID;
|
|
45131
45227
|
}
|
|
45132
|
-
Log$
|
|
45228
|
+
Log$e.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
|
|
45133
45229
|
}
|
|
45134
45230
|
checkFirmwareRelease() {
|
|
45135
45231
|
if (!this.device || this.device.isProtocolV2())
|
|
@@ -45160,9 +45256,6 @@ class BaseMethod {
|
|
|
45160
45256
|
}
|
|
45161
45257
|
const firmwareVersion = (_a = this.device.getCurrentFirmwareVersionString()) !== null && _a !== void 0 ? _a : '0.0.0';
|
|
45162
45258
|
const versionRange = this.device.getCurrentMethodVersionRange(type => getVersionRange()[type]);
|
|
45163
|
-
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
45164
|
-
throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
45165
|
-
}
|
|
45166
45259
|
if (!versionRange) {
|
|
45167
45260
|
if (options === null || options === void 0 ? void 0 : options.strictCheckDeviceSupport) {
|
|
45168
45261
|
throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
@@ -45207,7 +45300,7 @@ class BaseMethod {
|
|
|
45207
45300
|
checkFlag = true;
|
|
45208
45301
|
}
|
|
45209
45302
|
if (checkFlag && this.device.getCurrentSafetyChecks() === hdTransport.Enum_SafetyCheckLevel.Strict) {
|
|
45210
|
-
Log$
|
|
45303
|
+
Log$e.debug('will change safety_checks level');
|
|
45211
45304
|
yield this.device.commands.typedCall('ApplySettings', 'Success', {
|
|
45212
45305
|
safety_checks: hdTransport.Enum_SafetyCheckLevel.PromptTemporarily,
|
|
45213
45306
|
});
|
|
@@ -45241,13 +45334,58 @@ class TestInitializeDeviceDuration extends BaseMethod {
|
|
|
45241
45334
|
}
|
|
45242
45335
|
}
|
|
45243
45336
|
|
|
45244
|
-
const
|
|
45337
|
+
const PROTOCOL_V2_PING_MAX_MESSAGE_BYTES = 63;
|
|
45338
|
+
const getUtf8ByteLength$1 = (value) => Array.from(value).reduce((length, character) => {
|
|
45339
|
+
var _a;
|
|
45340
|
+
const codePoint = (_a = character.codePointAt(0)) !== null && _a !== void 0 ? _a : 0;
|
|
45341
|
+
if (codePoint <= 0x7f)
|
|
45342
|
+
return length + 1;
|
|
45343
|
+
if (codePoint <= 0x7ff)
|
|
45344
|
+
return length + 2;
|
|
45345
|
+
if (codePoint <= 0xffff)
|
|
45346
|
+
return length + 3;
|
|
45347
|
+
return length + 4;
|
|
45348
|
+
}, 0);
|
|
45349
|
+
function validateProtocolV2PingMessage(value) {
|
|
45350
|
+
if (value !== undefined && typeof value !== 'string') {
|
|
45351
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Protocol V2 Ping message must be a string.');
|
|
45352
|
+
}
|
|
45353
|
+
const message = value !== null && value !== void 0 ? value : '';
|
|
45354
|
+
if (getUtf8ByteLength$1(message) > PROTOCOL_V2_PING_MAX_MESSAGE_BYTES) {
|
|
45355
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, `Protocol V2 Ping message must not exceed ${PROTOCOL_V2_PING_MAX_MESSAGE_BYTES} UTF-8 bytes.`);
|
|
45356
|
+
}
|
|
45357
|
+
return message;
|
|
45358
|
+
}
|
|
45359
|
+
class Ping extends BaseMethod {
|
|
45360
|
+
getSupportedProtocols() {
|
|
45361
|
+
return ['V2'];
|
|
45362
|
+
}
|
|
45363
|
+
init() {
|
|
45364
|
+
this.skipForceUpdateCheck = true;
|
|
45365
|
+
this.useDevicePassphraseState = false;
|
|
45366
|
+
this.params = { message: validateProtocolV2PingMessage(this.payload.message) };
|
|
45367
|
+
}
|
|
45368
|
+
run() {
|
|
45369
|
+
var _a;
|
|
45370
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45371
|
+
const res = yield this.device.commands.typedCall('Ping', 'Success', {
|
|
45372
|
+
message: (_a = this.params.message) !== null && _a !== void 0 ? _a : '',
|
|
45373
|
+
});
|
|
45374
|
+
return Promise.resolve(res.message);
|
|
45375
|
+
});
|
|
45376
|
+
}
|
|
45377
|
+
}
|
|
45378
|
+
|
|
45379
|
+
const Log$d = getLogger(exports.LoggerNames.Core);
|
|
45245
45380
|
const parseInitOptions$1 = (payload) => ({
|
|
45246
45381
|
initSession: payload === null || payload === void 0 ? void 0 : payload.initSession,
|
|
45247
45382
|
passphraseState: payload === null || payload === void 0 ? void 0 : payload.passphraseState,
|
|
45248
45383
|
deriveCardano: payload === null || payload === void 0 ? void 0 : payload.deriveCardano,
|
|
45249
45384
|
});
|
|
45250
45385
|
class PreInitialize extends BaseMethod {
|
|
45386
|
+
getSupportedProtocols() {
|
|
45387
|
+
return ['V1', 'V2'];
|
|
45388
|
+
}
|
|
45251
45389
|
init() {
|
|
45252
45390
|
this.skipForceUpdateCheck = true;
|
|
45253
45391
|
this.useDevicePassphraseState = false;
|
|
@@ -45264,14 +45402,14 @@ class PreInitialize extends BaseMethod {
|
|
|
45264
45402
|
}
|
|
45265
45403
|
catch (_a) {
|
|
45266
45404
|
this.device.clearPreInitialized();
|
|
45267
|
-
Log$
|
|
45405
|
+
Log$d.debug('[PRE-INIT][FAILED]');
|
|
45268
45406
|
return false;
|
|
45269
45407
|
}
|
|
45270
45408
|
});
|
|
45271
45409
|
}
|
|
45272
45410
|
}
|
|
45273
45411
|
|
|
45274
|
-
const Log$
|
|
45412
|
+
const Log$c = getLogger(exports.LoggerNames.DevicePool);
|
|
45275
45413
|
class SearchDevices extends BaseMethod {
|
|
45276
45414
|
init() {
|
|
45277
45415
|
this.useDevice = false;
|
|
@@ -45311,7 +45449,7 @@ class SearchDevices extends BaseMethod {
|
|
|
45311
45449
|
const errorCode = error && typeof error === 'object' && 'errorCode' in error
|
|
45312
45450
|
? error.errorCode
|
|
45313
45451
|
: undefined;
|
|
45314
|
-
Log$
|
|
45452
|
+
Log$c.debug('Skip unavailable device during search', Object.assign({ path: descriptor.path }, (errorCode !== undefined ? { errorCode } : {})));
|
|
45315
45453
|
}
|
|
45316
45454
|
}
|
|
45317
45455
|
return deviceList.map(device => device.toMessageObject());
|
|
@@ -45336,9 +45474,6 @@ class GetFeatures extends BaseMethod {
|
|
|
45336
45474
|
if (((_a = this.payload) === null || _a === void 0 ? void 0 : _a.detectBootloaderDevice) && this.device.isBootloader()) {
|
|
45337
45475
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceDetectInBootloaderMode));
|
|
45338
45476
|
}
|
|
45339
|
-
if (this.device.isProtocolV2()) {
|
|
45340
|
-
throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
45341
|
-
}
|
|
45342
45477
|
const state = yield this.device.getDeviceState({
|
|
45343
45478
|
includeRaw: true,
|
|
45344
45479
|
});
|
|
@@ -45354,6 +45489,9 @@ const SCOPE_SECTIONS = {
|
|
|
45354
45489
|
};
|
|
45355
45490
|
const isLoaderMode = (mode) => mode === 'bootloader' || mode === 'romloader';
|
|
45356
45491
|
class GetDeviceState extends BaseMethod {
|
|
45492
|
+
getSupportedProtocols() {
|
|
45493
|
+
return ['V1', 'V2'];
|
|
45494
|
+
}
|
|
45357
45495
|
init() {
|
|
45358
45496
|
var _a;
|
|
45359
45497
|
const scope = ((_a = this.payload.scope) !== null && _a !== void 0 ? _a : 'runtime');
|
|
@@ -45403,9 +45541,6 @@ class GetOnekeyFeatures extends BaseMethod {
|
|
|
45403
45541
|
}
|
|
45404
45542
|
run() {
|
|
45405
45543
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45406
|
-
if (this.device.isProtocolV2()) {
|
|
45407
|
-
throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
45408
|
-
}
|
|
45409
45544
|
const { message } = yield this.device.commands.typedCall('OnekeyGetFeatures', 'OnekeyFeatures');
|
|
45410
45545
|
normalizeOnekeyFirmwareVersion(message);
|
|
45411
45546
|
return Promise.resolve(message);
|
|
@@ -45414,6 +45549,9 @@ class GetOnekeyFeatures extends BaseMethod {
|
|
|
45414
45549
|
}
|
|
45415
45550
|
|
|
45416
45551
|
class GetPassphraseState extends BaseMethod {
|
|
45552
|
+
getSupportedProtocols() {
|
|
45553
|
+
return ['V1', 'V2'];
|
|
45554
|
+
}
|
|
45417
45555
|
init() {
|
|
45418
45556
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
45419
45557
|
this.useDevicePassphraseState = false;
|
|
@@ -45629,12 +45767,6 @@ const requiredString = (value, name) => {
|
|
|
45629
45767
|
}
|
|
45630
45768
|
return value.trim();
|
|
45631
45769
|
};
|
|
45632
|
-
const optionalBoolean = (value, name) => {
|
|
45633
|
-
if (value !== undefined && typeof value !== 'boolean') {
|
|
45634
|
-
throw invalidParameter$1(`Parameter [${name}] must be a boolean.`);
|
|
45635
|
-
}
|
|
45636
|
-
return value;
|
|
45637
|
-
};
|
|
45638
45770
|
const wasResumed = (session) => !!session &&
|
|
45639
45771
|
typeof session === 'object' &&
|
|
45640
45772
|
'resumed' in session &&
|
|
@@ -45647,49 +45779,22 @@ const requireHiddenWalletResponse = (session) => {
|
|
|
45647
45779
|
return Object.assign({ passphraseState: session.passphraseState }, forwardSessionId(session));
|
|
45648
45780
|
};
|
|
45649
45781
|
const normalizeParams = (payload) => {
|
|
45650
|
-
if (payload.mode
|
|
45651
|
-
|
|
45652
|
-
payload.mode !== 'select-hidden' &&
|
|
45653
|
-
payload.mode !== 'resume-hidden') {
|
|
45654
|
-
throw invalidParameter$1('Parameter [mode] must be one of standard, select-hidden, or resume-hidden.');
|
|
45655
|
-
}
|
|
45656
|
-
if (payload.useEmptyPassphrase !== undefined || payload.initSession !== undefined) {
|
|
45657
|
-
throw invalidParameter$1('Parameters [useEmptyPassphrase] and [initSession] cannot be used with [mode].');
|
|
45658
|
-
}
|
|
45659
|
-
if (payload.mode === 'standard' || payload.mode === 'select-hidden') {
|
|
45660
|
-
if (payload.deviceId !== undefined || payload.passphraseState !== undefined) {
|
|
45661
|
-
throw invalidParameter$1('Parameters [deviceId] and [passphraseState] are only allowed with mode [resume-hidden].');
|
|
45662
|
-
}
|
|
45663
|
-
return { mode: payload.mode };
|
|
45664
|
-
}
|
|
45665
|
-
return {
|
|
45666
|
-
mode: 'resume-hidden',
|
|
45667
|
-
deviceId: requiredString(payload.deviceId, 'deviceId'),
|
|
45668
|
-
passphraseState: requiredString(payload.passphraseState, 'passphraseState'),
|
|
45669
|
-
};
|
|
45782
|
+
if (payload.mode === undefined) {
|
|
45783
|
+
throw invalidParameter$1('Parameter [mode] is required.');
|
|
45670
45784
|
}
|
|
45671
|
-
|
|
45672
|
-
|
|
45673
|
-
|
|
45674
|
-
|
|
45785
|
+
if (payload.mode !== 'standard' &&
|
|
45786
|
+
payload.mode !== 'select-hidden' &&
|
|
45787
|
+
payload.mode !== 'resume-hidden') {
|
|
45788
|
+
throw invalidParameter$1('Parameter [mode] must be one of standard, select-hidden, or resume-hidden.');
|
|
45675
45789
|
}
|
|
45676
|
-
if (initSession
|
|
45677
|
-
|
|
45678
|
-
const passphraseState = payload.passphraseState === undefined
|
|
45679
|
-
? undefined
|
|
45680
|
-
: requiredString(payload.passphraseState, 'passphraseState');
|
|
45681
|
-
return Object.assign({ mode: 'select-hidden' }, (passphraseState
|
|
45682
|
-
? {
|
|
45683
|
-
legacySessionToClear: {
|
|
45684
|
-
deviceId,
|
|
45685
|
-
passphraseState,
|
|
45686
|
-
},
|
|
45687
|
-
}
|
|
45688
|
-
: {}));
|
|
45790
|
+
if (payload.useEmptyPassphrase !== undefined || payload.initSession !== undefined) {
|
|
45791
|
+
throw invalidParameter$1('Legacy parameters [useEmptyPassphrase] and [initSession] are not supported by openWalletSession.');
|
|
45689
45792
|
}
|
|
45690
|
-
|
|
45691
|
-
|
|
45692
|
-
|
|
45793
|
+
if (payload.mode === 'standard' || payload.mode === 'select-hidden') {
|
|
45794
|
+
if (payload.deviceId !== undefined || payload.passphraseState !== undefined) {
|
|
45795
|
+
throw invalidParameter$1('Parameters [deviceId] and [passphraseState] are only allowed with mode [resume-hidden].');
|
|
45796
|
+
}
|
|
45797
|
+
return { mode: payload.mode };
|
|
45693
45798
|
}
|
|
45694
45799
|
return {
|
|
45695
45800
|
mode: 'resume-hidden',
|
|
@@ -45698,6 +45803,9 @@ const normalizeParams = (payload) => {
|
|
|
45698
45803
|
};
|
|
45699
45804
|
};
|
|
45700
45805
|
class OpenWalletSession extends BaseMethod {
|
|
45806
|
+
getSupportedProtocols() {
|
|
45807
|
+
return ['V1', 'V2'];
|
|
45808
|
+
}
|
|
45701
45809
|
init() {
|
|
45702
45810
|
this.useDevicePassphraseState = false;
|
|
45703
45811
|
this.skipForceUpdateCheck = true;
|
|
@@ -45710,29 +45818,17 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45710
45818
|
const isProtocolV2 = this.device.isProtocolV2();
|
|
45711
45819
|
const state = yield this.device.getDeviceState({ refreshSections: ['status'] });
|
|
45712
45820
|
let currentDeviceId = state.identity.deviceId;
|
|
45713
|
-
const { legacySessionToClear } = this.params;
|
|
45714
45821
|
const requireDeviceId = () => {
|
|
45715
45822
|
if (!currentDeviceId) {
|
|
45716
45823
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed);
|
|
45717
45824
|
}
|
|
45718
45825
|
return currentDeviceId;
|
|
45719
45826
|
};
|
|
45720
|
-
const clearLegacySession = () => {
|
|
45721
|
-
const deviceId = requireDeviceId();
|
|
45722
|
-
if (legacySessionToClear &&
|
|
45723
|
-
(!legacySessionToClear.deviceId || legacySessionToClear.deviceId === deviceId)) {
|
|
45724
|
-
deviceWalletSessionStore.delete(deviceId, legacySessionToClear.passphraseState);
|
|
45725
|
-
}
|
|
45726
|
-
};
|
|
45727
45827
|
const refreshProtocolV2DeviceId = () => __awaiter(this, void 0, void 0, function* () {
|
|
45728
45828
|
const refreshedState = yield this.device.getDeviceState({ refreshSections: ['status'] });
|
|
45729
45829
|
currentDeviceId = refreshedState.identity.deviceId;
|
|
45730
|
-
clearLegacySession();
|
|
45731
45830
|
return requireDeviceId();
|
|
45732
45831
|
});
|
|
45733
|
-
if (!isProtocolV2) {
|
|
45734
|
-
clearLegacySession();
|
|
45735
|
-
}
|
|
45736
45832
|
const protocol = isProtocolV2 ? 'V2' : 'V1';
|
|
45737
45833
|
if (this.params.mode === 'standard') {
|
|
45738
45834
|
this.device.passphraseState = undefined;
|
|
@@ -46039,6 +46135,7 @@ class CheckBootloaderRelease extends BaseMethod {
|
|
|
46039
46135
|
}
|
|
46040
46136
|
}
|
|
46041
46137
|
|
|
46138
|
+
const Log$b = getLogger(exports.LoggerNames.Method);
|
|
46042
46139
|
class CheckAllFirmwareRelease extends BaseMethod {
|
|
46043
46140
|
init() {
|
|
46044
46141
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.BOOTLOADER];
|
|
@@ -46046,7 +46143,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
46046
46143
|
this.skipForceUpdateCheck = true;
|
|
46047
46144
|
}
|
|
46048
46145
|
run() {
|
|
46049
|
-
var _a, _b;
|
|
46146
|
+
var _a, _b, _c;
|
|
46050
46147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46051
46148
|
const { features } = this.device;
|
|
46052
46149
|
const { checkBridgeRelease, firmwareType: firmwareTypeParams, platform, } = this.payload;
|
|
@@ -46085,7 +46182,12 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
46085
46182
|
bootloader: bootloaderRelease,
|
|
46086
46183
|
});
|
|
46087
46184
|
}
|
|
46088
|
-
catch (
|
|
46185
|
+
catch (error) {
|
|
46186
|
+
if (!(error instanceof hdShared.HardwareError) ||
|
|
46187
|
+
((_c = error.params) === null || _c === void 0 ? void 0 : _c.firmwareUpdateCode) !== 'FirmwarePlanInvalid') {
|
|
46188
|
+
throw error;
|
|
46189
|
+
}
|
|
46190
|
+
Log$b.warn('[CheckAllFirmwareRelease] Optional firmware Plan is unavailable; using the legacy release result');
|
|
46089
46191
|
firmwareUpdatePlan = undefined;
|
|
46090
46192
|
}
|
|
46091
46193
|
return {
|
|
@@ -46228,6 +46330,9 @@ function validateRequiredData(value, name) {
|
|
|
46228
46330
|
}
|
|
46229
46331
|
|
|
46230
46332
|
class DeviceChangePin extends BaseMethod {
|
|
46333
|
+
getSupportedProtocols() {
|
|
46334
|
+
return ['V1', 'V2'];
|
|
46335
|
+
}
|
|
46231
46336
|
init() {
|
|
46232
46337
|
this.unlockPolicy = 'unlock-before-run';
|
|
46233
46338
|
this.useDevicePassphraseState = false;
|
|
@@ -46278,6 +46383,9 @@ class DeviceFlags extends BaseMethod {
|
|
|
46278
46383
|
}
|
|
46279
46384
|
|
|
46280
46385
|
class DeviceRebootToBootloader extends BaseMethod {
|
|
46386
|
+
getSupportedProtocols() {
|
|
46387
|
+
return ['V1', 'V2'];
|
|
46388
|
+
}
|
|
46281
46389
|
init() {
|
|
46282
46390
|
this.useDevicePassphraseState = false;
|
|
46283
46391
|
this.skipForceUpdateCheck = true;
|
|
@@ -46308,6 +46416,9 @@ class DeviceRebootToBootloader extends BaseMethod {
|
|
|
46308
46416
|
}
|
|
46309
46417
|
|
|
46310
46418
|
class DeviceRebootToBoardloader extends BaseMethod {
|
|
46419
|
+
getSupportedProtocols() {
|
|
46420
|
+
return ['V1', 'V2'];
|
|
46421
|
+
}
|
|
46311
46422
|
init() {
|
|
46312
46423
|
this.useDevicePassphraseState = false;
|
|
46313
46424
|
this.skipForceUpdateCheck = true;
|
|
@@ -46478,6 +46589,9 @@ const settingsPageForPayload = (payload) => {
|
|
|
46478
46589
|
return undefined;
|
|
46479
46590
|
};
|
|
46480
46591
|
class DeviceSettings extends BaseMethod {
|
|
46592
|
+
getSupportedProtocols() {
|
|
46593
|
+
return ['V1', 'V2'];
|
|
46594
|
+
}
|
|
46481
46595
|
init() {
|
|
46482
46596
|
this.useDevicePassphraseState = false;
|
|
46483
46597
|
validateParams(this.payload, [
|
|
@@ -46805,6 +46919,9 @@ class DeviceUploadResource extends BaseMethod {
|
|
|
46805
46919
|
}
|
|
46806
46920
|
|
|
46807
46921
|
class DeviceSupportFeatures extends BaseMethod {
|
|
46922
|
+
getSupportedProtocols() {
|
|
46923
|
+
return ['V1', 'V2'];
|
|
46924
|
+
}
|
|
46808
46925
|
init() {
|
|
46809
46926
|
this.useDevicePassphraseState = false;
|
|
46810
46927
|
this.skipForceUpdateCheck = true;
|
|
@@ -46855,6 +46972,9 @@ class DeviceVerify extends BaseMethod {
|
|
|
46855
46972
|
}
|
|
46856
46973
|
|
|
46857
46974
|
class DeviceWipe extends BaseMethod {
|
|
46975
|
+
getSupportedProtocols() {
|
|
46976
|
+
return ['V1', 'V2'];
|
|
46977
|
+
}
|
|
46858
46978
|
init() {
|
|
46859
46979
|
this.unlockPolicy = 'unlock-before-run';
|
|
46860
46980
|
this.useDevicePassphraseState = false;
|
|
@@ -47998,6 +48118,9 @@ class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod {
|
|
|
47998
48118
|
}
|
|
47999
48119
|
|
|
48000
48120
|
class DeviceLock extends BaseMethod {
|
|
48121
|
+
getSupportedProtocols() {
|
|
48122
|
+
return ['V1', 'V2'];
|
|
48123
|
+
}
|
|
48001
48124
|
init() {
|
|
48002
48125
|
this.useDevicePassphraseState = false;
|
|
48003
48126
|
this.unlockPolicy = 'none';
|
|
@@ -48010,6 +48133,9 @@ class DeviceLock extends BaseMethod {
|
|
|
48010
48133
|
}
|
|
48011
48134
|
|
|
48012
48135
|
class DeviceUnlock extends BaseMethod {
|
|
48136
|
+
getSupportedProtocols() {
|
|
48137
|
+
return ['V1', 'V2'];
|
|
48138
|
+
}
|
|
48013
48139
|
init() {
|
|
48014
48140
|
this.useDevicePassphraseState = false;
|
|
48015
48141
|
this.unlockPolicy = 'none';
|
|
@@ -48030,6 +48156,9 @@ class DeviceUnlock extends BaseMethod {
|
|
|
48030
48156
|
}
|
|
48031
48157
|
|
|
48032
48158
|
class DeviceCancel extends BaseMethod {
|
|
48159
|
+
getSupportedProtocols() {
|
|
48160
|
+
return ['V1', 'V2'];
|
|
48161
|
+
}
|
|
48033
48162
|
init() {
|
|
48034
48163
|
this.useDevicePassphraseState = false;
|
|
48035
48164
|
this.unlockPolicy = 'none';
|
|
@@ -48148,9 +48277,6 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
48148
48277
|
const { device, params } = this;
|
|
48149
48278
|
const { features, commands } = device;
|
|
48150
48279
|
const deviceType = device.getCurrentDeviceType();
|
|
48151
|
-
if (device.isProtocolV2()) {
|
|
48152
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 firmware update must use firmwareUpdateV4');
|
|
48153
|
-
}
|
|
48154
48280
|
if (!device.isBootloader() && features) {
|
|
48155
48281
|
const serialNo = device.getCurrentSerialNo();
|
|
48156
48282
|
if (isEnteredManuallyBoot(features, params.updateType)) {
|
|
@@ -48759,9 +48885,6 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
48759
48885
|
}
|
|
48760
48886
|
run() {
|
|
48761
48887
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48762
|
-
if (this.device.isProtocolV2()) {
|
|
48763
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 firmware update must use firmwareUpdateV4');
|
|
48764
|
-
}
|
|
48765
48888
|
Log$6.debug('FirmwareUpdateV3 strategy: Protocol V1');
|
|
48766
48889
|
return this.runProtocolV1();
|
|
48767
48890
|
});
|
|
@@ -49582,7 +49705,7 @@ const parseProtocolV2OkppHeader = (bytes) => {
|
|
|
49582
49705
|
};
|
|
49583
49706
|
const assertProtocolV2ReconnectIdentity = (expectedSerialNumber, actualSerialNumber) => {
|
|
49584
49707
|
if (!expectedSerialNumber || !actualSerialNumber) {
|
|
49585
|
-
|
|
49708
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 reconnect physical identity is unavailable');
|
|
49586
49709
|
}
|
|
49587
49710
|
if (actualSerialNumber !== expectedSerialNumber) {
|
|
49588
49711
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, `Protocol V2 reconnect physical identity mismatch: expected ${expectedSerialNumber}, received ${actualSerialNumber}`);
|
|
@@ -49594,6 +49717,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49594
49717
|
this.protocolV2PreparedSources = [];
|
|
49595
49718
|
this.protocolV2ExecutionInLoader = false;
|
|
49596
49719
|
this.protocolV2CompletedTargetVersions = new Map();
|
|
49720
|
+
this.protocolV2FinalStatusVerified = false;
|
|
49721
|
+
}
|
|
49722
|
+
getSupportedProtocols() {
|
|
49723
|
+
return ['V2'];
|
|
49597
49724
|
}
|
|
49598
49725
|
init() {
|
|
49599
49726
|
var _a, _b, _c;
|
|
@@ -49697,13 +49824,18 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49697
49824
|
resourceBundleArtifacts: payload.resourceBundleArtifacts,
|
|
49698
49825
|
};
|
|
49699
49826
|
}
|
|
49700
|
-
getProtocolV2FirmwareChunkSize() {
|
|
49827
|
+
getProtocolV2FirmwareChunkSize(direction = 'write') {
|
|
49701
49828
|
var _a, _b;
|
|
49702
49829
|
const payloadChunkSize = Number((_a = this.params) === null || _a === void 0 ? void 0 : _a.chunkSize);
|
|
49703
49830
|
const env = DataManager.getSettings('env');
|
|
49704
|
-
const
|
|
49705
|
-
|
|
49706
|
-
|
|
49831
|
+
const isBle = ((_b = this.params) === null || _b === void 0 ? void 0 : _b.platform) === 'native' || (env && DataManager.isBleConnect(env));
|
|
49832
|
+
let maxChunkSize = hdTransport.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
|
|
49833
|
+
if (isBle) {
|
|
49834
|
+
maxChunkSize =
|
|
49835
|
+
direction === 'read'
|
|
49836
|
+
? hdTransport.PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE
|
|
49837
|
+
: hdTransport.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
|
|
49838
|
+
}
|
|
49707
49839
|
if (!Number.isFinite(payloadChunkSize) || payloadChunkSize <= 0) {
|
|
49708
49840
|
return maxChunkSize;
|
|
49709
49841
|
}
|
|
@@ -49711,9 +49843,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49711
49843
|
}
|
|
49712
49844
|
run() {
|
|
49713
49845
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49714
|
-
if (!this.device.isProtocolV2()) {
|
|
49715
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'firmwareUpdateV4 requires a Protocol V2 device');
|
|
49716
|
-
}
|
|
49717
49846
|
Log$5.debug('FirmwareUpdateV4 strategy: Protocol V2');
|
|
49718
49847
|
return this.runProtocolV2();
|
|
49719
49848
|
});
|
|
@@ -49943,7 +50072,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49943
50072
|
? visibleVersions[target]
|
|
49944
50073
|
: `${Math.floor(statusVersion / 0x10000) % 0x100}.${Math.floor(statusVersion / 0x100) % 0x100}.${statusVersion % 0x100}`;
|
|
49945
50074
|
if (!observedVersion) {
|
|
49946
|
-
|
|
50075
|
+
if (this.protocolV2FinalStatusVerified) {
|
|
50076
|
+
Log$5.warn(`Protocol V2 target ${target} has no observable final version; completed target status is authoritative`);
|
|
50077
|
+
}
|
|
50078
|
+
else {
|
|
50079
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, `Protocol V2 target ${target} has no observable final version after status fallback`);
|
|
50080
|
+
}
|
|
49947
50081
|
}
|
|
49948
50082
|
else if (observedVersion !== expectedVersion) {
|
|
49949
50083
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, `Protocol V2 target ${target} reached ${observedVersion}, expected ${expectedVersion}`);
|
|
@@ -50008,7 +50142,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
50008
50142
|
});
|
|
50009
50143
|
}
|
|
50010
50144
|
captureProtocolV2PhysicalIdentity() {
|
|
50011
|
-
var _a, _b;
|
|
50145
|
+
var _a, _b, _c;
|
|
50012
50146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50013
50147
|
const deviceInfo = yield this.requestProtocolV2PhysicalIdentity();
|
|
50014
50148
|
const serialNumber = this.getProtocolV2SerialNumber(deviceInfo);
|
|
@@ -50018,8 +50152,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
50018
50152
|
deviceIdentity: serialNumber,
|
|
50019
50153
|
});
|
|
50020
50154
|
}
|
|
50155
|
+
else if ((_b = this.params) === null || _b === void 0 ? void 0 : _b.expectedDeviceId) {
|
|
50156
|
+
assertProtocolV2ReconnectIdentity((_c = this.params) === null || _c === void 0 ? void 0 : _c.expectedDeviceId, serialNumber);
|
|
50157
|
+
}
|
|
50021
50158
|
else {
|
|
50022
|
-
assertProtocolV2ReconnectIdentity(
|
|
50159
|
+
assertProtocolV2ReconnectIdentity(serialNumber, serialNumber);
|
|
50023
50160
|
}
|
|
50024
50161
|
this.protocolV2ExpectedSerialNumber = serialNumber;
|
|
50025
50162
|
});
|
|
@@ -50104,7 +50241,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
50104
50241
|
fileSize < PROTOCOL_V2_OKPP_HEADER_SIZE) {
|
|
50105
50242
|
return null;
|
|
50106
50243
|
}
|
|
50107
|
-
const chunkSize = this.getProtocolV2FirmwareChunkSize();
|
|
50244
|
+
const chunkSize = this.getProtocolV2FirmwareChunkSize('read');
|
|
50108
50245
|
const chunks = [];
|
|
50109
50246
|
let offset = 0;
|
|
50110
50247
|
while (offset < PROTOCOL_V2_OKPP_HEADER_SIZE) {
|
|
@@ -50625,6 +50762,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
50625
50762
|
waitForProtocolV2FirmwareUpdateComplete(targets) {
|
|
50626
50763
|
var _a, _b;
|
|
50627
50764
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50765
|
+
this.protocolV2FinalStatusVerified = false;
|
|
50628
50766
|
const expectedTargetIds = new Set(targets.map(target => target.target_id));
|
|
50629
50767
|
const expectedPaths = new Map(targets.map(target => [target.target_id, target.path]));
|
|
50630
50768
|
const startTime = Date.now();
|
|
@@ -50642,6 +50780,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
50642
50780
|
},
|
|
50643
50781
|
}, { timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT });
|
|
50644
50782
|
if (this.assertProtocolV2TargetStatus(((_a = statusResponse.message.records) !== null && _a !== void 0 ? _a : []), expectedTargetIds, expectedPaths)) {
|
|
50783
|
+
this.protocolV2FinalStatusVerified = true;
|
|
50645
50784
|
return;
|
|
50646
50785
|
}
|
|
50647
50786
|
lastError = new Error('Protocol V2 firmware targets are still installing');
|
|
@@ -50950,8 +51089,10 @@ class PromptWebDeviceAccess extends BaseMethod {
|
|
|
50950
51089
|
}
|
|
50951
51090
|
|
|
50952
51091
|
class DeviceReboot extends BaseMethod {
|
|
51092
|
+
getSupportedProtocols() {
|
|
51093
|
+
return ['V2'];
|
|
51094
|
+
}
|
|
50953
51095
|
init() {
|
|
50954
|
-
this.requireProtocolV2 = true;
|
|
50955
51096
|
this.skipForceUpdateCheck = true;
|
|
50956
51097
|
this.useDevicePassphraseState = false;
|
|
50957
51098
|
this.params = {
|
|
@@ -50973,8 +51114,10 @@ class DeviceReboot extends BaseMethod {
|
|
|
50973
51114
|
}
|
|
50974
51115
|
|
|
50975
51116
|
class DeviceGetOnboardingStatus extends BaseMethod {
|
|
51117
|
+
getSupportedProtocols() {
|
|
51118
|
+
return ['V2'];
|
|
51119
|
+
}
|
|
50976
51120
|
init() {
|
|
50977
|
-
this.requireProtocolV2 = true;
|
|
50978
51121
|
this.skipForceUpdateCheck = true;
|
|
50979
51122
|
this.useDevicePassphraseState = false;
|
|
50980
51123
|
}
|
|
@@ -51133,6 +51276,9 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
51133
51276
|
this.uploaded = false;
|
|
51134
51277
|
this.path = '';
|
|
51135
51278
|
}
|
|
51279
|
+
getSupportedProtocols() {
|
|
51280
|
+
return ['V2'];
|
|
51281
|
+
}
|
|
51136
51282
|
init() {
|
|
51137
51283
|
const { width, height, rgba, fileName, chunkSize } = this.payload;
|
|
51138
51284
|
if (width !== PRO2_WALLPAPER_WIDTH || height !== PRO2_WALLPAPER_HEIGHT) {
|
|
@@ -51150,7 +51296,6 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
51150
51296
|
this.encoded = encodePro2Wallpaper({ width, height, rgba: rgbaBytes });
|
|
51151
51297
|
this.path = `${WALLPAPER_DIRECTORY}/${normalizeFileName(fileName, this.encoded.data)}`;
|
|
51152
51298
|
this.params = { width, height, rgba: rgbaBytes, fileName, chunkSize };
|
|
51153
|
-
this.requireProtocolV2 = true;
|
|
51154
51299
|
this.unlockPolicy = 'unlock-before-run';
|
|
51155
51300
|
this.skipForceUpdateCheck = true;
|
|
51156
51301
|
this.useDevicePassphraseState = false;
|
|
@@ -51220,9 +51365,11 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
51220
51365
|
}
|
|
51221
51366
|
|
|
51222
51367
|
class FileWrite extends BaseMethod {
|
|
51368
|
+
getSupportedProtocols() {
|
|
51369
|
+
return ['V2'];
|
|
51370
|
+
}
|
|
51223
51371
|
init() {
|
|
51224
51372
|
var _a, _b, _c;
|
|
51225
|
-
this.requireProtocolV2 = true;
|
|
51226
51373
|
this.skipForceUpdateCheck = true;
|
|
51227
51374
|
this.useDevicePassphraseState = false;
|
|
51228
51375
|
validateRequiredData(this.payload.data, 'data');
|
|
@@ -51295,6 +51442,9 @@ class CipherKeyValue extends BaseMethod {
|
|
|
51295
51442
|
super(...arguments);
|
|
51296
51443
|
this.hasBundle = false;
|
|
51297
51444
|
}
|
|
51445
|
+
getSupportedProtocols() {
|
|
51446
|
+
return ['V1', 'V2'];
|
|
51447
|
+
}
|
|
51298
51448
|
init() {
|
|
51299
51449
|
var _a;
|
|
51300
51450
|
this.checkDeviceId = true;
|
|
@@ -51533,6 +51683,9 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
51533
51683
|
super(...arguments);
|
|
51534
51684
|
this.abortController = null;
|
|
51535
51685
|
}
|
|
51686
|
+
getSupportedProtocols() {
|
|
51687
|
+
return ['V1', 'V2'];
|
|
51688
|
+
}
|
|
51536
51689
|
init() {
|
|
51537
51690
|
var _a, _b;
|
|
51538
51691
|
this.checkDeviceId = true;
|
|
@@ -51676,11 +51829,9 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
51676
51829
|
}
|
|
51677
51830
|
function preCheckDeviceSupport(device, method) {
|
|
51678
51831
|
var _a;
|
|
51832
|
+
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
51679
51833
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
51680
51834
|
const currentVersion = (_a = device.getCurrentFirmwareVersionString()) !== null && _a !== void 0 ? _a : '0.0.0';
|
|
51681
|
-
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
51682
|
-
throw hdShared.ERRORS.createDeviceNotSupportMethodError(method.name, device.getCurrentFirmwareType());
|
|
51683
|
-
}
|
|
51684
51835
|
if (versionRange &&
|
|
51685
51836
|
semver__default["default"].valid(versionRange.min) &&
|
|
51686
51837
|
semver__default["default"].lt(currentVersion, versionRange.min)) {
|
|
@@ -51711,10 +51862,6 @@ function handleSkippableHardwareError(e, device, method) {
|
|
|
51711
51862
|
((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage'))) {
|
|
51712
51863
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
51713
51864
|
const currentVersion = (_c = device.getCurrentFirmwareVersionString()) !== null && _c !== void 0 ? _c : '0.0.0';
|
|
51714
|
-
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
51715
|
-
error = hdShared.ERRORS.createDeviceNotSupportMethodError(method.name, device.getCurrentFirmwareType());
|
|
51716
|
-
return error;
|
|
51717
|
-
}
|
|
51718
51865
|
if (versionRange &&
|
|
51719
51866
|
semver__default["default"].valid(versionRange.min) &&
|
|
51720
51867
|
semver__default["default"].lt(currentVersion, versionRange.min)) {
|
|
@@ -52158,10 +52305,6 @@ function isCoinNameInList(coinName, coinNames) {
|
|
|
52158
52305
|
function getBitcoinForkVersionRange(params) {
|
|
52159
52306
|
if (isCoinNameInList('Neurai', params)) {
|
|
52160
52307
|
return {
|
|
52161
|
-
pro2: {
|
|
52162
|
-
min: '0.0.0',
|
|
52163
|
-
unsupported: true,
|
|
52164
|
-
},
|
|
52165
52308
|
model_mini: {
|
|
52166
52309
|
min: '3.7.0',
|
|
52167
52310
|
},
|
|
@@ -52172,12 +52315,19 @@ function getBitcoinForkVersionRange(params) {
|
|
|
52172
52315
|
}
|
|
52173
52316
|
return {};
|
|
52174
52317
|
}
|
|
52318
|
+
function getBitcoinForkSupportedProtocols(params) {
|
|
52319
|
+
return isCoinNameInList('Neurai', params) ? ['V1'] : ['V1', 'V2'];
|
|
52320
|
+
}
|
|
52175
52321
|
|
|
52176
52322
|
class BTCGetAddress extends BaseMethod {
|
|
52177
52323
|
constructor() {
|
|
52178
52324
|
super(...arguments);
|
|
52179
52325
|
this.hasBundle = false;
|
|
52180
52326
|
}
|
|
52327
|
+
getSupportedProtocols() {
|
|
52328
|
+
var _a, _b;
|
|
52329
|
+
return getBitcoinForkSupportedProtocols((_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.map(param => param.coin_name)) !== null && _b !== void 0 ? _b : []);
|
|
52330
|
+
}
|
|
52181
52331
|
init() {
|
|
52182
52332
|
this.checkDeviceId = true;
|
|
52183
52333
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -52414,6 +52564,10 @@ class BTCGetPublicKey extends BaseMethod {
|
|
|
52414
52564
|
super(...arguments);
|
|
52415
52565
|
this.hasBundle = false;
|
|
52416
52566
|
}
|
|
52567
|
+
getSupportedProtocols() {
|
|
52568
|
+
var _a, _b;
|
|
52569
|
+
return getBitcoinForkSupportedProtocols((_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.map(param => param.coin_name)) !== null && _b !== void 0 ? _b : []);
|
|
52570
|
+
}
|
|
52417
52571
|
init() {
|
|
52418
52572
|
this.checkDeviceId = true;
|
|
52419
52573
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -52533,6 +52687,10 @@ class BTCGetPublicKey extends BaseMethod {
|
|
|
52533
52687
|
}
|
|
52534
52688
|
|
|
52535
52689
|
class BTCSignMessage extends BaseMethod {
|
|
52690
|
+
getSupportedProtocols() {
|
|
52691
|
+
var _a;
|
|
52692
|
+
return getBitcoinForkSupportedProtocols([(_a = this.params) === null || _a === void 0 ? void 0 : _a.coin_name]);
|
|
52693
|
+
}
|
|
52536
52694
|
init() {
|
|
52537
52695
|
this.checkDeviceId = true;
|
|
52538
52696
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -52590,6 +52748,9 @@ class BTCSignMessage extends BaseMethod {
|
|
|
52590
52748
|
}
|
|
52591
52749
|
|
|
52592
52750
|
class BTCSignPsbt extends BaseMethod {
|
|
52751
|
+
getSupportedProtocols() {
|
|
52752
|
+
return ['V1', 'V2'];
|
|
52753
|
+
}
|
|
52593
52754
|
init() {
|
|
52594
52755
|
this.checkDeviceId = true;
|
|
52595
52756
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -52909,6 +53070,10 @@ var signtxLegacy = (typedCall, inputs, outputs, refTxsArray, options, coinName)
|
|
|
52909
53070
|
});
|
|
52910
53071
|
|
|
52911
53072
|
class BTCSignTransaction extends BaseMethod {
|
|
53073
|
+
getSupportedProtocols() {
|
|
53074
|
+
var _a;
|
|
53075
|
+
return getBitcoinForkSupportedProtocols([(_a = this.params) === null || _a === void 0 ? void 0 : _a.coinName]);
|
|
53076
|
+
}
|
|
52912
53077
|
init() {
|
|
52913
53078
|
this.checkDeviceId = true;
|
|
52914
53079
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -53004,6 +53169,10 @@ class BTCSignTransaction extends BaseMethod {
|
|
|
53004
53169
|
}
|
|
53005
53170
|
|
|
53006
53171
|
class BTCVerifyMessage extends BaseMethod {
|
|
53172
|
+
getSupportedProtocols() {
|
|
53173
|
+
var _a;
|
|
53174
|
+
return getBitcoinForkSupportedProtocols([(_a = this.params) === null || _a === void 0 ? void 0 : _a.coin_name]);
|
|
53175
|
+
}
|
|
53007
53176
|
init() {
|
|
53008
53177
|
this.checkDeviceId = true;
|
|
53009
53178
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -53040,6 +53209,9 @@ class ConfluxGetAddress extends BaseMethod {
|
|
|
53040
53209
|
this.checkDeviceId = true;
|
|
53041
53210
|
this.hasBundle = false;
|
|
53042
53211
|
}
|
|
53212
|
+
getSupportedProtocols() {
|
|
53213
|
+
return ['V1', 'V2'];
|
|
53214
|
+
}
|
|
53043
53215
|
init() {
|
|
53044
53216
|
var _a;
|
|
53045
53217
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -53096,6 +53268,9 @@ class ConfluxSignMessage extends BaseMethod {
|
|
|
53096
53268
|
super(...arguments);
|
|
53097
53269
|
this.checkDeviceId = true;
|
|
53098
53270
|
}
|
|
53271
|
+
getSupportedProtocols() {
|
|
53272
|
+
return ['V1', 'V2'];
|
|
53273
|
+
}
|
|
53099
53274
|
init() {
|
|
53100
53275
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
53101
53276
|
this.allowUsePreInitialize = true;
|
|
@@ -53130,6 +53305,9 @@ class ConfluxSignMessageCIP23 extends BaseMethod {
|
|
|
53130
53305
|
super(...arguments);
|
|
53131
53306
|
this.checkDeviceId = true;
|
|
53132
53307
|
}
|
|
53308
|
+
getSupportedProtocols() {
|
|
53309
|
+
return ['V1', 'V2'];
|
|
53310
|
+
}
|
|
53133
53311
|
init() {
|
|
53134
53312
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
53135
53313
|
this.allowUsePreInitialize = true;
|
|
@@ -53217,6 +53395,9 @@ class ConfluxSignTransaction extends BaseMethod {
|
|
|
53217
53395
|
return this.processTxRequest(response.message, rest);
|
|
53218
53396
|
});
|
|
53219
53397
|
}
|
|
53398
|
+
getSupportedProtocols() {
|
|
53399
|
+
return ['V1', 'V2'];
|
|
53400
|
+
}
|
|
53220
53401
|
init() {
|
|
53221
53402
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
53222
53403
|
this.allowUsePreInitialize = true;
|
|
@@ -53228,7 +53409,7 @@ class ConfluxSignTransaction extends BaseMethod {
|
|
|
53228
53409
|
this.addressN = validatePath(path, 3);
|
|
53229
53410
|
const tx = transaction;
|
|
53230
53411
|
const schema = [
|
|
53231
|
-
{ name: 'to', type: '
|
|
53412
|
+
{ name: 'to', type: 'hexString', required: true },
|
|
53232
53413
|
{ name: 'value', type: 'hexString', required: true },
|
|
53233
53414
|
{ name: 'gasLimit', type: 'hexString', required: true },
|
|
53234
53415
|
{ name: 'gasPrice', type: 'hexString', required: true },
|
|
@@ -53239,7 +53420,7 @@ class ConfluxSignTransaction extends BaseMethod {
|
|
|
53239
53420
|
{ name: 'data', type: 'hexString' },
|
|
53240
53421
|
];
|
|
53241
53422
|
validateParams(tx, schema);
|
|
53242
|
-
this.formattedTx =
|
|
53423
|
+
this.formattedTx = formatAnyHex(tx);
|
|
53243
53424
|
}
|
|
53244
53425
|
getVersionRange() {
|
|
53245
53426
|
return {
|
|
@@ -53282,6 +53463,9 @@ class EvmGetAddress extends BaseMethod {
|
|
|
53282
53463
|
super(...arguments);
|
|
53283
53464
|
this.hasBundle = false;
|
|
53284
53465
|
}
|
|
53466
|
+
getSupportedProtocols() {
|
|
53467
|
+
return ['V1', 'V2'];
|
|
53468
|
+
}
|
|
53285
53469
|
init() {
|
|
53286
53470
|
var _a;
|
|
53287
53471
|
this.checkDeviceId = true;
|
|
@@ -53369,6 +53553,9 @@ class EVMGetPublicKey extends BaseMethod {
|
|
|
53369
53553
|
this.confirmShowOnOneKey = false;
|
|
53370
53554
|
this.useBatch = false;
|
|
53371
53555
|
}
|
|
53556
|
+
getSupportedProtocols() {
|
|
53557
|
+
return ['V1', 'V2'];
|
|
53558
|
+
}
|
|
53372
53559
|
init() {
|
|
53373
53560
|
var _a, _b, _c;
|
|
53374
53561
|
this.checkDeviceId = true;
|
|
@@ -53462,6 +53649,9 @@ function signMessageLegacyV1 ({ typedCall, params, }) {
|
|
|
53462
53649
|
}
|
|
53463
53650
|
|
|
53464
53651
|
class EVMSignMessage$2 extends BaseMethod {
|
|
53652
|
+
getSupportedProtocols() {
|
|
53653
|
+
return ['V1', 'V2'];
|
|
53654
|
+
}
|
|
53465
53655
|
init() {
|
|
53466
53656
|
this.checkDeviceId = true;
|
|
53467
53657
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -53516,10 +53706,6 @@ class EVMSignMessageEIP712 extends BaseMethod {
|
|
|
53516
53706
|
}
|
|
53517
53707
|
getVersionRange() {
|
|
53518
53708
|
return {
|
|
53519
|
-
pro2: {
|
|
53520
|
-
min: '0.0.0',
|
|
53521
|
-
unsupported: true,
|
|
53522
|
-
},
|
|
53523
53709
|
model_mini: {
|
|
53524
53710
|
min: '2.1.9',
|
|
53525
53711
|
},
|
|
@@ -53530,9 +53716,7 @@ class EVMSignMessageEIP712 extends BaseMethod {
|
|
|
53530
53716
|
}
|
|
53531
53717
|
run() {
|
|
53532
53718
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53533
|
-
this.
|
|
53534
|
-
strictCheckDeviceSupport: true,
|
|
53535
|
-
});
|
|
53719
|
+
this.assertProtocolSupported(this.device.getProtocol(), this.device.getCurrentFirmwareType());
|
|
53536
53720
|
const res = yield this.device.commands.typedCall('EthereumSignMessageEIP712', 'EthereumMessageSignature', Object.assign({}, this.params));
|
|
53537
53721
|
return Promise.resolve(res.message);
|
|
53538
53722
|
});
|
|
@@ -53731,6 +53915,9 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
53731
53915
|
this.isEIP1559 = false;
|
|
53732
53916
|
this.isEIP7702 = false;
|
|
53733
53917
|
}
|
|
53918
|
+
getSupportedProtocols() {
|
|
53919
|
+
return ['V1', 'V2'];
|
|
53920
|
+
}
|
|
53734
53921
|
hasEIP7702Features(tx) {
|
|
53735
53922
|
const authList = tx.authorizationList;
|
|
53736
53923
|
return !!(authList && Array.isArray(authList) && authList.length > 0);
|
|
@@ -54014,6 +54201,9 @@ const MINI_MAX_DYNAMIC_VALUE_BYTES = 1536;
|
|
|
54014
54201
|
const MINI_MAX_ARRAY_TYPE_FIELDS = 24;
|
|
54015
54202
|
const MINI_MAX_ARRAY_ELEMENTS = 24;
|
|
54016
54203
|
class EVMSignTypedData extends BaseMethod {
|
|
54204
|
+
getSupportedProtocols() {
|
|
54205
|
+
return ['V1', 'V2'];
|
|
54206
|
+
}
|
|
54017
54207
|
init() {
|
|
54018
54208
|
this.checkDeviceId = true;
|
|
54019
54209
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -54452,6 +54642,9 @@ function verifyMessage ({ typedCall, params, }) {
|
|
|
54452
54642
|
}
|
|
54453
54643
|
|
|
54454
54644
|
class EVMSignMessage$1 extends BaseMethod {
|
|
54645
|
+
getSupportedProtocols() {
|
|
54646
|
+
return ['V1', 'V2'];
|
|
54647
|
+
}
|
|
54455
54648
|
init() {
|
|
54456
54649
|
this.checkDeviceId = true;
|
|
54457
54650
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -54490,6 +54683,9 @@ class StarcoinGetAddress extends BaseMethod {
|
|
|
54490
54683
|
super(...arguments);
|
|
54491
54684
|
this.hasBundle = false;
|
|
54492
54685
|
}
|
|
54686
|
+
getSupportedProtocols() {
|
|
54687
|
+
return ['V1', 'V2'];
|
|
54688
|
+
}
|
|
54493
54689
|
init() {
|
|
54494
54690
|
var _a;
|
|
54495
54691
|
this.checkDeviceId = true;
|
|
@@ -54538,6 +54734,9 @@ class StarcoinGetPublicKey extends BaseMethod {
|
|
|
54538
54734
|
super(...arguments);
|
|
54539
54735
|
this.hasBundle = false;
|
|
54540
54736
|
}
|
|
54737
|
+
getSupportedProtocols() {
|
|
54738
|
+
return ['V1', 'V2'];
|
|
54739
|
+
}
|
|
54541
54740
|
init() {
|
|
54542
54741
|
var _a;
|
|
54543
54742
|
this.checkDeviceId = true;
|
|
@@ -54577,6 +54776,9 @@ class StarcoinGetPublicKey extends BaseMethod {
|
|
|
54577
54776
|
}
|
|
54578
54777
|
|
|
54579
54778
|
class StarcoinSignMessage extends BaseMethod {
|
|
54779
|
+
getSupportedProtocols() {
|
|
54780
|
+
return ['V1', 'V2'];
|
|
54781
|
+
}
|
|
54580
54782
|
init() {
|
|
54581
54783
|
this.checkDeviceId = true;
|
|
54582
54784
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -54601,6 +54803,9 @@ class StarcoinSignMessage extends BaseMethod {
|
|
|
54601
54803
|
}
|
|
54602
54804
|
|
|
54603
54805
|
class StarcoinSignTransaction extends BaseMethod {
|
|
54806
|
+
getSupportedProtocols() {
|
|
54807
|
+
return ['V1', 'V2'];
|
|
54808
|
+
}
|
|
54604
54809
|
init() {
|
|
54605
54810
|
this.checkDeviceId = true;
|
|
54606
54811
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -54625,6 +54830,9 @@ class StarcoinSignTransaction extends BaseMethod {
|
|
|
54625
54830
|
}
|
|
54626
54831
|
|
|
54627
54832
|
class EVMSignMessage extends BaseMethod {
|
|
54833
|
+
getSupportedProtocols() {
|
|
54834
|
+
return ['V1', 'V2'];
|
|
54835
|
+
}
|
|
54628
54836
|
init() {
|
|
54629
54837
|
this.checkDeviceId = true;
|
|
54630
54838
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -54654,6 +54862,9 @@ class NEMGetAddress extends BaseMethod {
|
|
|
54654
54862
|
super(...arguments);
|
|
54655
54863
|
this.hasBundle = false;
|
|
54656
54864
|
}
|
|
54865
|
+
getSupportedProtocols() {
|
|
54866
|
+
return ['V1', 'V2'];
|
|
54867
|
+
}
|
|
54657
54868
|
init() {
|
|
54658
54869
|
var _a;
|
|
54659
54870
|
this.checkDeviceId = true;
|
|
@@ -54870,6 +55081,9 @@ class NEMSignTransaction extends BaseMethod {
|
|
|
54870
55081
|
return message;
|
|
54871
55082
|
};
|
|
54872
55083
|
}
|
|
55084
|
+
getSupportedProtocols() {
|
|
55085
|
+
return ['V1', 'V2'];
|
|
55086
|
+
}
|
|
54873
55087
|
init() {
|
|
54874
55088
|
this.checkDeviceId = true;
|
|
54875
55089
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -54895,6 +55109,9 @@ class SolGetAddress extends BaseMethod {
|
|
|
54895
55109
|
super(...arguments);
|
|
54896
55110
|
this.hasBundle = false;
|
|
54897
55111
|
}
|
|
55112
|
+
getSupportedProtocols() {
|
|
55113
|
+
return ['V1', 'V2'];
|
|
55114
|
+
}
|
|
54898
55115
|
init() {
|
|
54899
55116
|
var _a;
|
|
54900
55117
|
this.checkDeviceId = true;
|
|
@@ -54947,6 +55164,9 @@ class SolSignTransaction extends BaseMethod {
|
|
|
54947
55164
|
super(...arguments);
|
|
54948
55165
|
this.hasBundle = false;
|
|
54949
55166
|
}
|
|
55167
|
+
getSupportedProtocols() {
|
|
55168
|
+
return ['V1', 'V2'];
|
|
55169
|
+
}
|
|
54950
55170
|
init() {
|
|
54951
55171
|
var _a;
|
|
54952
55172
|
this.checkDeviceId = true;
|
|
@@ -55032,6 +55252,9 @@ class SolSignTransaction extends BaseMethod {
|
|
|
55032
55252
|
}
|
|
55033
55253
|
|
|
55034
55254
|
class SolSignOffchainMessage extends BaseMethod {
|
|
55255
|
+
getSupportedProtocols() {
|
|
55256
|
+
return ['V1', 'V2'];
|
|
55257
|
+
}
|
|
55035
55258
|
init() {
|
|
55036
55259
|
this.checkDeviceId = true;
|
|
55037
55260
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -55078,6 +55301,9 @@ class SolSignOffchainMessage extends BaseMethod {
|
|
|
55078
55301
|
}
|
|
55079
55302
|
|
|
55080
55303
|
class SolSignMessage extends BaseMethod {
|
|
55304
|
+
getSupportedProtocols() {
|
|
55305
|
+
return ['V1', 'V2'];
|
|
55306
|
+
}
|
|
55081
55307
|
init() {
|
|
55082
55308
|
this.checkDeviceId = true;
|
|
55083
55309
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -55150,14 +55376,6 @@ class StellarGetAddress extends BaseMethod {
|
|
|
55150
55376
|
});
|
|
55151
55377
|
});
|
|
55152
55378
|
}
|
|
55153
|
-
getVersionRange() {
|
|
55154
|
-
return {
|
|
55155
|
-
pro2: {
|
|
55156
|
-
min: '0.0.0',
|
|
55157
|
-
unsupported: true,
|
|
55158
|
-
},
|
|
55159
|
-
};
|
|
55160
|
-
}
|
|
55161
55379
|
run() {
|
|
55162
55380
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55163
55381
|
const responses = [];
|
|
@@ -55391,14 +55609,6 @@ class StellarSignTransaction extends BaseMethod {
|
|
|
55391
55609
|
}
|
|
55392
55610
|
});
|
|
55393
55611
|
}
|
|
55394
|
-
getVersionRange() {
|
|
55395
|
-
return {
|
|
55396
|
-
pro2: {
|
|
55397
|
-
min: '0.0.0',
|
|
55398
|
-
unsupported: true,
|
|
55399
|
-
},
|
|
55400
|
-
};
|
|
55401
|
-
}
|
|
55402
55612
|
init() {
|
|
55403
55613
|
this.checkDeviceId = true;
|
|
55404
55614
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -55457,6 +55667,9 @@ class TronGetAddress extends BaseMethod {
|
|
|
55457
55667
|
super(...arguments);
|
|
55458
55668
|
this.hasBundle = false;
|
|
55459
55669
|
}
|
|
55670
|
+
getSupportedProtocols() {
|
|
55671
|
+
return ['V1', 'V2'];
|
|
55672
|
+
}
|
|
55460
55673
|
init() {
|
|
55461
55674
|
var _a;
|
|
55462
55675
|
this.checkDeviceId = true;
|
|
@@ -55509,8 +55722,14 @@ class TronGetAddress extends BaseMethod {
|
|
|
55509
55722
|
}
|
|
55510
55723
|
|
|
55511
55724
|
class TronSignMessage extends BaseMethod {
|
|
55725
|
+
constructor() {
|
|
55726
|
+
super(...arguments);
|
|
55727
|
+
this.isLegacyMessageType = false;
|
|
55728
|
+
}
|
|
55729
|
+
getSupportedProtocols() {
|
|
55730
|
+
return ['V1', 'V2'];
|
|
55731
|
+
}
|
|
55512
55732
|
init() {
|
|
55513
|
-
var _a;
|
|
55514
55733
|
this.checkDeviceId = true;
|
|
55515
55734
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
55516
55735
|
this.allowUsePreInitialize = true;
|
|
@@ -55521,9 +55740,8 @@ class TronSignMessage extends BaseMethod {
|
|
|
55521
55740
|
]);
|
|
55522
55741
|
const { path, messageHex } = this.payload;
|
|
55523
55742
|
const addressN = validatePath(path, 3);
|
|
55524
|
-
|
|
55525
|
-
|
|
55526
|
-
}
|
|
55743
|
+
this.isLegacyMessageType =
|
|
55744
|
+
this.payload.messageType === 'V1' || this.payload.messageType == null;
|
|
55527
55745
|
const messageType = hdTransport.TronMessageType.V2;
|
|
55528
55746
|
this.params = {
|
|
55529
55747
|
address_n: addressN,
|
|
@@ -55559,6 +55777,9 @@ class TronSignMessage extends BaseMethod {
|
|
|
55559
55777
|
}
|
|
55560
55778
|
run() {
|
|
55561
55779
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55780
|
+
if (this.isLegacyMessageType) {
|
|
55781
|
+
throw hdShared.createDeviceNotSupportMethodError('TronSignMessage', this.device.getCurrentFirmwareType());
|
|
55782
|
+
}
|
|
55562
55783
|
this.checkFeatureVersionLimit(() => this.params.message_type === hdTransport.TronMessageType.V2, () => this.getMessageV2VersionRange(), {
|
|
55563
55784
|
strictCheckDeviceSupport: true,
|
|
55564
55785
|
});
|
|
@@ -55569,6 +55790,9 @@ class TronSignMessage extends BaseMethod {
|
|
|
55569
55790
|
}
|
|
55570
55791
|
|
|
55571
55792
|
class TronSignTransaction extends BaseMethod {
|
|
55793
|
+
getSupportedProtocols() {
|
|
55794
|
+
return ['V1', 'V2'];
|
|
55795
|
+
}
|
|
55572
55796
|
parseTx(tx, address_n) {
|
|
55573
55797
|
var _a;
|
|
55574
55798
|
const unSignTx = {
|
|
@@ -55749,6 +55973,9 @@ class NearGetAddress extends BaseMethod {
|
|
|
55749
55973
|
super(...arguments);
|
|
55750
55974
|
this.hasBundle = false;
|
|
55751
55975
|
}
|
|
55976
|
+
getSupportedProtocols() {
|
|
55977
|
+
return ['V1', 'V2'];
|
|
55978
|
+
}
|
|
55752
55979
|
init() {
|
|
55753
55980
|
var _a;
|
|
55754
55981
|
this.checkDeviceId = true;
|
|
@@ -55801,6 +56028,9 @@ class NearGetAddress extends BaseMethod {
|
|
|
55801
56028
|
}
|
|
55802
56029
|
|
|
55803
56030
|
class NearSignTransaction extends BaseMethod {
|
|
56031
|
+
getSupportedProtocols() {
|
|
56032
|
+
return ['V1', 'V2'];
|
|
56033
|
+
}
|
|
55804
56034
|
init() {
|
|
55805
56035
|
this.checkDeviceId = true;
|
|
55806
56036
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -55837,6 +56067,9 @@ class AptosGetAddress extends BaseMethod {
|
|
|
55837
56067
|
this.hasBundle = false;
|
|
55838
56068
|
this.shouldConfirm = false;
|
|
55839
56069
|
}
|
|
56070
|
+
getSupportedProtocols() {
|
|
56071
|
+
return ['V1', 'V2'];
|
|
56072
|
+
}
|
|
55840
56073
|
init() {
|
|
55841
56074
|
var _a, _b;
|
|
55842
56075
|
this.checkDeviceId = true;
|
|
@@ -55932,6 +56165,9 @@ class AptosGetPublicKey extends BaseMethod {
|
|
|
55932
56165
|
super(...arguments);
|
|
55933
56166
|
this.hasBundle = false;
|
|
55934
56167
|
}
|
|
56168
|
+
getSupportedProtocols() {
|
|
56169
|
+
return ['V1', 'V2'];
|
|
56170
|
+
}
|
|
55935
56171
|
init() {
|
|
55936
56172
|
var _a;
|
|
55937
56173
|
this.checkDeviceId = true;
|
|
@@ -55978,6 +56214,9 @@ class AptosGetPublicKey extends BaseMethod {
|
|
|
55978
56214
|
}
|
|
55979
56215
|
|
|
55980
56216
|
class AptosSignTransaction extends BaseMethod {
|
|
56217
|
+
getSupportedProtocols() {
|
|
56218
|
+
return ['V1', 'V2'];
|
|
56219
|
+
}
|
|
55981
56220
|
init() {
|
|
55982
56221
|
this.checkDeviceId = true;
|
|
55983
56222
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -56029,6 +56268,9 @@ class AptosSignTransaction extends BaseMethod {
|
|
|
56029
56268
|
}
|
|
56030
56269
|
|
|
56031
56270
|
class AptosSignMessage extends BaseMethod {
|
|
56271
|
+
getSupportedProtocols() {
|
|
56272
|
+
return ['V1', 'V2'];
|
|
56273
|
+
}
|
|
56032
56274
|
init() {
|
|
56033
56275
|
this.checkDeviceId = true;
|
|
56034
56276
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -56091,6 +56333,9 @@ class AptosSignMessage extends BaseMethod {
|
|
|
56091
56333
|
}
|
|
56092
56334
|
|
|
56093
56335
|
class AptosSignInMessage extends BaseMethod {
|
|
56336
|
+
getSupportedProtocols() {
|
|
56337
|
+
return ['V1', 'V2'];
|
|
56338
|
+
}
|
|
56094
56339
|
init() {
|
|
56095
56340
|
this.checkDeviceId = true;
|
|
56096
56341
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -56131,6 +56376,9 @@ class AlgoGetAddress extends BaseMethod {
|
|
|
56131
56376
|
super(...arguments);
|
|
56132
56377
|
this.hasBundle = false;
|
|
56133
56378
|
}
|
|
56379
|
+
getSupportedProtocols() {
|
|
56380
|
+
return ['V1', 'V2'];
|
|
56381
|
+
}
|
|
56134
56382
|
init() {
|
|
56135
56383
|
var _a;
|
|
56136
56384
|
this.checkDeviceId = true;
|
|
@@ -56187,6 +56435,9 @@ class AlgoSignTransaction extends BaseMethod {
|
|
|
56187
56435
|
super(...arguments);
|
|
56188
56436
|
this.hasBundle = false;
|
|
56189
56437
|
}
|
|
56438
|
+
getSupportedProtocols() {
|
|
56439
|
+
return ['V1', 'V2'];
|
|
56440
|
+
}
|
|
56190
56441
|
init() {
|
|
56191
56442
|
this.checkDeviceId = true;
|
|
56192
56443
|
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
@@ -56226,6 +56477,9 @@ class CosmosGetAddress extends BaseMethod {
|
|
|
56226
56477
|
super(...arguments);
|
|
56227
56478
|
this.hasBundle = false;
|
|
56228
56479
|
}
|
|
56480
|
+
getSupportedProtocols() {
|
|
56481
|
+
return ['V1', 'V2'];
|
|
56482
|
+
}
|
|
56229
56483
|
init() {
|
|
56230
56484
|
var _a;
|
|
56231
56485
|
this.checkDeviceId = true;
|
|
@@ -56288,6 +56542,9 @@ class CosmosGetPublicKey extends BaseMethod {
|
|
|
56288
56542
|
super(...arguments);
|
|
56289
56543
|
this.hasBundle = false;
|
|
56290
56544
|
}
|
|
56545
|
+
getSupportedProtocols() {
|
|
56546
|
+
return ['V1', 'V2'];
|
|
56547
|
+
}
|
|
56291
56548
|
init() {
|
|
56292
56549
|
var _a;
|
|
56293
56550
|
this.checkDeviceId = true;
|
|
@@ -56350,6 +56607,9 @@ class CosmosSignTransaction extends BaseMethod {
|
|
|
56350
56607
|
super(...arguments);
|
|
56351
56608
|
this.hasBundle = false;
|
|
56352
56609
|
}
|
|
56610
|
+
getSupportedProtocols() {
|
|
56611
|
+
return ['V1', 'V2'];
|
|
56612
|
+
}
|
|
56353
56613
|
init() {
|
|
56354
56614
|
this.checkDeviceId = true;
|
|
56355
56615
|
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
@@ -56403,6 +56663,9 @@ class XrpGetAddress$1 extends BaseMethod {
|
|
|
56403
56663
|
this.hasBundle = false;
|
|
56404
56664
|
this.shouldConfirm = false;
|
|
56405
56665
|
}
|
|
56666
|
+
getSupportedProtocols() {
|
|
56667
|
+
return ['V1', 'V2'];
|
|
56668
|
+
}
|
|
56406
56669
|
init() {
|
|
56407
56670
|
var _a;
|
|
56408
56671
|
this.checkDeviceId = true;
|
|
@@ -56472,6 +56735,9 @@ class XrpGetAddress extends BaseMethod {
|
|
|
56472
56735
|
super(...arguments);
|
|
56473
56736
|
this.hasBundle = false;
|
|
56474
56737
|
}
|
|
56738
|
+
getSupportedProtocols() {
|
|
56739
|
+
return ['V1', 'V2'];
|
|
56740
|
+
}
|
|
56475
56741
|
init() {
|
|
56476
56742
|
this.checkDeviceId = true;
|
|
56477
56743
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -56491,7 +56757,7 @@ class XrpGetAddress extends BaseMethod {
|
|
|
56491
56757
|
{ name: 'payment', type: 'object' },
|
|
56492
56758
|
]);
|
|
56493
56759
|
validateParams(transaction.payment, [
|
|
56494
|
-
{ name: 'amount', type: '
|
|
56760
|
+
{ name: 'amount', type: 'number', required: true },
|
|
56495
56761
|
{ name: 'destination', type: 'string', required: true },
|
|
56496
56762
|
{ name: 'destinationTag', type: 'number' },
|
|
56497
56763
|
]);
|
|
@@ -56552,6 +56818,9 @@ class SuiGetAddress extends BaseMethod {
|
|
|
56552
56818
|
this.hasBundle = false;
|
|
56553
56819
|
this.shouldConfirm = false;
|
|
56554
56820
|
}
|
|
56821
|
+
getSupportedProtocols() {
|
|
56822
|
+
return ['V1', 'V2'];
|
|
56823
|
+
}
|
|
56555
56824
|
init() {
|
|
56556
56825
|
var _a, _b;
|
|
56557
56826
|
this.checkDeviceId = true;
|
|
@@ -56647,6 +56916,9 @@ class SuiGetPublicKey extends BaseMethod {
|
|
|
56647
56916
|
super(...arguments);
|
|
56648
56917
|
this.hasBundle = false;
|
|
56649
56918
|
}
|
|
56919
|
+
getSupportedProtocols() {
|
|
56920
|
+
return ['V1', 'V2'];
|
|
56921
|
+
}
|
|
56650
56922
|
init() {
|
|
56651
56923
|
var _a;
|
|
56652
56924
|
this.checkDeviceId = true;
|
|
@@ -56699,6 +56971,9 @@ class SuiGetPublicKey extends BaseMethod {
|
|
|
56699
56971
|
}
|
|
56700
56972
|
|
|
56701
56973
|
class SuiSignMessage extends BaseMethod {
|
|
56974
|
+
getSupportedProtocols() {
|
|
56975
|
+
return ['V1', 'V2'];
|
|
56976
|
+
}
|
|
56702
56977
|
init() {
|
|
56703
56978
|
this.checkDeviceId = true;
|
|
56704
56979
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -56756,6 +57031,9 @@ class SuiSignTransaction extends BaseMethod {
|
|
|
56756
57031
|
return this.processTxRequest(typedCall, response, data, newOffset);
|
|
56757
57032
|
});
|
|
56758
57033
|
}
|
|
57034
|
+
getSupportedProtocols() {
|
|
57035
|
+
return ['V1', 'V2'];
|
|
57036
|
+
}
|
|
56759
57037
|
init() {
|
|
56760
57038
|
this.checkDeviceId = true;
|
|
56761
57039
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -56906,6 +57184,9 @@ const modifyAddressParametersForBackwardsCompatibility = (address_parameters) =>
|
|
|
56906
57184
|
};
|
|
56907
57185
|
|
|
56908
57186
|
class CardanoGetAddress extends BaseMethod {
|
|
57187
|
+
getSupportedProtocols() {
|
|
57188
|
+
return ['V1', 'V2'];
|
|
57189
|
+
}
|
|
56909
57190
|
init() {
|
|
56910
57191
|
var _a, _b, _c;
|
|
56911
57192
|
this.checkDeviceId = true;
|
|
@@ -57006,6 +57287,9 @@ class CardanoGetAddress extends BaseMethod {
|
|
|
57006
57287
|
}
|
|
57007
57288
|
|
|
57008
57289
|
class CardanoGetPublicKey extends BaseMethod {
|
|
57290
|
+
getSupportedProtocols() {
|
|
57291
|
+
return ['V1', 'V2'];
|
|
57292
|
+
}
|
|
57009
57293
|
init() {
|
|
57010
57294
|
var _a;
|
|
57011
57295
|
this.checkDeviceId = true;
|
|
@@ -57551,6 +57835,9 @@ class CardanoSignTransaction extends BaseMethod {
|
|
|
57551
57835
|
}
|
|
57552
57836
|
};
|
|
57553
57837
|
}
|
|
57838
|
+
getSupportedProtocols() {
|
|
57839
|
+
return ['V1', 'V2'];
|
|
57840
|
+
}
|
|
57554
57841
|
getVersionRange() {
|
|
57555
57842
|
return {
|
|
57556
57843
|
model_mini: {
|
|
@@ -57798,6 +58085,9 @@ class CardanoSignTransaction extends BaseMethod {
|
|
|
57798
58085
|
}
|
|
57799
58086
|
|
|
57800
58087
|
class CardanoSignMessage extends BaseMethod {
|
|
58088
|
+
getSupportedProtocols() {
|
|
58089
|
+
return ['V1', 'V2'];
|
|
58090
|
+
}
|
|
57801
58091
|
init() {
|
|
57802
58092
|
this.checkDeviceId = true;
|
|
57803
58093
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -57851,6 +58141,9 @@ class FilecoinGetAddress extends BaseMethod {
|
|
|
57851
58141
|
super(...arguments);
|
|
57852
58142
|
this.hasBundle = false;
|
|
57853
58143
|
}
|
|
58144
|
+
getSupportedProtocols() {
|
|
58145
|
+
return ['V1', 'V2'];
|
|
58146
|
+
}
|
|
57854
58147
|
init() {
|
|
57855
58148
|
var _a;
|
|
57856
58149
|
this.checkDeviceId = true;
|
|
@@ -57912,6 +58205,9 @@ class FilecoinSignTransaction extends BaseMethod {
|
|
|
57912
58205
|
super(...arguments);
|
|
57913
58206
|
this.hasBundle = false;
|
|
57914
58207
|
}
|
|
58208
|
+
getSupportedProtocols() {
|
|
58209
|
+
return ['V1', 'V2'];
|
|
58210
|
+
}
|
|
57915
58211
|
init() {
|
|
57916
58212
|
this.checkDeviceId = true;
|
|
57917
58213
|
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
@@ -58029,6 +58325,9 @@ class PolkadotGetAddress extends BaseMethod {
|
|
|
58029
58325
|
super(...arguments);
|
|
58030
58326
|
this.hasBundle = false;
|
|
58031
58327
|
}
|
|
58328
|
+
getSupportedProtocols() {
|
|
58329
|
+
return ['V1', 'V2'];
|
|
58330
|
+
}
|
|
58032
58331
|
init() {
|
|
58033
58332
|
var _a;
|
|
58034
58333
|
this.checkDeviceId = true;
|
|
@@ -58092,6 +58391,9 @@ class PolkadotSignTransaction extends BaseMethod {
|
|
|
58092
58391
|
super(...arguments);
|
|
58093
58392
|
this.hasBundle = false;
|
|
58094
58393
|
}
|
|
58394
|
+
getSupportedProtocols() {
|
|
58395
|
+
return ['V1', 'V2'];
|
|
58396
|
+
}
|
|
58095
58397
|
init() {
|
|
58096
58398
|
this.checkDeviceId = true;
|
|
58097
58399
|
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
@@ -58131,6 +58433,9 @@ class KaspaGetAddress extends BaseMethod {
|
|
|
58131
58433
|
super(...arguments);
|
|
58132
58434
|
this.hasBundle = false;
|
|
58133
58435
|
}
|
|
58436
|
+
getSupportedProtocols() {
|
|
58437
|
+
return ['V1', 'V2'];
|
|
58438
|
+
}
|
|
58134
58439
|
init() {
|
|
58135
58440
|
var _a;
|
|
58136
58441
|
this.checkDeviceId = true;
|
|
@@ -58517,6 +58822,8 @@ function serialize(transaction, inputNumber) {
|
|
|
58517
58822
|
|
|
58518
58823
|
const P2PK_SCRIPT = /^(20[0-9a-f]{64}ac|21[0-9a-f]{66}ab)$/i;
|
|
58519
58824
|
const isStreamableScript = (script) => !script || P2PK_SCRIPT.test(script);
|
|
58825
|
+
const getOutputAddress = (output) => 'address' in output ? output.address : undefined;
|
|
58826
|
+
const getOutputAddressN = (output) => 'addressN' in output ? output.addressN : undefined;
|
|
58520
58827
|
class KaspaSignTransaction extends BaseMethod {
|
|
58521
58828
|
constructor() {
|
|
58522
58829
|
super(...arguments);
|
|
@@ -58524,15 +58831,25 @@ class KaspaSignTransaction extends BaseMethod {
|
|
|
58524
58831
|
this.supportsLegacy = false;
|
|
58525
58832
|
this.supportsStreaming = false;
|
|
58526
58833
|
}
|
|
58834
|
+
getSupportedProtocols() {
|
|
58835
|
+
return ['V1', 'V2'];
|
|
58836
|
+
}
|
|
58527
58837
|
init() {
|
|
58528
58838
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
58529
58839
|
this.checkDeviceId = true;
|
|
58530
58840
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
58531
58841
|
this.allowUsePreInitialize = true;
|
|
58532
58842
|
const payload = this.payload;
|
|
58843
|
+
const payloadInputs = Array.isArray(payload.inputs) ? payload.inputs : [];
|
|
58844
|
+
const payloadOutputs = Array.isArray(payload.outputs) ? payload.outputs : [];
|
|
58845
|
+
const usesStreamingParams = payload.refTxs !== undefined ||
|
|
58846
|
+
payload.payload !== undefined ||
|
|
58847
|
+
payload.gas !== undefined ||
|
|
58848
|
+
payloadInputs.some(input => { var _a; return !((_a = input.output) === null || _a === void 0 ? void 0 : _a.script); }) ||
|
|
58849
|
+
payloadOutputs.some(output => !!getOutputAddress(output) || !!getOutputAddressN(output));
|
|
58533
58850
|
validateParams(payload, [
|
|
58534
58851
|
{ name: 'version', type: 'number' },
|
|
58535
|
-
{ name: 'sigHashType', type: 'number' },
|
|
58852
|
+
{ name: 'sigHashType', type: 'number', required: !usesStreamingParams },
|
|
58536
58853
|
{ name: 'inputs', type: 'array', required: true },
|
|
58537
58854
|
{ name: 'outputs', type: 'array', required: true },
|
|
58538
58855
|
{ name: 'lockTime', required: true },
|
|
@@ -58565,13 +58882,14 @@ class KaspaSignTransaction extends BaseMethod {
|
|
|
58565
58882
|
});
|
|
58566
58883
|
const outputs = payload.outputs.map(output => {
|
|
58567
58884
|
var _a;
|
|
58885
|
+
const addressN = getOutputAddressN(output);
|
|
58568
58886
|
validateParams(output, [
|
|
58569
58887
|
{ name: 'satoshis', required: true },
|
|
58570
58888
|
{ name: 'address', type: 'string' },
|
|
58571
|
-
{ name: 'script', type: 'string' },
|
|
58889
|
+
{ name: 'script', type: 'string', required: !usesStreamingParams },
|
|
58572
58890
|
{ name: 'scriptVersion', type: 'number' },
|
|
58573
58891
|
]);
|
|
58574
|
-
return Object.assign(Object.assign({}, output), { addressN:
|
|
58892
|
+
return Object.assign(Object.assign({}, output), { addressN: addressN ? validatePath(addressN, 3) : undefined, scriptVersion: (_a = output.scriptVersion) !== null && _a !== void 0 ? _a : 0 });
|
|
58575
58893
|
});
|
|
58576
58894
|
this.params = Object.assign(Object.assign({}, payload), { inputs,
|
|
58577
58895
|
outputs, scheme: (_b = payload.scheme) !== null && _b !== void 0 ? _b : 'schnorr', prefix: (_c = payload.prefix) !== null && _c !== void 0 ? _c : 'kaspa', sigHashType: (_d = payload.sigHashType) !== null && _d !== void 0 ? _d : SignatureType.SIGHASH_ALL | SignatureType.SIGHASH_FORKID, sigOpCount: (_e = payload.sigOpCount) !== null && _e !== void 0 ? _e : 1, subNetworkID: (_f = payload.subNetworkID) !== null && _f !== void 0 ? _f : utils.bytesToHex(zeroSubnetworkID()), gas: (_g = payload.gas) !== null && _g !== void 0 ? _g : 0, useTweak: payload.useTweak });
|
|
@@ -58585,7 +58903,7 @@ class KaspaSignTransaction extends BaseMethod {
|
|
|
58585
58903
|
this.params.sigHashType === (SignatureType.SIGHASH_ALL | SignatureType.SIGHASH_FORKID);
|
|
58586
58904
|
this.supportsStreaming =
|
|
58587
58905
|
isDefaultSigHashType &&
|
|
58588
|
-
this.params.outputs.every(output => !!output
|
|
58906
|
+
this.params.outputs.every(output => !!getOutputAddress(output) || !!getOutputAddressN(output)) &&
|
|
58589
58907
|
this.params.inputs.every(input => isStreamableScript(input.output.script)) &&
|
|
58590
58908
|
this.params.outputs.every(output => isStreamableScript(output.script));
|
|
58591
58909
|
if (!this.supportsLegacy && !this.supportsStreaming) {
|
|
@@ -58745,12 +59063,14 @@ class KaspaSignTransaction extends BaseMethod {
|
|
|
58745
59063
|
if (!output) {
|
|
58746
59064
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `KaspaSignTransaction: device requested output ${requestIndex} out of range`);
|
|
58747
59065
|
}
|
|
58748
|
-
const
|
|
59066
|
+
const address = getOutputAddress(output);
|
|
59067
|
+
const addressN = getOutputAddressN(output);
|
|
59068
|
+
const isChange = !!addressN;
|
|
58749
59069
|
response = yield typedCall('KaspaTxAckOutput', 'KaspaTxRequest', {
|
|
58750
59070
|
script_type: isChange ? 'KASPA_PAYTOCHANGE' : 'KASPA_PAYTOADDRESS',
|
|
58751
59071
|
amount: output.satoshis,
|
|
58752
|
-
address_n: (_d =
|
|
58753
|
-
address
|
|
59072
|
+
address_n: (_d = addressN) !== null && _d !== void 0 ? _d : [],
|
|
59073
|
+
address,
|
|
58754
59074
|
scheme: params.scheme,
|
|
58755
59075
|
use_tweak: params.useTweak,
|
|
58756
59076
|
});
|
|
@@ -58867,10 +59187,6 @@ class NexaGetAddress extends BaseMethod {
|
|
|
58867
59187
|
}
|
|
58868
59188
|
getVersionRange() {
|
|
58869
59189
|
return {
|
|
58870
|
-
pro2: {
|
|
58871
|
-
min: '0.0.0',
|
|
58872
|
-
unsupported: true,
|
|
58873
|
-
},
|
|
58874
59190
|
model_mini: {
|
|
58875
59191
|
min: '3.2.0',
|
|
58876
59192
|
},
|
|
@@ -58923,10 +59239,6 @@ class NexaSignTransaction extends BaseMethod {
|
|
|
58923
59239
|
}
|
|
58924
59240
|
getVersionRange() {
|
|
58925
59241
|
return {
|
|
58926
|
-
pro2: {
|
|
58927
|
-
min: '0.0.0',
|
|
58928
|
-
unsupported: true,
|
|
58929
|
-
},
|
|
58930
59242
|
model_mini: {
|
|
58931
59243
|
min: '3.2.0',
|
|
58932
59244
|
},
|
|
@@ -58984,6 +59296,9 @@ class NostrGetPublicKey extends BaseMethod {
|
|
|
58984
59296
|
super(...arguments);
|
|
58985
59297
|
this.hasBundle = false;
|
|
58986
59298
|
}
|
|
59299
|
+
getSupportedProtocols() {
|
|
59300
|
+
return ['V1', 'V2'];
|
|
59301
|
+
}
|
|
58987
59302
|
init() {
|
|
58988
59303
|
this.checkDeviceId = true;
|
|
58989
59304
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -59062,6 +59377,9 @@ class NostrSignEvent extends BaseMethod {
|
|
|
59062
59377
|
super(...arguments);
|
|
59063
59378
|
this.hasBundle = false;
|
|
59064
59379
|
}
|
|
59380
|
+
getSupportedProtocols() {
|
|
59381
|
+
return ['V1', 'V2'];
|
|
59382
|
+
}
|
|
59065
59383
|
init() {
|
|
59066
59384
|
this.checkDeviceId = true;
|
|
59067
59385
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -59111,6 +59429,9 @@ class NostrEncryptMessage extends BaseMethod {
|
|
|
59111
59429
|
super(...arguments);
|
|
59112
59430
|
this.hasBundle = false;
|
|
59113
59431
|
}
|
|
59432
|
+
getSupportedProtocols() {
|
|
59433
|
+
return ['V1', 'V2'];
|
|
59434
|
+
}
|
|
59114
59435
|
init() {
|
|
59115
59436
|
var _a;
|
|
59116
59437
|
this.checkDeviceId = true;
|
|
@@ -59158,6 +59479,9 @@ class NostrDecryptMessage extends BaseMethod {
|
|
|
59158
59479
|
super(...arguments);
|
|
59159
59480
|
this.hasBundle = false;
|
|
59160
59481
|
}
|
|
59482
|
+
getSupportedProtocols() {
|
|
59483
|
+
return ['V1', 'V2'];
|
|
59484
|
+
}
|
|
59161
59485
|
init() {
|
|
59162
59486
|
var _a;
|
|
59163
59487
|
this.checkDeviceId = true;
|
|
@@ -59205,6 +59529,9 @@ class NostrSignSchnorr extends BaseMethod {
|
|
|
59205
59529
|
super(...arguments);
|
|
59206
59530
|
this.hasBundle = false;
|
|
59207
59531
|
}
|
|
59532
|
+
getSupportedProtocols() {
|
|
59533
|
+
return ['V1', 'V2'];
|
|
59534
|
+
}
|
|
59208
59535
|
init() {
|
|
59209
59536
|
this.checkDeviceId = true;
|
|
59210
59537
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -59268,10 +59595,6 @@ class LnurlAuth1 extends BaseMethod {
|
|
|
59268
59595
|
model_touch: {
|
|
59269
59596
|
min: '4.8.0',
|
|
59270
59597
|
},
|
|
59271
|
-
pro2: {
|
|
59272
|
-
min: '0.0.0',
|
|
59273
|
-
unsupported: true,
|
|
59274
|
-
},
|
|
59275
59598
|
};
|
|
59276
59599
|
}
|
|
59277
59600
|
run() {
|
|
@@ -59314,10 +59637,6 @@ class NervosGetAddress extends BaseMethod {
|
|
|
59314
59637
|
}
|
|
59315
59638
|
getVersionRange() {
|
|
59316
59639
|
return {
|
|
59317
|
-
pro2: {
|
|
59318
|
-
min: '0.0.0',
|
|
59319
|
-
unsupported: true,
|
|
59320
|
-
},
|
|
59321
59640
|
model_mini: {
|
|
59322
59641
|
min: '3.7.0',
|
|
59323
59642
|
},
|
|
@@ -59398,10 +59717,6 @@ class NervosSignTransaction extends BaseMethod {
|
|
|
59398
59717
|
}
|
|
59399
59718
|
getVersionRange() {
|
|
59400
59719
|
return {
|
|
59401
|
-
pro2: {
|
|
59402
|
-
min: '0.0.0',
|
|
59403
|
-
unsupported: true,
|
|
59404
|
-
},
|
|
59405
59720
|
model_mini: {
|
|
59406
59721
|
min: '3.7.0',
|
|
59407
59722
|
},
|
|
@@ -59464,9 +59779,6 @@ class DnxGetAddress extends BaseMethod {
|
|
|
59464
59779
|
}
|
|
59465
59780
|
run() {
|
|
59466
59781
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59467
|
-
if (this.device.isProtocolV2()) {
|
|
59468
|
-
throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
59469
|
-
}
|
|
59470
59782
|
const responses = [];
|
|
59471
59783
|
for (let i = 0; i < this.params.length; i++) {
|
|
59472
59784
|
const param = this.params[i];
|
|
@@ -59572,9 +59884,6 @@ class DnxSignTransaction extends BaseMethod {
|
|
|
59572
59884
|
}
|
|
59573
59885
|
run() {
|
|
59574
59886
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59575
|
-
if (this.device.isProtocolV2()) {
|
|
59576
|
-
throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
59577
|
-
}
|
|
59578
59887
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
59579
59888
|
const res = yield this.device.commands.typedCall('DnxSignTx', 'DnxInputRequest', Object.assign({}, this.params));
|
|
59580
59889
|
return this.processTxRequest(typedCall, res, {});
|
|
@@ -59588,6 +59897,9 @@ class TonGetAddress extends BaseMethod {
|
|
|
59588
59897
|
this.hasBundle = false;
|
|
59589
59898
|
this.shouldConfirm = false;
|
|
59590
59899
|
}
|
|
59900
|
+
getSupportedProtocols() {
|
|
59901
|
+
return ['V1', 'V2'];
|
|
59902
|
+
}
|
|
59591
59903
|
init() {
|
|
59592
59904
|
var _a;
|
|
59593
59905
|
this.strictCheckDeviceSupport = true;
|
|
@@ -59679,6 +59991,9 @@ class TonSignMessage extends BaseMethod {
|
|
|
59679
59991
|
return this.processTxRequest(response.message, rest);
|
|
59680
59992
|
});
|
|
59681
59993
|
}
|
|
59994
|
+
getSupportedProtocols() {
|
|
59995
|
+
return ['V1', 'V2'];
|
|
59996
|
+
}
|
|
59682
59997
|
init() {
|
|
59683
59998
|
this.strictCheckDeviceSupport = true;
|
|
59684
59999
|
this.checkDeviceId = true;
|
|
@@ -59827,6 +60142,9 @@ class TonSignMessage extends BaseMethod {
|
|
|
59827
60142
|
}
|
|
59828
60143
|
|
|
59829
60144
|
class TonSignProof extends BaseMethod {
|
|
60145
|
+
getSupportedProtocols() {
|
|
60146
|
+
return ['V1', 'V2'];
|
|
60147
|
+
}
|
|
59830
60148
|
init() {
|
|
59831
60149
|
this.strictCheckDeviceSupport = true;
|
|
59832
60150
|
this.checkDeviceId = true;
|
|
@@ -59879,6 +60197,9 @@ class TonSignProof extends BaseMethod {
|
|
|
59879
60197
|
}
|
|
59880
60198
|
|
|
59881
60199
|
class TonSignData extends BaseMethod {
|
|
60200
|
+
getSupportedProtocols() {
|
|
60201
|
+
return ['V1', 'V2'];
|
|
60202
|
+
}
|
|
59882
60203
|
init() {
|
|
59883
60204
|
this.strictCheckDeviceSupport = false;
|
|
59884
60205
|
this.checkDeviceId = true;
|
|
@@ -59955,10 +60276,6 @@ class ScdoGetAddress extends BaseMethod {
|
|
|
59955
60276
|
}
|
|
59956
60277
|
getVersionRange() {
|
|
59957
60278
|
return {
|
|
59958
|
-
pro2: {
|
|
59959
|
-
min: '0.0.0',
|
|
59960
|
-
unsupported: true,
|
|
59961
|
-
},
|
|
59962
60279
|
model_touch: {
|
|
59963
60280
|
min: '4.10.0',
|
|
59964
60281
|
},
|
|
@@ -60035,10 +60352,6 @@ class ScdoSignTransaction extends BaseMethod {
|
|
|
60035
60352
|
}
|
|
60036
60353
|
getVersionRange() {
|
|
60037
60354
|
return {
|
|
60038
|
-
pro2: {
|
|
60039
|
-
min: '0.0.0',
|
|
60040
|
-
unsupported: true,
|
|
60041
|
-
},
|
|
60042
60355
|
model_touch: {
|
|
60043
60356
|
min: '4.10.0',
|
|
60044
60357
|
},
|
|
@@ -60079,10 +60392,6 @@ class ScdoSignMessage extends BaseMethod {
|
|
|
60079
60392
|
}
|
|
60080
60393
|
getVersionRange() {
|
|
60081
60394
|
return {
|
|
60082
|
-
pro2: {
|
|
60083
|
-
min: '0.0.0',
|
|
60084
|
-
unsupported: true,
|
|
60085
|
-
},
|
|
60086
60395
|
model_touch: {
|
|
60087
60396
|
min: '4.10.0',
|
|
60088
60397
|
},
|
|
@@ -60124,10 +60433,6 @@ class AlephiumGetAddress extends BaseMethod {
|
|
|
60124
60433
|
}
|
|
60125
60434
|
getVersionRange() {
|
|
60126
60435
|
return {
|
|
60127
|
-
pro2: {
|
|
60128
|
-
min: '0.0.0',
|
|
60129
|
-
unsupported: true,
|
|
60130
|
-
},
|
|
60131
60436
|
model_touch: {
|
|
60132
60437
|
min: '4.10.0',
|
|
60133
60438
|
},
|
|
@@ -60213,10 +60518,6 @@ class AlephiumSignTransaction extends BaseMethod {
|
|
|
60213
60518
|
}
|
|
60214
60519
|
getVersionRange() {
|
|
60215
60520
|
return {
|
|
60216
|
-
pro2: {
|
|
60217
|
-
min: '0.0.0',
|
|
60218
|
-
unsupported: true,
|
|
60219
|
-
},
|
|
60220
60521
|
model_touch: {
|
|
60221
60522
|
min: '4.10.0',
|
|
60222
60523
|
},
|
|
@@ -60259,10 +60560,6 @@ class AlephiumSignMessage extends BaseMethod {
|
|
|
60259
60560
|
}
|
|
60260
60561
|
getVersionRange() {
|
|
60261
60562
|
return {
|
|
60262
|
-
pro2: {
|
|
60263
|
-
min: '0.0.0',
|
|
60264
|
-
unsupported: true,
|
|
60265
|
-
},
|
|
60266
60563
|
model_touch: {
|
|
60267
60564
|
min: '4.10.0',
|
|
60268
60565
|
},
|
|
@@ -60304,6 +60601,12 @@ function hex2BfcAddress(hexAddress) {
|
|
|
60304
60601
|
return `BFC${hex}${checksumHex}`;
|
|
60305
60602
|
}
|
|
60306
60603
|
|
|
60604
|
+
const requireAddress = (address) => {
|
|
60605
|
+
if (address == null) {
|
|
60606
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodError, "Field 'address' is null");
|
|
60607
|
+
}
|
|
60608
|
+
return address;
|
|
60609
|
+
};
|
|
60307
60610
|
class BenfenGetAddress extends BaseMethod {
|
|
60308
60611
|
constructor() {
|
|
60309
60612
|
super(...arguments);
|
|
@@ -60338,10 +60641,6 @@ class BenfenGetAddress extends BaseMethod {
|
|
|
60338
60641
|
}
|
|
60339
60642
|
getVersionRange() {
|
|
60340
60643
|
return {
|
|
60341
|
-
pro2: {
|
|
60342
|
-
min: '0.0.0',
|
|
60343
|
-
unsupported: true,
|
|
60344
|
-
},
|
|
60345
60644
|
pro: {
|
|
60346
60645
|
min: '4.12.0',
|
|
60347
60646
|
},
|
|
@@ -60351,7 +60650,6 @@ class BenfenGetAddress extends BaseMethod {
|
|
|
60351
60650
|
};
|
|
60352
60651
|
}
|
|
60353
60652
|
run() {
|
|
60354
|
-
var _a;
|
|
60355
60653
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60356
60654
|
const supportsBatchPublicKey = supportBatchPublicKeyByDevice(this.device);
|
|
60357
60655
|
let responses = [];
|
|
@@ -60363,7 +60661,7 @@ class BenfenGetAddress extends BaseMethod {
|
|
|
60363
60661
|
let address;
|
|
60364
60662
|
if (this.shouldConfirm) {
|
|
60365
60663
|
const addressRes = yield this.device.commands.typedCall('BenfenGetAddress', 'BenfenAddress', param);
|
|
60366
|
-
address = (
|
|
60664
|
+
address = requireAddress(addressRes.message.address);
|
|
60367
60665
|
}
|
|
60368
60666
|
else {
|
|
60369
60667
|
address = publicKeyToAddress(publicKey);
|
|
@@ -60381,11 +60679,10 @@ class BenfenGetAddress extends BaseMethod {
|
|
|
60381
60679
|
}
|
|
60382
60680
|
else {
|
|
60383
60681
|
responses = yield Promise.all(this.params.map((param) => __awaiter(this, void 0, void 0, function* () {
|
|
60384
|
-
var _b;
|
|
60385
60682
|
const res = yield this.device.commands.typedCall('BenfenGetAddress', 'BenfenAddress', param);
|
|
60386
60683
|
const result = {
|
|
60387
60684
|
path: serializedPath(param.address_n),
|
|
60388
|
-
address: hex2BfcAddress((
|
|
60685
|
+
address: hex2BfcAddress(requireAddress(res.message.address)),
|
|
60389
60686
|
};
|
|
60390
60687
|
if (this.shouldConfirm) {
|
|
60391
60688
|
this.postPreviousAddressMessage(result);
|
|
@@ -60431,10 +60728,6 @@ class BenfenGetPublicKey extends BaseMethod {
|
|
|
60431
60728
|
}
|
|
60432
60729
|
getVersionRange() {
|
|
60433
60730
|
return {
|
|
60434
|
-
pro2: {
|
|
60435
|
-
min: '0.0.0',
|
|
60436
|
-
unsupported: true,
|
|
60437
|
-
},
|
|
60438
60731
|
pro: {
|
|
60439
60732
|
min: '4.12.0',
|
|
60440
60733
|
},
|
|
@@ -60476,10 +60769,6 @@ class BenfenSignMessage extends BaseMethod {
|
|
|
60476
60769
|
}
|
|
60477
60770
|
getVersionRange() {
|
|
60478
60771
|
return {
|
|
60479
|
-
pro2: {
|
|
60480
|
-
min: '0.0.0',
|
|
60481
|
-
unsupported: true,
|
|
60482
|
-
},
|
|
60483
60772
|
pro: {
|
|
60484
60773
|
min: '4.12.0',
|
|
60485
60774
|
},
|
|
@@ -60534,10 +60823,6 @@ class BenfenSignTransaction extends BaseMethod {
|
|
|
60534
60823
|
}
|
|
60535
60824
|
getVersionRange() {
|
|
60536
60825
|
return {
|
|
60537
|
-
pro2: {
|
|
60538
|
-
min: '0.0.0',
|
|
60539
|
-
unsupported: true,
|
|
60540
|
-
},
|
|
60541
60826
|
pro: {
|
|
60542
60827
|
min: '4.12.0',
|
|
60543
60828
|
},
|
|
@@ -60594,10 +60879,6 @@ class NeoGetAddress extends BaseMethod {
|
|
|
60594
60879
|
}
|
|
60595
60880
|
getVersionRange() {
|
|
60596
60881
|
return {
|
|
60597
|
-
pro2: {
|
|
60598
|
-
min: '0.0.0',
|
|
60599
|
-
unsupported: true,
|
|
60600
|
-
},
|
|
60601
60882
|
pro: {
|
|
60602
60883
|
min: '4.12.0',
|
|
60603
60884
|
},
|
|
@@ -60653,10 +60934,6 @@ class NeoSignTransaction extends BaseMethod {
|
|
|
60653
60934
|
}
|
|
60654
60935
|
getVersionRange() {
|
|
60655
60936
|
return {
|
|
60656
|
-
pro2: {
|
|
60657
|
-
min: '0.0.0',
|
|
60658
|
-
unsupported: true,
|
|
60659
|
-
},
|
|
60660
60937
|
pro: {
|
|
60661
60938
|
min: '4.12.0',
|
|
60662
60939
|
},
|
|
@@ -60685,6 +60962,7 @@ class NeoSignTransaction extends BaseMethod {
|
|
|
60685
60962
|
var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
60686
60963
|
__proto__: null,
|
|
60687
60964
|
testInitializeDeviceDuration: TestInitializeDeviceDuration,
|
|
60965
|
+
testProtocolV2Ping: Ping,
|
|
60688
60966
|
preInitialize: PreInitialize,
|
|
60689
60967
|
searchDevices: SearchDevices,
|
|
60690
60968
|
getFeatures: GetFeatures,
|
|
@@ -61230,7 +61508,7 @@ class ProtocolV2UiInteractionCoordinator {
|
|
|
61230
61508
|
|
|
61231
61509
|
const Log$1 = getLogger(exports.LoggerNames.Core);
|
|
61232
61510
|
function runMethodWithUnlockRetry(method, device, uiCoordinator) {
|
|
61233
|
-
var _a;
|
|
61511
|
+
var _a, _b, _c, _d;
|
|
61234
61512
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61235
61513
|
const shouldEmitUi = isProtocolV2UiEnabled(method);
|
|
61236
61514
|
const shouldUnlockBeforeRun = device.isProtocolV2() && method.unlockPolicy !== 'none' && ((_a = device.features) === null || _a === void 0 ? void 0 : _a.unlocked) === false;
|
|
@@ -61263,6 +61541,15 @@ function runMethodWithUnlockRetry(method, device, uiCoordinator) {
|
|
|
61263
61541
|
}
|
|
61264
61542
|
yield device.unlockDevice();
|
|
61265
61543
|
Log$1.debug('Protocol V2 unlock completed', { method: method.name });
|
|
61544
|
+
const expectedPassphraseState = ((_b = method.payload) === null || _b === void 0 ? void 0 : _b.useEmptyPassphrase)
|
|
61545
|
+
? undefined
|
|
61546
|
+
: (_d = (_c = method.payload) === null || _c === void 0 ? void 0 : _c.passphraseState) !== null && _d !== void 0 ? _d : device.passphraseState;
|
|
61547
|
+
if (method.useDevicePassphraseState &&
|
|
61548
|
+
typeof expectedPassphraseState === 'string' &&
|
|
61549
|
+
expectedPassphraseState.length > 0) {
|
|
61550
|
+
yield restoreProtocolV2WalletSession(device, expectedPassphraseState);
|
|
61551
|
+
Log$1.debug('Protocol V2 wallet session restored after unlock', { method: method.name });
|
|
61552
|
+
}
|
|
61266
61553
|
if (shouldEmitUi) {
|
|
61267
61554
|
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.resumeMethodInteraction();
|
|
61268
61555
|
}
|
|
@@ -61360,7 +61647,6 @@ const callAPI = (context, message) => __awaiter(void 0, void 0, void 0, function
|
|
|
61360
61647
|
}
|
|
61361
61648
|
return createResponseMessage((_b = method === null || method === void 0 ? void 0 : method.responseID) !== null && _b !== void 0 ? _b : message.id, false, { error });
|
|
61362
61649
|
}
|
|
61363
|
-
DevicePool.emitter.on(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
61364
61650
|
if (!method.useDevice) {
|
|
61365
61651
|
updateMethodRequestContext(method, { status: 'running' });
|
|
61366
61652
|
try {
|
|
@@ -61394,7 +61680,6 @@ const callAPI = (context, message) => __awaiter(void 0, void 0, void 0, function
|
|
|
61394
61680
|
});
|
|
61395
61681
|
const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61396
61682
|
const createAckResponse = () => {
|
|
61397
|
-
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
61398
61683
|
completeMethodRequestContext(method);
|
|
61399
61684
|
method.dispose();
|
|
61400
61685
|
return createResponseMessage(method.responseID, true, true);
|
|
@@ -61531,9 +61816,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
61531
61816
|
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
61532
61817
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61533
61818
|
var _j, _k, _l, _m, _o, _p, _q;
|
|
61534
|
-
|
|
61535
|
-
throw hdShared.createDeviceNotSupportMethodError(method.name, device.getCurrentFirmwareType());
|
|
61536
|
-
}
|
|
61819
|
+
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
61537
61820
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
61538
61821
|
const currentFirmwareVersion = (_j = device.getCurrentFirmwareVersionString()) !== null && _j !== void 0 ? _j : '0.0.0';
|
|
61539
61822
|
const currentBleVersion = (_k = device.getCurrentBLEFirmwareVersionString()) !== null && _k !== void 0 ? _k : '0.0.0';
|
|
@@ -61565,9 +61848,6 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
61565
61848
|
throw hdShared.createNewFirmwareForceUpdateHardwareError(method.connectId, method.deviceId, requiredUpdates, currentVersions);
|
|
61566
61849
|
}
|
|
61567
61850
|
}
|
|
61568
|
-
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
61569
|
-
throw hdShared.createDeviceNotSupportMethodError(method.name, deviceFirmwareType);
|
|
61570
|
-
}
|
|
61571
61851
|
if (versionRange) {
|
|
61572
61852
|
if (semver__default["default"].valid(versionRange.min) && semver__default["default"].lt(currentFirmwareVersion, versionRange.min)) {
|
|
61573
61853
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
@@ -61821,8 +62101,14 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
61821
62101
|
var _a;
|
|
61822
62102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61823
62103
|
try {
|
|
61824
|
-
|
|
62104
|
+
const shouldAcquire = !device.hasDeviceAcquire() || !device.commands || device.commands.disposed;
|
|
62105
|
+
if (shouldAcquire) {
|
|
62106
|
+
yield device.acquire(method.payload.connectProtocol);
|
|
62107
|
+
}
|
|
61825
62108
|
if ((_a = method.payload) === null || _a === void 0 ? void 0 : _a.onlyConnectBleDevice) {
|
|
62109
|
+
if (shouldAcquire) {
|
|
62110
|
+
DevicePool.emitter.emit(DEVICE.CONNECT, device);
|
|
62111
|
+
}
|
|
61826
62112
|
return;
|
|
61827
62113
|
}
|
|
61828
62114
|
if (!canSkipInitialize(method, device)) {
|
|
@@ -61832,6 +62118,9 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
61832
62118
|
passphraseState: initOptions.passphraseState,
|
|
61833
62119
|
});
|
|
61834
62120
|
}
|
|
62121
|
+
if (shouldAcquire) {
|
|
62122
|
+
DevicePool.emitter.emit(DEVICE.CONNECT, device);
|
|
62123
|
+
}
|
|
61835
62124
|
}
|
|
61836
62125
|
catch (err) {
|
|
61837
62126
|
if ((err.errorCode === hdShared.HardwareErrorCode.BleTimeoutError ||
|
|
@@ -62069,7 +62358,6 @@ const cleanup = () => {
|
|
|
62069
62358
|
};
|
|
62070
62359
|
const removeDeviceListener = (device) => {
|
|
62071
62360
|
device.removeAllListeners();
|
|
62072
|
-
DevicePool.emitter.removeAllListeners(DEVICE.CONNECT);
|
|
62073
62361
|
};
|
|
62074
62362
|
const closePopup = () => {
|
|
62075
62363
|
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW));
|
|
@@ -62087,6 +62375,16 @@ const onDeviceDisconnectHandler = (device) => {
|
|
|
62087
62375
|
return;
|
|
62088
62376
|
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|
|
62089
62377
|
};
|
|
62378
|
+
const onTransportDeviceDisconnectHandler = (event) => {
|
|
62379
|
+
var _a, _b;
|
|
62380
|
+
const device = (_b = (_a = deviceCacheMap.get(event.connectId)) !== null && _a !== void 0 ? _a : DevicePool.devicesCache[event.connectId]) !== null && _b !== void 0 ? _b : DevicePool.getDeviceByPath(event.connectId);
|
|
62381
|
+
if (!device) {
|
|
62382
|
+
Log.debug('Ignoring transport disconnect for an unknown device:', event.connectId);
|
|
62383
|
+
return;
|
|
62384
|
+
}
|
|
62385
|
+
device.markTransportDisconnected();
|
|
62386
|
+
DevicePool.emitter.emit(DEVICE.DISCONNECT, device);
|
|
62387
|
+
};
|
|
62090
62388
|
const onDevicePinHandler = (...[device, type, callback]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62091
62389
|
Log.log('request Input PIN');
|
|
62092
62390
|
const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PIN, device);
|
|
@@ -62314,7 +62612,12 @@ const initCore = () => {
|
|
|
62314
62612
|
};
|
|
62315
62613
|
const initConnector = () => {
|
|
62316
62614
|
_connector = new DeviceConnector();
|
|
62615
|
+
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
62616
|
+
DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
62617
|
+
DevicePool.emitter.removeListener(hdTransport.TRANSPORT_EVENT.DEVICE_DISCONNECT, onTransportDeviceDisconnectHandler);
|
|
62618
|
+
DevicePool.emitter.on(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
62317
62619
|
DevicePool.emitter.on(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
62620
|
+
DevicePool.emitter.on(hdTransport.TRANSPORT_EVENT.DEVICE_DISCONNECT, onTransportDeviceDisconnectHandler);
|
|
62318
62621
|
return _connector;
|
|
62319
62622
|
};
|
|
62320
62623
|
const initTransport = (Transport, plugin) => {
|
|
@@ -62473,7 +62776,6 @@ exports.getTimeStamp = getTimeStamp;
|
|
|
62473
62776
|
exports.httpRequest = httpRequest;
|
|
62474
62777
|
exports.initCore = init;
|
|
62475
62778
|
exports.isBleConnect = isBleConnect;
|
|
62476
|
-
exports.isMethodVersionRangeUnsupported = isMethodVersionRangeUnsupported;
|
|
62477
62779
|
exports.isValidVersionArray = isValidVersionArray;
|
|
62478
62780
|
exports.isValidVersionString = isValidVersionString;
|
|
62479
62781
|
exports.normalizeSafetyCheckLevel = normalizeSafetyCheckLevel;
|