@onekeyfe/hd-core 1.1.27-alpha.4 → 1.1.27-alpha.40
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 +1661 -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 +6 -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/TronGetAddress.d.ts +4 -0
- package/dist/api/tron/TronGetAddress.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 -1497
- 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 +9 -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/TronGetAddress.ts +4 -0
- 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 +88 -77
- 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
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import AllNetworkGetAddressBase from '../src/api/allnetwork/AllNetworkGetAddressBase';
|
|
2
|
-
import EvmGetAddress from '../src/api/evm/EVMGetAddress';
|
|
3
|
-
import EVMGetPublicKey from '../src/api/evm/EVMGetPublicKey';
|
|
4
|
-
import { findMethod } from '../src/api/utils';
|
|
5
|
-
|
|
6
|
-
jest.mock('../src/data/config', () => ({
|
|
7
|
-
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
8
|
-
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
jest.mock('../src/api/utils', () => ({
|
|
12
|
-
findMethod: jest.fn(),
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
const createDevice = (onekeyDeviceType: string) => {
|
|
16
|
-
const typedCall = jest.fn();
|
|
17
|
-
return {
|
|
18
|
-
typedCall,
|
|
19
|
-
device: {
|
|
20
|
-
features: {
|
|
21
|
-
onekey_device_type: onekeyDeviceType,
|
|
22
|
-
safety_checks: 'Strict',
|
|
23
|
-
},
|
|
24
|
-
commands: {
|
|
25
|
-
typedCall,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
class TestAllNetworkMethod extends AllNetworkGetAddressBase {
|
|
32
|
-
async getAllNetworkAddress() {
|
|
33
|
-
return Promise.resolve([]);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
describe('EVM Ledger legacy path safety checks', () => {
|
|
38
|
-
it.each([
|
|
39
|
-
['evmGetAddress', EvmGetAddress],
|
|
40
|
-
['evmGetPublicKey', EVMGetPublicKey],
|
|
41
|
-
])(
|
|
42
|
-
'temporarily relaxes safety checks for Pro %s on ledger legacy path index greater than 1',
|
|
43
|
-
async (methodName, Method) => {
|
|
44
|
-
const { device, typedCall } = createDevice('PRO');
|
|
45
|
-
const method = new Method({
|
|
46
|
-
id: 1,
|
|
47
|
-
payload: {
|
|
48
|
-
method: methodName,
|
|
49
|
-
path: "m/44'/60'/0'/2",
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
method.device = device as any;
|
|
53
|
-
|
|
54
|
-
await method.checkSafetyLevelOnTestNet();
|
|
55
|
-
|
|
56
|
-
expect(typedCall).toHaveBeenCalledWith('ApplySettings', 'Success', {
|
|
57
|
-
safety_checks: 'PromptTemporarily',
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
it('temporarily relaxes safety checks for Touch get public key on ledger legacy path index greater than 1', async () => {
|
|
63
|
-
const { device, typedCall } = createDevice('TOUCH');
|
|
64
|
-
const method = new EVMGetPublicKey({
|
|
65
|
-
id: 1,
|
|
66
|
-
payload: {
|
|
67
|
-
method: 'evmGetPublicKey',
|
|
68
|
-
path: "m/44'/60'/0'/2",
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
method.device = device as any;
|
|
72
|
-
|
|
73
|
-
await method.checkSafetyLevelOnTestNet();
|
|
74
|
-
|
|
75
|
-
expect(typedCall).toHaveBeenCalledWith('ApplySettings', 'Success', {
|
|
76
|
-
safety_checks: 'PromptTemporarily',
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('runs EVM safety checks when allNetwork dispatches to the inner get address method', async () => {
|
|
81
|
-
const { device, typedCall } = createDevice('PRO');
|
|
82
|
-
(findMethod as jest.Mock).mockImplementation(message => new EvmGetAddress(message));
|
|
83
|
-
const runSpy = jest.spyOn(EvmGetAddress.prototype, 'run').mockResolvedValue([
|
|
84
|
-
{
|
|
85
|
-
path: "m/44'/60'/0'/2",
|
|
86
|
-
address: '0x0000000000000000000000000000000000000000',
|
|
87
|
-
},
|
|
88
|
-
]);
|
|
89
|
-
const method = new TestAllNetworkMethod({
|
|
90
|
-
id: 1,
|
|
91
|
-
payload: {
|
|
92
|
-
method: 'allNetworkGetAddress',
|
|
93
|
-
connectId: 'connect-id',
|
|
94
|
-
deviceId: 'device-id',
|
|
95
|
-
bundle: [],
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
method.device = {
|
|
99
|
-
...device,
|
|
100
|
-
on: jest.fn(),
|
|
101
|
-
off: jest.fn(),
|
|
102
|
-
} as any;
|
|
103
|
-
|
|
104
|
-
await method.callMethod(
|
|
105
|
-
'evmGetAddress',
|
|
106
|
-
{
|
|
107
|
-
bundle: [
|
|
108
|
-
{
|
|
109
|
-
path: "m/44'/60'/0'/2",
|
|
110
|
-
showOnOneKey: false,
|
|
111
|
-
chainId: 1,
|
|
112
|
-
_originRequestParams: {
|
|
113
|
-
network: 'evm',
|
|
114
|
-
path: "m/44'/60'/0'/2",
|
|
115
|
-
showOnOneKey: false,
|
|
116
|
-
chainName: '1',
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
0
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
expect(typedCall).toHaveBeenCalledWith('ApplySettings', 'Success', {
|
|
125
|
-
safety_checks: 'PromptTemporarily',
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
runSpy.mockRestore();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('only applies temporary safety checks once during one allNetwork request even when features stay strict', async () => {
|
|
132
|
-
const { device, typedCall } = createDevice('PRO');
|
|
133
|
-
(findMethod as jest.Mock).mockImplementation(message => new EvmGetAddress(message));
|
|
134
|
-
const runSpy = jest
|
|
135
|
-
.spyOn(EvmGetAddress.prototype, 'run')
|
|
136
|
-
.mockResolvedValueOnce([
|
|
137
|
-
{
|
|
138
|
-
path: "m/44'/60'/0'/2",
|
|
139
|
-
address: '0x0000000000000000000000000000000000000002',
|
|
140
|
-
},
|
|
141
|
-
])
|
|
142
|
-
.mockResolvedValueOnce([
|
|
143
|
-
{
|
|
144
|
-
path: "m/44'/60'/0'/3",
|
|
145
|
-
address: '0x0000000000000000000000000000000000000003',
|
|
146
|
-
},
|
|
147
|
-
]);
|
|
148
|
-
const method = new TestAllNetworkMethod({
|
|
149
|
-
id: 1,
|
|
150
|
-
payload: {
|
|
151
|
-
method: 'allNetworkGetAddressByLoop',
|
|
152
|
-
connectId: 'connect-id',
|
|
153
|
-
deviceId: 'device-id',
|
|
154
|
-
bundle: [],
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
method.device = {
|
|
158
|
-
...device,
|
|
159
|
-
on: jest.fn(),
|
|
160
|
-
off: jest.fn(),
|
|
161
|
-
} as any;
|
|
162
|
-
|
|
163
|
-
await method.callMethod(
|
|
164
|
-
'evmGetAddress',
|
|
165
|
-
{
|
|
166
|
-
bundle: [
|
|
167
|
-
{
|
|
168
|
-
path: "m/44'/60'/0'/2",
|
|
169
|
-
showOnOneKey: false,
|
|
170
|
-
chainId: 1,
|
|
171
|
-
_originRequestParams: {
|
|
172
|
-
network: 'evm',
|
|
173
|
-
path: "m/44'/60'/0'/2",
|
|
174
|
-
showOnOneKey: false,
|
|
175
|
-
chainName: '1',
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
0
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
await method.callMethod(
|
|
184
|
-
'evmGetAddress',
|
|
185
|
-
{
|
|
186
|
-
bundle: [
|
|
187
|
-
{
|
|
188
|
-
path: "m/44'/60'/0'/3",
|
|
189
|
-
showOnOneKey: false,
|
|
190
|
-
chainId: 1,
|
|
191
|
-
_originRequestParams: {
|
|
192
|
-
network: 'evm',
|
|
193
|
-
path: "m/44'/60'/0'/3",
|
|
194
|
-
showOnOneKey: false,
|
|
195
|
-
chainName: '1',
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
},
|
|
200
|
-
0
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
expect(typedCall).toHaveBeenCalledTimes(1);
|
|
204
|
-
expect(typedCall).toHaveBeenCalledWith('ApplySettings', 'Success', {
|
|
205
|
-
safety_checks: 'PromptTemporarily',
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
runSpy.mockRestore();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it.each(["m/44'/60'/0'/0", "m/44'/60'/0'/1"])(
|
|
212
|
-
'keeps safety checks unchanged for legal ledger legacy path %s',
|
|
213
|
-
async path => {
|
|
214
|
-
const { device, typedCall } = createDevice('PRO');
|
|
215
|
-
const method = new EvmGetAddress({
|
|
216
|
-
id: 1,
|
|
217
|
-
payload: {
|
|
218
|
-
method: 'evmGetAddress',
|
|
219
|
-
path,
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
method.device = device as any;
|
|
223
|
-
|
|
224
|
-
await method.checkSafetyLevelOnTestNet();
|
|
225
|
-
|
|
226
|
-
expect(typedCall).not.toHaveBeenCalled();
|
|
227
|
-
}
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
it('keeps safety checks unchanged for standard 5-segment BIP44 paths', async () => {
|
|
231
|
-
const { device, typedCall } = createDevice('PRO');
|
|
232
|
-
const method = new EvmGetAddress({
|
|
233
|
-
id: 1,
|
|
234
|
-
payload: {
|
|
235
|
-
method: 'evmGetAddress',
|
|
236
|
-
path: "m/44'/60'/0'/0/2",
|
|
237
|
-
},
|
|
238
|
-
});
|
|
239
|
-
method.device = device as any;
|
|
240
|
-
|
|
241
|
-
await method.checkSafetyLevelOnTestNet();
|
|
242
|
-
|
|
243
|
-
expect(typedCall).not.toHaveBeenCalled();
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('keeps safety checks unchanged on non Pro/Touch devices', async () => {
|
|
247
|
-
const { device, typedCall } = createDevice('MINI');
|
|
248
|
-
const method = new EvmGetAddress({
|
|
249
|
-
id: 1,
|
|
250
|
-
payload: {
|
|
251
|
-
method: 'evmGetAddress',
|
|
252
|
-
path: "m/44'/60'/0'/2",
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
method.device = device as any;
|
|
256
|
-
|
|
257
|
-
await method.checkSafetyLevelOnTestNet();
|
|
258
|
-
|
|
259
|
-
expect(typedCall).not.toHaveBeenCalled();
|
|
260
|
-
});
|
|
261
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Device } from '../src/device/Device';
|
|
2
|
-
|
|
3
|
-
jest.mock('../src/data/config', () => ({
|
|
4
|
-
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
5
|
-
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
describe('preInitialize', () => {
|
|
9
|
-
it('matches pre-initialized state by passphraseState only', () => {
|
|
10
|
-
const device = Object.create(Device.prototype) as Device;
|
|
11
|
-
|
|
12
|
-
device.markPreInitialized({
|
|
13
|
-
passphraseState: 'passphrase-state',
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
expect(
|
|
17
|
-
device.isPreInitializeMetaMatch({
|
|
18
|
-
passphraseState: 'passphrase-state',
|
|
19
|
-
})
|
|
20
|
-
).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreInitialize.d.ts","sourceRoot":"","sources":["../../../src/api/device/PreInitialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAmB3C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD,IAAI;IAOE,GAAG;CAaV"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare class PollingStateManager {
|
|
2
|
-
private activePolls;
|
|
3
|
-
start(connectId: string): number;
|
|
4
|
-
isActive(connectId: string, pollingId: number): boolean;
|
|
5
|
-
stop(connectId: string): void;
|
|
6
|
-
stopAll(): void;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=PollingStateManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PollingStateManager.d.ts","sourceRoot":"","sources":["../../src/core/PollingStateManager.ts"],"names":[],"mappings":"AAOA,qBAAa,mBAAmB;IAE9B,OAAO,CAAC,WAAW,CAA6B;IAQhD,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAWhC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAQvD,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAO7B,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preInitialize.d.ts","sourceRoot":"","sources":["../../../src/types/api/preInitialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import { LoggerNames, getLogger } from '../../utils';
|
|
3
|
-
|
|
4
|
-
import type { InitOptions } from '../../device/Device';
|
|
5
|
-
|
|
6
|
-
// Core prefix (@onekey/hd-core) so the host app's LOG_EVENT bridge forwards
|
|
7
|
-
// this into the collected hardware log scope (like [PRE-INIT][HIT]/[MISS]).
|
|
8
|
-
const Log = getLogger(LoggerNames.Core);
|
|
9
|
-
|
|
10
|
-
const parseInitOptions = (payload?: {
|
|
11
|
-
initSession?: boolean;
|
|
12
|
-
passphraseState?: string;
|
|
13
|
-
deriveCardano?: boolean;
|
|
14
|
-
}): InitOptions => ({
|
|
15
|
-
initSession: payload?.initSession,
|
|
16
|
-
passphraseState: payload?.passphraseState,
|
|
17
|
-
deriveCardano: payload?.deriveCardano,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export default class PreInitialize extends BaseMethod {
|
|
21
|
-
init() {
|
|
22
|
-
this.skipForceUpdateCheck = true;
|
|
23
|
-
this.useDevicePassphraseState = false;
|
|
24
|
-
// Fire-and-forget warm-up signal (core dedups + hangs up for the next call)
|
|
25
|
-
this.isPreWarmSignal = true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async run() {
|
|
29
|
-
try {
|
|
30
|
-
await this.device.preInitialize(parseInitOptions(this.payload));
|
|
31
|
-
if (this.device.hasDeviceAcquire()) {
|
|
32
|
-
await this.device.release();
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
} catch {
|
|
36
|
-
this.device.clearPreInitialized();
|
|
37
|
-
Log.debug('[PRE-INIT][FAILED]');
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages polling state for device connection attempts.
|
|
3
|
-
*
|
|
4
|
-
* Polling is isolated by connectId (device), so:
|
|
5
|
-
* - New request for device A only stops device A's previous polling
|
|
6
|
-
* - Device B's polling is unaffected
|
|
7
|
-
*/
|
|
8
|
-
export class PollingStateManager {
|
|
9
|
-
// connectId -> current polling ID
|
|
10
|
-
private activePolls = new Map<string, number>();
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Start a new polling session for a device.
|
|
14
|
-
* Automatically stops the previous polling for the same device.
|
|
15
|
-
* @param connectId - Device identifier (use empty string for USB without connectId)
|
|
16
|
-
* @returns The new polling ID
|
|
17
|
-
*/
|
|
18
|
-
start(connectId: string): number {
|
|
19
|
-
const currentId = (this.activePolls.get(connectId) ?? 0) + 1;
|
|
20
|
-
this.activePolls.set(connectId, currentId);
|
|
21
|
-
return currentId;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Check if a polling session is still active.
|
|
26
|
-
* @param connectId - Device identifier
|
|
27
|
-
* @param pollingId - The polling ID to check
|
|
28
|
-
*/
|
|
29
|
-
isActive(connectId: string, pollingId: number): boolean {
|
|
30
|
-
return this.activePolls.get(connectId) === pollingId;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Stop polling for a specific device.
|
|
35
|
-
* @param connectId - Device identifier
|
|
36
|
-
*/
|
|
37
|
-
stop(connectId: string): void {
|
|
38
|
-
this.activePolls.delete(connectId);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Stop all active polling sessions.
|
|
43
|
-
*/
|
|
44
|
-
stopAll(): void {
|
|
45
|
-
this.activePolls.clear();
|
|
46
|
-
}
|
|
47
|
-
}
|