@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,226 @@
|
|
|
1
|
+
import type { CommonParams, Response } from '../params';
|
|
2
|
+
import type {
|
|
3
|
+
DeviceFirmwareTarget,
|
|
4
|
+
DeviceFirmwareUpdateStatus,
|
|
5
|
+
DeviceOnboardingStatus,
|
|
6
|
+
DeviceInfoTargets,
|
|
7
|
+
DeviceInfoTypes,
|
|
8
|
+
DeviceRebootType,
|
|
9
|
+
FactoryDeviceInfo,
|
|
10
|
+
ProtoVersion,
|
|
11
|
+
ProtocolV2DeviceInfo,
|
|
12
|
+
Success,
|
|
13
|
+
} from '@onekeyfe/hd-transport';
|
|
14
|
+
|
|
15
|
+
// ── Shared response shapes (Protocol V2 file system) ────────────────────
|
|
16
|
+
|
|
17
|
+
export type FileOpSuccess = { message?: string };
|
|
18
|
+
|
|
19
|
+
export type FileInfo = {
|
|
20
|
+
path: string;
|
|
21
|
+
offset: number;
|
|
22
|
+
total_size: number;
|
|
23
|
+
data?: Uint8Array;
|
|
24
|
+
data_hash?: number;
|
|
25
|
+
processed_byte?: number;
|
|
26
|
+
chunks?: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type DirInfo = {
|
|
30
|
+
path: string;
|
|
31
|
+
child_dirs?: string;
|
|
32
|
+
child_files?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type PathInfoResult = {
|
|
36
|
+
exist: boolean;
|
|
37
|
+
size: number;
|
|
38
|
+
year: number;
|
|
39
|
+
month: number;
|
|
40
|
+
day: number;
|
|
41
|
+
hour: number;
|
|
42
|
+
minute: number;
|
|
43
|
+
second: number;
|
|
44
|
+
readonly?: boolean;
|
|
45
|
+
hidden?: boolean;
|
|
46
|
+
system?: boolean;
|
|
47
|
+
archive?: boolean;
|
|
48
|
+
directory?: boolean;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type DeviceRebootParams = {
|
|
52
|
+
rebootType?: DeviceRebootType | string | number;
|
|
53
|
+
reboot_type?: DeviceRebootType | string | number;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type DeviceGetDeviceInfoParams = {
|
|
57
|
+
targets?: DeviceInfoTargets;
|
|
58
|
+
types?: DeviceInfoTypes;
|
|
59
|
+
targetHw?: boolean;
|
|
60
|
+
targetFw?: boolean;
|
|
61
|
+
targetBt?: boolean;
|
|
62
|
+
targetSe1?: boolean;
|
|
63
|
+
targetSe2?: boolean;
|
|
64
|
+
targetSe3?: boolean;
|
|
65
|
+
targetSe4?: boolean;
|
|
66
|
+
targetStatus?: boolean;
|
|
67
|
+
includeVersion?: boolean;
|
|
68
|
+
includeBuildId?: boolean;
|
|
69
|
+
includeHash?: boolean;
|
|
70
|
+
includeSpecific?: boolean;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type DeviceFirmwareUpdateParams = {
|
|
74
|
+
targets?: DeviceFirmwareTarget[];
|
|
75
|
+
targetId?: DeviceFirmwareTarget['target_id'] | string | number;
|
|
76
|
+
target_id?: DeviceFirmwareTarget['target_id'] | string | number;
|
|
77
|
+
path?: string;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type FactoryDeviceInfoSettingsParams = {
|
|
81
|
+
serial_no?: string;
|
|
82
|
+
serialNo?: string;
|
|
83
|
+
cpu_info?: string;
|
|
84
|
+
cpuInfo?: string;
|
|
85
|
+
pre_firmware?: string;
|
|
86
|
+
preFirmware?: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// ── Method signatures ─────────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
export declare function fileRead(
|
|
92
|
+
connectId: string,
|
|
93
|
+
params: {
|
|
94
|
+
path: string;
|
|
95
|
+
offset?: number;
|
|
96
|
+
totalSize?: number;
|
|
97
|
+
chunkLen?: number;
|
|
98
|
+
uiPercentage?: number;
|
|
99
|
+
}
|
|
100
|
+
): Response<FileInfo>;
|
|
101
|
+
|
|
102
|
+
export declare function fileWrite(
|
|
103
|
+
connectId: string,
|
|
104
|
+
params: {
|
|
105
|
+
path: string;
|
|
106
|
+
offset?: number;
|
|
107
|
+
totalSize?: number;
|
|
108
|
+
chunkSize?: number;
|
|
109
|
+
chunkLen?: number;
|
|
110
|
+
data: ArrayBuffer | Uint8Array | Blob | string;
|
|
111
|
+
overwrite?: boolean;
|
|
112
|
+
append?: boolean;
|
|
113
|
+
uiPercentage?: number;
|
|
114
|
+
}
|
|
115
|
+
): Response<FileInfo>;
|
|
116
|
+
|
|
117
|
+
export declare function fileDelete(
|
|
118
|
+
connectId: string,
|
|
119
|
+
params: { path: string }
|
|
120
|
+
): Response<FileOpSuccess>;
|
|
121
|
+
|
|
122
|
+
export declare function dirList(
|
|
123
|
+
connectId: string,
|
|
124
|
+
params: { path: string; depth?: number }
|
|
125
|
+
): Response<DirInfo>;
|
|
126
|
+
|
|
127
|
+
export declare function dirMake(
|
|
128
|
+
connectId: string,
|
|
129
|
+
params: { path: string }
|
|
130
|
+
): Response<FileOpSuccess>;
|
|
131
|
+
|
|
132
|
+
export declare function dirRemove(
|
|
133
|
+
connectId: string,
|
|
134
|
+
params: { path: string }
|
|
135
|
+
): Response<FileOpSuccess>;
|
|
136
|
+
|
|
137
|
+
export declare function pathInfo(
|
|
138
|
+
connectId: string,
|
|
139
|
+
params: { path: string }
|
|
140
|
+
): Response<PathInfoResult>;
|
|
141
|
+
|
|
142
|
+
export declare function getProtoVersion(
|
|
143
|
+
connectId: string,
|
|
144
|
+
params?: CommonParams
|
|
145
|
+
): Response<ProtoVersion>;
|
|
146
|
+
|
|
147
|
+
export declare function ping(
|
|
148
|
+
connectId: string,
|
|
149
|
+
params?: CommonParams & { message?: string }
|
|
150
|
+
): Response<Success>;
|
|
151
|
+
|
|
152
|
+
export declare function deviceReboot(
|
|
153
|
+
connectId: string,
|
|
154
|
+
params: CommonParams & DeviceRebootParams
|
|
155
|
+
): Response<Success>;
|
|
156
|
+
|
|
157
|
+
export declare function deviceGetDeviceInfo(
|
|
158
|
+
connectId: string,
|
|
159
|
+
params?: CommonParams & DeviceGetDeviceInfoParams
|
|
160
|
+
): Response<ProtocolV2DeviceInfo>;
|
|
161
|
+
|
|
162
|
+
export declare function deviceGetOnboardingStatus(
|
|
163
|
+
connectId: string,
|
|
164
|
+
params?: CommonParams
|
|
165
|
+
): Response<DeviceOnboardingStatus>;
|
|
166
|
+
|
|
167
|
+
export declare function deviceFirmwareUpdate(
|
|
168
|
+
connectId: string,
|
|
169
|
+
params: CommonParams & DeviceFirmwareUpdateParams
|
|
170
|
+
): Response<Success | DeviceFirmwareUpdateStatus>;
|
|
171
|
+
|
|
172
|
+
export declare function deviceGetFirmwareUpdateStatus(
|
|
173
|
+
connectId: string,
|
|
174
|
+
params?: CommonParams
|
|
175
|
+
): Response<DeviceFirmwareUpdateStatus>;
|
|
176
|
+
|
|
177
|
+
export declare function factoryDeviceInfoSettings(
|
|
178
|
+
connectId: string,
|
|
179
|
+
params: FactoryDeviceInfoSettingsParams
|
|
180
|
+
): Response<Success>;
|
|
181
|
+
|
|
182
|
+
export declare function factoryGetDeviceInfo(connectId: string): Response<FactoryDeviceInfo>;
|
|
183
|
+
|
|
184
|
+
export declare function filesystemFixPermission(connectId: string): Response<Success>;
|
|
185
|
+
|
|
186
|
+
export declare function filesystemFileRead(
|
|
187
|
+
connectId: string,
|
|
188
|
+
params: Parameters<typeof fileRead>[1]
|
|
189
|
+
): ReturnType<typeof fileRead>;
|
|
190
|
+
|
|
191
|
+
export declare function filesystemFileWrite(
|
|
192
|
+
connectId: string,
|
|
193
|
+
params: Parameters<typeof fileWrite>[1]
|
|
194
|
+
): ReturnType<typeof fileWrite>;
|
|
195
|
+
|
|
196
|
+
export declare function filesystemFileDelete(
|
|
197
|
+
connectId: string,
|
|
198
|
+
params: Parameters<typeof fileDelete>[1]
|
|
199
|
+
): ReturnType<typeof fileDelete>;
|
|
200
|
+
|
|
201
|
+
export declare function filesystemDirList(
|
|
202
|
+
connectId: string,
|
|
203
|
+
params: Parameters<typeof dirList>[1]
|
|
204
|
+
): ReturnType<typeof dirList>;
|
|
205
|
+
|
|
206
|
+
export declare function filesystemDirMake(
|
|
207
|
+
connectId: string,
|
|
208
|
+
params: Parameters<typeof dirMake>[1]
|
|
209
|
+
): ReturnType<typeof dirMake>;
|
|
210
|
+
|
|
211
|
+
export declare function filesystemDirRemove(
|
|
212
|
+
connectId: string,
|
|
213
|
+
params: Parameters<typeof dirRemove>[1]
|
|
214
|
+
): ReturnType<typeof dirRemove>;
|
|
215
|
+
|
|
216
|
+
export declare function filesystemPathInfoQuery(
|
|
217
|
+
connectId: string,
|
|
218
|
+
params: Parameters<typeof pathInfo>[1]
|
|
219
|
+
): ReturnType<typeof pathInfo>;
|
|
220
|
+
|
|
221
|
+
export declare function filesystemFormat(connectId: string): Response<Success>;
|
|
222
|
+
|
|
223
|
+
export declare function filesystemDiskControl(
|
|
224
|
+
connectId: string,
|
|
225
|
+
params: CommonParams & { enable: number | string; timeoutMs?: number | string }
|
|
226
|
+
): Response<Success>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SearchDevice } from '../device';
|
|
2
|
-
import type { Response } from '../params';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
3
|
|
|
4
|
-
export declare function searchDevices(): Response<SearchDevice[]>;
|
|
4
|
+
export declare function searchDevices(params?: CommonParams): Response<SearchDevice[]>;
|
package/src/types/device.ts
CHANGED
|
@@ -85,7 +85,35 @@ export type SearchDevice = {
|
|
|
85
85
|
|
|
86
86
|
export type Device = KnownDevice;
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
type OnekeyFeatureExtensions = Partial<
|
|
89
|
+
Pick<
|
|
90
|
+
PROTO.OnekeyFeatures,
|
|
91
|
+
| 'onekey_board_build_id'
|
|
92
|
+
| 'onekey_se02_hash'
|
|
93
|
+
| 'onekey_se03_hash'
|
|
94
|
+
| 'onekey_se04_hash'
|
|
95
|
+
| 'onekey_se02_build_id'
|
|
96
|
+
| 'onekey_se03_build_id'
|
|
97
|
+
| 'onekey_se04_build_id'
|
|
98
|
+
| 'onekey_se01_boot_version'
|
|
99
|
+
| 'onekey_se02_boot_version'
|
|
100
|
+
| 'onekey_se03_boot_version'
|
|
101
|
+
| 'onekey_se04_boot_version'
|
|
102
|
+
| 'onekey_se01_boot_hash'
|
|
103
|
+
| 'onekey_se02_boot_hash'
|
|
104
|
+
| 'onekey_se03_boot_hash'
|
|
105
|
+
| 'onekey_se04_boot_hash'
|
|
106
|
+
| 'onekey_se01_boot_build_id'
|
|
107
|
+
| 'onekey_se02_boot_build_id'
|
|
108
|
+
| 'onekey_se03_boot_build_id'
|
|
109
|
+
| 'onekey_se04_boot_build_id'
|
|
110
|
+
>
|
|
111
|
+
>;
|
|
112
|
+
|
|
113
|
+
export type Features = PROTO.Features &
|
|
114
|
+
OnekeyFeatureExtensions & {
|
|
115
|
+
protocol_version?: number | null;
|
|
116
|
+
};
|
|
89
117
|
|
|
90
118
|
export type OnekeyFeatures = PROTO.OnekeyFeatures;
|
|
91
119
|
|
|
@@ -96,7 +124,8 @@ export type IDeviceType =
|
|
|
96
124
|
| EDeviceType.ClassicPure
|
|
97
125
|
| EDeviceType.Mini
|
|
98
126
|
| EDeviceType.Touch
|
|
99
|
-
| EDeviceType.Pro
|
|
127
|
+
| EDeviceType.Pro
|
|
128
|
+
| EDeviceType.Pro2;
|
|
100
129
|
|
|
101
130
|
/**
|
|
102
131
|
* model_classic: 'classic' | 'classic1s' | 'classicpure'
|
|
@@ -124,6 +153,7 @@ export const DeviceTypeToModels: { [deviceType in IDeviceType]: IDeviceModel[] }
|
|
|
124
153
|
[EDeviceType.Mini]: ['model_mini'],
|
|
125
154
|
[EDeviceType.Touch]: ['model_touch'],
|
|
126
155
|
[EDeviceType.Pro]: ['model_touch'],
|
|
156
|
+
[EDeviceType.Pro2]: [],
|
|
127
157
|
[EDeviceType.Unknown]: [],
|
|
128
158
|
};
|
|
129
159
|
|
|
@@ -136,6 +166,7 @@ export type ITransportStatus = 'valid' | 'outdated';
|
|
|
136
166
|
export type IVersionRange = {
|
|
137
167
|
min: string;
|
|
138
168
|
max?: string;
|
|
169
|
+
unsupported?: boolean;
|
|
139
170
|
};
|
|
140
171
|
|
|
141
172
|
export type DeviceFirmwareRange = {
|
package/src/types/params.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
export interface CommonParams {
|
|
2
4
|
keepSession?: boolean;
|
|
3
5
|
/**
|
|
@@ -49,9 +51,9 @@ export interface CommonParams {
|
|
|
49
51
|
onlyConnectBleDevice?: boolean;
|
|
50
52
|
|
|
51
53
|
/**
|
|
52
|
-
*
|
|
54
|
+
* Expected transport protocol. If omitted, SDK probes Protocol V1 then Protocol V2.
|
|
53
55
|
*/
|
|
54
|
-
|
|
56
|
+
connectProtocol?: HardwareConnectProtocol;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export type Params<T> = CommonParams & T & { bundle?: undefined };
|
package/src/types/settings.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { isNaN } from 'lodash';
|
|
3
3
|
import { EDeviceType, type EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Enum_Capability,
|
|
6
|
+
type GetPassphraseState as GetPassphraseStateMessage,
|
|
7
|
+
} from '@onekeyfe/hd-transport';
|
|
5
8
|
|
|
6
9
|
import { toHardened } from '../api/helpers/pathUtils';
|
|
7
10
|
import { DeviceModelToTypes, DeviceTypeToModels } from '../types';
|
|
8
|
-
import DataManager, {
|
|
11
|
+
import DataManager, {
|
|
12
|
+
type IFirmwareField,
|
|
13
|
+
type ProtocolV1MessageSchema,
|
|
14
|
+
} from '../data-manager/DataManager';
|
|
9
15
|
import { PROTOBUF_MESSAGE_CONFIG } from '../data-manager/MessagesConfig';
|
|
10
16
|
import { getDeviceType } from './deviceInfoUtils';
|
|
11
17
|
import { getDeviceFirmwareVersion } from './deviceVersionUtils';
|
|
@@ -15,13 +21,13 @@ import type { Device } from '../device/Device';
|
|
|
15
21
|
import type { DeviceCommands } from '../device/DeviceCommands';
|
|
16
22
|
import type { Features, SupportFeatureType } from '../types';
|
|
17
23
|
|
|
18
|
-
export const
|
|
24
|
+
export const getSupportProtocolV1MessageSchema = (
|
|
19
25
|
features: Features | undefined
|
|
20
|
-
): { messages: JSON;
|
|
26
|
+
): { messages: JSON; protocolV1MessageSchema: ProtocolV1MessageSchema } => {
|
|
21
27
|
if (!features)
|
|
22
28
|
return {
|
|
23
|
-
messages: DataManager.messages.
|
|
24
|
-
|
|
29
|
+
messages: DataManager.messages.v1CurrentSchema,
|
|
30
|
+
protocolV1MessageSchema: 'v1CurrentSchema',
|
|
25
31
|
};
|
|
26
32
|
|
|
27
33
|
const currentDeviceVersion = getDeviceFirmwareVersion(features).join('.');
|
|
@@ -37,18 +43,18 @@ export const getSupportMessageVersion = (
|
|
|
37
43
|
const sortedDeviceVersionConfigs =
|
|
38
44
|
deviceVersionConfigs?.sort((a, b) => semver.compare(b.minVersion, a.minVersion)) ?? [];
|
|
39
45
|
|
|
40
|
-
for (const { minVersion,
|
|
46
|
+
for (const { minVersion, protocolV1MessageSchema } of sortedDeviceVersionConfigs) {
|
|
41
47
|
if (semver.gte(currentDeviceVersion, minVersion)) {
|
|
42
48
|
return {
|
|
43
|
-
messages: DataManager.messages[
|
|
44
|
-
|
|
49
|
+
messages: DataManager.messages[protocolV1MessageSchema],
|
|
50
|
+
protocolV1MessageSchema,
|
|
45
51
|
};
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
return {
|
|
50
|
-
messages: DataManager.messages.
|
|
51
|
-
|
|
56
|
+
messages: DataManager.messages.v1CurrentSchema,
|
|
57
|
+
protocolV1MessageSchema: 'v1CurrentSchema',
|
|
52
58
|
};
|
|
53
59
|
};
|
|
54
60
|
|
|
@@ -68,7 +74,11 @@ export const supportNewPassphrase = (features?: Features): SupportFeatureType =>
|
|
|
68
74
|
if (!features) return { support: false };
|
|
69
75
|
|
|
70
76
|
const deviceType = getDeviceType(features);
|
|
71
|
-
if (
|
|
77
|
+
if (
|
|
78
|
+
deviceType === EDeviceType.Touch ||
|
|
79
|
+
deviceType === EDeviceType.Pro ||
|
|
80
|
+
deviceType === EDeviceType.Pro2
|
|
81
|
+
) {
|
|
72
82
|
return { support: true };
|
|
73
83
|
}
|
|
74
84
|
|
|
@@ -82,10 +92,13 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
82
92
|
options?: {
|
|
83
93
|
expectPassphraseState?: string;
|
|
84
94
|
onlyMainPin?: boolean;
|
|
95
|
+
allowCreateAttachPin?: boolean;
|
|
85
96
|
}
|
|
86
97
|
) => {
|
|
87
98
|
const { features, commands } = device;
|
|
88
99
|
const locked = features?.unlocked === false;
|
|
100
|
+
const deviceType = getDeviceType(features);
|
|
101
|
+
const isPro2 = deviceType === EDeviceType.Pro2;
|
|
89
102
|
|
|
90
103
|
const { passphraseState, newSession, unlockedAttachPin } = await getPassphraseState(
|
|
91
104
|
features,
|
|
@@ -95,12 +108,12 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
95
108
|
}
|
|
96
109
|
);
|
|
97
110
|
|
|
98
|
-
const isModeT =
|
|
99
|
-
getDeviceType(features) === EDeviceType.Touch || getDeviceType(features) === EDeviceType.Pro;
|
|
111
|
+
const isModeT = deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro;
|
|
100
112
|
|
|
101
113
|
// 如果可以获取到 passphraseState,但是设备 features 显示设备未开启 passphrase,需要刷新设备状态
|
|
102
114
|
// if passphraseState can be obtained, but the device features show that the device has not enabled passphrase, the device status needs to be refreshed
|
|
103
|
-
const needRefreshWithPassphrase =
|
|
115
|
+
const needRefreshWithPassphrase =
|
|
116
|
+
!isPro2 && passphraseState && features?.passphrase_protection !== true;
|
|
104
117
|
// 如果 Touch/Pro 在之前是锁定状态,刷新设备状态
|
|
105
118
|
// if Touch/Pro was locked before, refresh the device state
|
|
106
119
|
const needRefreshWithLocked = isModeT && locked;
|
|
@@ -110,10 +123,19 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
110
123
|
await device.getFeatures();
|
|
111
124
|
}
|
|
112
125
|
|
|
126
|
+
if (isPro2 && device.features) {
|
|
127
|
+
if (passphraseState) {
|
|
128
|
+
device.features.passphrase_protection = true;
|
|
129
|
+
}
|
|
130
|
+
if (newSession) {
|
|
131
|
+
device.features.session_id = newSession;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
113
135
|
// Attach to pin try to fix internal state
|
|
114
136
|
if (features?.device_id) {
|
|
115
137
|
device.updateInternalState(
|
|
116
|
-
device.features?.passphrase_protection ?? false,
|
|
138
|
+
(device.features?.passphrase_protection ?? false) || isPro2,
|
|
117
139
|
passphraseState,
|
|
118
140
|
device.features?.device_id ?? '',
|
|
119
141
|
newSession,
|
|
@@ -130,6 +152,7 @@ export const getPassphraseState = async (
|
|
|
130
152
|
options?: {
|
|
131
153
|
expectPassphraseState?: string;
|
|
132
154
|
onlyMainPin?: boolean;
|
|
155
|
+
allowCreateAttachPin?: boolean;
|
|
133
156
|
}
|
|
134
157
|
): Promise<{
|
|
135
158
|
passphraseState: string | undefined;
|
|
@@ -148,12 +171,23 @@ export const getPassphraseState = async (
|
|
|
148
171
|
);
|
|
149
172
|
const supportGetPassphraseState =
|
|
150
173
|
supportAttachPinCapability ||
|
|
174
|
+
// Pro2 V2 暂未从 features 暴露 capabilities,先直连该方法用于固件联调。
|
|
175
|
+
deviceType === EDeviceType.Pro2 ||
|
|
151
176
|
(deviceType === EDeviceType.Pro && semver.gte(firmwareVersion.join('.'), '4.15.0'));
|
|
152
177
|
|
|
153
178
|
if (supportGetPassphraseState) {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
179
|
+
const payload: GetPassphraseStateMessage = options?.onlyMainPin
|
|
180
|
+
? { _only_main_pin: true }
|
|
181
|
+
: { passphrase_state: options?.expectPassphraseState };
|
|
182
|
+
if (options?.allowCreateAttachPin) {
|
|
183
|
+
payload.allow_create_attach_pin = true;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const { message, type } = await commands.typedCall(
|
|
187
|
+
'GetPassphraseState',
|
|
188
|
+
'PassphraseState',
|
|
189
|
+
payload
|
|
190
|
+
);
|
|
157
191
|
|
|
158
192
|
// @ts-expect-error
|
|
159
193
|
if (type === 'CallMethodError') {
|
|
@@ -197,7 +231,10 @@ export const supportBatchPublicKey = (
|
|
|
197
231
|
|
|
198
232
|
const deviceType = getDeviceType(features);
|
|
199
233
|
// btc batch get public key
|
|
200
|
-
if (
|
|
234
|
+
if (
|
|
235
|
+
!!options?.includeNode &&
|
|
236
|
+
(deviceType === EDeviceType.Pro || deviceType === EDeviceType.Pro2)
|
|
237
|
+
) {
|
|
201
238
|
return semver.gte(currentVersion, '4.14.0');
|
|
202
239
|
}
|
|
203
240
|
if (!!options?.includeNode && deviceType === EDeviceType.Touch) {
|
|
@@ -214,7 +251,11 @@ export const supportBatchPublicKey = (
|
|
|
214
251
|
}
|
|
215
252
|
|
|
216
253
|
// support batch get public key
|
|
217
|
-
if (
|
|
254
|
+
if (
|
|
255
|
+
deviceType === EDeviceType.Touch ||
|
|
256
|
+
deviceType === EDeviceType.Pro ||
|
|
257
|
+
deviceType === EDeviceType.Pro2
|
|
258
|
+
) {
|
|
218
259
|
return semver.gte(currentVersion, '3.1.0');
|
|
219
260
|
}
|
|
220
261
|
|
|
@@ -27,6 +27,9 @@ export const getDeviceType = (features?: Features): IDeviceType => {
|
|
|
27
27
|
return EDeviceType.Touch;
|
|
28
28
|
case 'PRO':
|
|
29
29
|
return EDeviceType.Pro;
|
|
30
|
+
case 'PRO2':
|
|
31
|
+
case 'pro2':
|
|
32
|
+
return EDeviceType.Pro2;
|
|
30
33
|
case 'PURE':
|
|
31
34
|
return EDeviceType.ClassicPure;
|
|
32
35
|
default:
|
|
@@ -68,13 +71,14 @@ export const getDeviceType = (features?: Features): IDeviceType => {
|
|
|
68
71
|
export const getDeviceTypeByBleName = (name?: string): IDeviceType => {
|
|
69
72
|
if (!name) return EDeviceType.Unknown;
|
|
70
73
|
|
|
71
|
-
if (
|
|
72
|
-
if (
|
|
74
|
+
if (/^BixinKey/i.test(name)) return EDeviceType.Classic;
|
|
75
|
+
if (/^K/i.test(name)) return EDeviceType.Classic;
|
|
73
76
|
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
77
|
+
if (/^T/i.test(name)) return EDeviceType.Touch;
|
|
78
|
+
if (/^Touch/i.test(name)) return EDeviceType.Touch;
|
|
76
79
|
|
|
77
|
-
if (name.
|
|
80
|
+
if (/\bPro\s*2\b/i.test(name) || /^Pro2/i.test(name)) return EDeviceType.Pro2;
|
|
81
|
+
if (/\bPro\b/i.test(name) || /^Pro/i.test(name)) return EDeviceType.Pro;
|
|
78
82
|
|
|
79
83
|
return EDeviceType.Unknown;
|
|
80
84
|
};
|
|
@@ -128,8 +132,8 @@ export const getMethodVersionRange = (
|
|
|
128
132
|
getVersionRange: (deviceModel: IDeviceType | IDeviceModel) => IVersionRange | undefined
|
|
129
133
|
): IVersionRange | undefined => {
|
|
130
134
|
const deviceType = getDeviceType(features);
|
|
131
|
-
let versionRange: IVersionRange | undefined = getVersionRange(deviceType);
|
|
132
135
|
|
|
136
|
+
const versionRange = getVersionRange(deviceType);
|
|
133
137
|
if (versionRange) {
|
|
134
138
|
return versionRange;
|
|
135
139
|
}
|
|
@@ -142,16 +146,19 @@ export const getMethodVersionRange = (
|
|
|
142
146
|
];
|
|
143
147
|
for (const model of modelFallbacks) {
|
|
144
148
|
if (DeviceModelToTypes[model].includes(deviceType)) {
|
|
145
|
-
versionRange = getVersionRange(model);
|
|
149
|
+
const versionRange = getVersionRange(model);
|
|
146
150
|
if (versionRange) {
|
|
147
151
|
return versionRange;
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
}
|
|
151
155
|
|
|
152
|
-
return
|
|
156
|
+
return undefined;
|
|
153
157
|
};
|
|
154
158
|
|
|
159
|
+
export const isMethodVersionRangeUnsupported = (versionRange?: IVersionRange): boolean =>
|
|
160
|
+
versionRange?.unsupported === true;
|
|
161
|
+
|
|
155
162
|
export const getFirmwareType = (features: Features | undefined) => {
|
|
156
163
|
if (!features) {
|
|
157
164
|
return EFirmwareType.Universal;
|
package/src/utils/index.ts
CHANGED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
-
|
|
3
|
-
import { DeviceCommands } from '../src/device/DeviceCommands';
|
|
4
|
-
|
|
5
|
-
jest.mock('../src/data/config', () => ({
|
|
6
|
-
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
7
|
-
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
const createCommands = () => {
|
|
11
|
-
const commands = Object.create(DeviceCommands.prototype) as DeviceCommands;
|
|
12
|
-
commands.device = {
|
|
13
|
-
clearCancelableAction: jest.fn(),
|
|
14
|
-
} as any;
|
|
15
|
-
return commands;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
describe('DeviceCommands failure mapping', () => {
|
|
19
|
-
it.each([
|
|
20
|
-
['ButtonAck', 'Not in Ethereum signing mode'],
|
|
21
|
-
['PinMatrixAck', 'Not in Conflux signing mode'],
|
|
22
|
-
])('keeps %s unexpected message "%s" as firmware runtime error', async (callType, message) => {
|
|
23
|
-
const commands = createCommands();
|
|
24
|
-
|
|
25
|
-
await expect(
|
|
26
|
-
commands._filterCommonTypes(
|
|
27
|
-
{
|
|
28
|
-
type: 'Failure',
|
|
29
|
-
message: {
|
|
30
|
-
code: 'Failure_UnexpectedMessage',
|
|
31
|
-
message,
|
|
32
|
-
},
|
|
33
|
-
} as any,
|
|
34
|
-
callType as any
|
|
35
|
-
)
|
|
36
|
-
).rejects.toMatchObject({
|
|
37
|
-
errorCode: HardwareErrorCode.RuntimeError,
|
|
38
|
-
message: `Failure_UnexpectedMessage,${message}`,
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('keeps the existing NotInSigningMode mapping', async () => {
|
|
43
|
-
const commands = createCommands();
|
|
44
|
-
|
|
45
|
-
await expect(
|
|
46
|
-
commands._filterCommonTypes(
|
|
47
|
-
{
|
|
48
|
-
type: 'Failure',
|
|
49
|
-
message: {
|
|
50
|
-
code: 'Failure_UnexpectedMessage',
|
|
51
|
-
message: 'Not in Signing mode',
|
|
52
|
-
},
|
|
53
|
-
} as any,
|
|
54
|
-
'ButtonAck'
|
|
55
|
-
)
|
|
56
|
-
).rejects.toMatchObject({
|
|
57
|
-
errorCode: HardwareErrorCode.NotInSigningMode,
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('keeps the existing unexpected passphrase mapping', async () => {
|
|
62
|
-
const commands = createCommands();
|
|
63
|
-
|
|
64
|
-
await expect(
|
|
65
|
-
commands._filterCommonTypes(
|
|
66
|
-
{
|
|
67
|
-
type: 'Failure',
|
|
68
|
-
message: {
|
|
69
|
-
code: 'Failure_UnexpectedMessage',
|
|
70
|
-
message: 'Unexpected message',
|
|
71
|
-
},
|
|
72
|
-
} as any,
|
|
73
|
-
'PassphraseAck'
|
|
74
|
-
)
|
|
75
|
-
).rejects.toMatchObject({
|
|
76
|
-
errorCode: HardwareErrorCode.UnexpectPassphrase,
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('keeps non signing unexpected messages as runtime errors', async () => {
|
|
81
|
-
const commands = createCommands();
|
|
82
|
-
|
|
83
|
-
await expect(
|
|
84
|
-
commands._filterCommonTypes(
|
|
85
|
-
{
|
|
86
|
-
type: 'Failure',
|
|
87
|
-
message: {
|
|
88
|
-
code: 'Failure_UnexpectedMessage',
|
|
89
|
-
message: 'Not in Reset mode',
|
|
90
|
-
},
|
|
91
|
-
} as any,
|
|
92
|
-
'ButtonAck'
|
|
93
|
-
)
|
|
94
|
-
).rejects.toMatchObject({
|
|
95
|
-
errorCode: HardwareErrorCode.RuntimeError,
|
|
96
|
-
message: 'Failure_UnexpectedMessage,Not in Reset mode',
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|