@onekeyfe/hd-core 1.1.27-alpha.35 → 1.1.27-alpha.4
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__/DeviceCommands.test.ts +99 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +261 -0
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/preInitialize.test.ts +22 -0
- package/dist/api/BaseMethod.d.ts +7 -1
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +0 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +1 -6
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +1 -2
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumGetAddress.d.ts +6 -2
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts +5 -2
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts +5 -2
- 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 +9 -2
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts +9 -2
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts +8 -2
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts +8 -2
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +11 -1
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +11 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +15 -1
- 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 +11 -1
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +11 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +11 -2
- 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/device/PreInitialize.d.ts +6 -0
- package/dist/api/device/PreInitialize.d.ts.map +1 -0
- 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 +8 -2
- 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 +2 -10
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -28
- 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 +8 -2
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts +8 -2
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts +9 -2
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts +9 -2
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts +8 -2
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +9 -2
- 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/scdo/ScdoGetAddress.d.ts +6 -2
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts +5 -2
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts +5 -2
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- 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 +1 -2
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/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.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
- package/dist/core/PollingStateManager.d.ts +8 -0
- package/dist/core/PollingStateManager.d.ts.map +1 -0
- 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 +4 -7
- 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 +4 -5
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +18 -5
- 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 +1 -2
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +0 -8
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +43 -292
- package/dist/index.js +1002 -16133
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +0 -7
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +1 -10
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +3 -33
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/preInitialize.d.ts +3 -0
- package/dist/types/api/preInitialize.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 +2 -6
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -2
- 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 +3 -5
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +0 -1
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/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 +82 -7
- package/src/api/FirmwareUpdateV3.ts +4 -21
- package/src/api/GetOnekeyFeatures.ts +3 -75
- package/src/api/GetPassphraseState.ts +7 -16
- package/src/api/SearchDevices.ts +2 -7
- package/src/api/alephium/AlephiumGetAddress.ts +2 -6
- package/src/api/alephium/AlephiumSignMessage.ts +2 -6
- package/src/api/alephium/AlephiumSignTransaction.ts +3 -6
- package/src/api/algo/AlgoSignTransaction.ts +1 -0
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +9 -18
- package/src/api/aptos/AptosSignInMessage.ts +1 -0
- package/src/api/aptos/AptosSignMessage.ts +1 -0
- package/src/api/aptos/AptosSignTransaction.ts +1 -0
- package/src/api/benfen/BenfenGetAddress.ts +2 -6
- package/src/api/benfen/BenfenGetPublicKey.ts +2 -6
- package/src/api/benfen/BenfenSignMessage.ts +2 -6
- package/src/api/benfen/BenfenSignTransaction.ts +2 -6
- package/src/api/btc/BTCSignMessage.ts +1 -0
- package/src/api/btc/BTCSignPsbt.ts +1 -0
- package/src/api/btc/BTCSignTransaction.ts +1 -0
- package/src/api/btc/helpers/versionLimit.ts +1 -7
- package/src/api/cardano/CardanoSignMessage.ts +1 -0
- package/src/api/cardano/CardanoSignTransaction.ts +1 -0
- package/src/api/conflux/ConfluxSignMessage.ts +1 -0
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +3 -5
- package/src/api/cosmos/CosmosSignTransaction.ts +1 -0
- package/src/api/device/DeviceRebootToBoardloader.ts +1 -10
- package/src/api/device/DeviceRebootToBootloader.ts +1 -10
- package/src/api/device/PreInitialize.ts +41 -0
- package/src/api/dynex/DnxGetAddress.ts +0 -7
- package/src/api/dynex/DnxSignTransaction.ts +1 -7
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +3 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +2 -14
- package/src/api/evm/EVMSignTransaction.ts +3 -1
- package/src/api/evm/EVMSignTypedData.ts +8 -6
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/filecoin/FilecoinSignTransaction.ts +1 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +4 -27
- package/src/api/index.ts +1 -30
- package/src/api/kaspa/KaspaSignTransaction.ts +1 -0
- package/src/api/near/NearSignTransaction.ts +1 -0
- package/src/api/nem/NEMSignTransaction.ts +1 -0
- package/src/api/neo/NeoGetAddress.ts +1 -6
- package/src/api/neo/NeoSignTransaction.ts +2 -6
- package/src/api/nervos/NervosGetAddress.ts +2 -6
- package/src/api/nervos/NervosSignTransaction.ts +3 -6
- package/src/api/nexa/NexaGetAddress.ts +2 -6
- package/src/api/nexa/NexaSignTransaction.ts +4 -6
- package/src/api/nostr/NostrSignEvent.ts +1 -0
- package/src/api/nostr/NostrSignSchnorr.ts +1 -0
- package/src/api/polkadot/PolkadotSignTransaction.ts +1 -0
- package/src/api/scdo/ScdoGetAddress.ts +2 -6
- package/src/api/scdo/ScdoSignMessage.ts +2 -6
- package/src/api/scdo/ScdoSignTransaction.ts +3 -6
- package/src/api/solana/SolSignMessage.ts +1 -0
- package/src/api/solana/SolSignOffchainMessage.ts +1 -0
- package/src/api/solana/SolSignTransaction.ts +1 -0
- package/src/api/starcoin/StarcoinSignMessage.ts +1 -0
- package/src/api/starcoin/StarcoinSignTransaction.ts +1 -0
- package/src/api/stellar/StellarGetAddress.ts +1 -10
- package/src/api/stellar/StellarSignTransaction.ts +2 -14
- package/src/api/sui/SuiSignMessage.ts +1 -0
- package/src/api/sui/SuiSignTransaction.ts +10 -12
- package/src/api/ton/TonSignData.ts +1 -0
- package/src/api/ton/TonSignMessage.ts +1 -0
- package/src/api/ton/TonSignProof.ts +1 -0
- package/src/api/tron/TronSignMessage.ts +2 -1
- package/src/api/tron/TronSignTransaction.ts +1 -0
- package/src/api/xrp/XrpSignTransaction.ts +2 -1
- package/src/core/PollingStateManager.ts +47 -0
- package/src/core/RequestQueue.ts +10 -3
- package/src/core/index.ts +153 -62
- package/src/data-manager/DataManager.ts +7 -12
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +12 -38
- package/src/device/Device.ts +75 -82
- package/src/device/DeviceCommands.ts +26 -162
- package/src/device/DeviceConnector.ts +4 -29
- package/src/device/DevicePool.ts +1 -1
- package/src/events/ui-request.ts +0 -8
- package/src/inject.ts +2 -46
- package/src/types/api/export.ts +0 -1
- package/src/types/api/firmwareUpdate.ts +0 -12
- package/src/types/api/getPassphraseState.ts +2 -13
- package/src/types/api/index.ts +3 -80
- package/src/types/api/preInitialize.ts +3 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/device.ts +2 -33
- package/src/types/params.ts +2 -4
- package/src/types/settings.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +21 -62
- package/src/utils/deviceInfoUtils.ts +8 -15
- package/src/utils/index.ts +0 -1
- package/__tests__/protocol-v2.test.ts +0 -1544
- package/dist/api/DirList.d.ts +0 -10
- package/dist/api/DirList.d.ts.map +0 -1
- package/dist/api/DirMake.d.ts +0 -9
- package/dist/api/DirMake.d.ts.map +0 -1
- package/dist/api/DirRemove.d.ts +0 -9
- package/dist/api/DirRemove.d.ts.map +0 -1
- package/dist/api/FileDelete.d.ts +0 -9
- package/dist/api/FileDelete.d.ts.map +0 -1
- package/dist/api/FileRead.d.ts +0 -19
- package/dist/api/FileRead.d.ts.map +0 -1
- package/dist/api/FileWrite.d.ts +0 -23
- package/dist/api/FileWrite.d.ts.map +0 -1
- package/dist/api/FirmwareUpdateV4.d.ts +0 -32
- package/dist/api/FirmwareUpdateV4.d.ts.map +0 -1
- package/dist/api/GetDeviceInfo.d.ts +0 -9
- package/dist/api/GetDeviceInfo.d.ts.map +0 -1
- package/dist/api/PathInfo.d.ts +0 -9
- package/dist/api/PathInfo.d.ts.map +0 -1
- package/dist/api/helpers/deviceInfo.d.ts +0 -15
- package/dist/api/helpers/deviceInfo.d.ts.map +0 -1
- package/dist/api/helpers/filesystemValidation.d.ts +0 -7
- package/dist/api/helpers/filesystemValidation.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -10
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +0 -6
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +0 -6
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +0 -1
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
- package/dist/api/protocol-v2/Ping.d.ts +0 -8
- package/dist/api/protocol-v2/Ping.d.ts.map +0 -1
- package/dist/api/protocol-v2/helpers.d.ts +0 -49
- package/dist/api/protocol-v2/helpers.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/features.d.ts +0 -74
- package/dist/protocols/protocol-v2/features.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +0 -12
- package/dist/protocols/protocol-v2/firmware.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/index.d.ts +0 -3
- package/dist/protocols/protocol-v2/index.d.ts.map +0 -1
- package/dist/types/api/getDeviceInfo.d.ts +0 -84
- package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
- package/dist/types/api/protocolV2.d.ts +0 -127
- package/dist/types/api/protocolV2.d.ts.map +0 -1
- package/src/api/DirList.ts +0 -29
- package/src/api/DirMake.ts +0 -21
- package/src/api/DirRemove.ts +0 -21
- package/src/api/FileDelete.ts +0 -21
- package/src/api/FileRead.ts +0 -165
- package/src/api/FileWrite.ts +0 -203
- package/src/api/FirmwareUpdateV4.ts +0 -810
- package/src/api/GetDeviceInfo.ts +0 -153
- package/src/api/PathInfo.ts +0 -25
- package/src/api/helpers/deviceInfo.ts +0 -205
- package/src/api/helpers/filesystemValidation.ts +0 -51
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +0 -50
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +0 -35
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +0 -18
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -18
- package/src/api/protocol-v2/DeviceReboot.ts +0 -22
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -27
- package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +0 -18
- package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -34
- package/src/api/protocol-v2/FilesystemFixPermission.ts +0 -14
- package/src/api/protocol-v2/FilesystemFormat.ts +0 -14
- package/src/api/protocol-v2/GetProtoVersion.ts +0 -14
- package/src/api/protocol-v2/Ping.ts +0 -16
- package/src/api/protocol-v2/helpers.ts +0 -161
- package/src/data/messages/messages-protocol-v2.json +0 -13116
- package/src/protocols/protocol-v2/features.ts +0 -278
- package/src/protocols/protocol-v2/firmware.ts +0 -26
- package/src/protocols/protocol-v2/index.ts +0 -2
- package/src/types/api/getDeviceInfo.ts +0 -97
- package/src/types/api/protocolV2.ts +0 -226
package/src/inject.ts
CHANGED
|
@@ -103,13 +103,12 @@ export const createCoreApi = (
|
|
|
103
103
|
/**
|
|
104
104
|
* 搜索设备
|
|
105
105
|
*/
|
|
106
|
-
searchDevices:
|
|
106
|
+
searchDevices: () => call({ method: 'searchDevices' }),
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* 获取设备信息
|
|
110
110
|
*/
|
|
111
111
|
getFeatures: (connectId, params) => call({ ...params, connectId, method: 'getFeatures' }),
|
|
112
|
-
getDeviceInfo: (connectId, params) => call({ ...params, connectId, method: 'getDeviceInfo' }),
|
|
113
112
|
getOnekeyFeatures: (connectId, params) =>
|
|
114
113
|
call({ ...params, connectId, method: 'getOnekeyFeatures' }),
|
|
115
114
|
|
|
@@ -143,53 +142,12 @@ export const createCoreApi = (
|
|
|
143
142
|
|
|
144
143
|
testInitializeDeviceDuration: (connectId, params) =>
|
|
145
144
|
call({ ...params, connectId, method: 'testInitializeDeviceDuration' }),
|
|
146
|
-
|
|
145
|
+
preInitialize: (connectId, params) => call({ ...params, connectId, method: 'preInitialize' }),
|
|
147
146
|
deviceBackup: connectId => call({ connectId, method: 'deviceBackup' }),
|
|
148
147
|
deviceChangePin: (connectId, params) => call({ ...params, connectId, method: 'deviceChangePin' }),
|
|
149
148
|
deviceFlags: (connectId, params) => call({ ...params, connectId, method: 'deviceFlags' }),
|
|
150
149
|
deviceRebootToBoardloader: connectId => call({ connectId, method: 'deviceRebootToBoardloader' }),
|
|
151
150
|
deviceRebootToBootloader: connectId => call({ connectId, method: 'deviceRebootToBootloader' }),
|
|
152
|
-
|
|
153
|
-
// File system & device control API (Protocol V2 only)
|
|
154
|
-
getProtoVersion: (connectId, params) => call({ ...params, connectId, method: 'getProtoVersion' }),
|
|
155
|
-
ping: (connectId, params) => call({ ...params, connectId, method: 'ping' }),
|
|
156
|
-
deviceReboot: (connectId, params) => call({ ...params, connectId, method: 'deviceReboot' }),
|
|
157
|
-
deviceGetDeviceInfo: (connectId, params) =>
|
|
158
|
-
call({ ...params, connectId, method: 'deviceGetDeviceInfo' }),
|
|
159
|
-
deviceGetOnboardingStatus: (connectId, params) =>
|
|
160
|
-
call({ ...params, connectId, method: 'deviceGetOnboardingStatus' }),
|
|
161
|
-
deviceFirmwareUpdate: (connectId, params) =>
|
|
162
|
-
call({ ...params, connectId, method: 'deviceFirmwareUpdate' }),
|
|
163
|
-
deviceGetFirmwareUpdateStatus: (connectId, params) =>
|
|
164
|
-
call({ ...params, connectId, method: 'deviceGetFirmwareUpdateStatus' }),
|
|
165
|
-
factoryDeviceInfoSettings: (connectId, params) =>
|
|
166
|
-
call({ ...params, connectId, method: 'factoryDeviceInfoSettings' }),
|
|
167
|
-
factoryGetDeviceInfo: connectId => call({ connectId, method: 'factoryGetDeviceInfo' }),
|
|
168
|
-
filesystemFixPermission: connectId => call({ connectId, method: 'filesystemFixPermission' }),
|
|
169
|
-
fileRead: (connectId, params) => call({ ...params, connectId, method: 'fileRead' }),
|
|
170
|
-
fileWrite: (connectId, params) => call({ ...params, connectId, method: 'fileWrite' }),
|
|
171
|
-
fileDelete: (connectId, params) => call({ ...params, connectId, method: 'fileDelete' }),
|
|
172
|
-
dirList: (connectId, params) => call({ ...params, connectId, method: 'dirList' }),
|
|
173
|
-
dirMake: (connectId, params) => call({ ...params, connectId, method: 'dirMake' }),
|
|
174
|
-
dirRemove: (connectId, params) => call({ ...params, connectId, method: 'dirRemove' }),
|
|
175
|
-
pathInfo: (connectId, params) => call({ ...params, connectId, method: 'pathInfo' }),
|
|
176
|
-
filesystemFileRead: (connectId, params) =>
|
|
177
|
-
call({ ...params, connectId, method: 'filesystemFileRead' }),
|
|
178
|
-
filesystemFileWrite: (connectId, params) =>
|
|
179
|
-
call({ ...params, connectId, method: 'filesystemFileWrite' }),
|
|
180
|
-
filesystemFileDelete: (connectId, params) =>
|
|
181
|
-
call({ ...params, connectId, method: 'filesystemFileDelete' }),
|
|
182
|
-
filesystemDirList: (connectId, params) =>
|
|
183
|
-
call({ ...params, connectId, method: 'filesystemDirList' }),
|
|
184
|
-
filesystemDirMake: (connectId, params) =>
|
|
185
|
-
call({ ...params, connectId, method: 'filesystemDirMake' }),
|
|
186
|
-
filesystemDirRemove: (connectId, params) =>
|
|
187
|
-
call({ ...params, connectId, method: 'filesystemDirRemove' }),
|
|
188
|
-
filesystemPathInfoQuery: (connectId, params) =>
|
|
189
|
-
call({ ...params, connectId, method: 'filesystemPathInfoQuery' }),
|
|
190
|
-
filesystemFormat: connectId => call({ connectId, method: 'filesystemFormat' }),
|
|
191
|
-
filesystemDiskControl: (connectId, params) =>
|
|
192
|
-
call({ ...params, connectId, method: 'filesystemDiskControl' }),
|
|
193
151
|
deviceRecovery: (connectId, params) => call({ ...params, connectId, method: 'deviceRecovery' }),
|
|
194
152
|
deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
|
|
195
153
|
deviceSettings: (connectId, params) => call({ ...params, connectId, method: 'deviceSettings' }),
|
|
@@ -302,8 +260,6 @@ export const createCoreApi = (
|
|
|
302
260
|
call({ ...params, connectId, method: 'firmwareUpdateV2' }),
|
|
303
261
|
firmwareUpdateV3: (connectId, params) =>
|
|
304
262
|
call({ ...params, connectId, method: 'firmwareUpdateV3' }),
|
|
305
|
-
firmwareUpdateV4: (connectId, params) =>
|
|
306
|
-
call({ ...params, connectId, method: 'firmwareUpdateV4' }),
|
|
307
263
|
promptWebDeviceAccess: params => call({ ...params, method: 'promptWebDeviceAccess' }),
|
|
308
264
|
|
|
309
265
|
tronGetAddress: (connectId, deviceId, params) =>
|
package/src/types/api/export.ts
CHANGED
|
@@ -41,7 +41,6 @@ export declare function firmwareUpdateV2(
|
|
|
41
41
|
export interface FirmwareUpdateV3Params {
|
|
42
42
|
bleVersion?: number[];
|
|
43
43
|
bleBinary?: ArrayBuffer;
|
|
44
|
-
chunkSize?: number;
|
|
45
44
|
|
|
46
45
|
firmwareVersion?: number[];
|
|
47
46
|
firmwareBinary?: ArrayBuffer;
|
|
@@ -57,8 +56,6 @@ export interface FirmwareUpdateV3Params {
|
|
|
57
56
|
platform: IPlatform;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
export type FirmwareUpdateV4Params = FirmwareUpdateV3Params;
|
|
61
|
-
|
|
62
59
|
export declare function firmwareUpdateV3(
|
|
63
60
|
connectId: string | undefined,
|
|
64
61
|
params: Params<FirmwareUpdateV3Params>
|
|
@@ -67,12 +64,3 @@ export declare function firmwareUpdateV3(
|
|
|
67
64
|
firmwareVersion: string;
|
|
68
65
|
bootloaderVersion: string;
|
|
69
66
|
}>;
|
|
70
|
-
|
|
71
|
-
export declare function firmwareUpdateV4(
|
|
72
|
-
connectId: string | undefined,
|
|
73
|
-
params: Params<FirmwareUpdateV4Params>
|
|
74
|
-
): Response<{
|
|
75
|
-
bleVersion: string;
|
|
76
|
-
firmwareVersion: string;
|
|
77
|
-
bootloaderVersion: string;
|
|
78
|
-
}>;
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import type { CommonParams, Response } from '../params';
|
|
2
2
|
|
|
3
|
-
export type GetPassphraseStatePayload = {
|
|
4
|
-
passphrase_state?: string;
|
|
5
|
-
session_id?: string;
|
|
6
|
-
unlocked_attach_pin?: boolean;
|
|
7
|
-
passphrase_protection?: boolean | null;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type GetPassphraseStateParams = CommonParams & {
|
|
11
|
-
allowCreateAttachPin?: boolean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
3
|
export declare function getPassphraseState(
|
|
15
4
|
connectId?: string,
|
|
16
|
-
params?:
|
|
17
|
-
): Response<
|
|
5
|
+
params?: CommonParams
|
|
6
|
+
): Response<string>;
|
package/src/types/api/index.ts
CHANGED
|
@@ -1,35 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
deviceFirmwareUpdate,
|
|
3
|
-
deviceGetDeviceInfo,
|
|
4
|
-
deviceGetFirmwareUpdateStatus,
|
|
5
|
-
deviceGetOnboardingStatus,
|
|
6
|
-
deviceReboot,
|
|
7
|
-
dirList,
|
|
8
|
-
dirMake,
|
|
9
|
-
dirRemove,
|
|
10
|
-
factoryDeviceInfoSettings,
|
|
11
|
-
factoryGetDeviceInfo,
|
|
12
|
-
fileDelete,
|
|
13
|
-
fileRead,
|
|
14
|
-
fileWrite,
|
|
15
|
-
filesystemDirList,
|
|
16
|
-
filesystemDirMake,
|
|
17
|
-
filesystemDirRemove,
|
|
18
|
-
filesystemDiskControl,
|
|
19
|
-
filesystemFileDelete,
|
|
20
|
-
filesystemFileRead,
|
|
21
|
-
filesystemFileWrite,
|
|
22
|
-
filesystemFixPermission,
|
|
23
|
-
filesystemFormat,
|
|
24
|
-
filesystemPathInfoQuery,
|
|
25
|
-
getProtoVersion,
|
|
26
|
-
pathInfo,
|
|
27
|
-
ping,
|
|
28
|
-
} from './protocolV2';
|
|
29
1
|
import type { off, on, removeAllListeners } from './event';
|
|
30
2
|
import type { uiResponse } from './uiResponse';
|
|
31
3
|
import type { init, updateSettings } from './init';
|
|
32
4
|
import type { testInitializeDeviceDuration } from './testInitializeDeviceDuration';
|
|
5
|
+
import type { preInitialize } from './preInitialize';
|
|
33
6
|
import type { getLogs } from './getLogs';
|
|
34
7
|
import type { checkBridgeStatus } from './checkBridgeStatus';
|
|
35
8
|
import type { checkBridgeRelease } from './checkBridgeRelease';
|
|
@@ -38,17 +11,11 @@ import type { checkAllFirmwareRelease } from './checkAllFirmwareRelease';
|
|
|
38
11
|
import type { checkFirmwareTypeAvailable } from './checkFirmwareTypeAvailable';
|
|
39
12
|
import type { searchDevices } from './searchDevices';
|
|
40
13
|
import type { getFeatures } from './getFeatures';
|
|
41
|
-
import type { getDeviceInfo } from './getDeviceInfo';
|
|
42
14
|
import type { getOnekeyFeatures } from './getOnekeyFeatures';
|
|
43
15
|
import type { getPassphraseState } from './getPassphraseState';
|
|
44
16
|
import type { checkFirmwareRelease } from './checkFirmwareRelease';
|
|
45
17
|
import type { checkBLEFirmwareRelease } from './checkBLEFirmwareRelease';
|
|
46
|
-
import type {
|
|
47
|
-
firmwareUpdate,
|
|
48
|
-
firmwareUpdateV2,
|
|
49
|
-
firmwareUpdateV3,
|
|
50
|
-
firmwareUpdateV4,
|
|
51
|
-
} from './firmwareUpdate';
|
|
18
|
+
import type { firmwareUpdate, firmwareUpdateV2, firmwareUpdateV3 } from './firmwareUpdate';
|
|
52
19
|
import type { promptWebDeviceAccess } from './promptWebDeviceAccess';
|
|
53
20
|
import type { deviceReset } from './deviceReset';
|
|
54
21
|
import type { deviceRecovery } from './deviceRecovery';
|
|
@@ -164,19 +131,6 @@ import type { neoSignTransaction } from './neoSignTransaction';
|
|
|
164
131
|
import type { ConnectSettings } from '../settings';
|
|
165
132
|
|
|
166
133
|
export * from './export';
|
|
167
|
-
export type {
|
|
168
|
-
DeviceInfoMode,
|
|
169
|
-
DeviceInfoProtocol,
|
|
170
|
-
DeviceInfoScope,
|
|
171
|
-
DeviceInfoSource,
|
|
172
|
-
DeviceInfoStatus,
|
|
173
|
-
GetDeviceInfoParams,
|
|
174
|
-
UnifiedDeviceInfo,
|
|
175
|
-
UnifiedDeviceInfoRaw,
|
|
176
|
-
UnifiedDeviceInfoVerify,
|
|
177
|
-
UnifiedDeviceInfoVersions,
|
|
178
|
-
} from './getDeviceInfo';
|
|
179
|
-
export type { GetPassphraseStateParams, GetPassphraseStatePayload } from './getPassphraseState';
|
|
180
134
|
|
|
181
135
|
export type CoreApi = {
|
|
182
136
|
/**
|
|
@@ -199,6 +153,7 @@ export type CoreApi = {
|
|
|
199
153
|
* Test function
|
|
200
154
|
*/
|
|
201
155
|
testInitializeDeviceDuration: typeof testInitializeDeviceDuration;
|
|
156
|
+
preInitialize: typeof preInitialize;
|
|
202
157
|
|
|
203
158
|
/**
|
|
204
159
|
* Core function
|
|
@@ -215,7 +170,6 @@ export type CoreApi = {
|
|
|
215
170
|
searchDevices: typeof searchDevices;
|
|
216
171
|
promptWebDeviceAccess: typeof promptWebDeviceAccess;
|
|
217
172
|
getFeatures: typeof getFeatures;
|
|
218
|
-
getDeviceInfo: typeof getDeviceInfo;
|
|
219
173
|
getOnekeyFeatures: typeof getOnekeyFeatures;
|
|
220
174
|
getPassphraseState: typeof getPassphraseState;
|
|
221
175
|
deviceBackup: typeof deviceBackup;
|
|
@@ -243,39 +197,8 @@ export type CoreApi = {
|
|
|
243
197
|
firmwareUpdate: typeof firmwareUpdate;
|
|
244
198
|
firmwareUpdateV2: typeof firmwareUpdateV2;
|
|
245
199
|
firmwareUpdateV3: typeof firmwareUpdateV3;
|
|
246
|
-
firmwareUpdateV4: typeof firmwareUpdateV4;
|
|
247
200
|
cipherKeyValue: typeof cipherKeyValue;
|
|
248
201
|
|
|
249
|
-
/**
|
|
250
|
-
* File system & device control API (Protocol V2 only)
|
|
251
|
-
*/
|
|
252
|
-
getProtoVersion: typeof getProtoVersion;
|
|
253
|
-
ping: typeof ping;
|
|
254
|
-
deviceReboot: typeof deviceReboot;
|
|
255
|
-
deviceGetDeviceInfo: typeof deviceGetDeviceInfo;
|
|
256
|
-
deviceGetOnboardingStatus: typeof deviceGetOnboardingStatus;
|
|
257
|
-
deviceFirmwareUpdate: typeof deviceFirmwareUpdate;
|
|
258
|
-
deviceGetFirmwareUpdateStatus: typeof deviceGetFirmwareUpdateStatus;
|
|
259
|
-
factoryDeviceInfoSettings: typeof factoryDeviceInfoSettings;
|
|
260
|
-
factoryGetDeviceInfo: typeof factoryGetDeviceInfo;
|
|
261
|
-
filesystemFixPermission: typeof filesystemFixPermission;
|
|
262
|
-
fileRead: typeof fileRead;
|
|
263
|
-
fileWrite: typeof fileWrite;
|
|
264
|
-
fileDelete: typeof fileDelete;
|
|
265
|
-
dirList: typeof dirList;
|
|
266
|
-
dirMake: typeof dirMake;
|
|
267
|
-
dirRemove: typeof dirRemove;
|
|
268
|
-
pathInfo: typeof pathInfo;
|
|
269
|
-
filesystemFileRead: typeof filesystemFileRead;
|
|
270
|
-
filesystemFileWrite: typeof filesystemFileWrite;
|
|
271
|
-
filesystemFileDelete: typeof filesystemFileDelete;
|
|
272
|
-
filesystemDirList: typeof filesystemDirList;
|
|
273
|
-
filesystemDirMake: typeof filesystemDirMake;
|
|
274
|
-
filesystemDirRemove: typeof filesystemDirRemove;
|
|
275
|
-
filesystemPathInfoQuery: typeof filesystemPathInfoQuery;
|
|
276
|
-
filesystemFormat: typeof filesystemFormat;
|
|
277
|
-
filesystemDiskControl: typeof filesystemDiskControl;
|
|
278
|
-
|
|
279
202
|
/**
|
|
280
203
|
* All network function
|
|
281
204
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SearchDevice } from '../device';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Response } from '../params';
|
|
3
3
|
|
|
4
|
-
export declare function searchDevices(
|
|
4
|
+
export declare function searchDevices(): Response<SearchDevice[]>;
|
package/src/types/device.ts
CHANGED
|
@@ -85,35 +85,7 @@ export type SearchDevice = {
|
|
|
85
85
|
|
|
86
86
|
export type Device = KnownDevice;
|
|
87
87
|
|
|
88
|
-
type
|
|
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
|
-
};
|
|
88
|
+
export type Features = PROTO.Features;
|
|
117
89
|
|
|
118
90
|
export type OnekeyFeatures = PROTO.OnekeyFeatures;
|
|
119
91
|
|
|
@@ -124,8 +96,7 @@ export type IDeviceType =
|
|
|
124
96
|
| EDeviceType.ClassicPure
|
|
125
97
|
| EDeviceType.Mini
|
|
126
98
|
| EDeviceType.Touch
|
|
127
|
-
| EDeviceType.Pro
|
|
128
|
-
| EDeviceType.Pro2;
|
|
99
|
+
| EDeviceType.Pro;
|
|
129
100
|
|
|
130
101
|
/**
|
|
131
102
|
* model_classic: 'classic' | 'classic1s' | 'classicpure'
|
|
@@ -153,7 +124,6 @@ export const DeviceTypeToModels: { [deviceType in IDeviceType]: IDeviceModel[] }
|
|
|
153
124
|
[EDeviceType.Mini]: ['model_mini'],
|
|
154
125
|
[EDeviceType.Touch]: ['model_touch'],
|
|
155
126
|
[EDeviceType.Pro]: ['model_touch'],
|
|
156
|
-
[EDeviceType.Pro2]: [],
|
|
157
127
|
[EDeviceType.Unknown]: [],
|
|
158
128
|
};
|
|
159
129
|
|
|
@@ -166,7 +136,6 @@ export type ITransportStatus = 'valid' | 'outdated';
|
|
|
166
136
|
export type IVersionRange = {
|
|
167
137
|
min: string;
|
|
168
138
|
max?: string;
|
|
169
|
-
unsupported?: boolean;
|
|
170
139
|
};
|
|
171
140
|
|
|
172
141
|
export type DeviceFirmwareRange = {
|
package/src/types/params.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
|
|
2
|
-
|
|
3
1
|
export interface CommonParams {
|
|
4
2
|
keepSession?: boolean;
|
|
5
3
|
/**
|
|
@@ -51,9 +49,9 @@ export interface CommonParams {
|
|
|
51
49
|
onlyConnectBleDevice?: boolean;
|
|
52
50
|
|
|
53
51
|
/**
|
|
54
|
-
*
|
|
52
|
+
* Use pre-initialized device state (BLE only)
|
|
55
53
|
*/
|
|
56
|
-
|
|
54
|
+
usePreInitialize?: boolean;
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
export type Params<T> = CommonParams & T & { bundle?: undefined };
|
package/src/types/settings.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
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 {
|
|
5
|
-
Enum_Capability,
|
|
6
|
-
type GetPassphraseState as GetPassphraseStateMessage,
|
|
7
|
-
} from '@onekeyfe/hd-transport';
|
|
4
|
+
import { Enum_Capability } from '@onekeyfe/hd-transport';
|
|
8
5
|
|
|
9
6
|
import { toHardened } from '../api/helpers/pathUtils';
|
|
10
7
|
import { DeviceModelToTypes, DeviceTypeToModels } from '../types';
|
|
11
|
-
import DataManager, {
|
|
12
|
-
type IFirmwareField,
|
|
13
|
-
type ProtocolV1MessageSchema,
|
|
14
|
-
} from '../data-manager/DataManager';
|
|
8
|
+
import DataManager, { type IFirmwareField, type MessageVersion } from '../data-manager/DataManager';
|
|
15
9
|
import { PROTOBUF_MESSAGE_CONFIG } from '../data-manager/MessagesConfig';
|
|
16
10
|
import { getDeviceType } from './deviceInfoUtils';
|
|
17
11
|
import { getDeviceFirmwareVersion } from './deviceVersionUtils';
|
|
@@ -21,13 +15,13 @@ import type { Device } from '../device/Device';
|
|
|
21
15
|
import type { DeviceCommands } from '../device/DeviceCommands';
|
|
22
16
|
import type { Features, SupportFeatureType } from '../types';
|
|
23
17
|
|
|
24
|
-
export const
|
|
18
|
+
export const getSupportMessageVersion = (
|
|
25
19
|
features: Features | undefined
|
|
26
|
-
): { messages: JSON;
|
|
20
|
+
): { messages: JSON; messageVersion: MessageVersion } => {
|
|
27
21
|
if (!features)
|
|
28
22
|
return {
|
|
29
|
-
messages: DataManager.messages.
|
|
30
|
-
|
|
23
|
+
messages: DataManager.messages.latest,
|
|
24
|
+
messageVersion: 'latest',
|
|
31
25
|
};
|
|
32
26
|
|
|
33
27
|
const currentDeviceVersion = getDeviceFirmwareVersion(features).join('.');
|
|
@@ -43,18 +37,18 @@ export const getSupportProtocolV1MessageSchema = (
|
|
|
43
37
|
const sortedDeviceVersionConfigs =
|
|
44
38
|
deviceVersionConfigs?.sort((a, b) => semver.compare(b.minVersion, a.minVersion)) ?? [];
|
|
45
39
|
|
|
46
|
-
for (const { minVersion,
|
|
40
|
+
for (const { minVersion, messageVersion } of sortedDeviceVersionConfigs) {
|
|
47
41
|
if (semver.gte(currentDeviceVersion, minVersion)) {
|
|
48
42
|
return {
|
|
49
|
-
messages: DataManager.messages[
|
|
50
|
-
|
|
43
|
+
messages: DataManager.messages[messageVersion],
|
|
44
|
+
messageVersion,
|
|
51
45
|
};
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
48
|
|
|
55
49
|
return {
|
|
56
|
-
messages: DataManager.messages.
|
|
57
|
-
|
|
50
|
+
messages: DataManager.messages.latest,
|
|
51
|
+
messageVersion: 'latest',
|
|
58
52
|
};
|
|
59
53
|
};
|
|
60
54
|
|
|
@@ -74,11 +68,7 @@ export const supportNewPassphrase = (features?: Features): SupportFeatureType =>
|
|
|
74
68
|
if (!features) return { support: false };
|
|
75
69
|
|
|
76
70
|
const deviceType = getDeviceType(features);
|
|
77
|
-
if (
|
|
78
|
-
deviceType === EDeviceType.Touch ||
|
|
79
|
-
deviceType === EDeviceType.Pro ||
|
|
80
|
-
deviceType === EDeviceType.Pro2
|
|
81
|
-
) {
|
|
71
|
+
if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
|
|
82
72
|
return { support: true };
|
|
83
73
|
}
|
|
84
74
|
|
|
@@ -92,13 +82,10 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
92
82
|
options?: {
|
|
93
83
|
expectPassphraseState?: string;
|
|
94
84
|
onlyMainPin?: boolean;
|
|
95
|
-
allowCreateAttachPin?: boolean;
|
|
96
85
|
}
|
|
97
86
|
) => {
|
|
98
87
|
const { features, commands } = device;
|
|
99
88
|
const locked = features?.unlocked === false;
|
|
100
|
-
const deviceType = getDeviceType(features);
|
|
101
|
-
const isPro2 = deviceType === EDeviceType.Pro2;
|
|
102
89
|
|
|
103
90
|
const { passphraseState, newSession, unlockedAttachPin } = await getPassphraseState(
|
|
104
91
|
features,
|
|
@@ -108,12 +95,12 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
108
95
|
}
|
|
109
96
|
);
|
|
110
97
|
|
|
111
|
-
const isModeT =
|
|
98
|
+
const isModeT =
|
|
99
|
+
getDeviceType(features) === EDeviceType.Touch || getDeviceType(features) === EDeviceType.Pro;
|
|
112
100
|
|
|
113
101
|
// 如果可以获取到 passphraseState,但是设备 features 显示设备未开启 passphrase,需要刷新设备状态
|
|
114
102
|
// if passphraseState can be obtained, but the device features show that the device has not enabled passphrase, the device status needs to be refreshed
|
|
115
|
-
const needRefreshWithPassphrase =
|
|
116
|
-
!isPro2 && passphraseState && features?.passphrase_protection !== true;
|
|
103
|
+
const needRefreshWithPassphrase = passphraseState && features?.passphrase_protection !== true;
|
|
117
104
|
// 如果 Touch/Pro 在之前是锁定状态,刷新设备状态
|
|
118
105
|
// if Touch/Pro was locked before, refresh the device state
|
|
119
106
|
const needRefreshWithLocked = isModeT && locked;
|
|
@@ -123,19 +110,10 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
123
110
|
await device.getFeatures();
|
|
124
111
|
}
|
|
125
112
|
|
|
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
|
-
|
|
135
113
|
// Attach to pin try to fix internal state
|
|
136
114
|
if (features?.device_id) {
|
|
137
115
|
device.updateInternalState(
|
|
138
|
-
|
|
116
|
+
device.features?.passphrase_protection ?? false,
|
|
139
117
|
passphraseState,
|
|
140
118
|
device.features?.device_id ?? '',
|
|
141
119
|
newSession,
|
|
@@ -152,7 +130,6 @@ export const getPassphraseState = async (
|
|
|
152
130
|
options?: {
|
|
153
131
|
expectPassphraseState?: string;
|
|
154
132
|
onlyMainPin?: boolean;
|
|
155
|
-
allowCreateAttachPin?: boolean;
|
|
156
133
|
}
|
|
157
134
|
): Promise<{
|
|
158
135
|
passphraseState: string | undefined;
|
|
@@ -171,23 +148,12 @@ export const getPassphraseState = async (
|
|
|
171
148
|
);
|
|
172
149
|
const supportGetPassphraseState =
|
|
173
150
|
supportAttachPinCapability ||
|
|
174
|
-
// Pro2 V2 暂未从 features 暴露 capabilities,先直连该方法用于固件联调。
|
|
175
|
-
deviceType === EDeviceType.Pro2 ||
|
|
176
151
|
(deviceType === EDeviceType.Pro && semver.gte(firmwareVersion.join('.'), '4.15.0'));
|
|
177
152
|
|
|
178
153
|
if (supportGetPassphraseState) {
|
|
179
|
-
const
|
|
180
|
-
?
|
|
181
|
-
|
|
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
|
-
);
|
|
154
|
+
const { message, type } = await commands.typedCall('GetPassphraseState', 'PassphraseState', {
|
|
155
|
+
passphrase_state: options?.onlyMainPin ? undefined : options?.expectPassphraseState,
|
|
156
|
+
});
|
|
191
157
|
|
|
192
158
|
// @ts-expect-error
|
|
193
159
|
if (type === 'CallMethodError') {
|
|
@@ -231,10 +197,7 @@ export const supportBatchPublicKey = (
|
|
|
231
197
|
|
|
232
198
|
const deviceType = getDeviceType(features);
|
|
233
199
|
// btc batch get public key
|
|
234
|
-
if (
|
|
235
|
-
!!options?.includeNode &&
|
|
236
|
-
(deviceType === EDeviceType.Pro || deviceType === EDeviceType.Pro2)
|
|
237
|
-
) {
|
|
200
|
+
if (!!options?.includeNode && deviceType === EDeviceType.Pro) {
|
|
238
201
|
return semver.gte(currentVersion, '4.14.0');
|
|
239
202
|
}
|
|
240
203
|
if (!!options?.includeNode && deviceType === EDeviceType.Touch) {
|
|
@@ -251,11 +214,7 @@ export const supportBatchPublicKey = (
|
|
|
251
214
|
}
|
|
252
215
|
|
|
253
216
|
// support batch get public key
|
|
254
|
-
if (
|
|
255
|
-
deviceType === EDeviceType.Touch ||
|
|
256
|
-
deviceType === EDeviceType.Pro ||
|
|
257
|
-
deviceType === EDeviceType.Pro2
|
|
258
|
-
) {
|
|
217
|
+
if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
|
|
259
218
|
return semver.gte(currentVersion, '3.1.0');
|
|
260
219
|
}
|
|
261
220
|
|
|
@@ -27,9 +27,6 @@ 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;
|
|
33
30
|
case 'PURE':
|
|
34
31
|
return EDeviceType.ClassicPure;
|
|
35
32
|
default:
|
|
@@ -71,14 +68,13 @@ export const getDeviceType = (features?: Features): IDeviceType => {
|
|
|
71
68
|
export const getDeviceTypeByBleName = (name?: string): IDeviceType => {
|
|
72
69
|
if (!name) return EDeviceType.Unknown;
|
|
73
70
|
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
71
|
+
if (name.startsWith('BixinKey')) return EDeviceType.Classic;
|
|
72
|
+
if (name.startsWith('K')) return EDeviceType.Classic;
|
|
76
73
|
|
|
77
|
-
if (
|
|
78
|
-
if (
|
|
74
|
+
if (name.startsWith('T')) return EDeviceType.Touch;
|
|
75
|
+
if (name.startsWith('Touch')) return EDeviceType.Touch;
|
|
79
76
|
|
|
80
|
-
if (
|
|
81
|
-
if (/\bPro\b/i.test(name) || /^Pro/i.test(name)) return EDeviceType.Pro;
|
|
77
|
+
if (name.startsWith('Pro')) return EDeviceType.Pro;
|
|
82
78
|
|
|
83
79
|
return EDeviceType.Unknown;
|
|
84
80
|
};
|
|
@@ -132,8 +128,8 @@ export const getMethodVersionRange = (
|
|
|
132
128
|
getVersionRange: (deviceModel: IDeviceType | IDeviceModel) => IVersionRange | undefined
|
|
133
129
|
): IVersionRange | undefined => {
|
|
134
130
|
const deviceType = getDeviceType(features);
|
|
131
|
+
let versionRange: IVersionRange | undefined = getVersionRange(deviceType);
|
|
135
132
|
|
|
136
|
-
const versionRange = getVersionRange(deviceType);
|
|
137
133
|
if (versionRange) {
|
|
138
134
|
return versionRange;
|
|
139
135
|
}
|
|
@@ -146,19 +142,16 @@ export const getMethodVersionRange = (
|
|
|
146
142
|
];
|
|
147
143
|
for (const model of modelFallbacks) {
|
|
148
144
|
if (DeviceModelToTypes[model].includes(deviceType)) {
|
|
149
|
-
|
|
145
|
+
versionRange = getVersionRange(model);
|
|
150
146
|
if (versionRange) {
|
|
151
147
|
return versionRange;
|
|
152
148
|
}
|
|
153
149
|
}
|
|
154
150
|
}
|
|
155
151
|
|
|
156
|
-
return
|
|
152
|
+
return versionRange;
|
|
157
153
|
};
|
|
158
154
|
|
|
159
|
-
export const isMethodVersionRangeUnsupported = (versionRange?: IVersionRange): boolean =>
|
|
160
|
-
versionRange?.unsupported === true;
|
|
161
|
-
|
|
162
155
|
export const getFirmwareType = (features: Features | undefined) => {
|
|
163
156
|
if (!features) {
|
|
164
157
|
return EFirmwareType.Universal;
|