@onekeyfe/hd-core 1.1.27-alpha.34 → 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 +998 -16134
- 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 +2 -18
- 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 -15
- 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 -1501
- 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/api/GetDeviceInfo.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import semver from 'semver';
|
|
2
|
-
import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
|
-
|
|
4
|
-
import { UI_REQUEST } from '../constants/ui-request';
|
|
5
|
-
import {
|
|
6
|
-
PROTOCOL_V2_DEVICE_INFO_REQUEST,
|
|
7
|
-
normalizeProtocolV2Features,
|
|
8
|
-
} from '../protocols/protocol-v2';
|
|
9
|
-
import { getDeviceType } from '../utils';
|
|
10
|
-
import { fixVersion } from '../utils/deviceFeaturesUtils';
|
|
11
|
-
import { buildUnifiedDeviceInfo } from './helpers/deviceInfo';
|
|
12
|
-
import { BaseMethod } from './BaseMethod';
|
|
13
|
-
|
|
14
|
-
import type {
|
|
15
|
-
DeviceInfoScope,
|
|
16
|
-
DeviceInfoSource,
|
|
17
|
-
GetDeviceInfoParams,
|
|
18
|
-
} from '../types/api/getDeviceInfo';
|
|
19
|
-
import type { Features, OnekeyFeatures } from '../types';
|
|
20
|
-
import type { ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
21
|
-
|
|
22
|
-
const DEVICE_INFO_SCOPES: readonly DeviceInfoScope[] = ['basic', 'versions', 'verify', 'full'];
|
|
23
|
-
|
|
24
|
-
function isDeviceInfoScope(scope: unknown): scope is DeviceInfoScope {
|
|
25
|
-
return typeof scope === 'string' && DEVICE_INFO_SCOPES.includes(scope as DeviceInfoScope);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function normalizeScope(scope: unknown): GetDeviceInfoParams['scope'] {
|
|
29
|
-
if (scope === undefined || scope === null) return 'basic';
|
|
30
|
-
if (isDeviceInfoScope(scope)) {
|
|
31
|
-
return scope;
|
|
32
|
-
}
|
|
33
|
-
throw ERRORS.TypedError(
|
|
34
|
-
HardwareErrorCode.CallMethodInvalidParameter,
|
|
35
|
-
`Invalid getDeviceInfo scope: ${String(scope)}`
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function shouldReadProtocolV2DeviceInfo(params: GetDeviceInfoParams) {
|
|
40
|
-
return (
|
|
41
|
-
params.refresh === true ||
|
|
42
|
-
params.includeRaw === true ||
|
|
43
|
-
params.scope === 'verify' ||
|
|
44
|
-
params.scope === 'full'
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function shouldReadOnekeyFeatures(params: GetDeviceInfoParams) {
|
|
49
|
-
return (
|
|
50
|
-
params.includeRaw === true ||
|
|
51
|
-
params.scope === 'versions' ||
|
|
52
|
-
params.scope === 'verify' ||
|
|
53
|
-
params.scope === 'full'
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function supportOnekeyFeatures(features?: Features) {
|
|
58
|
-
if (!features || features.bootloader_mode) return false;
|
|
59
|
-
|
|
60
|
-
const deviceType = getDeviceType(features);
|
|
61
|
-
return ![
|
|
62
|
-
EDeviceType.Unknown,
|
|
63
|
-
EDeviceType.Classic1s,
|
|
64
|
-
EDeviceType.ClassicPure,
|
|
65
|
-
EDeviceType.Pro2,
|
|
66
|
-
].includes(deviceType);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function normalizeOnekeyFeatures(message: OnekeyFeatures) {
|
|
70
|
-
if (message.onekey_firmware_version && !semver.valid(message.onekey_firmware_version)) {
|
|
71
|
-
message.onekey_firmware_version = fixVersion(message.onekey_firmware_version);
|
|
72
|
-
}
|
|
73
|
-
return message;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default class GetDeviceInfo extends BaseMethod<GetDeviceInfoParams> {
|
|
77
|
-
init() {
|
|
78
|
-
this.allowDeviceMode = [
|
|
79
|
-
...this.allowDeviceMode,
|
|
80
|
-
UI_REQUEST.NOT_INITIALIZE,
|
|
81
|
-
UI_REQUEST.BOOTLOADER,
|
|
82
|
-
];
|
|
83
|
-
this.useDevicePassphraseState = false;
|
|
84
|
-
this.skipForceUpdateCheck = true;
|
|
85
|
-
this.params = {
|
|
86
|
-
scope: normalizeScope(this.payload.scope),
|
|
87
|
-
refresh: this.payload.refresh,
|
|
88
|
-
includeRaw: this.payload.includeRaw,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async run() {
|
|
93
|
-
if (this.device.originalDescriptor?.protocolType === 'V2') {
|
|
94
|
-
return this.runProtocolV2();
|
|
95
|
-
}
|
|
96
|
-
return this.runProtocolV1();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private async runProtocolV2() {
|
|
100
|
-
const sources: DeviceInfoSource[] = ['features'];
|
|
101
|
-
let { features } = this.device;
|
|
102
|
-
let protocolV2DeviceInfo: ProtocolV2DeviceInfo | undefined;
|
|
103
|
-
|
|
104
|
-
if (shouldReadProtocolV2DeviceInfo(this.params)) {
|
|
105
|
-
const { message } = await this.device.commands.typedCall(
|
|
106
|
-
'DeviceGetDeviceInfo',
|
|
107
|
-
'DeviceInfo',
|
|
108
|
-
PROTOCOL_V2_DEVICE_INFO_REQUEST
|
|
109
|
-
);
|
|
110
|
-
protocolV2DeviceInfo = message as unknown as ProtocolV2DeviceInfo;
|
|
111
|
-
features = normalizeProtocolV2Features(this.device.originalDescriptor, protocolV2DeviceInfo);
|
|
112
|
-
this.device._updateFeatures(features);
|
|
113
|
-
sources.push('deviceGetDeviceInfo');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return buildUnifiedDeviceInfo({
|
|
117
|
-
protocol: 'V2',
|
|
118
|
-
features,
|
|
119
|
-
protocolV2DeviceInfo,
|
|
120
|
-
sources,
|
|
121
|
-
scope: this.params.scope,
|
|
122
|
-
includeRaw: this.params.includeRaw,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private async runProtocolV1() {
|
|
127
|
-
if (this.params.refresh === true) {
|
|
128
|
-
await this.device.getFeatures();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const sources: DeviceInfoSource[] = ['features'];
|
|
132
|
-
const { features } = this.device;
|
|
133
|
-
let onekeyFeatures: OnekeyFeatures | undefined;
|
|
134
|
-
|
|
135
|
-
if (shouldReadOnekeyFeatures(this.params) && supportOnekeyFeatures(features)) {
|
|
136
|
-
const { message } = await this.device.commands.typedCall(
|
|
137
|
-
'OnekeyGetFeatures',
|
|
138
|
-
'OnekeyFeatures'
|
|
139
|
-
);
|
|
140
|
-
onekeyFeatures = normalizeOnekeyFeatures(message);
|
|
141
|
-
sources.push('onekeyFeatures');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return buildUnifiedDeviceInfo({
|
|
145
|
-
protocol: 'V1',
|
|
146
|
-
features,
|
|
147
|
-
onekeyFeatures,
|
|
148
|
-
sources,
|
|
149
|
-
scope: this.params.scope,
|
|
150
|
-
includeRaw: this.params.includeRaw,
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
package/src/api/PathInfo.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from './BaseMethod';
|
|
2
|
-
import { validateNonEmptyString } from './helpers/filesystemValidation';
|
|
3
|
-
|
|
4
|
-
export type PathInfoParams = {
|
|
5
|
-
path: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export default class PathInfo extends BaseMethod<PathInfoParams> {
|
|
9
|
-
init() {
|
|
10
|
-
this.skipForceUpdateCheck = true;
|
|
11
|
-
this.useDevicePassphraseState = false;
|
|
12
|
-
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async run() {
|
|
16
|
-
const res = await this.device.commands.typedCall(
|
|
17
|
-
'FilesystemPathInfoQuery',
|
|
18
|
-
'FilesystemPathInfo',
|
|
19
|
-
{
|
|
20
|
-
path: this.params.path,
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
return Promise.resolve(res.message);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDeviceBLEFirmwareVersion,
|
|
3
|
-
getDeviceBleName,
|
|
4
|
-
getDeviceBoardloaderVersion,
|
|
5
|
-
getDeviceBootloaderVersion,
|
|
6
|
-
getDeviceFirmwareVersion,
|
|
7
|
-
getDeviceLabel,
|
|
8
|
-
getDeviceType,
|
|
9
|
-
getDeviceUUID,
|
|
10
|
-
getFirmwareType,
|
|
11
|
-
} from '../../utils';
|
|
12
|
-
|
|
13
|
-
import type {
|
|
14
|
-
DeviceInfoProtocol,
|
|
15
|
-
DeviceInfoSource,
|
|
16
|
-
DeviceInfoStatus,
|
|
17
|
-
GetDeviceInfoParams,
|
|
18
|
-
UnifiedDeviceInfo,
|
|
19
|
-
UnifiedDeviceInfoRaw,
|
|
20
|
-
UnifiedDeviceInfoVerify,
|
|
21
|
-
UnifiedDeviceInfoVersions,
|
|
22
|
-
} from '../../types/api/getDeviceInfo';
|
|
23
|
-
import type { Features, OnekeyFeatures } from '../../types';
|
|
24
|
-
import type { ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
25
|
-
|
|
26
|
-
type BuildDeviceInfoParams = {
|
|
27
|
-
protocol: DeviceInfoProtocol;
|
|
28
|
-
features?: Features;
|
|
29
|
-
onekeyFeatures?: OnekeyFeatures;
|
|
30
|
-
protocolV2DeviceInfo?: ProtocolV2DeviceInfo;
|
|
31
|
-
sources: DeviceInfoSource[];
|
|
32
|
-
scope?: GetDeviceInfoParams['scope'];
|
|
33
|
-
includeRaw?: boolean;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const isMeaningfulVersion = (version?: string | null) => Boolean(version && version !== '0.0.0');
|
|
37
|
-
|
|
38
|
-
const versionArrayToString = (version?: Array<number | string | null> | null) => {
|
|
39
|
-
if (!version || version.length === 0) return null;
|
|
40
|
-
const value = version.join('.');
|
|
41
|
-
return isMeaningfulVersion(value) ? value : null;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const firstVersion = (...versions: Array<string | null | undefined>) =>
|
|
45
|
-
versions.find(isMeaningfulVersion) ?? null;
|
|
46
|
-
|
|
47
|
-
const safeGetDeviceUUID = (features?: Features) => (features ? getDeviceUUID(features) : '');
|
|
48
|
-
|
|
49
|
-
const shouldIncludeVerify = (scope?: GetDeviceInfoParams['scope']) =>
|
|
50
|
-
scope === 'verify' || scope === 'full';
|
|
51
|
-
|
|
52
|
-
const getDeviceMode = (features?: Features): DeviceInfoStatus['mode'] => {
|
|
53
|
-
if (!features) return 'unknown';
|
|
54
|
-
if (features.bootloader_mode === true) return 'bootloader';
|
|
55
|
-
if (features.initialized === false) return 'notInitialized';
|
|
56
|
-
if (features.initialized === true) return 'normal';
|
|
57
|
-
return 'unknown';
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const normalizeVersions = (
|
|
61
|
-
features?: Features,
|
|
62
|
-
onekeyFeatures?: OnekeyFeatures
|
|
63
|
-
): UnifiedDeviceInfoVersions => ({
|
|
64
|
-
firmware: firstVersion(
|
|
65
|
-
onekeyFeatures?.onekey_firmware_version,
|
|
66
|
-
versionArrayToString(getDeviceFirmwareVersion(features))
|
|
67
|
-
),
|
|
68
|
-
bootloader: firstVersion(
|
|
69
|
-
onekeyFeatures?.onekey_boot_version,
|
|
70
|
-
versionArrayToString(getDeviceBootloaderVersion(features))
|
|
71
|
-
),
|
|
72
|
-
board: firstVersion(
|
|
73
|
-
onekeyFeatures?.onekey_board_version,
|
|
74
|
-
versionArrayToString(features ? getDeviceBoardloaderVersion(features) : undefined)
|
|
75
|
-
),
|
|
76
|
-
ble: firstVersion(
|
|
77
|
-
onekeyFeatures?.onekey_ble_version,
|
|
78
|
-
features?.onekey_ble_version,
|
|
79
|
-
features?.ble_ver,
|
|
80
|
-
versionArrayToString(features ? getDeviceBLEFirmwareVersion(features) : undefined)
|
|
81
|
-
),
|
|
82
|
-
se01: firstVersion(onekeyFeatures?.onekey_se01_version, features?.onekey_se01_version),
|
|
83
|
-
se02: firstVersion(onekeyFeatures?.onekey_se02_version, features?.onekey_se02_version),
|
|
84
|
-
se03: firstVersion(onekeyFeatures?.onekey_se03_version, features?.onekey_se03_version),
|
|
85
|
-
se04: firstVersion(onekeyFeatures?.onekey_se04_version, features?.onekey_se04_version),
|
|
86
|
-
se01Boot: firstVersion(
|
|
87
|
-
onekeyFeatures?.onekey_se01_boot_version,
|
|
88
|
-
features?.onekey_se01_boot_version
|
|
89
|
-
),
|
|
90
|
-
se02Boot: firstVersion(
|
|
91
|
-
onekeyFeatures?.onekey_se02_boot_version,
|
|
92
|
-
features?.onekey_se02_boot_version
|
|
93
|
-
),
|
|
94
|
-
se03Boot: firstVersion(
|
|
95
|
-
onekeyFeatures?.onekey_se03_boot_version,
|
|
96
|
-
features?.onekey_se03_boot_version
|
|
97
|
-
),
|
|
98
|
-
se04Boot: firstVersion(
|
|
99
|
-
onekeyFeatures?.onekey_se04_boot_version,
|
|
100
|
-
features?.onekey_se04_boot_version
|
|
101
|
-
),
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const normalizeStatus = (protocol: DeviceInfoProtocol, features?: Features): DeviceInfoStatus => ({
|
|
105
|
-
mode: getDeviceMode(features),
|
|
106
|
-
initialized: features?.initialized ?? null,
|
|
107
|
-
bootloaderMode: features?.bootloader_mode ?? null,
|
|
108
|
-
unlocked: protocol === 'V2' ? null : features?.unlocked ?? null,
|
|
109
|
-
passphraseProtection: features?.passphrase_protection ?? null,
|
|
110
|
-
backupRequired: features?.needs_backup ?? null,
|
|
111
|
-
language: features?.language ?? null,
|
|
112
|
-
bleEnabled: (features as { ble_enable?: boolean } | undefined)?.ble_enable ?? null,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const normalizeVerify = (
|
|
116
|
-
features?: Features,
|
|
117
|
-
onekeyFeatures?: OnekeyFeatures
|
|
118
|
-
): UnifiedDeviceInfoVerify => {
|
|
119
|
-
const featureRecord = features as Record<string, string | undefined> | undefined;
|
|
120
|
-
return {
|
|
121
|
-
firmwareBuildId: onekeyFeatures?.onekey_firmware_build_id ?? features?.onekey_firmware_build_id,
|
|
122
|
-
firmwareHash: onekeyFeatures?.onekey_firmware_hash ?? features?.onekey_firmware_hash,
|
|
123
|
-
bootloaderBuildId: onekeyFeatures?.onekey_boot_build_id ?? features?.onekey_boot_build_id,
|
|
124
|
-
bootloaderHash: onekeyFeatures?.onekey_boot_hash ?? features?.onekey_boot_hash,
|
|
125
|
-
boardBuildId: onekeyFeatures?.onekey_board_build_id ?? featureRecord?.onekey_board_build_id,
|
|
126
|
-
boardHash: onekeyFeatures?.onekey_board_hash ?? features?.onekey_board_hash,
|
|
127
|
-
bleBuildId: onekeyFeatures?.onekey_ble_build_id ?? features?.onekey_ble_build_id,
|
|
128
|
-
bleHash: onekeyFeatures?.onekey_ble_hash ?? features?.onekey_ble_hash,
|
|
129
|
-
se01BuildId: onekeyFeatures?.onekey_se01_build_id ?? features?.onekey_se01_build_id,
|
|
130
|
-
se01Hash: onekeyFeatures?.onekey_se01_hash ?? featureRecord?.onekey_se01_hash,
|
|
131
|
-
se02BuildId: onekeyFeatures?.onekey_se02_build_id ?? featureRecord?.onekey_se02_build_id,
|
|
132
|
-
se02Hash: onekeyFeatures?.onekey_se02_hash ?? featureRecord?.onekey_se02_hash,
|
|
133
|
-
se03BuildId: onekeyFeatures?.onekey_se03_build_id ?? featureRecord?.onekey_se03_build_id,
|
|
134
|
-
se03Hash: onekeyFeatures?.onekey_se03_hash ?? featureRecord?.onekey_se03_hash,
|
|
135
|
-
se04BuildId: onekeyFeatures?.onekey_se04_build_id ?? featureRecord?.onekey_se04_build_id,
|
|
136
|
-
se04Hash: onekeyFeatures?.onekey_se04_hash ?? featureRecord?.onekey_se04_hash,
|
|
137
|
-
se01BootBuildId:
|
|
138
|
-
onekeyFeatures?.onekey_se01_boot_build_id ?? features?.onekey_se01_boot_build_id,
|
|
139
|
-
se01BootHash: onekeyFeatures?.onekey_se01_boot_hash ?? features?.onekey_se01_boot_hash,
|
|
140
|
-
se02BootBuildId:
|
|
141
|
-
onekeyFeatures?.onekey_se02_boot_build_id ?? features?.onekey_se02_boot_build_id,
|
|
142
|
-
se02BootHash: onekeyFeatures?.onekey_se02_boot_hash ?? features?.onekey_se02_boot_hash,
|
|
143
|
-
se03BootBuildId:
|
|
144
|
-
onekeyFeatures?.onekey_se03_boot_build_id ?? features?.onekey_se03_boot_build_id,
|
|
145
|
-
se03BootHash: onekeyFeatures?.onekey_se03_boot_hash ?? features?.onekey_se03_boot_hash,
|
|
146
|
-
se04BootBuildId:
|
|
147
|
-
onekeyFeatures?.onekey_se04_boot_build_id ?? features?.onekey_se04_boot_build_id,
|
|
148
|
-
se04BootHash: onekeyFeatures?.onekey_se04_boot_hash ?? features?.onekey_se04_boot_hash,
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const normalizeRaw = ({
|
|
153
|
-
features,
|
|
154
|
-
onekeyFeatures,
|
|
155
|
-
protocolV2DeviceInfo,
|
|
156
|
-
}: Pick<
|
|
157
|
-
BuildDeviceInfoParams,
|
|
158
|
-
'features' | 'onekeyFeatures' | 'protocolV2DeviceInfo'
|
|
159
|
-
>): UnifiedDeviceInfoRaw => ({
|
|
160
|
-
...(features ? { features } : {}),
|
|
161
|
-
...(onekeyFeatures ? { onekeyFeatures } : {}),
|
|
162
|
-
...(protocolV2DeviceInfo ? { protocolV2DeviceInfo } : {}),
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
export function buildUnifiedDeviceInfo({
|
|
166
|
-
protocol,
|
|
167
|
-
features,
|
|
168
|
-
onekeyFeatures,
|
|
169
|
-
protocolV2DeviceInfo,
|
|
170
|
-
sources,
|
|
171
|
-
scope = 'basic',
|
|
172
|
-
includeRaw = false,
|
|
173
|
-
}: BuildDeviceInfoParams): UnifiedDeviceInfo {
|
|
174
|
-
const mergedFeatures = {
|
|
175
|
-
...(features ?? {}),
|
|
176
|
-
...(onekeyFeatures ?? {}),
|
|
177
|
-
} as Features;
|
|
178
|
-
const hasFeatures = Boolean(features || onekeyFeatures);
|
|
179
|
-
const sourceFeatures = hasFeatures ? mergedFeatures : undefined;
|
|
180
|
-
const deviceType = getDeviceType(sourceFeatures);
|
|
181
|
-
const verify = normalizeVerify(sourceFeatures, onekeyFeatures);
|
|
182
|
-
|
|
183
|
-
return {
|
|
184
|
-
protocol,
|
|
185
|
-
sources,
|
|
186
|
-
deviceType,
|
|
187
|
-
firmwareType: getFirmwareType(sourceFeatures),
|
|
188
|
-
deviceId: sourceFeatures?.device_id || safeGetDeviceUUID(sourceFeatures),
|
|
189
|
-
serialNo: safeGetDeviceUUID(sourceFeatures),
|
|
190
|
-
label: getDeviceLabel(sourceFeatures),
|
|
191
|
-
bleName: getDeviceBleName(sourceFeatures),
|
|
192
|
-
status: normalizeStatus(protocol, sourceFeatures),
|
|
193
|
-
versions: normalizeVersions(sourceFeatures, onekeyFeatures),
|
|
194
|
-
...(shouldIncludeVerify(scope) ? { verify } : {}),
|
|
195
|
-
...(includeRaw
|
|
196
|
-
? {
|
|
197
|
-
raw: normalizeRaw({
|
|
198
|
-
features,
|
|
199
|
-
onekeyFeatures,
|
|
200
|
-
protocolV2DeviceInfo,
|
|
201
|
-
}),
|
|
202
|
-
}
|
|
203
|
-
: {}),
|
|
204
|
-
};
|
|
205
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
-
|
|
3
|
-
export const invalidParameter = (message: string) =>
|
|
4
|
-
ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
5
|
-
|
|
6
|
-
export function validateNonEmptyString(value: unknown, name: string): string {
|
|
7
|
-
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
8
|
-
throw invalidParameter(`Parameter [${name}] is required and must be a non-empty string.`);
|
|
9
|
-
}
|
|
10
|
-
return value;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function validateNonNegativeInteger(
|
|
14
|
-
value: unknown,
|
|
15
|
-
name: string,
|
|
16
|
-
defaultValue?: number
|
|
17
|
-
): number {
|
|
18
|
-
if (value === undefined || value === null) {
|
|
19
|
-
if (defaultValue !== undefined) return defaultValue;
|
|
20
|
-
throw invalidParameter(`Missing required parameter: ${name}`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const numeric = typeof value === 'string' && value.trim() !== '' ? Number(value) : value;
|
|
24
|
-
if (typeof numeric !== 'number' || !Number.isSafeInteger(numeric) || numeric < 0) {
|
|
25
|
-
throw invalidParameter(`Parameter [${name}] must be a non-negative integer.`);
|
|
26
|
-
}
|
|
27
|
-
return numeric;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function validateOptionalNonNegativeInteger(
|
|
31
|
-
value: unknown,
|
|
32
|
-
name: string
|
|
33
|
-
): number | undefined {
|
|
34
|
-
if (value === undefined || value === null) return undefined;
|
|
35
|
-
return validateNonNegativeInteger(value, name);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function validateOptionalPercentage(value: unknown, name: string): number | undefined {
|
|
39
|
-
const numeric = validateOptionalNonNegativeInteger(value, name);
|
|
40
|
-
if (numeric === undefined) return undefined;
|
|
41
|
-
if (numeric > 100) {
|
|
42
|
-
throw invalidParameter(`Parameter [${name}] must be between 0 and 100.`);
|
|
43
|
-
}
|
|
44
|
-
return numeric;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function validateRequiredData(value: unknown, name: string): void {
|
|
48
|
-
if (value === undefined || value === null) {
|
|
49
|
-
throw invalidParameter(`Missing required parameter: ${name}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import {
|
|
3
|
-
PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS,
|
|
4
|
-
PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES,
|
|
5
|
-
normalizeFirmwareTargets,
|
|
6
|
-
} from './helpers';
|
|
7
|
-
import { UI_REQUEST, createUiMessage } from '../../events/ui-request';
|
|
8
|
-
import type { KnownDevice } from '../../types';
|
|
9
|
-
|
|
10
|
-
import type { DeviceFirmwareUpdateParams } from './helpers';
|
|
11
|
-
|
|
12
|
-
export default class DeviceFirmwareUpdate extends BaseMethod<DeviceFirmwareUpdateParams> {
|
|
13
|
-
init() {
|
|
14
|
-
this.skipForceUpdateCheck = true;
|
|
15
|
-
this.useDevicePassphraseState = false;
|
|
16
|
-
this.params = {
|
|
17
|
-
targets: this.payload.targets,
|
|
18
|
-
targetId: this.payload.targetId,
|
|
19
|
-
target_id: this.payload.target_id,
|
|
20
|
-
path: this.payload.path,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async run() {
|
|
25
|
-
const targets = normalizeFirmwareTargets(this.params);
|
|
26
|
-
const res = await this.device.commands.typedCall(
|
|
27
|
-
'DeviceFirmwareUpdate',
|
|
28
|
-
PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES,
|
|
29
|
-
{
|
|
30
|
-
targets,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
...PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS,
|
|
34
|
-
onIntermediateResponse: response => {
|
|
35
|
-
if (response.type !== 'DeviceFirmwareInstallProgress') return;
|
|
36
|
-
const progress = Number(response.message?.progress);
|
|
37
|
-
if (!Number.isFinite(progress)) return;
|
|
38
|
-
this.postMessage(
|
|
39
|
-
createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
|
|
40
|
-
device: this.device.toMessageObject() as KnownDevice,
|
|
41
|
-
progress: Math.min(Math.max(progress, 0), 100),
|
|
42
|
-
progressType: 'installingFirmware',
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
return Promise.resolve(res.message);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import { buildTargets, buildTypes } from './helpers';
|
|
3
|
-
|
|
4
|
-
import type { DeviceGetDeviceInfoParams } from './helpers';
|
|
5
|
-
|
|
6
|
-
export default class DeviceGetDeviceInfo extends BaseMethod<DeviceGetDeviceInfoParams> {
|
|
7
|
-
init() {
|
|
8
|
-
this.skipForceUpdateCheck = true;
|
|
9
|
-
this.useDevicePassphraseState = false;
|
|
10
|
-
this.params = {
|
|
11
|
-
targets: this.payload.targets,
|
|
12
|
-
types: this.payload.types,
|
|
13
|
-
targetHw: this.payload.targetHw,
|
|
14
|
-
targetFw: this.payload.targetFw,
|
|
15
|
-
targetBt: this.payload.targetBt,
|
|
16
|
-
targetSe1: this.payload.targetSe1,
|
|
17
|
-
targetSe2: this.payload.targetSe2,
|
|
18
|
-
targetSe3: this.payload.targetSe3,
|
|
19
|
-
targetSe4: this.payload.targetSe4,
|
|
20
|
-
targetStatus: this.payload.targetStatus,
|
|
21
|
-
includeVersion: this.payload.includeVersion,
|
|
22
|
-
includeBuildId: this.payload.includeBuildId,
|
|
23
|
-
includeHash: this.payload.includeHash,
|
|
24
|
-
includeSpecific: this.payload.includeSpecific,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async run() {
|
|
29
|
-
const res = await this.device.commands.typedCall('DeviceGetDeviceInfo', 'DeviceInfo', {
|
|
30
|
-
targets: buildTargets(this.params),
|
|
31
|
-
types: buildTypes(this.params),
|
|
32
|
-
});
|
|
33
|
-
return Promise.resolve(res.message);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
|
|
3
|
-
export default class DeviceGetFirmwareUpdateStatus extends BaseMethod {
|
|
4
|
-
init() {
|
|
5
|
-
this.skipForceUpdateCheck = true;
|
|
6
|
-
this.useDevicePassphraseState = false;
|
|
7
|
-
this.params = undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run() {
|
|
11
|
-
const res = await this.device.commands.typedCall(
|
|
12
|
-
'DeviceGetFirmwareUpdateStatus',
|
|
13
|
-
'DeviceFirmwareUpdateStatus',
|
|
14
|
-
{}
|
|
15
|
-
);
|
|
16
|
-
return Promise.resolve(res.message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
|
|
3
|
-
export default class DeviceGetOnboardingStatus extends BaseMethod {
|
|
4
|
-
init() {
|
|
5
|
-
this.skipForceUpdateCheck = true;
|
|
6
|
-
this.useDevicePassphraseState = false;
|
|
7
|
-
this.params = undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run() {
|
|
11
|
-
const res = await this.device.commands.typedCall(
|
|
12
|
-
'DeviceGetOnboardingStatus',
|
|
13
|
-
'DeviceOnboardingStatus',
|
|
14
|
-
{}
|
|
15
|
-
);
|
|
16
|
-
return Promise.resolve(res.message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import { normalizeRebootType } from './helpers';
|
|
3
|
-
|
|
4
|
-
import type { DeviceRebootParams } from './helpers';
|
|
5
|
-
|
|
6
|
-
export default class DeviceReboot extends BaseMethod<DeviceRebootParams> {
|
|
7
|
-
init() {
|
|
8
|
-
this.skipForceUpdateCheck = true;
|
|
9
|
-
this.useDevicePassphraseState = false;
|
|
10
|
-
this.params = {
|
|
11
|
-
rebootType: this.payload.rebootType,
|
|
12
|
-
reboot_type: this.payload.reboot_type,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async run() {
|
|
17
|
-
const res = await this.device.commands.typedCall('DeviceReboot', 'Success', {
|
|
18
|
-
reboot_type: normalizeRebootType(this.params.reboot_type ?? this.params.rebootType),
|
|
19
|
-
});
|
|
20
|
-
return Promise.resolve(res.message);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
|
|
3
|
-
import type { FactoryDeviceInfoSettingsParams } from './helpers';
|
|
4
|
-
|
|
5
|
-
export default class FactoryDeviceInfoSettings extends BaseMethod<FactoryDeviceInfoSettingsParams> {
|
|
6
|
-
init() {
|
|
7
|
-
this.skipForceUpdateCheck = true;
|
|
8
|
-
this.useDevicePassphraseState = false;
|
|
9
|
-
this.params = {
|
|
10
|
-
serial_no: this.payload.serial_no,
|
|
11
|
-
serialNo: this.payload.serialNo,
|
|
12
|
-
cpu_info: this.payload.cpu_info,
|
|
13
|
-
cpuInfo: this.payload.cpuInfo,
|
|
14
|
-
pre_firmware: this.payload.pre_firmware,
|
|
15
|
-
preFirmware: this.payload.preFirmware,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async run() {
|
|
20
|
-
const res = await this.device.commands.typedCall('FactoryDeviceInfoSettings', 'Success', {
|
|
21
|
-
serial_no: this.params.serial_no ?? this.params.serialNo,
|
|
22
|
-
cpu_info: this.params.cpu_info ?? this.params.cpuInfo,
|
|
23
|
-
pre_firmware: this.params.pre_firmware ?? this.params.preFirmware,
|
|
24
|
-
});
|
|
25
|
-
return Promise.resolve(res.message);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
|
|
3
|
-
export default class FactoryGetDeviceInfo extends BaseMethod {
|
|
4
|
-
init() {
|
|
5
|
-
this.skipForceUpdateCheck = true;
|
|
6
|
-
this.useDevicePassphraseState = false;
|
|
7
|
-
this.params = undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run() {
|
|
11
|
-
const res = await this.device.commands.typedCall(
|
|
12
|
-
'FactoryGetDeviceInfo',
|
|
13
|
-
'FactoryDeviceInfo',
|
|
14
|
-
{}
|
|
15
|
-
);
|
|
16
|
-
return Promise.resolve(res.message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import {
|
|
3
|
-
validateNonNegativeInteger,
|
|
4
|
-
validateOptionalNonNegativeInteger,
|
|
5
|
-
} from '../helpers/filesystemValidation';
|
|
6
|
-
|
|
7
|
-
export type FilesystemDiskControlParams = {
|
|
8
|
-
enable?: number | string;
|
|
9
|
-
timeoutMs?: number | string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default class FilesystemDiskControl extends BaseMethod<FilesystemDiskControlParams> {
|
|
13
|
-
init() {
|
|
14
|
-
this.skipForceUpdateCheck = true;
|
|
15
|
-
this.useDevicePassphraseState = false;
|
|
16
|
-
this.params = {
|
|
17
|
-
enable: validateNonNegativeInteger(this.payload.enable, 'enable', 0),
|
|
18
|
-
timeoutMs: validateOptionalNonNegativeInteger(this.payload.timeoutMs, 'timeoutMs'),
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async run() {
|
|
23
|
-
const timeoutMs = Number(this.params.timeoutMs);
|
|
24
|
-
const res = await this.device.commands.typedCall(
|
|
25
|
-
'FilesystemDiskControl',
|
|
26
|
-
'Success',
|
|
27
|
-
{
|
|
28
|
-
enable: Number(this.params.enable ?? 0),
|
|
29
|
-
},
|
|
30
|
-
Number.isFinite(timeoutMs) && timeoutMs > 0 ? { timeoutMs } : undefined
|
|
31
|
-
);
|
|
32
|
-
return Promise.resolve(res.message);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
|
|
3
|
-
export default class FilesystemFixPermission extends BaseMethod {
|
|
4
|
-
init() {
|
|
5
|
-
this.skipForceUpdateCheck = true;
|
|
6
|
-
this.useDevicePassphraseState = false;
|
|
7
|
-
this.params = undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run() {
|
|
11
|
-
const res = await this.device.commands.typedCall('FilesystemFixPermission', 'Success', {});
|
|
12
|
-
return Promise.resolve(res.message);
|
|
13
|
-
}
|
|
14
|
-
}
|