@onekeyfe/hd-core 1.1.34-alpha.3 → 1.1.34-alpha.4
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__/DeviceCommands.test.ts +0 -217
- package/__tests__/evmLedgerLegacySafety.test.ts +4 -15
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +31 -48
- package/__tests__/preInitialize.test.ts +0 -33
- package/dist/api/BaseMethod.d.ts +0 -12
- 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/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +3 -14
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +3 -10
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- 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/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +1 -5
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumGetAddress.d.ts +6 -2
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts +5 -2
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts +8 -5
- 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 +9 -2
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts +9 -2
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts +8 -2
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts +8 -2
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +11 -1
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +11 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +15 -1
- 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 +11 -1
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +11 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +11 -2
- 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 +2 -1
- 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 +1 -7
- 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 +8 -2
- 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/FirmwareUpdateBaseMethod.d.ts +1 -10
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +0 -11
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +0 -2
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +1 -9
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts +0 -3
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -29
- 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 +0 -4
- package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts +8 -2
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts +8 -2
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts +9 -2
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts +12 -9
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts +8 -2
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +9 -2
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +0 -3
- package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
- package/dist/api/polkadot/networks.d.ts +0 -3
- package/dist/api/polkadot/networks.d.ts.map +1 -1
- package/dist/api/scdo/ScdoGetAddress.d.ts +6 -2
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts +5 -2
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts +5 -2
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts +0 -1
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +0 -3
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +0 -3
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +0 -6
- package/dist/api/solana/SolSignTransaction.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 +0 -3
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +0 -3
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +0 -3
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +2 -5
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +0 -3
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +0 -1
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +0 -3
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +0 -3
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +0 -3
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +0 -3
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/utils.d.ts +1 -2
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -2
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +1 -19
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +5 -9
- 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 +4 -5
- 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 +16 -60
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +14 -16
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +1 -2
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts +2 -4
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/events/call.d.ts +0 -7
- 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 +2 -11
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/iframe.d.ts +0 -1
- package/dist/events/iframe.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts +0 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -26
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +451 -1797
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5556 -26855
- package/dist/inject.d.ts +2 -3
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts +1 -2
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +2 -4
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +0 -9
- 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 +1 -6
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +1 -4
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +1 -114
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- 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 +1 -2
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +2 -48
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/searchDevices.d.ts +2 -2
- package/dist/types/api/searchDevices.d.ts.map +1 -1
- package/dist/types/device.d.ts +5 -207
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +0 -3
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +0 -33
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/capabilitieUtils.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +9 -17
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +8 -10
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +0 -2
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +5 -6
- 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 +1 -3
- 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/tracing.d.ts.map +1 -1
- package/dist/utils/versionUtils.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +23 -60
- package/src/api/CheckAllFirmwareRelease.ts +3 -16
- package/src/api/CheckBootloaderRelease.ts +2 -1
- package/src/api/CheckFirmwareRelease.ts +2 -1
- package/src/api/FirmwareUpdate.ts +7 -15
- package/src/api/FirmwareUpdateV2.ts +148 -354
- package/src/api/FirmwareUpdateV3.ts +62 -376
- package/src/api/GetFeatures.ts +4 -12
- package/src/api/GetOnekeyFeatures.ts +3 -15
- package/src/api/GetPassphraseState.ts +10 -9
- package/src/api/PromptWebDeviceAccess.ts +1 -10
- package/src/api/SearchDevices.ts +3 -33
- package/src/api/alephium/AlephiumGetAddress.ts +2 -6
- package/src/api/alephium/AlephiumSignMessage.ts +1 -6
- package/src/api/alephium/AlephiumSignTransaction.ts +4 -15
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +21 -25
- package/src/api/aptos/AptosGetAddress.ts +3 -2
- package/src/api/benfen/BenfenGetAddress.ts +7 -11
- package/src/api/benfen/BenfenGetPublicKey.ts +2 -6
- package/src/api/benfen/BenfenSignMessage.ts +1 -6
- package/src/api/benfen/BenfenSignTransaction.ts +1 -6
- package/src/api/btc/BTCGetPublicKey.ts +2 -3
- package/src/api/btc/BTCSignPsbt.ts +2 -1
- package/src/api/btc/helpers/versionLimit.ts +1 -7
- package/src/api/cardano/CardanoSignTransaction.ts +4 -2
- package/src/api/conflux/ConfluxSignTransaction.ts +2 -5
- package/src/api/device/DeviceCancel.ts +0 -1
- package/src/api/device/DeviceChangePin.ts +0 -24
- package/src/api/device/DeviceFullyUploadResource.ts +7 -6
- package/src/api/device/DeviceLock.ts +3 -2
- package/src/api/device/DeviceRebootToBoardloader.ts +1 -11
- package/src/api/device/DeviceRebootToBootloader.ts +1 -11
- package/src/api/device/DeviceSettings.ts +0 -121
- package/src/api/device/DeviceSupportFeatures.ts +13 -2
- package/src/api/device/DeviceUnlock.ts +0 -9
- package/src/api/device/DeviceUpdateBootloader.ts +11 -175
- package/src/api/device/DeviceUploadResource.ts +5 -4
- package/src/api/device/DeviceVerify.ts +2 -1
- package/src/api/device/DeviceWipe.ts +0 -19
- package/src/api/dynex/DnxGetAddress.ts +0 -6
- package/src/api/dynex/DnxSignTransaction.ts +0 -6
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +4 -3
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -14
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +18 -30
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/evm/latest/signTypedHash.ts +4 -2
- package/src/api/evm/legacyV1/getAddress.ts +3 -5
- package/src/api/evm/legacyV1/getPublicKey.ts +3 -5
- package/src/api/evm/legacyV1/signMessage.ts +3 -5
- package/src/api/evm/legacyV1/signTypedData.ts +8 -9
- package/src/api/evm/legacyV1/signTypedHash.ts +7 -7
- package/src/api/evm/legacyV1/verifyMessage.ts +3 -5
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +15 -83
- package/src/api/firmware/bootloaderHelper.ts +2 -3
- package/src/api/firmware/getBinary.ts +1 -1
- package/src/api/firmware/releaseHelper.ts +3 -3
- package/src/api/firmware/updateBootloader.ts +4 -19
- package/src/api/firmware/uploadFirmware.ts +34 -148
- package/src/api/helpers/batchGetPublickeys.ts +6 -51
- package/src/api/index.ts +0 -32
- package/src/api/kaspa/KaspaSignTransaction.ts +3 -2
- package/src/api/lightning/LnurlAuth.ts +0 -4
- package/src/api/neo/NeoGetAddress.ts +1 -6
- package/src/api/neo/NeoSignTransaction.ts +1 -6
- package/src/api/nervos/NervosGetAddress.ts +2 -6
- package/src/api/nervos/NervosSignTransaction.ts +4 -14
- package/src/api/nexa/NexaGetAddress.ts +2 -6
- package/src/api/nexa/NexaSignTransaction.ts +12 -11
- package/src/api/polkadot/networks.ts +0 -9
- package/src/api/scdo/ScdoGetAddress.ts +2 -6
- package/src/api/scdo/ScdoSignMessage.ts +1 -6
- package/src/api/scdo/ScdoSignTransaction.ts +2 -6
- package/src/api/solana/SolGetAddress.ts +0 -4
- package/src/api/solana/SolSignMessage.ts +0 -3
- package/src/api/solana/SolSignOffchainMessage.ts +0 -3
- package/src/api/solana/SolSignTransaction.ts +0 -6
- package/src/api/stellar/StellarGetAddress.ts +1 -10
- package/src/api/stellar/StellarSignTransaction.ts +1 -14
- package/src/api/sui/SuiGetAddress.ts +3 -5
- package/src/api/sui/SuiGetPublicKey.ts +0 -3
- package/src/api/sui/SuiSignMessage.ts +0 -3
- package/src/api/sui/SuiSignTransaction.ts +12 -14
- package/src/api/ton/TonGetAddress.ts +0 -3
- package/src/api/ton/TonSignData.ts +3 -6
- package/src/api/ton/TonSignMessage.ts +5 -6
- package/src/api/ton/TonSignProof.ts +0 -3
- package/src/api/tron/TronSignMessage.ts +1 -4
- package/src/api/tron/TronSignTransaction.ts +0 -3
- package/src/api/utils.ts +3 -7
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/constants/index.ts +1 -7
- package/src/core/RequestQueue.ts +4 -124
- package/src/core/index.ts +116 -255
- package/src/data-manager/DataManager.ts +49 -61
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +12 -38
- package/src/data-manager/connectSettings.ts +0 -15
- package/src/device/Device.ts +164 -759
- package/src/device/DeviceCommands.ts +36 -245
- package/src/device/DeviceConnector.ts +4 -29
- package/src/device/DevicePool.ts +21 -69
- package/src/events/call.ts +0 -6
- package/src/events/core.ts +0 -2
- package/src/events/device.ts +1 -17
- package/src/events/iframe.ts +0 -1
- package/src/events/logBlockEvent.ts +0 -30
- package/src/events/ui-request.ts +2 -32
- package/src/index.ts +0 -9
- package/src/inject.ts +3 -75
- package/src/lowLevelInject.ts +1 -8
- package/src/topLevelInject.ts +1 -7
- package/src/types/api/checkAllFirmwareRelease.ts +2 -4
- package/src/types/api/deviceSettings.ts +0 -9
- package/src/types/api/deviceUnlock.ts +1 -1
- package/src/types/api/deviceUpdateBootloader.ts +1 -10
- package/src/types/api/export.ts +0 -25
- package/src/types/api/firmwareUpdate.ts +1 -163
- package/src/types/api/getFeatures.ts +0 -3
- package/src/types/api/getOnekeyFeatures.ts +0 -3
- package/src/types/api/getPassphraseState.ts +2 -10
- package/src/types/api/index.ts +2 -89
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/device.ts +5 -266
- package/src/types/params.ts +0 -11
- package/src/types/settings.ts +29 -54
- package/src/utils/capabilitieUtils.ts +2 -1
- package/src/utils/deviceFeaturesUtils.ts +84 -122
- package/src/utils/deviceInfoUtils.ts +87 -38
- package/src/utils/deviceSettings.ts +0 -48
- package/src/utils/deviceVersionUtils.ts +62 -25
- package/src/utils/findDefectiveBatchDevice.ts +8 -8
- package/src/utils/homescreen.ts +0 -10
- package/src/utils/index.ts +0 -4
- package/src/utils/tracing.ts +1 -3
- package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +0 -75
- package/__tests__/RequestQueue.test.ts +0 -140
- package/__tests__/UploadPortfolio.test.ts +0 -46
- package/__tests__/connectSettings.test.ts +0 -61
- package/__tests__/device-lifecycle-events.test.ts +0 -117
- package/__tests__/device-pool-state.test.ts +0 -132
- package/__tests__/device-settings.test.ts +0 -286
- package/__tests__/device-state-mapper.test.ts +0 -229
- package/__tests__/device-utils.test.ts +0 -106
- package/__tests__/device-wallet-session-store.test.ts +0 -191
- package/__tests__/filesystemValidation.test.ts +0 -53
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +0 -119
- package/__tests__/firmware-update/firmware-checkpoint.test.ts +0 -105
- package/__tests__/firmware-update/firmware-host-binding.test.ts +0 -73
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +0 -17
- package/__tests__/firmware-update/firmware-update-plan.test.ts +0 -358
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +0 -200
- package/__tests__/firmware-update/firmware-update-recovery.test.ts +0 -81
- package/__tests__/firmware-update/firmware-upload-source.test.ts +0 -70
- package/__tests__/get-device-state.test.ts +0 -403
- package/__tests__/logBlockEvent.test.ts +0 -61
- package/__tests__/logger.test.ts +0 -34
- package/__tests__/open-wallet-session.test.ts +0 -565
- package/__tests__/pro2Wallpaper.test.ts +0 -39
- package/__tests__/protocol-v2-bootloader-mode.test.ts +0 -37
- package/__tests__/protocol-v2-firmware-targets.test.ts +0 -19
- package/__tests__/protocol-v2.test.ts +0 -6008
- package/__tests__/protocolV2FileWrite.test.ts +0 -67
- package/__tests__/public-pro2-api-boundary.test.ts +0 -66
- package/__tests__/search-devices.test.ts +0 -136
- package/dist/api/ClearSessionCache.d.ts +0 -9
- package/dist/api/ClearSessionCache.d.ts.map +0 -1
- package/dist/api/DirList.d.ts +0 -10
- package/dist/api/DirList.d.ts.map +0 -1
- package/dist/api/DirMake.d.ts +0 -9
- package/dist/api/DirMake.d.ts.map +0 -1
- package/dist/api/DirRemove.d.ts +0 -9
- package/dist/api/DirRemove.d.ts.map +0 -1
- package/dist/api/FileDelete.d.ts +0 -9
- package/dist/api/FileDelete.d.ts.map +0 -1
- package/dist/api/FileRead.d.ts +0 -19
- package/dist/api/FileRead.d.ts.map +0 -1
- package/dist/api/FileWrite.d.ts +0 -25
- package/dist/api/FileWrite.d.ts.map +0 -1
- package/dist/api/FirmwareUpdateV4.d.ts +0 -75
- package/dist/api/FirmwareUpdateV4.d.ts.map +0 -1
- package/dist/api/GetDeviceState.d.ts +0 -7
- package/dist/api/GetDeviceState.d.ts.map +0 -1
- package/dist/api/OpenWalletSession.d.ts +0 -14
- package/dist/api/OpenWalletSession.d.ts.map +0 -1
- package/dist/api/PathInfo.d.ts +0 -10
- package/dist/api/PathInfo.d.ts.map +0 -1
- package/dist/api/UploadPortfolio.d.ts +0 -18
- package/dist/api/UploadPortfolio.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +0 -26
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareCheckpoint.d.ts +0 -15
- package/dist/api/firmware/FirmwareCheckpoint.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareHostBinding.d.ts +0 -6
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +0 -3
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +0 -29
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +0 -25
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +0 -1
- package/dist/api/firmware/progressThrottle.d.ts +0 -3
- package/dist/api/firmware/progressThrottle.d.ts.map +0 -1
- package/dist/api/helpers/filesystemValidation.d.ts +0 -10
- package/dist/api/helpers/filesystemValidation.d.ts.map +0 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -33
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +0 -28
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts +0 -28
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +0 -16
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +0 -12
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +0 -26
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +0 -6
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +0 -6
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +0 -1
- package/dist/api/protocol-v2/Ping.d.ts +0 -8
- package/dist/api/protocol-v2/Ping.d.ts.map +0 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +0 -6
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +0 -1
- package/dist/api/protocol-v2/helpers.d.ts +0 -42
- package/dist/api/protocol-v2/helpers.d.ts.map +0 -1
- package/dist/core/deviceEventRegistration.d.ts +0 -11
- package/dist/core/deviceEventRegistration.d.ts.map +0 -1
- package/dist/device/DeviceFeaturesState.d.ts +0 -4
- package/dist/device/DeviceFeaturesState.d.ts.map +0 -1
- package/dist/device/DeviceStateMapper.d.ts +0 -13
- package/dist/device/DeviceStateMapper.d.ts.map +0 -1
- package/dist/device/DeviceStateProjector.d.ts +0 -7
- package/dist/device/DeviceStateProjector.d.ts.map +0 -1
- package/dist/device/DeviceStateStore.d.ts +0 -21
- package/dist/device/DeviceStateStore.d.ts.map +0 -1
- package/dist/device/DeviceWalletSessionStore.d.ts +0 -15
- package/dist/device/DeviceWalletSessionStore.d.ts.map +0 -1
- package/dist/device/cloneDeviceState.d.ts +0 -2
- package/dist/device/cloneDeviceState.d.ts.map +0 -1
- package/dist/device/deviceIdentity.d.ts +0 -5
- package/dist/device/deviceIdentity.d.ts.map +0 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +0 -12
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +0 -1
- package/dist/deviceProfile/index.d.ts +0 -2
- package/dist/deviceProfile/index.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/deviceSession.d.ts +0 -7
- package/dist/protocols/protocol-v2/deviceSession.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/features.d.ts +0 -88
- package/dist/protocols/protocol-v2/features.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +0 -15
- package/dist/protocols/protocol-v2/firmware.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/index.d.ts +0 -5
- package/dist/protocols/protocol-v2/index.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +0 -2
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +0 -16
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +0 -39
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +0 -11
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +0 -21
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +0 -13
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdatePlan.d.ts +0 -35
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +0 -43
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +0 -1
- package/dist/types/api/getDeviceState.d.ts +0 -12
- package/dist/types/api/getDeviceState.d.ts.map +0 -1
- package/dist/types/api/openWalletSession.d.ts +0 -35
- package/dist/types/api/openWalletSession.d.ts.map +0 -1
- package/dist/types/api/protocolV2.d.ts +0 -113
- package/dist/types/api/protocolV2.d.ts.map +0 -1
- package/dist/types/api/sessionCache.d.ts +0 -10
- package/dist/types/api/sessionCache.d.ts.map +0 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +0 -13
- package/dist/utils/deviceFeaturesCompat.d.ts.map +0 -1
- package/dist/utils/pro2Wallpaper.d.ts +0 -12
- package/dist/utils/pro2Wallpaper.d.ts.map +0 -1
- package/src/api/ClearSessionCache.ts +0 -28
- package/src/api/DirList.ts +0 -33
- package/src/api/DirMake.ts +0 -23
- package/src/api/DirRemove.ts +0 -23
- package/src/api/FileDelete.ts +0 -23
- package/src/api/FileRead.ts +0 -183
- package/src/api/FileWrite.ts +0 -71
- package/src/api/FirmwareUpdateV4.ts +0 -2279
- package/src/api/GetDeviceState.ts +0 -55
- package/src/api/OpenWalletSession.ts +0 -211
- package/src/api/PathInfo.ts +0 -41
- package/src/api/UploadPortfolio.ts +0 -50
- package/src/api/firmware/FirmwareArtifactSource.ts +0 -278
- package/src/api/firmware/FirmwareCheckpoint.ts +0 -188
- package/src/api/firmware/FirmwareHostBinding.ts +0 -108
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +0 -13
- package/src/api/firmware/FirmwareUpdatePlan.ts +0 -729
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +0 -403
- package/src/api/firmware/progressThrottle.ts +0 -44
- package/src/api/helpers/filesystemValidation.ts +0 -112
- package/src/api/helpers/protocolV2FileWrite.ts +0 -193
- package/src/api/protocol-v2/DeviceFactoryInfoGet.ts +0 -20
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +0 -32
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +0 -61
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +0 -55
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -18
- package/src/api/protocol-v2/DeviceInfoGet.ts +0 -145
- package/src/api/protocol-v2/DeviceReboot.ts +0 -26
- package/src/api/protocol-v2/DeviceSessionOpen.ts +0 -102
- package/src/api/protocol-v2/DeviceSettingsGet.ts +0 -18
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +0 -70
- package/src/api/protocol-v2/DeviceSettingsSet.ts +0 -44
- package/src/api/protocol-v2/DeviceStatusGet.ts +0 -16
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +0 -131
- package/src/api/protocol-v2/FilesystemFormat.ts +0 -19
- package/src/api/protocol-v2/FilesystemPermissionFix.ts +0 -16
- package/src/api/protocol-v2/Ping.ts +0 -18
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +0 -16
- package/src/api/protocol-v2/helpers.ts +0 -203
- package/src/core/deviceEventRegistration.ts +0 -23
- package/src/data/messages/messages-protocol-v2.json +0 -13544
- package/src/device/DeviceFeaturesState.ts +0 -34
- package/src/device/DeviceStateMapper.ts +0 -348
- package/src/device/DeviceStateProjector.ts +0 -95
- package/src/device/DeviceStateStore.ts +0 -201
- package/src/device/DeviceWalletSessionStore.ts +0 -78
- package/src/device/cloneDeviceState.ts +0 -39
- package/src/device/deviceIdentity.ts +0 -18
- package/src/deviceProfile/buildDeviceFeatures.ts +0 -391
- package/src/deviceProfile/index.ts +0 -4
- package/src/protocols/protocol-v2/deviceSession.ts +0 -24
- package/src/protocols/protocol-v2/features.ts +0 -163
- package/src/protocols/protocol-v2/firmware.ts +0 -21
- package/src/protocols/protocol-v2/index.ts +0 -18
- package/src/protocols/protocol-v2/lockedError.ts +0 -10
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +0 -61
- package/src/protocols/protocol-v2/uiInteraction.ts +0 -210
- package/src/protocols/protocol-v2/unlockRetry.ts +0 -76
- package/src/protocols/protocol-v2/walletSession.ts +0 -202
- package/src/types/api/firmwareUpdateCapabilities.ts +0 -13
- package/src/types/api/firmwareUpdatePlan.ts +0 -52
- package/src/types/api/firmwareUpdatePreparedPlan.ts +0 -55
- package/src/types/api/getDeviceState.ts +0 -19
- package/src/types/api/openWalletSession.ts +0 -54
- package/src/types/api/protocolV2.ts +0 -244
- package/src/types/api/sessionCache.ts +0 -14
- package/src/utils/deviceFeaturesCompat.ts +0 -173
- package/src/utils/pro2Wallpaper.ts +0 -109
package/src/core/index.ts
CHANGED
|
@@ -17,8 +17,11 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
LoggerNames,
|
|
19
19
|
enableLog,
|
|
20
|
+
getDeviceBLEFirmwareVersion,
|
|
21
|
+
getDeviceFirmwareVersion,
|
|
22
|
+
getFirmwareType,
|
|
20
23
|
getLogger,
|
|
21
|
-
|
|
24
|
+
getMethodVersionRange,
|
|
22
25
|
setLoggerPostMessage,
|
|
23
26
|
wait,
|
|
24
27
|
} from '../utils';
|
|
@@ -26,6 +29,7 @@ import {
|
|
|
26
29
|
findDefectiveBatchDevice,
|
|
27
30
|
getDefectiveDeviceInfo,
|
|
28
31
|
} from '../utils/findDefectiveBatchDevice';
|
|
32
|
+
import { supportNewPassphrase } from '../utils/deviceFeaturesUtils';
|
|
29
33
|
import {
|
|
30
34
|
cleanupSdkInstance,
|
|
31
35
|
completeRequestContext,
|
|
@@ -36,7 +40,6 @@ import {
|
|
|
36
40
|
updateRequestContext,
|
|
37
41
|
} from '../utils/tracing';
|
|
38
42
|
import { Device } from '../device/Device';
|
|
39
|
-
import { checkLiveDeviceId } from '../device/deviceIdentity';
|
|
40
43
|
import { DeviceList } from '../device/DeviceList';
|
|
41
44
|
import { DevicePool } from '../device/DevicePool';
|
|
42
45
|
import { PollingStateManager } from './PollingStateManager';
|
|
@@ -52,25 +55,22 @@ import {
|
|
|
52
55
|
createDeviceMessage,
|
|
53
56
|
createResponseMessage,
|
|
54
57
|
createUiMessage,
|
|
55
|
-
getLogBlockLabel,
|
|
56
58
|
} from '../events';
|
|
57
59
|
import TransportManager from '../data-manager/TransportManager';
|
|
58
60
|
import DeviceConnector from '../device/DeviceConnector';
|
|
59
61
|
import RequestQueue from './RequestQueue';
|
|
60
|
-
import { registerHardwareUiEventListeners } from './deviceEventRegistration';
|
|
61
62
|
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';
|
|
67
63
|
|
|
68
|
-
import type { ConnectSettings,
|
|
64
|
+
import type { ConnectSettings, KnownDevice } from '../types';
|
|
69
65
|
import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
|
|
70
66
|
import type { DeviceEvents, InitOptions, RunOptions } from '../device/Device';
|
|
71
67
|
import type { SdkTracingContext } from '../utils/tracing';
|
|
72
68
|
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
73
|
-
import type {
|
|
69
|
+
import type {
|
|
70
|
+
Features,
|
|
71
|
+
LowlevelTransportSharedPlugin,
|
|
72
|
+
OneKeyDeviceInfo,
|
|
73
|
+
} from '@onekeyfe/hd-transport';
|
|
74
74
|
import type { BaseMethod } from '../api/BaseMethod';
|
|
75
75
|
|
|
76
76
|
const Log = getLogger(LoggerNames.Core);
|
|
@@ -99,14 +99,12 @@ function hasDeriveCardano(method: BaseMethod): boolean {
|
|
|
99
99
|
|
|
100
100
|
const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
101
101
|
initSession: method?.payload.initSession,
|
|
102
|
-
passphraseState: method?.payload.
|
|
102
|
+
passphraseState: method?.payload.passphraseState,
|
|
103
103
|
deviceId: method?.payload.deviceId,
|
|
104
104
|
deriveCardano: method && hasDeriveCardano(method),
|
|
105
|
-
connectProtocol: method?.payload.connectProtocol,
|
|
106
|
-
protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
|
|
107
105
|
});
|
|
108
106
|
|
|
109
|
-
let _core: Core
|
|
107
|
+
let _core: Core;
|
|
110
108
|
let _deviceList: DeviceList | undefined;
|
|
111
109
|
let _connector: DeviceConnector | undefined;
|
|
112
110
|
let _uiPromises: UiPromise<UiPromiseResponse['type']>[] = []; // Waiting for ui response
|
|
@@ -150,7 +148,7 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
150
148
|
}
|
|
151
149
|
|
|
152
150
|
// find api method
|
|
153
|
-
let method
|
|
151
|
+
let method: BaseMethod;
|
|
154
152
|
try {
|
|
155
153
|
method = findMethod(message as IFrameCallMessage);
|
|
156
154
|
method.connector = _connector;
|
|
@@ -166,10 +164,6 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
166
164
|
|
|
167
165
|
method.init();
|
|
168
166
|
} catch (error) {
|
|
169
|
-
if (method) {
|
|
170
|
-
completeMethodRequestContext(method, error);
|
|
171
|
-
method.dispose();
|
|
172
|
-
}
|
|
173
167
|
return Promise.reject(error);
|
|
174
168
|
}
|
|
175
169
|
|
|
@@ -196,25 +190,34 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
196
190
|
// );
|
|
197
191
|
// }
|
|
198
192
|
|
|
193
|
+
const { requestQueue, methodSynchronize } = context;
|
|
194
|
+
const error = await methodSynchronize(() => {
|
|
195
|
+
for (const requestId of requestQueue.getRequestTasksId()) {
|
|
196
|
+
const task = requestQueue.getTask(requestId);
|
|
197
|
+
Log.debug(
|
|
198
|
+
'pre request task: ',
|
|
199
|
+
`task?.id: ${task?.id},
|
|
200
|
+
task?.method.connectId: ${task?.method.connectId},
|
|
201
|
+
task?.method.deviceId: ${task?.method.deviceId},
|
|
202
|
+
task?.method.name: ${task?.method.name}`
|
|
203
|
+
);
|
|
204
|
+
// if (task) {
|
|
205
|
+
// return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceBusy));
|
|
206
|
+
// }
|
|
207
|
+
}
|
|
208
|
+
return null;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
if (error) {
|
|
212
|
+
return createResponseMessage(method.responseID, false, { error });
|
|
213
|
+
}
|
|
214
|
+
|
|
199
215
|
// only the pre-warm signal (PreInitialize) forks here; normal methods fall
|
|
200
216
|
// through to onCallDevice below, so the pre-warm dedup/guards never touch them
|
|
201
217
|
if (method.isPreWarmSignal) {
|
|
202
218
|
return handlePreWarmSignal(context, message, method);
|
|
203
219
|
}
|
|
204
220
|
|
|
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
|
-
|
|
218
221
|
return onCallDevice(context, message, method);
|
|
219
222
|
};
|
|
220
223
|
|
|
@@ -226,16 +229,9 @@ const handlePreWarmSignal = async (
|
|
|
226
229
|
message: CoreMessage,
|
|
227
230
|
method: BaseMethod
|
|
228
231
|
): 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
|
-
|
|
236
232
|
// no connectId: can't target a device safely, skip pre-warm (ack only)
|
|
237
233
|
if (!method.connectId) {
|
|
238
|
-
return
|
|
234
|
+
return createResponseMessage(method.responseID, true, true);
|
|
239
235
|
}
|
|
240
236
|
|
|
241
237
|
const key = method.getPreWarmKey();
|
|
@@ -248,12 +244,12 @@ const handlePreWarmSignal = async (
|
|
|
248
244
|
} catch {
|
|
249
245
|
// pre-warm is best-effort; ignore its failure for the coalesced caller
|
|
250
246
|
}
|
|
251
|
-
return
|
|
247
|
+
return createResponseMessage(method.responseID, true, true);
|
|
252
248
|
}
|
|
253
249
|
|
|
254
250
|
const doneAt = preWarmDoneAt.get(key);
|
|
255
251
|
if (typeof doneAt === 'number' && Date.now() - doneAt <= method.preWarmTtl) {
|
|
256
|
-
return
|
|
252
|
+
return createResponseMessage(method.responseID, true, true);
|
|
257
253
|
}
|
|
258
254
|
|
|
259
255
|
const run = onCallDevice(context, message, method);
|
|
@@ -334,7 +330,7 @@ const onCallDevice = async (
|
|
|
334
330
|
|
|
335
331
|
await waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
336
332
|
|
|
337
|
-
const task = requestQueue.
|
|
333
|
+
const task = requestQueue.createTask(method);
|
|
338
334
|
|
|
339
335
|
// Pre-warm holds the device as a per-connectId callback task so a concurrent
|
|
340
336
|
// real call waits (before ensureConnected) instead of racing its Initialize.
|
|
@@ -361,7 +357,7 @@ const onCallDevice = async (
|
|
|
361
357
|
);
|
|
362
358
|
} catch (e) {
|
|
363
359
|
preWarmCallbackTask?.resolve();
|
|
364
|
-
|
|
360
|
+
console.log('ensureConnected error: ', e);
|
|
365
361
|
|
|
366
362
|
completeMethodRequestContext(method, e);
|
|
367
363
|
|
|
@@ -378,10 +374,6 @@ const onCallDevice = async (
|
|
|
378
374
|
if (method.payload?.onlyConnectBleDevice) {
|
|
379
375
|
preWarmCallbackTask?.resolve();
|
|
380
376
|
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();
|
|
385
377
|
return createResponseMessage(method.responseID, true, null);
|
|
386
378
|
}
|
|
387
379
|
|
|
@@ -402,23 +394,18 @@ const onCallDevice = async (
|
|
|
402
394
|
);
|
|
403
395
|
}
|
|
404
396
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
attachPinOnDevice: onEnterAttachPinOnDeviceHandler,
|
|
413
|
-
});
|
|
397
|
+
device.on(DEVICE.PIN, onDevicePinHandler);
|
|
398
|
+
device.on(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
399
|
+
device.on(
|
|
400
|
+
DEVICE.PASSPHRASE,
|
|
401
|
+
message.payload.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler
|
|
402
|
+
);
|
|
403
|
+
device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
414
404
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
415
|
-
device.on(DEVICE.STATE, onDeviceStateHandler);
|
|
416
405
|
device.on(
|
|
417
406
|
DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE,
|
|
418
407
|
onSelectDeviceInBootloaderForWebDeviceHandler
|
|
419
408
|
);
|
|
420
|
-
|
|
421
|
-
const protocolV2UiCoordinator = new ProtocolV2UiInteractionCoordinator(device, postMessage);
|
|
422
409
|
device.on(
|
|
423
410
|
DEVICE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE,
|
|
424
411
|
onSelectDeviceForSwitchFirmwareWebDeviceHandler
|
|
@@ -433,24 +420,13 @@ const onCallDevice = async (
|
|
|
433
420
|
await waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
434
421
|
|
|
435
422
|
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
|
-
|
|
442
423
|
// check firmware version
|
|
443
|
-
const versionRange =
|
|
424
|
+
const versionRange = getMethodVersionRange(
|
|
425
|
+
device.features,
|
|
444
426
|
type => method.getVersionRange()[type]
|
|
445
427
|
);
|
|
446
|
-
|
|
447
|
-
|
|
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()) {
|
|
428
|
+
|
|
429
|
+
if (device.features) {
|
|
454
430
|
await DataManager.checkAndReloadData();
|
|
455
431
|
|
|
456
432
|
// 检测故障固件设备
|
|
@@ -467,9 +443,12 @@ const onCallDevice = async (
|
|
|
467
443
|
}
|
|
468
444
|
}
|
|
469
445
|
|
|
470
|
-
|
|
446
|
+
const deviceFirmwareType = getFirmwareType(device.features);
|
|
447
|
+
const newVersionStatus = DataManager.getFirmwareStatus(device.features, deviceFirmwareType);
|
|
471
448
|
const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
|
|
472
449
|
|
|
450
|
+
const currentFirmwareVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
451
|
+
const currentBleVersion = getDeviceBLEFirmwareVersion(device.features).join('.');
|
|
473
452
|
if (
|
|
474
453
|
(newVersionStatus === 'required' || bleVersionStatus === 'required') &&
|
|
475
454
|
method.skipForceUpdateCheck === false
|
|
@@ -495,43 +474,42 @@ const onCallDevice = async (
|
|
|
495
474
|
currentVersions
|
|
496
475
|
);
|
|
497
476
|
}
|
|
498
|
-
}
|
|
499
477
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
478
|
+
if (versionRange) {
|
|
479
|
+
if (
|
|
480
|
+
semver.valid(versionRange.min) &&
|
|
481
|
+
semver.lt(currentFirmwareVersion, versionRange.min)
|
|
482
|
+
) {
|
|
483
|
+
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
484
|
+
throw createNewFirmwareUnReleaseHardwareError({
|
|
485
|
+
currentVersion: currentFirmwareVersion,
|
|
486
|
+
requireVersion: versionRange.min,
|
|
487
|
+
methodName: method.name,
|
|
488
|
+
firmwareType: getFirmwareType(device.features),
|
|
489
|
+
});
|
|
490
|
+
}
|
|
503
491
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
});
|
|
492
|
+
return Promise.reject(
|
|
493
|
+
createNeedUpgradeFirmwareHardwareError({
|
|
494
|
+
currentVersion: currentFirmwareVersion,
|
|
495
|
+
requireVersion: versionRange.min,
|
|
496
|
+
methodName: method.name,
|
|
497
|
+
firmwareType: getFirmwareType(device.features),
|
|
498
|
+
})
|
|
499
|
+
);
|
|
513
500
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
|
|
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
|
-
);
|
|
501
|
+
if (
|
|
502
|
+
versionRange.max &&
|
|
503
|
+
semver.valid(versionRange.max) &&
|
|
504
|
+
semver.gte(currentFirmwareVersion, versionRange.max)
|
|
505
|
+
) {
|
|
506
|
+
return Promise.reject(
|
|
507
|
+
createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name)
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
} else if (method.strictCheckDeviceSupport) {
|
|
511
|
+
throw createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
532
512
|
}
|
|
533
|
-
} else if (method.strictCheckDeviceSupport) {
|
|
534
|
-
throw createDeviceNotSupportMethodError(method.name, deviceFirmwareType);
|
|
535
513
|
}
|
|
536
514
|
|
|
537
515
|
// check call method mode
|
|
@@ -552,7 +530,7 @@ const onCallDevice = async (
|
|
|
552
530
|
}
|
|
553
531
|
|
|
554
532
|
if (method.deviceId && method.checkDeviceId) {
|
|
555
|
-
const isSameDeviceID =
|
|
533
|
+
const isSameDeviceID = device.checkDeviceId(method.deviceId);
|
|
556
534
|
if (!isSameDeviceID) {
|
|
557
535
|
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError));
|
|
558
536
|
}
|
|
@@ -569,16 +547,16 @@ const onCallDevice = async (
|
|
|
569
547
|
method.checkDeviceSupportFeature();
|
|
570
548
|
|
|
571
549
|
// reconfigure messages
|
|
572
|
-
if (_deviceList
|
|
550
|
+
if (_deviceList) {
|
|
573
551
|
await TransportManager.reconfigure(device.features);
|
|
574
552
|
}
|
|
575
553
|
|
|
576
554
|
// Check to see if it is safe to use Passphrase
|
|
577
555
|
checkPassphraseEnableState(method, device.features);
|
|
578
556
|
|
|
579
|
-
if (
|
|
557
|
+
if (device.hasUsePassphrase() && method.useDevicePassphraseState) {
|
|
580
558
|
// check version
|
|
581
|
-
const support = device.
|
|
559
|
+
const support = supportNewPassphrase(device.features);
|
|
582
560
|
if (!support.support) {
|
|
583
561
|
return Promise.reject(
|
|
584
562
|
ERRORS.TypedError(
|
|
@@ -629,11 +607,7 @@ const onCallDevice = async (
|
|
|
629
607
|
method.device?.commands?.checkDisposed();
|
|
630
608
|
|
|
631
609
|
try {
|
|
632
|
-
const response: object = await
|
|
633
|
-
method,
|
|
634
|
-
device,
|
|
635
|
-
protocolV2UiCoordinator
|
|
636
|
-
);
|
|
610
|
+
const response: object = await method.run();
|
|
637
611
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
638
612
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
639
613
|
completeMethodRequestContext(method);
|
|
@@ -650,8 +624,6 @@ const onCallDevice = async (
|
|
|
650
624
|
) {
|
|
651
625
|
throw error;
|
|
652
626
|
}
|
|
653
|
-
} finally {
|
|
654
|
-
protocolV2UiCoordinator.close();
|
|
655
627
|
}
|
|
656
628
|
};
|
|
657
629
|
Log.debug('Call API - Device Run: ', device.mainId);
|
|
@@ -661,9 +633,8 @@ const onCallDevice = async (
|
|
|
661
633
|
skipInitialize: canSkipInitialize(method, device),
|
|
662
634
|
...parseInitOptions(method),
|
|
663
635
|
};
|
|
664
|
-
const
|
|
665
|
-
task.callPromise = createDeferred<any>();
|
|
666
|
-
deviceRunPromise.catch(error => task.callPromise?.reject(error));
|
|
636
|
+
const deviceRun = () => device.run(inner, runOptions);
|
|
637
|
+
task.callPromise = createDeferred<any>(deviceRun);
|
|
667
638
|
|
|
668
639
|
try {
|
|
669
640
|
return await task.callPromise.promise;
|
|
@@ -671,8 +642,6 @@ const onCallDevice = async (
|
|
|
671
642
|
Log.debug('Device Run Error: ', e);
|
|
672
643
|
completeMethodRequestContext(method, e);
|
|
673
644
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
674
|
-
} finally {
|
|
675
|
-
await deviceRunPromise.catch(() => undefined);
|
|
676
645
|
}
|
|
677
646
|
} catch (error) {
|
|
678
647
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
@@ -708,9 +677,7 @@ const onCallDevice = async (
|
|
|
708
677
|
|
|
709
678
|
requestQueue.releaseTask(method.responseID);
|
|
710
679
|
|
|
711
|
-
|
|
712
|
-
closePopup();
|
|
713
|
-
}
|
|
680
|
+
closePopup();
|
|
714
681
|
|
|
715
682
|
cleanup();
|
|
716
683
|
|
|
@@ -756,27 +723,17 @@ function initDevice(method: BaseMethod) {
|
|
|
756
723
|
let device: Device | typeof undefined;
|
|
757
724
|
const allDevices = _deviceList.allDevices();
|
|
758
725
|
|
|
759
|
-
if (method.payload?.detectBootloaderDevice && allDevices.some(d => d.
|
|
726
|
+
if (method.payload?.detectBootloaderDevice && allDevices.some(d => d.features?.bootloader_mode)) {
|
|
760
727
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceDetectInBootloaderMode);
|
|
761
728
|
}
|
|
762
729
|
|
|
763
730
|
if (method.connectId) {
|
|
764
731
|
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
|
-
}
|
|
774
732
|
} else if (allDevices.length === 1) {
|
|
775
733
|
[device] = allDevices;
|
|
776
734
|
} else if (allDevices.length > 1) {
|
|
777
735
|
throw ERRORS.TypedError(
|
|
778
736
|
[
|
|
779
|
-
'firmwareUpdateV4',
|
|
780
737
|
'firmwareUpdateV3',
|
|
781
738
|
'firmwareUpdateV2',
|
|
782
739
|
'checkFirmwareRelease',
|
|
@@ -839,8 +796,8 @@ function canSkipInitialize(method: BaseMethod, device: Device): boolean {
|
|
|
839
796
|
if (!method.connectId) reasons.push('connectId.missing');
|
|
840
797
|
// passphrase state must match the pre-initialize
|
|
841
798
|
if (!device.isPreInitializeMetaMatch(method.payload)) reasons.push('meta.mismatch');
|
|
842
|
-
// device must have been initialized before
|
|
843
|
-
if (device.
|
|
799
|
+
// device must have been initialized before (has features)
|
|
800
|
+
if (!device.features) reasons.push('features.missing');
|
|
844
801
|
// within pre-initialize TTL
|
|
845
802
|
if (!device.isPreInitializedValid(PRE_INITIALIZE_TTL_MS)) reasons.push('ttl.expired');
|
|
846
803
|
|
|
@@ -856,23 +813,13 @@ function canSkipInitialize(method: BaseMethod, device: Device): boolean {
|
|
|
856
813
|
return true;
|
|
857
814
|
}
|
|
858
815
|
|
|
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
|
-
|
|
869
816
|
/**
|
|
870
817
|
* If the Bluetooth connection times out, retry up to 6 times
|
|
871
818
|
* @param retryCount - Current retry count (default 0)
|
|
872
819
|
*/
|
|
873
820
|
async function connectDeviceForBle(method: BaseMethod, device: Device, retryCount = 0) {
|
|
874
821
|
try {
|
|
875
|
-
await device.acquire(
|
|
822
|
+
await device.acquire();
|
|
876
823
|
if (method.payload?.onlyConnectBleDevice) {
|
|
877
824
|
return;
|
|
878
825
|
}
|
|
@@ -885,12 +832,7 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
885
832
|
});
|
|
886
833
|
}
|
|
887
834
|
} catch (err) {
|
|
888
|
-
if (
|
|
889
|
-
(err.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
890
|
-
err.errorCode === HardwareErrorCode.BleConnectedError ||
|
|
891
|
-
isRetryableBleProtocolV2ProbeError(method, err)) &&
|
|
892
|
-
retryCount < 6
|
|
893
|
-
) {
|
|
835
|
+
if (err.errorCode === HardwareErrorCode.BleTimeoutError && retryCount < 6) {
|
|
894
836
|
const nextRetry = retryCount + 1;
|
|
895
837
|
Log.debug(`Bluetooth connect timeout and will retry, retry count: ${nextRetry}`);
|
|
896
838
|
await wait(3000);
|
|
@@ -1149,11 +1091,7 @@ export const cancel = (context: CoreContext, connectId?: string) => {
|
|
|
1149
1091
|
const checkPassphraseEnableState = (method: BaseMethod, features?: Features) => {
|
|
1150
1092
|
if (!method.useDevicePassphraseState) return;
|
|
1151
1093
|
|
|
1152
|
-
|
|
1153
|
-
? method.device.getCurrentPassphraseProtection()
|
|
1154
|
-
: features?.passphraseProtection;
|
|
1155
|
-
|
|
1156
|
-
if (passphraseProtection === true) {
|
|
1094
|
+
if (features?.passphrase_protection === true) {
|
|
1157
1095
|
const hasNoPassphraseState =
|
|
1158
1096
|
method.payload.passphraseState == null || method.payload.passphraseState === '';
|
|
1159
1097
|
const shouldRequirePassphrase =
|
|
@@ -1165,18 +1103,12 @@ const checkPassphraseEnableState = (method: BaseMethod, features?: Features) =>
|
|
|
1165
1103
|
}
|
|
1166
1104
|
}
|
|
1167
1105
|
|
|
1168
|
-
if (
|
|
1106
|
+
if (features?.passphrase_protection === false && method.payload.passphraseState) {
|
|
1169
1107
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
1170
1108
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
1171
1109
|
}
|
|
1172
1110
|
};
|
|
1173
1111
|
|
|
1174
|
-
const shouldCheckPassphraseState = (method: BaseMethod, device: Device) => {
|
|
1175
|
-
if (!method.useDevicePassphraseState) return false;
|
|
1176
|
-
|
|
1177
|
-
return device.hasUsePassphrase();
|
|
1178
|
-
};
|
|
1179
|
-
|
|
1180
1112
|
const cleanup = () => {
|
|
1181
1113
|
_uiPromises = [];
|
|
1182
1114
|
Log.debug('Cleanup...');
|
|
@@ -1196,16 +1128,16 @@ const closePopup = () => {
|
|
|
1196
1128
|
};
|
|
1197
1129
|
|
|
1198
1130
|
const onDeviceConnectHandler = (device: Device) => {
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1201
|
-
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject }));
|
|
1131
|
+
const env = DataManager.getSettings('env');
|
|
1132
|
+
const deviceObject = DataManager.isBleConnect(env) ? device : device.toMessageObject();
|
|
1133
|
+
postMessage(createDeviceMessage(DEVICE.CONNECT, { device: deviceObject as KnownDevice }));
|
|
1202
1134
|
};
|
|
1203
1135
|
|
|
1204
1136
|
const onDeviceDisconnectHandler = (device: Device) => {
|
|
1205
1137
|
device.clearPreInitialized();
|
|
1206
|
-
const
|
|
1207
|
-
|
|
1208
|
-
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|
|
1138
|
+
const env = DataManager.getSettings('env');
|
|
1139
|
+
const deviceObject = DataManager.isBleConnect(env) ? device : device.toMessageObject();
|
|
1140
|
+
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject as KnownDevice }));
|
|
1209
1141
|
};
|
|
1210
1142
|
|
|
1211
1143
|
const onDevicePinHandler = async (...[device, type, callback]: DeviceEvents['pin']) => {
|
|
@@ -1246,10 +1178,6 @@ const onDeviceFeaturesHandler = (...[_, features]: [...DeviceEvents['features']]
|
|
|
1246
1178
|
postMessage(createDeviceMessage(DEVICE.FEATURES, { ...features }));
|
|
1247
1179
|
};
|
|
1248
1180
|
|
|
1249
|
-
const onDeviceStateHandler = (...[_, stateEvent]: [...DeviceEvents['state']]) => {
|
|
1250
|
-
postMessage(createDeviceMessage(DEVICE.STATE, stateEvent));
|
|
1251
|
-
};
|
|
1252
|
-
|
|
1253
1181
|
const onDevicePassphraseHandler = async (
|
|
1254
1182
|
...[device, requestPayload, callback]: DeviceEvents['passphrase']
|
|
1255
1183
|
) => {
|
|
@@ -1260,9 +1188,6 @@ const onDevicePassphraseHandler = async (
|
|
|
1260
1188
|
device: device.toMessageObject() as KnownDevice,
|
|
1261
1189
|
passphraseState: device.passphraseState,
|
|
1262
1190
|
existsAttachPinUser: requestPayload.existsAttachPinUser,
|
|
1263
|
-
source: requestPayload.source,
|
|
1264
|
-
reason: requestPayload.reason,
|
|
1265
|
-
expectedPassphraseState: requestPayload.expectedPassphraseState,
|
|
1266
1191
|
})
|
|
1267
1192
|
);
|
|
1268
1193
|
// wait for passphrase
|
|
@@ -1284,27 +1209,12 @@ const onEmptyPassphraseHandler = (...[_, , callback]: DeviceEvents['passphrase']
|
|
|
1284
1209
|
};
|
|
1285
1210
|
|
|
1286
1211
|
const onEnterPassphraseOnDeviceHandler = (
|
|
1287
|
-
...[device
|
|
1212
|
+
...[device]: [...DeviceEvents['passphrase_on_device']]
|
|
1288
1213
|
) => {
|
|
1289
1214
|
postMessage(
|
|
1290
1215
|
createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
1291
1216
|
device: device.toMessageObject() as KnownDevice,
|
|
1292
1217
|
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,
|
|
1308
1218
|
})
|
|
1309
1219
|
);
|
|
1310
1220
|
};
|
|
@@ -1375,8 +1285,6 @@ export default class Core extends EventEmitter {
|
|
|
1375
1285
|
|
|
1376
1286
|
private requestQueue = new RequestQueue();
|
|
1377
1287
|
|
|
1378
|
-
private disposePromise?: Promise<void>;
|
|
1379
|
-
|
|
1380
1288
|
// background task
|
|
1381
1289
|
private prePendingCallPromise: Promise<void> | undefined;
|
|
1382
1290
|
|
|
@@ -1389,10 +1297,6 @@ export default class Core extends EventEmitter {
|
|
|
1389
1297
|
Log.debug(`[Core] Created SDK instance: ${this.sdkInstanceId}`);
|
|
1390
1298
|
}
|
|
1391
1299
|
|
|
1392
|
-
cancelOperation(operationId: string) {
|
|
1393
|
-
this.requestQueue.abortOperation(operationId);
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
1300
|
private getCoreContext() {
|
|
1397
1301
|
return {
|
|
1398
1302
|
sdkInstanceId: this.sdkInstanceId,
|
|
@@ -1439,17 +1343,10 @@ export default class Core extends EventEmitter {
|
|
|
1439
1343
|
}
|
|
1440
1344
|
|
|
1441
1345
|
case IFRAME.CALL: {
|
|
1442
|
-
|
|
1443
|
-
Log.log(
|
|
1444
|
-
`[${Date.now()}][CALL_API]`,
|
|
1445
|
-
logBlockLabel ? { method: logBlockLabel, payload: '[REDACTED]' } : message
|
|
1446
|
-
);
|
|
1346
|
+
Log.log(`[${Date.now()}][CALL_API]`, message);
|
|
1447
1347
|
const response = await callAPI(this.getCoreContext(), message);
|
|
1448
1348
|
const { success, payload } = response;
|
|
1449
|
-
Log.log(
|
|
1450
|
-
`[${Date.now()}][CALL_API_RESPONSE]`,
|
|
1451
|
-
logBlockLabel ? { method: logBlockLabel, payload: '[REDACTED]' } : response
|
|
1452
|
-
);
|
|
1349
|
+
Log.log(`[${Date.now()}][CALL_API_RESPONSE]`, response);
|
|
1453
1350
|
if (success) {
|
|
1454
1351
|
return response;
|
|
1455
1352
|
}
|
|
@@ -1468,10 +1365,6 @@ export default class Core extends EventEmitter {
|
|
|
1468
1365
|
cancel(this.getCoreContext(), message.payload.connectId);
|
|
1469
1366
|
break;
|
|
1470
1367
|
}
|
|
1471
|
-
case IFRAME.CANCEL_OPERATION: {
|
|
1472
|
-
this.cancelOperation(message.payload.operationId);
|
|
1473
|
-
break;
|
|
1474
|
-
}
|
|
1475
1368
|
case IFRAME.CALLBACK: {
|
|
1476
1369
|
Log.log('callback message: ', message);
|
|
1477
1370
|
postMessage(message);
|
|
@@ -1483,52 +1376,20 @@ export default class Core extends EventEmitter {
|
|
|
1483
1376
|
return Promise.resolve(message);
|
|
1484
1377
|
}
|
|
1485
1378
|
|
|
1486
|
-
dispose()
|
|
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.
|
|
1379
|
+
dispose() {
|
|
1511
1380
|
_deviceList = undefined;
|
|
1512
1381
|
_connector = undefined;
|
|
1513
|
-
DevicePool.resetState();
|
|
1514
1382
|
deviceCacheMap.clear();
|
|
1515
1383
|
preWarmInflight.clear();
|
|
1516
1384
|
preWarmDoneAt.clear();
|
|
1517
|
-
|
|
1518
|
-
this.prePendingCallPromise = undefined;
|
|
1519
|
-
this.removeAllListeners();
|
|
1385
|
+
Log.debug(`[Core] Disposing SDK instance: ${this.sdkInstanceId}`);
|
|
1520
1386
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
1521
|
-
if (_core === this) _core = undefined;
|
|
1522
|
-
|
|
1523
|
-
// Transports, especially Node USB, may release native handles asynchronously.
|
|
1524
|
-
await transportCleanup;
|
|
1525
1387
|
}
|
|
1526
1388
|
}
|
|
1527
1389
|
|
|
1528
1390
|
export const initCore = () => {
|
|
1529
|
-
|
|
1530
|
-
_core
|
|
1531
|
-
return core;
|
|
1391
|
+
_core = new Core();
|
|
1392
|
+
return _core;
|
|
1532
1393
|
};
|
|
1533
1394
|
|
|
1534
1395
|
export const initConnector = () => {
|