@onekeyfe/hd-core 1.2.0-alpha.3 → 1.2.0-alpha.31
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__/AllNetworkGetAddressBase.tracing.test.ts +77 -0
- package/__tests__/DeviceCommands.test.ts +433 -0
- package/__tests__/DeviceEventRegistration.test.ts +43 -0
- package/__tests__/chain-params-onekey-compatibility.test.ts +229 -0
- package/__tests__/connectSettings.test.ts +61 -0
- package/__tests__/core-dispose.test.ts +34 -0
- package/__tests__/core-error-output.test.ts +39 -0
- package/__tests__/device-features-state.test.ts +78 -0
- package/__tests__/device-identity.test.ts +52 -0
- package/__tests__/device-lifecycle-events.test.ts +197 -0
- package/__tests__/device-pool-state.test.ts +132 -0
- package/__tests__/device-settings.test.ts +391 -0
- package/__tests__/device-state-contract.test.ts +27 -0
- package/__tests__/device-state-events.test.ts +286 -0
- package/__tests__/device-state-mapper.test.ts +241 -0
- package/__tests__/device-state-projector.test.ts +94 -0
- package/__tests__/device-state-store.test.ts +82 -0
- package/__tests__/device-utils.test.ts +106 -0
- package/__tests__/device-wallet-session-store.test.ts +358 -0
- package/__tests__/deviceFeaturesUtils.test.ts +39 -0
- package/__tests__/deviceSettings.test.ts +103 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +12 -6
- package/__tests__/evmSignTypedData.test.ts +80 -0
- package/__tests__/filesystemValidation.test.ts +53 -0
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +174 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +213 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +430 -0
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +410 -0
- package/__tests__/homescreen.test.ts +24 -0
- package/__tests__/kaspa-public-types.type-test.ts +16 -0
- package/__tests__/kaspa-use-tweak-pro2.test.ts +20 -0
- package/__tests__/kaspaSignTransaction.test.ts +592 -0
- package/__tests__/logBlockEvent.test.ts +43 -0
- package/__tests__/method-protocol-support.test.ts +113 -0
- package/__tests__/networkUtils.test.ts +386 -0
- package/__tests__/open-wallet-session-error-response.test.ts +43 -0
- package/__tests__/open-wallet-session.test.ts +915 -0
- package/__tests__/preInitialize.test.ts +33 -0
- package/__tests__/pro2Wallpaper.test.ts +39 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +19 -0
- package/__tests__/protocol-v2-ping.test.ts +28 -0
- package/__tests__/protocol-v2-unlock-policy.test.ts +45 -0
- package/__tests__/protocol-v2.test.ts +5310 -1856
- package/__tests__/protocolV2FileWrite.test.ts +92 -0
- package/__tests__/protocolV2UiInteraction.test.ts +266 -0
- package/__tests__/public-device-state-api.test.ts +266 -0
- package/__tests__/public-pro2-api-boundary.test.ts +106 -0
- package/__tests__/refresh-device-state.test.ts +101 -0
- package/__tests__/request-context-logging.test.ts +16 -0
- package/__tests__/search-devices.test.ts +136 -0
- package/__tests__/tron-sign-message-init.test.ts +74 -0
- package/dist/api/BaseMethod.d.ts +14 -1
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CipherKeyValue.d.ts +1 -0
- package/dist/api/CipherKeyValue.d.ts.map +1 -1
- package/dist/api/ClearSessionCache.d.ts +9 -0
- package/dist/api/ClearSessionCache.d.ts.map +1 -0
- package/dist/api/DirList.d.ts +1 -0
- package/dist/api/DirList.d.ts.map +1 -1
- package/dist/api/DirMake.d.ts +1 -0
- package/dist/api/DirMake.d.ts.map +1 -1
- package/dist/api/DirRemove.d.ts +1 -0
- package/dist/api/DirRemove.d.ts.map +1 -1
- package/dist/api/FileDelete.d.ts +1 -0
- package/dist/api/FileDelete.d.ts.map +1 -1
- package/dist/api/FileRead.d.ts +1 -0
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts +2 -0
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +13 -2
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +47 -6
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts +8 -0
- package/dist/api/GetDeviceState.d.ts.map +1 -0
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +2 -6
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts +8 -0
- package/dist/api/OpenWalletSession.d.ts.map +1 -0
- package/dist/api/PathInfo.d.ts +1 -0
- package/dist/api/PathInfo.d.ts.map +1 -1
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +3 -0
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +17 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -0
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/algo/AlgoGetAddress.d.ts +1 -0
- package/dist/api/algo/AlgoGetAddress.d.ts.map +1 -1
- package/dist/api/algo/AlgoSignTransaction.d.ts +1 -0
- package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +1 -0
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts +1 -0
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetPublicKey.d.ts +1 -0
- package/dist/api/aptos/AptosGetPublicKey.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignInMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignMessage.d.ts +1 -0
- package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignTransaction.d.ts +1 -0
- package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -0
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -0
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -0
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts +1 -0
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -0
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -0
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -0
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetAddress.d.ts +1 -0
- package/dist/api/cardano/CardanoGetAddress.d.ts.map +1 -1
- package/dist/api/cardano/CardanoGetPublicKey.d.ts +1 -0
- package/dist/api/cardano/CardanoGetPublicKey.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignMessage.d.ts +1 -0
- package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts +1 -0
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxGetAddress.d.ts +2 -0
- package/dist/api/conflux/ConfluxGetAddress.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessage.d.ts +2 -0
- package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts +2 -0
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts +2 -0
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosGetAddress.d.ts +1 -0
- package/dist/api/cosmos/CosmosGetAddress.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosGetPublicKey.d.ts +1 -0
- package/dist/api/cosmos/CosmosGetPublicKey.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosSignTransaction.d.ts +1 -0
- package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceCancel.d.ts +1 -0
- package/dist/api/device/DeviceCancel.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts +1 -0
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts +1 -2
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.d.ts +1 -0
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -0
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts +1 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts +1 -0
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceSupportFeatures.d.ts +1 -0
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -0
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts +1 -0
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/device/PreInitialize.d.ts +1 -0
- package/dist/api/device/PreInitialize.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/EVMGetAddress.d.ts +1 -0
- package/dist/api/evm/EVMGetAddress.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts +1 -0
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessage.d.ts +1 -0
- package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts +1 -0
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts +1 -0
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/EVMVerifyMessage.d.ts +1 -0
- package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -1
- package/dist/api/filecoin/FilecoinGetAddress.d.ts +1 -0
- package/dist/api/filecoin/FilecoinGetAddress.d.ts.map +1 -1
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts +1 -0
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +8 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +30 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +18 -3
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/filesystemValidation.d.ts +3 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -1
- package/dist/api/helpers/paramsValidator.d.ts +1 -0
- package/dist/api/helpers/paramsValidator.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +33 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
- package/dist/api/index.d.ts +6 -29
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaGetAddress.d.ts +4 -0
- package/dist/api/kaspa/KaspaGetAddress.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts +9 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/kaspa/helpers/TransferSerialize.d.ts.map +1 -1
- package/dist/api/lightning/LnurlAuth.d.ts +0 -4
- package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
- package/dist/api/near/NearGetAddress.d.ts +1 -0
- package/dist/api/near/NearGetAddress.d.ts.map +1 -1
- package/dist/api/near/NearSignTransaction.d.ts +1 -0
- package/dist/api/near/NearSignTransaction.d.ts.map +1 -1
- package/dist/api/nem/NEMGetAddress.d.ts +1 -0
- package/dist/api/nem/NEMGetAddress.d.ts.map +1 -1
- package/dist/api/nem/NEMSignTransaction.d.ts +1 -0
- package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +1 -0
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/nostr/NostrDecryptMessage.d.ts +1 -0
- package/dist/api/nostr/NostrDecryptMessage.d.ts.map +1 -1
- package/dist/api/nostr/NostrEncryptMessage.d.ts +1 -0
- package/dist/api/nostr/NostrEncryptMessage.d.ts.map +1 -1
- package/dist/api/nostr/NostrGetPublicKey.d.ts +1 -0
- package/dist/api/nostr/NostrGetPublicKey.d.ts.map +1 -1
- package/dist/api/nostr/NostrSignEvent.d.ts +1 -0
- package/dist/api/nostr/NostrSignEvent.d.ts.map +1 -1
- package/dist/api/nostr/NostrSignSchnorr.d.ts +1 -0
- package/dist/api/nostr/NostrSignSchnorr.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -0
- package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotSignTransaction.d.ts +1 -0
- package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +8 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +2 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +4 -2
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +2 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +29 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +27 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +7 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
- package/dist/api/protocol-v2/Ping.d.ts +3 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +7 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +27 -18
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- 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 +1 -0
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -0
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +1 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetAddress.d.ts +1 -0
- package/dist/api/starcoin/StarcoinGetAddress.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts +1 -0
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignMessage.d.ts +1 -0
- package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts +1 -0
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts +1 -0
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +1 -2
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +2 -3
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +1 -0
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +1 -0
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +1 -0
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +1 -0
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +1 -0
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +2 -5
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +1 -0
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +1 -0
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronGetAddress.d.ts +1 -0
- package/dist/api/tron/TronGetAddress.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +5 -0
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +1 -0
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/utils.d.ts +2 -1
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/api/xrp/XrpGetAddress.d.ts +1 -0
- package/dist/api/xrp/XrpGetAddress.d.ts.map +1 -1
- package/dist/api/xrp/XrpSignTransaction.d.ts +1 -0
- package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/deviceEventRegistration.d.ts +11 -0
- package/dist/core/deviceEventRegistration.d.ts.map +1 -0
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +2 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +40 -13
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +8 -6
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceFeaturesState.d.ts +3 -0
- package/dist/device/DeviceFeaturesState.d.ts.map +1 -0
- package/dist/device/DevicePool.d.ts +4 -2
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts +13 -0
- package/dist/device/DeviceStateMapper.d.ts.map +1 -0
- package/dist/device/DeviceStateProjector.d.ts +7 -0
- package/dist/device/DeviceStateProjector.d.ts.map +1 -0
- package/dist/device/DeviceStateStore.d.ts +21 -0
- package/dist/device/DeviceStateStore.d.ts.map +1 -0
- package/dist/device/DeviceWalletSessionStore.d.ts +20 -0
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -0
- package/dist/device/cloneDeviceState.d.ts +2 -0
- package/dist/device/cloneDeviceState.d.ts.map +1 -0
- package/dist/device/deviceIdentity.d.ts +5 -0
- package/dist/device/deviceIdentity.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +9 -3
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/deviceProfile/index.d.ts +0 -1
- package/dist/deviceProfile/index.d.ts.map +1 -1
- package/dist/events/device.d.ts +12 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +19 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +1487 -691
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8831 -4014
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/deviceSession.d.ts +7 -0
- package/dist/protocols/protocol-v2/deviceSession.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/features.d.ts +23 -28
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +11 -9
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +3 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +16 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +39 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +4 -0
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +31 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -0
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +5 -2
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +11 -2
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +1 -1
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +5 -2
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +75 -6
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/getDeviceState.d.ts +12 -0
- package/dist/types/api/getDeviceState.d.ts.map +1 -0
- package/dist/types/api/getFeatures.d.ts.map +1 -1
- package/dist/types/api/getOnekeyFeatures.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +2 -10
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +25 -35
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/kaspaSignTransaction.d.ts +42 -4
- package/dist/types/api/kaspaSignTransaction.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +29 -0
- package/dist/types/api/openWalletSession.d.ts.map +1 -0
- package/dist/types/api/protocolV2.d.ts +15 -89
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/api/sessionCache.d.ts +13 -0
- package/dist/types/api/sessionCache.d.ts.map +1 -0
- package/dist/types/device.d.ts +122 -6
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +34 -2
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/assets.d.ts +2 -1
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +13 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -0
- package/dist/utils/deviceFeaturesUtils.d.ts +11 -3
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +9 -9
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +38 -7
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +7 -5
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +5 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/networkUtils.d.ts +9 -1
- package/dist/utils/networkUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/pro2Wallpaper.d.ts +12 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -0
- package/dist/utils/tracing.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +52 -17
- package/src/api/CheckAllFirmwareRelease.ts +51 -4
- package/src/api/CheckBootloaderRelease.ts +1 -2
- package/src/api/CheckFirmwareRelease.ts +1 -2
- package/src/api/CipherKeyValue.ts +4 -0
- package/src/api/ClearSessionCache.ts +32 -0
- package/src/api/DirList.ts +9 -4
- package/src/api/DirMake.ts +7 -4
- package/src/api/DirRemove.ts +7 -4
- package/src/api/FileDelete.ts +7 -4
- package/src/api/FileRead.ts +27 -8
- package/src/api/FileWrite.ts +26 -168
- package/src/api/FirmwareUpdate.ts +11 -12
- package/src/api/FirmwareUpdateV2.ts +370 -112
- package/src/api/FirmwareUpdateV3.ts +266 -68
- package/src/api/FirmwareUpdateV4.ts +1687 -397
- package/src/api/GetDeviceState.ts +59 -0
- package/src/api/GetFeatures.ts +6 -4
- package/src/api/GetOnekeyFeatures.ts +1 -75
- package/src/api/GetPassphraseState.ts +21 -21
- package/src/api/OpenWalletSession.ts +202 -0
- package/src/api/PathInfo.ts +9 -4
- package/src/api/PromptWebDeviceAccess.ts +2 -3
- package/src/api/SearchDevices.ts +29 -4
- package/src/api/UploadPortfolio.ts +40 -0
- package/src/api/alephium/AlephiumGetAddress.ts +0 -4
- package/src/api/alephium/AlephiumSignMessage.ts +0 -4
- package/src/api/alephium/AlephiumSignTransaction.ts +2 -6
- package/src/api/algo/AlgoGetAddress.ts +4 -0
- package/src/api/algo/AlgoSignTransaction.ts +4 -0
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +9 -21
- package/src/api/aptos/AptosGetAddress.ts +4 -0
- package/src/api/aptos/AptosGetPublicKey.ts +4 -0
- package/src/api/aptos/AptosSignInMessage.ts +4 -0
- package/src/api/aptos/AptosSignMessage.ts +4 -0
- package/src/api/aptos/AptosSignTransaction.ts +4 -0
- package/src/api/benfen/BenfenGetAddress.ts +11 -7
- package/src/api/benfen/BenfenGetPublicKey.ts +0 -4
- package/src/api/benfen/BenfenSignMessage.ts +0 -4
- package/src/api/benfen/BenfenSignTransaction.ts +0 -4
- package/src/api/btc/BTCGetAddress.ts +8 -1
- package/src/api/btc/BTCGetPublicKey.ts +9 -2
- package/src/api/btc/BTCSignMessage.ts +8 -1
- package/src/api/btc/BTCSignPsbt.ts +4 -0
- package/src/api/btc/BTCSignTransaction.ts +8 -1
- package/src/api/btc/BTCVerifyMessage.ts +8 -1
- package/src/api/btc/helpers/versionLimit.ts +7 -4
- package/src/api/cardano/CardanoGetAddress.ts +4 -0
- package/src/api/cardano/CardanoGetPublicKey.ts +4 -0
- package/src/api/cardano/CardanoSignMessage.ts +5 -1
- package/src/api/cardano/CardanoSignTransaction.ts +5 -1
- package/src/api/conflux/ConfluxGetAddress.ts +6 -0
- package/src/api/conflux/ConfluxSignMessage.ts +6 -0
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +6 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +8 -5
- package/src/api/cosmos/CosmosGetAddress.ts +4 -0
- package/src/api/cosmos/CosmosGetPublicKey.ts +4 -0
- package/src/api/cosmos/CosmosSignTransaction.ts +4 -0
- package/src/api/device/DeviceCancel.ts +5 -0
- package/src/api/device/DeviceChangePin.ts +28 -0
- package/src/api/device/DeviceFullyUploadResource.ts +4 -5
- package/src/api/device/DeviceLock.ts +5 -0
- package/src/api/device/DeviceRebootToBoardloader.ts +9 -4
- package/src/api/device/DeviceRebootToBootloader.ts +9 -4
- package/src/api/device/DeviceSettings.ts +187 -1
- package/src/api/device/DeviceSupportFeatures.ts +4 -0
- package/src/api/device/DeviceUnlock.ts +13 -0
- package/src/api/device/DeviceUpdateBootloader.ts +123 -8
- package/src/api/device/DeviceWipe.ts +25 -0
- package/src/api/device/PreInitialize.ts +4 -0
- package/src/api/dynex/DnxGetAddress.ts +0 -6
- package/src/api/dynex/DnxSignTransaction.ts +0 -6
- package/src/api/evm/EVMGetAddress.ts +4 -0
- package/src/api/evm/EVMGetPublicKey.ts +4 -0
- package/src/api/evm/EVMSignMessage.ts +4 -0
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -11
- package/src/api/evm/EVMSignTransaction.ts +4 -0
- package/src/api/evm/EVMSignTypedData.ts +7 -5
- package/src/api/evm/EVMVerifyMessage.ts +4 -0
- package/src/api/evm/legacyV1/getAddress.ts +2 -2
- package/src/api/evm/legacyV1/getPublicKey.ts +2 -2
- package/src/api/evm/legacyV1/signMessage.ts +2 -2
- package/src/api/evm/legacyV1/signTypedData.ts +2 -2
- package/src/api/evm/legacyV1/signTypedHash.ts +2 -2
- package/src/api/evm/legacyV1/verifyMessage.ts +2 -2
- package/src/api/filecoin/FilecoinGetAddress.ts +4 -0
- package/src/api/filecoin/FilecoinSignTransaction.ts +4 -0
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +71 -7
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +745 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +392 -0
- package/src/api/firmware/getBinary.ts +8 -3
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +140 -22
- package/src/api/helpers/batchGetPublickeys.ts +2 -2
- package/src/api/helpers/filesystemValidation.ts +61 -0
- package/src/api/helpers/paramsValidator.ts +1 -1
- package/src/api/helpers/protocolV2FileWrite.ts +199 -0
- package/src/api/index.ts +7 -30
- package/src/api/kaspa/KaspaGetAddress.ts +7 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +373 -29
- package/src/api/kaspa/helpers/TransferSerialize.ts +17 -7
- package/src/api/lightning/LnurlAuth.ts +0 -4
- package/src/api/near/NearGetAddress.ts +4 -0
- package/src/api/near/NearSignTransaction.ts +4 -0
- package/src/api/nem/NEMGetAddress.ts +4 -0
- package/src/api/nem/NEMSignTransaction.ts +4 -0
- package/src/api/neo/NeoGetAddress.ts +0 -4
- package/src/api/neo/NeoSignTransaction.ts +0 -4
- package/src/api/nervos/NervosGetAddress.ts +0 -4
- package/src/api/nervos/NervosSignTransaction.ts +2 -6
- package/src/api/nexa/NexaGetAddress.ts +0 -4
- package/src/api/nexa/NexaSignTransaction.ts +3 -5
- package/src/api/nostr/NostrDecryptMessage.ts +4 -0
- package/src/api/nostr/NostrEncryptMessage.ts +4 -0
- package/src/api/nostr/NostrGetPublicKey.ts +4 -0
- package/src/api/nostr/NostrSignEvent.ts +4 -0
- package/src/api/nostr/NostrSignSchnorr.ts +4 -0
- package/src/api/polkadot/PolkadotGetAddress.ts +4 -0
- package/src/api/polkadot/PolkadotSignTransaction.ts +4 -0
- package/src/api/protocol-v2/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +8 -5
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +35 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +11 -10
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +45 -7
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +10 -5
- package/src/api/protocol-v2/DeviceInfoGet.ts +141 -0
- package/src/api/protocol-v2/DeviceReboot.ts +8 -4
- package/src/api/protocol-v2/DeviceStatusGet.ts +19 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +134 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +9 -3
- package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +7 -4
- package/src/api/protocol-v2/Ping.ts +37 -3
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +19 -0
- package/src/api/protocol-v2/helpers.ts +71 -50
- package/src/api/scdo/ScdoGetAddress.ts +0 -4
- package/src/api/scdo/ScdoSignMessage.ts +0 -4
- package/src/api/scdo/ScdoSignTransaction.ts +0 -4
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +4 -0
- package/src/api/solana/SolSignOffchainMessage.ts +4 -0
- package/src/api/solana/SolSignTransaction.ts +4 -0
- package/src/api/starcoin/StarcoinGetAddress.ts +4 -0
- package/src/api/starcoin/StarcoinGetPublicKey.ts +4 -0
- package/src/api/starcoin/StarcoinSignMessage.ts +4 -0
- package/src/api/starcoin/StarcoinSignTransaction.ts +4 -0
- package/src/api/starcoin/StarcoinVerifyMessage.ts +4 -0
- package/src/api/stellar/StellarGetAddress.ts +1 -10
- package/src/api/stellar/StellarSignTransaction.ts +1 -14
- package/src/api/sui/SuiGetAddress.ts +4 -0
- package/src/api/sui/SuiGetPublicKey.ts +4 -0
- package/src/api/sui/SuiSignMessage.ts +4 -0
- package/src/api/sui/SuiSignTransaction.ts +4 -0
- package/src/api/ton/TonGetAddress.ts +4 -0
- package/src/api/ton/TonSignData.ts +6 -6
- package/src/api/ton/TonSignMessage.ts +4 -0
- package/src/api/ton/TonSignProof.ts +4 -0
- package/src/api/tron/TronGetAddress.ts +4 -0
- package/src/api/tron/TronSignMessage.ts +18 -7
- package/src/api/tron/TronSignTransaction.ts +4 -0
- package/src/api/utils.ts +7 -3
- package/src/api/xrp/XrpGetAddress.ts +4 -0
- package/src/api/xrp/XrpSignTransaction.ts +5 -1
- package/src/constants/index.ts +1 -4
- package/src/core/RequestQueue.ts +1 -0
- package/src/core/deviceEventRegistration.ts +23 -0
- package/src/core/index.ts +181 -58
- package/src/data/messages/messages-protocol-v2.json +796 -620
- package/src/data/messages/messages.json +286 -1
- package/src/data-manager/DataManager.ts +45 -38
- package/src/data-manager/TransportManager.ts +1 -1
- package/src/data-manager/connectSettings.ts +13 -4
- package/src/device/Device.ts +573 -278
- package/src/device/DeviceCommands.ts +154 -156
- package/src/device/DeviceFeaturesState.ts +25 -0
- package/src/device/DevicePool.ts +61 -13
- package/src/device/DeviceStateMapper.ts +366 -0
- package/src/device/DeviceStateProjector.ts +101 -0
- package/src/device/DeviceStateStore.ts +201 -0
- package/src/device/DeviceWalletSessionStore.ts +105 -0
- package/src/device/cloneDeviceState.ts +39 -0
- package/src/device/deviceIdentity.ts +18 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +234 -210
- package/src/deviceProfile/index.ts +0 -1
- package/src/events/device.ts +18 -1
- package/src/events/logBlockEvent.ts +1 -7
- package/src/events/ui-request.ts +25 -2
- package/src/index.ts +5 -0
- package/src/inject.ts +35 -47
- package/src/lowLevelInject.ts +5 -1
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +68 -83
- package/src/protocols/protocol-v2/firmware.ts +12 -36
- package/src/protocols/protocol-v2/index.ts +3 -1
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +60 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +210 -0
- package/src/protocols/protocol-v2/unlockPolicy.ts +105 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +98 -0
- package/src/protocols/protocol-v2/walletSession.ts +202 -0
- package/src/topLevelInject.ts +5 -1
- package/src/types/api/checkAllFirmwareRelease.ts +5 -2
- package/src/types/api/deviceSettings.ts +26 -2
- package/src/types/api/deviceUnlock.ts +1 -1
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +21 -0
- package/src/types/api/firmwareUpdate.ts +103 -19
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/getDeviceState.ts +19 -0
- package/src/types/api/getFeatures.ts +3 -0
- package/src/types/api/getOnekeyFeatures.ts +3 -0
- package/src/types/api/getPassphraseState.ts +9 -11
- package/src/types/api/index.ts +33 -73
- package/src/types/api/kaspaSignTransaction.ts +60 -4
- package/src/types/api/openWalletSession.ts +45 -0
- package/src/types/api/protocolV2.ts +23 -162
- package/src/types/api/sessionCache.ts +19 -0
- package/src/types/device.ts +172 -5
- package/src/types/params.ts +4 -0
- package/src/types/settings.ts +55 -35
- package/src/utils/assets.ts +4 -1
- package/src/utils/deviceFeaturesCompat.ts +173 -0
- package/src/utils/deviceFeaturesUtils.ts +66 -24
- package/src/utils/deviceInfoUtils.ts +27 -69
- package/src/utils/deviceSettings.ts +171 -39
- package/src/utils/deviceVersionUtils.ts +25 -44
- package/src/utils/findDefectiveBatchDevice.ts +3 -3
- package/src/utils/homescreen.ts +10 -0
- package/src/utils/index.ts +21 -2
- package/src/utils/networkUtils.ts +270 -14
- package/src/utils/pro2Wallpaper.ts +109 -0
- package/src/utils/tracing.ts +3 -1
- package/tsconfig.type-tests.json +8 -0
- package/dist/api/GetDeviceInfo.d.ts +0 -9
- package/dist/api/GetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +0 -29
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +0 -6
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts +0 -21
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +0 -1
- package/dist/types/api/getDeviceInfo.d.ts +0 -85
- package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
- package/src/api/GetDeviceInfo.ts +0 -145
- package/src/api/protocol-v2/DevReboot.ts +0 -24
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +0 -118
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
- package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
- package/src/api/protocol-v2/GetProtoVersion.ts +0 -16
- package/src/deviceProfile/buildDeviceProfile.ts +0 -333
- package/src/types/api/getDeviceInfo.ts +0 -99
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
import BenfenGetAddress from '../src/api/benfen/BenfenGetAddress';
|
|
4
|
+
import ConfluxSignTransaction from '../src/api/conflux/ConfluxSignTransaction';
|
|
5
|
+
import EVMSignTransaction from '../src/api/evm/EVMSignTransaction';
|
|
6
|
+
import EVMSignMessageEIP712 from '../src/api/evm/EVMSignMessageEIP712';
|
|
7
|
+
import KaspaSignTransaction from '../src/api/kaspa/KaspaSignTransaction';
|
|
8
|
+
import XrpSignTransaction from '../src/api/xrp/XrpSignTransaction';
|
|
9
|
+
|
|
10
|
+
import type { Device } from '../src/device/Device';
|
|
11
|
+
|
|
12
|
+
jest.mock('../src/data/config', () => ({
|
|
13
|
+
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
14
|
+
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock('../src/data-manager/TransportManager', () => ({
|
|
18
|
+
getProtocolV1MessageSchema: jest.fn(() => 'v1CurrentSchema'),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock('../src/device/Device', () => ({
|
|
22
|
+
Device: jest.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const KASPA_PATH = "m/44'/111111'/0'/0/0";
|
|
26
|
+
const KASPA_SCRIPT = `20${'ab'.repeat(32)}ac`;
|
|
27
|
+
const KASPA_ADDRESS = 'kaspa:qr0lr4ml9fn3chekrqmjdkergxl93l4wrk3dankcgvjq776s9wn9jkdskewva';
|
|
28
|
+
|
|
29
|
+
const buildKaspaPayload = () => ({
|
|
30
|
+
method: 'kaspaSignTransaction',
|
|
31
|
+
version: 0,
|
|
32
|
+
lockTime: 0,
|
|
33
|
+
inputs: [
|
|
34
|
+
{
|
|
35
|
+
path: KASPA_PATH,
|
|
36
|
+
prevTxId: 'aa'.repeat(32),
|
|
37
|
+
outputIndex: 0,
|
|
38
|
+
sequenceNumber: 0,
|
|
39
|
+
output: { satoshis: 200000, script: KASPA_SCRIPT },
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
outputs: [{ satoshis: 100000, script: KASPA_SCRIPT, scriptVersion: 0 }],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('onekey public-chain parameter compatibility', () => {
|
|
46
|
+
it('keeps the historical EVM contract-deployment representation', () => {
|
|
47
|
+
const transaction = {
|
|
48
|
+
to: '',
|
|
49
|
+
value: '0x0',
|
|
50
|
+
gasPrice: '0x1',
|
|
51
|
+
gasLimit: '0x5208',
|
|
52
|
+
nonce: '0x0',
|
|
53
|
+
chainId: 1,
|
|
54
|
+
data: '0x6000',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const method = new EVMSignTransaction({
|
|
58
|
+
id: 1,
|
|
59
|
+
payload: {
|
|
60
|
+
method: 'evmSignTransaction',
|
|
61
|
+
path: "m/44'/60'/0'/0/0",
|
|
62
|
+
transaction,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
expect(() => method.init()).not.toThrow();
|
|
67
|
+
|
|
68
|
+
const { to: _to, ...transactionWithoutTo } = transaction;
|
|
69
|
+
const missingTo = new EVMSignTransaction({
|
|
70
|
+
id: 2,
|
|
71
|
+
payload: {
|
|
72
|
+
method: 'evmSignTransaction',
|
|
73
|
+
path: "m/44'/60'/0'/0/0",
|
|
74
|
+
transaction: transactionWithoutTo,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(() => missingTo.init()).toThrow('Missing required parameter: to');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('keeps Conflux to validation aligned with onekey', () => {
|
|
82
|
+
const method = new ConfluxSignTransaction({
|
|
83
|
+
id: 1,
|
|
84
|
+
payload: {
|
|
85
|
+
method: 'confluxSignTransaction',
|
|
86
|
+
path: "m/44'/503'/0'/0/0",
|
|
87
|
+
transaction: {
|
|
88
|
+
to: 'cfx:aak2rra2njvd77ezwjvx04kkds9fzagfe6d5r8e957',
|
|
89
|
+
value: '0x0',
|
|
90
|
+
gasLimit: '0x5208',
|
|
91
|
+
gasPrice: '0x1',
|
|
92
|
+
nonce: '0x0',
|
|
93
|
+
epochHeight: '0x1',
|
|
94
|
+
storageLimit: '0x0',
|
|
95
|
+
chainId: 1029,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
expect(() => method.init()).toThrow('should be [hexString]');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('keeps XRP payment amount as the historical number input', () => {
|
|
104
|
+
const createMethod = (amount: number | string) =>
|
|
105
|
+
new XrpSignTransaction({
|
|
106
|
+
id: 1,
|
|
107
|
+
payload: {
|
|
108
|
+
method: 'xrpSignTransaction',
|
|
109
|
+
path: "m/44'/144'/0'/0/0",
|
|
110
|
+
transaction: {
|
|
111
|
+
payment: {
|
|
112
|
+
amount,
|
|
113
|
+
destination: 'rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(() => createMethod(1).init()).not.toThrow();
|
|
120
|
+
expect(() => createMethod('1').init()).toThrow('should be [number]');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('keeps the Kaspa legacy schema while allowing the additive streaming shape', () => {
|
|
124
|
+
const legacyWithoutSigHash = new KaspaSignTransaction({
|
|
125
|
+
id: 1,
|
|
126
|
+
payload: buildKaspaPayload(),
|
|
127
|
+
});
|
|
128
|
+
expect(() => legacyWithoutSigHash.init()).toThrow('Missing required parameter: sigHashType');
|
|
129
|
+
|
|
130
|
+
const legacyWithoutScript = new KaspaSignTransaction({
|
|
131
|
+
id: 2,
|
|
132
|
+
payload: {
|
|
133
|
+
...buildKaspaPayload(),
|
|
134
|
+
sigHashType: 0x41,
|
|
135
|
+
outputs: [{ satoshis: 100000, scriptVersion: 0 }],
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
expect(() => legacyWithoutScript.init()).toThrow('Missing required parameter: script');
|
|
139
|
+
|
|
140
|
+
const streaming = new KaspaSignTransaction({
|
|
141
|
+
id: 3,
|
|
142
|
+
payload: {
|
|
143
|
+
...buildKaspaPayload(),
|
|
144
|
+
inputs: [
|
|
145
|
+
{
|
|
146
|
+
...buildKaspaPayload().inputs[0],
|
|
147
|
+
output: { satoshis: 200000 },
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
outputs: [{ satoshis: 100000, address: KASPA_ADDRESS }],
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
expect(() => streaming.init()).not.toThrow();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('keeps validating the Kaspa legacy input amount', () => {
|
|
157
|
+
const payload = buildKaspaPayload();
|
|
158
|
+
const method = new KaspaSignTransaction({
|
|
159
|
+
id: 1,
|
|
160
|
+
payload: {
|
|
161
|
+
...payload,
|
|
162
|
+
sigHashType: 0x41,
|
|
163
|
+
inputs: [
|
|
164
|
+
{
|
|
165
|
+
...payload.inputs[0],
|
|
166
|
+
output: { script: KASPA_SCRIPT },
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
expect(() => method.init()).toThrow('Missing required parameter: satoshis');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('keeps the deprecated EIP-712 method callable on existing Protocol V1 devices', async () => {
|
|
176
|
+
const method = new EVMSignMessageEIP712({
|
|
177
|
+
id: 1,
|
|
178
|
+
payload: {
|
|
179
|
+
method: 'evmSignMessageEIP712',
|
|
180
|
+
path: "m/44'/60'/0'/0/0",
|
|
181
|
+
domainHash: `0x${'11'.repeat(32)}`,
|
|
182
|
+
messageHash: `0x${'22'.repeat(32)}`,
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
method.init();
|
|
186
|
+
|
|
187
|
+
const typedCall = jest.fn().mockResolvedValue({
|
|
188
|
+
message: {
|
|
189
|
+
address: '0x1234',
|
|
190
|
+
signature: 'abcd',
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
method.device = {
|
|
194
|
+
commands: { typedCall },
|
|
195
|
+
getCurrentFirmwareVersionString: jest.fn(() => '4.10.0'),
|
|
196
|
+
getCurrentMethodVersionRange: jest.fn(() => undefined),
|
|
197
|
+
getCurrentFirmwareType: jest.fn(() => EFirmwareType.Universal),
|
|
198
|
+
getProtocol: jest.fn(() => 'V1'),
|
|
199
|
+
} as unknown as Device;
|
|
200
|
+
|
|
201
|
+
await expect(method.run()).resolves.toEqual({
|
|
202
|
+
address: '0x1234',
|
|
203
|
+
signature: 'abcd',
|
|
204
|
+
});
|
|
205
|
+
expect(typedCall).toHaveBeenCalledTimes(1);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('rejects a Benfen response that omits the address', async () => {
|
|
209
|
+
const method = new BenfenGetAddress({
|
|
210
|
+
id: 1,
|
|
211
|
+
payload: {
|
|
212
|
+
method: 'benfenGetAddress',
|
|
213
|
+
path: "m/44'/728'/0'/0'/0'",
|
|
214
|
+
showOnOneKey: false,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
method.init();
|
|
218
|
+
method.device = {
|
|
219
|
+
commands: {
|
|
220
|
+
typedCall: jest.fn().mockResolvedValue({ message: {} }),
|
|
221
|
+
},
|
|
222
|
+
getCurrentFirmwareVersionString: jest.fn(() => '1.0.0'),
|
|
223
|
+
getCurrentDeviceType: jest.fn(() => EDeviceType.Classic),
|
|
224
|
+
isProtocolV2: jest.fn(() => false),
|
|
225
|
+
} as unknown as Device;
|
|
226
|
+
|
|
227
|
+
await expect(method.run()).rejects.toThrow(/address/i);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import DataManager from '../src/data-manager/DataManager';
|
|
2
|
+
import { parseConnectSettings } from '../src/data-manager/connectSettings';
|
|
3
|
+
|
|
4
|
+
import type { RemoteConfigResponse } from '../src/types';
|
|
5
|
+
|
|
6
|
+
jest.mock('axios', () => ({
|
|
7
|
+
get: jest.fn(),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
jest.mock('../src/data/config', () => ({
|
|
11
|
+
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
12
|
+
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
const mockAxiosGet: jest.Mock = jest.requireMock('axios').get;
|
|
16
|
+
|
|
17
|
+
describe('parseConnectSettings', () => {
|
|
18
|
+
const preloadedConfig = {
|
|
19
|
+
bridge: {},
|
|
20
|
+
classic: { firmware: [], ble: [] },
|
|
21
|
+
classic1s: { firmware: [], ble: [] },
|
|
22
|
+
classicpure: { firmware: [], ble: [] },
|
|
23
|
+
mini: { firmware: [], ble: [] },
|
|
24
|
+
touch: { firmware: [], ble: [] },
|
|
25
|
+
pro: { firmware: [], ble: [] },
|
|
26
|
+
pro2: { firmware: [], ble: [] },
|
|
27
|
+
} as unknown as RemoteConfigResponse;
|
|
28
|
+
|
|
29
|
+
it('keeps a serializable preloaded config in parsed settings', () => {
|
|
30
|
+
const settings = parseConnectSettings({
|
|
31
|
+
firmwareManifestMode: 'sdk-managed',
|
|
32
|
+
preloadedConfig,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
expect(settings.firmwareManifestMode).toBe('sdk-managed');
|
|
36
|
+
expect(settings.preloadedConfig).toBe(preloadedConfig);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('uses the preloaded config before the SDK network client', async () => {
|
|
40
|
+
const settings = parseConnectSettings({
|
|
41
|
+
firmwareManifestMode: 'sdk-managed',
|
|
42
|
+
preloadedConfig,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
await DataManager.load(settings);
|
|
46
|
+
|
|
47
|
+
expect(mockAxiosGet).not.toHaveBeenCalled();
|
|
48
|
+
expect(DataManager.deviceMap.classic).toEqual({ firmware: [], ble: [] });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('fails closed without a preloaded config in external-only mode', async () => {
|
|
52
|
+
const settings = parseConnectSettings({
|
|
53
|
+
firmwareManifestMode: 'external-only',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
await expect(DataManager.load(settings)).rejects.toThrow(
|
|
57
|
+
'External firmware config snapshot is required'
|
|
58
|
+
);
|
|
59
|
+
expect(mockAxiosGet).not.toHaveBeenCalled();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Core, { initConnector } from '../src/core';
|
|
2
|
+
import TransportManager from '../src/data-manager/TransportManager';
|
|
3
|
+
import { DevicePool } from '../src/device/DevicePool';
|
|
4
|
+
|
|
5
|
+
jest.mock('../src/data/config', () => ({
|
|
6
|
+
getSDKVersion: jest.fn(() => '1.0.0-test'),
|
|
7
|
+
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0-test/',
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
describe('Core.dispose', () => {
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
jest.restoreAllMocks();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('幂等停止 Connector 和 Transport,并重置共享设备状态', async () => {
|
|
16
|
+
const connector = initConnector();
|
|
17
|
+
const connectorStop = jest.spyOn(connector, 'stop');
|
|
18
|
+
const transportStop = jest.fn().mockResolvedValue(undefined);
|
|
19
|
+
jest.spyOn(TransportManager, 'getTransport').mockReturnValue({ stop: transportStop } as never);
|
|
20
|
+
const resetDevicePool = jest.spyOn(DevicePool, 'resetState');
|
|
21
|
+
const core = new Core();
|
|
22
|
+
|
|
23
|
+
const firstDispose = core.dispose();
|
|
24
|
+
expect(connectorStop).toHaveBeenCalledTimes(1);
|
|
25
|
+
expect(transportStop).toHaveBeenCalledTimes(1);
|
|
26
|
+
expect(resetDevicePool).toHaveBeenCalledTimes(1);
|
|
27
|
+
|
|
28
|
+
await firstDispose;
|
|
29
|
+
await core.dispose();
|
|
30
|
+
expect(connectorStop).toHaveBeenCalledTimes(1);
|
|
31
|
+
expect(transportStop).toHaveBeenCalledTimes(1);
|
|
32
|
+
expect(resetDevicePool).toHaveBeenCalledTimes(1);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { initCore } from '../src/core';
|
|
2
|
+
import { IFRAME } from '../src/events';
|
|
3
|
+
|
|
4
|
+
jest.mock('../src/data/config', () => ({
|
|
5
|
+
getSDKVersion: jest.fn(() => '1.0.0-test'),
|
|
6
|
+
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0-test/',
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
jest.mock('../src/data-manager/TransportManager', () => ({
|
|
10
|
+
__esModule: true,
|
|
11
|
+
default: {
|
|
12
|
+
configure: jest.fn().mockResolvedValue(undefined),
|
|
13
|
+
getTransport: jest.fn(() => undefined),
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
describe('Core 错误输出边界', () => {
|
|
18
|
+
test('连接失败只返回结构化错误,不直接写入 stdout', async () => {
|
|
19
|
+
const stdout = jest.spyOn(console, 'log').mockImplementation(() => undefined);
|
|
20
|
+
const core = initCore();
|
|
21
|
+
|
|
22
|
+
const response = await core.handleMessage({
|
|
23
|
+
id: 1,
|
|
24
|
+
event: IFRAME.CALL,
|
|
25
|
+
type: IFRAME.CALL,
|
|
26
|
+
payload: {
|
|
27
|
+
method: 'getDeviceState',
|
|
28
|
+
connectId: 'missing-device',
|
|
29
|
+
retryCount: 0,
|
|
30
|
+
pollIntervalTime: 1,
|
|
31
|
+
timeout: 10,
|
|
32
|
+
},
|
|
33
|
+
} as never);
|
|
34
|
+
|
|
35
|
+
expect(response).toMatchObject({ success: false });
|
|
36
|
+
expect(stdout).not.toHaveBeenCalled();
|
|
37
|
+
await core.dispose();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { mergeDeviceFeaturesPatch } from '../src/device/DeviceFeaturesState';
|
|
2
|
+
|
|
3
|
+
import type { Features } from '../src/types';
|
|
4
|
+
|
|
5
|
+
const baseFeatures = {
|
|
6
|
+
protocol: 'V2',
|
|
7
|
+
deviceType: 'pro2',
|
|
8
|
+
firmwareType: 'universal',
|
|
9
|
+
model: 'pro2',
|
|
10
|
+
vendor: 'onekey.so',
|
|
11
|
+
deviceId: null,
|
|
12
|
+
serialNo: 'P20001',
|
|
13
|
+
label: 'Old Label',
|
|
14
|
+
bleName: 'Pro2 0001',
|
|
15
|
+
capabilities: [],
|
|
16
|
+
mode: 'normal',
|
|
17
|
+
initialized: true,
|
|
18
|
+
bootloaderMode: false,
|
|
19
|
+
unlocked: true,
|
|
20
|
+
firmwarePresent: true,
|
|
21
|
+
passphraseProtection: false,
|
|
22
|
+
pinProtection: true,
|
|
23
|
+
backupRequired: false,
|
|
24
|
+
noBackup: false,
|
|
25
|
+
unfinishedBackup: false,
|
|
26
|
+
recoveryMode: false,
|
|
27
|
+
language: 'en-US',
|
|
28
|
+
bleEnabled: true,
|
|
29
|
+
sdCardPresent: null,
|
|
30
|
+
sdProtection: null,
|
|
31
|
+
wipeCodeProtection: null,
|
|
32
|
+
passphraseAlwaysOnDevice: null,
|
|
33
|
+
safetyChecks: null,
|
|
34
|
+
autoLockDelayMs: 60_000,
|
|
35
|
+
displayRotation: null,
|
|
36
|
+
experimentalFeatures: false,
|
|
37
|
+
firmwareVersion: '1.0.0',
|
|
38
|
+
bootloaderVersion: '1.0.0',
|
|
39
|
+
boardVersion: '1.0.0',
|
|
40
|
+
bleVersion: '1.0.0',
|
|
41
|
+
sessionId: null,
|
|
42
|
+
} as Features;
|
|
43
|
+
|
|
44
|
+
describe('mergeDeviceFeaturesPatch', () => {
|
|
45
|
+
it('ignores undefined fields instead of clearing cached values', () => {
|
|
46
|
+
const next = mergeDeviceFeaturesPatch(baseFeatures, {
|
|
47
|
+
label: undefined,
|
|
48
|
+
language: 'ja-JP',
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(next).toMatchObject({
|
|
52
|
+
label: 'Old Label',
|
|
53
|
+
language: 'ja-JP',
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('allows null to explicitly clear a cached value', () => {
|
|
58
|
+
const next = mergeDeviceFeaturesPatch(baseFeatures, { label: null });
|
|
59
|
+
|
|
60
|
+
expect(next.label).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('returns the same object when no value changes', () => {
|
|
64
|
+
const next = mergeDeviceFeaturesPatch(baseFeatures, {
|
|
65
|
+
label: 'Old Label',
|
|
66
|
+
language: undefined,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(next).toBe(baseFeatures);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('returns a new object when a defined value changes', () => {
|
|
73
|
+
const next = mergeDeviceFeaturesPatch(baseFeatures, { label: 'New Label' });
|
|
74
|
+
|
|
75
|
+
expect(next).not.toBe(baseFeatures);
|
|
76
|
+
expect(next.label).toBe('New Label');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { checkLiveDeviceId } from '../src/device/deviceIdentity';
|
|
2
|
+
import ConfluxGetAddress from '../src/api/conflux/ConfluxGetAddress';
|
|
3
|
+
import ConfluxSignMessage from '../src/api/conflux/ConfluxSignMessage';
|
|
4
|
+
import ConfluxSignMessageCIP23 from '../src/api/conflux/ConfluxSignMessageCIP23';
|
|
5
|
+
import ConfluxSignTransaction from '../src/api/conflux/ConfluxSignTransaction';
|
|
6
|
+
import NexaSignTransaction from '../src/api/nexa/NexaSignTransaction';
|
|
7
|
+
|
|
8
|
+
jest.mock('../src/data/config', () => ({
|
|
9
|
+
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
10
|
+
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
describe('live device identity', () => {
|
|
14
|
+
test.each([
|
|
15
|
+
['confluxGetAddress', ConfluxGetAddress],
|
|
16
|
+
['confluxSignMessage', ConfluxSignMessage],
|
|
17
|
+
['confluxSignMessageCIP23', ConfluxSignMessageCIP23],
|
|
18
|
+
['confluxSignTransaction', ConfluxSignTransaction],
|
|
19
|
+
['nexaSignTransaction', NexaSignTransaction],
|
|
20
|
+
])('%s requires a live device id check', (methodName, Method) => {
|
|
21
|
+
const method = new Method({ payload: { method: methodName } });
|
|
22
|
+
|
|
23
|
+
expect(method.checkDeviceId).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('refreshes Protocol V2 status before comparing the expected device id', async () => {
|
|
27
|
+
let currentDeviceId = 'OLD_DEVICE_ID';
|
|
28
|
+
const device = {
|
|
29
|
+
isProtocolV2: () => true,
|
|
30
|
+
getDeviceState: jest.fn().mockImplementation(() => {
|
|
31
|
+
currentDeviceId = 'NEW_DEVICE_ID';
|
|
32
|
+
return Promise.resolve({ identity: { deviceId: currentDeviceId } });
|
|
33
|
+
}),
|
|
34
|
+
checkDeviceId: jest.fn((expected: string) => currentDeviceId === expected),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
await expect(checkLiveDeviceId(device as never, 'OLD_DEVICE_ID')).resolves.toBe(false);
|
|
38
|
+
expect(device.getDeviceState).toHaveBeenCalledWith({ refreshSections: ['status'] });
|
|
39
|
+
expect(device.checkDeviceId).toHaveBeenCalledWith('OLD_DEVICE_ID');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('keeps Protocol V1 identity checks on the Initialize/GetFeatures state', async () => {
|
|
43
|
+
const device = {
|
|
44
|
+
isProtocolV2: () => false,
|
|
45
|
+
getDeviceState: jest.fn(),
|
|
46
|
+
checkDeviceId: jest.fn(() => true),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
await expect(checkLiveDeviceId(device as never, 'V1_DEVICE_ID')).resolves.toBe(true);
|
|
50
|
+
expect(device.getDeviceState).not.toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { TRANSPORT_EVENT } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
3
|
+
import { initConnector, initCore } from '../src/core';
|
|
4
|
+
import { DataManager } from '../src/data-manager';
|
|
5
|
+
import TransportManager from '../src/data-manager/TransportManager';
|
|
6
|
+
import { Device } from '../src/device/Device';
|
|
7
|
+
import { DevicePool } from '../src/device/DevicePool';
|
|
8
|
+
import { CORE_EVENT, DEVICE, IFRAME } from '../src/events';
|
|
9
|
+
|
|
10
|
+
import type Core from '../src/core';
|
|
11
|
+
import type { CoreMessage } from '../src/events';
|
|
12
|
+
import type { KnownDevice } from '../src/types';
|
|
13
|
+
|
|
14
|
+
jest.mock('../src/data/config', () => ({
|
|
15
|
+
getSDKVersion: jest.fn(() => '1.0.0-test'),
|
|
16
|
+
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0-test/',
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const createInitializedDevice = (protocol: 'V1' | 'V2') => {
|
|
20
|
+
const device = Device.fromDescriptor({
|
|
21
|
+
id: 'ble-discovery-id',
|
|
22
|
+
path: 'ble-discovery-id',
|
|
23
|
+
commType: 'ble',
|
|
24
|
+
protocolType: protocol,
|
|
25
|
+
} as never);
|
|
26
|
+
device.mainId = 'ble-connect-id';
|
|
27
|
+
device.features = {
|
|
28
|
+
protocol,
|
|
29
|
+
deviceType: protocol === 'V2' ? 'pro2' : 'classic',
|
|
30
|
+
firmwareType: 'universal',
|
|
31
|
+
deviceId: 'wallet-device-id',
|
|
32
|
+
serialNo: 'SERIAL-001',
|
|
33
|
+
label: 'OneKey Test',
|
|
34
|
+
bleName: 'OneKey Test BLE',
|
|
35
|
+
capabilities: [],
|
|
36
|
+
mode: 'normal',
|
|
37
|
+
initialized: true,
|
|
38
|
+
bootloaderMode: false,
|
|
39
|
+
firmwareVersion: '1.2.3',
|
|
40
|
+
bootloaderVersion: '1.0.0',
|
|
41
|
+
boardVersion: '1.0.0',
|
|
42
|
+
bleVersion: '2.3.4',
|
|
43
|
+
} as never;
|
|
44
|
+
return device;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
describe('public device lifecycle events', () => {
|
|
48
|
+
let core: Core | undefined;
|
|
49
|
+
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
DevicePool.resetState();
|
|
52
|
+
jest.spyOn(TransportManager, 'load').mockImplementation();
|
|
53
|
+
TransportManager.transport = {
|
|
54
|
+
stop: jest.fn().mockResolvedValue(undefined),
|
|
55
|
+
} as never;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
afterEach(async () => {
|
|
59
|
+
await core?.dispose();
|
|
60
|
+
core = undefined;
|
|
61
|
+
jest.restoreAllMocks();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('registers the shared device lifecycle listeners exactly once', async () => {
|
|
65
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
66
|
+
core = initCore();
|
|
67
|
+
initConnector();
|
|
68
|
+
|
|
69
|
+
for (const id of ['first-call', 'second-call']) {
|
|
70
|
+
await core.handleMessage({
|
|
71
|
+
id,
|
|
72
|
+
event: IFRAME.CALL,
|
|
73
|
+
type: IFRAME.CALL,
|
|
74
|
+
payload: { method: 'clearSessionCache' },
|
|
75
|
+
} as CoreMessage);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
expect(DevicePool.emitter.listenerCount(DEVICE.CONNECT)).toBe(1);
|
|
79
|
+
expect(DevicePool.emitter.listenerCount(DEVICE.DISCONNECT)).toBe(1);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('converts an internal transport disconnect into a public KnownDevice snapshot', () => {
|
|
83
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
84
|
+
core = initCore();
|
|
85
|
+
initConnector();
|
|
86
|
+
const messages: CoreMessage[] = [];
|
|
87
|
+
core.on(CORE_EVENT, message => messages.push(message));
|
|
88
|
+
const device = createInitializedDevice('V2');
|
|
89
|
+
DevicePool.devicesCache['ble-connect-id'] = device;
|
|
90
|
+
|
|
91
|
+
DevicePool.emitter.emit(TRANSPORT_EVENT.DEVICE_DISCONNECT, {
|
|
92
|
+
id: 'ble-connect-id',
|
|
93
|
+
connectId: 'ble-connect-id',
|
|
94
|
+
name: 'OneKey Test BLE',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const disconnectMessage = messages.find(message => message.type === DEVICE.DISCONNECT);
|
|
98
|
+
expect(disconnectMessage?.payload.device).toMatchObject({
|
|
99
|
+
connectId: 'ble-connect-id',
|
|
100
|
+
serialNo: 'SERIAL-001',
|
|
101
|
+
state: { protocol: 'V2' },
|
|
102
|
+
});
|
|
103
|
+
expect(() => JSON.stringify(disconnectMessage?.payload.device)).not.toThrow();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('treats an acquired BLE device as reusable until the transport disconnects', async () => {
|
|
107
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('desktop-web-ble' as never);
|
|
108
|
+
const device = createInitializedDevice('V2');
|
|
109
|
+
const acquire = jest.spyOn(device, 'acquire').mockResolvedValue(undefined);
|
|
110
|
+
(device as unknown as { deviceAcquired: boolean }).deviceAcquired = true;
|
|
111
|
+
(device as any).commands = { disposed: false };
|
|
112
|
+
|
|
113
|
+
expect(device.isUsedHere()).toBe(true);
|
|
114
|
+
await expect(device.connect('V2')).resolves.toBe(true);
|
|
115
|
+
expect(acquire).not.toHaveBeenCalled();
|
|
116
|
+
|
|
117
|
+
device.markTransportDisconnected();
|
|
118
|
+
expect(device.isUsedHere()).toBe(false);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('exposes the current transport usage state in public device snapshots', () => {
|
|
122
|
+
const getSettings = jest
|
|
123
|
+
.spyOn(DataManager, 'getSettings')
|
|
124
|
+
.mockReturnValue('desktop-web-ble' as never);
|
|
125
|
+
const device = createInitializedDevice('V2');
|
|
126
|
+
|
|
127
|
+
expect(device.toMessageObject()?.status).toBe('available');
|
|
128
|
+
|
|
129
|
+
(device as unknown as { deviceAcquired: boolean }).deviceAcquired = true;
|
|
130
|
+
expect(device.toMessageObject()?.status).toBe('used');
|
|
131
|
+
|
|
132
|
+
device.markTransportDisconnected();
|
|
133
|
+
expect(device.toMessageObject()?.status).toBe('available');
|
|
134
|
+
|
|
135
|
+
getSettings.mockReturnValue('web' as never);
|
|
136
|
+
device.originalDescriptor.session = 'external-session';
|
|
137
|
+
expect(device.toMessageObject()?.status).toBe('occupied');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test.each([
|
|
141
|
+
['react-native', 'V1'],
|
|
142
|
+
['react-native', 'V2'],
|
|
143
|
+
['lowlevel', 'V1'],
|
|
144
|
+
['lowlevel', 'V2'],
|
|
145
|
+
] as const)(
|
|
146
|
+
'emits KnownDevice snapshots for %s Protocol %s connect and disconnect events',
|
|
147
|
+
async (env, protocol) => {
|
|
148
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue(env as never);
|
|
149
|
+
core = initCore();
|
|
150
|
+
initConnector();
|
|
151
|
+
|
|
152
|
+
await core.handleMessage({
|
|
153
|
+
id: 'register-device-connect-listener',
|
|
154
|
+
event: IFRAME.CALL,
|
|
155
|
+
type: IFRAME.CALL,
|
|
156
|
+
payload: { method: 'clearSessionCache' },
|
|
157
|
+
} as CoreMessage);
|
|
158
|
+
|
|
159
|
+
const messages: CoreMessage[] = [];
|
|
160
|
+
core.on(CORE_EVENT, message => messages.push(message));
|
|
161
|
+
const internalDevice = createInitializedDevice(protocol);
|
|
162
|
+
|
|
163
|
+
DevicePool.emitter.emit(DEVICE.CONNECT, internalDevice);
|
|
164
|
+
internalDevice.updateState({ identity: { label: 'Updated label' } }, 'settings-write');
|
|
165
|
+
DevicePool.emitter.emit(DEVICE.DISCONNECT, internalDevice);
|
|
166
|
+
|
|
167
|
+
const connectMessage = messages.find(message => message.type === DEVICE.CONNECT);
|
|
168
|
+
const disconnectMessage = messages.find(message => message.type === DEVICE.DISCONNECT);
|
|
169
|
+
const connectedDevice = connectMessage?.payload.device as KnownDevice;
|
|
170
|
+
const disconnectedDevice = disconnectMessage?.payload.device as KnownDevice;
|
|
171
|
+
|
|
172
|
+
expect(connectedDevice).toMatchObject({
|
|
173
|
+
connectId: 'ble-connect-id',
|
|
174
|
+
serialNo: 'SERIAL-001',
|
|
175
|
+
uuid: 'SERIAL-001',
|
|
176
|
+
status: 'available',
|
|
177
|
+
label: 'OneKey Test',
|
|
178
|
+
state: { protocol },
|
|
179
|
+
});
|
|
180
|
+
expect(disconnectedDevice).toMatchObject({
|
|
181
|
+
connectId: 'ble-connect-id',
|
|
182
|
+
serialNo: 'SERIAL-001',
|
|
183
|
+
uuid: 'SERIAL-001',
|
|
184
|
+
status: 'available',
|
|
185
|
+
label: 'Updated label',
|
|
186
|
+
state: { protocol },
|
|
187
|
+
});
|
|
188
|
+
expect(connectedDevice).not.toBe(internalDevice);
|
|
189
|
+
expect(connectedDevice).not.toBe(disconnectedDevice);
|
|
190
|
+
expect(connectedDevice).not.toHaveProperty('run');
|
|
191
|
+
expect(connectedDevice).not.toHaveProperty('acquire');
|
|
192
|
+
expect(connectedDevice).not.toHaveProperty('commands');
|
|
193
|
+
expect(() => JSON.stringify(connectedDevice)).not.toThrow();
|
|
194
|
+
expect(connectedDevice.label).toBe('OneKey Test');
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
});
|