@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
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
3
|
|
|
4
|
-
import { getDeviceFirmwareVersion, getDeviceType } from '../../../utils';
|
|
5
|
-
|
|
6
4
|
import type { Device } from '../../../device/Device';
|
|
7
5
|
import type { MessageResponse, TypedCall } from '@onekeyfe/hd-transport';
|
|
8
6
|
|
|
@@ -21,10 +19,10 @@ export const signTypedHash = async ({
|
|
|
21
19
|
domainHash: string;
|
|
22
20
|
messageHash: string | undefined;
|
|
23
21
|
}): Promise<MessageResponse<'EthereumTypedDataSignatureOneKey'>> => {
|
|
24
|
-
const deviceType =
|
|
22
|
+
const deviceType = device.getCurrentDeviceType();
|
|
25
23
|
if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
|
|
26
24
|
// Touch Pro Sign NestedArrays
|
|
27
|
-
const currentVersion =
|
|
25
|
+
const currentVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
28
26
|
const supportNestedArraysSignVersion = '4.2.0';
|
|
29
27
|
|
|
30
28
|
// 4.2.0 is the first version that supports nested arrays in signTypedData
|
|
@@ -7,10 +7,12 @@ export default async function ({
|
|
|
7
7
|
typedCall: TypedCall;
|
|
8
8
|
param: EthereumGetAddressOneKey;
|
|
9
9
|
}): Promise<MessageResponse<'EthereumAddress'>> {
|
|
10
|
-
|
|
10
|
+
// legacy EthereumGetAddress 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
|
|
11
|
+
// 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
|
|
12
|
+
const message = {
|
|
11
13
|
address_n: param.address_n,
|
|
12
14
|
show_display: param.show_display,
|
|
13
|
-
// @ts-ignore
|
|
14
15
|
chain_id: param.chain_id,
|
|
15
|
-
}
|
|
16
|
+
};
|
|
17
|
+
return typedCall('EthereumGetAddress', 'EthereumAddress', message);
|
|
16
18
|
}
|
|
@@ -11,10 +11,12 @@ export default async function ({
|
|
|
11
11
|
typedCall: TypedCall;
|
|
12
12
|
param: EthereumGetPublicKeyOneKey;
|
|
13
13
|
}): Promise<MessageResponse<'EthereumPublicKey'>> {
|
|
14
|
-
|
|
14
|
+
// legacy EthereumGetPublicKey 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
|
|
15
|
+
// 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
|
|
16
|
+
const message = {
|
|
15
17
|
address_n: param.address_n,
|
|
16
18
|
show_display: param.show_display,
|
|
17
|
-
// @ts-ignore
|
|
18
19
|
chain_id: param.chain_id,
|
|
19
|
-
}
|
|
20
|
+
};
|
|
21
|
+
return typedCall('EthereumGetPublicKey', 'EthereumPublicKey', message);
|
|
20
22
|
}
|
|
@@ -11,12 +11,14 @@ export default async function ({
|
|
|
11
11
|
typedCall: TypedCall;
|
|
12
12
|
params: EthereumSignMessageOneKey;
|
|
13
13
|
}): Promise<EthereumMessageSignature> {
|
|
14
|
-
|
|
14
|
+
// legacy EthereumSignMessage 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
|
|
15
|
+
// 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
|
|
16
|
+
const message = {
|
|
15
17
|
address_n: params.address_n,
|
|
16
18
|
message: params.message,
|
|
17
|
-
// @ts-ignore
|
|
18
19
|
chain_id: params.chain_id,
|
|
19
|
-
}
|
|
20
|
+
};
|
|
21
|
+
const res = await typedCall('EthereumSignMessage', 'EthereumMessageSignature', message);
|
|
20
22
|
|
|
21
23
|
return Promise.resolve(res.message);
|
|
22
24
|
}
|
|
@@ -16,22 +16,23 @@ export const signTypedData = async ({
|
|
|
16
16
|
}) => {
|
|
17
17
|
const { primaryType }: EthereumSignTypedDataMessage<EthereumSignTypedDataTypes> = data;
|
|
18
18
|
|
|
19
|
+
// legacy EthereumSignTypedData 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
|
|
20
|
+
// 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
|
|
21
|
+
const message = {
|
|
22
|
+
address_n: addressN,
|
|
23
|
+
primary_type: primaryType as string,
|
|
24
|
+
metamask_v4_compat: metamaskV4Compat,
|
|
25
|
+
chain_id: chainId,
|
|
26
|
+
};
|
|
19
27
|
const response = await typedCall(
|
|
20
28
|
'EthereumSignTypedData',
|
|
21
|
-
// @ts-ignore
|
|
22
29
|
[
|
|
23
30
|
'EthereumTypedDataStructRequest',
|
|
24
31
|
'EthereumTypedDataValueRequest',
|
|
25
32
|
'EthereumTypedDataSignature',
|
|
26
33
|
'EthereumGnosisSafeTxRequest',
|
|
27
34
|
],
|
|
28
|
-
|
|
29
|
-
address_n: addressN,
|
|
30
|
-
primary_type: primaryType as string,
|
|
31
|
-
metamask_v4_compat: metamaskV4Compat,
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
chain_id: chainId,
|
|
34
|
-
}
|
|
35
|
+
message
|
|
35
36
|
);
|
|
36
37
|
return response;
|
|
37
38
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
3
|
|
|
4
|
-
import { getDeviceFirmwareVersion, getDeviceType } from '../../../utils';
|
|
5
|
-
|
|
6
4
|
import type { Device } from '../../../device/Device';
|
|
7
5
|
import type { MessageResponse, TypedCall } from '@onekeyfe/hd-transport';
|
|
8
6
|
|
|
@@ -24,10 +22,10 @@ export const signTypedHash = async ({
|
|
|
24
22
|
| MessageResponse<'EthereumTypedDataSignature'>
|
|
25
23
|
| MessageResponse<'EthereumTypedDataSignatureOneKey'>
|
|
26
24
|
> => {
|
|
27
|
-
const deviceType =
|
|
25
|
+
const deviceType = device.getCurrentDeviceType();
|
|
28
26
|
if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
|
|
29
27
|
// Touch Pro Sign NestedArrays
|
|
30
|
-
const currentVersion =
|
|
28
|
+
const currentVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
31
29
|
const supportNestedArraysSignVersion = '4.2.0';
|
|
32
30
|
|
|
33
31
|
// 4.2.0 is the first version that supports nested arrays in signTypedData
|
|
@@ -40,11 +38,13 @@ export const signTypedHash = async ({
|
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
// legacy EthereumSignTypedHash 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
|
|
42
|
+
// 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
|
|
43
|
+
const message = {
|
|
44
44
|
address_n: addressN,
|
|
45
45
|
domain_separator_hash: domainHash ?? '',
|
|
46
46
|
message_hash: messageHash,
|
|
47
|
-
// @ts-ignore
|
|
48
47
|
chain_id: chainId,
|
|
49
|
-
}
|
|
48
|
+
};
|
|
49
|
+
return typedCall('EthereumSignTypedHash', 'EthereumTypedDataSignature', message);
|
|
50
50
|
};
|
|
@@ -7,13 +7,15 @@ export default async function ({
|
|
|
7
7
|
typedCall: TypedCall;
|
|
8
8
|
params: EthereumVerifyMessageOneKey;
|
|
9
9
|
}): Promise<Success> {
|
|
10
|
-
|
|
10
|
+
// legacy EthereumVerifyMessage 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
|
|
11
|
+
// 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
|
|
12
|
+
const message = {
|
|
11
13
|
signature: params.signature,
|
|
12
14
|
message: params.message,
|
|
13
15
|
address: params.address,
|
|
14
|
-
// @ts-ignore
|
|
15
16
|
chain_id: params.chain_id,
|
|
16
|
-
}
|
|
17
|
+
};
|
|
18
|
+
const res = await typedCall('EthereumVerifyMessage', 'Success', message);
|
|
17
19
|
|
|
18
20
|
return Promise.resolve(res.message);
|
|
19
21
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import { FirmwareUpdateTipMessage, UI_REQUEST, createUiMessage } from '../../events/ui-request';
|
|
10
10
|
import { DevicePool } from '../../device/DevicePool';
|
|
11
|
-
import { LoggerNames,
|
|
11
|
+
import { LoggerNames, getDeviceUUID, getLogger, wait } from '../../utils';
|
|
12
12
|
import { DeviceModelToTypes } from '../../types';
|
|
13
13
|
import { DataManager } from '../../data-manager';
|
|
14
14
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -142,8 +142,8 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
142
142
|
let timeoutTimer: ReturnType<typeof setTimeout> | undefined;
|
|
143
143
|
|
|
144
144
|
const isTouchOrProDevice =
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
this?.device?.getCurrentDeviceType() === EDeviceType.Touch ||
|
|
146
|
+
this?.device?.getCurrentDeviceType() === EDeviceType.Pro;
|
|
147
147
|
|
|
148
148
|
const intervalTimer: ReturnType<typeof setInterval> | undefined = setInterval(
|
|
149
149
|
async () => {
|
|
@@ -187,7 +187,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
187
187
|
true
|
|
188
188
|
);
|
|
189
189
|
await this.device.initialize();
|
|
190
|
-
if (this.device.
|
|
190
|
+
if (this.device.isBootloader()) {
|
|
191
191
|
clearInterval(intervalTimer);
|
|
192
192
|
this.checkPromise?.resolve(true);
|
|
193
193
|
}
|
|
@@ -220,7 +220,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
220
220
|
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
221
221
|
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, connectId);
|
|
222
222
|
|
|
223
|
-
if (deviceList.length === 1 && deviceList[0]?.
|
|
223
|
+
if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
|
|
224
224
|
// should update current device from cache
|
|
225
225
|
// because device was reboot and had some new requests
|
|
226
226
|
this.device.updateFromCache(deviceList[0]);
|
|
@@ -236,9 +236,9 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
236
236
|
|
|
237
237
|
async enterBootloaderMode() {
|
|
238
238
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
239
|
-
if (this.device.features && !this.device.
|
|
239
|
+
if (this.device.features && !this.device.isBootloader()) {
|
|
240
240
|
const uuid = getDeviceUUID(this.device.features);
|
|
241
|
-
const deviceType =
|
|
241
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
242
242
|
// auto go to bootloader mode
|
|
243
243
|
try {
|
|
244
244
|
this.postTipMessage(FirmwareUpdateTipMessage.AutoRebootToBootloader);
|
|
@@ -436,7 +436,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
436
436
|
const deviceDiff = await this.device.deviceConnector?.enumerate();
|
|
437
437
|
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
438
438
|
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, undefined);
|
|
439
|
-
if (deviceList.length === 1 && deviceList[0]?.
|
|
439
|
+
if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
|
|
440
440
|
this.device.updateFromCache(deviceList[0]);
|
|
441
441
|
await this.device.acquire();
|
|
442
442
|
this.device.getCommands().mainId = this.device.mainId ?? '';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
3
3
|
|
|
4
|
-
import { getDeviceType } from '../../utils';
|
|
4
|
+
import { getDeviceBootloaderVersion, getDeviceType } from '../../utils';
|
|
5
5
|
|
|
6
6
|
import type { Features, IVersionArray } from '../../types';
|
|
7
7
|
|
|
@@ -38,9 +38,10 @@ export function shouldUpdateBootloaderForClassicAndMini({
|
|
|
38
38
|
export function isEnteredManuallyBoot(features: Features, updateType: string) {
|
|
39
39
|
const deviceType = getDeviceType(features);
|
|
40
40
|
const isMini = deviceType === EDeviceType.Mini;
|
|
41
|
+
const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
|
|
41
42
|
const isBoot183ClassicUpBle =
|
|
42
43
|
updateType === 'firmware' &&
|
|
43
44
|
deviceType === EDeviceType.Classic &&
|
|
44
|
-
|
|
45
|
+
bootloaderVersion === '1.8.3';
|
|
45
46
|
return isMini || isBoot183ClassicUpBle;
|
|
46
47
|
}
|
|
@@ -41,7 +41,7 @@ export const getBinary = async ({
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (version && !semver.eq(releaseInfo.version.join('.'), version.join('.'))) {
|
|
44
|
-
const touchWithoutVersion = getDeviceType(features) === 'touch' && !features.
|
|
44
|
+
const touchWithoutVersion = getDeviceType(features) === 'touch' && !features.firmwareVersion;
|
|
45
45
|
if (!touchWithoutVersion) {
|
|
46
46
|
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'firmware version mismatch');
|
|
47
47
|
}
|
|
@@ -12,7 +12,7 @@ export const getFirmwareReleaseInfo = (features: Features, firmwareType: EFirmwa
|
|
|
12
12
|
const firmwareStatus = DataManager.getFirmwareStatus(features, firmwareType);
|
|
13
13
|
const changelog = DataManager.getFirmwareChangelog(features, firmwareType);
|
|
14
14
|
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
15
|
-
const bootloaderMode = !!features.
|
|
15
|
+
const bootloaderMode = !!features.bootloaderMode;
|
|
16
16
|
return {
|
|
17
17
|
status: firmwareStatus,
|
|
18
18
|
changelog,
|
|
@@ -25,7 +25,7 @@ export const getBleFirmwareReleaseInfo = (features: Features) => {
|
|
|
25
25
|
const firmwareStatus = DataManager.getBLEFirmwareStatus(features);
|
|
26
26
|
const changelog = DataManager.getBleFirmwareChangelog(features);
|
|
27
27
|
const release = DataManager.getBleFirmwareLatestRelease(features);
|
|
28
|
-
const bootloaderMode = !!features.
|
|
28
|
+
const bootloaderMode = !!features.bootloaderMode;
|
|
29
29
|
return {
|
|
30
30
|
status: firmwareStatus,
|
|
31
31
|
changelog,
|
|
@@ -52,7 +52,7 @@ export const getBootloaderReleaseInfo = ({
|
|
|
52
52
|
Object.prototype.hasOwnProperty.call(item, 'en-US')
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
const bootloaderMode = !!features.
|
|
55
|
+
const bootloaderMode = !!features.bootloaderMode;
|
|
56
56
|
|
|
57
57
|
let shouldUpdate = false;
|
|
58
58
|
|
|
@@ -3,19 +3,13 @@ import { blake2s } from '@noble/hashes/blake2s';
|
|
|
3
3
|
import JSZip from 'jszip';
|
|
4
4
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
LoggerNames,
|
|
9
|
-
getDeviceBootloaderVersion,
|
|
10
|
-
getDeviceType,
|
|
11
|
-
getLogger,
|
|
12
|
-
wait,
|
|
13
|
-
} from '../../utils';
|
|
6
|
+
import { LoggerNames, getDeviceBootloaderVersion, getLogger, wait } from '../../utils';
|
|
14
7
|
import { DEVICE, UI_REQUEST, createUiMessage } from '../../events';
|
|
15
8
|
import { DeviceModelToTypes } from '../../types';
|
|
16
9
|
import { bytesToHex } from '../helpers/hexUtils';
|
|
17
10
|
import { DataManager } from '../../data-manager';
|
|
18
11
|
import { DevicePool } from '../../device/DevicePool';
|
|
12
|
+
import { buildProtocolV1FeaturesPayload } from '../../deviceProfile';
|
|
19
13
|
|
|
20
14
|
import type { KnownDevice } from '../../types';
|
|
21
15
|
import type { TypedCall, TypedResponseMessage } from '../../device/DeviceCommands';
|
|
@@ -41,7 +35,7 @@ const isDeviceDisconnectedError = (error: unknown) => {
|
|
|
41
35
|
|
|
42
36
|
const postConfirmationMessage = (device: Device) => {
|
|
43
37
|
// only if firmware is already installed. fresh device does not require button confirmation
|
|
44
|
-
if (device.features?.
|
|
38
|
+
if (device.features?.firmwarePresent) {
|
|
45
39
|
device.emit(DEVICE.BUTTON, device, { code: 'ButtonRequest_FirmwareUpdate' });
|
|
46
40
|
}
|
|
47
41
|
};
|
|
@@ -107,7 +101,7 @@ export const uploadFirmware = async (
|
|
|
107
101
|
},
|
|
108
102
|
isUpdateBootloader?: boolean
|
|
109
103
|
) => {
|
|
110
|
-
const deviceType =
|
|
104
|
+
const deviceType = device.getCurrentDeviceType();
|
|
111
105
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
112
106
|
postConfirmationMessage(device);
|
|
113
107
|
postProgressTip(device, 'ConfirmOnDevice', postMessage);
|
|
@@ -116,7 +110,9 @@ export const uploadFirmware = async (
|
|
|
116
110
|
|
|
117
111
|
if (isFirmware && !isUpdateBootloader) {
|
|
118
112
|
const newFeatures = await typedCall('GetFeatures', 'Features', {});
|
|
119
|
-
const deviceBootloaderVersion = getDeviceBootloaderVersion(
|
|
113
|
+
const deviceBootloaderVersion = getDeviceBootloaderVersion(
|
|
114
|
+
buildProtocolV1FeaturesPayload(newFeatures.message, device.features)
|
|
115
|
+
).join('.');
|
|
120
116
|
const supportUpgradeFileHeader = semver.gte(deviceBootloaderVersion, '2.1.0');
|
|
121
117
|
Log.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
|
|
122
118
|
|
|
@@ -429,7 +425,7 @@ const emmcFileWriteWithRetry = async (
|
|
|
429
425
|
const deviceDiff = await device.deviceConnector?.enumerate();
|
|
430
426
|
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
431
427
|
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, undefined);
|
|
432
|
-
if (deviceList.length === 1 && deviceList[0]?.
|
|
428
|
+
if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
|
|
433
429
|
device.updateFromCache(deviceList[0]);
|
|
434
430
|
await device.acquire();
|
|
435
431
|
device.getCommands().mainId = device.mainId ?? '';
|
|
@@ -1,18 +1,63 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
1
2
|
import {
|
|
3
|
+
EDeviceType,
|
|
2
4
|
HardwareErrorCode,
|
|
3
5
|
TypedError,
|
|
4
6
|
createDeviceNotSupportMethodError,
|
|
5
7
|
} from '@onekeyfe/hd-shared';
|
|
6
8
|
|
|
7
|
-
import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils';
|
|
8
9
|
import { isEqualBip44CoinType } from './pathUtils';
|
|
9
10
|
import { splitArray } from '../../utils/arrayUtils';
|
|
10
|
-
import { getDeviceType, getFirmwareType } from '../../utils';
|
|
11
11
|
import { DeviceModelToTypes } from '../../types';
|
|
12
12
|
|
|
13
13
|
import type { EcdsaPublicKeys, Path } from '@onekeyfe/hd-transport';
|
|
14
14
|
import type { Device } from '../../device/Device';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Protocol-agnostic version of `supportBatchPublicKey` (utils/deviceFeaturesUtils):
|
|
18
|
+
* derives device type and firmware version through Device accessors so that
|
|
19
|
+
* Protocol V2 devices (features === undefined, profile set) resolve correctly.
|
|
20
|
+
*/
|
|
21
|
+
export function supportBatchPublicKeyByDevice(
|
|
22
|
+
device: Device,
|
|
23
|
+
options?: {
|
|
24
|
+
includeNode?: boolean;
|
|
25
|
+
}
|
|
26
|
+
): boolean {
|
|
27
|
+
const currentVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
28
|
+
const deviceType = device.getCurrentDeviceType();
|
|
29
|
+
|
|
30
|
+
// Pro2 (Protocol V2) 版本线独立于 Pro 系列,固件从首个版本即支持 batch / include_node,
|
|
31
|
+
// 不能套用下面 Pro 系列的 4.x 门槛。
|
|
32
|
+
if (device.isProtocolV2() || deviceType === EDeviceType.Pro2) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// btc batch get public key
|
|
37
|
+
if (!!options?.includeNode && deviceType === EDeviceType.Pro) {
|
|
38
|
+
return semver.gte(currentVersion, '4.14.0');
|
|
39
|
+
}
|
|
40
|
+
if (!!options?.includeNode && deviceType === EDeviceType.Touch) {
|
|
41
|
+
return semver.gte(currentVersion, '4.11.0');
|
|
42
|
+
}
|
|
43
|
+
if (!!options?.includeNode && DeviceModelToTypes.model_classic1s.includes(deviceType)) {
|
|
44
|
+
return semver.gte(currentVersion, '3.12.0');
|
|
45
|
+
}
|
|
46
|
+
if (!!options?.includeNode && DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
47
|
+
return semver.gte(currentVersion, '3.10.0');
|
|
48
|
+
}
|
|
49
|
+
if (options?.includeNode) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// support batch get public key
|
|
54
|
+
if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
|
|
55
|
+
return semver.gte(currentVersion, '3.1.0');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return semver.gte(currentVersion, '2.6.0');
|
|
59
|
+
}
|
|
60
|
+
|
|
16
61
|
export async function batchGetPublickeys(
|
|
17
62
|
device: Device,
|
|
18
63
|
paths: Path[],
|
|
@@ -28,9 +73,9 @@ export async function batchGetPublickeys(
|
|
|
28
73
|
throw TypedError(HardwareErrorCode.ForbiddenKeyPath, 'Path length must be greater than 3');
|
|
29
74
|
}
|
|
30
75
|
|
|
31
|
-
const supportsBatchPublicKey =
|
|
76
|
+
const supportsBatchPublicKey = supportBatchPublicKeyByDevice(device, options);
|
|
32
77
|
if (!supportsBatchPublicKey) {
|
|
33
|
-
throw createDeviceNotSupportMethodError('BatchGetPublickeys',
|
|
78
|
+
throw createDeviceNotSupportMethodError('BatchGetPublickeys', device.getCurrentFirmwareType());
|
|
34
79
|
}
|
|
35
80
|
|
|
36
81
|
const existsPathNotEqualCoinType = paths.find(p => !isEqualBip44CoinType(p.address_n, coinType));
|
|
@@ -39,7 +84,7 @@ export async function batchGetPublickeys(
|
|
|
39
84
|
}
|
|
40
85
|
|
|
41
86
|
let batchSize = 10;
|
|
42
|
-
const deviceType =
|
|
87
|
+
const deviceType = device.getCurrentDeviceType();
|
|
43
88
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
44
89
|
batchSize = 10;
|
|
45
90
|
} else if (DeviceModelToTypes.model_touch.includes(deviceType)) {
|
|
@@ -60,7 +105,7 @@ export async function batchGetPublickeys(
|
|
|
60
105
|
if (res.type !== 'EcdsaPublicKeys') {
|
|
61
106
|
throw createDeviceNotSupportMethodError(
|
|
62
107
|
'BatchGetPublickeys',
|
|
63
|
-
|
|
108
|
+
device.getCurrentFirmwareType()
|
|
64
109
|
);
|
|
65
110
|
} else {
|
|
66
111
|
result.root_fingerprint = res.message.root_fingerprint;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
}
|
package/src/api/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as preInitialize } from './device/PreInitialize';
|
|
|
3
3
|
|
|
4
4
|
export { default as searchDevices } from './SearchDevices';
|
|
5
5
|
export { default as getFeatures } from './GetFeatures';
|
|
6
|
+
export { default as getDeviceInfo } from './GetDeviceInfo';
|
|
6
7
|
export { default as getOnekeyFeatures } from './GetOnekeyFeatures';
|
|
7
8
|
export { default as getPassphraseState } from './GetPassphraseState';
|
|
8
9
|
export { default as getLogs } from './GetLogs';
|
|
@@ -38,8 +39,41 @@ export { default as getNextU2FCounter } from './u2f/GetNextU2FCounter';
|
|
|
38
39
|
export { default as firmwareUpdate } from './FirmwareUpdate';
|
|
39
40
|
export { default as firmwareUpdateV2 } from './FirmwareUpdateV2';
|
|
40
41
|
export { default as firmwareUpdateV3 } from './FirmwareUpdateV3';
|
|
42
|
+
export { default as firmwareUpdateV4 } from './FirmwareUpdateV4';
|
|
41
43
|
export { default as promptWebDeviceAccess } from './PromptWebDeviceAccess';
|
|
42
44
|
|
|
45
|
+
// File system & device control API (Protocol V2 only)
|
|
46
|
+
export { default as getProtoVersion } from './protocol-v2/GetProtoVersion';
|
|
47
|
+
export { default as ping } from './protocol-v2/Ping';
|
|
48
|
+
export { default as deviceReboot } from './protocol-v2/DeviceReboot';
|
|
49
|
+
export { default as deviceGetDeviceInfo } from './protocol-v2/DeviceGetDeviceInfo';
|
|
50
|
+
export { default as deviceGetOnboardingStatus } from './protocol-v2/DeviceGetOnboardingStatus';
|
|
51
|
+
export { default as deviceFirmwareUpdate } from './protocol-v2/DeviceFirmwareUpdate';
|
|
52
|
+
export { default as deviceGetFirmwareUpdateStatus } from './protocol-v2/DeviceGetFirmwareUpdateStatus';
|
|
53
|
+
export { default as devReboot } from './protocol-v2/DevReboot';
|
|
54
|
+
export { default as devGetDeviceInfo } from './protocol-v2/DeviceGetDeviceInfo';
|
|
55
|
+
export { default as devFirmwareUpdate } from './protocol-v2/DeviceFirmwareUpdate';
|
|
56
|
+
export { default as devGetFirmwareUpdateStatus } from './protocol-v2/DeviceGetFirmwareUpdateStatus';
|
|
57
|
+
export { default as factoryDeviceInfoSettings } from './protocol-v2/FactoryDeviceInfoSettings';
|
|
58
|
+
export { default as factoryGetDeviceInfo } from './protocol-v2/FactoryGetDeviceInfo';
|
|
59
|
+
export { default as filesystemFixPermission } from './protocol-v2/FilesystemFixPermission';
|
|
60
|
+
export { default as filesystemFormat } from './protocol-v2/FilesystemFormat';
|
|
61
|
+
export { default as filesystemDiskControl } from './protocol-v2/FilesystemDiskControl';
|
|
62
|
+
export { default as fileRead } from './FileRead';
|
|
63
|
+
export { default as fileWrite } from './FileWrite';
|
|
64
|
+
export { default as fileDelete } from './FileDelete';
|
|
65
|
+
export { default as dirList } from './DirList';
|
|
66
|
+
export { default as dirMake } from './DirMake';
|
|
67
|
+
export { default as dirRemove } from './DirRemove';
|
|
68
|
+
export { default as pathInfo } from './PathInfo';
|
|
69
|
+
export { default as filesystemFileRead } from './FileRead';
|
|
70
|
+
export { default as filesystemFileWrite } from './FileWrite';
|
|
71
|
+
export { default as filesystemFileDelete } from './FileDelete';
|
|
72
|
+
export { default as filesystemDirList } from './DirList';
|
|
73
|
+
export { default as filesystemDirMake } from './DirMake';
|
|
74
|
+
export { default as filesystemDirRemove } from './DirRemove';
|
|
75
|
+
export { default as filesystemPathInfoQuery } from './PathInfo';
|
|
76
|
+
|
|
43
77
|
export { default as cipherKeyValue } from './CipherKeyValue';
|
|
44
78
|
|
|
45
79
|
export { default as allNetworkGetAddress } from './allnetwork/AllNetworkGetAddress';
|
|
@@ -134,15 +134,14 @@ export default class KaspaSignTransaction extends BaseMethod<KaspaSignTransactio
|
|
|
134
134
|
|
|
135
135
|
const response = await typedCall(
|
|
136
136
|
'KaspaTxInputAck',
|
|
137
|
-
// @ts-expect-error
|
|
138
137
|
['KaspaTxInputRequest', 'KaspaSignedTx'],
|
|
139
138
|
{
|
|
140
|
-
|
|
139
|
+
// params.inputs 的 path 可能是字符串或已解析数组,统一归一为 address_n 数组
|
|
140
|
+
address_n: validatePath(input.path, 3),
|
|
141
141
|
raw_message: bytesToHex(rawMessage),
|
|
142
142
|
}
|
|
143
143
|
);
|
|
144
144
|
|
|
145
|
-
// @ts-expect-error
|
|
146
145
|
return this.processTxRequest(typedCall, response, nextIndex, signature);
|
|
147
146
|
}
|
|
148
147
|
|
|
@@ -164,12 +163,12 @@ export default class KaspaSignTransaction extends BaseMethod<KaspaSignTransactio
|
|
|
164
163
|
|
|
165
164
|
const { device, params } = this;
|
|
166
165
|
|
|
167
|
-
// @ts-expect-error
|
|
168
166
|
const response = await device.commands.typedCall(
|
|
169
167
|
'KaspaSignTx',
|
|
170
168
|
['KaspaTxInputRequest', 'KaspaSignedTx'],
|
|
171
169
|
{
|
|
172
|
-
|
|
170
|
+
// init() 已把 path 归一为数组,这里再过一遍 validatePath 收窄类型
|
|
171
|
+
address_n: validatePath(input.path, 3),
|
|
173
172
|
raw_message: bytesToHex(rawMessage),
|
|
174
173
|
scheme: params.scheme,
|
|
175
174
|
prefix: params.prefix,
|
|
@@ -5,6 +5,7 @@ import { UI_REQUEST } from '../../constants/ui-request';
|
|
|
5
5
|
|
|
6
6
|
import type { NeoGetAddress as HardwareNeoGetAddress } from '@onekeyfe/hd-transport';
|
|
7
7
|
import type { NeoAddress, NeoGetAddressParams } from '../../types/api/neoGetAddress';
|
|
8
|
+
import type { DeviceFirmwareRange } from '../../types';
|
|
8
9
|
|
|
9
10
|
export default class NeoGetAddress extends BaseMethod<HardwareNeoGetAddress[]> {
|
|
10
11
|
hasBundle = false;
|
|
@@ -37,8 +38,12 @@ export default class NeoGetAddress extends BaseMethod<HardwareNeoGetAddress[]> {
|
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
getVersionRange() {
|
|
41
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
41
42
|
return {
|
|
43
|
+
pro2: {
|
|
44
|
+
min: '0.0.0',
|
|
45
|
+
unsupported: true,
|
|
46
|
+
},
|
|
42
47
|
pro: {
|
|
43
48
|
min: '4.12.0',
|
|
44
49
|
},
|
|
@@ -5,6 +5,7 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
5
5
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
6
6
|
|
|
7
7
|
import type { NeoSignTx } from '@onekeyfe/hd-transport';
|
|
8
|
+
import type { DeviceFirmwareRange } from '../../types';
|
|
8
9
|
|
|
9
10
|
export default class NeoSignTransaction extends BaseMethod<NeoSignTx> {
|
|
10
11
|
init() {
|
|
@@ -29,8 +30,12 @@ export default class NeoSignTransaction extends BaseMethod<NeoSignTx> {
|
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
getVersionRange() {
|
|
33
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
33
34
|
return {
|
|
35
|
+
pro2: {
|
|
36
|
+
min: '0.0.0',
|
|
37
|
+
unsupported: true,
|
|
38
|
+
},
|
|
34
39
|
pro: {
|
|
35
40
|
min: '4.12.0',
|
|
36
41
|
},
|
|
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
4
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
5
5
|
|
|
6
6
|
import type { NervosGetAddress as HardwareNervosGetAddress } from '@onekeyfe/hd-transport';
|
|
7
|
-
import type { NervosAddress, NervosGetAddressParams } from '../../types';
|
|
7
|
+
import type { DeviceFirmwareRange, NervosAddress, NervosGetAddressParams } from '../../types';
|
|
8
8
|
|
|
9
9
|
export default class NervosGetAddress extends BaseMethod<HardwareNervosGetAddress[]> {
|
|
10
10
|
hasBundle = false;
|
|
@@ -40,8 +40,12 @@ export default class NervosGetAddress extends BaseMethod<HardwareNervosGetAddres
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
getVersionRange() {
|
|
43
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
44
44
|
return {
|
|
45
|
+
pro2: {
|
|
46
|
+
min: '0.0.0',
|
|
47
|
+
unsupported: true,
|
|
48
|
+
},
|
|
45
49
|
model_mini: {
|
|
46
50
|
min: '3.7.0',
|
|
47
51
|
},
|