@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
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { CommonParams, Response } from '../params';
|
|
2
|
+
import type {
|
|
3
|
+
DeviceFirmwareUpdateStatus,
|
|
4
|
+
DevFirmwareUpdateStatus,
|
|
5
|
+
FactoryDeviceInfo,
|
|
6
|
+
OnboardingStatus,
|
|
7
|
+
ProtoVersion,
|
|
8
|
+
ProtocolV2DeviceInfo,
|
|
9
|
+
Success,
|
|
10
|
+
} from '@onekeyfe/hd-transport';
|
|
11
|
+
import type {
|
|
12
|
+
DeviceFirmwareUpdateParams,
|
|
13
|
+
DeviceRebootParams,
|
|
14
|
+
FactoryDeviceInfoSettingsParams,
|
|
15
|
+
} from '../../api/protocol-v2/helpers';
|
|
16
|
+
import type { DeviceGetDeviceInfoParams } from '../../api/protocol-v2/DeviceGetDeviceInfo';
|
|
17
|
+
|
|
18
|
+
// 参数类型单源:以 api/protocol-v2 的实现为准(type-only re-export,无运行时依赖)
|
|
19
|
+
export type {
|
|
20
|
+
DeviceFirmwareTargetInput,
|
|
21
|
+
DeviceFirmwareUpdateParams,
|
|
22
|
+
DeviceRebootParams,
|
|
23
|
+
FactoryDeviceInfoSettingsParams,
|
|
24
|
+
RebootTypeInput,
|
|
25
|
+
} from '../../api/protocol-v2/helpers';
|
|
26
|
+
export type {
|
|
27
|
+
DeviceGetDeviceInfoParams,
|
|
28
|
+
DeviceGetDeviceInfoTargets,
|
|
29
|
+
DeviceGetDeviceInfoTypes,
|
|
30
|
+
} from '../../api/protocol-v2/DeviceGetDeviceInfo';
|
|
31
|
+
|
|
32
|
+
// ── Shared response shapes (Protocol V2 file system) ────────────────────
|
|
33
|
+
|
|
34
|
+
export type FileOpSuccess = { message?: string };
|
|
35
|
+
|
|
36
|
+
export type FileInfo = {
|
|
37
|
+
path: string;
|
|
38
|
+
offset: number;
|
|
39
|
+
total_size: number;
|
|
40
|
+
data?: Uint8Array;
|
|
41
|
+
data_hash?: number;
|
|
42
|
+
processed_byte?: number;
|
|
43
|
+
chunks?: number;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type DirInfo = {
|
|
47
|
+
path: string;
|
|
48
|
+
child_dirs?: string;
|
|
49
|
+
child_files?: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// proto 中 FilesystemPathInfo 的全部字段均为 required,类型与之保持一致
|
|
53
|
+
export type PathInfoResult = {
|
|
54
|
+
exist: boolean;
|
|
55
|
+
size: number;
|
|
56
|
+
year: number;
|
|
57
|
+
month: number;
|
|
58
|
+
day: number;
|
|
59
|
+
hour: number;
|
|
60
|
+
minute: number;
|
|
61
|
+
second: number;
|
|
62
|
+
readonly: boolean;
|
|
63
|
+
hidden: boolean;
|
|
64
|
+
system: boolean;
|
|
65
|
+
archive: boolean;
|
|
66
|
+
directory: boolean;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// ── Method signatures ─────────────────────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
export declare function getProtoVersion(
|
|
72
|
+
connectId: string,
|
|
73
|
+
params?: CommonParams
|
|
74
|
+
): Response<ProtoVersion>;
|
|
75
|
+
|
|
76
|
+
export declare function ping(
|
|
77
|
+
connectId: string,
|
|
78
|
+
params?: CommonParams & { message?: string }
|
|
79
|
+
): Response<Success>;
|
|
80
|
+
|
|
81
|
+
export declare function deviceReboot(
|
|
82
|
+
connectId: string,
|
|
83
|
+
params: CommonParams & DeviceRebootParams
|
|
84
|
+
): Response<Success>;
|
|
85
|
+
|
|
86
|
+
export declare function deviceGetDeviceInfo(
|
|
87
|
+
connectId: string,
|
|
88
|
+
params?: CommonParams & DeviceGetDeviceInfoParams
|
|
89
|
+
): Response<ProtocolV2DeviceInfo>;
|
|
90
|
+
|
|
91
|
+
export declare function deviceGetOnboardingStatus(
|
|
92
|
+
connectId: string,
|
|
93
|
+
params?: CommonParams
|
|
94
|
+
): Response<OnboardingStatus>;
|
|
95
|
+
|
|
96
|
+
export declare function deviceFirmwareUpdate(
|
|
97
|
+
connectId: string,
|
|
98
|
+
params: CommonParams & DeviceFirmwareUpdateParams
|
|
99
|
+
): Response<Success | DevFirmwareUpdateStatus | DeviceFirmwareUpdateStatus>;
|
|
100
|
+
|
|
101
|
+
export declare function deviceGetFirmwareUpdateStatus(
|
|
102
|
+
connectId: string,
|
|
103
|
+
params?: CommonParams
|
|
104
|
+
): Response<DevFirmwareUpdateStatus | DeviceFirmwareUpdateStatus>;
|
|
105
|
+
|
|
106
|
+
export declare function devReboot(
|
|
107
|
+
connectId: string,
|
|
108
|
+
params: CommonParams & DeviceRebootParams
|
|
109
|
+
): Response<Success>;
|
|
110
|
+
|
|
111
|
+
export declare function devGetDeviceInfo(
|
|
112
|
+
connectId: string,
|
|
113
|
+
params?: CommonParams & DeviceGetDeviceInfoParams
|
|
114
|
+
): Response<ProtocolV2DeviceInfo>;
|
|
115
|
+
|
|
116
|
+
export declare function devFirmwareUpdate(
|
|
117
|
+
connectId: string,
|
|
118
|
+
params: CommonParams & DeviceFirmwareUpdateParams
|
|
119
|
+
): Response<Success | DevFirmwareUpdateStatus>;
|
|
120
|
+
|
|
121
|
+
export declare function devGetFirmwareUpdateStatus(
|
|
122
|
+
connectId: string,
|
|
123
|
+
params?: CommonParams
|
|
124
|
+
): Response<DevFirmwareUpdateStatus>;
|
|
125
|
+
|
|
126
|
+
export declare function factoryDeviceInfoSettings(
|
|
127
|
+
connectId: string,
|
|
128
|
+
params: FactoryDeviceInfoSettingsParams
|
|
129
|
+
): Response<Success>;
|
|
130
|
+
|
|
131
|
+
export declare function factoryGetDeviceInfo(connectId: string): Response<FactoryDeviceInfo>;
|
|
132
|
+
|
|
133
|
+
export declare function filesystemFixPermission(connectId: string): Response<Success>;
|
|
134
|
+
|
|
135
|
+
export declare function fileRead(
|
|
136
|
+
connectId: string,
|
|
137
|
+
params: {
|
|
138
|
+
path: string;
|
|
139
|
+
offset?: number;
|
|
140
|
+
totalSize?: number;
|
|
141
|
+
chunkLen?: number;
|
|
142
|
+
uiPercentage?: number;
|
|
143
|
+
}
|
|
144
|
+
): Response<FileInfo>;
|
|
145
|
+
|
|
146
|
+
export declare function fileWrite(
|
|
147
|
+
connectId: string,
|
|
148
|
+
params: {
|
|
149
|
+
path: string;
|
|
150
|
+
offset?: number;
|
|
151
|
+
totalSize?: number;
|
|
152
|
+
chunkSize?: number;
|
|
153
|
+
chunkLen?: number;
|
|
154
|
+
data: ArrayBuffer | Uint8Array | Blob | string;
|
|
155
|
+
overwrite?: boolean;
|
|
156
|
+
append?: boolean;
|
|
157
|
+
uiPercentage?: number;
|
|
158
|
+
timeoutMs?: number | string;
|
|
159
|
+
}
|
|
160
|
+
): Response<FileInfo>;
|
|
161
|
+
|
|
162
|
+
export declare function fileDelete(
|
|
163
|
+
connectId: string,
|
|
164
|
+
params: { path: string }
|
|
165
|
+
): Response<FileOpSuccess>;
|
|
166
|
+
|
|
167
|
+
export declare function dirList(
|
|
168
|
+
connectId: string,
|
|
169
|
+
params: { path: string; depth?: number }
|
|
170
|
+
): Response<DirInfo>;
|
|
171
|
+
|
|
172
|
+
export declare function dirMake(
|
|
173
|
+
connectId: string,
|
|
174
|
+
params: { path: string }
|
|
175
|
+
): Response<FileOpSuccess>;
|
|
176
|
+
|
|
177
|
+
export declare function dirRemove(
|
|
178
|
+
connectId: string,
|
|
179
|
+
params: { path: string }
|
|
180
|
+
): Response<FileOpSuccess>;
|
|
181
|
+
|
|
182
|
+
export declare function pathInfo(
|
|
183
|
+
connectId: string,
|
|
184
|
+
params: { path: string; timeoutMs?: number | string }
|
|
185
|
+
): Response<PathInfoResult>;
|
|
186
|
+
|
|
187
|
+
export declare const filesystemFileRead: typeof fileRead;
|
|
188
|
+
export declare const filesystemFileWrite: typeof fileWrite;
|
|
189
|
+
export declare const filesystemFileDelete: typeof fileDelete;
|
|
190
|
+
export declare const filesystemDirList: typeof dirList;
|
|
191
|
+
export declare const filesystemDirMake: typeof dirMake;
|
|
192
|
+
export declare const filesystemDirRemove: typeof dirRemove;
|
|
193
|
+
export declare const filesystemPathInfoQuery: typeof pathInfo;
|
|
194
|
+
|
|
195
|
+
export declare function filesystemFormat(connectId: string): Response<Success>;
|
|
196
|
+
|
|
197
|
+
export declare function filesystemDiskControl(
|
|
198
|
+
connectId: string,
|
|
199
|
+
// enable 收紧为 boolean | 0 | 1(兼容历史的 '0' / '1' 字符串输入,内部归一化为 0/1)
|
|
200
|
+
params: CommonParams & { enable: boolean | 0 | 1; timeoutMs?: number | string }
|
|
201
|
+
): Response<Success>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SearchDevice } from '../device';
|
|
2
|
-
import type { Response } from '../params';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
3
|
|
|
4
|
-
export declare function searchDevices(): Response<SearchDevice[]>;
|
|
4
|
+
export declare function searchDevices(params?: CommonParams): Response<SearchDevice[]>;
|
package/src/types/device.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
|
3
3
|
import type { IVersionArray } from './settings';
|
|
4
4
|
import type { PROTO } from '../constants';
|
|
5
5
|
import type { OneKeyDeviceCommType } from '@onekeyfe/hd-transport';
|
|
6
|
+
import type { DeviceProfile } from './api/getDeviceInfo';
|
|
6
7
|
|
|
7
8
|
export type DeviceStatus = 'available' | 'occupied' | 'used';
|
|
8
9
|
|
|
@@ -33,7 +34,9 @@ export type KnownDevice = {
|
|
|
33
34
|
name: string;
|
|
34
35
|
error?: typeof undefined;
|
|
35
36
|
mode: EOneKeyDeviceMode;
|
|
36
|
-
|
|
37
|
+
profile?: DeviceProfile;
|
|
38
|
+
features?: PROTO.Features;
|
|
39
|
+
sessionId?: string | null;
|
|
37
40
|
unavailableCapabilities: UnavailableCapabilities;
|
|
38
41
|
bleFirmwareVersion: IVersionArray | null;
|
|
39
42
|
firmwareVersion: IVersionArray | null;
|
|
@@ -85,7 +88,35 @@ export type SearchDevice = {
|
|
|
85
88
|
|
|
86
89
|
export type Device = KnownDevice;
|
|
87
90
|
|
|
88
|
-
|
|
91
|
+
type OnekeyFeatureExtensions = Partial<
|
|
92
|
+
Pick<
|
|
93
|
+
PROTO.OnekeyFeatures,
|
|
94
|
+
| 'onekey_board_build_id'
|
|
95
|
+
| 'onekey_se02_hash'
|
|
96
|
+
| 'onekey_se03_hash'
|
|
97
|
+
| 'onekey_se04_hash'
|
|
98
|
+
| 'onekey_se02_build_id'
|
|
99
|
+
| 'onekey_se03_build_id'
|
|
100
|
+
| 'onekey_se04_build_id'
|
|
101
|
+
| 'onekey_se01_boot_version'
|
|
102
|
+
| 'onekey_se02_boot_version'
|
|
103
|
+
| 'onekey_se03_boot_version'
|
|
104
|
+
| 'onekey_se04_boot_version'
|
|
105
|
+
| 'onekey_se01_boot_hash'
|
|
106
|
+
| 'onekey_se02_boot_hash'
|
|
107
|
+
| 'onekey_se03_boot_hash'
|
|
108
|
+
| 'onekey_se04_boot_hash'
|
|
109
|
+
| 'onekey_se01_boot_build_id'
|
|
110
|
+
| 'onekey_se02_boot_build_id'
|
|
111
|
+
| 'onekey_se03_boot_build_id'
|
|
112
|
+
| 'onekey_se04_boot_build_id'
|
|
113
|
+
>
|
|
114
|
+
>;
|
|
115
|
+
|
|
116
|
+
export type Features = PROTO.Features &
|
|
117
|
+
OnekeyFeatureExtensions & {
|
|
118
|
+
protocol_version?: number | null;
|
|
119
|
+
};
|
|
89
120
|
|
|
90
121
|
export type OnekeyFeatures = PROTO.OnekeyFeatures;
|
|
91
122
|
|
|
@@ -96,7 +127,8 @@ export type IDeviceType =
|
|
|
96
127
|
| EDeviceType.ClassicPure
|
|
97
128
|
| EDeviceType.Mini
|
|
98
129
|
| EDeviceType.Touch
|
|
99
|
-
| EDeviceType.Pro
|
|
130
|
+
| EDeviceType.Pro
|
|
131
|
+
| EDeviceType.Pro2;
|
|
100
132
|
|
|
101
133
|
/**
|
|
102
134
|
* model_classic: 'classic' | 'classic1s' | 'classicpure'
|
|
@@ -124,6 +156,7 @@ export const DeviceTypeToModels: { [deviceType in IDeviceType]: IDeviceModel[] }
|
|
|
124
156
|
[EDeviceType.Mini]: ['model_mini'],
|
|
125
157
|
[EDeviceType.Touch]: ['model_touch'],
|
|
126
158
|
[EDeviceType.Pro]: ['model_touch'],
|
|
159
|
+
[EDeviceType.Pro2]: [],
|
|
127
160
|
[EDeviceType.Unknown]: [],
|
|
128
161
|
};
|
|
129
162
|
|
|
@@ -136,6 +169,7 @@ export type ITransportStatus = 'valid' | 'outdated';
|
|
|
136
169
|
export type IVersionRange = {
|
|
137
170
|
min: string;
|
|
138
171
|
max?: string;
|
|
172
|
+
unsupported?: boolean;
|
|
139
173
|
};
|
|
140
174
|
|
|
141
175
|
export type DeviceFirmwareRange = {
|
package/src/types/params.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
export interface CommonParams {
|
|
2
4
|
keepSession?: boolean;
|
|
3
5
|
/**
|
|
@@ -52,6 +54,11 @@ export interface CommonParams {
|
|
|
52
54
|
* Use pre-initialized device state (BLE only)
|
|
53
55
|
*/
|
|
54
56
|
usePreInitialize?: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Expected transport protocol. If omitted, SDK probes Protocol V1 then Protocol V2.
|
|
60
|
+
*/
|
|
61
|
+
connectProtocol?: HardwareConnectProtocol;
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
export type Params<T> = CommonParams & T & { bundle?: undefined };
|
package/src/types/settings.ts
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { isNaN } from 'lodash';
|
|
3
3
|
import { EDeviceType, type EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
4
|
-
import { Enum_Capability } from '@onekeyfe/hd-transport';
|
|
4
|
+
import { Enum_Capability, type GetPassphraseState } from '@onekeyfe/hd-transport';
|
|
5
5
|
|
|
6
6
|
import { toHardened } from '../api/helpers/pathUtils';
|
|
7
7
|
import { DeviceModelToTypes, DeviceTypeToModels } from '../types';
|
|
8
|
-
import DataManager, {
|
|
8
|
+
import DataManager, {
|
|
9
|
+
type IFirmwareField,
|
|
10
|
+
type ProtocolV1MessageSchema,
|
|
11
|
+
} from '../data-manager/DataManager';
|
|
9
12
|
import { PROTOBUF_MESSAGE_CONFIG } from '../data-manager/MessagesConfig';
|
|
10
13
|
import { getDeviceType } from './deviceInfoUtils';
|
|
11
14
|
import { getDeviceFirmwareVersion } from './deviceVersionUtils';
|
|
12
15
|
import { existCapability } from './capabilitieUtils';
|
|
13
16
|
|
|
14
17
|
import type { Device } from '../device/Device';
|
|
15
|
-
import type {
|
|
16
|
-
import type { Features, SupportFeatureType } from '../types';
|
|
18
|
+
import type { Features, IDeviceType, SupportFeatureType } from '../types';
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
// 生成的 GetPassphraseState 已包含 _only_main_pin / allow_create_attach_pin,
|
|
21
|
+
// 不再需要手动扩展字段。
|
|
22
|
+
type GetPassphraseStateMessage = GetPassphraseState;
|
|
23
|
+
|
|
24
|
+
export const getSupportProtocolV1MessageSchema = (
|
|
19
25
|
features: Features | undefined
|
|
20
|
-
): { messages: JSON;
|
|
26
|
+
): { messages: JSON; protocolV1MessageSchema: ProtocolV1MessageSchema } => {
|
|
21
27
|
if (!features)
|
|
22
28
|
return {
|
|
23
|
-
messages: DataManager.messages.
|
|
24
|
-
|
|
29
|
+
messages: DataManager.messages.v1CurrentSchema,
|
|
30
|
+
protocolV1MessageSchema: 'v1CurrentSchema',
|
|
25
31
|
};
|
|
26
32
|
|
|
27
33
|
const currentDeviceVersion = getDeviceFirmwareVersion(features).join('.');
|
|
@@ -37,18 +43,18 @@ export const getSupportMessageVersion = (
|
|
|
37
43
|
const sortedDeviceVersionConfigs =
|
|
38
44
|
deviceVersionConfigs?.sort((a, b) => semver.compare(b.minVersion, a.minVersion)) ?? [];
|
|
39
45
|
|
|
40
|
-
for (const { minVersion,
|
|
46
|
+
for (const { minVersion, protocolV1MessageSchema } of sortedDeviceVersionConfigs) {
|
|
41
47
|
if (semver.gte(currentDeviceVersion, minVersion)) {
|
|
42
48
|
return {
|
|
43
|
-
messages: DataManager.messages[
|
|
44
|
-
|
|
49
|
+
messages: DataManager.messages[protocolV1MessageSchema],
|
|
50
|
+
protocolV1MessageSchema,
|
|
45
51
|
};
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
return {
|
|
50
|
-
messages: DataManager.messages.
|
|
51
|
-
|
|
56
|
+
messages: DataManager.messages.v1CurrentSchema,
|
|
57
|
+
protocolV1MessageSchema: 'v1CurrentSchema',
|
|
52
58
|
};
|
|
53
59
|
};
|
|
54
60
|
|
|
@@ -68,7 +74,11 @@ export const supportNewPassphrase = (features?: Features): SupportFeatureType =>
|
|
|
68
74
|
if (!features) return { support: false };
|
|
69
75
|
|
|
70
76
|
const deviceType = getDeviceType(features);
|
|
71
|
-
if (
|
|
77
|
+
if (
|
|
78
|
+
deviceType === EDeviceType.Touch ||
|
|
79
|
+
deviceType === EDeviceType.Pro ||
|
|
80
|
+
deviceType === EDeviceType.Pro2
|
|
81
|
+
) {
|
|
72
82
|
return { support: true };
|
|
73
83
|
}
|
|
74
84
|
|
|
@@ -82,25 +92,26 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
82
92
|
options?: {
|
|
83
93
|
expectPassphraseState?: string;
|
|
84
94
|
onlyMainPin?: boolean;
|
|
95
|
+
allowCreateAttachPin?: boolean;
|
|
85
96
|
}
|
|
86
97
|
) => {
|
|
87
|
-
const { features
|
|
98
|
+
const { features } = device;
|
|
88
99
|
const locked = features?.unlocked === false;
|
|
100
|
+
const deviceType = device.getCurrentDeviceType();
|
|
89
101
|
|
|
90
|
-
const { passphraseState, newSession, unlockedAttachPin } = await getPassphraseState(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
...options,
|
|
95
|
-
}
|
|
96
|
-
);
|
|
102
|
+
const { passphraseState, newSession, unlockedAttachPin } = await getPassphraseState(device, {
|
|
103
|
+
...options,
|
|
104
|
+
});
|
|
97
105
|
|
|
98
106
|
const isModeT =
|
|
99
|
-
|
|
107
|
+
deviceType === EDeviceType.Touch ||
|
|
108
|
+
deviceType === EDeviceType.Pro ||
|
|
109
|
+
deviceType === EDeviceType.Pro2;
|
|
100
110
|
|
|
101
111
|
// 如果可以获取到 passphraseState,但是设备 features 显示设备未开启 passphrase,需要刷新设备状态
|
|
102
112
|
// if passphraseState can be obtained, but the device features show that the device has not enabled passphrase, the device status needs to be refreshed
|
|
103
|
-
const needRefreshWithPassphrase =
|
|
113
|
+
const needRefreshWithPassphrase =
|
|
114
|
+
passphraseState && device.getCurrentPassphraseProtection() !== true;
|
|
104
115
|
// 如果 Touch/Pro 在之前是锁定状态,刷新设备状态
|
|
105
116
|
// if Touch/Pro was locked before, refresh the device state
|
|
106
117
|
const needRefreshWithLocked = isModeT && locked;
|
|
@@ -111,11 +122,12 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
111
122
|
}
|
|
112
123
|
|
|
113
124
|
// Attach to pin try to fix internal state
|
|
114
|
-
|
|
125
|
+
const deviceId = device.getCurrentDeviceId();
|
|
126
|
+
if (deviceId) {
|
|
115
127
|
device.updateInternalState(
|
|
116
|
-
device.
|
|
128
|
+
device.getCurrentPassphraseProtection() ?? false,
|
|
117
129
|
passphraseState,
|
|
118
|
-
|
|
130
|
+
deviceId,
|
|
119
131
|
newSession,
|
|
120
132
|
device.features?.session_id
|
|
121
133
|
);
|
|
@@ -124,36 +136,56 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
124
136
|
return { passphraseState, newSession, unlockedAttachPin };
|
|
125
137
|
};
|
|
126
138
|
|
|
139
|
+
// 仅适用于 Protocol V1 的 Pro:Pro2 走独立版本线,不能套用 4.15.0 门槛
|
|
140
|
+
// (Pro2 在 getPassphraseState 中通过 isProtocolV2 直接判定支持)。
|
|
141
|
+
const supportProSeriesAttachPinPassphrase = (deviceType: IDeviceType, firmwareVersion: string) =>
|
|
142
|
+
deviceType === EDeviceType.Pro && semver.gte(firmwareVersion, '4.15.0');
|
|
143
|
+
|
|
127
144
|
export const getPassphraseState = async (
|
|
128
|
-
|
|
129
|
-
commands: DeviceCommands,
|
|
145
|
+
device: Device,
|
|
130
146
|
options?: {
|
|
131
147
|
expectPassphraseState?: string;
|
|
132
148
|
onlyMainPin?: boolean;
|
|
149
|
+
allowCreateAttachPin?: boolean;
|
|
133
150
|
}
|
|
134
151
|
): Promise<{
|
|
135
152
|
passphraseState: string | undefined;
|
|
136
153
|
newSession: string | undefined;
|
|
137
154
|
unlockedAttachPin: boolean | undefined;
|
|
138
155
|
}> => {
|
|
139
|
-
|
|
156
|
+
const { features, commands } = device;
|
|
157
|
+
|
|
158
|
+
// 设备尚未建立任何状态(V1 无 features 且无 profile)时无法判定,保持旧的空返回语义
|
|
159
|
+
if (!features && !device.profile)
|
|
140
160
|
return { passphraseState: undefined, newSession: undefined, unlockedAttachPin: undefined };
|
|
141
161
|
|
|
142
|
-
const firmwareVersion =
|
|
143
|
-
const deviceType =
|
|
162
|
+
const firmwareVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
163
|
+
const deviceType = device.getCurrentDeviceType();
|
|
144
164
|
|
|
145
165
|
const supportAttachPinCapability = existCapability(
|
|
146
166
|
features,
|
|
147
167
|
Enum_Capability.Capability_AttachToPin
|
|
148
168
|
);
|
|
169
|
+
// Pro2 (Protocol V2) 协议自带 GetPassphraseState(10028),固件从首个版本即支持,
|
|
170
|
+
// 不依赖 Pro 系列的 4.15.0 版本线;V2 也没有 GetAddress Testnet 探测这条 legacy 回退路径。
|
|
149
171
|
const supportGetPassphraseState =
|
|
172
|
+
device.isProtocolV2() ||
|
|
150
173
|
supportAttachPinCapability ||
|
|
151
|
-
(deviceType
|
|
174
|
+
supportProSeriesAttachPinPassphrase(deviceType, firmwareVersion);
|
|
152
175
|
|
|
153
176
|
if (supportGetPassphraseState) {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
177
|
+
const payload: GetPassphraseStateMessage = options?.onlyMainPin
|
|
178
|
+
? { _only_main_pin: true }
|
|
179
|
+
: { passphrase_state: options?.expectPassphraseState };
|
|
180
|
+
if (options?.allowCreateAttachPin) {
|
|
181
|
+
payload.allow_create_attach_pin = true;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const { message, type } = await commands.typedCall(
|
|
185
|
+
'GetPassphraseState',
|
|
186
|
+
'PassphraseState',
|
|
187
|
+
payload
|
|
188
|
+
);
|
|
157
189
|
|
|
158
190
|
// @ts-expect-error
|
|
159
191
|
if (type === 'CallMethodError') {
|
|
@@ -186,40 +218,8 @@ export const getPassphraseState = async (
|
|
|
186
218
|
};
|
|
187
219
|
};
|
|
188
220
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
options?: {
|
|
192
|
-
includeNode?: boolean;
|
|
193
|
-
}
|
|
194
|
-
): boolean => {
|
|
195
|
-
if (!features) return false;
|
|
196
|
-
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
197
|
-
|
|
198
|
-
const deviceType = getDeviceType(features);
|
|
199
|
-
// btc batch get public key
|
|
200
|
-
if (!!options?.includeNode && deviceType === EDeviceType.Pro) {
|
|
201
|
-
return semver.gte(currentVersion, '4.14.0');
|
|
202
|
-
}
|
|
203
|
-
if (!!options?.includeNode && deviceType === EDeviceType.Touch) {
|
|
204
|
-
return semver.gte(currentVersion, '4.11.0');
|
|
205
|
-
}
|
|
206
|
-
if (!!options?.includeNode && DeviceModelToTypes.model_classic1s.includes(deviceType)) {
|
|
207
|
-
return semver.gte(currentVersion, '3.12.0');
|
|
208
|
-
}
|
|
209
|
-
if (!!options?.includeNode && DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
210
|
-
return semver.gte(currentVersion, '3.10.0');
|
|
211
|
-
}
|
|
212
|
-
if (options?.includeNode) {
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// support batch get public key
|
|
217
|
-
if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
|
|
218
|
-
return semver.gte(currentVersion, '3.1.0');
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return semver.gte(currentVersion, '2.6.0');
|
|
222
|
-
};
|
|
221
|
+
// supportBatchPublicKey 已迁移为 device-aware 版本:
|
|
222
|
+
// 见 api/helpers/batchGetPublickeys.ts 的 supportBatchPublicKeyByDevice
|
|
223
223
|
|
|
224
224
|
export const supportModifyHomescreen = (features?: Features): SupportFeatureType => {
|
|
225
225
|
if (!features) return { support: false };
|
|
@@ -27,6 +27,9 @@ export const getDeviceType = (features?: Features): IDeviceType => {
|
|
|
27
27
|
return EDeviceType.Touch;
|
|
28
28
|
case 'PRO':
|
|
29
29
|
return EDeviceType.Pro;
|
|
30
|
+
case 'PRO2':
|
|
31
|
+
case 'pro2':
|
|
32
|
+
return EDeviceType.Pro2;
|
|
30
33
|
case 'PURE':
|
|
31
34
|
return EDeviceType.ClassicPure;
|
|
32
35
|
default:
|
|
@@ -68,13 +71,14 @@ export const getDeviceType = (features?: Features): IDeviceType => {
|
|
|
68
71
|
export const getDeviceTypeByBleName = (name?: string): IDeviceType => {
|
|
69
72
|
if (!name) return EDeviceType.Unknown;
|
|
70
73
|
|
|
71
|
-
if (
|
|
72
|
-
if (
|
|
74
|
+
if (/^BixinKey/i.test(name)) return EDeviceType.Classic;
|
|
75
|
+
if (/^K/i.test(name)) return EDeviceType.Classic;
|
|
73
76
|
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
77
|
+
if (/^T/i.test(name)) return EDeviceType.Touch;
|
|
78
|
+
if (/^Touch/i.test(name)) return EDeviceType.Touch;
|
|
76
79
|
|
|
77
|
-
if (name.
|
|
80
|
+
if (/\bPro\s*2\b/i.test(name) || /^Pro2/i.test(name)) return EDeviceType.Pro2;
|
|
81
|
+
if (/\bPro\b/i.test(name) || /^Pro/i.test(name)) return EDeviceType.Pro;
|
|
78
82
|
|
|
79
83
|
return EDeviceType.Unknown;
|
|
80
84
|
};
|
|
@@ -128,8 +132,8 @@ export const getMethodVersionRange = (
|
|
|
128
132
|
getVersionRange: (deviceModel: IDeviceType | IDeviceModel) => IVersionRange | undefined
|
|
129
133
|
): IVersionRange | undefined => {
|
|
130
134
|
const deviceType = getDeviceType(features);
|
|
131
|
-
let versionRange: IVersionRange | undefined = getVersionRange(deviceType);
|
|
132
135
|
|
|
136
|
+
const versionRange = getVersionRange(deviceType);
|
|
133
137
|
if (versionRange) {
|
|
134
138
|
return versionRange;
|
|
135
139
|
}
|
|
@@ -142,16 +146,19 @@ export const getMethodVersionRange = (
|
|
|
142
146
|
];
|
|
143
147
|
for (const model of modelFallbacks) {
|
|
144
148
|
if (DeviceModelToTypes[model].includes(deviceType)) {
|
|
145
|
-
versionRange = getVersionRange(model);
|
|
149
|
+
const versionRange = getVersionRange(model);
|
|
146
150
|
if (versionRange) {
|
|
147
151
|
return versionRange;
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
}
|
|
151
155
|
|
|
152
|
-
return
|
|
156
|
+
return undefined;
|
|
153
157
|
};
|
|
154
158
|
|
|
159
|
+
export const isMethodVersionRangeUnsupported = (versionRange?: IVersionRange): boolean =>
|
|
160
|
+
versionRange?.unsupported === true;
|
|
161
|
+
|
|
155
162
|
export const getFirmwareType = (features: Features | undefined) => {
|
|
156
163
|
if (!features) {
|
|
157
164
|
return EFirmwareType.Universal;
|