@onekeyfe/hd-core 1.1.34-alpha.2 → 1.1.34-alpha.3
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 +75 -0
- package/__tests__/DeviceCommands.test.ts +217 -0
- package/__tests__/RequestQueue.test.ts +140 -0
- package/__tests__/UploadPortfolio.test.ts +46 -0
- package/__tests__/connectSettings.test.ts +61 -0
- package/__tests__/device-lifecycle-events.test.ts +117 -0
- package/__tests__/device-pool-state.test.ts +132 -0
- package/__tests__/device-settings.test.ts +286 -0
- package/__tests__/device-state-mapper.test.ts +229 -0
- package/__tests__/device-utils.test.ts +106 -0
- package/__tests__/device-wallet-session-store.test.ts +191 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +15 -4
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/filesystemValidation.test.ts +53 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-checkpoint.test.ts +105 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +73 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +17 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +358 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-recovery.test.ts +81 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +48 -31
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +403 -0
- package/__tests__/logBlockEvent.test.ts +61 -0
- package/__tests__/logger.test.ts +34 -0
- package/__tests__/open-wallet-session.test.ts +565 -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.test.ts +6008 -0
- package/__tests__/protocolV2FileWrite.test.ts +67 -0
- package/__tests__/public-pro2-api-boundary.test.ts +66 -0
- package/__tests__/search-devices.test.ts +136 -0
- package/dist/api/BaseMethod.d.ts +12 -0
- 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/ClearSessionCache.d.ts +9 -0
- package/dist/api/ClearSessionCache.d.ts.map +1 -0
- 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 +25 -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 +14 -3
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +10 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +75 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -0
- package/dist/api/GetDeviceState.d.ts +7 -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.map +1 -1
- package/dist/api/OpenWalletSession.d.ts +14 -0
- package/dist/api/OpenWalletSession.d.ts.map +1 -0
- 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 +5 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +18 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -0
- 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/allnetwork/AllNetworkGetAddressBase.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/DeviceCancel.d.ts.map +1 -1
- 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.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/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -1
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +7 -1
- package/dist/api/device/DeviceUpdateBootloader.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/device/DeviceWipe.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/FirmwareArtifactSource.d.ts +26 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareCheckpoint.d.ts +15 -0
- package/dist/api/firmware/FirmwareCheckpoint.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/FirmwareUpdateBaseMethod.d.ts +10 -1
- 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 +29 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +11 -0
- 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/batchGetPublickeys.d.ts +3 -0
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/helpers/filesystemValidation.d.ts +10 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
- 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 +29 -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/DeviceFactoryInfoGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.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/DeviceGetFirmwareUpdateStatus.d.ts +7 -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/DeviceInfoGet.d.ts +28 -0
- package/dist/api/protocol-v2/DeviceInfoGet.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/DeviceSessionOpen.d.ts +28 -0
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +16 -0
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +12 -0
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +26 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.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/FilesystemPermissionFix.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemPermissionFix.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/ProtocolInfoRequest.d.ts +6 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +42 -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 +1 -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 +3 -0
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +3 -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/constants/index.d.ts +2 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +19 -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 +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +9 -5
- 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/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +60 -16
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +16 -14
- 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/device/DeviceFeaturesState.d.ts +4 -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 +15 -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 +12 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -0
- package/dist/deviceProfile/index.d.ts +2 -0
- package/dist/deviceProfile/index.d.ts.map +1 -0
- package/dist/events/call.d.ts +7 -0
- package/dist/events/call.d.ts.map +1 -1
- package/dist/events/core.d.ts +2 -2
- package/dist/events/core.d.ts.map +1 -1
- package/dist/events/device.d.ts +11 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/iframe.d.ts +1 -0
- package/dist/events/iframe.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts +1 -0
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +26 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +1797 -451
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26905 -5611
- package/dist/inject.d.ts +3 -2
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts +2 -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 +88 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/firmware.d.ts +15 -0
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/index.d.ts +5 -0
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -0
- 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/unlockRetry.d.ts +11 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +21 -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 +4 -2
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +9 -0
- 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 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +114 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +13 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +35 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +43 -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 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +48 -2
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +35 -0
- package/dist/types/api/openWalletSession.d.ts.map +1 -0
- package/dist/types/api/protocolV2.d.ts +113 -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/api/sessionCache.d.ts +10 -0
- package/dist/types/api/sessionCache.d.ts.map +1 -0
- package/dist/types/device.d.ts +207 -5
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +3 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +33 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/capabilitieUtils.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 +17 -9
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +10 -8
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +2 -0
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +6 -5
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/findDefectiveBatchDevice.d.ts +1 -1
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +3 -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/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/dist/utils/versionUtils.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +60 -23
- package/src/api/CheckAllFirmwareRelease.ts +16 -3
- package/src/api/CheckBootloaderRelease.ts +1 -2
- package/src/api/CheckFirmwareRelease.ts +1 -2
- package/src/api/ClearSessionCache.ts +28 -0
- package/src/api/DirList.ts +33 -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 +183 -0
- package/src/api/FileWrite.ts +71 -0
- package/src/api/FirmwareUpdate.ts +15 -7
- package/src/api/FirmwareUpdateV2.ts +354 -148
- package/src/api/FirmwareUpdateV3.ts +376 -62
- package/src/api/FirmwareUpdateV4.ts +2279 -0
- package/src/api/GetDeviceState.ts +55 -0
- package/src/api/GetFeatures.ts +12 -4
- package/src/api/GetOnekeyFeatures.ts +15 -3
- package/src/api/GetPassphraseState.ts +9 -10
- package/src/api/OpenWalletSession.ts +211 -0
- package/src/api/PathInfo.ts +41 -0
- package/src/api/PromptWebDeviceAccess.ts +10 -1
- package/src/api/SearchDevices.ts +33 -3
- package/src/api/UploadPortfolio.ts +50 -0
- 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 +25 -21
- 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/DeviceCancel.ts +1 -0
- package/src/api/device/DeviceChangePin.ts +24 -0
- package/src/api/device/DeviceFullyUploadResource.ts +6 -7
- package/src/api/device/DeviceLock.ts +2 -3
- package/src/api/device/DeviceRebootToBoardloader.ts +11 -1
- package/src/api/device/DeviceRebootToBootloader.ts +11 -1
- package/src/api/device/DeviceSettings.ts +121 -0
- package/src/api/device/DeviceSupportFeatures.ts +2 -13
- package/src/api/device/DeviceUnlock.ts +9 -0
- package/src/api/device/DeviceUpdateBootloader.ts +175 -11
- package/src/api/device/DeviceUploadResource.ts +4 -5
- package/src/api/device/DeviceVerify.ts +1 -2
- package/src/api/device/DeviceWipe.ts +19 -0
- 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 +30 -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/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareCheckpoint.ts +188 -0
- package/src/api/firmware/FirmwareHostBinding.ts +108 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -15
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +13 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +729 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +403 -0
- package/src/api/firmware/bootloaderHelper.ts +3 -2
- package/src/api/firmware/getBinary.ts +1 -1
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/releaseHelper.ts +3 -3
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +148 -34
- package/src/api/helpers/batchGetPublickeys.ts +51 -6
- package/src/api/helpers/filesystemValidation.ts +112 -0
- package/src/api/helpers/protocolV2FileWrite.ts +193 -0
- package/src/api/index.ts +32 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +2 -3
- 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/DeviceFactoryInfoGet.ts +20 -0
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +61 -0
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +55 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +18 -0
- package/src/api/protocol-v2/DeviceInfoGet.ts +145 -0
- package/src/api/protocol-v2/DeviceReboot.ts +26 -0
- package/src/api/protocol-v2/DeviceSessionOpen.ts +102 -0
- package/src/api/protocol-v2/DeviceSettingsGet.ts +18 -0
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +70 -0
- package/src/api/protocol-v2/DeviceSettingsSet.ts +44 -0
- package/src/api/protocol-v2/DeviceStatusGet.ts +16 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +131 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +19 -0
- package/src/api/protocol-v2/FilesystemPermissionFix.ts +16 -0
- package/src/api/protocol-v2/Ping.ts +18 -0
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +16 -0
- package/src/api/protocol-v2/helpers.ts +203 -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 +6 -3
- package/src/api/ton/TonSignMessage.ts +6 -5
- package/src/api/ton/TonSignProof.ts +3 -0
- package/src/api/tron/TronSignMessage.ts +4 -1
- package/src/api/tron/TronSignTransaction.ts +3 -0
- package/src/api/utils.ts +7 -3
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/constants/index.ts +7 -1
- package/src/core/RequestQueue.ts +124 -4
- package/src/core/deviceEventRegistration.ts +23 -0
- package/src/core/index.ts +253 -125
- package/src/data/messages/messages-protocol-v2.json +13544 -0
- package/src/data-manager/DataManager.ts +61 -49
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +38 -12
- package/src/data-manager/connectSettings.ts +15 -0
- package/src/device/Device.ts +759 -164
- package/src/device/DeviceCommands.ts +245 -36
- package/src/device/DeviceConnector.ts +29 -4
- package/src/device/DeviceFeaturesState.ts +34 -0
- package/src/device/DevicePool.ts +69 -21
- package/src/device/DeviceStateMapper.ts +348 -0
- package/src/device/DeviceStateProjector.ts +95 -0
- package/src/device/DeviceStateStore.ts +201 -0
- package/src/device/DeviceWalletSessionStore.ts +78 -0
- package/src/device/cloneDeviceState.ts +39 -0
- package/src/device/deviceIdentity.ts +18 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +391 -0
- package/src/deviceProfile/index.ts +4 -0
- package/src/events/call.ts +6 -0
- package/src/events/core.ts +2 -0
- package/src/events/device.ts +17 -1
- package/src/events/iframe.ts +1 -0
- package/src/events/logBlockEvent.ts +30 -0
- package/src/events/ui-request.ts +32 -2
- package/src/index.ts +9 -0
- package/src/inject.ts +75 -3
- package/src/lowLevelInject.ts +8 -1
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +163 -0
- package/src/protocols/protocol-v2/firmware.ts +21 -0
- package/src/protocols/protocol-v2/index.ts +18 -0
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +61 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +210 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +76 -0
- package/src/protocols/protocol-v2/walletSession.ts +202 -0
- package/src/topLevelInject.ts +7 -1
- package/src/types/api/checkAllFirmwareRelease.ts +4 -2
- package/src/types/api/deviceSettings.ts +9 -0
- package/src/types/api/deviceUnlock.ts +1 -1
- package/src/types/api/deviceUpdateBootloader.ts +10 -1
- package/src/types/api/export.ts +25 -0
- package/src/types/api/firmwareUpdate.ts +163 -1
- package/src/types/api/firmwareUpdateCapabilities.ts +13 -0
- package/src/types/api/firmwareUpdatePlan.ts +52 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +55 -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 +10 -2
- package/src/types/api/index.ts +89 -2
- package/src/types/api/openWalletSession.ts +54 -0
- package/src/types/api/protocolV2.ts +244 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/api/sessionCache.ts +14 -0
- package/src/types/device.ts +266 -5
- package/src/types/params.ts +11 -0
- package/src/types/settings.ts +54 -29
- package/src/utils/capabilitieUtils.ts +1 -2
- package/src/utils/deviceFeaturesCompat.ts +173 -0
- package/src/utils/deviceFeaturesUtils.ts +122 -84
- package/src/utils/deviceInfoUtils.ts +38 -87
- package/src/utils/deviceSettings.ts +48 -0
- package/src/utils/deviceVersionUtils.ts +25 -62
- package/src/utils/findDefectiveBatchDevice.ts +8 -8
- package/src/utils/homescreen.ts +10 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/pro2Wallpaper.ts +109 -0
- package/src/utils/tracing.ts +3 -1
package/src/core/index.ts
CHANGED
|
@@ -2,7 +2,6 @@ import semver from 'semver';
|
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
3
|
import {
|
|
4
4
|
ERRORS,
|
|
5
|
-
ERROR_CODES_REQUIRE_DISCONNECT,
|
|
6
5
|
ERROR_CODES_REQUIRE_RELEASE,
|
|
7
6
|
HardwareError,
|
|
8
7
|
HardwareErrorCode,
|
|
@@ -18,11 +17,8 @@ import {
|
|
|
18
17
|
import {
|
|
19
18
|
LoggerNames,
|
|
20
19
|
enableLog,
|
|
21
|
-
getDeviceBLEFirmwareVersion,
|
|
22
|
-
getDeviceFirmwareVersion,
|
|
23
|
-
getFirmwareType,
|
|
24
20
|
getLogger,
|
|
25
|
-
|
|
21
|
+
isMethodVersionRangeUnsupported,
|
|
26
22
|
setLoggerPostMessage,
|
|
27
23
|
wait,
|
|
28
24
|
} from '../utils';
|
|
@@ -30,7 +26,6 @@ import {
|
|
|
30
26
|
findDefectiveBatchDevice,
|
|
31
27
|
getDefectiveDeviceInfo,
|
|
32
28
|
} from '../utils/findDefectiveBatchDevice';
|
|
33
|
-
import { supportNewPassphrase } from '../utils/deviceFeaturesUtils';
|
|
34
29
|
import {
|
|
35
30
|
cleanupSdkInstance,
|
|
36
31
|
completeRequestContext,
|
|
@@ -41,6 +36,7 @@ import {
|
|
|
41
36
|
updateRequestContext,
|
|
42
37
|
} from '../utils/tracing';
|
|
43
38
|
import { Device } from '../device/Device';
|
|
39
|
+
import { checkLiveDeviceId } from '../device/deviceIdentity';
|
|
44
40
|
import { DeviceList } from '../device/DeviceList';
|
|
45
41
|
import { DevicePool } from '../device/DevicePool';
|
|
46
42
|
import { PollingStateManager } from './PollingStateManager';
|
|
@@ -56,22 +52,25 @@ import {
|
|
|
56
52
|
createDeviceMessage,
|
|
57
53
|
createResponseMessage,
|
|
58
54
|
createUiMessage,
|
|
55
|
+
getLogBlockLabel,
|
|
59
56
|
} from '../events';
|
|
60
57
|
import TransportManager from '../data-manager/TransportManager';
|
|
61
58
|
import DeviceConnector from '../device/DeviceConnector';
|
|
62
59
|
import RequestQueue from './RequestQueue';
|
|
60
|
+
import { registerHardwareUiEventListeners } from './deviceEventRegistration';
|
|
63
61
|
import { getSynchronize } from '../utils/getSynchronize';
|
|
62
|
+
import { runMethodWithUnlockRetry } from '../protocols/protocol-v2/unlockRetry';
|
|
63
|
+
import {
|
|
64
|
+
ProtocolV2UiInteractionCoordinator,
|
|
65
|
+
isProtocolV2UiEnabled,
|
|
66
|
+
} from '../protocols/protocol-v2/uiInteraction';
|
|
64
67
|
|
|
65
|
-
import type { ConnectSettings, KnownDevice } from '../types';
|
|
68
|
+
import type { ConnectSettings, Features, KnownDevice } from '../types';
|
|
66
69
|
import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
|
|
67
70
|
import type { DeviceEvents, InitOptions, RunOptions } from '../device/Device';
|
|
68
71
|
import type { SdkTracingContext } from '../utils/tracing';
|
|
69
72
|
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
70
|
-
import type {
|
|
71
|
-
Features,
|
|
72
|
-
LowlevelTransportSharedPlugin,
|
|
73
|
-
OneKeyDeviceInfo,
|
|
74
|
-
} from '@onekeyfe/hd-transport';
|
|
73
|
+
import type { LowlevelTransportSharedPlugin, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
|
|
75
74
|
import type { BaseMethod } from '../api/BaseMethod';
|
|
76
75
|
|
|
77
76
|
const Log = getLogger(LoggerNames.Core);
|
|
@@ -100,12 +99,14 @@ function hasDeriveCardano(method: BaseMethod): boolean {
|
|
|
100
99
|
|
|
101
100
|
const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
102
101
|
initSession: method?.payload.initSession,
|
|
103
|
-
passphraseState: method?.payload.passphraseState,
|
|
102
|
+
passphraseState: method?.payload.useEmptyPassphrase ? undefined : method?.payload.passphraseState,
|
|
104
103
|
deviceId: method?.payload.deviceId,
|
|
105
104
|
deriveCardano: method && hasDeriveCardano(method),
|
|
105
|
+
connectProtocol: method?.payload.connectProtocol,
|
|
106
|
+
protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
|
|
106
107
|
});
|
|
107
108
|
|
|
108
|
-
let _core: Core;
|
|
109
|
+
let _core: Core | undefined;
|
|
109
110
|
let _deviceList: DeviceList | undefined;
|
|
110
111
|
let _connector: DeviceConnector | undefined;
|
|
111
112
|
let _uiPromises: UiPromise<UiPromiseResponse['type']>[] = []; // Waiting for ui response
|
|
@@ -149,7 +150,7 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
// find api method
|
|
152
|
-
let method
|
|
153
|
+
let method!: BaseMethod;
|
|
153
154
|
try {
|
|
154
155
|
method = findMethod(message as IFrameCallMessage);
|
|
155
156
|
method.connector = _connector;
|
|
@@ -165,6 +166,10 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
165
166
|
|
|
166
167
|
method.init();
|
|
167
168
|
} catch (error) {
|
|
169
|
+
if (method) {
|
|
170
|
+
completeMethodRequestContext(method, error);
|
|
171
|
+
method.dispose();
|
|
172
|
+
}
|
|
168
173
|
return Promise.reject(error);
|
|
169
174
|
}
|
|
170
175
|
|
|
@@ -191,34 +196,25 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
191
196
|
// );
|
|
192
197
|
// }
|
|
193
198
|
|
|
194
|
-
const { requestQueue, methodSynchronize } = context;
|
|
195
|
-
const error = await methodSynchronize(() => {
|
|
196
|
-
for (const requestId of requestQueue.getRequestTasksId()) {
|
|
197
|
-
const task = requestQueue.getTask(requestId);
|
|
198
|
-
Log.debug(
|
|
199
|
-
'pre request task: ',
|
|
200
|
-
`task?.id: ${task?.id},
|
|
201
|
-
task?.method.connectId: ${task?.method.connectId},
|
|
202
|
-
task?.method.deviceId: ${task?.method.deviceId},
|
|
203
|
-
task?.method.name: ${task?.method.name}`
|
|
204
|
-
);
|
|
205
|
-
// if (task) {
|
|
206
|
-
// return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceBusy));
|
|
207
|
-
// }
|
|
208
|
-
}
|
|
209
|
-
return null;
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
if (error) {
|
|
213
|
-
return createResponseMessage(method.responseID, false, { error });
|
|
214
|
-
}
|
|
215
|
-
|
|
216
199
|
// only the pre-warm signal (PreInitialize) forks here; normal methods fall
|
|
217
200
|
// through to onCallDevice below, so the pre-warm dedup/guards never touch them
|
|
218
201
|
if (method.isPreWarmSignal) {
|
|
219
202
|
return handlePreWarmSignal(context, message, method);
|
|
220
203
|
}
|
|
221
204
|
|
|
205
|
+
const { requestQueue, methodSynchronize } = context;
|
|
206
|
+
const admission = await methodSynchronize(
|
|
207
|
+
() => requestQueue.admitTask(method),
|
|
208
|
+
method.connectId ?? method.deviceId ?? 'unknown-device'
|
|
209
|
+
);
|
|
210
|
+
if (admission.status === 'busy') {
|
|
211
|
+
const error = ERRORS.TypedError(HardwareErrorCode.DeviceBusy);
|
|
212
|
+
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
213
|
+
completeMethodRequestContext(method, error);
|
|
214
|
+
method.dispose();
|
|
215
|
+
return createResponseMessage(method.responseID, false, { error });
|
|
216
|
+
}
|
|
217
|
+
|
|
222
218
|
return onCallDevice(context, message, method);
|
|
223
219
|
};
|
|
224
220
|
|
|
@@ -230,9 +226,16 @@ const handlePreWarmSignal = async (
|
|
|
230
226
|
message: CoreMessage,
|
|
231
227
|
method: BaseMethod
|
|
232
228
|
): Promise<any> => {
|
|
229
|
+
const createAckResponse = () => {
|
|
230
|
+
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
231
|
+
completeMethodRequestContext(method);
|
|
232
|
+
method.dispose();
|
|
233
|
+
return createResponseMessage(method.responseID, true, true);
|
|
234
|
+
};
|
|
235
|
+
|
|
233
236
|
// no connectId: can't target a device safely, skip pre-warm (ack only)
|
|
234
237
|
if (!method.connectId) {
|
|
235
|
-
return
|
|
238
|
+
return createAckResponse();
|
|
236
239
|
}
|
|
237
240
|
|
|
238
241
|
const key = method.getPreWarmKey();
|
|
@@ -245,12 +248,12 @@ const handlePreWarmSignal = async (
|
|
|
245
248
|
} catch {
|
|
246
249
|
// pre-warm is best-effort; ignore its failure for the coalesced caller
|
|
247
250
|
}
|
|
248
|
-
return
|
|
251
|
+
return createAckResponse();
|
|
249
252
|
}
|
|
250
253
|
|
|
251
254
|
const doneAt = preWarmDoneAt.get(key);
|
|
252
255
|
if (typeof doneAt === 'number' && Date.now() - doneAt <= method.preWarmTtl) {
|
|
253
|
-
return
|
|
256
|
+
return createAckResponse();
|
|
254
257
|
}
|
|
255
258
|
|
|
256
259
|
const run = onCallDevice(context, message, method);
|
|
@@ -331,7 +334,7 @@ const onCallDevice = async (
|
|
|
331
334
|
|
|
332
335
|
await waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
333
336
|
|
|
334
|
-
const task = requestQueue.createTask(method);
|
|
337
|
+
const task = requestQueue.getTask(method.responseID) ?? requestQueue.createTask(method);
|
|
335
338
|
|
|
336
339
|
// Pre-warm holds the device as a per-connectId callback task so a concurrent
|
|
337
340
|
// real call waits (before ensureConnected) instead of racing its Initialize.
|
|
@@ -358,7 +361,7 @@ const onCallDevice = async (
|
|
|
358
361
|
);
|
|
359
362
|
} catch (e) {
|
|
360
363
|
preWarmCallbackTask?.resolve();
|
|
361
|
-
|
|
364
|
+
Log.debug('ensureConnected error: ', e);
|
|
362
365
|
|
|
363
366
|
completeMethodRequestContext(method, e);
|
|
364
367
|
|
|
@@ -375,6 +378,10 @@ const onCallDevice = async (
|
|
|
375
378
|
if (method.payload?.onlyConnectBleDevice) {
|
|
376
379
|
preWarmCallbackTask?.resolve();
|
|
377
380
|
Log.debug('Call API - only connect ble device: ', device?.mainId);
|
|
381
|
+
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
382
|
+
requestQueue.releaseTask(method.responseID);
|
|
383
|
+
completeMethodRequestContext(method);
|
|
384
|
+
method.dispose();
|
|
378
385
|
return createResponseMessage(method.responseID, true, null);
|
|
379
386
|
}
|
|
380
387
|
|
|
@@ -395,18 +402,23 @@ const onCallDevice = async (
|
|
|
395
402
|
);
|
|
396
403
|
}
|
|
397
404
|
|
|
398
|
-
device
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
+
registerHardwareUiEventListeners(device, {
|
|
406
|
+
pin: onDevicePinHandler,
|
|
407
|
+
button: onDeviceButtonHandler,
|
|
408
|
+
passphrase: message.payload.useEmptyPassphrase
|
|
409
|
+
? onEmptyPassphraseHandler
|
|
410
|
+
: onDevicePassphraseHandler,
|
|
411
|
+
passphraseOnDevice: onEnterPassphraseOnDeviceHandler,
|
|
412
|
+
attachPinOnDevice: onEnterAttachPinOnDeviceHandler,
|
|
413
|
+
});
|
|
405
414
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
415
|
+
device.on(DEVICE.STATE, onDeviceStateHandler);
|
|
406
416
|
device.on(
|
|
407
417
|
DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE,
|
|
408
418
|
onSelectDeviceInBootloaderForWebDeviceHandler
|
|
409
419
|
);
|
|
420
|
+
|
|
421
|
+
const protocolV2UiCoordinator = new ProtocolV2UiInteractionCoordinator(device, postMessage);
|
|
410
422
|
device.on(
|
|
411
423
|
DEVICE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE,
|
|
412
424
|
onSelectDeviceForSwitchFirmwareWebDeviceHandler
|
|
@@ -421,13 +433,24 @@ const onCallDevice = async (
|
|
|
421
433
|
await waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
422
434
|
|
|
423
435
|
const inner = async (): Promise<void> => {
|
|
436
|
+
// The protocol is established after acquire/initialize. Reject Protocol V2-only
|
|
437
|
+
// methods on other devices through BaseMethod.requireProtocolV2.
|
|
438
|
+
if (method.requireProtocolV2 && !device.isProtocolV2()) {
|
|
439
|
+
throw createDeviceNotSupportMethodError(method.name, device.getCurrentFirmwareType());
|
|
440
|
+
}
|
|
441
|
+
|
|
424
442
|
// check firmware version
|
|
425
|
-
const versionRange =
|
|
426
|
-
device.features,
|
|
443
|
+
const versionRange = device.getCurrentMethodVersionRange(
|
|
427
444
|
type => method.getVersionRange()[type]
|
|
428
445
|
);
|
|
429
|
-
|
|
430
|
-
|
|
446
|
+
const currentFirmwareVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
447
|
+
const currentBleVersion = device.getCurrentBLEFirmwareVersionString() ?? '0.0.0';
|
|
448
|
+
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
449
|
+
let newVersionStatus: ReturnType<typeof DataManager.getFirmwareStatus> | undefined;
|
|
450
|
+
|
|
451
|
+
// Defective-batch and forced-update gates depend on V1 features/remote config.
|
|
452
|
+
// Pro2 joins after DataManager supports its profile firmwareStatus.
|
|
453
|
+
if (device.features && !device.isProtocolV2()) {
|
|
431
454
|
await DataManager.checkAndReloadData();
|
|
432
455
|
|
|
433
456
|
// 检测故障固件设备
|
|
@@ -444,12 +467,9 @@ const onCallDevice = async (
|
|
|
444
467
|
}
|
|
445
468
|
}
|
|
446
469
|
|
|
447
|
-
|
|
448
|
-
const newVersionStatus = DataManager.getFirmwareStatus(device.features, deviceFirmwareType);
|
|
470
|
+
newVersionStatus = DataManager.getFirmwareStatus(device.features, deviceFirmwareType);
|
|
449
471
|
const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
|
|
450
472
|
|
|
451
|
-
const currentFirmwareVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
452
|
-
const currentBleVersion = getDeviceBLEFirmwareVersion(device.features).join('.');
|
|
453
473
|
if (
|
|
454
474
|
(newVersionStatus === 'required' || bleVersionStatus === 'required') &&
|
|
455
475
|
method.skipForceUpdateCheck === false
|
|
@@ -475,42 +495,43 @@ const onCallDevice = async (
|
|
|
475
495
|
currentVersions
|
|
476
496
|
);
|
|
477
497
|
}
|
|
498
|
+
}
|
|
478
499
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
semver.lt(currentFirmwareVersion, versionRange.min)
|
|
483
|
-
) {
|
|
484
|
-
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
485
|
-
throw createNewFirmwareUnReleaseHardwareError({
|
|
486
|
-
currentVersion: currentFirmwareVersion,
|
|
487
|
-
requireVersion: versionRange.min,
|
|
488
|
-
methodName: method.name,
|
|
489
|
-
firmwareType: getFirmwareType(device.features),
|
|
490
|
-
});
|
|
491
|
-
}
|
|
500
|
+
if (isMethodVersionRangeUnsupported(versionRange)) {
|
|
501
|
+
throw createDeviceNotSupportMethodError(method.name, deviceFirmwareType);
|
|
502
|
+
}
|
|
492
503
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
if (
|
|
503
|
-
versionRange.max &&
|
|
504
|
-
semver.valid(versionRange.max) &&
|
|
505
|
-
semver.gte(currentFirmwareVersion, versionRange.max)
|
|
506
|
-
) {
|
|
507
|
-
return Promise.reject(
|
|
508
|
-
createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name)
|
|
509
|
-
);
|
|
504
|
+
if (versionRange) {
|
|
505
|
+
if (semver.valid(versionRange.min) && semver.lt(currentFirmwareVersion, versionRange.min)) {
|
|
506
|
+
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
507
|
+
throw createNewFirmwareUnReleaseHardwareError({
|
|
508
|
+
currentVersion: currentFirmwareVersion,
|
|
509
|
+
requireVersion: versionRange.min,
|
|
510
|
+
methodName: method.name,
|
|
511
|
+
firmwareType: deviceFirmwareType,
|
|
512
|
+
});
|
|
510
513
|
}
|
|
511
|
-
|
|
512
|
-
|
|
514
|
+
|
|
515
|
+
return Promise.reject(
|
|
516
|
+
createNeedUpgradeFirmwareHardwareError({
|
|
517
|
+
currentVersion: currentFirmwareVersion,
|
|
518
|
+
requireVersion: versionRange.min,
|
|
519
|
+
methodName: method.name,
|
|
520
|
+
firmwareType: deviceFirmwareType,
|
|
521
|
+
})
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
if (
|
|
525
|
+
versionRange.max &&
|
|
526
|
+
semver.valid(versionRange.max) &&
|
|
527
|
+
semver.gte(currentFirmwareVersion, versionRange.max)
|
|
528
|
+
) {
|
|
529
|
+
return Promise.reject(
|
|
530
|
+
createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name)
|
|
531
|
+
);
|
|
513
532
|
}
|
|
533
|
+
} else if (method.strictCheckDeviceSupport) {
|
|
534
|
+
throw createDeviceNotSupportMethodError(method.name, deviceFirmwareType);
|
|
514
535
|
}
|
|
515
536
|
|
|
516
537
|
// check call method mode
|
|
@@ -531,7 +552,7 @@ const onCallDevice = async (
|
|
|
531
552
|
}
|
|
532
553
|
|
|
533
554
|
if (method.deviceId && method.checkDeviceId) {
|
|
534
|
-
const isSameDeviceID = device
|
|
555
|
+
const isSameDeviceID = await checkLiveDeviceId(device, method.deviceId);
|
|
535
556
|
if (!isSameDeviceID) {
|
|
536
557
|
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError));
|
|
537
558
|
}
|
|
@@ -548,16 +569,16 @@ const onCallDevice = async (
|
|
|
548
569
|
method.checkDeviceSupportFeature();
|
|
549
570
|
|
|
550
571
|
// reconfigure messages
|
|
551
|
-
if (_deviceList) {
|
|
572
|
+
if (_deviceList && device.features && !device.isProtocolV2()) {
|
|
552
573
|
await TransportManager.reconfigure(device.features);
|
|
553
574
|
}
|
|
554
575
|
|
|
555
576
|
// Check to see if it is safe to use Passphrase
|
|
556
577
|
checkPassphraseEnableState(method, device.features);
|
|
557
578
|
|
|
558
|
-
if (
|
|
579
|
+
if (shouldCheckPassphraseState(method, device)) {
|
|
559
580
|
// check version
|
|
560
|
-
const support = supportNewPassphrase(
|
|
581
|
+
const support = device.supportNewPassphrase();
|
|
561
582
|
if (!support.support) {
|
|
562
583
|
return Promise.reject(
|
|
563
584
|
ERRORS.TypedError(
|
|
@@ -608,7 +629,11 @@ const onCallDevice = async (
|
|
|
608
629
|
method.device?.commands?.checkDisposed();
|
|
609
630
|
|
|
610
631
|
try {
|
|
611
|
-
const response: object = await
|
|
632
|
+
const response: object = await runMethodWithUnlockRetry(
|
|
633
|
+
method,
|
|
634
|
+
device,
|
|
635
|
+
protocolV2UiCoordinator
|
|
636
|
+
);
|
|
612
637
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
613
638
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
614
639
|
completeMethodRequestContext(method);
|
|
@@ -625,6 +650,8 @@ const onCallDevice = async (
|
|
|
625
650
|
) {
|
|
626
651
|
throw error;
|
|
627
652
|
}
|
|
653
|
+
} finally {
|
|
654
|
+
protocolV2UiCoordinator.close();
|
|
628
655
|
}
|
|
629
656
|
};
|
|
630
657
|
Log.debug('Call API - Device Run: ', device.mainId);
|
|
@@ -634,8 +661,9 @@ const onCallDevice = async (
|
|
|
634
661
|
skipInitialize: canSkipInitialize(method, device),
|
|
635
662
|
...parseInitOptions(method),
|
|
636
663
|
};
|
|
637
|
-
const
|
|
638
|
-
task.callPromise = createDeferred<any>(
|
|
664
|
+
const deviceRunPromise = device.run(inner, runOptions);
|
|
665
|
+
task.callPromise = createDeferred<any>();
|
|
666
|
+
deviceRunPromise.catch(error => task.callPromise?.reject(error));
|
|
639
667
|
|
|
640
668
|
try {
|
|
641
669
|
return await task.callPromise.promise;
|
|
@@ -643,6 +671,8 @@ const onCallDevice = async (
|
|
|
643
671
|
Log.debug('Device Run Error: ', e);
|
|
644
672
|
completeMethodRequestContext(method, e);
|
|
645
673
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
674
|
+
} finally {
|
|
675
|
+
await deviceRunPromise.catch(() => undefined);
|
|
646
676
|
}
|
|
647
677
|
} catch (error) {
|
|
648
678
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
@@ -678,7 +708,9 @@ const onCallDevice = async (
|
|
|
678
708
|
|
|
679
709
|
requestQueue.releaseTask(method.responseID);
|
|
680
710
|
|
|
681
|
-
|
|
711
|
+
if (isProtocolV2UiEnabled(method)) {
|
|
712
|
+
closePopup();
|
|
713
|
+
}
|
|
682
714
|
|
|
683
715
|
cleanup();
|
|
684
716
|
|
|
@@ -724,17 +756,27 @@ function initDevice(method: BaseMethod) {
|
|
|
724
756
|
let device: Device | typeof undefined;
|
|
725
757
|
const allDevices = _deviceList.allDevices();
|
|
726
758
|
|
|
727
|
-
if (method.payload?.detectBootloaderDevice && allDevices.some(d => d.
|
|
759
|
+
if (method.payload?.detectBootloaderDevice && allDevices.some(d => d.isBootloader())) {
|
|
728
760
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceDetectInBootloaderMode);
|
|
729
761
|
}
|
|
730
762
|
|
|
731
763
|
if (method.connectId) {
|
|
732
764
|
device = _deviceList.getDevice(method.connectId);
|
|
765
|
+
if (!device && method.name === 'firmwareUpdateV4' && allDevices.length === 1) {
|
|
766
|
+
const [singleDevice] = allDevices;
|
|
767
|
+
if (singleDevice.isBootloader()) {
|
|
768
|
+
Log.debug(
|
|
769
|
+
'firmwareUpdateV4 uses the only bootloader device when connectId changed after reboot'
|
|
770
|
+
);
|
|
771
|
+
device = singleDevice;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
733
774
|
} else if (allDevices.length === 1) {
|
|
734
775
|
[device] = allDevices;
|
|
735
776
|
} else if (allDevices.length > 1) {
|
|
736
777
|
throw ERRORS.TypedError(
|
|
737
778
|
[
|
|
779
|
+
'firmwareUpdateV4',
|
|
738
780
|
'firmwareUpdateV3',
|
|
739
781
|
'firmwareUpdateV2',
|
|
740
782
|
'checkFirmwareRelease',
|
|
@@ -797,8 +839,8 @@ function canSkipInitialize(method: BaseMethod, device: Device): boolean {
|
|
|
797
839
|
if (!method.connectId) reasons.push('connectId.missing');
|
|
798
840
|
// passphrase state must match the pre-initialize
|
|
799
841
|
if (!device.isPreInitializeMetaMatch(method.payload)) reasons.push('meta.mismatch');
|
|
800
|
-
// device must have been initialized before
|
|
801
|
-
if (
|
|
842
|
+
// device must have been initialized before.
|
|
843
|
+
if (device.isUnacquired()) reasons.push('deviceInfo.missing');
|
|
802
844
|
// within pre-initialize TTL
|
|
803
845
|
if (!device.isPreInitializedValid(PRE_INITIALIZE_TTL_MS)) reasons.push('ttl.expired');
|
|
804
846
|
|
|
@@ -814,13 +856,23 @@ function canSkipInitialize(method: BaseMethod, device: Device): boolean {
|
|
|
814
856
|
return true;
|
|
815
857
|
}
|
|
816
858
|
|
|
859
|
+
function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown) {
|
|
860
|
+
const message = error instanceof Error ? error.message : String(error ?? '');
|
|
861
|
+
return (
|
|
862
|
+
method.payload.connectProtocol === 'V2' &&
|
|
863
|
+
message.includes('Device protocol mismatch') &&
|
|
864
|
+
message.includes('expected V2') &&
|
|
865
|
+
message.includes('did not respond to expected protocol')
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
|
|
817
869
|
/**
|
|
818
870
|
* If the Bluetooth connection times out, retry up to 6 times
|
|
819
871
|
* @param retryCount - Current retry count (default 0)
|
|
820
872
|
*/
|
|
821
873
|
async function connectDeviceForBle(method: BaseMethod, device: Device, retryCount = 0) {
|
|
822
874
|
try {
|
|
823
|
-
await device.acquire();
|
|
875
|
+
await device.acquire(method.payload.connectProtocol);
|
|
824
876
|
if (method.payload?.onlyConnectBleDevice) {
|
|
825
877
|
return;
|
|
826
878
|
}
|
|
@@ -833,17 +885,12 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
833
885
|
});
|
|
834
886
|
}
|
|
835
887
|
} catch (err) {
|
|
836
|
-
// Device.run()'s REQUIRE_DISCONNECT handling never sees acquire/initialize
|
|
837
|
-
// failures — drop the wedged link here so retries cold-connect instead of
|
|
838
|
-
// reusing it forever.
|
|
839
888
|
if (
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
889
|
+
(err.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
890
|
+
err.errorCode === HardwareErrorCode.BleConnectedError ||
|
|
891
|
+
isRetryableBleProtocolV2ProbeError(method, err)) &&
|
|
892
|
+
retryCount < 6
|
|
843
893
|
) {
|
|
844
|
-
await device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
845
|
-
}
|
|
846
|
-
if (err.errorCode === HardwareErrorCode.BleTimeoutError && retryCount < 6) {
|
|
847
894
|
const nextRetry = retryCount + 1;
|
|
848
895
|
Log.debug(`Bluetooth connect timeout and will retry, retry count: ${nextRetry}`);
|
|
849
896
|
await wait(3000);
|
|
@@ -1102,7 +1149,11 @@ export const cancel = (context: CoreContext, connectId?: string) => {
|
|
|
1102
1149
|
const checkPassphraseEnableState = (method: BaseMethod, features?: Features) => {
|
|
1103
1150
|
if (!method.useDevicePassphraseState) return;
|
|
1104
1151
|
|
|
1105
|
-
|
|
1152
|
+
const passphraseProtection = method.device
|
|
1153
|
+
? method.device.getCurrentPassphraseProtection()
|
|
1154
|
+
: features?.passphraseProtection;
|
|
1155
|
+
|
|
1156
|
+
if (passphraseProtection === true) {
|
|
1106
1157
|
const hasNoPassphraseState =
|
|
1107
1158
|
method.payload.passphraseState == null || method.payload.passphraseState === '';
|
|
1108
1159
|
const shouldRequirePassphrase =
|
|
@@ -1114,12 +1165,18 @@ const checkPassphraseEnableState = (method: BaseMethod, features?: Features) =>
|
|
|
1114
1165
|
}
|
|
1115
1166
|
}
|
|
1116
1167
|
|
|
1117
|
-
if (
|
|
1168
|
+
if (passphraseProtection === false && method.payload.passphraseState) {
|
|
1118
1169
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
1119
1170
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
1120
1171
|
}
|
|
1121
1172
|
};
|
|
1122
1173
|
|
|
1174
|
+
const shouldCheckPassphraseState = (method: BaseMethod, device: Device) => {
|
|
1175
|
+
if (!method.useDevicePassphraseState) return false;
|
|
1176
|
+
|
|
1177
|
+
return device.hasUsePassphrase();
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1123
1180
|
const cleanup = () => {
|
|
1124
1181
|
_uiPromises = [];
|
|
1125
1182
|
Log.debug('Cleanup...');
|
|
@@ -1139,16 +1196,16 @@ const closePopup = () => {
|
|
|
1139
1196
|
};
|
|
1140
1197
|
|
|
1141
1198
|
const onDeviceConnectHandler = (device: Device) => {
|
|
1142
|
-
const
|
|
1143
|
-
|
|
1144
|
-
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject
|
|
1199
|
+
const deviceObject = device.toMessageObject();
|
|
1200
|
+
if (!deviceObject) return;
|
|
1201
|
+
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject }));
|
|
1145
1202
|
};
|
|
1146
1203
|
|
|
1147
1204
|
const onDeviceDisconnectHandler = (device: Device) => {
|
|
1148
1205
|
device.clearPreInitialized();
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
-
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject
|
|
1206
|
+
const deviceObject = device.toMessageObject();
|
|
1207
|
+
if (!deviceObject) return;
|
|
1208
|
+
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|
|
1152
1209
|
};
|
|
1153
1210
|
|
|
1154
1211
|
const onDevicePinHandler = async (...[device, type, callback]: DeviceEvents['pin']) => {
|
|
@@ -1189,6 +1246,10 @@ const onDeviceFeaturesHandler = (...[_, features]: [...DeviceEvents['features']]
|
|
|
1189
1246
|
postMessage(createDeviceMessage(DEVICE.FEATURES, { ...features }));
|
|
1190
1247
|
};
|
|
1191
1248
|
|
|
1249
|
+
const onDeviceStateHandler = (...[_, stateEvent]: [...DeviceEvents['state']]) => {
|
|
1250
|
+
postMessage(createDeviceMessage(DEVICE.STATE, stateEvent));
|
|
1251
|
+
};
|
|
1252
|
+
|
|
1192
1253
|
const onDevicePassphraseHandler = async (
|
|
1193
1254
|
...[device, requestPayload, callback]: DeviceEvents['passphrase']
|
|
1194
1255
|
) => {
|
|
@@ -1199,6 +1260,9 @@ const onDevicePassphraseHandler = async (
|
|
|
1199
1260
|
device: device.toMessageObject() as KnownDevice,
|
|
1200
1261
|
passphraseState: device.passphraseState,
|
|
1201
1262
|
existsAttachPinUser: requestPayload.existsAttachPinUser,
|
|
1263
|
+
source: requestPayload.source,
|
|
1264
|
+
reason: requestPayload.reason,
|
|
1265
|
+
expectedPassphraseState: requestPayload.expectedPassphraseState,
|
|
1202
1266
|
})
|
|
1203
1267
|
);
|
|
1204
1268
|
// wait for passphrase
|
|
@@ -1220,12 +1284,27 @@ const onEmptyPassphraseHandler = (...[_, , callback]: DeviceEvents['passphrase']
|
|
|
1220
1284
|
};
|
|
1221
1285
|
|
|
1222
1286
|
const onEnterPassphraseOnDeviceHandler = (
|
|
1223
|
-
...[device]: [...DeviceEvents['passphrase_on_device']]
|
|
1287
|
+
...[device, requestPayload]: [...DeviceEvents['passphrase_on_device']]
|
|
1224
1288
|
) => {
|
|
1225
1289
|
postMessage(
|
|
1226
1290
|
createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
1227
1291
|
device: device.toMessageObject() as KnownDevice,
|
|
1228
1292
|
passphraseState: device.passphraseState,
|
|
1293
|
+
source: requestPayload?.source,
|
|
1294
|
+
reason: requestPayload?.reason,
|
|
1295
|
+
})
|
|
1296
|
+
);
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
const onEnterAttachPinOnDeviceHandler = (
|
|
1300
|
+
...[device, requestPayload]: [...DeviceEvents['attach_pin_on_device']]
|
|
1301
|
+
) => {
|
|
1302
|
+
postMessage(
|
|
1303
|
+
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1304
|
+
device: device.toMessageObject() as KnownDevice,
|
|
1305
|
+
type: 'ButtonRequest_AttachPin',
|
|
1306
|
+
source: requestPayload?.source,
|
|
1307
|
+
reason: requestPayload?.reason,
|
|
1229
1308
|
})
|
|
1230
1309
|
);
|
|
1231
1310
|
};
|
|
@@ -1296,6 +1375,8 @@ export default class Core extends EventEmitter {
|
|
|
1296
1375
|
|
|
1297
1376
|
private requestQueue = new RequestQueue();
|
|
1298
1377
|
|
|
1378
|
+
private disposePromise?: Promise<void>;
|
|
1379
|
+
|
|
1299
1380
|
// background task
|
|
1300
1381
|
private prePendingCallPromise: Promise<void> | undefined;
|
|
1301
1382
|
|
|
@@ -1308,6 +1389,10 @@ export default class Core extends EventEmitter {
|
|
|
1308
1389
|
Log.debug(`[Core] Created SDK instance: ${this.sdkInstanceId}`);
|
|
1309
1390
|
}
|
|
1310
1391
|
|
|
1392
|
+
cancelOperation(operationId: string) {
|
|
1393
|
+
this.requestQueue.abortOperation(operationId);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1311
1396
|
private getCoreContext() {
|
|
1312
1397
|
return {
|
|
1313
1398
|
sdkInstanceId: this.sdkInstanceId,
|
|
@@ -1354,10 +1439,17 @@ export default class Core extends EventEmitter {
|
|
|
1354
1439
|
}
|
|
1355
1440
|
|
|
1356
1441
|
case IFRAME.CALL: {
|
|
1357
|
-
|
|
1442
|
+
const logBlockLabel = getLogBlockLabel(message);
|
|
1443
|
+
Log.log(
|
|
1444
|
+
`[${Date.now()}][CALL_API]`,
|
|
1445
|
+
logBlockLabel ? { method: logBlockLabel, payload: '[REDACTED]' } : message
|
|
1446
|
+
);
|
|
1358
1447
|
const response = await callAPI(this.getCoreContext(), message);
|
|
1359
1448
|
const { success, payload } = response;
|
|
1360
|
-
Log.log(
|
|
1449
|
+
Log.log(
|
|
1450
|
+
`[${Date.now()}][CALL_API_RESPONSE]`,
|
|
1451
|
+
logBlockLabel ? { method: logBlockLabel, payload: '[REDACTED]' } : response
|
|
1452
|
+
);
|
|
1361
1453
|
if (success) {
|
|
1362
1454
|
return response;
|
|
1363
1455
|
}
|
|
@@ -1376,6 +1468,10 @@ export default class Core extends EventEmitter {
|
|
|
1376
1468
|
cancel(this.getCoreContext(), message.payload.connectId);
|
|
1377
1469
|
break;
|
|
1378
1470
|
}
|
|
1471
|
+
case IFRAME.CANCEL_OPERATION: {
|
|
1472
|
+
this.cancelOperation(message.payload.operationId);
|
|
1473
|
+
break;
|
|
1474
|
+
}
|
|
1379
1475
|
case IFRAME.CALLBACK: {
|
|
1380
1476
|
Log.log('callback message: ', message);
|
|
1381
1477
|
postMessage(message);
|
|
@@ -1387,20 +1483,52 @@ export default class Core extends EventEmitter {
|
|
|
1387
1483
|
return Promise.resolve(message);
|
|
1388
1484
|
}
|
|
1389
1485
|
|
|
1390
|
-
dispose() {
|
|
1486
|
+
dispose(): Promise<void> {
|
|
1487
|
+
if (!this.disposePromise) {
|
|
1488
|
+
this.disposePromise = this.disposeResources();
|
|
1489
|
+
}
|
|
1490
|
+
return this.disposePromise;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
private async disposeResources(): Promise<void> {
|
|
1494
|
+
Log.debug(`[Core] Disposing SDK instance: ${this.sdkInstanceId}`);
|
|
1495
|
+
pollingManager.stopAll();
|
|
1496
|
+
this.requestQueue.abortAllRequests();
|
|
1497
|
+
cleanup();
|
|
1498
|
+
|
|
1499
|
+
_connector?.stop();
|
|
1500
|
+
let transportCleanup: Promise<void>;
|
|
1501
|
+
try {
|
|
1502
|
+
transportCleanup = Promise.resolve(TransportManager.getTransport()?.stop?.()).catch(error => {
|
|
1503
|
+
Log.warn('[Core] Transport cleanup failed:', error);
|
|
1504
|
+
});
|
|
1505
|
+
} catch (error) {
|
|
1506
|
+
Log.warn('[Core] Transport cleanup failed:', error);
|
|
1507
|
+
transportCleanup = Promise.resolve();
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
// Preserve synchronous dispose semantics for in-memory state and listeners.
|
|
1391
1511
|
_deviceList = undefined;
|
|
1392
1512
|
_connector = undefined;
|
|
1513
|
+
DevicePool.resetState();
|
|
1393
1514
|
deviceCacheMap.clear();
|
|
1394
1515
|
preWarmInflight.clear();
|
|
1395
1516
|
preWarmDoneAt.clear();
|
|
1396
|
-
|
|
1517
|
+
preConnectCache = { passphraseState: undefined };
|
|
1518
|
+
this.prePendingCallPromise = undefined;
|
|
1519
|
+
this.removeAllListeners();
|
|
1397
1520
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
1521
|
+
if (_core === this) _core = undefined;
|
|
1522
|
+
|
|
1523
|
+
// Transports, especially Node USB, may release native handles asynchronously.
|
|
1524
|
+
await transportCleanup;
|
|
1398
1525
|
}
|
|
1399
1526
|
}
|
|
1400
1527
|
|
|
1401
1528
|
export const initCore = () => {
|
|
1402
|
-
|
|
1403
|
-
|
|
1529
|
+
const core = new Core();
|
|
1530
|
+
_core = core;
|
|
1531
|
+
return core;
|
|
1404
1532
|
};
|
|
1405
1533
|
|
|
1406
1534
|
export const initConnector = () => {
|