@onekeyfe/hd-core 1.1.27 → 1.2.0-alpha.0
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 +3025 -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.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/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/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 +34 -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/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +7 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +5 -4
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +36 -10
- 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/buildDeviceProfile.d.ts +22 -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/deviceProfile/legacyFeaturesView.d.ts +5 -0
- package/dist/deviceProfile/legacyFeaturesView.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 +720 -382
- package/dist/index.js +17634 -1201
- 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 +10 -3
- 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 +1 -1
- package/dist/types/settings.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/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 +21 -25
- package/src/api/FirmwareUpdateV3.ts +17 -4
- package/src/api/FirmwareUpdateV4.ts +827 -0
- package/src/api/GetDeviceInfo.ts +152 -0
- package/src/api/GetFeatures.ts +5 -2
- package/src/api/GetOnekeyFeatures.ts +95 -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/uploadFirmware.ts +3 -10
- 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 +207 -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/core/index.ts +87 -55
- package/src/data/messages/messages-protocol-v2.json +13369 -0
- package/src/data-manager/DataManager.ts +12 -7
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +38 -12
- package/src/device/Device.ts +538 -61
- package/src/device/DeviceCommands.ts +195 -29
- package/src/device/DeviceConnector.ts +29 -4
- package/src/device/DevicePool.ts +7 -7
- package/src/deviceProfile/buildDeviceProfile.ts +387 -0
- package/src/deviceProfile/index.ts +2 -0
- package/src/deviceProfile/legacyFeaturesView.ts +123 -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 +180 -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 +201 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/device.ts +37 -3
- package/src/types/params.ts +7 -0
- package/src/types/settings.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +70 -70
- package/src/utils/deviceInfoUtils.ts +15 -8
- package/src/utils/index.ts +1 -0
|
@@ -9,7 +9,6 @@ import { validatePath } from '../helpers/pathUtils';
|
|
|
9
9
|
import { BaseMethod } from '../BaseMethod';
|
|
10
10
|
import { validateParams } from '../helpers/paramsValidator';
|
|
11
11
|
import { formatAnyHex, parseChainId, stripHexStartZeroes } from '../helpers/hexUtils';
|
|
12
|
-
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils';
|
|
13
12
|
import { existCapability } from '../../utils/capabilitieUtils';
|
|
14
13
|
import {
|
|
15
14
|
DeviceModelToTypes,
|
|
@@ -26,11 +25,20 @@ import { encodeData, getFieldType, parseArrayType } from '../helpers/typeNameUti
|
|
|
26
25
|
import type {
|
|
27
26
|
EthereumTypedDataSignature,
|
|
28
27
|
EthereumTypedDataStructAck,
|
|
28
|
+
EthereumTypedDataStructAckOneKey,
|
|
29
29
|
MessageKey,
|
|
30
30
|
MessageResponse,
|
|
31
31
|
TypedCall,
|
|
32
32
|
} from '@onekeyfe/hd-transport';
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* EthereumTypedDataStructAckOneKey 与 EthereumTypedDataStructAck 的字段结构与
|
|
36
|
+
* 枚举数值完全一致(生成产物的 OneKey/Trezor 双份消息),仅枚举名义类型不同;
|
|
37
|
+
* 这里做无运行时成本的名义转换,避免在调用点散落 any。
|
|
38
|
+
*/
|
|
39
|
+
const toOneKeyStructAck = (ack: EthereumTypedDataStructAck): EthereumTypedDataStructAckOneKey =>
|
|
40
|
+
ack as unknown as EthereumTypedDataStructAckOneKey;
|
|
41
|
+
|
|
34
42
|
export type EVMSignTypedDataParams = {
|
|
35
43
|
addressN: number[];
|
|
36
44
|
metamaskV4Compat: boolean;
|
|
@@ -130,7 +138,6 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
130
138
|
if (supportTrezor) {
|
|
131
139
|
response = await typedCall(
|
|
132
140
|
'EthereumTypedDataStructAck',
|
|
133
|
-
// @ts-ignore
|
|
134
141
|
[
|
|
135
142
|
'EthereumTypedDataStructRequest',
|
|
136
143
|
'EthereumTypedDataValueRequest',
|
|
@@ -141,13 +148,12 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
141
148
|
} else {
|
|
142
149
|
response = await typedCall(
|
|
143
150
|
'EthereumTypedDataStructAckOneKey',
|
|
144
|
-
// @ts-ignore
|
|
145
151
|
[
|
|
146
152
|
'EthereumTypedDataStructRequestOneKey',
|
|
147
153
|
'EthereumTypedDataValueRequestOneKey',
|
|
148
154
|
'EthereumTypedDataSignatureOneKey',
|
|
149
155
|
],
|
|
150
|
-
dataStruckAck
|
|
156
|
+
toOneKeyStructAck(dataStruckAck)
|
|
151
157
|
);
|
|
152
158
|
}
|
|
153
159
|
}
|
|
@@ -183,7 +189,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
183
189
|
} else if (typeof memberData === 'object' && memberData !== null) {
|
|
184
190
|
const memberTypeDefinition = types[memberTypeName][index];
|
|
185
191
|
memberTypeName = memberTypeDefinition.type;
|
|
186
|
-
memberData = memberData[memberTypeDefinition.name];
|
|
192
|
+
memberData = (memberData as Record<string, unknown>)[memberTypeDefinition.name];
|
|
187
193
|
} else {
|
|
188
194
|
// TODO
|
|
189
195
|
}
|
|
@@ -220,6 +226,15 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
220
226
|
|
|
221
227
|
if (response.type === 'EthereumGnosisSafeTxRequest') {
|
|
222
228
|
const { data } = this.params;
|
|
229
|
+
const verifyingContract = data.domain?.verifyingContract;
|
|
230
|
+
// EthereumGnosisSafeTxAck.verifyingContract 在 proto 中是 required 字段,
|
|
231
|
+
// Gnosis Safe 签名缺少 verifyingContract 没有意义,这里给出明确的参数错误。
|
|
232
|
+
if (!verifyingContract) {
|
|
233
|
+
throw ERRORS.TypedError(
|
|
234
|
+
HardwareErrorCode.CallMethodInvalidParameter,
|
|
235
|
+
'EIP712Domain.verifyingContract is required for Gnosis Safe transaction'
|
|
236
|
+
);
|
|
237
|
+
}
|
|
223
238
|
const param = {
|
|
224
239
|
to: data.message.to,
|
|
225
240
|
value: formatAnyHex(new BigNumber(data.message.value).toString(16)),
|
|
@@ -232,11 +247,10 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
232
247
|
refundReceiver: data.message.refundReceiver,
|
|
233
248
|
nonce: formatAnyHex(new BigNumber(data.message.nonce).toString(16)),
|
|
234
249
|
chain_id: parseChainId(data.domain.chainId),
|
|
235
|
-
verifyingContract
|
|
250
|
+
verifyingContract,
|
|
236
251
|
};
|
|
237
252
|
response = await typedCall(
|
|
238
253
|
'EthereumGnosisSafeTxAck',
|
|
239
|
-
// @ts-ignore
|
|
240
254
|
['EthereumTypedDataSignature', 'EthereumTypedDataSignatureOneKey'],
|
|
241
255
|
param
|
|
242
256
|
);
|
|
@@ -262,8 +276,8 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
262
276
|
|
|
263
277
|
let supportTrezor = false;
|
|
264
278
|
let response: MessageResponse<MessageKey>;
|
|
265
|
-
switch (TransportManager.
|
|
266
|
-
case '
|
|
279
|
+
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
280
|
+
case 'v1LegacySchema':
|
|
267
281
|
supportTrezor = true;
|
|
268
282
|
response = await signTypedDataLegacyV1({
|
|
269
283
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
@@ -274,7 +288,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
274
288
|
});
|
|
275
289
|
break;
|
|
276
290
|
|
|
277
|
-
case '
|
|
291
|
+
case 'v1CurrentSchema':
|
|
278
292
|
default:
|
|
279
293
|
supportTrezor = false;
|
|
280
294
|
response = await signTypedData({
|
|
@@ -310,8 +324,8 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
310
324
|
}) {
|
|
311
325
|
if (!domainHash) throw ERRORS.TypedError('Runtime', 'domainHash is required');
|
|
312
326
|
|
|
313
|
-
switch (TransportManager.
|
|
314
|
-
case '
|
|
327
|
+
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
328
|
+
case 'v1LegacySchema':
|
|
315
329
|
return signTypedHashLegacyV1({
|
|
316
330
|
typedCall,
|
|
317
331
|
addressN,
|
|
@@ -321,7 +335,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
321
335
|
device: this.device,
|
|
322
336
|
});
|
|
323
337
|
|
|
324
|
-
case '
|
|
338
|
+
case 'v1CurrentSchema':
|
|
325
339
|
default:
|
|
326
340
|
return signTypedHash({
|
|
327
341
|
typedCall,
|
|
@@ -348,8 +362,8 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
348
362
|
|
|
349
363
|
let biggerLimit = 1024; // 1k
|
|
350
364
|
|
|
351
|
-
const currentVersion =
|
|
352
|
-
const currentDeviceType =
|
|
365
|
+
const currentVersion = this.device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
366
|
+
const currentDeviceType = this.device.getCurrentDeviceType();
|
|
353
367
|
const supportBiggerDataVersion = '4.4.0';
|
|
354
368
|
|
|
355
369
|
const supportBiggerData =
|
|
@@ -532,9 +546,9 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
532
546
|
}
|
|
533
547
|
|
|
534
548
|
supportSignTyped() {
|
|
535
|
-
const deviceType =
|
|
549
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
536
550
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
537
|
-
const currentVersion =
|
|
551
|
+
const currentVersion = this.device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
538
552
|
const supportSignTypedVersion = '2.2.0';
|
|
539
553
|
|
|
540
554
|
if (semver.lt(currentVersion, supportSignTypedVersion)) {
|
|
@@ -564,7 +578,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
564
578
|
// For Classic / Mini:
|
|
565
579
|
// - If parsed typed-data capability is missing, keep using blind-sign.
|
|
566
580
|
// - For Mini with parsed capability, add extra format checks before parsed signing.
|
|
567
|
-
const deviceType =
|
|
581
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
568
582
|
if (
|
|
569
583
|
DeviceModelToTypes.model_mini.includes(deviceType) &&
|
|
570
584
|
(!supportEip712OnClassic || this.hasClassicFamilyTypedDataFormatViolations(this.params.data))
|
|
@@ -31,7 +31,7 @@ export default class EVMSignMessage extends BaseMethod<EthereumVerifyMessageOneK
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
async run() {
|
|
34
|
-
if (TransportManager.
|
|
34
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
35
35
|
return verifyMessageLegacyV1({
|
|
36
36
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
37
37
|
params: this.params,
|
|
@@ -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 ?? '';
|
|
@@ -3,14 +3,7 @@ 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';
|
|
@@ -107,7 +100,7 @@ export const uploadFirmware = async (
|
|
|
107
100
|
},
|
|
108
101
|
isUpdateBootloader?: boolean
|
|
109
102
|
) => {
|
|
110
|
-
const deviceType =
|
|
103
|
+
const deviceType = device.getCurrentDeviceType();
|
|
111
104
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
112
105
|
postConfirmationMessage(device);
|
|
113
106
|
postProgressTip(device, 'ConfirmOnDevice', postMessage);
|
|
@@ -429,7 +422,7 @@ const emmcFileWriteWithRetry = async (
|
|
|
429
422
|
const deviceDiff = await device.deviceConnector?.enumerate();
|
|
430
423
|
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
431
424
|
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, undefined);
|
|
432
|
-
if (deviceList.length === 1 && deviceList[0]?.
|
|
425
|
+
if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
|
|
433
426
|
device.updateFromCache(deviceList[0]);
|
|
434
427
|
await device.acquire();
|
|
435
428
|
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,
|