@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,465 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeviceCommands = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const randombytes_1 = (0, tslib_1.__importDefault)(require("randombytes"));
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const events_1 = require("../events");
|
|
8
|
+
const hdnodeUtils = (0, tslib_1.__importStar)(require("../utils/hdnodeUtils"));
|
|
9
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
10
|
+
const accountUtils_1 = require("../utils/accountUtils");
|
|
11
|
+
const versionUtils_1 = require("../utils/versionUtils");
|
|
12
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
13
|
+
const debug_1 = require("../utils/debug");
|
|
14
|
+
const logger = (0, debug_1.initLog)('DeviceCommands');
|
|
15
|
+
const assertType = (res, resType) => {
|
|
16
|
+
const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
|
|
17
|
+
if (!splitResTypes.includes(res.type)) {
|
|
18
|
+
throw constants_1.ERRORS.TypedError('Runtime', `assertType: Response of unexpected type: ${res.type}. Should be ${resType}`);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const generateEntropy = (len) => {
|
|
22
|
+
try {
|
|
23
|
+
return (0, randombytes_1.default)(len);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'generateEntropy: Environment does not support crypto random');
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const filterForLog = (type, msg) => {
|
|
30
|
+
const blacklist = {};
|
|
31
|
+
if (type in blacklist) {
|
|
32
|
+
return { ...msg, ...blacklist[type] };
|
|
33
|
+
}
|
|
34
|
+
return msg;
|
|
35
|
+
};
|
|
36
|
+
class DeviceCommands {
|
|
37
|
+
constructor(device, transport, sessionId) {
|
|
38
|
+
this.device = device;
|
|
39
|
+
this.transport = transport;
|
|
40
|
+
this.sessionId = sessionId;
|
|
41
|
+
this.disposed = false;
|
|
42
|
+
}
|
|
43
|
+
dispose() {
|
|
44
|
+
this.disposed = true;
|
|
45
|
+
this._cancelableRequest = undefined;
|
|
46
|
+
}
|
|
47
|
+
isDisposed() {
|
|
48
|
+
return this.disposed;
|
|
49
|
+
}
|
|
50
|
+
async getPublicKey(address_n, coin_name = 'Bitcoin', script_type, show_display) {
|
|
51
|
+
const response = await this.typedCall('GetPublicKey', 'PublicKey', {
|
|
52
|
+
address_n,
|
|
53
|
+
coin_name,
|
|
54
|
+
script_type,
|
|
55
|
+
show_display,
|
|
56
|
+
});
|
|
57
|
+
return response.message;
|
|
58
|
+
}
|
|
59
|
+
async getHDNode(path, coinInfo, validation = true, showOnTrezor = false) {
|
|
60
|
+
if (!this.device.atLeast(['1.7.2', '2.0.10']) || !coinInfo) {
|
|
61
|
+
return this.getBitcoinHDNode(path, coinInfo);
|
|
62
|
+
}
|
|
63
|
+
let network;
|
|
64
|
+
if ((0, pathUtils_1.isMultisigPath)(path)) {
|
|
65
|
+
network = coinInfo.network;
|
|
66
|
+
}
|
|
67
|
+
else if ((0, pathUtils_1.isSegwitPath)(path)) {
|
|
68
|
+
network = (0, coinInfo_1.getSegwitNetwork)(coinInfo);
|
|
69
|
+
}
|
|
70
|
+
else if ((0, pathUtils_1.isBech32Path)(path)) {
|
|
71
|
+
network = (0, coinInfo_1.getBech32Network)(coinInfo);
|
|
72
|
+
}
|
|
73
|
+
let scriptType = (0, pathUtils_1.getScriptType)(path);
|
|
74
|
+
if (!network) {
|
|
75
|
+
network = coinInfo.network;
|
|
76
|
+
if (scriptType !== 'SPENDADDRESS') {
|
|
77
|
+
scriptType = undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let publicKey;
|
|
81
|
+
if (showOnTrezor || !validation) {
|
|
82
|
+
publicKey = await this.getPublicKey(path, coinInfo.name, scriptType, showOnTrezor);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const suffix = 0;
|
|
86
|
+
const childPath = path.concat([suffix]);
|
|
87
|
+
const resKey = await this.getPublicKey(path, coinInfo.name, scriptType);
|
|
88
|
+
const childKey = await this.getPublicKey(childPath, coinInfo.name, scriptType);
|
|
89
|
+
publicKey = hdnodeUtils.xpubDerive(resKey, childKey, suffix, network, coinInfo.network);
|
|
90
|
+
}
|
|
91
|
+
const response = {
|
|
92
|
+
path,
|
|
93
|
+
serializedPath: (0, pathUtils_1.getSerializedPath)(path),
|
|
94
|
+
childNum: publicKey.node.child_num,
|
|
95
|
+
xpub: publicKey.xpub,
|
|
96
|
+
chainCode: publicKey.node.chain_code,
|
|
97
|
+
publicKey: publicKey.node.public_key,
|
|
98
|
+
fingerprint: publicKey.node.fingerprint,
|
|
99
|
+
depth: publicKey.node.depth,
|
|
100
|
+
};
|
|
101
|
+
if (network !== coinInfo.network) {
|
|
102
|
+
response.xpubSegwit = response.xpub;
|
|
103
|
+
response.xpub = hdnodeUtils.convertXpub(publicKey.xpub, network, coinInfo.network);
|
|
104
|
+
}
|
|
105
|
+
if ((0, pathUtils_1.isTaprootPath)(path)) {
|
|
106
|
+
response.xpubSegwit = `tr([5c9e228d/86'/${(0, pathUtils_1.fromHardened)(path[1])}'/${(0, pathUtils_1.fromHardened)(path[2])}']${response.xpub}/<0;1>/*)`;
|
|
107
|
+
}
|
|
108
|
+
return response;
|
|
109
|
+
}
|
|
110
|
+
async getBitcoinHDNode(path, coinInfo, validation = true) {
|
|
111
|
+
let publicKey;
|
|
112
|
+
if (!validation) {
|
|
113
|
+
publicKey = await this.getPublicKey(path);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const suffix = 0;
|
|
117
|
+
const childPath = path.concat([suffix]);
|
|
118
|
+
const resKey = await this.getPublicKey(path);
|
|
119
|
+
const childKey = await this.getPublicKey(childPath);
|
|
120
|
+
publicKey = hdnodeUtils.xpubDerive(resKey, childKey, suffix);
|
|
121
|
+
}
|
|
122
|
+
const response = {
|
|
123
|
+
path,
|
|
124
|
+
serializedPath: (0, pathUtils_1.getSerializedPath)(path),
|
|
125
|
+
childNum: publicKey.node.child_num,
|
|
126
|
+
xpub: coinInfo
|
|
127
|
+
? hdnodeUtils.convertBitcoinXpub(publicKey.xpub, coinInfo.network)
|
|
128
|
+
: publicKey.xpub,
|
|
129
|
+
chainCode: publicKey.node.chain_code,
|
|
130
|
+
publicKey: publicKey.node.public_key,
|
|
131
|
+
fingerprint: publicKey.node.fingerprint,
|
|
132
|
+
depth: publicKey.node.depth,
|
|
133
|
+
};
|
|
134
|
+
if (coinInfo) {
|
|
135
|
+
const bech32Network = (0, coinInfo_1.getBech32Network)(coinInfo);
|
|
136
|
+
const segwitNetwork = (0, coinInfo_1.getSegwitNetwork)(coinInfo);
|
|
137
|
+
if (bech32Network && (0, pathUtils_1.isBech32Path)(path)) {
|
|
138
|
+
response.xpubSegwit = hdnodeUtils.convertBitcoinXpub(publicKey.xpub, bech32Network);
|
|
139
|
+
}
|
|
140
|
+
else if (segwitNetwork && (0, pathUtils_1.isSegwitPath)(path)) {
|
|
141
|
+
response.xpubSegwit = hdnodeUtils.convertBitcoinXpub(publicKey.xpub, segwitNetwork);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return response;
|
|
145
|
+
}
|
|
146
|
+
async getAddress({ address_n, show_display, multisig, script_type }, coinInfo) {
|
|
147
|
+
if (!script_type) {
|
|
148
|
+
script_type = (0, pathUtils_1.getScriptType)(address_n);
|
|
149
|
+
if (script_type === 'SPENDMULTISIG' && !multisig) {
|
|
150
|
+
script_type = 'SPENDADDRESS';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (multisig && multisig.pubkeys) {
|
|
154
|
+
multisig.pubkeys.forEach(pk => {
|
|
155
|
+
if (typeof pk.node === 'string') {
|
|
156
|
+
pk.node = hdnodeUtils.xpubToHDNodeType(pk.node, coinInfo.network);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const response = await this.typedCall('GetAddress', 'Address', {
|
|
161
|
+
address_n,
|
|
162
|
+
coin_name: coinInfo.name,
|
|
163
|
+
show_display,
|
|
164
|
+
multisig,
|
|
165
|
+
script_type: script_type || 'SPENDADDRESS',
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
path: address_n,
|
|
169
|
+
serializedPath: (0, pathUtils_1.getSerializedPath)(address_n),
|
|
170
|
+
address: response.message.address,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
async ethereumGetAddress({ address_n, show_display }) {
|
|
174
|
+
const response = await this.typedCall('EthereumGetAddress', 'EthereumAddress', {
|
|
175
|
+
address_n,
|
|
176
|
+
show_display,
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
path: address_n,
|
|
180
|
+
serializedPath: (0, pathUtils_1.getSerializedPath)(address_n),
|
|
181
|
+
address: response.message.address,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
async ethereumGetPublicKey({ address_n, show_display, }) {
|
|
185
|
+
if (!this.device.atLeast(['1.8.1', '2.1.0'])) {
|
|
186
|
+
return this.getHDNode(address_n);
|
|
187
|
+
}
|
|
188
|
+
const suffix = 0;
|
|
189
|
+
const childPath = address_n.concat([suffix]);
|
|
190
|
+
const resKey = await this.typedCall('EthereumGetPublicKey', 'EthereumPublicKey', {
|
|
191
|
+
address_n,
|
|
192
|
+
show_display,
|
|
193
|
+
});
|
|
194
|
+
const childKey = await this.typedCall('EthereumGetPublicKey', 'EthereumPublicKey', {
|
|
195
|
+
address_n: childPath,
|
|
196
|
+
show_display: false,
|
|
197
|
+
});
|
|
198
|
+
const publicKey = hdnodeUtils.xpubDerive(resKey.message, childKey.message, suffix);
|
|
199
|
+
return {
|
|
200
|
+
path: address_n,
|
|
201
|
+
serializedPath: (0, pathUtils_1.getSerializedPath)(address_n),
|
|
202
|
+
childNum: publicKey.node.child_num,
|
|
203
|
+
xpub: publicKey.xpub,
|
|
204
|
+
chainCode: publicKey.node.chain_code,
|
|
205
|
+
publicKey: publicKey.node.public_key,
|
|
206
|
+
fingerprint: publicKey.node.fingerprint,
|
|
207
|
+
depth: publicKey.node.depth,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
getDeviceState(networkType) {
|
|
211
|
+
if (!this.device.atLeast('2.4.3')) {
|
|
212
|
+
return this._getAddressForNetworkType(networkType);
|
|
213
|
+
}
|
|
214
|
+
return this._getAddressForNetworkType();
|
|
215
|
+
}
|
|
216
|
+
async call(type, msg = {}) {
|
|
217
|
+
const logMessage = filterForLog(type, msg);
|
|
218
|
+
logger.debug('Sending', type, logMessage);
|
|
219
|
+
try {
|
|
220
|
+
const promise = this.transport.call(this.sessionId, type, msg, false);
|
|
221
|
+
this.callPromise = promise;
|
|
222
|
+
const res = await promise;
|
|
223
|
+
const logMessage = filterForLog(res.type, res.message);
|
|
224
|
+
logger.debug('Received', res.type, logMessage);
|
|
225
|
+
return res;
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
logger.warn('Received error', error);
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
async typedCall(type, resType, msg) {
|
|
233
|
+
if (this.disposed) {
|
|
234
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'typedCall: DeviceCommands already disposed');
|
|
235
|
+
}
|
|
236
|
+
const response = await this._commonCall(type, msg);
|
|
237
|
+
try {
|
|
238
|
+
assertType(response, resType);
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
await this.transport.read(this.sessionId, false);
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
return response;
|
|
245
|
+
}
|
|
246
|
+
async _commonCall(type, msg) {
|
|
247
|
+
const resp = await this.call(type, msg);
|
|
248
|
+
return this._filterCommonTypes(resp);
|
|
249
|
+
}
|
|
250
|
+
_filterCommonTypes(res) {
|
|
251
|
+
if (res.type === 'Failure') {
|
|
252
|
+
const { code } = res.message;
|
|
253
|
+
let { message } = res.message;
|
|
254
|
+
if (code === 'Failure_FirmwareError' && !message) {
|
|
255
|
+
message = 'Firmware installation failed';
|
|
256
|
+
}
|
|
257
|
+
if (code === 'Failure_ActionCancelled' && !message) {
|
|
258
|
+
message = 'Action cancelled by user';
|
|
259
|
+
}
|
|
260
|
+
return Promise.reject(new constants_1.ERRORS.TrezorError(code || 'Failure_UnknownCode', message || 'Failure_UnknownMessage'));
|
|
261
|
+
}
|
|
262
|
+
if (res.type === 'Features') {
|
|
263
|
+
return Promise.resolve(res);
|
|
264
|
+
}
|
|
265
|
+
if (res.type === 'ButtonRequest') {
|
|
266
|
+
if (res.message.code === '_Deprecated_ButtonRequest_PassphraseType') {
|
|
267
|
+
res.message.code = 'ButtonRequest_PassphraseType';
|
|
268
|
+
}
|
|
269
|
+
if (res.message.code === 'ButtonRequest_PassphraseEntry') {
|
|
270
|
+
this.device.emit(events_1.DEVICE.PASSPHRASE_ON_DEVICE, this.device);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
this.device.emit(events_1.DEVICE.BUTTON, this.device, res.message);
|
|
274
|
+
}
|
|
275
|
+
return this._commonCall('ButtonAck', {});
|
|
276
|
+
}
|
|
277
|
+
if (res.type === 'EntropyRequest') {
|
|
278
|
+
return this._commonCall('EntropyAck', {
|
|
279
|
+
entropy: generateEntropy(32).toString('hex'),
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
if (res.type === 'PinMatrixRequest') {
|
|
283
|
+
return this._promptPin(res.message.type).then(pin => this._commonCall('PinMatrixAck', { pin }), () => this._commonCall('Cancel', {}));
|
|
284
|
+
}
|
|
285
|
+
if (res.type === 'PassphraseRequest') {
|
|
286
|
+
const state = this.device.getInternalState();
|
|
287
|
+
const legacy = this.device.useLegacyPassphrase();
|
|
288
|
+
const legacyT1 = legacy && this.device.isT1();
|
|
289
|
+
if (legacyT1 && typeof state === 'string') {
|
|
290
|
+
return this._commonCall('PassphraseAck', { passphrase: state });
|
|
291
|
+
}
|
|
292
|
+
if (legacy && res.message._on_device) {
|
|
293
|
+
this.device.emit(events_1.DEVICE.PASSPHRASE_ON_DEVICE, this.device);
|
|
294
|
+
return this._commonCall('PassphraseAck', { _state: state });
|
|
295
|
+
}
|
|
296
|
+
return this._promptPassphrase().then(response => {
|
|
297
|
+
const { passphrase, passphraseOnDevice, cache } = response;
|
|
298
|
+
if (legacyT1) {
|
|
299
|
+
this.device.setInternalState(cache ? passphrase : undefined);
|
|
300
|
+
return this._commonCall('PassphraseAck', { passphrase });
|
|
301
|
+
}
|
|
302
|
+
if (legacy) {
|
|
303
|
+
return this._commonCall('PassphraseAck', { passphrase, _state: state });
|
|
304
|
+
}
|
|
305
|
+
return !passphraseOnDevice
|
|
306
|
+
? this._commonCall('PassphraseAck', { passphrase })
|
|
307
|
+
: this._commonCall('PassphraseAck', { on_device: true });
|
|
308
|
+
}, err => this._commonCall('Cancel', {}).catch((e) => {
|
|
309
|
+
throw err || e;
|
|
310
|
+
}));
|
|
311
|
+
}
|
|
312
|
+
if (res.type === 'Deprecated_PassphraseStateRequest') {
|
|
313
|
+
const { state } = res.message;
|
|
314
|
+
this.device.setInternalState(state);
|
|
315
|
+
return this._commonCall('Deprecated_PassphraseStateAck', {});
|
|
316
|
+
}
|
|
317
|
+
if (res.type === 'WordRequest') {
|
|
318
|
+
return this._promptWord(res.message.type).then(word => this._commonCall('WordAck', { word }), () => this._commonCall('Cancel', {}));
|
|
319
|
+
}
|
|
320
|
+
return Promise.resolve(res);
|
|
321
|
+
}
|
|
322
|
+
async _getAddressForNetworkType(networkType) {
|
|
323
|
+
switch (networkType) {
|
|
324
|
+
case constants_1.NETWORK.TYPES.cardano: {
|
|
325
|
+
const { message } = await this.typedCall('CardanoGetAddress', 'CardanoAddress', {
|
|
326
|
+
address_parameters: {
|
|
327
|
+
address_type: 8,
|
|
328
|
+
address_n: [(0, pathUtils_1.toHardened)(44), (0, pathUtils_1.toHardened)(1815), (0, pathUtils_1.toHardened)(0), 0, 0],
|
|
329
|
+
address_n_staking: [],
|
|
330
|
+
},
|
|
331
|
+
protocol_magic: 42,
|
|
332
|
+
network_id: 0,
|
|
333
|
+
derivation_type: 2,
|
|
334
|
+
});
|
|
335
|
+
return message.address;
|
|
336
|
+
}
|
|
337
|
+
default: {
|
|
338
|
+
const { message } = await this.typedCall('GetAddress', 'Address', {
|
|
339
|
+
address_n: [(0, pathUtils_1.toHardened)(44), (0, pathUtils_1.toHardened)(1), (0, pathUtils_1.toHardened)(0), 0, 0],
|
|
340
|
+
coin_name: 'Testnet',
|
|
341
|
+
script_type: 'SPENDADDRESS',
|
|
342
|
+
});
|
|
343
|
+
return message.address;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
_promptPin(type) {
|
|
348
|
+
return new Promise((resolve, reject) => {
|
|
349
|
+
if (this.device.listenerCount(events_1.DEVICE.PIN) > 0) {
|
|
350
|
+
this._cancelableRequest = reject;
|
|
351
|
+
this.device.emit(events_1.DEVICE.PIN, this.device, type, (err, pin) => {
|
|
352
|
+
this._cancelableRequest = undefined;
|
|
353
|
+
if (err || pin == null) {
|
|
354
|
+
reject(err);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
resolve(pin);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
console.warn('[DeviceCommands] [call] PIN callback not configured, cancelling request');
|
|
363
|
+
reject(constants_1.ERRORS.TypedError('Runtime', '_promptPin: PIN callback not configured'));
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
_promptPassphrase() {
|
|
368
|
+
return new Promise((resolve, reject) => {
|
|
369
|
+
if (this.device.listenerCount(events_1.DEVICE.PASSPHRASE) > 0) {
|
|
370
|
+
this._cancelableRequest = reject;
|
|
371
|
+
this.device.emit(events_1.DEVICE.PASSPHRASE, this.device, (response, error) => {
|
|
372
|
+
this._cancelableRequest = undefined;
|
|
373
|
+
if (error) {
|
|
374
|
+
reject(error);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
resolve(response);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
console.warn('[DeviceCommands] [call] Passphrase callback not configured, cancelling request');
|
|
383
|
+
reject(constants_1.ERRORS.TypedError('Runtime', '_promptPassphrase: Passphrase callback not configured'));
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
_promptWord(type) {
|
|
388
|
+
return new Promise((resolve, reject) => {
|
|
389
|
+
this._cancelableRequest = reject;
|
|
390
|
+
this.device.emit(events_1.DEVICE.WORD, this.device, type, (err, word) => {
|
|
391
|
+
this._cancelableRequest = undefined;
|
|
392
|
+
if (err || word == null) {
|
|
393
|
+
reject(err);
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
resolve(word.toLocaleLowerCase());
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
async getAccountDescriptor(coinInfo, indexOrPath, derivationType) {
|
|
402
|
+
const address_n = Array.isArray(indexOrPath)
|
|
403
|
+
? indexOrPath
|
|
404
|
+
: (0, accountUtils_1.getAccountAddressN)(coinInfo, indexOrPath);
|
|
405
|
+
if (coinInfo.type === 'bitcoin') {
|
|
406
|
+
const resp = await this.getHDNode(address_n, coinInfo, false);
|
|
407
|
+
return {
|
|
408
|
+
descriptor: resp.xpubSegwit || resp.xpub,
|
|
409
|
+
legacyXpub: resp.xpub,
|
|
410
|
+
address_n,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
if (coinInfo.type === 'ethereum') {
|
|
414
|
+
const resp = await this.ethereumGetAddress({ address_n });
|
|
415
|
+
return {
|
|
416
|
+
descriptor: resp.address,
|
|
417
|
+
address_n,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
if (coinInfo.shortcut === 'ADA' || coinInfo.shortcut === 'tADA') {
|
|
421
|
+
if (typeof derivationType === 'undefined')
|
|
422
|
+
throw new Error('Derivation type is not specified');
|
|
423
|
+
const { message } = await this.typedCall('CardanoGetPublicKey', 'CardanoPublicKey', {
|
|
424
|
+
address_n,
|
|
425
|
+
derivation_type: derivationType,
|
|
426
|
+
});
|
|
427
|
+
return {
|
|
428
|
+
descriptor: message.xpub,
|
|
429
|
+
address_n,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
if (coinInfo.shortcut === 'XRP' || coinInfo.shortcut === 'tXRP') {
|
|
433
|
+
const { message } = await this.typedCall('RippleGetAddress', 'RippleAddress', {
|
|
434
|
+
address_n,
|
|
435
|
+
});
|
|
436
|
+
return {
|
|
437
|
+
descriptor: message.address,
|
|
438
|
+
address_n,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'DeviceCommands.getAccountDescriptor: unsupported coinInfo.type');
|
|
442
|
+
}
|
|
443
|
+
async cancel() {
|
|
444
|
+
if (this._cancelableRequest) {
|
|
445
|
+
this._cancelableRequest();
|
|
446
|
+
this._cancelableRequest = undefined;
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (this.disposed) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const { activeName, version } = this.transport;
|
|
453
|
+
if (activeName &&
|
|
454
|
+
activeName === 'BridgeTransport' &&
|
|
455
|
+
(0, versionUtils_1.versionCompare)(version, '2.0.28') < 1) {
|
|
456
|
+
await this.device.legacyForceRelease();
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
await this.transport.post(this.sessionId, 'Cancel', {}, false);
|
|
460
|
+
await this.transport.read(this.sessionId, false);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
exports.DeviceCommands = DeviceCommands;
|
|
465
|
+
//# sourceMappingURL=DeviceCommands.js.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import EventEmitter from 'events';
|
|
3
|
+
import { Transport, TrezorDeviceInfoWithSession as DeviceDescriptor } from '@trezor/transport';
|
|
4
|
+
import { TRANSPORT, DEVICE, TransportInfo } from '../events';
|
|
5
|
+
import { DescriptorStream } from './DescriptorStream';
|
|
6
|
+
import { Device } from './Device';
|
|
7
|
+
import type { Device as DeviceTyped } from '../types';
|
|
8
|
+
import type { Controller } from './AbortController';
|
|
9
|
+
declare type LowLevelPlugin = {
|
|
10
|
+
name: 'WebUsbPlugin' | 'ReactNativePlugin';
|
|
11
|
+
unreadableHidDeviceChange: {
|
|
12
|
+
on: (event: string, fn: any) => void;
|
|
13
|
+
};
|
|
14
|
+
unreadableHidDevice: boolean;
|
|
15
|
+
};
|
|
16
|
+
interface DeviceListEvents {
|
|
17
|
+
[TRANSPORT.START]: TransportInfo;
|
|
18
|
+
[TRANSPORT.ERROR]: string;
|
|
19
|
+
[TRANSPORT.STREAM]: DescriptorStream;
|
|
20
|
+
[DEVICE.CONNECT]: DeviceTyped;
|
|
21
|
+
[DEVICE.CONNECT_UNACQUIRED]: DeviceTyped;
|
|
22
|
+
[DEVICE.DISCONNECT]: DeviceTyped;
|
|
23
|
+
[DEVICE.CHANGED]: DeviceTyped;
|
|
24
|
+
[DEVICE.RELEASED]: DeviceTyped;
|
|
25
|
+
[DEVICE.ACQUIRED]: DeviceTyped;
|
|
26
|
+
}
|
|
27
|
+
export interface DeviceList {
|
|
28
|
+
on<K extends keyof DeviceListEvents>(type: K, listener: (event: DeviceListEvents[K]) => void): this;
|
|
29
|
+
off<K extends keyof DeviceListEvents>(type: K, listener: (event: DeviceListEvents[K]) => void): this;
|
|
30
|
+
emit<K extends keyof DeviceListEvents>(type: K, args: DeviceListEvents[K]): boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare class DeviceList extends EventEmitter {
|
|
33
|
+
transport: Transport;
|
|
34
|
+
transportPlugin: LowLevelPlugin | typeof undefined;
|
|
35
|
+
stream: DescriptorStream;
|
|
36
|
+
devices: {
|
|
37
|
+
[path: string]: Device;
|
|
38
|
+
};
|
|
39
|
+
creatingDevicesDescriptors: {
|
|
40
|
+
[k: string]: DeviceDescriptor;
|
|
41
|
+
};
|
|
42
|
+
defaultMessages: JSON | Record<string, any>;
|
|
43
|
+
currentMessages: JSON | Record<string, any>;
|
|
44
|
+
hasCustomMessages: boolean;
|
|
45
|
+
transportStartPending: number;
|
|
46
|
+
penalizedDevices: {
|
|
47
|
+
[deviceID: string]: number;
|
|
48
|
+
};
|
|
49
|
+
fetchController?: Controller | null;
|
|
50
|
+
constructor();
|
|
51
|
+
init(): Promise<void>;
|
|
52
|
+
reconfigure(messages: JSON | Record<string, any> | number[], custom?: boolean): Promise<void>;
|
|
53
|
+
restoreMessages(): Promise<void>;
|
|
54
|
+
resolveTransportEvent(): void;
|
|
55
|
+
waitForTransportFirstEvent(): Promise<void>;
|
|
56
|
+
_initStream(): void;
|
|
57
|
+
_createAndSaveDevice(descriptor: DeviceDescriptor): Promise<void>;
|
|
58
|
+
_createUnacquiredDevice(descriptor: DeviceDescriptor): Device;
|
|
59
|
+
_createUnreadableDevice(descriptor: DeviceDescriptor, unreadableError: string): Device;
|
|
60
|
+
getDevice(path: string): Device;
|
|
61
|
+
getFirstDevicePath(): string;
|
|
62
|
+
asArray(): DeviceTyped[];
|
|
63
|
+
allDevices(): Device[];
|
|
64
|
+
length(): number;
|
|
65
|
+
transportType(): string;
|
|
66
|
+
getTransportInfo(): TransportInfo;
|
|
67
|
+
dispose(): void;
|
|
68
|
+
disconnectDevices(): void;
|
|
69
|
+
enumerate(): void;
|
|
70
|
+
addAuthPenalty(device: Device): void;
|
|
71
|
+
getAuthPenalty(): number;
|
|
72
|
+
removeAuthPenalty(device: Device): void;
|
|
73
|
+
}
|
|
74
|
+
export declare const getDeviceList: () => Promise<DeviceList>;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=DeviceList.d.ts.map
|