@trezor/connect 9.0.0-beta.1
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/LICENSE.md +50 -0
- package/README.md +38 -0
- package/lib/api/applyFlags.d.ts +8 -0
- package/lib/api/applyFlags.js +37 -0
- package/lib/api/applySettings.d.ts +8 -0
- package/lib/api/applySettings.js +57 -0
- package/lib/api/authorizeCoinJoin.d.ts +7 -0
- package/lib/api/authorizeCoinJoin.js +45 -0
- package/lib/api/backupDevice.d.ts +7 -0
- package/lib/api/backupDevice.js +31 -0
- package/lib/api/binance/binanceSignTx.d.ts +6 -0
- package/lib/api/binance/binanceSignTx.js +91 -0
- package/lib/api/binanceGetAddress.d.ts +22 -0
- package/lib/api/binanceGetAddress.js +126 -0
- package/lib/api/binanceGetPublicKey.d.ts +10 -0
- package/lib/api/binanceGetPublicKey.js +72 -0
- package/lib/api/binanceSignTransaction.d.ts +12 -0
- package/lib/api/binanceSignTransaction.js +31 -0
- package/lib/api/bitcoin/Fees.d.ts +15 -0
- package/lib/api/bitcoin/Fees.js +175 -0
- package/lib/api/bitcoin/TransactionComposer.d.ts +36 -0
- package/lib/api/bitcoin/TransactionComposer.js +150 -0
- package/lib/api/bitcoin/__fixtures__/inputs.d.ts +112 -0
- package/lib/api/bitcoin/__fixtures__/inputs.js +102 -0
- package/lib/api/bitcoin/__fixtures__/signtxVerify.d.ts +147 -0
- package/lib/api/bitcoin/__fixtures__/signtxVerify.js +216 -0
- package/lib/api/bitcoin/enhanceSignTx.d.ts +4 -0
- package/lib/api/bitcoin/enhanceSignTx.js +63 -0
- package/lib/api/bitcoin/index.d.ts +10 -0
- package/lib/api/bitcoin/index.js +13 -0
- package/lib/api/bitcoin/inputs.d.ts +8 -0
- package/lib/api/bitcoin/inputs.js +60 -0
- package/lib/api/bitcoin/outputs.d.ts +8 -0
- package/lib/api/bitcoin/outputs.js +115 -0
- package/lib/api/bitcoin/refTx.d.ts +11 -0
- package/lib/api/bitcoin/refTx.js +220 -0
- package/lib/api/bitcoin/signtx.d.ts +25 -0
- package/lib/api/bitcoin/signtx.js +164 -0
- package/lib/api/bitcoin/signtxLegacy.d.ts +4 -0
- package/lib/api/bitcoin/signtxLegacy.js +136 -0
- package/lib/api/bitcoin/signtxVerify.d.ts +8 -0
- package/lib/api/bitcoin/signtxVerify.js +130 -0
- package/lib/api/blockchainDisconnect.d.ts +13 -0
- package/lib/api/blockchainDisconnect.js +34 -0
- package/lib/api/blockchainEstimateFee.d.ts +12 -0
- package/lib/api/blockchainEstimateFee.js +70 -0
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +12 -0
- package/lib/api/blockchainGetAccountBalanceHistory.js +41 -0
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +15 -0
- package/lib/api/blockchainGetCurrentFiatRates.js +33 -0
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +17 -0
- package/lib/api/blockchainGetFiatRatesForTimestamps.js +33 -0
- package/lib/api/blockchainGetTransactions.d.ts +12 -0
- package/lib/api/blockchainGetTransactions.js +33 -0
- package/lib/api/blockchainSetCustomBackend.d.ts +11 -0
- package/lib/api/blockchainSetCustomBackend.js +38 -0
- package/lib/api/blockchainSubscribe.d.ts +14 -0
- package/lib/api/blockchainSubscribe.js +38 -0
- package/lib/api/blockchainSubscribeFiatRates.d.ts +14 -0
- package/lib/api/blockchainSubscribeFiatRates.js +33 -0
- package/lib/api/blockchainUnsubscribe.d.ts +14 -0
- package/lib/api/blockchainUnsubscribe.js +38 -0
- package/lib/api/blockchainUnsubscribeFiatRates.d.ts +13 -0
- package/lib/api/blockchainUnsubscribeFiatRates.js +29 -0
- package/lib/api/cardano/cardanoAddressParameters.d.ts +8 -0
- package/lib/api/cardano/cardanoAddressParameters.js +100 -0
- package/lib/api/cardano/cardanoAuxiliaryData.d.ts +6 -0
- package/lib/api/cardano/cardanoAuxiliaryData.js +51 -0
- package/lib/api/cardano/cardanoCertificate.d.ts +14 -0
- package/lib/api/cardano/cardanoCertificate.js +149 -0
- package/lib/api/cardano/cardanoInputs.d.ts +13 -0
- package/lib/api/cardano/cardanoInputs.js +34 -0
- package/lib/api/cardano/cardanoOutputs.d.ts +8 -0
- package/lib/api/cardano/cardanoOutputs.js +38 -0
- package/lib/api/cardano/cardanoTokenBundle.d.ts +8 -0
- package/lib/api/cardano/cardanoTokenBundle.js +36 -0
- package/lib/api/cardano/cardanoWitnesses.d.ts +5 -0
- package/lib/api/cardano/cardanoWitnesses.js +48 -0
- package/lib/api/cardanoGetAddress.d.ts +23 -0
- package/lib/api/cardanoGetAddress.js +158 -0
- package/lib/api/cardanoGetNativeScriptHash.d.ts +12 -0
- package/lib/api/cardanoGetNativeScriptHash.js +79 -0
- package/lib/api/cardanoGetPublicKey.d.ts +10 -0
- package/lib/api/cardanoGetPublicKey.js +78 -0
- package/lib/api/cardanoSignTransaction.d.ts +48 -0
- package/lib/api/cardanoSignTransaction.js +283 -0
- package/lib/api/changePin.d.ts +7 -0
- package/lib/api/changePin.js +22 -0
- package/lib/api/cipherKeyValue.d.ts +8 -0
- package/lib/api/cipherKeyValue.js +56 -0
- package/lib/api/common/Discovery.d.ts +35 -0
- package/lib/api/common/Discovery.js +113 -0
- package/lib/api/common/__fixtures__/paramsValidator.d.ts +596 -0
- package/lib/api/common/__fixtures__/paramsValidator.js +355 -0
- package/lib/api/common/paramsValidator.d.ts +14 -0
- package/lib/api/common/paramsValidator.js +140 -0
- package/lib/api/composeTransaction.d.ts +33 -0
- package/lib/api/composeTransaction.js +270 -0
- package/lib/api/customMessage.d.ts +13 -0
- package/lib/api/customMessage.js +56 -0
- package/lib/api/eos/eosSignTx.d.ts +17 -0
- package/lib/api/eos/eosSignTx.js +347 -0
- package/lib/api/eosGetPublicKey.d.ts +10 -0
- package/lib/api/eosGetPublicKey.js +73 -0
- package/lib/api/eosSignTransaction.d.ts +16 -0
- package/lib/api/eosSignTransaction.js +36 -0
- package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.d.ts +225 -0
- package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.js +341 -0
- package/lib/api/ethereum/ethereumSignTx.d.ts +13 -0
- package/lib/api/ethereum/ethereumSignTx.js +92 -0
- package/lib/api/ethereum/ethereumSignTypedData.d.ts +9 -0
- package/lib/api/ethereum/ethereumSignTypedData.js +120 -0
- package/lib/api/ethereumGetAddress.d.ts +28 -0
- package/lib/api/ethereumGetAddress.js +133 -0
- package/lib/api/ethereumGetPublicKey.d.ts +15 -0
- package/lib/api/ethereumGetPublicKey.js +79 -0
- package/lib/api/ethereumSignMessage.d.ts +7 -0
- package/lib/api/ethereumSignMessage.js +41 -0
- package/lib/api/ethereumSignTransaction.d.ts +20 -0
- package/lib/api/ethereumSignTransaction.js +82 -0
- package/lib/api/ethereumSignTypedData.d.ts +14 -0
- package/lib/api/ethereumSignTypedData.js +151 -0
- package/lib/api/ethereumVerifyMessage.d.ts +7 -0
- package/lib/api/ethereumVerifyMessage.js +34 -0
- package/lib/api/firmware/getBinary.d.ts +20 -0
- package/lib/api/firmware/getBinary.js +37 -0
- package/lib/api/firmware/modifyFirmware.d.ts +6 -0
- package/lib/api/firmware/modifyFirmware.js +18 -0
- package/lib/api/firmwareUpdate.d.ts +15 -0
- package/lib/api/firmwareUpdate.js +89 -0
- package/lib/api/getAccountInfo.d.ts +98 -0
- package/lib/api/getAccountInfo.js +326 -0
- package/lib/api/getAddress.d.ts +28 -0
- package/lib/api/getAddress.js +152 -0
- package/lib/api/getCoinInfo.d.ts +11 -0
- package/lib/api/getCoinInfo.js +27 -0
- package/lib/api/getDeviceState.d.ts +8 -0
- package/lib/api/getDeviceState.js +15 -0
- package/lib/api/getFeatures.d.ts +6 -0
- package/lib/api/getFeatures.js +18 -0
- package/lib/api/getOwnershipId.d.ts +10 -0
- package/lib/api/getOwnershipId.js +75 -0
- package/lib/api/getOwnershipProof.d.ts +14 -0
- package/lib/api/getOwnershipProof.js +86 -0
- package/lib/api/getPublicKey.d.ts +15 -0
- package/lib/api/getPublicKey.js +84 -0
- package/lib/api/getSettings.d.ts +6 -0
- package/lib/api/getSettings.js +16 -0
- package/lib/api/index.d.ts +64 -0
- package/lib/api/index.js +134 -0
- package/lib/api/management/uploadFirmware.d.ts +6 -0
- package/lib/api/management/uploadFirmware.js +49 -0
- package/lib/api/nem/nemSignTx.d.ts +4 -0
- package/lib/api/nem/nemSignTx.js +139 -0
- package/lib/api/nemGetAddress.d.ts +22 -0
- package/lib/api/nemGetAddress.js +144 -0
- package/lib/api/nemSignTransaction.d.ts +7 -0
- package/lib/api/nemSignTransaction.js +29 -0
- package/lib/api/pushTransaction.d.ts +14 -0
- package/lib/api/pushTransaction.js +40 -0
- package/lib/api/rebootToBootloader.d.ts +8 -0
- package/lib/api/rebootToBootloader.js +43 -0
- package/lib/api/recoveryDevice.d.ts +8 -0
- package/lib/api/recoveryDevice.js +57 -0
- package/lib/api/requestLogin.d.ts +12 -0
- package/lib/api/requestLogin.js +63 -0
- package/lib/api/resetDevice.d.ts +9 -0
- package/lib/api/resetDevice.js +59 -0
- package/lib/api/rippleGetAddress.d.ts +22 -0
- package/lib/api/rippleGetAddress.js +126 -0
- package/lib/api/rippleSignTransaction.d.ts +10 -0
- package/lib/api/rippleSignTransaction.js +54 -0
- package/lib/api/setProxy.d.ts +8 -0
- package/lib/api/setProxy.js +26 -0
- package/lib/api/signMessage.d.ts +7 -0
- package/lib/api/signMessage.js +51 -0
- package/lib/api/signTransaction.d.ts +21 -0
- package/lib/api/signTransaction.js +146 -0
- package/lib/api/stellar/stellarSignTx.d.ts +5 -0
- package/lib/api/stellar/stellarSignTx.js +198 -0
- package/lib/api/stellarGetAddress.d.ts +22 -0
- package/lib/api/stellarGetAddress.js +126 -0
- package/lib/api/stellarSignTransaction.d.ts +23 -0
- package/lib/api/stellarSignTransaction.js +62 -0
- package/lib/api/tezos/tezosSignTx.d.ts +4 -0
- package/lib/api/tezos/tezosSignTx.js +237 -0
- package/lib/api/tezosGetAddress.d.ts +22 -0
- package/lib/api/tezosGetAddress.js +126 -0
- package/lib/api/tezosGetPublicKey.d.ts +10 -0
- package/lib/api/tezosGetPublicKey.js +72 -0
- package/lib/api/tezosSignTransaction.d.ts +7 -0
- package/lib/api/tezosSignTransaction.js +30 -0
- package/lib/api/verifyMessage.d.ts +7 -0
- package/lib/api/verifyMessage.js +47 -0
- package/lib/api/wipeDevice.d.ts +8 -0
- package/lib/api/wipeDevice.js +41 -0
- package/lib/backend/BlockchainLink.d.ts +75 -0
- package/lib/backend/BlockchainLink.js +298 -0
- package/lib/constants/cardano.d.ts +9 -0
- package/lib/constants/cardano.js +14 -0
- package/lib/constants/errors.d.ts +49 -0
- package/lib/constants/errors.js +62 -0
- package/lib/constants/index.d.ts +6 -0
- package/lib/constants/index.js +10 -0
- package/lib/constants/nem.d.ts +22 -0
- package/lib/constants/nem.js +28 -0
- package/lib/constants/network.d.ts +13 -0
- package/lib/constants/network.js +15 -0
- package/lib/core/AbstractMethod.d.ts +59 -0
- package/lib/core/AbstractMethod.js +159 -0
- package/lib/core/index.d.ts +16 -0
- package/lib/core/index.js +671 -0
- package/lib/core/method.d.ts +6 -0
- package/lib/core/method.js +19 -0
- package/lib/data/DataManager.d.ts +31 -0
- package/lib/data/DataManager.js +98 -0
- package/lib/data/coinInfo.d.ts +37 -0
- package/lib/data/coinInfo.js +278 -0
- package/lib/data/config.d.ts +98 -0
- package/lib/data/config.js +201 -0
- package/lib/data/connectSettings.d.ts +6 -0
- package/lib/data/connectSettings.js +150 -0
- package/lib/data/firmwareInfo.d.ts +11 -0
- package/lib/data/firmwareInfo.js +148 -0
- package/lib/data/transportInfo.d.ts +4 -0
- package/lib/data/transportInfo.js +29 -0
- package/lib/data/udevInfo.d.ts +3 -0
- package/lib/data/udevInfo.js +21 -0
- package/lib/data/version.d.ts +3 -0
- package/lib/data/version.js +7 -0
- package/lib/device/AbortController.d.ts +21 -0
- package/lib/device/AbortController.js +40 -0
- package/lib/device/DescriptorStream.d.ts +28 -0
- package/lib/device/DescriptorStream.js +139 -0
- package/lib/device/Device.d.ts +105 -0
- package/lib/device/Device.js +527 -0
- package/lib/device/DeviceCommands.d.ts +63 -0
- package/lib/device/DeviceCommands.js +465 -0
- package/lib/device/DeviceList.d.ts +76 -0
- package/lib/device/DeviceList.js +411 -0
- package/lib/events/blockchain.d.ts +56 -0
- package/lib/events/blockchain.js +18 -0
- package/lib/events/call.d.ts +41 -0
- package/lib/events/call.js +14 -0
- package/lib/events/core.d.ts +20 -0
- package/lib/events/core.js +28 -0
- package/lib/events/device.d.ts +40 -0
- package/lib/events/device.js +28 -0
- package/lib/events/iframe.d.ts +39 -0
- package/lib/events/iframe.js +18 -0
- package/lib/events/index.d.ts +62 -0
- package/lib/events/index.js +21 -0
- package/lib/events/popup.d.ts +51 -0
- package/lib/events/popup.js +22 -0
- package/lib/events/transport.d.ts +62 -0
- package/lib/events/transport.js +21 -0
- package/lib/events/ui-promise.d.ts +12 -0
- package/lib/events/ui-promise.js +3 -0
- package/lib/events/ui-request.d.ts +180 -0
- package/lib/events/ui-request.js +50 -0
- package/lib/events/ui-response.d.ts +97 -0
- package/lib/events/ui-response.js +25 -0
- package/lib/exports.d.ts +5 -0
- package/lib/exports.js +10 -0
- package/lib/factory.d.ts +20 -0
- package/lib/factory.js +122 -0
- package/lib/index-browser.d.ts +4 -0
- package/lib/index-browser.js +29 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +236 -0
- package/lib/types/account.d.ts +37 -0
- package/lib/types/account.js +3 -0
- package/lib/types/api/applyFlags.d.ts +4 -0
- package/lib/types/api/applyFlags.js +3 -0
- package/lib/types/api/applySettings.d.ts +4 -0
- package/lib/types/api/applySettings.js +3 -0
- package/lib/types/api/authorizeCoinJoin.d.ts +14 -0
- package/lib/types/api/authorizeCoinJoin.js +3 -0
- package/lib/types/api/backupDevice.d.ts +4 -0
- package/lib/types/api/backupDevice.js +3 -0
- package/lib/types/api/binanceGetAddress.d.ts +4 -0
- package/lib/types/api/binanceGetAddress.js +3 -0
- package/lib/types/api/binanceGetPublicKey.d.ts +4 -0
- package/lib/types/api/binanceGetPublicKey.js +3 -0
- package/lib/types/api/binanceSignTransaction.d.ts +31 -0
- package/lib/types/api/binanceSignTransaction.js +3 -0
- package/lib/types/api/blockchainDisconnect.d.ts +5 -0
- package/lib/types/api/blockchainDisconnect.js +3 -0
- package/lib/types/api/blockchainEstimateFee.d.ts +29 -0
- package/lib/types/api/blockchainEstimateFee.js +3 -0
- package/lib/types/api/blockchainGetAccountBalanceHistory.d.ts +4 -0
- package/lib/types/api/blockchainGetAccountBalanceHistory.js +3 -0
- package/lib/types/api/blockchainGetCurrentFiatRates.d.ts +4 -0
- package/lib/types/api/blockchainGetCurrentFiatRates.js +3 -0
- package/lib/types/api/blockchainGetFiatRatesForTimestamps.d.ts +4 -0
- package/lib/types/api/blockchainGetFiatRatesForTimestamps.js +3 -0
- package/lib/types/api/blockchainGetTransactions.d.ts +7 -0
- package/lib/types/api/blockchainGetTransactions.js +3 -0
- package/lib/types/api/blockchainSetCustomBackend.d.ts +7 -0
- package/lib/types/api/blockchainSetCustomBackend.js +3 -0
- package/lib/types/api/blockchainSubscribe.d.ts +7 -0
- package/lib/types/api/blockchainSubscribe.js +3 -0
- package/lib/types/api/blockchainSubscribeFiatRates.d.ts +7 -0
- package/lib/types/api/blockchainSubscribeFiatRates.js +3 -0
- package/lib/types/api/blockchainUnsubscribe.d.ts +5 -0
- package/lib/types/api/blockchainUnsubscribe.js +3 -0
- package/lib/types/api/blockchainUnsubscribeFiatRates.d.ts +5 -0
- package/lib/types/api/blockchainUnsubscribeFiatRates.js +3 -0
- package/lib/types/api/cancel.d.ts +2 -0
- package/lib/types/api/cancel.js +3 -0
- package/lib/types/api/cardanoGetAddress.d.ts +35 -0
- package/lib/types/api/cardanoGetAddress.js +3 -0
- package/lib/types/api/cardanoGetNativeScriptHash.d.ts +21 -0
- package/lib/types/api/cardanoGetNativeScriptHash.js +3 -0
- package/lib/types/api/cardanoGetPublicKey.d.ts +16 -0
- package/lib/types/api/cardanoGetPublicKey.js +3 -0
- package/lib/types/api/cardanoSignTransaction.d.ts +130 -0
- package/lib/types/api/cardanoSignTransaction.js +3 -0
- package/lib/types/api/changePin.d.ts +4 -0
- package/lib/types/api/changePin.js +3 -0
- package/lib/types/api/cipherKeyValue.d.ts +17 -0
- package/lib/types/api/cipherKeyValue.js +3 -0
- package/lib/types/api/composeTransaction.d.ts +92 -0
- package/lib/types/api/composeTransaction.js +3 -0
- package/lib/types/api/customMessage.d.ts +12 -0
- package/lib/types/api/customMessage.js +3 -0
- package/lib/types/api/disableWebUSB.d.ts +2 -0
- package/lib/types/api/disableWebUSB.js +3 -0
- package/lib/types/api/dispose.d.ts +2 -0
- package/lib/types/api/dispose.js +3 -0
- package/lib/types/api/eosGetPublicKey.d.ts +14 -0
- package/lib/types/api/eosGetPublicKey.js +3 -0
- package/lib/types/api/eosSignTransaction.d.ts +111 -0
- package/lib/types/api/eosSignTransaction.js +3 -0
- package/lib/types/api/ethereumGetAddress.d.ts +4 -0
- package/lib/types/api/ethereumGetAddress.js +3 -0
- package/lib/types/api/ethereumGetPublicKey.d.ts +5 -0
- package/lib/types/api/ethereumGetPublicKey.js +3 -0
- package/lib/types/api/ethereumSignMessage.d.ts +9 -0
- package/lib/types/api/ethereumSignMessage.js +3 -0
- package/lib/types/api/ethereumSignTransaction.d.ts +40 -0
- package/lib/types/api/ethereumSignTransaction.js +3 -0
- package/lib/types/api/ethereumSignTypedData.d.ts +42 -0
- package/lib/types/api/ethereumSignTypedData.js +3 -0
- package/lib/types/api/ethereumVerifyMessage.d.ts +10 -0
- package/lib/types/api/ethereumVerifyMessage.js +3 -0
- package/lib/types/api/firmwareUpdate.d.ts +14 -0
- package/lib/types/api/firmwareUpdate.js +3 -0
- package/lib/types/api/getAccountInfo.d.ts +14 -0
- package/lib/types/api/getAccountInfo.js +3 -0
- package/lib/types/api/getAddress.d.ts +13 -0
- package/lib/types/api/getAddress.js +3 -0
- package/lib/types/api/getCoinInfo.d.ts +4 -0
- package/lib/types/api/getCoinInfo.js +3 -0
- package/lib/types/api/getDeviceState.d.ts +6 -0
- package/lib/types/api/getDeviceState.js +3 -0
- package/lib/types/api/getFeatures.d.ts +4 -0
- package/lib/types/api/getFeatures.js +3 -0
- package/lib/types/api/getOwnershipId.d.ts +15 -0
- package/lib/types/api/getOwnershipId.js +3 -0
- package/lib/types/api/getOwnershipProof.d.ts +19 -0
- package/lib/types/api/getOwnershipProof.js +3 -0
- package/lib/types/api/getPublicKey.d.ts +19 -0
- package/lib/types/api/getPublicKey.js +3 -0
- package/lib/types/api/getSettings.d.ts +4 -0
- package/lib/types/api/getSettings.js +3 -0
- package/lib/types/api/index.d.ts +149 -0
- package/lib/types/api/index.js +3 -0
- package/lib/types/api/init.d.ts +5 -0
- package/lib/types/api/init.js +3 -0
- package/lib/types/api/manifest.d.ts +3 -0
- package/lib/types/api/manifest.js +3 -0
- package/lib/types/api/nemGetAddress.d.ts +7 -0
- package/lib/types/api/nemGetAddress.js +3 -0
- package/lib/types/api/nemSignTransaction.d.ts +92 -0
- package/lib/types/api/nemSignTransaction.js +3 -0
- package/lib/types/api/off.d.ts +11 -0
- package/lib/types/api/off.js +3 -0
- package/lib/types/api/on.d.ts +14 -0
- package/lib/types/api/on.js +3 -0
- package/lib/types/api/pushTransaction.d.ts +10 -0
- package/lib/types/api/pushTransaction.js +3 -0
- package/lib/types/api/rebootToBootloader.d.ts +4 -0
- package/lib/types/api/rebootToBootloader.js +3 -0
- package/lib/types/api/recoveryDevice.d.ts +7 -0
- package/lib/types/api/recoveryDevice.js +3 -0
- package/lib/types/api/removeAllListeners.d.ts +3 -0
- package/lib/types/api/removeAllListeners.js +3 -0
- package/lib/types/api/renderWebUSBButton.d.ts +2 -0
- package/lib/types/api/renderWebUSBButton.js +3 -0
- package/lib/types/api/requestLogin.d.ts +20 -0
- package/lib/types/api/requestLogin.js +3 -0
- package/lib/types/api/resetDevice.d.ts +16 -0
- package/lib/types/api/resetDevice.js +3 -0
- package/lib/types/api/rippleGetAddress.d.ts +4 -0
- package/lib/types/api/rippleGetAddress.js +3 -0
- package/lib/types/api/rippleSignTransaction.d.ts +23 -0
- package/lib/types/api/rippleSignTransaction.js +3 -0
- package/lib/types/api/setProxy.d.ts +9 -0
- package/lib/types/api/setProxy.js +3 -0
- package/lib/types/api/signMessage.d.ts +11 -0
- package/lib/types/api/signMessage.js +3 -0
- package/lib/types/api/signTransaction.d.ts +70 -0
- package/lib/types/api/signTransaction.js +3 -0
- package/lib/types/api/stellarGetAddress.d.ts +4 -0
- package/lib/types/api/stellarGetAddress.js +3 -0
- package/lib/types/api/stellarSignTransaction.d.ts +182 -0
- package/lib/types/api/stellarSignTransaction.js +3 -0
- package/lib/types/api/tezosGetAddress.d.ts +4 -0
- package/lib/types/api/tezosGetAddress.js +3 -0
- package/lib/types/api/tezosGetPublicKey.d.ts +4 -0
- package/lib/types/api/tezosGetPublicKey.js +3 -0
- package/lib/types/api/tezosSignTransaction.d.ts +61 -0
- package/lib/types/api/tezosSignTransaction.js +3 -0
- package/lib/types/api/uiResponse.d.ts +3 -0
- package/lib/types/api/uiResponse.js +3 -0
- package/lib/types/api/verifyMessage.d.ts +11 -0
- package/lib/types/api/verifyMessage.js +3 -0
- package/lib/types/api/wipeDevice.d.ts +4 -0
- package/lib/types/api/wipeDevice.js +3 -0
- package/lib/types/coinInfo.d.ts +79 -0
- package/lib/types/coinInfo.js +3 -0
- package/lib/types/device.d.ts +92 -0
- package/lib/types/device.js +3 -0
- package/lib/types/firmware.d.ts +36 -0
- package/lib/types/firmware.js +3 -0
- package/lib/types/index.d.ts +15 -0
- package/lib/types/index.js +11 -0
- package/lib/types/params.d.ts +56 -0
- package/lib/types/params.js +3 -0
- package/lib/types/settings.d.ts +34 -0
- package/lib/types/settings.js +3 -0
- package/lib/types/utils.d.ts +15 -0
- package/lib/types/utils.js +3 -0
- package/lib/utils/__fixtures__/accountUtils.d.ts +4 -0
- package/lib/utils/__fixtures__/accountUtils.js +32 -0
- package/lib/utils/__fixtures__/addressUtils.d.ts +10 -0
- package/lib/utils/__fixtures__/addressUtils.js +214 -0
- package/lib/utils/__fixtures__/ethereumUtils.d.ts +3 -0
- package/lib/utils/__fixtures__/ethereumUtils.js +20 -0
- package/lib/utils/__fixtures__/formatUtils.d.ts +3 -0
- package/lib/utils/__fixtures__/formatUtils.js +15 -0
- package/lib/utils/__fixtures__/hdnodeUtils.d.ts +186 -0
- package/lib/utils/__fixtures__/hdnodeUtils.js +206 -0
- package/lib/utils/accountUtils.d.ts +11 -0
- package/lib/utils/accountUtils.js +99 -0
- package/lib/utils/addressUtils.d.ts +3 -0
- package/lib/utils/addressUtils.js +32 -0
- package/lib/utils/assets-browser.d.ts +2 -0
- package/lib/utils/assets-browser.js +21 -0
- package/lib/utils/assets.d.ts +2 -0
- package/lib/utils/assets.js +28 -0
- package/lib/utils/bip39.d.ts +3 -0
- package/lib/utils/bip39.js +2053 -0
- package/lib/utils/browserUtils.d.ts +21 -0
- package/lib/utils/browserUtils.js +100 -0
- package/lib/utils/bufferUtils.d.ts +3 -0
- package/lib/utils/bufferUtils.js +11 -0
- package/lib/utils/debug.d.ts +24 -0
- package/lib/utils/debug.js +90 -0
- package/lib/utils/deferred.d.ts +18 -0
- package/lib/utils/deferred.js +66 -0
- package/lib/utils/deviceFeaturesUtils.d.ts +6 -0
- package/lib/utils/deviceFeaturesUtils.js +115 -0
- package/lib/utils/ethereumUtils.d.ts +3 -0
- package/lib/utils/ethereumUtils.js +12 -0
- package/lib/utils/firmwareUtils.d.ts +7 -0
- package/lib/utils/firmwareUtils.js +28 -0
- package/lib/utils/formatUtils.d.ts +8 -0
- package/lib/utils/formatUtils.js +57 -0
- package/lib/utils/hdnodeUtils.d.ts +8 -0
- package/lib/utils/hdnodeUtils.js +80 -0
- package/lib/utils/interactionTimeout.d.ts +10 -0
- package/lib/utils/interactionTimeout.js +34 -0
- package/lib/utils/objectUtils.d.ts +10 -0
- package/lib/utils/objectUtils.js +37 -0
- package/lib/utils/pathUtils.d.ts +20 -0
- package/lib/utils/pathUtils.js +159 -0
- package/lib/utils/promiseUtils.d.ts +2 -0
- package/lib/utils/promiseUtils.js +8 -0
- package/lib/utils/urlUtils.d.ts +5 -0
- package/lib/utils/urlUtils.js +27 -0
- package/lib/utils/versionUtils.d.ts +6 -0
- package/lib/utils/versionUtils.js +72 -0
- package/lib/utils/windowsUtils.d.ts +2 -0
- package/lib/utils/windowsUtils.js +6 -0
- package/lib/workers/RNUsbPlugin.d.ts +31 -0
- package/lib/workers/RNUsbPlugin.js +65 -0
- package/lib/workers/workers-browser.d.ts +8 -0
- package/lib/workers/workers-browser.js +19 -0
- package/lib/workers/workers-react-native.d.ts +8 -0
- package/lib/workers/workers-react-native.js +19 -0
- package/lib/workers/workers.d.ts +10 -0
- package/lib/workers/workers.js +17 -0
- package/package.json +62 -0
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Device = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const events_1 = (0, tslib_1.__importDefault)(require("events"));
|
|
6
|
+
const DeviceCommands_1 = require("./DeviceCommands");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const events_2 = require("../events");
|
|
9
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
10
|
+
const firmwareInfo_1 = require("../data/firmwareInfo");
|
|
11
|
+
const deviceFeaturesUtils_1 = require("../utils/deviceFeaturesUtils");
|
|
12
|
+
const versionUtils_1 = require("../utils/versionUtils");
|
|
13
|
+
const deferred_1 = require("../utils/deferred");
|
|
14
|
+
const debug_1 = require("../utils/debug");
|
|
15
|
+
const _log = (0, debug_1.initLog)('Device');
|
|
16
|
+
const parseRunOptions = (options) => {
|
|
17
|
+
if (!options)
|
|
18
|
+
options = {};
|
|
19
|
+
return options;
|
|
20
|
+
};
|
|
21
|
+
class Device extends events_1.default {
|
|
22
|
+
constructor(transport, descriptor) {
|
|
23
|
+
super();
|
|
24
|
+
this.featuresNeedsReload = false;
|
|
25
|
+
this.deferredActions = {};
|
|
26
|
+
this.loaded = false;
|
|
27
|
+
this.inconsistent = false;
|
|
28
|
+
this.keepSession = false;
|
|
29
|
+
this.instance = 0;
|
|
30
|
+
this.internalState = [];
|
|
31
|
+
this.externalState = [];
|
|
32
|
+
this.unavailableCapabilities = {};
|
|
33
|
+
this.networkTypeState = [];
|
|
34
|
+
this.transport = transport;
|
|
35
|
+
this.originalDescriptor = descriptor;
|
|
36
|
+
this.firstRunPromise = (0, deferred_1.create)();
|
|
37
|
+
}
|
|
38
|
+
static fromDescriptor(transport, originalDescriptor) {
|
|
39
|
+
const descriptor = { ...originalDescriptor, session: null };
|
|
40
|
+
try {
|
|
41
|
+
const device = new Device(transport, descriptor);
|
|
42
|
+
return device;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
_log.error('Device.fromDescriptor', error);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
static createUnacquired(transport, descriptor, unreadableError) {
|
|
50
|
+
const device = new Device(transport, descriptor);
|
|
51
|
+
device.unreadableError = unreadableError;
|
|
52
|
+
return device;
|
|
53
|
+
}
|
|
54
|
+
async acquire() {
|
|
55
|
+
this.deferredActions[events_2.DEVICE.ACQUIRE] = (0, deferred_1.create)();
|
|
56
|
+
this.deferredActions[events_2.DEVICE.ACQUIRED] = (0, deferred_1.create)();
|
|
57
|
+
try {
|
|
58
|
+
const sessionID = await this.transport.acquire({
|
|
59
|
+
path: this.originalDescriptor.path,
|
|
60
|
+
previous: this.originalDescriptor.session,
|
|
61
|
+
}, false);
|
|
62
|
+
_log.debug('Expected session id:', sessionID);
|
|
63
|
+
this.activitySessionID = sessionID;
|
|
64
|
+
this.deferredActions[events_2.DEVICE.ACQUIRED].resolve();
|
|
65
|
+
delete this.deferredActions[events_2.DEVICE.ACQUIRED];
|
|
66
|
+
if (this.commands) {
|
|
67
|
+
this.commands.dispose();
|
|
68
|
+
}
|
|
69
|
+
this.commands = new DeviceCommands_1.DeviceCommands(this, this.transport, sessionID);
|
|
70
|
+
this.deferredActions[events_2.DEVICE.RELEASE] = (0, deferred_1.create)();
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
this.deferredActions[events_2.DEVICE.ACQUIRED].resolve();
|
|
74
|
+
delete this.deferredActions[events_2.DEVICE.ACQUIRED];
|
|
75
|
+
if (this.runPromise) {
|
|
76
|
+
this.runPromise.reject(error);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
this.runPromise = null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async release() {
|
|
85
|
+
if (this.isUsedHere() && !this.keepSession && this.activitySessionID) {
|
|
86
|
+
if (this.commands) {
|
|
87
|
+
this.commands.dispose();
|
|
88
|
+
if (this.commands.callPromise) {
|
|
89
|
+
try {
|
|
90
|
+
await this.commands.callPromise;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.commands.callPromise = undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
await this.transport.release(this.activitySessionID, false, false);
|
|
99
|
+
if (this.deferredActions[events_2.DEVICE.RELEASE])
|
|
100
|
+
await this.deferredActions[events_2.DEVICE.RELEASE].promise;
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async cleanup() {
|
|
107
|
+
this.removeAllListeners();
|
|
108
|
+
this.runPromise = null;
|
|
109
|
+
await this.release();
|
|
110
|
+
}
|
|
111
|
+
run(fn, options) {
|
|
112
|
+
if (this.runPromise) {
|
|
113
|
+
_log.warn('Previous call is still running');
|
|
114
|
+
throw constants_1.ERRORS.TypedError('Device_CallInProgress');
|
|
115
|
+
}
|
|
116
|
+
options = parseRunOptions(options);
|
|
117
|
+
this.runPromise = (0, deferred_1.create)(this._runInner.bind(this, fn, options));
|
|
118
|
+
return this.runPromise.promise;
|
|
119
|
+
}
|
|
120
|
+
async override(error) {
|
|
121
|
+
if (this.deferredActions[events_2.DEVICE.ACQUIRE]) {
|
|
122
|
+
await this.deferredActions[events_2.DEVICE.ACQUIRE].promise;
|
|
123
|
+
}
|
|
124
|
+
if (this.runPromise) {
|
|
125
|
+
this.runPromise.reject(error);
|
|
126
|
+
this.runPromise = null;
|
|
127
|
+
}
|
|
128
|
+
if (!this.keepSession && this.deferredActions[events_2.DEVICE.RELEASE]) {
|
|
129
|
+
await this.deferredActions[events_2.DEVICE.RELEASE].promise;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async interruptionFromUser(error) {
|
|
133
|
+
_log.debug('interruptionFromUser');
|
|
134
|
+
if (this.commands) {
|
|
135
|
+
await this.commands.cancel();
|
|
136
|
+
this.commands.dispose();
|
|
137
|
+
}
|
|
138
|
+
if (this.runPromise) {
|
|
139
|
+
this.runPromise.reject(error);
|
|
140
|
+
this.runPromise = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
interruptionFromOutside() {
|
|
144
|
+
_log.debug('interruptionFromOutside');
|
|
145
|
+
if (this.commands) {
|
|
146
|
+
this.commands.dispose();
|
|
147
|
+
}
|
|
148
|
+
if (this.runPromise) {
|
|
149
|
+
this.runPromise.reject(constants_1.ERRORS.TypedError('Device_UsedElsewhere'));
|
|
150
|
+
this.runPromise = null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async _runInner(fn, options) {
|
|
154
|
+
if (!this.isUsedHere() || this.commands.disposed || !this.getExternalState()) {
|
|
155
|
+
await this.acquire();
|
|
156
|
+
try {
|
|
157
|
+
if (fn) {
|
|
158
|
+
await this.initialize(!!options.useEmptyPassphrase, !!options.useCardanoDerivation);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
await Promise.race([
|
|
162
|
+
this.getFeatures(),
|
|
163
|
+
new Promise((_resolve, reject) => setTimeout(() => reject(new Error('GetFeatures timeout')), 3000)),
|
|
164
|
+
]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (!this.inconsistent && error.message === 'GetFeatures timeout') {
|
|
169
|
+
this.inconsistent = true;
|
|
170
|
+
return this._runInner(() => Promise.resolve({}), options);
|
|
171
|
+
}
|
|
172
|
+
this.inconsistent = true;
|
|
173
|
+
await this.deferredActions[events_2.DEVICE.ACQUIRE].promise;
|
|
174
|
+
this.runPromise = null;
|
|
175
|
+
return Promise.reject(constants_1.ERRORS.TypedError('Device_InitializeFailed', `Initialize failed: ${error.message}, code: ${error.code}`));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (options.keepSession) {
|
|
179
|
+
this.keepSession = true;
|
|
180
|
+
}
|
|
181
|
+
await this.deferredActions[events_2.DEVICE.ACQUIRE].promise;
|
|
182
|
+
if (fn) {
|
|
183
|
+
await fn();
|
|
184
|
+
}
|
|
185
|
+
if (this.loaded && this.features && !options.skipFinalReload) {
|
|
186
|
+
await this.getFeatures();
|
|
187
|
+
}
|
|
188
|
+
if ((!this.keepSession && typeof options.keepSession !== 'boolean') ||
|
|
189
|
+
options.keepSession === false) {
|
|
190
|
+
this.keepSession = false;
|
|
191
|
+
await this.release();
|
|
192
|
+
}
|
|
193
|
+
if (this.runPromise) {
|
|
194
|
+
this.runPromise.resolve();
|
|
195
|
+
}
|
|
196
|
+
this.runPromise = null;
|
|
197
|
+
if (!this.loaded) {
|
|
198
|
+
this.loaded = true;
|
|
199
|
+
this.firstRunPromise.resolve(true);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
getCommands() {
|
|
203
|
+
return this.commands;
|
|
204
|
+
}
|
|
205
|
+
setInstance(instance = 0) {
|
|
206
|
+
if (this.instance !== instance) {
|
|
207
|
+
if (this.keepSession) {
|
|
208
|
+
this.activitySessionID = null;
|
|
209
|
+
this.keepSession = false;
|
|
210
|
+
}
|
|
211
|
+
if (this.isT1() && this.useLegacyPassphrase()) {
|
|
212
|
+
this.setInternalState(undefined);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
this.instance = instance;
|
|
216
|
+
}
|
|
217
|
+
getInstance() {
|
|
218
|
+
return this.instance;
|
|
219
|
+
}
|
|
220
|
+
setInternalState(state) {
|
|
221
|
+
if (typeof state !== 'string') {
|
|
222
|
+
delete this.internalState[this.instance];
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
this.internalState[this.instance] = state;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
getInternalState() {
|
|
229
|
+
return this.internalState[this.instance];
|
|
230
|
+
}
|
|
231
|
+
setExternalState(state) {
|
|
232
|
+
if (typeof state !== 'string') {
|
|
233
|
+
delete this.internalState[this.instance];
|
|
234
|
+
delete this.externalState[this.instance];
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
this.externalState[this.instance] = state;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
getExternalState() {
|
|
241
|
+
return this.externalState[this.instance];
|
|
242
|
+
}
|
|
243
|
+
async validateState(networkType) {
|
|
244
|
+
if (!this.features)
|
|
245
|
+
return;
|
|
246
|
+
const altMode = this._altModeChange(networkType);
|
|
247
|
+
const expectedState = altMode ? undefined : this.getExternalState();
|
|
248
|
+
const state = await this.commands.getDeviceState(networkType);
|
|
249
|
+
const uniqueState = `${state}@${this.features.device_id || 'device_id'}:${this.instance}`;
|
|
250
|
+
if (!this.useLegacyPassphrase() && this.features.session_id) {
|
|
251
|
+
this.setInternalState(this.features.session_id);
|
|
252
|
+
}
|
|
253
|
+
if (expectedState && expectedState !== uniqueState) {
|
|
254
|
+
return uniqueState;
|
|
255
|
+
}
|
|
256
|
+
if (!expectedState) {
|
|
257
|
+
this.setExternalState(uniqueState);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
useLegacyPassphrase() {
|
|
261
|
+
return !this.atLeast(['1.9.0', '2.3.0']);
|
|
262
|
+
}
|
|
263
|
+
async initialize(useEmptyPassphrase, useCardanoDerivation) {
|
|
264
|
+
let payload;
|
|
265
|
+
if (this.features) {
|
|
266
|
+
const legacy = this.useLegacyPassphrase();
|
|
267
|
+
const internalState = this.getInternalState();
|
|
268
|
+
payload = {};
|
|
269
|
+
payload.derive_cardano = useCardanoDerivation;
|
|
270
|
+
if (!legacy && internalState) {
|
|
271
|
+
payload.session_id = internalState;
|
|
272
|
+
}
|
|
273
|
+
if (legacy && !this.isT1()) {
|
|
274
|
+
payload.state = internalState;
|
|
275
|
+
if (useEmptyPassphrase) {
|
|
276
|
+
payload._skip_passphrase = useEmptyPassphrase;
|
|
277
|
+
payload.state = null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
const { message } = await this.commands.typedCall('Initialize', 'Features', payload);
|
|
282
|
+
this._updateFeatures(message);
|
|
283
|
+
}
|
|
284
|
+
async getFeatures() {
|
|
285
|
+
const { message } = await this.commands.typedCall('GetFeatures', 'Features', {});
|
|
286
|
+
this._updateFeatures(message);
|
|
287
|
+
}
|
|
288
|
+
_updateFeatures(feat) {
|
|
289
|
+
const capabilities = (0, deviceFeaturesUtils_1.parseCapabilities)(feat);
|
|
290
|
+
feat.capabilities = capabilities;
|
|
291
|
+
const version = [feat.major_version, feat.minor_version, feat.patch_version];
|
|
292
|
+
const capabilitiesDidChange = this.features &&
|
|
293
|
+
this.features.capabilities &&
|
|
294
|
+
this.features.capabilities.join('') !== capabilities.join('');
|
|
295
|
+
if ((0, versionUtils_1.versionCompare)(version, this.getVersion()) !== 0 || capabilitiesDidChange) {
|
|
296
|
+
this.unavailableCapabilities = (0, deviceFeaturesUtils_1.getUnavailableCapabilities)(feat, (0, coinInfo_1.getAllNetworks)());
|
|
297
|
+
this.firmwareStatus = (0, firmwareInfo_1.getFirmwareStatus)(feat);
|
|
298
|
+
this.firmwareRelease = (0, firmwareInfo_1.getRelease)(feat);
|
|
299
|
+
}
|
|
300
|
+
if (this.features && this.features.session_id && !feat.session_id) {
|
|
301
|
+
feat.session_id = this.features.session_id;
|
|
302
|
+
}
|
|
303
|
+
feat.unlocked = feat.unlocked || true;
|
|
304
|
+
const revision = (0, deviceFeaturesUtils_1.parseRevision)(feat);
|
|
305
|
+
feat.revision = revision;
|
|
306
|
+
this.features = feat;
|
|
307
|
+
this.featuresNeedsReload = false;
|
|
308
|
+
}
|
|
309
|
+
isUnacquired() {
|
|
310
|
+
return this.features === undefined;
|
|
311
|
+
}
|
|
312
|
+
async updateDescriptor(upcomingDescriptor) {
|
|
313
|
+
const originalSession = this.originalDescriptor.session;
|
|
314
|
+
const upcomingSession = upcomingDescriptor.session;
|
|
315
|
+
_log.debug('updateDescriptor', 'currentSession', originalSession, 'upcoming', upcomingSession, 'lastUsedID', this.activitySessionID);
|
|
316
|
+
if (!originalSession && !upcomingSession && !this.activitySessionID) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (this.deferredActions[events_2.DEVICE.ACQUIRED]) {
|
|
320
|
+
await this.deferredActions[events_2.DEVICE.ACQUIRED].promise;
|
|
321
|
+
}
|
|
322
|
+
if (!upcomingSession) {
|
|
323
|
+
if (this.listeners(events_2.DEVICE.ACQUIRED).length > 0) {
|
|
324
|
+
this.emit(events_2.DEVICE.ACQUIRED);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const methodStillRunning = this.commands && !this.commands.disposed;
|
|
328
|
+
if (!upcomingSession && !methodStillRunning) {
|
|
329
|
+
if (originalSession === this.activitySessionID) {
|
|
330
|
+
_log.debug('Session released by this app');
|
|
331
|
+
if (this.deferredActions[events_2.DEVICE.RELEASE]) {
|
|
332
|
+
this.deferredActions[events_2.DEVICE.RELEASE].resolve();
|
|
333
|
+
delete this.deferredActions[events_2.DEVICE.RELEASE];
|
|
334
|
+
}
|
|
335
|
+
this.activitySessionID = null;
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
_log.debug('Session released by other app');
|
|
339
|
+
this.featuresNeedsReload = true;
|
|
340
|
+
}
|
|
341
|
+
this.keepSession = false;
|
|
342
|
+
}
|
|
343
|
+
else if (upcomingSession === this.activitySessionID) {
|
|
344
|
+
_log.debug('Session acquired by this app');
|
|
345
|
+
if (this.deferredActions[events_2.DEVICE.ACQUIRE]) {
|
|
346
|
+
this.deferredActions[events_2.DEVICE.ACQUIRE].resolve();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
_log.debug('Session acquired by other app');
|
|
351
|
+
this.interruptionFromOutside();
|
|
352
|
+
}
|
|
353
|
+
this.originalDescriptor = upcomingDescriptor;
|
|
354
|
+
}
|
|
355
|
+
disconnect() {
|
|
356
|
+
_log.debug('Disconnect cleanup');
|
|
357
|
+
if (this.deferredActions[events_2.DEVICE.RELEASE]) {
|
|
358
|
+
this.deferredActions[events_2.DEVICE.RELEASE].resolve();
|
|
359
|
+
delete this.deferredActions[events_2.DEVICE.RELEASE];
|
|
360
|
+
}
|
|
361
|
+
this.interruptionFromUser(constants_1.ERRORS.TypedError('Device_Disconnected'));
|
|
362
|
+
this.runPromise = null;
|
|
363
|
+
}
|
|
364
|
+
isBootloader() {
|
|
365
|
+
return this.features && !!this.features.bootloader_mode;
|
|
366
|
+
}
|
|
367
|
+
isInitialized() {
|
|
368
|
+
return this.features && !!this.features.initialized;
|
|
369
|
+
}
|
|
370
|
+
isSeedless() {
|
|
371
|
+
return this.features && !!this.features.no_backup;
|
|
372
|
+
}
|
|
373
|
+
isInconsistent() {
|
|
374
|
+
return this.inconsistent;
|
|
375
|
+
}
|
|
376
|
+
getVersion() {
|
|
377
|
+
if (!this.features)
|
|
378
|
+
return [];
|
|
379
|
+
return [
|
|
380
|
+
this.features.major_version,
|
|
381
|
+
this.features.minor_version,
|
|
382
|
+
this.features.patch_version,
|
|
383
|
+
];
|
|
384
|
+
}
|
|
385
|
+
atLeast(versions) {
|
|
386
|
+
if (!this.features)
|
|
387
|
+
return false;
|
|
388
|
+
const modelVersion = typeof versions === 'string' ? versions : versions[this.features.major_version - 1];
|
|
389
|
+
return (0, versionUtils_1.versionCompare)(this.getVersion(), modelVersion) >= 0;
|
|
390
|
+
}
|
|
391
|
+
isUsed() {
|
|
392
|
+
return typeof this.originalDescriptor.session === 'string';
|
|
393
|
+
}
|
|
394
|
+
isUsedHere() {
|
|
395
|
+
return this.isUsed() && this.originalDescriptor.session === this.activitySessionID;
|
|
396
|
+
}
|
|
397
|
+
isUsedElsewhere() {
|
|
398
|
+
return this.isUsed() && !this.isUsedHere();
|
|
399
|
+
}
|
|
400
|
+
isRunning() {
|
|
401
|
+
return !!this.runPromise;
|
|
402
|
+
}
|
|
403
|
+
isLoaded() {
|
|
404
|
+
return this.loaded;
|
|
405
|
+
}
|
|
406
|
+
waitForFirstRun() {
|
|
407
|
+
return this.firstRunPromise.promise;
|
|
408
|
+
}
|
|
409
|
+
getDevicePath() {
|
|
410
|
+
return this.originalDescriptor.path;
|
|
411
|
+
}
|
|
412
|
+
needAuthentication() {
|
|
413
|
+
if (this.isUnacquired() || this.isUsedElsewhere() || this.featuresNeedsReload)
|
|
414
|
+
return true;
|
|
415
|
+
if (this.features.bootloader_mode || !this.features.initialized)
|
|
416
|
+
return true;
|
|
417
|
+
const pin = this.features.pin_protection ? !!this.features.unlocked : true;
|
|
418
|
+
const pass = this.features.passphrase_protection ? this.features.passphrase_cached : true;
|
|
419
|
+
return pin && pass;
|
|
420
|
+
}
|
|
421
|
+
isT1() {
|
|
422
|
+
return this.features ? this.features.major_version === 1 : false;
|
|
423
|
+
}
|
|
424
|
+
hasUnexpectedMode(allow, require) {
|
|
425
|
+
if (this.features) {
|
|
426
|
+
if (this.isBootloader() && !allow.includes(events_2.UI.BOOTLOADER)) {
|
|
427
|
+
return events_2.UI.BOOTLOADER;
|
|
428
|
+
}
|
|
429
|
+
if (!this.isInitialized() && !allow.includes(events_2.UI.INITIALIZE)) {
|
|
430
|
+
return events_2.UI.INITIALIZE;
|
|
431
|
+
}
|
|
432
|
+
if (this.isSeedless() && !allow.includes(events_2.UI.SEEDLESS)) {
|
|
433
|
+
return events_2.UI.SEEDLESS;
|
|
434
|
+
}
|
|
435
|
+
if (!this.isBootloader() && require.includes(events_2.UI.BOOTLOADER)) {
|
|
436
|
+
return events_2.UI.NOT_IN_BOOTLOADER;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
dispose() {
|
|
442
|
+
this.removeAllListeners();
|
|
443
|
+
if (this.isUsedHere() && this.activitySessionID) {
|
|
444
|
+
try {
|
|
445
|
+
if (this.commands) {
|
|
446
|
+
this.commands.cancel();
|
|
447
|
+
}
|
|
448
|
+
this.transport.release(this.activitySessionID, true, false);
|
|
449
|
+
}
|
|
450
|
+
catch (err) {
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
getMode() {
|
|
455
|
+
if (this.features.bootloader_mode)
|
|
456
|
+
return 'bootloader';
|
|
457
|
+
if (!this.features.initialized)
|
|
458
|
+
return 'initialize';
|
|
459
|
+
if (this.features.no_backup)
|
|
460
|
+
return 'seedless';
|
|
461
|
+
return 'normal';
|
|
462
|
+
}
|
|
463
|
+
toMessageObject() {
|
|
464
|
+
if (this.unreadableError) {
|
|
465
|
+
return {
|
|
466
|
+
type: 'unreadable',
|
|
467
|
+
path: this.originalDescriptor.path,
|
|
468
|
+
error: this.unreadableError,
|
|
469
|
+
label: 'Unreadable device',
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
if (this.isUnacquired()) {
|
|
473
|
+
return {
|
|
474
|
+
type: 'unacquired',
|
|
475
|
+
path: this.originalDescriptor.path,
|
|
476
|
+
label: 'Unacquired device',
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
const defaultLabel = 'My Trezor';
|
|
480
|
+
const label = this.features.label === '' || !this.features.label ? defaultLabel : this.features.label;
|
|
481
|
+
let status = this.isUsedElsewhere() ? 'occupied' : 'available';
|
|
482
|
+
if (this.featuresNeedsReload)
|
|
483
|
+
status = 'used';
|
|
484
|
+
return {
|
|
485
|
+
type: 'acquired',
|
|
486
|
+
id: this.features.device_id || null,
|
|
487
|
+
path: this.originalDescriptor.path,
|
|
488
|
+
label,
|
|
489
|
+
state: this.getExternalState(),
|
|
490
|
+
status,
|
|
491
|
+
mode: this.getMode(),
|
|
492
|
+
firmware: this.firmwareStatus,
|
|
493
|
+
firmwareRelease: this.firmwareRelease,
|
|
494
|
+
features: this.features,
|
|
495
|
+
unavailableCapabilities: this.unavailableCapabilities,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
_getNetworkTypeState() {
|
|
499
|
+
return this.networkTypeState[this.instance];
|
|
500
|
+
}
|
|
501
|
+
_setNetworkTypeState(networkType) {
|
|
502
|
+
if (typeof networkType !== 'string') {
|
|
503
|
+
delete this.networkTypeState[this.instance];
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
this.networkTypeState[this.instance] = networkType;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
_altModeChange(networkType) {
|
|
510
|
+
const prevAltMode = this._isAltModeNetworkType(this._getNetworkTypeState());
|
|
511
|
+
const nextAltMode = this._isAltModeNetworkType(networkType);
|
|
512
|
+
this._setNetworkTypeState(networkType);
|
|
513
|
+
return prevAltMode !== nextAltMode;
|
|
514
|
+
}
|
|
515
|
+
_isAltModeNetworkType(networkType) {
|
|
516
|
+
return networkType ? ['cardano'].includes(networkType) : false;
|
|
517
|
+
}
|
|
518
|
+
async legacyForceRelease() {
|
|
519
|
+
if (this.isUsedHere()) {
|
|
520
|
+
await this.acquire();
|
|
521
|
+
await this.getFeatures();
|
|
522
|
+
await this.release();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
exports.Device = Device;
|
|
527
|
+
//# sourceMappingURL=Device.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Transport, Messages } from '@trezor/transport';
|
|
2
|
+
import type { Device } from './Device';
|
|
3
|
+
import type { CoinInfo, BitcoinNetworkInfo } from '../types';
|
|
4
|
+
import type { HDNodeResponse } from '../types/api/getPublicKey';
|
|
5
|
+
declare type MessageType = Messages.MessageType;
|
|
6
|
+
declare type MessageKey = keyof MessageType;
|
|
7
|
+
export declare type TypedResponseMessage<T extends MessageKey> = {
|
|
8
|
+
type: T;
|
|
9
|
+
message: MessageType[T];
|
|
10
|
+
};
|
|
11
|
+
declare type TypedCallResponseMap = {
|
|
12
|
+
[K in keyof MessageType]: TypedResponseMessage<K>;
|
|
13
|
+
};
|
|
14
|
+
export declare type DefaultMessageResponse = TypedCallResponseMap[keyof MessageType];
|
|
15
|
+
export declare type PassphrasePromptResponse = {
|
|
16
|
+
passphrase?: string;
|
|
17
|
+
passphraseOnDevice?: boolean;
|
|
18
|
+
cache?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare class DeviceCommands {
|
|
21
|
+
device: Device;
|
|
22
|
+
transport: Transport;
|
|
23
|
+
sessionId: string;
|
|
24
|
+
disposed: boolean;
|
|
25
|
+
callPromise?: Promise<DefaultMessageResponse>;
|
|
26
|
+
_cancelableRequest?: (error?: any) => void;
|
|
27
|
+
constructor(device: Device, transport: Transport, sessionId: string);
|
|
28
|
+
dispose(): void;
|
|
29
|
+
isDisposed(): boolean;
|
|
30
|
+
getPublicKey(address_n: number[], coin_name?: string, script_type?: Messages.InputScriptType, show_display?: boolean): Promise<Messages.PublicKey>;
|
|
31
|
+
getHDNode(path: number[], coinInfo?: BitcoinNetworkInfo, validation?: boolean, showOnTrezor?: boolean): Promise<HDNodeResponse>;
|
|
32
|
+
getBitcoinHDNode(path: number[], coinInfo?: BitcoinNetworkInfo, validation?: boolean): Promise<HDNodeResponse>;
|
|
33
|
+
getAddress({ address_n, show_display, multisig, script_type }: Messages.GetAddress, coinInfo: BitcoinNetworkInfo): Promise<{
|
|
34
|
+
path: number[];
|
|
35
|
+
serializedPath: string;
|
|
36
|
+
address: string;
|
|
37
|
+
}>;
|
|
38
|
+
ethereumGetAddress({ address_n, show_display }: Messages.EthereumGetAddress): Promise<{
|
|
39
|
+
path: number[];
|
|
40
|
+
serializedPath: string;
|
|
41
|
+
address: string;
|
|
42
|
+
}>;
|
|
43
|
+
ethereumGetPublicKey({ address_n, show_display, }: Messages.EthereumGetPublicKey): Promise<HDNodeResponse>;
|
|
44
|
+
getDeviceState(networkType?: string): Promise<string>;
|
|
45
|
+
call(type: MessageKey, msg?: DefaultMessageResponse['message']): Promise<DefaultMessageResponse>;
|
|
46
|
+
typedCall<T extends MessageKey, R extends MessageKey[]>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedCallResponseMap[R[number]]>;
|
|
47
|
+
typedCall<T extends MessageKey, R extends MessageKey>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedResponseMessage<R>>;
|
|
48
|
+
_commonCall(type: MessageKey, msg?: DefaultMessageResponse['message']): Promise<DefaultMessageResponse>;
|
|
49
|
+
_filterCommonTypes(res: DefaultMessageResponse): Promise<DefaultMessageResponse>;
|
|
50
|
+
_getAddressForNetworkType(networkType?: string): Promise<string>;
|
|
51
|
+
_promptPin(type?: Messages.PinMatrixRequestType): Promise<string>;
|
|
52
|
+
_promptPassphrase(): Promise<PassphrasePromptResponse>;
|
|
53
|
+
_promptWord(type: Messages.WordRequestType): Promise<string>;
|
|
54
|
+
getAccountDescriptor(coinInfo: CoinInfo, indexOrPath: number | number[], derivationType?: Messages.CardanoDerivationType): Promise<{
|
|
55
|
+
descriptor: string;
|
|
56
|
+
legacyXpub?: string;
|
|
57
|
+
address_n: number[];
|
|
58
|
+
}>;
|
|
59
|
+
cancel(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export declare type TypedCall = DeviceCommands['typedCall'];
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=DeviceCommands.d.ts.map
|