@onekeyfe/hd-core 1.1.28 → 1.2.0-alpha.1
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__/evmLedgerLegacySafety.test.ts +15 -4
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/logBlockEvent.test.ts +37 -0
- package/__tests__/protocol-v2.test.ts +2908 -0
- package/dist/api/BaseMethod.d.ts +1 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/DirList.d.ts +10 -0
- package/dist/api/DirList.d.ts.map +1 -0
- package/dist/api/DirMake.d.ts +9 -0
- package/dist/api/DirMake.d.ts.map +1 -0
- package/dist/api/DirRemove.d.ts +9 -0
- package/dist/api/DirRemove.d.ts.map +1 -0
- package/dist/api/FileDelete.d.ts +9 -0
- package/dist/api/FileDelete.d.ts.map +1 -0
- package/dist/api/FileRead.d.ts +19 -0
- package/dist/api/FileRead.d.ts.map +1 -0
- package/dist/api/FileWrite.d.ts +24 -0
- package/dist/api/FileWrite.d.ts.map +1 -0
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +1 -0
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +35 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -0
- package/dist/api/GetDeviceInfo.d.ts +9 -0
- package/dist/api/GetDeviceInfo.d.ts.map +1 -0
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +6 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/PathInfo.d.ts +10 -0
- package/dist/api/PathInfo.d.ts.map +1 -0
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +2 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumGetAddress.d.ts +2 -6
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts +2 -5
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts +5 -8
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts +2 -9
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts +2 -9
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts +2 -8
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts +2 -8
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -11
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -11
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -15
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -11
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -11
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -11
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.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/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -1
- package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceVerify.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -8
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/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/latest/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getAddress.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getPublicKey.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signMessage.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/evm/legacyV1/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/verifyMessage.d.ts.map +1 -1
- package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts +3 -0
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/helpers/filesystemValidation.d.ts +7 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
- package/dist/api/index.d.ts +32 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/lightning/LnurlAuth.d.ts +4 -0
- package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts +2 -8
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts +2 -8
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts +2 -9
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts +9 -12
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts +2 -8
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +2 -9
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +3 -0
- package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
- package/dist/api/polkadot/networks.d.ts +3 -0
- package/dist/api/polkadot/networks.d.ts.map +1 -1
- package/dist/api/protocol-v2/DevReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DevReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +29 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +7 -0
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +1 -0
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +6 -0
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +13 -0
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -0
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +6 -0
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +1 -0
- package/dist/api/protocol-v2/Ping.d.ts +8 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +33 -0
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -0
- package/dist/api/scdo/ScdoGetAddress.d.ts +2 -6
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts +2 -5
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts +2 -5
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts +1 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +3 -0
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +3 -0
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +6 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +2 -1
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +3 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +3 -0
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +3 -0
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +3 -0
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +5 -2
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +3 -0
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +5 -0
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +3 -0
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +3 -0
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +4 -0
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +4 -0
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/constants/index.d.ts +2 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +7 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +5 -4
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +33 -11
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +9 -9
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +2 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +6 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceProfile.d.ts +21 -0
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -0
- package/dist/deviceProfile/index.d.ts +3 -0
- package/dist/deviceProfile/index.d.ts.map +1 -0
- package/dist/events/logBlockEvent.d.ts +1 -0
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +8 -0
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +717 -302
- package/dist/index.js +17654 -1271
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +93 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/firmware.d.ts +13 -0
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/index.d.ts +4 -0
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +27 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getDeviceInfo.d.ts +85 -0
- package/dist/types/api/getDeviceInfo.d.ts.map +1 -0
- package/dist/types/api/getPassphraseState.d.ts +10 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +37 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +103 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -0
- package/dist/types/api/searchDevices.d.ts +2 -2
- package/dist/types/api/searchDevices.d.ts.map +1 -1
- package/dist/types/device.d.ts +91 -5
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +2 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +2 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/capabilitieUtils.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +6 -8
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +1 -0
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/findDefectiveBatchDevice.d.ts +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/package.json +4 -4
- package/src/api/BaseMethod.ts +26 -22
- package/src/api/DirList.ts +31 -0
- package/src/api/DirMake.ts +23 -0
- package/src/api/DirRemove.ts +23 -0
- package/src/api/FileDelete.ts +23 -0
- package/src/api/FileRead.ts +167 -0
- package/src/api/FileWrite.ts +216 -0
- package/src/api/FirmwareUpdate.ts +13 -5
- package/src/api/FirmwareUpdateV2.ts +22 -19
- package/src/api/FirmwareUpdateV3.ts +19 -5
- package/src/api/FirmwareUpdateV4.ts +820 -0
- package/src/api/GetDeviceInfo.ts +145 -0
- package/src/api/GetFeatures.ts +5 -2
- package/src/api/GetOnekeyFeatures.ts +84 -3
- package/src/api/GetPassphraseState.ts +16 -10
- package/src/api/PathInfo.ts +39 -0
- package/src/api/PromptWebDeviceAccess.ts +11 -1
- package/src/api/SearchDevices.ts +7 -2
- package/src/api/alephium/AlephiumGetAddress.ts +6 -2
- package/src/api/alephium/AlephiumSignMessage.ts +6 -1
- package/src/api/alephium/AlephiumSignTransaction.ts +15 -4
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +21 -13
- package/src/api/aptos/AptosGetAddress.ts +2 -3
- package/src/api/benfen/BenfenGetAddress.ts +11 -7
- package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
- package/src/api/benfen/BenfenSignMessage.ts +6 -1
- package/src/api/benfen/BenfenSignTransaction.ts +6 -1
- package/src/api/btc/BTCGetPublicKey.ts +3 -2
- package/src/api/btc/BTCSignPsbt.ts +1 -2
- package/src/api/btc/helpers/versionLimit.ts +7 -1
- package/src/api/cardano/CardanoSignTransaction.ts +2 -4
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
- package/src/api/device/DeviceFullyUploadResource.ts +3 -3
- package/src/api/device/DeviceLock.ts +1 -3
- package/src/api/device/DeviceRebootToBoardloader.ts +10 -1
- package/src/api/device/DeviceRebootToBootloader.ts +10 -1
- package/src/api/device/DeviceSupportFeatures.ts +2 -13
- package/src/api/device/DeviceUpdateBootloader.ts +4 -4
- package/src/api/device/DeviceUploadResource.ts +4 -5
- package/src/api/device/DeviceVerify.ts +1 -2
- package/src/api/dynex/DnxGetAddress.ts +6 -0
- package/src/api/dynex/DnxSignTransaction.ts +6 -0
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +3 -4
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +14 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +32 -18
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/evm/latest/signTypedHash.ts +2 -4
- package/src/api/evm/legacyV1/getAddress.ts +5 -3
- package/src/api/evm/legacyV1/getPublicKey.ts +5 -3
- package/src/api/evm/legacyV1/signMessage.ts +5 -3
- package/src/api/evm/legacyV1/signTypedData.ts +9 -8
- package/src/api/evm/legacyV1/signTypedHash.ts +7 -7
- package/src/api/evm/legacyV1/verifyMessage.ts +5 -3
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +8 -8
- package/src/api/firmware/bootloaderHelper.ts +3 -2
- package/src/api/firmware/getBinary.ts +1 -1
- package/src/api/firmware/releaseHelper.ts +3 -3
- package/src/api/firmware/uploadFirmware.ts +8 -12
- package/src/api/helpers/batchGetPublickeys.ts +51 -6
- package/src/api/helpers/filesystemValidation.ts +51 -0
- package/src/api/index.ts +34 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +4 -5
- package/src/api/lightning/LnurlAuth.ts +4 -0
- package/src/api/neo/NeoGetAddress.ts +6 -1
- package/src/api/neo/NeoSignTransaction.ts +6 -1
- package/src/api/nervos/NervosGetAddress.ts +6 -2
- package/src/api/nervos/NervosSignTransaction.ts +14 -4
- package/src/api/nexa/NexaGetAddress.ts +6 -2
- package/src/api/nexa/NexaSignTransaction.ts +11 -12
- package/src/api/polkadot/networks.ts +9 -0
- package/src/api/protocol-v2/DevReboot.ts +24 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +63 -0
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +118 -0
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +20 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +16 -0
- package/src/api/protocol-v2/DeviceReboot.ts +24 -0
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +29 -0
- package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +20 -0
- package/src/api/protocol-v2/FilesystemDiskControl.ts +50 -0
- package/src/api/protocol-v2/FilesystemFixPermission.ts +16 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +16 -0
- package/src/api/protocol-v2/GetProtoVersion.ts +16 -0
- package/src/api/protocol-v2/Ping.ts +18 -0
- package/src/api/protocol-v2/helpers.ts +182 -0
- package/src/api/scdo/ScdoGetAddress.ts +6 -2
- package/src/api/scdo/ScdoSignMessage.ts +6 -1
- package/src/api/scdo/ScdoSignTransaction.ts +6 -2
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +3 -0
- package/src/api/solana/SolSignOffchainMessage.ts +3 -0
- package/src/api/solana/SolSignTransaction.ts +6 -0
- package/src/api/stellar/StellarGetAddress.ts +10 -1
- package/src/api/stellar/StellarSignTransaction.ts +14 -1
- package/src/api/sui/SuiGetAddress.ts +5 -3
- package/src/api/sui/SuiGetPublicKey.ts +3 -0
- package/src/api/sui/SuiSignMessage.ts +3 -0
- package/src/api/sui/SuiSignTransaction.ts +14 -12
- package/src/api/ton/TonGetAddress.ts +3 -0
- package/src/api/ton/TonSignData.ts +10 -3
- package/src/api/ton/TonSignMessage.ts +6 -5
- package/src/api/ton/TonSignProof.ts +3 -0
- package/src/api/tron/TronSignMessage.ts +5 -1
- package/src/api/tron/TronSignTransaction.ts +4 -0
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/constants/index.ts +10 -1
- package/src/core/index.ts +91 -61
- package/src/data/messages/messages-protocol-v2.json +13375 -0
- package/src/data-manager/DataManager.ts +16 -11
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +38 -12
- package/src/data-manager/connectSettings.ts +6 -0
- package/src/device/Device.ts +398 -76
- package/src/device/DeviceCommands.ts +195 -29
- package/src/device/DeviceConnector.ts +29 -4
- package/src/device/DevicePool.ts +8 -8
- package/src/deviceProfile/buildDeviceFeatures.ts +368 -0
- package/src/deviceProfile/buildDeviceProfile.ts +333 -0
- package/src/deviceProfile/index.ts +5 -0
- package/src/events/logBlockEvent.ts +23 -0
- package/src/events/ui-request.ts +8 -0
- package/src/inject.ts +52 -1
- package/src/protocols/protocol-v2/features.ts +178 -0
- package/src/protocols/protocol-v2/firmware.ts +43 -0
- package/src/protocols/protocol-v2/index.ts +16 -0
- package/src/types/api/export.ts +1 -0
- package/src/types/api/firmwareUpdate.ts +49 -0
- package/src/types/api/getDeviceInfo.ts +99 -0
- package/src/types/api/getPassphraseState.ts +13 -2
- package/src/types/api/index.ts +88 -1
- package/src/types/api/protocolV2.ts +200 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/device.ts +102 -5
- package/src/types/params.ts +7 -0
- package/src/types/settings.ts +6 -1
- package/src/utils/capabilitieUtils.ts +1 -2
- package/src/utils/deviceFeaturesUtils.ts +75 -81
- package/src/utils/deviceInfoUtils.ts +23 -34
- package/src/utils/deviceVersionUtils.ts +7 -25
- package/src/utils/findDefectiveBatchDevice.ts +6 -6
- package/src/utils/index.ts +1 -0
|
@@ -5,8 +5,12 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
5
5
|
import { validateParams } from '../helpers/paramsValidator';
|
|
6
6
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
7
7
|
|
|
8
|
-
import type { NervosSignTransactionParams, NervosSignedTx } from '../../types';
|
|
9
|
-
import type {
|
|
8
|
+
import type { DeviceFirmwareRange, NervosSignTransactionParams, NervosSignedTx } from '../../types';
|
|
9
|
+
import type {
|
|
10
|
+
NervosSignTx as HardwareNervosSignTx,
|
|
11
|
+
NervosTxRequest,
|
|
12
|
+
TypedCall,
|
|
13
|
+
} from '@onekeyfe/hd-transport';
|
|
10
14
|
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
11
15
|
|
|
12
16
|
type NervosSignTx = Omit<HardwareNervosSignTx, 'data_initial_chunk' | 'data_length'> & {
|
|
@@ -41,8 +45,12 @@ export default class NervosSignTransaction extends BaseMethod<NervosSignTx> {
|
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
getVersionRange() {
|
|
48
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
45
49
|
return {
|
|
50
|
+
pro2: {
|
|
51
|
+
min: '0.0.0',
|
|
52
|
+
unsupported: true,
|
|
53
|
+
},
|
|
46
54
|
model_mini: {
|
|
47
55
|
min: '3.7.0',
|
|
48
56
|
},
|
|
@@ -59,7 +67,9 @@ export default class NervosSignTransaction extends BaseMethod<NervosSignTx> {
|
|
|
59
67
|
res: TypedResponseMessage<'NervosSignedTx'> | TypedResponseMessage<'NervosTxRequest'>,
|
|
60
68
|
data: Buffer,
|
|
61
69
|
offset = 0
|
|
62
|
-
|
|
70
|
+
// 设备可能在最后一个 NervosTxRequest(无 data_length)里返回签名,
|
|
71
|
+
// 该消息没有 address 字段,返回类型如实声明为联合类型
|
|
72
|
+
): Promise<NervosSignedTx | (NervosTxRequest & { path: string })> => {
|
|
63
73
|
if (res.type === 'NervosSignedTx') {
|
|
64
74
|
if (!res?.message?.signature) {
|
|
65
75
|
throw new Error('No signature returned');
|
|
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
4
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
5
5
|
|
|
6
6
|
import type { NexaGetAddress as HardwareNexaGetAddress } from '@onekeyfe/hd-transport';
|
|
7
|
-
import type { NexaGetAddressParams } from '../../types';
|
|
7
|
+
import type { DeviceFirmwareRange, NexaGetAddressParams } from '../../types';
|
|
8
8
|
|
|
9
9
|
export default class NexaGetAddress extends BaseMethod<HardwareNexaGetAddress[]> {
|
|
10
10
|
hasBundle = false;
|
|
@@ -43,8 +43,12 @@ export default class NexaGetAddress extends BaseMethod<HardwareNexaGetAddress[]>
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
getVersionRange() {
|
|
46
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
47
47
|
return {
|
|
48
|
+
pro2: {
|
|
49
|
+
min: '0.0.0',
|
|
50
|
+
unsupported: true,
|
|
51
|
+
},
|
|
48
52
|
model_mini: {
|
|
49
53
|
min: '3.2.0',
|
|
50
54
|
},
|
|
@@ -6,7 +6,7 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
6
6
|
|
|
7
7
|
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
8
8
|
import type { TypedCall } from '@onekeyfe/hd-transport';
|
|
9
|
-
import type { NexaSignTransactionParams, NexaSignature } from '../../types';
|
|
9
|
+
import type { DeviceFirmwareRange, NexaSignTransactionParams, NexaSignature } from '../../types';
|
|
10
10
|
|
|
11
11
|
export default class NexaSignTransaction extends BaseMethod<NexaSignTransactionParams> {
|
|
12
12
|
hasBundle = false;
|
|
@@ -27,8 +27,12 @@ export default class NexaSignTransaction extends BaseMethod<NexaSignTransactionP
|
|
|
27
27
|
this.params = payload;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
getVersionRange() {
|
|
30
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
31
31
|
return {
|
|
32
|
+
pro2: {
|
|
33
|
+
min: '0.0.0',
|
|
34
|
+
unsupported: true,
|
|
35
|
+
},
|
|
32
36
|
model_mini: {
|
|
33
37
|
min: '3.2.0',
|
|
34
38
|
},
|
|
@@ -68,17 +72,12 @@ export default class NexaSignTransaction extends BaseMethod<NexaSignTransactionP
|
|
|
68
72
|
|
|
69
73
|
const nextIndex = res.message.request_index;
|
|
70
74
|
const input = this.params.inputs[nextIndex];
|
|
71
|
-
const response = await typedCall(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
address_n: input.path,
|
|
77
|
-
raw_message: input.message,
|
|
78
|
-
}
|
|
79
|
-
);
|
|
75
|
+
const response = await typedCall('NexaTxInputAck', ['NexaTxInputRequest', 'NexaSignedTx'], {
|
|
76
|
+
// path 为字符串形式,归一为 address_n 数组(与 run() 中首个 input 的处理一致)
|
|
77
|
+
address_n: validatePath(input.path, 3),
|
|
78
|
+
raw_message: input.message,
|
|
79
|
+
});
|
|
80
80
|
|
|
81
|
-
// @ts-expect-error
|
|
82
81
|
return this.processTxRequest(typedCall, response, nextIndex, signatures);
|
|
83
82
|
}
|
|
84
83
|
|
|
@@ -23,6 +23,9 @@ const baseVersionRange = {
|
|
|
23
23
|
model_touch: {
|
|
24
24
|
min: '4.3.0',
|
|
25
25
|
},
|
|
26
|
+
pro2: {
|
|
27
|
+
min: '0.0.0',
|
|
28
|
+
},
|
|
26
29
|
};
|
|
27
30
|
|
|
28
31
|
const specialVersionRange: Record<string, DeviceFirmwareRange> = {
|
|
@@ -33,6 +36,9 @@ const specialVersionRange: Record<string, DeviceFirmwareRange> = {
|
|
|
33
36
|
model_touch: {
|
|
34
37
|
min: '4.7.0',
|
|
35
38
|
},
|
|
39
|
+
pro2: {
|
|
40
|
+
min: '0.0.0',
|
|
41
|
+
},
|
|
36
42
|
},
|
|
37
43
|
[Networks.Manta]: {
|
|
38
44
|
model_mini: {
|
|
@@ -41,6 +47,9 @@ const specialVersionRange: Record<string, DeviceFirmwareRange> = {
|
|
|
41
47
|
model_touch: {
|
|
42
48
|
min: '4.9.0',
|
|
43
49
|
},
|
|
50
|
+
pro2: {
|
|
51
|
+
min: '0.0.0',
|
|
52
|
+
},
|
|
44
53
|
},
|
|
45
54
|
};
|
|
46
55
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
import { normalizeRebootType } from './helpers';
|
|
3
|
+
|
|
4
|
+
import type { DeviceRebootParams } from './helpers';
|
|
5
|
+
|
|
6
|
+
export default class DevReboot extends BaseMethod<DeviceRebootParams> {
|
|
7
|
+
init() {
|
|
8
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
9
|
+
this.requireProtocolV2 = true;
|
|
10
|
+
this.skipForceUpdateCheck = true;
|
|
11
|
+
this.useDevicePassphraseState = false;
|
|
12
|
+
this.params = {
|
|
13
|
+
rebootType: this.payload.rebootType,
|
|
14
|
+
reboot_type: this.payload.reboot_type,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async run() {
|
|
19
|
+
const res = await this.device.commands.typedCall('DevReboot', 'Success', {
|
|
20
|
+
reboot_type: normalizeRebootType(this.params.reboot_type ?? this.params.rebootType),
|
|
21
|
+
});
|
|
22
|
+
return Promise.resolve(res.message);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
import {
|
|
3
|
+
PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS,
|
|
4
|
+
PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES,
|
|
5
|
+
isProtocolV2DeviceDisconnectedError,
|
|
6
|
+
normalizeFirmwareTargets,
|
|
7
|
+
} from './helpers';
|
|
8
|
+
import { UI_REQUEST, createUiMessage } from '../../events/ui-request';
|
|
9
|
+
|
|
10
|
+
import type { KnownDevice } from '../../types';
|
|
11
|
+
import type { MessageFromOneKey } from '@onekeyfe/hd-transport';
|
|
12
|
+
import type { DeviceFirmwareUpdateParams } from './helpers';
|
|
13
|
+
|
|
14
|
+
export default class DeviceFirmwareUpdate extends BaseMethod<DeviceFirmwareUpdateParams> {
|
|
15
|
+
init() {
|
|
16
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
17
|
+
this.requireProtocolV2 = true;
|
|
18
|
+
this.skipForceUpdateCheck = true;
|
|
19
|
+
this.useDevicePassphraseState = false;
|
|
20
|
+
this.params = {
|
|
21
|
+
targets: this.payload.targets,
|
|
22
|
+
targetId: this.payload.targetId,
|
|
23
|
+
target_id: this.payload.target_id,
|
|
24
|
+
path: this.payload.path,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
const targets = normalizeFirmwareTargets(this.params);
|
|
30
|
+
try {
|
|
31
|
+
const res = await this.device.commands.typedCall(
|
|
32
|
+
'DevFirmwareUpdate',
|
|
33
|
+
PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES,
|
|
34
|
+
{
|
|
35
|
+
targets,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
...PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS,
|
|
39
|
+
onIntermediateResponse: (response: MessageFromOneKey) => {
|
|
40
|
+
if (response.type !== 'DevFirmwareInstallProgress') return;
|
|
41
|
+
const progress = Number(response.message?.progress);
|
|
42
|
+
if (!Number.isFinite(progress)) return;
|
|
43
|
+
this.postMessage(
|
|
44
|
+
createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
|
|
45
|
+
device: this.device.toMessageObject() as KnownDevice,
|
|
46
|
+
progress: Math.min(Math.max(progress, 0), 100),
|
|
47
|
+
progressType: 'installingFirmware',
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
return Promise.resolve(res.message);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (isProtocolV2DeviceDisconnectedError(error)) {
|
|
56
|
+
return Promise.resolve({
|
|
57
|
+
message: 'Device firmware update started',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createDeviceNotSupportMethodError } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
import { UI_REQUEST } from '../../constants/ui-request';
|
|
4
|
+
import { PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS } from '../../protocols/protocol-v2';
|
|
5
|
+
import { BaseMethod } from '../BaseMethod';
|
|
6
|
+
|
|
7
|
+
export type DeviceGetDeviceInfoTargets = {
|
|
8
|
+
hw?: boolean;
|
|
9
|
+
fw?: boolean;
|
|
10
|
+
bt?: boolean;
|
|
11
|
+
se1?: boolean;
|
|
12
|
+
se2?: boolean;
|
|
13
|
+
se3?: boolean;
|
|
14
|
+
se4?: boolean;
|
|
15
|
+
status?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type DeviceGetDeviceInfoTypes = {
|
|
19
|
+
version?: boolean;
|
|
20
|
+
build_id?: boolean;
|
|
21
|
+
hash?: boolean;
|
|
22
|
+
specific?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type DeviceGetDeviceInfoParams = {
|
|
26
|
+
targets?: DeviceGetDeviceInfoTargets;
|
|
27
|
+
types?: DeviceGetDeviceInfoTypes;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const TARGET_KEYS: (keyof DeviceGetDeviceInfoTargets)[] = [
|
|
31
|
+
'hw',
|
|
32
|
+
'fw',
|
|
33
|
+
'bt',
|
|
34
|
+
'se1',
|
|
35
|
+
'se2',
|
|
36
|
+
'se3',
|
|
37
|
+
'se4',
|
|
38
|
+
'status',
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const TYPE_KEYS: (keyof DeviceGetDeviceInfoTypes)[] = ['version', 'build_id', 'hash', 'specific'];
|
|
42
|
+
|
|
43
|
+
const DEFAULT_TARGETS: DeviceGetDeviceInfoTargets = {
|
|
44
|
+
hw: true,
|
|
45
|
+
fw: true,
|
|
46
|
+
bt: true,
|
|
47
|
+
status: true,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const DEFAULT_TYPES: DeviceGetDeviceInfoTypes = {
|
|
51
|
+
version: true,
|
|
52
|
+
specific: true,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
function pickBooleanKeys<T extends Record<string, boolean | undefined>>(
|
|
56
|
+
value: unknown,
|
|
57
|
+
keys: (keyof T)[]
|
|
58
|
+
): T | undefined {
|
|
59
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return undefined;
|
|
60
|
+
const source = value as Record<string, unknown>;
|
|
61
|
+
const result = {} as T;
|
|
62
|
+
let hasKey = false;
|
|
63
|
+
for (const key of keys) {
|
|
64
|
+
if (source[key as string]) {
|
|
65
|
+
result[key] = true as T[keyof T];
|
|
66
|
+
hasKey = true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return hasKey ? result : undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 原生 DevGetDeviceInfo(Protocol V2 only)。
|
|
74
|
+
*
|
|
75
|
+
* 与 getDeviceInfo 不同:不构建 DeviceProfile、不更新设备缓存,
|
|
76
|
+
* 按调用方给定的 targets/types 原样请求并返回未加工的 DeviceInfo 消息,
|
|
77
|
+
* 用于调试固件字段上报。
|
|
78
|
+
*/
|
|
79
|
+
export default class DeviceGetDeviceInfo extends BaseMethod<{
|
|
80
|
+
targets: DeviceGetDeviceInfoTargets;
|
|
81
|
+
types: DeviceGetDeviceInfoTypes;
|
|
82
|
+
}> {
|
|
83
|
+
init() {
|
|
84
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
85
|
+
this.requireProtocolV2 = true;
|
|
86
|
+
this.allowDeviceMode = [
|
|
87
|
+
...this.allowDeviceMode,
|
|
88
|
+
UI_REQUEST.NOT_INITIALIZE,
|
|
89
|
+
UI_REQUEST.BOOTLOADER,
|
|
90
|
+
];
|
|
91
|
+
this.useDevicePassphraseState = false;
|
|
92
|
+
this.skipForceUpdateCheck = true;
|
|
93
|
+
this.params = {
|
|
94
|
+
targets:
|
|
95
|
+
pickBooleanKeys<DeviceGetDeviceInfoTargets>(this.payload.targets, TARGET_KEYS) ??
|
|
96
|
+
DEFAULT_TARGETS,
|
|
97
|
+
types:
|
|
98
|
+
pickBooleanKeys<DeviceGetDeviceInfoTypes>(this.payload.types, TYPE_KEYS) ?? DEFAULT_TYPES,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async run() {
|
|
103
|
+
if (!this.device.isProtocolV2()) {
|
|
104
|
+
throw createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const res = await this.device.commands.typedCall(
|
|
108
|
+
'DevGetDeviceInfo',
|
|
109
|
+
'DeviceInfo',
|
|
110
|
+
{
|
|
111
|
+
targets: this.params.targets,
|
|
112
|
+
types: this.params.types,
|
|
113
|
+
},
|
|
114
|
+
{ timeoutMs: PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS }
|
|
115
|
+
);
|
|
116
|
+
return Promise.resolve(res.message);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class DeviceGetFirmwareUpdateStatus extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
6
|
+
this.requireProtocolV2 = true;
|
|
7
|
+
this.skipForceUpdateCheck = true;
|
|
8
|
+
this.useDevicePassphraseState = false;
|
|
9
|
+
this.params = undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async run() {
|
|
13
|
+
const res = await this.device.commands.typedCall(
|
|
14
|
+
'DevGetFirmwareUpdateStatus',
|
|
15
|
+
'DevFirmwareUpdateStatus',
|
|
16
|
+
{}
|
|
17
|
+
);
|
|
18
|
+
return Promise.resolve(res.message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class DeviceGetOnboardingStatus extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
6
|
+
this.requireProtocolV2 = true;
|
|
7
|
+
this.skipForceUpdateCheck = true;
|
|
8
|
+
this.useDevicePassphraseState = false;
|
|
9
|
+
this.params = undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async run() {
|
|
13
|
+
const res = await this.device.commands.typedCall('GetOnboardingStatus', 'OnboardingStatus', {});
|
|
14
|
+
return Promise.resolve(res.message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
9
|
+
this.requireProtocolV2 = true;
|
|
10
|
+
this.skipForceUpdateCheck = true;
|
|
11
|
+
this.useDevicePassphraseState = false;
|
|
12
|
+
this.params = {
|
|
13
|
+
rebootType: this.payload.rebootType,
|
|
14
|
+
reboot_type: this.payload.reboot_type,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async run() {
|
|
19
|
+
const res = await this.device.commands.typedCall('DevReboot', 'Success', {
|
|
20
|
+
reboot_type: normalizeRebootType(this.params.reboot_type ?? this.params.rebootType),
|
|
21
|
+
});
|
|
22
|
+
return Promise.resolve(res.message);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
import type { FactoryDeviceInfoSettingsParams } from './helpers';
|
|
4
|
+
|
|
5
|
+
export default class FactoryDeviceInfoSettings extends BaseMethod<FactoryDeviceInfoSettingsParams> {
|
|
6
|
+
init() {
|
|
7
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
8
|
+
this.requireProtocolV2 = true;
|
|
9
|
+
this.skipForceUpdateCheck = true;
|
|
10
|
+
this.useDevicePassphraseState = false;
|
|
11
|
+
this.params = {
|
|
12
|
+
serial_no: this.payload.serial_no,
|
|
13
|
+
serialNo: this.payload.serialNo,
|
|
14
|
+
cpu_info: this.payload.cpu_info,
|
|
15
|
+
cpuInfo: this.payload.cpuInfo,
|
|
16
|
+
pre_firmware: this.payload.pre_firmware,
|
|
17
|
+
preFirmware: this.payload.preFirmware,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async run() {
|
|
22
|
+
const res = await this.device.commands.typedCall('FactoryDeviceInfoSettings', 'Success', {
|
|
23
|
+
serial_no: this.params.serial_no ?? this.params.serialNo,
|
|
24
|
+
cpu_info: this.params.cpu_info ?? this.params.cpuInfo,
|
|
25
|
+
pre_firmware: this.params.pre_firmware ?? this.params.preFirmware,
|
|
26
|
+
});
|
|
27
|
+
return Promise.resolve(res.message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class FactoryGetDeviceInfo extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
6
|
+
this.requireProtocolV2 = true;
|
|
7
|
+
this.skipForceUpdateCheck = true;
|
|
8
|
+
this.useDevicePassphraseState = false;
|
|
9
|
+
this.params = undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async run() {
|
|
13
|
+
const res = await this.device.commands.typedCall(
|
|
14
|
+
'FactoryGetDeviceInfo',
|
|
15
|
+
'FactoryDeviceInfo',
|
|
16
|
+
{}
|
|
17
|
+
);
|
|
18
|
+
return Promise.resolve(res.message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
import {
|
|
3
|
+
invalidParameter,
|
|
4
|
+
validateOptionalNonNegativeInteger,
|
|
5
|
+
} from '../helpers/filesystemValidation';
|
|
6
|
+
|
|
7
|
+
export type FilesystemDiskControlParams = {
|
|
8
|
+
// 收紧为 boolean | 0 | 1;'0' / '1' 字符串仅作为历史输入向后兼容,内部归一化为 0/1
|
|
9
|
+
enable?: boolean | 0 | 1;
|
|
10
|
+
timeoutMs?: number | string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function normalizeDiskControlEnable(value: unknown): 0 | 1 {
|
|
14
|
+
if (value === undefined || value === null) return 0;
|
|
15
|
+
if (typeof value === 'boolean') return value ? 1 : 0;
|
|
16
|
+
if (value === 0 || value === '0') return 0;
|
|
17
|
+
if (value === 1 || value === '1') return 1;
|
|
18
|
+
throw invalidParameter('Parameter [enable] must be a boolean or 0 | 1.');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default class FilesystemDiskControl extends BaseMethod<{
|
|
22
|
+
enable: 0 | 1;
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
}> {
|
|
25
|
+
init() {
|
|
26
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
27
|
+
this.requireProtocolV2 = true;
|
|
28
|
+
this.skipForceUpdateCheck = true;
|
|
29
|
+
this.useDevicePassphraseState = false;
|
|
30
|
+
this.params = {
|
|
31
|
+
enable: normalizeDiskControlEnable(this.payload.enable),
|
|
32
|
+
timeoutMs: validateOptionalNonNegativeInteger(this.payload.timeoutMs, 'timeoutMs'),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async run() {
|
|
37
|
+
const typedCall = this.device.commands.typedCall as any;
|
|
38
|
+
const res = await typedCall(
|
|
39
|
+
'FilesystemDiskControl',
|
|
40
|
+
'Success',
|
|
41
|
+
{
|
|
42
|
+
enable: this.params.enable,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
timeoutMs: this.params.timeoutMs,
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
return Promise.resolve(res.message);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class FilesystemFixPermission extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
6
|
+
this.requireProtocolV2 = true;
|
|
7
|
+
this.skipForceUpdateCheck = true;
|
|
8
|
+
this.useDevicePassphraseState = false;
|
|
9
|
+
this.params = undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async run() {
|
|
13
|
+
const res = await this.device.commands.typedCall('FilesystemFixPermission', 'Success', {});
|
|
14
|
+
return Promise.resolve(res.message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class FilesystemFormat extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
6
|
+
this.requireProtocolV2 = true;
|
|
7
|
+
this.skipForceUpdateCheck = true;
|
|
8
|
+
this.useDevicePassphraseState = false;
|
|
9
|
+
this.params = undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async run() {
|
|
13
|
+
const res = await this.device.commands.typedCall('FilesystemFormat', 'Success', {});
|
|
14
|
+
return Promise.resolve(res.message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class GetProtoVersion extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
6
|
+
this.requireProtocolV2 = true;
|
|
7
|
+
this.skipForceUpdateCheck = true;
|
|
8
|
+
this.useDevicePassphraseState = false;
|
|
9
|
+
this.params = undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async run() {
|
|
13
|
+
const res = await this.device.commands.typedCall('GetProtoVersion', 'ProtoVersion', {});
|
|
14
|
+
return Promise.resolve(res.message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class Ping extends BaseMethod<{ message?: string }> {
|
|
4
|
+
init() {
|
|
5
|
+
// Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
|
|
6
|
+
this.requireProtocolV2 = true;
|
|
7
|
+
this.skipForceUpdateCheck = true;
|
|
8
|
+
this.useDevicePassphraseState = false;
|
|
9
|
+
this.params = { message: this.payload.message };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async run() {
|
|
13
|
+
const res = await this.device.commands.typedCall('Ping', 'Success', {
|
|
14
|
+
message: this.params.message ?? '',
|
|
15
|
+
});
|
|
16
|
+
return Promise.resolve(res.message);
|
|
17
|
+
}
|
|
18
|
+
}
|