@onekeyfe/hd-core 1.1.27-patch.1 → 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
|
@@ -2,7 +2,7 @@ import { ERRORS, HardwareError, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
|
2
2
|
|
|
3
3
|
import TransportManager from '../data-manager/TransportManager';
|
|
4
4
|
import DataManager from '../data-manager/DataManager';
|
|
5
|
-
import { LoggerNames,
|
|
5
|
+
import { LoggerNames, getLogger, patchFeatures } from '../utils';
|
|
6
6
|
import { DEVICE, type PassphraseRequestPayload } from '../events';
|
|
7
7
|
import { DeviceModelToTypes } from '../types';
|
|
8
8
|
import {
|
|
@@ -12,7 +12,12 @@ import {
|
|
|
12
12
|
} from '../utils/tracing';
|
|
13
13
|
|
|
14
14
|
import type { Device } from './Device';
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
FailureType,
|
|
17
|
+
Messages,
|
|
18
|
+
Transport,
|
|
19
|
+
TransportCallOptions,
|
|
20
|
+
} from '@onekeyfe/hd-transport';
|
|
16
21
|
|
|
17
22
|
export type PassphrasePromptResponse = {
|
|
18
23
|
passphrase?: string;
|
|
@@ -22,15 +27,132 @@ export type PassphrasePromptResponse = {
|
|
|
22
27
|
};
|
|
23
28
|
|
|
24
29
|
type MessageType = Messages.MessageType;
|
|
25
|
-
type MessageKey = keyof MessageType
|
|
30
|
+
type MessageKey = Extract<keyof MessageType, string>;
|
|
26
31
|
export type TypedResponseMessage<T extends MessageKey> = {
|
|
27
32
|
type: T;
|
|
28
33
|
message: MessageType[T];
|
|
29
34
|
};
|
|
30
35
|
type TypedCallResponseMap = {
|
|
31
|
-
[K in
|
|
36
|
+
[K in MessageKey]: TypedResponseMessage<K>;
|
|
37
|
+
};
|
|
38
|
+
export type DefaultMessageResponse = TypedCallResponseMap[MessageKey];
|
|
39
|
+
|
|
40
|
+
const MAX_DEBUG_ARRAY_ITEMS = 20;
|
|
41
|
+
const MAX_DEBUG_OBJECT_KEYS = 40;
|
|
42
|
+
const MAX_DEBUG_STRING_LENGTH = 512;
|
|
43
|
+
const MAX_DEBUG_DEPTH = 4;
|
|
44
|
+
const HIGH_VOLUME_DEBUG_CALLS = new Set([
|
|
45
|
+
'FilesystemFileRead',
|
|
46
|
+
'FilesystemFileWrite',
|
|
47
|
+
'FileRead',
|
|
48
|
+
'FileWrite',
|
|
49
|
+
'EmmcFileRead',
|
|
50
|
+
'EmmcFileWrite',
|
|
51
|
+
'FirmwareUpload',
|
|
52
|
+
'ResourceAck',
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
function shouldReduceDebugForCall(type: string) {
|
|
56
|
+
return HIGH_VOLUME_DEBUG_CALLS.has(type);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getBinaryByteLength(value: unknown): number | undefined {
|
|
60
|
+
if (value instanceof ArrayBuffer) {
|
|
61
|
+
return value.byteLength;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (ArrayBuffer.isView(value)) {
|
|
65
|
+
return value.byteLength;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (typeof Blob !== 'undefined' && value instanceof Blob) {
|
|
69
|
+
return value.size;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function summarizeRedactedData(value: unknown): string {
|
|
76
|
+
const byteLength = getBinaryByteLength(value);
|
|
77
|
+
if (byteLength !== undefined) {
|
|
78
|
+
return `[redacted data: ${byteLength} bytes]`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (typeof value === 'string') {
|
|
82
|
+
return `[redacted data: string length=${value.length}]`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
return `[redacted data: array length=${value.length}]`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (value && typeof value === 'object') {
|
|
90
|
+
return `[redacted data: object keys=${Object.keys(value).length}]`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return `[redacted data: ${typeof value}]`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function sanitizeDebugPayload(value: unknown, key = '', depth = 0): unknown {
|
|
97
|
+
if (key === 'data' && value !== null && value !== undefined) {
|
|
98
|
+
return summarizeRedactedData(value);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const byteLength = getBinaryByteLength(value);
|
|
102
|
+
if (byteLength !== undefined) {
|
|
103
|
+
return `[binary: ${byteLength} bytes]`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (typeof value === 'string') {
|
|
107
|
+
return value.length > MAX_DEBUG_STRING_LENGTH
|
|
108
|
+
? `${value.slice(0, MAX_DEBUG_STRING_LENGTH)}... (len=${value.length})`
|
|
109
|
+
: value;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!value || typeof value !== 'object') {
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (depth >= MAX_DEBUG_DEPTH) {
|
|
117
|
+
return Array.isArray(value)
|
|
118
|
+
? `[array length=${value.length}]`
|
|
119
|
+
: `[object keys=${Object.keys(value).length}]`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (Array.isArray(value)) {
|
|
123
|
+
const items = value
|
|
124
|
+
.slice(0, MAX_DEBUG_ARRAY_ITEMS)
|
|
125
|
+
.map(item => sanitizeDebugPayload(item, key, depth + 1));
|
|
126
|
+
if (value.length > MAX_DEBUG_ARRAY_ITEMS) {
|
|
127
|
+
items.push(`... (${value.length - MAX_DEBUG_ARRAY_ITEMS} more)`);
|
|
128
|
+
}
|
|
129
|
+
return items;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const entries = Object.entries(value).slice(0, MAX_DEBUG_OBJECT_KEYS);
|
|
133
|
+
const sanitized: Record<string, unknown> = {};
|
|
134
|
+
entries.forEach(([entryKey, entryValue]) => {
|
|
135
|
+
sanitized[entryKey] = sanitizeDebugPayload(entryValue, entryKey, depth + 1);
|
|
136
|
+
});
|
|
137
|
+
if (Object.keys(value).length > MAX_DEBUG_OBJECT_KEYS) {
|
|
138
|
+
sanitized.__truncated__ = `${Object.keys(value).length - MAX_DEBUG_OBJECT_KEYS} more keys`;
|
|
139
|
+
}
|
|
140
|
+
return sanitized;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 交互式 Ack(ButtonAck / PinMatrixAck / PassphraseAck 等)不应继承原调用的
|
|
145
|
+
* timeoutMs:设备在等待用户操作(确认、输入 PIN/passphrase),思考时间不可预估,
|
|
146
|
+
* 沿用业务调用的超时会把用户操作截断。仅保留 expectedTypes / intermediateTypes
|
|
147
|
+
* 等与响应类型相关的选项。
|
|
148
|
+
*/
|
|
149
|
+
const stripInteractiveAckTimeout = (
|
|
150
|
+
options?: TransportCallOptions
|
|
151
|
+
): TransportCallOptions | undefined => {
|
|
152
|
+
if (!options) return options;
|
|
153
|
+
const { timeoutMs: _timeoutMs, ...rest } = options;
|
|
154
|
+
return rest;
|
|
32
155
|
};
|
|
33
|
-
export type DefaultMessageResponse = TypedCallResponseMap[keyof MessageType];
|
|
34
156
|
|
|
35
157
|
const assertType = (res: DefaultMessageResponse, resType: string | string[]) => {
|
|
36
158
|
const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
|
|
@@ -224,17 +346,21 @@ export class DeviceCommands {
|
|
|
224
346
|
// Sends an async message to the opened device.
|
|
225
347
|
async call(
|
|
226
348
|
type: MessageKey,
|
|
227
|
-
msg
|
|
349
|
+
msg?: DefaultMessageResponse['message'],
|
|
350
|
+
options?: TransportCallOptions
|
|
228
351
|
): Promise<DefaultMessageResponse> {
|
|
229
|
-
|
|
352
|
+
const shouldReduceDebug = shouldReduceDebugForCall(type);
|
|
353
|
+
if (!shouldReduceDebug) {
|
|
354
|
+
Log.debug('[DeviceCommands] [call] Sending', type);
|
|
355
|
+
}
|
|
230
356
|
|
|
231
357
|
try {
|
|
232
|
-
const promise = this.transport.call(this.mainId, type, msg) as any;
|
|
358
|
+
const promise = this.transport.call(this.mainId, type, msg ?? {}, options) as any;
|
|
233
359
|
this.callPromise = promise;
|
|
234
360
|
const res = await promise;
|
|
235
361
|
if (res.type === 'Failure') {
|
|
236
362
|
LogCore.debug('[DeviceCommands] [call] Received', res.type, res.message);
|
|
237
|
-
} else {
|
|
363
|
+
} else if (!shouldReduceDebug) {
|
|
238
364
|
LogCore.debug('[DeviceCommands] [call] Received', res.type);
|
|
239
365
|
}
|
|
240
366
|
return res;
|
|
@@ -283,19 +409,22 @@ export class DeviceCommands {
|
|
|
283
409
|
typedCall<T extends MessageKey, R extends MessageKey[]>(
|
|
284
410
|
type: T,
|
|
285
411
|
resType: R,
|
|
286
|
-
msg?: MessageType[T]
|
|
412
|
+
msg?: MessageType[T],
|
|
413
|
+
options?: TransportCallOptions
|
|
287
414
|
): Promise<TypedCallResponseMap[R[number]]>;
|
|
288
415
|
|
|
289
416
|
typedCall<T extends MessageKey, R extends MessageKey>(
|
|
290
417
|
type: T,
|
|
291
418
|
resType: R,
|
|
292
|
-
msg?: MessageType[T]
|
|
419
|
+
msg?: MessageType[T],
|
|
420
|
+
options?: TransportCallOptions
|
|
293
421
|
): Promise<TypedResponseMessage<R>>;
|
|
294
422
|
|
|
295
423
|
async typedCall(
|
|
296
424
|
type: MessageKey,
|
|
297
425
|
resType: MessageKey | MessageKey[],
|
|
298
|
-
msg?: DefaultMessageResponse['message']
|
|
426
|
+
msg?: DefaultMessageResponse['message'],
|
|
427
|
+
options?: TransportCallOptions
|
|
299
428
|
) {
|
|
300
429
|
if (this.disposed) {
|
|
301
430
|
throw ERRORS.TypedError(
|
|
@@ -312,16 +441,28 @@ export class DeviceCommands {
|
|
|
312
441
|
'PassphraseAck',
|
|
313
442
|
'Cancel',
|
|
314
443
|
'BixinPinInputOnDevice',
|
|
444
|
+
'FilesystemFileRead',
|
|
445
|
+
'FilesystemFileWrite',
|
|
446
|
+
'FileRead',
|
|
447
|
+
'FileWrite',
|
|
448
|
+
'EmmcFileRead',
|
|
449
|
+
'EmmcFileWrite',
|
|
450
|
+
'FirmwareUpload',
|
|
451
|
+
'ResourceAck',
|
|
315
452
|
] as any;
|
|
316
453
|
if (!skipTypes.includes(type) && msg) {
|
|
317
454
|
// Use debug channel to avoid noise escalation
|
|
318
|
-
Log.debug('[DeviceCommands] [typedCall] Sending payload', type, msg);
|
|
455
|
+
Log.debug('[DeviceCommands] [typedCall] Sending payload', type, sanitizeDebugPayload(msg));
|
|
319
456
|
}
|
|
320
457
|
} catch (e) {
|
|
321
458
|
// ignore logging errors
|
|
322
459
|
}
|
|
323
460
|
|
|
324
|
-
const
|
|
461
|
+
const expectedTypes = Array.isArray(resType) ? resType : resType.split('|');
|
|
462
|
+
const response = await this._commonCall(type, msg, {
|
|
463
|
+
...options,
|
|
464
|
+
expectedTypes: options?.expectedTypes ?? expectedTypes,
|
|
465
|
+
});
|
|
325
466
|
try {
|
|
326
467
|
assertType(response, resType);
|
|
327
468
|
} catch (error) {
|
|
@@ -334,6 +475,12 @@ export class DeviceCommands {
|
|
|
334
475
|
// throw bridge network error
|
|
335
476
|
if (error instanceof HardwareError) {
|
|
336
477
|
if (error.errorCode === HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
478
|
+
Log.debug('[DeviceCommands] [typedCall] Unexpected response type', {
|
|
479
|
+
request: type,
|
|
480
|
+
expected: resType,
|
|
481
|
+
received: response.type,
|
|
482
|
+
response: sanitizeDebugPayload(response.message),
|
|
483
|
+
});
|
|
337
484
|
// Do not intercept CallMethodError
|
|
338
485
|
// Do not intercept “assertType: Response of unexpected type” error
|
|
339
486
|
// Blocking the above two messages will not know what the specific error message is, and the specific error should be handled by the subsequent business logic.
|
|
@@ -347,7 +494,7 @@ export class DeviceCommands {
|
|
|
347
494
|
if (error.message.indexOf('BridgeDeviceDisconnected') > -1) {
|
|
348
495
|
throw ERRORS.TypedError(HardwareErrorCode.BridgeDeviceDisconnected);
|
|
349
496
|
}
|
|
350
|
-
throw
|
|
497
|
+
throw error;
|
|
351
498
|
}
|
|
352
499
|
} else {
|
|
353
500
|
// throw error anyway, next call should be resolved properly// throw error anyway, next call should be resolved properly
|
|
@@ -357,20 +504,27 @@ export class DeviceCommands {
|
|
|
357
504
|
return response;
|
|
358
505
|
}
|
|
359
506
|
|
|
360
|
-
async _commonCall(
|
|
361
|
-
|
|
362
|
-
|
|
507
|
+
async _commonCall(
|
|
508
|
+
type: MessageKey,
|
|
509
|
+
msg?: DefaultMessageResponse['message'],
|
|
510
|
+
options?: TransportCallOptions
|
|
511
|
+
) {
|
|
512
|
+
const resp = await this.call(type, msg, options);
|
|
513
|
+
return this._filterCommonTypes(resp, type, options);
|
|
363
514
|
}
|
|
364
515
|
|
|
365
516
|
_filterCommonTypes(
|
|
366
517
|
res: DefaultMessageResponse,
|
|
367
|
-
callType: MessageKey
|
|
518
|
+
callType: MessageKey,
|
|
519
|
+
options?: TransportCallOptions
|
|
368
520
|
): Promise<DefaultMessageResponse> {
|
|
369
521
|
try {
|
|
370
|
-
if (
|
|
371
|
-
|
|
522
|
+
if (shouldReduceDebugForCall(callType)) {
|
|
523
|
+
// 高频文件写入每个 chunk 都会经过这里,避免 debug log 反向拖慢传输。
|
|
524
|
+
} else if (DataManager.getSettings('env') === 'react-native') {
|
|
525
|
+
Log.debug('_filterCommonTypes: ', JSON.stringify(sanitizeDebugPayload(res)));
|
|
372
526
|
} else {
|
|
373
|
-
Log.debug('_filterCommonTypes: ', res);
|
|
527
|
+
Log.debug('_filterCommonTypes: ', sanitizeDebugPayload(res));
|
|
374
528
|
}
|
|
375
529
|
} catch (error) {
|
|
376
530
|
// ignore
|
|
@@ -461,7 +615,7 @@ export class DeviceCommands {
|
|
|
461
615
|
}
|
|
462
616
|
|
|
463
617
|
if (res.type === 'ButtonRequest') {
|
|
464
|
-
const deviceType =
|
|
618
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
465
619
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
466
620
|
this.device.setCancelableAction(() => this.cancelDeviceOnOneKeyDevice());
|
|
467
621
|
} else {
|
|
@@ -472,7 +626,7 @@ export class DeviceCommands {
|
|
|
472
626
|
} else {
|
|
473
627
|
this.device.emit(DEVICE.BUTTON, this.device, res.message);
|
|
474
628
|
}
|
|
475
|
-
return this._commonCall('ButtonAck', {});
|
|
629
|
+
return this._commonCall('ButtonAck', {}, stripInteractiveAckTimeout(options));
|
|
476
630
|
}
|
|
477
631
|
|
|
478
632
|
if (res.type === 'EntropyRequest') {
|
|
@@ -485,11 +639,15 @@ export class DeviceCommands {
|
|
|
485
639
|
if (pin === '@@ONEKEY_INPUT_PIN_IN_DEVICE') {
|
|
486
640
|
// only classic\1s\mini\pure
|
|
487
641
|
this.device.setCancelableAction(() => this.cancelDeviceOnOneKeyDevice());
|
|
488
|
-
return this._commonCall(
|
|
642
|
+
return this._commonCall(
|
|
643
|
+
'BixinPinInputOnDevice',
|
|
644
|
+
{},
|
|
645
|
+
stripInteractiveAckTimeout(options)
|
|
646
|
+
).finally(() => {
|
|
489
647
|
this.device.clearCancelableAction();
|
|
490
648
|
});
|
|
491
649
|
}
|
|
492
|
-
return this._commonCall('PinMatrixAck', { pin });
|
|
650
|
+
return this._commonCall('PinMatrixAck', { pin }, stripInteractiveAckTimeout(options));
|
|
493
651
|
},
|
|
494
652
|
error => Promise.reject(error)
|
|
495
653
|
);
|
|
@@ -504,12 +662,20 @@ export class DeviceCommands {
|
|
|
504
662
|
|
|
505
663
|
// Attach PIN on device
|
|
506
664
|
if (attachPinOnDevice && existsAttachPinUser) {
|
|
507
|
-
return this._commonCall(
|
|
665
|
+
return this._commonCall(
|
|
666
|
+
'PassphraseAck',
|
|
667
|
+
{ on_device_attach_pin: true },
|
|
668
|
+
stripInteractiveAckTimeout(options)
|
|
669
|
+
);
|
|
508
670
|
}
|
|
509
671
|
|
|
510
672
|
return !passphraseOnDevice
|
|
511
|
-
? this._commonCall('PassphraseAck', { passphrase })
|
|
512
|
-
: this._commonCall(
|
|
673
|
+
? this._commonCall('PassphraseAck', { passphrase }, stripInteractiveAckTimeout(options))
|
|
674
|
+
: this._commonCall(
|
|
675
|
+
'PassphraseAck',
|
|
676
|
+
{ on_device: true },
|
|
677
|
+
stripInteractiveAckTimeout(options)
|
|
678
|
+
);
|
|
513
679
|
});
|
|
514
680
|
}
|
|
515
681
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
import { safeThrowError } from '../constants';
|
|
2
4
|
import { DataManager } from '../data-manager';
|
|
3
5
|
import TransportManager from '../data-manager/TransportManager';
|
|
@@ -6,6 +8,7 @@ import { resolveAfter } from '../utils/promiseUtils';
|
|
|
6
8
|
import { LoggerNames, getLogger } from '../utils';
|
|
7
9
|
|
|
8
10
|
import type { DeviceDescriptorDiff } from './DevicePool';
|
|
11
|
+
import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
|
|
9
12
|
import type { OneKeyDeviceInfo as DeviceDescriptor, Transport } from '@onekeyfe/hd-transport';
|
|
10
13
|
|
|
11
14
|
const Log = getLogger(LoggerNames.DeviceConnector);
|
|
@@ -75,15 +78,37 @@ export default class DeviceConnector {
|
|
|
75
78
|
this.listening = false;
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
async acquire(
|
|
79
|
-
|
|
81
|
+
async acquire(
|
|
82
|
+
path: string,
|
|
83
|
+
session?: string | null,
|
|
84
|
+
forceCleanRunPromise?: boolean,
|
|
85
|
+
connectProtocol?: HardwareConnectProtocol
|
|
86
|
+
) {
|
|
87
|
+
Log.debug('acquire', path, session, connectProtocol);
|
|
80
88
|
const env = DataManager.getSettings('env');
|
|
81
89
|
try {
|
|
82
90
|
let res;
|
|
83
91
|
if (DataManager.isBleConnect(env)) {
|
|
84
|
-
res = await this.transport.acquire({
|
|
92
|
+
res = await this.transport.acquire({
|
|
93
|
+
uuid: path,
|
|
94
|
+
forceCleanRunPromise,
|
|
95
|
+
expectedProtocol: connectProtocol,
|
|
96
|
+
});
|
|
85
97
|
} else {
|
|
86
|
-
res = await this.transport.acquire({
|
|
98
|
+
res = await this.transport.acquire({
|
|
99
|
+
path,
|
|
100
|
+
previous: session ?? null,
|
|
101
|
+
expectedProtocol: connectProtocol,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (connectProtocol) {
|
|
105
|
+
const detectedProtocol = this.transport.getProtocolType(path);
|
|
106
|
+
if (detectedProtocol !== connectProtocol) {
|
|
107
|
+
throw ERRORS.TypedError(
|
|
108
|
+
HardwareErrorCode.RuntimeError,
|
|
109
|
+
`Device protocol mismatch: expected ${connectProtocol}, detected ${detectedProtocol}`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
87
112
|
}
|
|
88
113
|
return res;
|
|
89
114
|
} catch (error) {
|
package/src/device/DevicePool.ts
CHANGED
|
@@ -3,7 +3,7 @@ import EventEmitter from 'events';
|
|
|
3
3
|
// eslint-disable-next-line import/no-cycle
|
|
4
4
|
import { Device } from './Device';
|
|
5
5
|
import { DEVICE } from '../events';
|
|
6
|
-
import { LoggerNames,
|
|
6
|
+
import { LoggerNames, getLogger } from '../utils';
|
|
7
7
|
|
|
8
8
|
import type { InitOptions } from './Device';
|
|
9
9
|
import type { OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-transport';
|
|
@@ -118,8 +118,8 @@ export class DevicePool extends EventEmitter {
|
|
|
118
118
|
for await (const descriptor of descriptorList) {
|
|
119
119
|
const device = await this._createDevice(descriptor, initOptions);
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
const uuid = device.getCurrentSerialNo();
|
|
122
|
+
if (uuid) {
|
|
123
123
|
if (this.devicesCache[uuid]) {
|
|
124
124
|
const cache = this.devicesCache[uuid];
|
|
125
125
|
cache.updateDescriptor(descriptor, true);
|
|
@@ -150,7 +150,7 @@ export class DevicePool extends EventEmitter {
|
|
|
150
150
|
if (!device) {
|
|
151
151
|
device = Device.fromDescriptor(descriptor);
|
|
152
152
|
device.deviceConnector = this.connector;
|
|
153
|
-
await device.connect();
|
|
153
|
+
await device.connect(initOptions?.connectProtocol);
|
|
154
154
|
await device.initialize(initOptions);
|
|
155
155
|
await device.release();
|
|
156
156
|
}
|
|
@@ -166,7 +166,7 @@ export class DevicePool extends EventEmitter {
|
|
|
166
166
|
for (let i = this.connectedPool.length - 1; i >= 0; i--) {
|
|
167
167
|
const descriptor = this.connectedPool[i];
|
|
168
168
|
const device = await this._createDevice(descriptor, initOptions);
|
|
169
|
-
Log.debug('emit DEVICE.CONNECT: ', device?.features);
|
|
169
|
+
Log.debug('emit DEVICE.CONNECT: ', device?.profile ?? device?.features);
|
|
170
170
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
171
171
|
this.connectedPool.splice(i, 1);
|
|
172
172
|
}
|
|
@@ -203,7 +203,7 @@ export class DevicePool extends EventEmitter {
|
|
|
203
203
|
this._addConnectedDeviceToPool(d);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
Log.debug('emit DEVICE.CONNECT: ', device.features);
|
|
206
|
+
Log.debug('emit DEVICE.CONNECT: ', device.profile ?? device.features);
|
|
207
207
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
208
208
|
});
|
|
209
209
|
|
|
@@ -215,7 +215,7 @@ export class DevicePool extends EventEmitter {
|
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
Log.debug('emit DEVICE.DISCONNECT: ', device.features);
|
|
218
|
+
Log.debug('emit DEVICE.DISCONNECT: ', device.profile ?? device.features);
|
|
219
219
|
this.emitter.emit(DEVICE.DISCONNECT, device);
|
|
220
220
|
});
|
|
221
221
|
}
|