@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
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
2
|
+
import { OneKeyDeviceType, OneKeySEState, OneKeySeType } from '@onekeyfe/hd-transport';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
getDeviceBLEFirmwareVersion,
|
|
6
|
+
getDeviceBoardloaderVersion,
|
|
7
|
+
getDeviceBootloaderVersion,
|
|
8
|
+
getDeviceFirmwareVersion,
|
|
9
|
+
} from '../utils/deviceVersionUtils';
|
|
10
|
+
import {
|
|
11
|
+
getDeviceBleName,
|
|
12
|
+
getDeviceLabel,
|
|
13
|
+
getDeviceType,
|
|
14
|
+
getDeviceUUID,
|
|
15
|
+
getFirmwareType,
|
|
16
|
+
} from '../utils/deviceInfoUtils';
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
DeviceInfoProtocol,
|
|
20
|
+
DeviceInfoSource,
|
|
21
|
+
DeviceInfoStatus,
|
|
22
|
+
DeviceProfile,
|
|
23
|
+
DeviceProfileRaw,
|
|
24
|
+
DeviceProfileVerify,
|
|
25
|
+
DeviceProfileVersions,
|
|
26
|
+
GetDeviceInfoParams,
|
|
27
|
+
} from '../types/api/getDeviceInfo';
|
|
28
|
+
import type { Features, OnekeyFeatures } from '../types';
|
|
29
|
+
import type { DevFirmwareImageInfo, ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
30
|
+
|
|
31
|
+
type BuildProtocolV1ProfileParams = {
|
|
32
|
+
protocol?: DeviceInfoProtocol;
|
|
33
|
+
features?: Features;
|
|
34
|
+
onekeyFeatures?: OnekeyFeatures;
|
|
35
|
+
sources?: DeviceInfoSource[];
|
|
36
|
+
scope?: GetDeviceInfoParams['scope'];
|
|
37
|
+
includeRaw?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type BuildProtocolV2ProfileParams = {
|
|
41
|
+
deviceInfo?: ProtocolV2DeviceInfo;
|
|
42
|
+
sources?: DeviceInfoSource[];
|
|
43
|
+
scope?: GetDeviceInfoParams['scope'];
|
|
44
|
+
includeRaw?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* hw.serial_no 为空时的回退身份(通常传 transport 层的 device path)。
|
|
47
|
+
* 早期 Pro2 工程板没有烧录 serial_no,空 serialNo 会导致设备无法进入
|
|
48
|
+
* DevicePool 的 devices 字典,后续 getDevice(connectId) 必然失败。
|
|
49
|
+
*/
|
|
50
|
+
fallbackSerialNo?: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const isMeaningfulVersion = (version?: string | null) => Boolean(version && version !== '0.0.0');
|
|
54
|
+
|
|
55
|
+
const firstVersion = (...versions: Array<string | null | undefined>) =>
|
|
56
|
+
versions.find(isMeaningfulVersion) ?? null;
|
|
57
|
+
|
|
58
|
+
const versionArrayToString = (version?: Array<number | string | null> | null) => {
|
|
59
|
+
if (!version || version.length === 0) return null;
|
|
60
|
+
const value = version.join('.');
|
|
61
|
+
return isMeaningfulVersion(value) ? value : null;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const bytesToHex = (value: unknown): string | undefined => {
|
|
65
|
+
if (!value) return undefined;
|
|
66
|
+
if (typeof value === 'string') return value;
|
|
67
|
+
if (value instanceof Uint8Array) {
|
|
68
|
+
return Array.from(value)
|
|
69
|
+
.map(byte => byte.toString(16).padStart(2, '0'))
|
|
70
|
+
.join('');
|
|
71
|
+
}
|
|
72
|
+
if (Array.isArray(value)) {
|
|
73
|
+
return value.map(byte => Number(byte).toString(16).padStart(2, '0')).join('');
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const getImageVersion = (image?: DevFirmwareImageInfo | null) => image?.version ?? null;
|
|
79
|
+
|
|
80
|
+
const getImageBuildId = (image?: DevFirmwareImageInfo | null) => image?.build_id ?? undefined;
|
|
81
|
+
|
|
82
|
+
const getImageHash = (image?: DevFirmwareImageInfo | null) => bytesToHex(image?.hash);
|
|
83
|
+
|
|
84
|
+
const shouldIncludeVerify = (scope?: GetDeviceInfoParams['scope']) =>
|
|
85
|
+
scope === 'verify' || scope === 'full';
|
|
86
|
+
|
|
87
|
+
const getDeviceMode = (features?: Features): DeviceInfoStatus['mode'] => {
|
|
88
|
+
if (!features) return 'unknown';
|
|
89
|
+
if (features.bootloader_mode === true) return 'bootloader';
|
|
90
|
+
if (features.initialized === false) return 'notInitialized';
|
|
91
|
+
if (features.initialized === true) return 'normal';
|
|
92
|
+
return 'unknown';
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const getProtocolV2Mode = (deviceInfo?: ProtocolV2DeviceInfo): DeviceInfoStatus['mode'] => {
|
|
96
|
+
const initialized = deviceInfo?.status?.init_states;
|
|
97
|
+
if (initialized === false) return 'notInitialized';
|
|
98
|
+
if (initialized === true) return 'normal';
|
|
99
|
+
return 'unknown';
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const normalizeV1Versions = (
|
|
103
|
+
features?: Features,
|
|
104
|
+
onekeyFeatures?: OnekeyFeatures
|
|
105
|
+
): DeviceProfileVersions => ({
|
|
106
|
+
firmware: firstVersion(
|
|
107
|
+
onekeyFeatures?.onekey_firmware_version,
|
|
108
|
+
versionArrayToString(getDeviceFirmwareVersion(features))
|
|
109
|
+
),
|
|
110
|
+
bootloader: firstVersion(
|
|
111
|
+
onekeyFeatures?.onekey_boot_version,
|
|
112
|
+
versionArrayToString(getDeviceBootloaderVersion(features))
|
|
113
|
+
),
|
|
114
|
+
board: firstVersion(
|
|
115
|
+
onekeyFeatures?.onekey_board_version,
|
|
116
|
+
versionArrayToString(features ? getDeviceBoardloaderVersion(features) : undefined)
|
|
117
|
+
),
|
|
118
|
+
ble: firstVersion(
|
|
119
|
+
onekeyFeatures?.onekey_ble_version,
|
|
120
|
+
features?.onekey_ble_version,
|
|
121
|
+
features?.ble_ver,
|
|
122
|
+
versionArrayToString(features ? getDeviceBLEFirmwareVersion(features) : undefined)
|
|
123
|
+
),
|
|
124
|
+
se01: firstVersion(onekeyFeatures?.onekey_se01_version, features?.onekey_se01_version),
|
|
125
|
+
se02: firstVersion(onekeyFeatures?.onekey_se02_version, features?.onekey_se02_version),
|
|
126
|
+
se03: firstVersion(onekeyFeatures?.onekey_se03_version, features?.onekey_se03_version),
|
|
127
|
+
se04: firstVersion(onekeyFeatures?.onekey_se04_version, features?.onekey_se04_version),
|
|
128
|
+
se01Boot: firstVersion(
|
|
129
|
+
onekeyFeatures?.onekey_se01_boot_version,
|
|
130
|
+
features?.onekey_se01_boot_version
|
|
131
|
+
),
|
|
132
|
+
se02Boot: firstVersion(
|
|
133
|
+
onekeyFeatures?.onekey_se02_boot_version,
|
|
134
|
+
features?.onekey_se02_boot_version
|
|
135
|
+
),
|
|
136
|
+
se03Boot: firstVersion(
|
|
137
|
+
onekeyFeatures?.onekey_se03_boot_version,
|
|
138
|
+
features?.onekey_se03_boot_version
|
|
139
|
+
),
|
|
140
|
+
se04Boot: firstVersion(
|
|
141
|
+
onekeyFeatures?.onekey_se04_boot_version,
|
|
142
|
+
features?.onekey_se04_boot_version
|
|
143
|
+
),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const normalizeV2Versions = (deviceInfo?: ProtocolV2DeviceInfo): DeviceProfileVersions => ({
|
|
147
|
+
firmware: firstVersion(getImageVersion(deviceInfo?.fw?.app)),
|
|
148
|
+
bootloader: firstVersion(getImageVersion(deviceInfo?.fw?.boot)),
|
|
149
|
+
board: firstVersion(getImageVersion(deviceInfo?.fw?.board)),
|
|
150
|
+
ble: firstVersion(getImageVersion(deviceInfo?.bt?.app)),
|
|
151
|
+
se01: firstVersion(getImageVersion(deviceInfo?.se1?.app)),
|
|
152
|
+
se02: firstVersion(getImageVersion(deviceInfo?.se2?.app)),
|
|
153
|
+
se03: firstVersion(getImageVersion(deviceInfo?.se3?.app)),
|
|
154
|
+
se04: firstVersion(getImageVersion(deviceInfo?.se4?.app)),
|
|
155
|
+
se01Boot: firstVersion(getImageVersion(deviceInfo?.se1?.boot)),
|
|
156
|
+
se02Boot: firstVersion(getImageVersion(deviceInfo?.se2?.boot)),
|
|
157
|
+
se03Boot: firstVersion(getImageVersion(deviceInfo?.se3?.boot)),
|
|
158
|
+
se04Boot: firstVersion(getImageVersion(deviceInfo?.se4?.boot)),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// V2 状态由 normalizeV2Status 处理,这里只服务 buildProfileFromProtocolV1 的 V1 路径。
|
|
162
|
+
const normalizeV1Status = (features?: Features): DeviceInfoStatus => ({
|
|
163
|
+
mode: getDeviceMode(features),
|
|
164
|
+
initialized: features?.initialized ?? null,
|
|
165
|
+
bootloaderMode: features?.bootloader_mode ?? null,
|
|
166
|
+
unlocked: features?.unlocked ?? null,
|
|
167
|
+
passphraseProtection: features?.passphrase_protection ?? null,
|
|
168
|
+
backupRequired: features?.needs_backup ?? null,
|
|
169
|
+
noBackup: features?.no_backup ?? null,
|
|
170
|
+
language: features?.language ?? null,
|
|
171
|
+
bleEnabled: features?.ble_enable ?? null,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const normalizeV2Status = (deviceInfo?: ProtocolV2DeviceInfo): DeviceInfoStatus => ({
|
|
175
|
+
mode: getProtocolV2Mode(deviceInfo),
|
|
176
|
+
initialized: deviceInfo?.status?.init_states ?? null,
|
|
177
|
+
bootloaderMode: false,
|
|
178
|
+
unlocked: null,
|
|
179
|
+
passphraseProtection: deviceInfo?.status?.passphrase_protection ?? null,
|
|
180
|
+
backupRequired: deviceInfo?.status?.backup_required ?? null,
|
|
181
|
+
noBackup: null,
|
|
182
|
+
language: deviceInfo?.status?.language ?? null,
|
|
183
|
+
bleEnabled: deviceInfo?.status?.bt_enable ?? null,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const normalizeV1Verify = (
|
|
187
|
+
features?: Features,
|
|
188
|
+
onekeyFeatures?: OnekeyFeatures
|
|
189
|
+
): DeviceProfileVerify => ({
|
|
190
|
+
firmwareBuildId: onekeyFeatures?.onekey_firmware_build_id ?? features?.onekey_firmware_build_id,
|
|
191
|
+
firmwareHash: onekeyFeatures?.onekey_firmware_hash ?? features?.onekey_firmware_hash,
|
|
192
|
+
bootloaderBuildId: onekeyFeatures?.onekey_boot_build_id ?? features?.onekey_boot_build_id,
|
|
193
|
+
bootloaderHash: onekeyFeatures?.onekey_boot_hash ?? features?.onekey_boot_hash,
|
|
194
|
+
boardBuildId: onekeyFeatures?.onekey_board_build_id ?? features?.onekey_board_build_id,
|
|
195
|
+
boardHash: onekeyFeatures?.onekey_board_hash ?? features?.onekey_board_hash,
|
|
196
|
+
bleBuildId: onekeyFeatures?.onekey_ble_build_id ?? features?.onekey_ble_build_id,
|
|
197
|
+
bleHash: onekeyFeatures?.onekey_ble_hash ?? features?.onekey_ble_hash,
|
|
198
|
+
se01BuildId: onekeyFeatures?.onekey_se01_build_id ?? features?.onekey_se01_build_id,
|
|
199
|
+
se01Hash: onekeyFeatures?.onekey_se01_hash ?? features?.onekey_se01_hash,
|
|
200
|
+
se02BuildId: onekeyFeatures?.onekey_se02_build_id ?? features?.onekey_se02_build_id,
|
|
201
|
+
se02Hash: onekeyFeatures?.onekey_se02_hash ?? features?.onekey_se02_hash,
|
|
202
|
+
se03BuildId: onekeyFeatures?.onekey_se03_build_id ?? features?.onekey_se03_build_id,
|
|
203
|
+
se03Hash: onekeyFeatures?.onekey_se03_hash ?? features?.onekey_se03_hash,
|
|
204
|
+
se04BuildId: onekeyFeatures?.onekey_se04_build_id ?? features?.onekey_se04_build_id,
|
|
205
|
+
se04Hash: onekeyFeatures?.onekey_se04_hash ?? features?.onekey_se04_hash,
|
|
206
|
+
se01BootBuildId: onekeyFeatures?.onekey_se01_boot_build_id ?? features?.onekey_se01_boot_build_id,
|
|
207
|
+
se01BootHash: onekeyFeatures?.onekey_se01_boot_hash ?? features?.onekey_se01_boot_hash,
|
|
208
|
+
se02BootBuildId: onekeyFeatures?.onekey_se02_boot_build_id ?? features?.onekey_se02_boot_build_id,
|
|
209
|
+
se02BootHash: onekeyFeatures?.onekey_se02_boot_hash ?? features?.onekey_se02_boot_hash,
|
|
210
|
+
se03BootBuildId: onekeyFeatures?.onekey_se03_boot_build_id ?? features?.onekey_se03_boot_build_id,
|
|
211
|
+
se03BootHash: onekeyFeatures?.onekey_se03_boot_hash ?? features?.onekey_se03_boot_hash,
|
|
212
|
+
se04BootBuildId: onekeyFeatures?.onekey_se04_boot_build_id ?? features?.onekey_se04_boot_build_id,
|
|
213
|
+
se04BootHash: onekeyFeatures?.onekey_se04_boot_hash ?? features?.onekey_se04_boot_hash,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const normalizeV2Verify = (deviceInfo?: ProtocolV2DeviceInfo): DeviceProfileVerify => ({
|
|
217
|
+
firmwareBuildId: getImageBuildId(deviceInfo?.fw?.app),
|
|
218
|
+
firmwareHash: getImageHash(deviceInfo?.fw?.app),
|
|
219
|
+
bootloaderBuildId: getImageBuildId(deviceInfo?.fw?.boot),
|
|
220
|
+
bootloaderHash: getImageHash(deviceInfo?.fw?.boot),
|
|
221
|
+
boardBuildId: getImageBuildId(deviceInfo?.fw?.board),
|
|
222
|
+
boardHash: getImageHash(deviceInfo?.fw?.board),
|
|
223
|
+
bleBuildId: getImageBuildId(deviceInfo?.bt?.app),
|
|
224
|
+
bleHash: getImageHash(deviceInfo?.bt?.app),
|
|
225
|
+
se01BuildId: getImageBuildId(deviceInfo?.se1?.app),
|
|
226
|
+
se01Hash: getImageHash(deviceInfo?.se1?.app),
|
|
227
|
+
se02BuildId: getImageBuildId(deviceInfo?.se2?.app),
|
|
228
|
+
se02Hash: getImageHash(deviceInfo?.se2?.app),
|
|
229
|
+
se03BuildId: getImageBuildId(deviceInfo?.se3?.app),
|
|
230
|
+
se03Hash: getImageHash(deviceInfo?.se3?.app),
|
|
231
|
+
se04BuildId: getImageBuildId(deviceInfo?.se4?.app),
|
|
232
|
+
se04Hash: getImageHash(deviceInfo?.se4?.app),
|
|
233
|
+
se01BootBuildId: getImageBuildId(deviceInfo?.se1?.boot),
|
|
234
|
+
se01BootHash: getImageHash(deviceInfo?.se1?.boot),
|
|
235
|
+
se02BootBuildId: getImageBuildId(deviceInfo?.se2?.boot),
|
|
236
|
+
se02BootHash: getImageHash(deviceInfo?.se2?.boot),
|
|
237
|
+
se03BootBuildId: getImageBuildId(deviceInfo?.se3?.boot),
|
|
238
|
+
se03BootHash: getImageHash(deviceInfo?.se3?.boot),
|
|
239
|
+
se04BootBuildId: getImageBuildId(deviceInfo?.se4?.boot),
|
|
240
|
+
se04BootHash: getImageHash(deviceInfo?.se4?.boot),
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const normalizeRaw = ({
|
|
244
|
+
features,
|
|
245
|
+
onekeyFeatures,
|
|
246
|
+
protocolV2DeviceInfo,
|
|
247
|
+
}: {
|
|
248
|
+
features?: Features;
|
|
249
|
+
onekeyFeatures?: OnekeyFeatures;
|
|
250
|
+
protocolV2DeviceInfo?: ProtocolV2DeviceInfo;
|
|
251
|
+
}): DeviceProfileRaw => ({
|
|
252
|
+
...(features ? { features } : {}),
|
|
253
|
+
...(onekeyFeatures ? { onekeyFeatures } : {}),
|
|
254
|
+
...(protocolV2DeviceInfo ? { protocolV2DeviceInfo } : {}),
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* V1 profile 构建用的 features 合并视图。
|
|
259
|
+
*
|
|
260
|
+
* OnekeyFeatures 与 Features 的同名字段(onekey_device_type / onekey_se_type /
|
|
261
|
+
* onekey_se0X_state)wire 同源:传输层解码会把 proto 枚举输出为名称字符串,与
|
|
262
|
+
* Features 侧的 string 声明一致,仅生成类型分别声明为枚举/字符串,这里按
|
|
263
|
+
* Features 的声明显式归一,避免整体 as Features 断言。
|
|
264
|
+
*/
|
|
265
|
+
const mergeV1Features = (
|
|
266
|
+
features?: Features,
|
|
267
|
+
onekeyFeatures?: OnekeyFeatures
|
|
268
|
+
): Features | undefined => {
|
|
269
|
+
if (!features && !onekeyFeatures) return undefined;
|
|
270
|
+
|
|
271
|
+
const {
|
|
272
|
+
onekey_device_type: onekeyDeviceType,
|
|
273
|
+
onekey_se_type: onekeySeType,
|
|
274
|
+
onekey_se01_state: onekeySe01State,
|
|
275
|
+
onekey_se02_state: onekeySe02State,
|
|
276
|
+
onekey_se03_state: onekeySe03State,
|
|
277
|
+
onekey_se04_state: onekeySe04State,
|
|
278
|
+
...restOnekeyFeatures
|
|
279
|
+
} = onekeyFeatures ?? {};
|
|
280
|
+
|
|
281
|
+
const toEnumName = (
|
|
282
|
+
enumObject: Record<string | number, string | number>,
|
|
283
|
+
value: number | string | null | undefined
|
|
284
|
+
): string | null | undefined => {
|
|
285
|
+
if (value == null || typeof value === 'string') return value;
|
|
286
|
+
const label = enumObject[value];
|
|
287
|
+
return typeof label === 'string' ? label : String(value);
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
// 仅 onekeyFeatures 的场景没有完整 Features 底座(与历史 as Features 行为一致,
|
|
292
|
+
// 该路径目前没有调用方触达:两处调用都至少携带 features)。
|
|
293
|
+
...((features ?? {}) as Features),
|
|
294
|
+
...restOnekeyFeatures,
|
|
295
|
+
...(onekeyDeviceType !== undefined
|
|
296
|
+
? { onekey_device_type: toEnumName(OneKeyDeviceType, onekeyDeviceType) }
|
|
297
|
+
: {}),
|
|
298
|
+
...(onekeySeType !== undefined
|
|
299
|
+
? { onekey_se_type: toEnumName(OneKeySeType, onekeySeType) }
|
|
300
|
+
: {}),
|
|
301
|
+
...(onekeySe01State !== undefined
|
|
302
|
+
? { onekey_se01_state: toEnumName(OneKeySEState, onekeySe01State) }
|
|
303
|
+
: {}),
|
|
304
|
+
...(onekeySe02State !== undefined
|
|
305
|
+
? { onekey_se02_state: toEnumName(OneKeySEState, onekeySe02State) }
|
|
306
|
+
: {}),
|
|
307
|
+
...(onekeySe03State !== undefined
|
|
308
|
+
? { onekey_se03_state: toEnumName(OneKeySEState, onekeySe03State) }
|
|
309
|
+
: {}),
|
|
310
|
+
...(onekeySe04State !== undefined
|
|
311
|
+
? { onekey_se04_state: toEnumName(OneKeySEState, onekeySe04State) }
|
|
312
|
+
: {}),
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export function buildProfileFromProtocolV1({
|
|
317
|
+
protocol = 'V1',
|
|
318
|
+
features,
|
|
319
|
+
onekeyFeatures,
|
|
320
|
+
sources = ['features'],
|
|
321
|
+
scope = 'basic',
|
|
322
|
+
includeRaw = false,
|
|
323
|
+
}: BuildProtocolV1ProfileParams): DeviceProfile {
|
|
324
|
+
const sourceFeatures = mergeV1Features(features, onekeyFeatures);
|
|
325
|
+
const verify = normalizeV1Verify(sourceFeatures, onekeyFeatures);
|
|
326
|
+
|
|
327
|
+
return {
|
|
328
|
+
protocol,
|
|
329
|
+
sources,
|
|
330
|
+
deviceType: getDeviceType(sourceFeatures),
|
|
331
|
+
firmwareType: getFirmwareType(sourceFeatures),
|
|
332
|
+
deviceId: sourceFeatures?.device_id || (sourceFeatures ? getDeviceUUID(sourceFeatures) : ''),
|
|
333
|
+
serialNo: sourceFeatures ? getDeviceUUID(sourceFeatures) : '',
|
|
334
|
+
label: getDeviceLabel(sourceFeatures),
|
|
335
|
+
bleName: getDeviceBleName(sourceFeatures),
|
|
336
|
+
status: normalizeV1Status(sourceFeatures),
|
|
337
|
+
versions: normalizeV1Versions(sourceFeatures, onekeyFeatures),
|
|
338
|
+
...(shouldIncludeVerify(scope) ? { verify } : {}),
|
|
339
|
+
...(includeRaw
|
|
340
|
+
? {
|
|
341
|
+
raw: normalizeRaw({
|
|
342
|
+
features,
|
|
343
|
+
onekeyFeatures,
|
|
344
|
+
}),
|
|
345
|
+
}
|
|
346
|
+
: {}),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export function buildProfileFromProtocolV2({
|
|
351
|
+
deviceInfo,
|
|
352
|
+
sources = ['deviceInfo'],
|
|
353
|
+
scope = 'basic',
|
|
354
|
+
includeRaw = false,
|
|
355
|
+
fallbackSerialNo,
|
|
356
|
+
}: BuildProtocolV2ProfileParams): DeviceProfile {
|
|
357
|
+
// 早期工程板 hw.serial_no 为空串,回退到调用方提供的 transport path(mock 身份)。
|
|
358
|
+
const serialNo = deviceInfo?.hw?.serial_no || fallbackSerialNo || '';
|
|
359
|
+
const label = deviceInfo?.status?.label ?? null;
|
|
360
|
+
const bleName = deviceInfo?.bt?.adv_name ?? null;
|
|
361
|
+
const verify = normalizeV2Verify(deviceInfo);
|
|
362
|
+
|
|
363
|
+
return {
|
|
364
|
+
protocol: 'V2',
|
|
365
|
+
sources,
|
|
366
|
+
deviceType: EDeviceType.Pro2,
|
|
367
|
+
firmwareType: EFirmwareType.Universal,
|
|
368
|
+
// Protocol V2 的 DevGetDeviceInfo 没有 device_id 字段(固件 proto 仅提供 hw.serial_no),
|
|
369
|
+
// 这里只能回退 serialNo。注意语义差异:V1 的 device_id 随擦除/换种子轮换,serialNo 永不变化。
|
|
370
|
+
// 固件在 DevStatus 暴露 device_id 后,此处必须改为读取它,否则 wipe 后基于 deviceId 的
|
|
371
|
+
// session 缓存(deviceSessionCache)不会自然失效。
|
|
372
|
+
deviceId: serialNo,
|
|
373
|
+
serialNo,
|
|
374
|
+
label,
|
|
375
|
+
bleName,
|
|
376
|
+
status: normalizeV2Status(deviceInfo),
|
|
377
|
+
versions: normalizeV2Versions(deviceInfo),
|
|
378
|
+
...(shouldIncludeVerify(scope) ? { verify } : {}),
|
|
379
|
+
...(includeRaw
|
|
380
|
+
? {
|
|
381
|
+
raw: normalizeRaw({
|
|
382
|
+
protocolV2DeviceInfo: deviceInfo,
|
|
383
|
+
}),
|
|
384
|
+
}
|
|
385
|
+
: {}),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
import { getProtocolV2SeState, getProtocolV2SeType } from '../protocols/protocol-v2/features';
|
|
4
|
+
|
|
5
|
+
import type { Features } from '../types';
|
|
6
|
+
import type { DeviceProfile } from '../types/api/getDeviceInfo';
|
|
7
|
+
import type { ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
8
|
+
|
|
9
|
+
const parseProtocolV2Version = (version?: string | null): [number, number, number] => {
|
|
10
|
+
if (!version) return [0, 0, 0];
|
|
11
|
+
const [major = 0, minor = 0, patch = 0] = version.split('.').map(part => Number(part) || 0);
|
|
12
|
+
return [major, minor, patch];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Protocol V2 的 legacy `Features` 兼容视图。
|
|
17
|
+
*
|
|
18
|
+
* SDK 内部标准模型是 DeviceProfile;该函数只为 getFeatures() 等旧 API
|
|
19
|
+
* 临时合成 Features 形状的数据,不应被内部逻辑消费。
|
|
20
|
+
*
|
|
21
|
+
* 注意:以下字段在 V2 协议中没有等价信息,使用保守占位值——
|
|
22
|
+
* bootloader_mode/firmware_present 恒 false、unlocked 恒 false、
|
|
23
|
+
* capabilities 恒空、pin_protection/safety_checks 等恒 null。
|
|
24
|
+
* 内部判断请使用 device.profile / getCurrent* accessor,而不是这些占位值。
|
|
25
|
+
*/
|
|
26
|
+
export const buildProtocolV2GetFeaturesPayload = (
|
|
27
|
+
profile: DeviceProfile,
|
|
28
|
+
deviceInfo?: ProtocolV2DeviceInfo
|
|
29
|
+
): Features => {
|
|
30
|
+
const firmwareVersion = profile.versions.firmware;
|
|
31
|
+
const [fwMajor, fwMinor, fwPatch] = parseProtocolV2Version(firmwareVersion);
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
vendor: 'onekey.so',
|
|
35
|
+
major_version: fwMajor,
|
|
36
|
+
minor_version: fwMinor,
|
|
37
|
+
patch_version: fwPatch,
|
|
38
|
+
bootloader_mode: false,
|
|
39
|
+
device_id: profile.deviceId,
|
|
40
|
+
pin_protection: null,
|
|
41
|
+
passphrase_protection: profile.status.passphraseProtection,
|
|
42
|
+
language: profile.status.language,
|
|
43
|
+
label: profile.label,
|
|
44
|
+
initialized: profile.status.initialized ?? false,
|
|
45
|
+
revision: null,
|
|
46
|
+
bootloader_hash: null,
|
|
47
|
+
imported: null,
|
|
48
|
+
unlocked: false,
|
|
49
|
+
firmware_present: false,
|
|
50
|
+
needs_backup: profile.status.backupRequired,
|
|
51
|
+
flags: null,
|
|
52
|
+
model: 'pro2',
|
|
53
|
+
fw_major: fwMajor,
|
|
54
|
+
fw_minor: fwMinor,
|
|
55
|
+
fw_patch: fwPatch,
|
|
56
|
+
fw_vendor: null,
|
|
57
|
+
unfinished_backup: null,
|
|
58
|
+
no_backup: null,
|
|
59
|
+
recovery_mode: null,
|
|
60
|
+
capabilities: [],
|
|
61
|
+
backup_type: null,
|
|
62
|
+
sd_card_present: null,
|
|
63
|
+
sd_protection: null,
|
|
64
|
+
wipe_code_protection: null,
|
|
65
|
+
session_id: null,
|
|
66
|
+
passphrase_always_on_device: null,
|
|
67
|
+
safety_checks: null,
|
|
68
|
+
auto_lock_delay_ms: null,
|
|
69
|
+
display_rotation: null,
|
|
70
|
+
experimental_features: null,
|
|
71
|
+
protocol_version: deviceInfo?.protocol_version ?? null,
|
|
72
|
+
onekey_device_type: EDeviceType.Pro2,
|
|
73
|
+
onekey_serial_no: profile.serialNo,
|
|
74
|
+
serial_no: profile.serialNo,
|
|
75
|
+
ble_enable: profile.status.bleEnabled ?? undefined,
|
|
76
|
+
onekey_ble_name: profile.bleName ?? undefined,
|
|
77
|
+
ble_name: profile.bleName ?? undefined,
|
|
78
|
+
onekey_firmware_version: firmwareVersion ?? undefined,
|
|
79
|
+
onekey_firmware_build_id: profile.verify?.firmwareBuildId,
|
|
80
|
+
onekey_firmware_hash: profile.verify?.firmwareHash,
|
|
81
|
+
onekey_boot_version: profile.versions.bootloader ?? undefined,
|
|
82
|
+
bootloader_version: profile.versions.bootloader ?? undefined,
|
|
83
|
+
onekey_boot_build_id: profile.verify?.bootloaderBuildId,
|
|
84
|
+
onekey_boot_hash: profile.verify?.bootloaderHash,
|
|
85
|
+
onekey_board_version: profile.versions.board ?? undefined,
|
|
86
|
+
onekey_board_build_id: profile.verify?.boardBuildId,
|
|
87
|
+
onekey_board_hash: profile.verify?.boardHash,
|
|
88
|
+
onekey_ble_version: profile.versions.ble ?? undefined,
|
|
89
|
+
ble_ver: profile.versions.ble ?? undefined,
|
|
90
|
+
onekey_ble_build_id: profile.verify?.bleBuildId,
|
|
91
|
+
onekey_ble_hash: profile.verify?.bleHash,
|
|
92
|
+
// Pro2 的 SE 类型在 DevGetDeviceInfo 的 se1.type 上报(如 THD89)
|
|
93
|
+
onekey_se_type: getProtocolV2SeType(deviceInfo?.se1),
|
|
94
|
+
onekey_se01_version: profile.versions.se01 ?? undefined,
|
|
95
|
+
onekey_se01_hash: profile.verify?.se01Hash,
|
|
96
|
+
onekey_se01_build_id: profile.verify?.se01BuildId,
|
|
97
|
+
onekey_se01_boot_version: profile.versions.se01Boot ?? undefined,
|
|
98
|
+
onekey_se01_boot_hash: profile.verify?.se01BootHash,
|
|
99
|
+
onekey_se01_boot_build_id: profile.verify?.se01BootBuildId,
|
|
100
|
+
onekey_se01_state: getProtocolV2SeState(deviceInfo?.se1),
|
|
101
|
+
onekey_se02_version: profile.versions.se02 ?? undefined,
|
|
102
|
+
onekey_se02_hash: profile.verify?.se02Hash,
|
|
103
|
+
onekey_se02_build_id: profile.verify?.se02BuildId,
|
|
104
|
+
onekey_se02_boot_version: profile.versions.se02Boot ?? undefined,
|
|
105
|
+
onekey_se02_boot_hash: profile.verify?.se02BootHash,
|
|
106
|
+
onekey_se02_boot_build_id: profile.verify?.se02BootBuildId,
|
|
107
|
+
onekey_se02_state: getProtocolV2SeState(deviceInfo?.se2),
|
|
108
|
+
onekey_se03_version: profile.versions.se03 ?? undefined,
|
|
109
|
+
onekey_se03_hash: profile.verify?.se03Hash,
|
|
110
|
+
onekey_se03_build_id: profile.verify?.se03BuildId,
|
|
111
|
+
onekey_se03_boot_version: profile.versions.se03Boot ?? undefined,
|
|
112
|
+
onekey_se03_boot_hash: profile.verify?.se03BootHash,
|
|
113
|
+
onekey_se03_boot_build_id: profile.verify?.se03BootBuildId,
|
|
114
|
+
onekey_se03_state: getProtocolV2SeState(deviceInfo?.se3),
|
|
115
|
+
onekey_se04_version: profile.versions.se04 ?? undefined,
|
|
116
|
+
onekey_se04_hash: profile.verify?.se04Hash,
|
|
117
|
+
onekey_se04_build_id: profile.verify?.se04BuildId,
|
|
118
|
+
onekey_se04_boot_version: profile.versions.se04Boot ?? undefined,
|
|
119
|
+
onekey_se04_boot_hash: profile.verify?.se04BootHash,
|
|
120
|
+
onekey_se04_boot_build_id: profile.verify?.se04BootBuildId,
|
|
121
|
+
onekey_se04_state: getProtocolV2SeState(deviceInfo?.se4),
|
|
122
|
+
};
|
|
123
|
+
};
|
|
@@ -4,3 +4,26 @@ export const LogBlockEvent: Set<string> = new Set([
|
|
|
4
4
|
UI_RESPONSE.RECEIVE_PIN,
|
|
5
5
|
UI_RESPONSE.RECEIVE_PASSPHRASE,
|
|
6
6
|
]);
|
|
7
|
+
|
|
8
|
+
const LogBlockMethod: Set<string> = new Set(['evmSignTypedData']);
|
|
9
|
+
|
|
10
|
+
export function getLogBlockLabel(message: unknown): string | undefined {
|
|
11
|
+
if (!message || typeof message !== 'object') return undefined;
|
|
12
|
+
|
|
13
|
+
const { type, payload, method } = message as {
|
|
14
|
+
type?: string;
|
|
15
|
+
payload?: { method?: string };
|
|
16
|
+
method?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (type && LogBlockEvent.has(type)) {
|
|
20
|
+
return type;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const methodName = method ?? payload?.method;
|
|
24
|
+
if (methodName && LogBlockMethod.has(methodName)) {
|
|
25
|
+
return methodName;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
package/src/events/ui-request.ts
CHANGED
|
@@ -129,6 +129,10 @@ export interface FirmwareProgress {
|
|
|
129
129
|
device: Device;
|
|
130
130
|
progress: number;
|
|
131
131
|
progressType: IFirmwareUpdateProgressType;
|
|
132
|
+
transferredBytes?: number;
|
|
133
|
+
totalBytes?: number;
|
|
134
|
+
rateBytesPerSecond?: number;
|
|
135
|
+
elapsedMs?: number;
|
|
132
136
|
};
|
|
133
137
|
}
|
|
134
138
|
|
|
@@ -144,6 +148,10 @@ export interface DeviceProgress {
|
|
|
144
148
|
type: typeof UI_REQUEST.DEVICE_PROGRESS;
|
|
145
149
|
payload: {
|
|
146
150
|
progress?: number;
|
|
151
|
+
transferredBytes?: number;
|
|
152
|
+
totalBytes?: number;
|
|
153
|
+
rateBytesPerSecond?: number;
|
|
154
|
+
elapsedMs?: number;
|
|
147
155
|
};
|
|
148
156
|
}
|
|
149
157
|
|
package/src/inject.ts
CHANGED
|
@@ -103,12 +103,13 @@ export const createCoreApi = (
|
|
|
103
103
|
/**
|
|
104
104
|
* 搜索设备
|
|
105
105
|
*/
|
|
106
|
-
searchDevices:
|
|
106
|
+
searchDevices: params => call({ ...params, method: 'searchDevices' }),
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* 获取设备信息
|
|
110
110
|
*/
|
|
111
111
|
getFeatures: (connectId, params) => call({ ...params, connectId, method: 'getFeatures' }),
|
|
112
|
+
getDeviceInfo: (connectId, params) => call({ ...params, connectId, method: 'getDeviceInfo' }),
|
|
112
113
|
getOnekeyFeatures: (connectId, params) =>
|
|
113
114
|
call({ ...params, connectId, method: 'getOnekeyFeatures' }),
|
|
114
115
|
|
|
@@ -148,6 +149,54 @@ export const createCoreApi = (
|
|
|
148
149
|
deviceFlags: (connectId, params) => call({ ...params, connectId, method: 'deviceFlags' }),
|
|
149
150
|
deviceRebootToBoardloader: connectId => call({ connectId, method: 'deviceRebootToBoardloader' }),
|
|
150
151
|
deviceRebootToBootloader: connectId => call({ connectId, method: 'deviceRebootToBootloader' }),
|
|
152
|
+
|
|
153
|
+
// File system & device control API (Protocol V2 only)
|
|
154
|
+
getProtoVersion: (connectId, params) => call({ ...params, connectId, method: 'getProtoVersion' }),
|
|
155
|
+
ping: (connectId, params) => call({ ...params, connectId, method: 'ping' }),
|
|
156
|
+
deviceReboot: (connectId, params) => call({ ...params, connectId, method: 'deviceReboot' }),
|
|
157
|
+
deviceGetDeviceInfo: (connectId, params) =>
|
|
158
|
+
call({ ...params, connectId, method: 'deviceGetDeviceInfo' }),
|
|
159
|
+
deviceGetOnboardingStatus: (connectId, params) =>
|
|
160
|
+
call({ ...params, connectId, method: 'deviceGetOnboardingStatus' }),
|
|
161
|
+
deviceFirmwareUpdate: (connectId, params) =>
|
|
162
|
+
call({ ...params, connectId, method: 'deviceFirmwareUpdate' }),
|
|
163
|
+
deviceGetFirmwareUpdateStatus: (connectId, params) =>
|
|
164
|
+
call({ ...params, connectId, method: 'deviceGetFirmwareUpdateStatus' }),
|
|
165
|
+
devReboot: (connectId, params) => call({ ...params, connectId, method: 'devReboot' }),
|
|
166
|
+
devGetDeviceInfo: (connectId, params) =>
|
|
167
|
+
call({ ...params, connectId, method: 'devGetDeviceInfo' }),
|
|
168
|
+
devFirmwareUpdate: (connectId, params) =>
|
|
169
|
+
call({ ...params, connectId, method: 'devFirmwareUpdate' }),
|
|
170
|
+
devGetFirmwareUpdateStatus: (connectId, params) =>
|
|
171
|
+
call({ ...params, connectId, method: 'devGetFirmwareUpdateStatus' }),
|
|
172
|
+
factoryDeviceInfoSettings: (connectId, params) =>
|
|
173
|
+
call({ ...params, connectId, method: 'factoryDeviceInfoSettings' }),
|
|
174
|
+
factoryGetDeviceInfo: connectId => call({ connectId, method: 'factoryGetDeviceInfo' }),
|
|
175
|
+
filesystemFixPermission: connectId => call({ connectId, method: 'filesystemFixPermission' }),
|
|
176
|
+
fileRead: (connectId, params) => call({ ...params, connectId, method: 'fileRead' }),
|
|
177
|
+
fileWrite: (connectId, params) => call({ ...params, connectId, method: 'fileWrite' }),
|
|
178
|
+
fileDelete: (connectId, params) => call({ ...params, connectId, method: 'fileDelete' }),
|
|
179
|
+
dirList: (connectId, params) => call({ ...params, connectId, method: 'dirList' }),
|
|
180
|
+
dirMake: (connectId, params) => call({ ...params, connectId, method: 'dirMake' }),
|
|
181
|
+
dirRemove: (connectId, params) => call({ ...params, connectId, method: 'dirRemove' }),
|
|
182
|
+
pathInfo: (connectId, params) => call({ ...params, connectId, method: 'pathInfo' }),
|
|
183
|
+
filesystemFileRead: (connectId, params) =>
|
|
184
|
+
call({ ...params, connectId, method: 'filesystemFileRead' }),
|
|
185
|
+
filesystemFileWrite: (connectId, params) =>
|
|
186
|
+
call({ ...params, connectId, method: 'filesystemFileWrite' }),
|
|
187
|
+
filesystemFileDelete: (connectId, params) =>
|
|
188
|
+
call({ ...params, connectId, method: 'filesystemFileDelete' }),
|
|
189
|
+
filesystemDirList: (connectId, params) =>
|
|
190
|
+
call({ ...params, connectId, method: 'filesystemDirList' }),
|
|
191
|
+
filesystemDirMake: (connectId, params) =>
|
|
192
|
+
call({ ...params, connectId, method: 'filesystemDirMake' }),
|
|
193
|
+
filesystemDirRemove: (connectId, params) =>
|
|
194
|
+
call({ ...params, connectId, method: 'filesystemDirRemove' }),
|
|
195
|
+
filesystemPathInfoQuery: (connectId, params) =>
|
|
196
|
+
call({ ...params, connectId, method: 'filesystemPathInfoQuery' }),
|
|
197
|
+
filesystemFormat: connectId => call({ connectId, method: 'filesystemFormat' }),
|
|
198
|
+
filesystemDiskControl: (connectId, params) =>
|
|
199
|
+
call({ ...params, connectId, method: 'filesystemDiskControl' }),
|
|
151
200
|
deviceRecovery: (connectId, params) => call({ ...params, connectId, method: 'deviceRecovery' }),
|
|
152
201
|
deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
|
|
153
202
|
deviceSettings: (connectId, params) => call({ ...params, connectId, method: 'deviceSettings' }),
|
|
@@ -260,6 +309,8 @@ export const createCoreApi = (
|
|
|
260
309
|
call({ ...params, connectId, method: 'firmwareUpdateV2' }),
|
|
261
310
|
firmwareUpdateV3: (connectId, params) =>
|
|
262
311
|
call({ ...params, connectId, method: 'firmwareUpdateV3' }),
|
|
312
|
+
firmwareUpdateV4: (connectId, params) =>
|
|
313
|
+
call({ ...params, connectId, method: 'firmwareUpdateV4' }),
|
|
263
314
|
promptWebDeviceAccess: params => call({ ...params, method: 'promptWebDeviceAccess' }),
|
|
264
315
|
|
|
265
316
|
tronGetAddress: (connectId, deviceId, params) =>
|