@onekeyfe/hd-core 1.1.27-alpha.4 → 1.1.27-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/protocol-v2.test.ts +1688 -0
- package/dist/api/BaseMethod.d.ts +1 -7
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/DirList.d.ts +10 -0
- package/dist/api/DirList.d.ts.map +1 -0
- package/dist/api/DirMake.d.ts +9 -0
- package/dist/api/DirMake.d.ts.map +1 -0
- package/dist/api/DirRemove.d.ts +9 -0
- package/dist/api/DirRemove.d.ts.map +1 -0
- package/dist/api/FileDelete.d.ts +9 -0
- package/dist/api/FileDelete.d.ts.map +1 -0
- package/dist/api/FileRead.d.ts +19 -0
- package/dist/api/FileRead.d.ts.map +1 -0
- package/dist/api/FileWrite.d.ts +23 -0
- package/dist/api/FileWrite.d.ts.map +1 -0
- package/dist/api/FirmwareUpdateV3.d.ts +1 -0
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +32 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -0
- package/dist/api/GetDeviceInfo.d.ts +9 -0
- package/dist/api/GetDeviceInfo.d.ts.map +1 -0
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +6 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/PathInfo.d.ts +9 -0
- package/dist/api/PathInfo.d.ts.map +1 -0
- package/dist/api/SearchDevices.d.ts +2 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumGetAddress.d.ts +2 -6
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts +2 -5
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts +2 -5
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts +2 -9
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts +2 -9
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts +2 -8
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts +2 -8
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -11
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -11
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -15
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -11
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -11
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -11
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.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/EVMSignMessage.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -8
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +10 -2
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/helpers/deviceInfo.d.ts +15 -0
- package/dist/api/helpers/deviceInfo.d.ts.map +1 -0
- package/dist/api/helpers/filesystemValidation.d.ts +7 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
- package/dist/api/index.d.ts +28 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/near/NearSignTransaction.d.ts.map +1 -1
- package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts +2 -8
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts +2 -8
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts +2 -9
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts +2 -9
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts +2 -8
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +2 -9
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/nostr/NostrSignEvent.d.ts.map +1 -1
- package/dist/api/nostr/NostrSignSchnorr.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +7 -0
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +1 -0
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +6 -0
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +10 -0
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -0
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +6 -0
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +1 -0
- package/dist/api/protocol-v2/Ping.d.ts +8 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +49 -0
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -0
- package/dist/api/scdo/ScdoGetAddress.d.ts +2 -6
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts +2 -5
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts +2 -5
- 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 +4 -0
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +4 -0
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +8 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +2 -1
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +2 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +2 -2
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +4 -0
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +4 -0
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +1 -1
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +7 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +5 -4
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +5 -18
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +8 -8
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +2 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +8 -0
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +292 -43
- package/dist/index.js +16693 -1501
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +104 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/firmware.d.ts +12 -0
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/index.d.ts +3 -0
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +7 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getDeviceInfo.d.ts +84 -0
- package/dist/types/api/getDeviceInfo.d.ts.map +1 -0
- package/dist/types/api/getPassphraseState.d.ts +10 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +33 -3
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +127 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -0
- package/dist/types/api/searchDevices.d.ts +2 -2
- package/dist/types/api/searchDevices.d.ts.map +1 -1
- package/dist/types/device.d.ts +6 -2
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +2 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +5 -3
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +1 -0
- package/dist/utils/deviceInfoUtils.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/dist/utils/versionUtils.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +7 -82
- package/src/api/DirList.ts +29 -0
- package/src/api/DirMake.ts +21 -0
- package/src/api/DirRemove.ts +21 -0
- package/src/api/FileDelete.ts +21 -0
- package/src/api/FileRead.ts +165 -0
- package/src/api/FileWrite.ts +203 -0
- package/src/api/FirmwareUpdateV3.ts +21 -4
- package/src/api/FirmwareUpdateV4.ts +810 -0
- package/src/api/GetDeviceInfo.ts +161 -0
- package/src/api/GetOnekeyFeatures.ts +75 -3
- package/src/api/GetPassphraseState.ts +16 -7
- package/src/api/PathInfo.ts +25 -0
- package/src/api/SearchDevices.ts +7 -2
- package/src/api/alephium/AlephiumGetAddress.ts +6 -2
- package/src/api/alephium/AlephiumSignMessage.ts +6 -2
- package/src/api/alephium/AlephiumSignTransaction.ts +6 -3
- package/src/api/algo/AlgoSignTransaction.ts +0 -1
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +18 -9
- package/src/api/aptos/AptosSignInMessage.ts +0 -1
- package/src/api/aptos/AptosSignMessage.ts +0 -1
- package/src/api/aptos/AptosSignTransaction.ts +0 -1
- package/src/api/benfen/BenfenGetAddress.ts +6 -2
- package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
- package/src/api/benfen/BenfenSignMessage.ts +6 -2
- package/src/api/benfen/BenfenSignTransaction.ts +6 -2
- package/src/api/btc/BTCSignMessage.ts +0 -1
- package/src/api/btc/BTCSignPsbt.ts +0 -1
- package/src/api/btc/BTCSignTransaction.ts +0 -1
- package/src/api/btc/helpers/versionLimit.ts +7 -1
- package/src/api/cardano/CardanoSignMessage.ts +0 -1
- package/src/api/cardano/CardanoSignTransaction.ts +0 -1
- package/src/api/conflux/ConfluxSignMessage.ts +0 -1
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +0 -1
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -3
- package/src/api/cosmos/CosmosSignTransaction.ts +0 -1
- package/src/api/device/DeviceRebootToBoardloader.ts +10 -1
- package/src/api/device/DeviceRebootToBootloader.ts +10 -1
- package/src/api/dynex/DnxGetAddress.ts +7 -0
- package/src/api/dynex/DnxSignTransaction.ts +7 -1
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -3
- package/src/api/evm/EVMSignMessageEIP712.ts +14 -2
- package/src/api/evm/EVMSignTransaction.ts +1 -3
- package/src/api/evm/EVMSignTypedData.ts +6 -8
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/filecoin/FilecoinSignTransaction.ts +0 -1
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +27 -4
- package/src/api/helpers/deviceInfo.ts +205 -0
- package/src/api/helpers/filesystemValidation.ts +51 -0
- package/src/api/index.ts +30 -1
- package/src/api/kaspa/KaspaSignTransaction.ts +0 -1
- package/src/api/near/NearSignTransaction.ts +0 -1
- package/src/api/nem/NEMSignTransaction.ts +0 -1
- package/src/api/neo/NeoGetAddress.ts +6 -1
- package/src/api/neo/NeoSignTransaction.ts +6 -2
- package/src/api/nervos/NervosGetAddress.ts +6 -2
- package/src/api/nervos/NervosSignTransaction.ts +6 -3
- package/src/api/nexa/NexaGetAddress.ts +6 -2
- package/src/api/nexa/NexaSignTransaction.ts +6 -4
- package/src/api/nostr/NostrSignEvent.ts +0 -1
- package/src/api/nostr/NostrSignSchnorr.ts +0 -1
- package/src/api/polkadot/PolkadotSignTransaction.ts +0 -1
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +50 -0
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +35 -0
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +18 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +18 -0
- package/src/api/protocol-v2/DeviceReboot.ts +22 -0
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +27 -0
- package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +18 -0
- package/src/api/protocol-v2/FilesystemDiskControl.ts +34 -0
- package/src/api/protocol-v2/FilesystemFixPermission.ts +14 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +14 -0
- package/src/api/protocol-v2/GetProtoVersion.ts +14 -0
- package/src/api/protocol-v2/Ping.ts +16 -0
- package/src/api/protocol-v2/helpers.ts +161 -0
- package/src/api/scdo/ScdoGetAddress.ts +6 -2
- package/src/api/scdo/ScdoSignMessage.ts +6 -2
- package/src/api/scdo/ScdoSignTransaction.ts +6 -3
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +4 -1
- package/src/api/solana/SolSignOffchainMessage.ts +4 -1
- package/src/api/solana/SolSignTransaction.ts +8 -1
- package/src/api/starcoin/StarcoinSignMessage.ts +0 -1
- package/src/api/starcoin/StarcoinSignTransaction.ts +0 -1
- package/src/api/stellar/StellarGetAddress.ts +10 -1
- package/src/api/stellar/StellarSignTransaction.ts +14 -2
- package/src/api/sui/SuiSignMessage.ts +0 -1
- package/src/api/sui/SuiSignTransaction.ts +12 -10
- package/src/api/ton/TonSignData.ts +0 -1
- package/src/api/ton/TonSignMessage.ts +0 -1
- package/src/api/ton/TonSignProof.ts +0 -1
- package/src/api/tron/TronSignMessage.ts +5 -2
- package/src/api/tron/TronSignTransaction.ts +4 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -2
- package/src/core/RequestQueue.ts +3 -10
- package/src/core/index.ts +62 -153
- package/src/data/messages/messages-protocol-v2.json +13128 -0
- package/src/data-manager/DataManager.ts +12 -7
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +38 -12
- package/src/device/Device.ts +98 -82
- package/src/device/DeviceCommands.ts +166 -26
- package/src/device/DeviceConnector.ts +29 -4
- package/src/device/DevicePool.ts +1 -1
- package/src/events/ui-request.ts +8 -0
- package/src/inject.ts +46 -2
- package/src/protocols/protocol-v2/features.ts +287 -0
- package/src/protocols/protocol-v2/firmware.ts +26 -0
- package/src/protocols/protocol-v2/index.ts +2 -0
- package/src/types/api/export.ts +1 -0
- package/src/types/api/firmwareUpdate.ts +12 -0
- package/src/types/api/getDeviceInfo.ts +97 -0
- package/src/types/api/getPassphraseState.ts +13 -2
- package/src/types/api/index.ts +80 -3
- package/src/types/api/protocolV2.ts +226 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/device.ts +33 -2
- package/src/types/params.ts +4 -2
- package/src/types/settings.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +62 -21
- package/src/utils/deviceInfoUtils.ts +15 -8
- package/src/utils/index.ts +1 -0
- package/__tests__/DeviceCommands.test.ts +0 -99
- package/__tests__/evmLedgerLegacySafety.test.ts +0 -261
- package/__tests__/preInitialize.test.ts +0 -22
- package/dist/api/device/PreInitialize.d.ts +0 -6
- package/dist/api/device/PreInitialize.d.ts.map +0 -1
- package/dist/core/PollingStateManager.d.ts +0 -8
- package/dist/core/PollingStateManager.d.ts.map +0 -1
- package/dist/types/api/preInitialize.d.ts +0 -3
- package/dist/types/api/preInitialize.d.ts.map +0 -1
- package/src/api/device/PreInitialize.ts +0 -41
- package/src/core/PollingStateManager.ts +0 -47
- package/src/types/api/preInitialize.ts +0 -3
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
|
+
|
|
4
|
+
import { UI_REQUEST } from '../constants/ui-request';
|
|
5
|
+
import {
|
|
6
|
+
PROTOCOL_V2_DEVICE_INFO_REQUEST,
|
|
7
|
+
PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST,
|
|
8
|
+
normalizeProtocolV2Features,
|
|
9
|
+
} from '../protocols/protocol-v2';
|
|
10
|
+
import { getDeviceType } from '../utils';
|
|
11
|
+
import { fixVersion } from '../utils/deviceFeaturesUtils';
|
|
12
|
+
import { buildUnifiedDeviceInfo } from './helpers/deviceInfo';
|
|
13
|
+
import { BaseMethod } from './BaseMethod';
|
|
14
|
+
|
|
15
|
+
import type {
|
|
16
|
+
DeviceInfoScope,
|
|
17
|
+
DeviceInfoSource,
|
|
18
|
+
GetDeviceInfoParams,
|
|
19
|
+
} from '../types/api/getDeviceInfo';
|
|
20
|
+
import type { Features, OnekeyFeatures } from '../types';
|
|
21
|
+
import type { ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
22
|
+
|
|
23
|
+
const DEVICE_INFO_SCOPES: readonly DeviceInfoScope[] = ['basic', 'versions', 'verify', 'full'];
|
|
24
|
+
|
|
25
|
+
function isDeviceInfoScope(scope: unknown): scope is DeviceInfoScope {
|
|
26
|
+
return typeof scope === 'string' && DEVICE_INFO_SCOPES.includes(scope as DeviceInfoScope);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function normalizeScope(scope: unknown): GetDeviceInfoParams['scope'] {
|
|
30
|
+
if (scope === undefined || scope === null) return 'basic';
|
|
31
|
+
if (isDeviceInfoScope(scope)) {
|
|
32
|
+
return scope;
|
|
33
|
+
}
|
|
34
|
+
throw ERRORS.TypedError(
|
|
35
|
+
HardwareErrorCode.CallMethodInvalidParameter,
|
|
36
|
+
`Invalid getDeviceInfo scope: ${String(scope)}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function shouldReadProtocolV2DeviceInfo(params: GetDeviceInfoParams) {
|
|
41
|
+
return (
|
|
42
|
+
params.refresh === true ||
|
|
43
|
+
params.includeRaw === true ||
|
|
44
|
+
params.scope === 'verify' ||
|
|
45
|
+
params.scope === 'full'
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getProtocolV2DeviceInfoRequest(params: GetDeviceInfoParams) {
|
|
50
|
+
if (params.scope === 'verify' || params.scope === 'full') {
|
|
51
|
+
return PROTOCOL_V2_DEVICE_INFO_REQUEST;
|
|
52
|
+
}
|
|
53
|
+
return PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function shouldReadOnekeyFeatures(params: GetDeviceInfoParams) {
|
|
57
|
+
return (
|
|
58
|
+
params.includeRaw === true ||
|
|
59
|
+
params.scope === 'versions' ||
|
|
60
|
+
params.scope === 'verify' ||
|
|
61
|
+
params.scope === 'full'
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function supportOnekeyFeatures(features?: Features) {
|
|
66
|
+
if (!features || features.bootloader_mode) return false;
|
|
67
|
+
|
|
68
|
+
const deviceType = getDeviceType(features);
|
|
69
|
+
return ![
|
|
70
|
+
EDeviceType.Unknown,
|
|
71
|
+
EDeviceType.Classic1s,
|
|
72
|
+
EDeviceType.ClassicPure,
|
|
73
|
+
EDeviceType.Pro2,
|
|
74
|
+
].includes(deviceType);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function normalizeOnekeyFeatures(message: OnekeyFeatures) {
|
|
78
|
+
if (message.onekey_firmware_version && !semver.valid(message.onekey_firmware_version)) {
|
|
79
|
+
message.onekey_firmware_version = fixVersion(message.onekey_firmware_version);
|
|
80
|
+
}
|
|
81
|
+
return message;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default class GetDeviceInfo extends BaseMethod<GetDeviceInfoParams> {
|
|
85
|
+
init() {
|
|
86
|
+
this.allowDeviceMode = [
|
|
87
|
+
...this.allowDeviceMode,
|
|
88
|
+
UI_REQUEST.NOT_INITIALIZE,
|
|
89
|
+
UI_REQUEST.BOOTLOADER,
|
|
90
|
+
];
|
|
91
|
+
this.useDevicePassphraseState = false;
|
|
92
|
+
this.skipForceUpdateCheck = true;
|
|
93
|
+
this.params = {
|
|
94
|
+
scope: normalizeScope(this.payload.scope),
|
|
95
|
+
refresh: this.payload.refresh,
|
|
96
|
+
includeRaw: this.payload.includeRaw,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async run() {
|
|
101
|
+
if (this.device.originalDescriptor?.protocolType === 'V2') {
|
|
102
|
+
return this.runProtocolV2();
|
|
103
|
+
}
|
|
104
|
+
return this.runProtocolV1();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private async runProtocolV2() {
|
|
108
|
+
const sources: DeviceInfoSource[] = ['features'];
|
|
109
|
+
let { features } = this.device;
|
|
110
|
+
let protocolV2DeviceInfo: ProtocolV2DeviceInfo | undefined;
|
|
111
|
+
|
|
112
|
+
if (shouldReadProtocolV2DeviceInfo(this.params)) {
|
|
113
|
+
const { message } = await this.device.commands.typedCall(
|
|
114
|
+
'DeviceGetDeviceInfo',
|
|
115
|
+
'DeviceInfo',
|
|
116
|
+
getProtocolV2DeviceInfoRequest(this.params)
|
|
117
|
+
);
|
|
118
|
+
protocolV2DeviceInfo = message as unknown as ProtocolV2DeviceInfo;
|
|
119
|
+
features = normalizeProtocolV2Features(this.device.originalDescriptor, protocolV2DeviceInfo);
|
|
120
|
+
this.device._updateFeatures(features);
|
|
121
|
+
sources.push('deviceGetDeviceInfo');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return buildUnifiedDeviceInfo({
|
|
125
|
+
protocol: 'V2',
|
|
126
|
+
features,
|
|
127
|
+
protocolV2DeviceInfo,
|
|
128
|
+
sources,
|
|
129
|
+
scope: this.params.scope,
|
|
130
|
+
includeRaw: this.params.includeRaw,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private async runProtocolV1() {
|
|
135
|
+
if (this.params.refresh === true) {
|
|
136
|
+
await this.device.getFeatures();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const sources: DeviceInfoSource[] = ['features'];
|
|
140
|
+
const { features } = this.device;
|
|
141
|
+
let onekeyFeatures: OnekeyFeatures | undefined;
|
|
142
|
+
|
|
143
|
+
if (shouldReadOnekeyFeatures(this.params) && supportOnekeyFeatures(features)) {
|
|
144
|
+
const { message } = await this.device.commands.typedCall(
|
|
145
|
+
'OnekeyGetFeatures',
|
|
146
|
+
'OnekeyFeatures'
|
|
147
|
+
);
|
|
148
|
+
onekeyFeatures = normalizeOnekeyFeatures(message);
|
|
149
|
+
sources.push('onekeyFeatures');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return buildUnifiedDeviceInfo({
|
|
153
|
+
protocol: 'V1',
|
|
154
|
+
features,
|
|
155
|
+
onekeyFeatures,
|
|
156
|
+
sources,
|
|
157
|
+
scope: this.params.scope,
|
|
158
|
+
includeRaw: this.params.includeRaw,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -4,6 +4,76 @@ import { UI_REQUEST } from '../constants/ui-request';
|
|
|
4
4
|
import { fixVersion } from '../utils/deviceFeaturesUtils';
|
|
5
5
|
import { BaseMethod } from './BaseMethod';
|
|
6
6
|
|
|
7
|
+
import type { OnekeyFeatures } from '../types';
|
|
8
|
+
|
|
9
|
+
const ONEKEY_FEATURE_KEYS: Array<keyof OnekeyFeatures> = [
|
|
10
|
+
'onekey_device_type',
|
|
11
|
+
'onekey_board_version',
|
|
12
|
+
'onekey_boot_version',
|
|
13
|
+
'onekey_firmware_version',
|
|
14
|
+
'onekey_board_hash',
|
|
15
|
+
'onekey_boot_hash',
|
|
16
|
+
'onekey_firmware_hash',
|
|
17
|
+
'onekey_board_build_id',
|
|
18
|
+
'onekey_boot_build_id',
|
|
19
|
+
'onekey_firmware_build_id',
|
|
20
|
+
'onekey_serial_no',
|
|
21
|
+
'onekey_ble_name',
|
|
22
|
+
'onekey_ble_version',
|
|
23
|
+
'onekey_ble_build_id',
|
|
24
|
+
'onekey_ble_hash',
|
|
25
|
+
'onekey_se_type',
|
|
26
|
+
'onekey_se01_state',
|
|
27
|
+
'onekey_se02_state',
|
|
28
|
+
'onekey_se03_state',
|
|
29
|
+
'onekey_se04_state',
|
|
30
|
+
'onekey_se01_version',
|
|
31
|
+
'onekey_se02_version',
|
|
32
|
+
'onekey_se03_version',
|
|
33
|
+
'onekey_se04_version',
|
|
34
|
+
'onekey_se01_hash',
|
|
35
|
+
'onekey_se02_hash',
|
|
36
|
+
'onekey_se03_hash',
|
|
37
|
+
'onekey_se04_hash',
|
|
38
|
+
'onekey_se01_build_id',
|
|
39
|
+
'onekey_se02_build_id',
|
|
40
|
+
'onekey_se03_build_id',
|
|
41
|
+
'onekey_se04_build_id',
|
|
42
|
+
'onekey_se01_boot_version',
|
|
43
|
+
'onekey_se02_boot_version',
|
|
44
|
+
'onekey_se03_boot_version',
|
|
45
|
+
'onekey_se04_boot_version',
|
|
46
|
+
'onekey_se01_boot_hash',
|
|
47
|
+
'onekey_se02_boot_hash',
|
|
48
|
+
'onekey_se03_boot_hash',
|
|
49
|
+
'onekey_se04_boot_hash',
|
|
50
|
+
'onekey_se01_boot_build_id',
|
|
51
|
+
'onekey_se02_boot_build_id',
|
|
52
|
+
'onekey_se03_boot_build_id',
|
|
53
|
+
'onekey_se04_boot_build_id',
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
function normalizeOnekeyFirmwareVersion(message: OnekeyFeatures) {
|
|
57
|
+
if (message.onekey_firmware_version && !semver.valid(message.onekey_firmware_version)) {
|
|
58
|
+
message.onekey_firmware_version = fixVersion(message.onekey_firmware_version);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function pickOnekeyFeatures(features?: OnekeyFeatures | null): OnekeyFeatures {
|
|
63
|
+
const message: OnekeyFeatures = {};
|
|
64
|
+
if (!features) return message;
|
|
65
|
+
|
|
66
|
+
for (const key of ONEKEY_FEATURE_KEYS) {
|
|
67
|
+
const value = features[key];
|
|
68
|
+
if (value !== undefined && value !== null) {
|
|
69
|
+
(message as Record<string, unknown>)[key] = value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
normalizeOnekeyFirmwareVersion(message);
|
|
74
|
+
return message;
|
|
75
|
+
}
|
|
76
|
+
|
|
7
77
|
export default class GetOnekeyFeatures extends BaseMethod {
|
|
8
78
|
init() {
|
|
9
79
|
this.allowDeviceMode = [
|
|
@@ -16,10 +86,12 @@ export default class GetOnekeyFeatures extends BaseMethod {
|
|
|
16
86
|
}
|
|
17
87
|
|
|
18
88
|
async run() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
message.onekey_firmware_version = fixVersion(message.onekey_firmware_version);
|
|
89
|
+
if (this.device.originalDescriptor?.protocolType === 'V2') {
|
|
90
|
+
return Promise.resolve(pickOnekeyFeatures(this.device.features as OnekeyFeatures));
|
|
22
91
|
}
|
|
92
|
+
|
|
93
|
+
const { message } = await this.device.commands.typedCall('OnekeyGetFeatures', 'OnekeyFeatures');
|
|
94
|
+
normalizeOnekeyFirmwareVersion(message);
|
|
23
95
|
return Promise.resolve(message);
|
|
24
96
|
}
|
|
25
97
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
4
4
|
import { getPassphraseStateWithRefreshDeviceInfo } from '../utils/deviceFeaturesUtils';
|
|
5
|
+
import { getDeviceType } from '../utils/deviceInfoUtils';
|
|
5
6
|
import { BaseMethod } from './BaseMethod';
|
|
6
7
|
|
|
7
8
|
export default class GetPassphraseState extends BaseMethod {
|
|
@@ -14,15 +15,23 @@ export default class GetPassphraseState extends BaseMethod {
|
|
|
14
15
|
if (!this.device.features)
|
|
15
16
|
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInitializeFailed));
|
|
16
17
|
|
|
17
|
-
const { passphraseState } =
|
|
18
|
+
const { passphraseState, newSession, unlockedAttachPin } =
|
|
19
|
+
await getPassphraseStateWithRefreshDeviceInfo(this.device, {
|
|
20
|
+
expectPassphraseState: this.payload.passphraseState,
|
|
21
|
+
onlyMainPin: this.payload.useEmptyPassphrase,
|
|
22
|
+
allowCreateAttachPin: this.payload.allowCreateAttachPin,
|
|
23
|
+
});
|
|
18
24
|
|
|
19
25
|
const { features } = this.device;
|
|
26
|
+
const isPro2 = getDeviceType(features) === EDeviceType.Pro2;
|
|
27
|
+
const passphraseProtection = features?.passphrase_protection ?? null;
|
|
20
28
|
|
|
21
29
|
// refresh device info
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
return Promise.resolve({
|
|
31
|
+
passphrase_state: isPro2 || passphraseProtection === true ? passphraseState : undefined,
|
|
32
|
+
session_id: newSession ?? features?.session_id ?? undefined,
|
|
33
|
+
unlocked_attach_pin: unlockedAttachPin ?? features?.unlocked_attach_pin,
|
|
34
|
+
passphrase_protection: passphraseProtection,
|
|
35
|
+
});
|
|
27
36
|
}
|
|
28
37
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseMethod } from './BaseMethod';
|
|
2
|
+
import { validateNonEmptyString } from './helpers/filesystemValidation';
|
|
3
|
+
|
|
4
|
+
export type PathInfoParams = {
|
|
5
|
+
path: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default class PathInfo extends BaseMethod<PathInfoParams> {
|
|
9
|
+
init() {
|
|
10
|
+
this.skipForceUpdateCheck = true;
|
|
11
|
+
this.useDevicePassphraseState = false;
|
|
12
|
+
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async run() {
|
|
16
|
+
const res = await this.device.commands.typedCall(
|
|
17
|
+
'FilesystemPathInfoQuery',
|
|
18
|
+
'FilesystemPathInfo',
|
|
19
|
+
{
|
|
20
|
+
path: this.params.path,
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
return Promise.resolve(res.message);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/api/SearchDevices.ts
CHANGED
|
@@ -34,17 +34,22 @@ export default class SearchDevices extends BaseMethod {
|
|
|
34
34
|
const lowerId = device.id?.toLowerCase();
|
|
35
35
|
if (!seenIds.has(lowerId)) {
|
|
36
36
|
seenIds.add(lowerId);
|
|
37
|
+
const bleName =
|
|
38
|
+
device.name ?? (device as unknown as { localName?: string }).localName ?? '';
|
|
37
39
|
devices.push({
|
|
38
40
|
...device,
|
|
39
41
|
connectId: device.id,
|
|
40
|
-
|
|
42
|
+
name: bleName || device.name,
|
|
43
|
+
deviceType: getDeviceTypeByBleName(bleName),
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
return devices;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
const { deviceList } = await DevicePool.getDevices(devicesDescriptor
|
|
50
|
+
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, undefined, {
|
|
51
|
+
connectProtocol: this.payload.connectProtocol,
|
|
52
|
+
});
|
|
48
53
|
return deviceList.map(device => device.toMessageObject());
|
|
49
54
|
}
|
|
50
55
|
}
|
|
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
4
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
5
5
|
|
|
6
6
|
import type { AlephiumGetAddress as HardwareAlephiumGetAddress } from '@onekeyfe/hd-transport';
|
|
7
|
-
import type { AlephiumAddress, AlephiumGetAddressParams } from '../../types';
|
|
7
|
+
import type { AlephiumAddress, AlephiumGetAddressParams, DeviceFirmwareRange } from '../../types';
|
|
8
8
|
|
|
9
9
|
export default class AlephiumGetAddress extends BaseMethod<HardwareAlephiumGetAddress[]> {
|
|
10
10
|
hasBundle = false;
|
|
@@ -43,8 +43,12 @@ export default class AlephiumGetAddress extends BaseMethod<HardwareAlephiumGetAd
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
getVersionRange() {
|
|
46
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
47
47
|
return {
|
|
48
|
+
pro2: {
|
|
49
|
+
min: '0.0.0',
|
|
50
|
+
unsupported: true,
|
|
51
|
+
},
|
|
48
52
|
model_touch: {
|
|
49
53
|
min: '4.10.0',
|
|
50
54
|
},
|
|
@@ -5,12 +5,12 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
5
5
|
import { stripHexPrefix } from '../helpers/hexUtils';
|
|
6
6
|
|
|
7
7
|
import type { AlephiumSignMessage as HardwareAlephiumSignMessage } from '@onekeyfe/hd-transport';
|
|
8
|
+
import type { DeviceFirmwareRange } from '../../types';
|
|
8
9
|
|
|
9
10
|
export default class AlephiumSignMessage extends BaseMethod<HardwareAlephiumSignMessage> {
|
|
10
11
|
init() {
|
|
11
12
|
this.checkDeviceId = true;
|
|
12
13
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
14
|
|
|
15
15
|
// check payload
|
|
16
16
|
validateParams(this.payload, [
|
|
@@ -30,8 +30,12 @@ export default class AlephiumSignMessage extends BaseMethod<HardwareAlephiumSign
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
getVersionRange() {
|
|
33
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
34
34
|
return {
|
|
35
|
+
pro2: {
|
|
36
|
+
min: '0.0.0',
|
|
37
|
+
unsupported: true,
|
|
38
|
+
},
|
|
35
39
|
model_touch: {
|
|
36
40
|
min: '4.10.0',
|
|
37
41
|
},
|
|
@@ -11,14 +11,13 @@ import type {
|
|
|
11
11
|
AlephiumSignTx as HardwareAlephiumSignTx,
|
|
12
12
|
TypedCall,
|
|
13
13
|
} from '@onekeyfe/hd-transport';
|
|
14
|
-
import type { AlephiumSignTransactionParams } from '../../types';
|
|
14
|
+
import type { AlephiumSignTransactionParams, DeviceFirmwareRange } from '../../types';
|
|
15
15
|
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
16
16
|
|
|
17
17
|
export default class AlephiumSignTransaction extends BaseMethod<HardwareAlephiumSignTx> {
|
|
18
18
|
init() {
|
|
19
19
|
this.checkDeviceId = true;
|
|
20
20
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
21
|
-
this.allowUsePreInitialize = true;
|
|
22
21
|
|
|
23
22
|
// check payload
|
|
24
23
|
validateParams(this.payload, [
|
|
@@ -39,8 +38,12 @@ export default class AlephiumSignTransaction extends BaseMethod<HardwareAlephium
|
|
|
39
38
|
};
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
getVersionRange() {
|
|
41
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
43
42
|
return {
|
|
43
|
+
pro2: {
|
|
44
|
+
min: '0.0.0',
|
|
45
|
+
unsupported: true,
|
|
46
|
+
},
|
|
44
47
|
model_touch: {
|
|
45
48
|
min: '4.10.0',
|
|
46
49
|
},
|
|
@@ -12,7 +12,6 @@ export default class AlgoSignTransaction extends BaseMethod<HardwareAlgorandSign
|
|
|
12
12
|
init() {
|
|
13
13
|
this.checkDeviceId = true;
|
|
14
14
|
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
15
|
-
this.allowUsePreInitialize = true;
|
|
16
15
|
|
|
17
16
|
// check payload
|
|
18
17
|
validateParams(this.payload, [
|
|
@@ -12,7 +12,12 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
12
12
|
import { PROTO } from '../../constants';
|
|
13
13
|
import { findMethod } from '../utils';
|
|
14
14
|
import { DEVICE, IFRAME, createUiMessage } from '../../events';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
getDeviceFirmwareVersion,
|
|
17
|
+
getFirmwareType,
|
|
18
|
+
getMethodVersionRange,
|
|
19
|
+
isMethodVersionRangeUnsupported,
|
|
20
|
+
} from '../../utils';
|
|
16
21
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
17
22
|
import { onDeviceButtonHandler } from '../../core';
|
|
18
23
|
import {
|
|
@@ -371,14 +376,6 @@ export default abstract class AllNetworkGetAddressBase extends BaseMethod<
|
|
|
371
376
|
this.device.on(DEVICE.PASSPHRASE, onSignalAbort);
|
|
372
377
|
|
|
373
378
|
preCheckDeviceSupport(this.device, method);
|
|
374
|
-
if (this.temporarySafetyCheckPrompted) {
|
|
375
|
-
method.temporarySafetyCheckPrompted = true;
|
|
376
|
-
} else {
|
|
377
|
-
const appliedTemporarySafetyCheck = await method.checkSafetyLevelOnTestNet();
|
|
378
|
-
if (appliedTemporarySafetyCheck) {
|
|
379
|
-
this.temporarySafetyCheckPrompted = true;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
379
|
|
|
383
380
|
const response = await method.run();
|
|
384
381
|
|
|
@@ -469,6 +466,10 @@ function preCheckDeviceSupport(device: Device, method: BaseMethod) {
|
|
|
469
466
|
);
|
|
470
467
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
471
468
|
|
|
469
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
470
|
+
throw ERRORS.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
471
|
+
}
|
|
472
|
+
|
|
472
473
|
if (
|
|
473
474
|
versionRange &&
|
|
474
475
|
semver.valid(versionRange.min) &&
|
|
@@ -509,6 +510,14 @@ function handleSkippableHardwareError(
|
|
|
509
510
|
);
|
|
510
511
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
511
512
|
|
|
513
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
514
|
+
error = ERRORS.createDeviceNotSupportMethodError(
|
|
515
|
+
method.name,
|
|
516
|
+
getFirmwareType(device.features)
|
|
517
|
+
);
|
|
518
|
+
return error;
|
|
519
|
+
}
|
|
520
|
+
|
|
512
521
|
if (
|
|
513
522
|
versionRange &&
|
|
514
523
|
semver.valid(versionRange.min) &&
|
|
@@ -10,7 +10,6 @@ export default class AptosSignInMessage extends BaseMethod<AptosSignSIWAMessage>
|
|
|
10
10
|
init() {
|
|
11
11
|
this.checkDeviceId = true;
|
|
12
12
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
13
|
|
|
15
14
|
// check payload
|
|
16
15
|
validateParams(this.payload, [
|
|
@@ -10,7 +10,6 @@ export default class AptosSignMessage extends BaseMethod<HardwareAptosSignMessag
|
|
|
10
10
|
init() {
|
|
11
11
|
this.checkDeviceId = true;
|
|
12
12
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
13
|
|
|
15
14
|
// check payload
|
|
16
15
|
validateParams(this.payload, [
|
|
@@ -10,7 +10,6 @@ export default class AptosSignTransaction extends BaseMethod<HardwareAptosSignTx
|
|
|
10
10
|
init() {
|
|
11
11
|
this.checkDeviceId = true;
|
|
12
12
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
13
|
|
|
15
14
|
// check payload
|
|
16
15
|
validateParams(this.payload, [
|
|
@@ -6,7 +6,7 @@ import { hex2BfcAddress, publicKeyToAddress } from './normalize';
|
|
|
6
6
|
import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils';
|
|
7
7
|
import { batchGetPublickeys } from '../helpers/batchGetPublickeys';
|
|
8
8
|
|
|
9
|
-
import type { BenfenAddress, BenfenGetAddressParams } from '../../types';
|
|
9
|
+
import type { BenfenAddress, BenfenGetAddressParams, DeviceFirmwareRange } from '../../types';
|
|
10
10
|
import type { BenfenGetAddress as HardwareBenfenGetAddress } from '@onekeyfe/hd-transport';
|
|
11
11
|
|
|
12
12
|
export default class BenfenGetAddress extends BaseMethod<HardwareBenfenGetAddress[]> {
|
|
@@ -47,8 +47,12 @@ export default class BenfenGetAddress extends BaseMethod<HardwareBenfenGetAddres
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
getVersionRange() {
|
|
50
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
51
51
|
return {
|
|
52
|
+
pro2: {
|
|
53
|
+
min: '0.0.0',
|
|
54
|
+
unsupported: true,
|
|
55
|
+
},
|
|
52
56
|
pro: {
|
|
53
57
|
min: '4.12.0',
|
|
54
58
|
},
|
|
@@ -4,7 +4,7 @@ import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
|
4
4
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
5
5
|
import { batchGetPublickeys } from '../helpers/batchGetPublickeys';
|
|
6
6
|
|
|
7
|
-
import type { BenfenGetPublicKeyParams, BenfenPublicKey } from '../../types';
|
|
7
|
+
import type { BenfenGetPublicKeyParams, BenfenPublicKey, DeviceFirmwareRange } from '../../types';
|
|
8
8
|
|
|
9
9
|
export default class BenfenGetPublicKey extends BaseMethod<any> {
|
|
10
10
|
hasBundle = false;
|
|
@@ -38,8 +38,12 @@ export default class BenfenGetPublicKey extends BaseMethod<any> {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
getVersionRange() {
|
|
41
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
42
42
|
return {
|
|
43
|
+
pro2: {
|
|
44
|
+
min: '0.0.0',
|
|
45
|
+
unsupported: true,
|
|
46
|
+
},
|
|
43
47
|
pro: {
|
|
44
48
|
min: '4.12.0',
|
|
45
49
|
},
|
|
@@ -5,12 +5,12 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
5
5
|
import { stripHexPrefix } from '../helpers/hexUtils';
|
|
6
6
|
|
|
7
7
|
import type { BenfenSignMessage as HardwareBenfenSignMessage } from '@onekeyfe/hd-transport';
|
|
8
|
+
import type { DeviceFirmwareRange } from '../../types';
|
|
8
9
|
|
|
9
10
|
export default class BenfenSignMessage extends BaseMethod<HardwareBenfenSignMessage> {
|
|
10
11
|
init() {
|
|
11
12
|
this.checkDeviceId = true;
|
|
12
13
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
14
|
|
|
15
15
|
validateParams(this.payload, [
|
|
16
16
|
{ name: 'path', required: true },
|
|
@@ -26,8 +26,12 @@ export default class BenfenSignMessage extends BaseMethod<HardwareBenfenSignMess
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
getVersionRange() {
|
|
29
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
30
30
|
return {
|
|
31
|
+
pro2: {
|
|
32
|
+
min: '0.0.0',
|
|
33
|
+
unsupported: true,
|
|
34
|
+
},
|
|
31
35
|
pro: {
|
|
32
36
|
min: '4.12.0',
|
|
33
37
|
},
|
|
@@ -8,12 +8,12 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
8
8
|
|
|
9
9
|
import type { BenfenSignTx, BenfenSignedTx, MessageType, TypedCall } from '@onekeyfe/hd-transport';
|
|
10
10
|
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
11
|
+
import type { DeviceFirmwareRange } from '../../types';
|
|
11
12
|
|
|
12
13
|
export default class BenfenSignTransaction extends BaseMethod<BenfenSignTx> {
|
|
13
14
|
init() {
|
|
14
15
|
this.checkDeviceId = true;
|
|
15
16
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
16
|
-
this.allowUsePreInitialize = true;
|
|
17
17
|
|
|
18
18
|
validateParams(this.payload, [
|
|
19
19
|
{ name: 'path', required: true },
|
|
@@ -33,8 +33,12 @@ export default class BenfenSignTransaction extends BaseMethod<BenfenSignTx> {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
getVersionRange() {
|
|
36
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
37
37
|
return {
|
|
38
|
+
pro2: {
|
|
39
|
+
min: '0.0.0',
|
|
40
|
+
unsupported: true,
|
|
41
|
+
},
|
|
38
42
|
pro: {
|
|
39
43
|
min: '4.12.0',
|
|
40
44
|
},
|
|
@@ -12,7 +12,6 @@ export default class BTCSignMessage extends BaseMethod<SignMessage> {
|
|
|
12
12
|
init() {
|
|
13
13
|
this.checkDeviceId = true;
|
|
14
14
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
15
|
-
this.allowUsePreInitialize = true;
|
|
16
15
|
|
|
17
16
|
validateParams(this.payload, [
|
|
18
17
|
{ name: 'path', required: true },
|
|
@@ -13,7 +13,6 @@ export default class BTCSignPsbt extends BaseMethod<SignPsbt> {
|
|
|
13
13
|
init() {
|
|
14
14
|
this.checkDeviceId = true;
|
|
15
15
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
16
|
-
this.allowUsePreInitialize = true;
|
|
17
16
|
|
|
18
17
|
validateParams(this.payload, [
|
|
19
18
|
{ name: 'psbt', type: 'hexString', required: true },
|
|
@@ -29,7 +29,6 @@ export default class BTCSignTransaction extends BaseMethod<Params> {
|
|
|
29
29
|
init() {
|
|
30
30
|
this.checkDeviceId = true;
|
|
31
31
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
32
|
-
this.allowUsePreInitialize = true;
|
|
33
32
|
|
|
34
33
|
validateParams(this.payload, [
|
|
35
34
|
{ name: 'coin', type: 'string', required: true },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { DeviceFirmwareRange } from '../../../types';
|
|
2
|
+
|
|
1
3
|
function isCoinNameInList(coinName: string, coinNames: (string | undefined)[]) {
|
|
2
4
|
for (let i = 0; i < coinNames.length; i++) {
|
|
3
5
|
const coin_name = coinNames[i];
|
|
@@ -8,9 +10,13 @@ function isCoinNameInList(coinName: string, coinNames: (string | undefined)[]) {
|
|
|
8
10
|
return false;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export function getBitcoinForkVersionRange(params: (string | undefined)[]) {
|
|
13
|
+
export function getBitcoinForkVersionRange(params: (string | undefined)[]): DeviceFirmwareRange {
|
|
12
14
|
if (isCoinNameInList('Neurai', params)) {
|
|
13
15
|
return {
|
|
16
|
+
pro2: {
|
|
17
|
+
min: '0.0.0',
|
|
18
|
+
unsupported: true,
|
|
19
|
+
},
|
|
14
20
|
model_mini: {
|
|
15
21
|
min: '3.7.0',
|
|
16
22
|
},
|