@trezor/connect 9.7.3 → 10.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/CHANGELOG.md +68 -1334
- package/README.md +9 -45
- package/lib/api/applyFlags.d.ts +17 -14
- package/lib/api/applyFlags.js +19 -20
- package/lib/api/applySettings.d.ts +18 -15
- package/lib/api/applySettings.js +25 -21
- package/lib/api/authenticateDevice.d.ts +24 -10
- package/lib/api/authenticateDevice.js +149 -49
- package/lib/api/authorizeCoinjoin.d.ts +10 -8
- package/lib/api/authorizeCoinjoin.js +21 -25
- package/lib/api/backupDevice.d.ts +16 -14
- package/lib/api/backupDevice.js +20 -21
- package/lib/api/bitcoin/TransactionComposer.d.ts +42 -44
- package/lib/api/bitcoin/TransactionComposer.js +21 -21
- package/lib/api/bitcoin/createPendingTx.d.ts +34 -32
- package/lib/api/bitcoin/createPendingTx.js +8 -15
- package/lib/api/bitcoin/enhanceSignTx.d.ts +2 -4
- package/lib/api/bitcoin/enhanceSignTx.js +5 -46
- package/lib/api/bitcoin/index.d.ts +9 -10
- package/lib/api/bitcoin/index.js +9 -16
- package/lib/api/bitcoin/inputs.d.ts +3 -7
- package/lib/api/bitcoin/inputs.js +12 -34
- package/lib/api/bitcoin/outputs.d.ts +3 -6
- package/lib/api/bitcoin/outputs.js +34 -33
- package/lib/api/bitcoin/refTx.d.ts +16 -12
- package/lib/api/bitcoin/refTx.js +49 -70
- package/lib/api/bitcoin/signtx.d.ts +26 -21
- package/lib/api/bitcoin/signtx.js +47 -39
- package/lib/api/bitcoin/signtxLegacy.d.ts +10 -4
- package/lib/api/bitcoin/signtxLegacy.js +31 -32
- package/lib/api/bitcoin/signtxVerify.d.ts +7 -9
- package/lib/api/bitcoin/signtxVerify.js +35 -35
- package/lib/api/bitcoin/transactionBytes.d.ts +3 -5
- package/lib/api/bitcoin/transactionBytes.js +8 -19
- package/lib/api/bleUnpair.d.ts +10 -8
- package/lib/api/bleUnpair.js +23 -25
- package/lib/api/blockchainDisconnect.d.ts +12 -11
- package/lib/api/blockchainDisconnect.js +22 -28
- package/lib/api/blockchainEstimateFee.d.ts +12 -9
- package/lib/api/blockchainEstimateFee.js +27 -32
- package/lib/api/blockchainEvmRpcCall.d.ts +15 -12
- package/lib/api/blockchainEvmRpcCall.js +22 -27
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +12 -9
- package/lib/api/blockchainGetAccountBalanceHistory.js +27 -28
- package/lib/api/blockchainGetContractInfo.d.ts +16 -0
- package/lib/api/blockchainGetContractInfo.js +46 -0
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +16 -13
- package/lib/api/blockchainGetCurrentFiatRates.js +22 -27
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +19 -16
- package/lib/api/blockchainGetFiatRatesForTimestamps.js +22 -27
- package/lib/api/blockchainGetInfo.d.ts +11 -8
- package/lib/api/blockchainGetInfo.js +22 -27
- package/lib/api/blockchainGetTransactions.d.ts +14 -9
- package/lib/api/blockchainGetTransactions.js +29 -29
- package/lib/api/blockchainSetCustomBackend.d.ts +13 -8
- package/lib/api/blockchainSetCustomBackend.js +26 -28
- package/lib/api/blockchainSubscribe.d.ts +15 -12
- package/lib/api/blockchainSubscribe.js +25 -28
- package/lib/api/blockchainSubscribeFiatRates.d.ts +15 -11
- package/lib/api/blockchainSubscribeFiatRates.js +23 -27
- package/lib/api/blockchainUnsubscribe.d.ts +15 -12
- package/lib/api/blockchainUnsubscribe.js +25 -28
- package/lib/api/blockchainUnsubscribeFiatRates.d.ts +13 -10
- package/lib/api/blockchainUnsubscribeFiatRates.js +22 -27
- package/lib/api/blockchainValidateEvmRpcUrl.d.ts +17 -0
- package/lib/api/blockchainValidateEvmRpcUrl.js +54 -0
- package/lib/api/cancelCoinjoinAuthorization.d.ts +11 -10
- package/lib/api/cancelCoinjoinAuthorization.js +15 -18
- package/lib/api/cardano/api/cardanoComposeTransaction.d.ts +9 -7
- package/lib/api/cardano/api/cardanoComposeTransaction.js +25 -27
- package/lib/api/cardano/api/cardanoGetAddress.d.ts +31 -24
- package/lib/api/cardano/api/cardanoGetAddress.js +75 -70
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.d.ts +11 -12
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +47 -56
- package/lib/api/cardano/api/cardanoGetPublicKey.d.ts +19 -14
- package/lib/api/cardano/api/cardanoGetPublicKey.js +62 -43
- package/lib/api/cardano/api/cardanoSignMessage.d.ts +19 -22
- package/lib/api/cardano/api/cardanoSignMessage.js +34 -44
- package/lib/api/cardano/api/cardanoSignTransaction.d.ts +75 -73
- package/lib/api/cardano/api/cardanoSignTransaction.js +64 -62
- package/lib/api/cardano/api/index.d.ts +6 -7
- package/lib/api/cardano/api/index.js +6 -50
- package/lib/api/cardano/cardanoAddressParameters.d.ts +3 -4
- package/lib/api/cardano/cardanoAddressParameters.js +17 -27
- package/lib/api/cardano/cardanoAuxiliaryData.d.ts +3 -4
- package/lib/api/cardano/cardanoAuxiliaryData.js +16 -25
- package/lib/api/cardano/cardanoCertificate.d.ts +9 -10
- package/lib/api/cardano/cardanoCertificate.js +35 -42
- package/lib/api/cardano/cardanoInputs.d.ts +16 -17
- package/lib/api/cardano/cardanoInputs.js +19 -29
- package/lib/api/cardano/cardanoOutputs.d.ts +35 -35
- package/lib/api/cardano/cardanoOutputs.js +25 -34
- package/lib/api/cardano/cardanoTokenBundle.d.ts +10 -11
- package/lib/api/cardano/cardanoTokenBundle.js +9 -17
- package/lib/api/cardano/cardanoUtils.d.ts +13 -5
- package/lib/api/cardano/cardanoUtils.js +19 -33
- package/lib/api/cardano/cardanoWitnesses.d.ts +4 -5
- package/lib/api/cardano/cardanoWitnesses.js +6 -14
- package/lib/api/changeLanguage.d.ts +16 -15
- package/lib/api/changeLanguage.js +22 -23
- package/lib/api/changePin.d.ts +9 -7
- package/lib/api/changePin.js +18 -20
- package/lib/api/changeWipeCode.d.ts +10 -8
- package/lib/api/changeWipeCode.js +17 -19
- package/lib/api/cipherKeyValue.d.ts +16 -12
- package/lib/api/cipherKeyValue.js +35 -33
- package/lib/api/common/AbstractMiscGetAddress.d.ts +37 -0
- package/lib/api/common/AbstractMiscGetAddress.js +126 -0
- package/lib/api/common/Discovery.d.ts +23 -26
- package/lib/api/common/Discovery.js +14 -22
- package/lib/api/common/paramsValidator.d.ts +19 -9
- package/lib/api/common/paramsValidator.js +77 -71
- package/lib/api/common/requestExistingAccounts.d.ts +14 -0
- package/lib/api/common/requestExistingAccounts.js +20 -0
- package/lib/api/composeTransaction.d.ts +31 -39
- package/lib/api/composeTransaction.js +172 -108
- package/lib/api/discoverAccounts.d.ts +36 -29
- package/lib/api/discoverAccounts.js +113 -69
- package/lib/api/ethereum/api/ethereumGetAddress.d.ts +27 -25
- package/lib/api/ethereum/api/ethereumGetAddress.js +80 -62
- package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +49 -41
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +54 -42
- package/lib/api/ethereum/api/ethereumSignMessage.d.ts +24 -21
- package/lib/api/ethereum/api/ethereumSignMessage.js +40 -46
- package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +77 -76
- package/lib/api/ethereum/api/ethereumSignTransaction.js +63 -77
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +108 -107
- package/lib/api/ethereum/api/ethereumSignTypedData.js +69 -77
- package/lib/api/ethereum/api/ethereumVerifyMessage.d.ts +11 -9
- package/lib/api/ethereum/api/ethereumVerifyMessage.js +23 -25
- package/lib/api/ethereum/api/index.d.ts +6 -7
- package/lib/api/ethereum/api/index.js +6 -50
- package/lib/api/ethereum/ethereumDefinitions.d.ts +42 -36
- package/lib/api/ethereum/ethereumDefinitions.js +67 -50
- package/lib/api/ethereum/ethereumSignTx.d.ts +15 -21
- package/lib/api/ethereum/ethereumSignTx.js +64 -62
- package/lib/api/ethereum/ethereumSignTypedData.d.ts +28 -5
- package/lib/api/ethereum/ethereumSignTypedData.js +95 -41
- package/lib/api/evoluGetDelegatedIdentityKey.d.ts +13 -10
- package/lib/api/evoluGetDelegatedIdentityKey.js +20 -32
- package/lib/api/evoluGetNode.d.ts +11 -9
- package/lib/api/evoluGetNode.js +16 -20
- package/lib/api/evoluSignRegistrationRequest.d.ts +14 -10
- package/lib/api/evoluSignRegistrationRequest.js +18 -20
- package/lib/api/firmware/calculateFirmwareHash.d.ts +15 -10
- package/lib/api/firmware/calculateFirmwareHash.js +16 -21
- package/lib/api/firmware/calculateXPubHash.d.ts +14 -0
- package/lib/api/firmware/calculateXPubHash.js +16 -0
- package/lib/api/firmware/getBinary.d.ts +11 -8
- package/lib/api/firmware/getBinary.js +12 -21
- package/lib/api/firmware/index.d.ts +6 -6
- package/lib/api/firmware/index.js +6 -54
- package/lib/api/firmware/modifyFirmware.d.ts +2 -3
- package/lib/api/firmware/modifyFirmware.js +6 -14
- package/lib/api/firmware/parseFirmwareHeaders.d.ts +3 -4
- package/lib/api/firmware/parseFirmwareHeaders.js +2 -10
- package/lib/api/firmware/uploadFirmware.d.ts +22 -17
- package/lib/api/firmware/uploadFirmware.js +20 -20
- package/lib/api/firmware/verifyEntropy.d.ts +20 -14
- package/lib/api/firmware/verifyEntropy.js +22 -29
- package/lib/api/getAccountInfo.d.ts +17 -143
- package/lib/api/getAccountInfo.js +92 -184
- package/lib/api/getAddress.d.ts +42 -35
- package/lib/api/getAddress.js +76 -71
- package/lib/api/getCoinInfo.d.ts +144 -146
- package/lib/api/getCoinInfo.js +17 -25
- package/lib/api/getDeviceState.d.ts +7 -8
- package/lib/api/getDeviceState.js +11 -17
- package/lib/api/getFeatures.d.ts +70 -64
- package/lib/api/getFeatures.js +17 -17
- package/lib/api/getFirmwareHash.d.ts +9 -7
- package/lib/api/getFirmwareHash.js +20 -24
- package/lib/api/getNonce.d.ts +10 -9
- package/lib/api/getNonce.js +12 -12
- package/lib/api/getOwnershipId.d.ts +16 -12
- package/lib/api/getOwnershipId.js +54 -37
- package/lib/api/getOwnershipProof.d.ts +16 -12
- package/lib/api/getOwnershipProof.js +54 -39
- package/lib/api/getPublicKey.d.ts +51 -43
- package/lib/api/getPublicKey.js +67 -48
- package/lib/api/getSettings.d.ts +23 -5
- package/lib/api/getSettings.js +16 -14
- package/lib/api/index.d.ts +62 -58
- package/lib/api/index.js +62 -408
- package/lib/api/loadDevice.d.ts +14 -12
- package/lib/api/loadDevice.js +20 -24
- package/lib/api/monero/api/index.d.ts +4 -5
- package/lib/api/monero/api/index.js +4 -36
- package/lib/api/monero/api/moneroGetAddress.d.ts +29 -24
- package/lib/api/monero/api/moneroGetAddress.js +56 -61
- package/lib/api/monero/api/moneroGetWatchKey.d.ts +11 -10
- package/lib/api/monero/api/moneroGetWatchKey.js +26 -29
- package/lib/api/monero/api/moneroKeyImageSync.d.ts +13 -12
- package/lib/api/monero/api/moneroKeyImageSync.js +34 -37
- package/lib/api/monero/api/moneroSignTransaction.d.ts +13 -12
- package/lib/api/monero/api/moneroSignTransaction.js +52 -41
- package/lib/api/nostr/nostrGetPublicKey.d.ts +15 -0
- package/lib/api/nostr/nostrGetPublicKey.js +38 -0
- package/lib/api/nostr/nostrSignEvent.d.ts +13 -0
- package/lib/api/nostr/nostrSignEvent.js +36 -0
- package/lib/api/pingDevice.d.ts +11 -0
- package/lib/api/pingDevice.js +29 -0
- package/lib/api/pushTransaction.d.ts +15 -12
- package/lib/api/pushTransaction.js +25 -30
- package/lib/api/recoveryDevice.d.ts +18 -16
- package/lib/api/recoveryDevice.js +22 -23
- package/lib/api/requestLogin.d.ts +13 -11
- package/lib/api/requestLogin.js +24 -30
- package/lib/api/resetDevice.d.ts +21 -15
- package/lib/api/resetDevice.js +64 -48
- package/lib/api/ripple/api/index.d.ts +2 -3
- package/lib/api/ripple/api/index.js +2 -22
- package/lib/api/ripple/api/rippleGetAddress.d.ts +17 -27
- package/lib/api/ripple/api/rippleGetAddress.js +12 -101
- package/lib/api/ripple/api/rippleSignTransaction.d.ts +12 -10
- package/lib/api/ripple/api/rippleSignTransaction.js +21 -24
- package/lib/api/selectAccount.d.ts +15 -0
- package/lib/api/selectAccount.js +42 -0
- package/lib/api/setBrightness.d.ts +10 -7
- package/lib/api/setBrightness.js +19 -20
- package/lib/api/setBusy.d.ts +10 -8
- package/lib/api/setBusy.js +18 -25
- package/lib/api/showDeviceTutorial.d.ts +11 -10
- package/lib/api/showDeviceTutorial.js +11 -16
- package/lib/api/signMessage.d.ts +24 -18
- package/lib/api/signMessage.js +47 -36
- package/lib/api/signTransaction.d.ts +195 -227
- package/lib/api/signTransaction.js +84 -101
- package/lib/api/solana/api/index.d.ts +4 -5
- package/lib/api/solana/api/index.js +4 -36
- package/lib/api/solana/api/solanaComposeTransaction.d.ts +29 -26
- package/lib/api/solana/api/solanaComposeTransaction.js +47 -36
- package/lib/api/solana/api/solanaGetAddress.d.ts +17 -27
- package/lib/api/solana/api/solanaGetAddress.js +12 -101
- package/lib/api/solana/api/solanaGetPublicKey.d.ts +31 -26
- package/lib/api/solana/api/solanaGetPublicKey.js +54 -39
- package/lib/api/solana/api/solanaSignTransaction.d.ts +38 -36
- package/lib/api/solana/api/solanaSignTransaction.js +134 -133
- package/lib/api/solana/solanaDefinitions.d.ts +5 -4
- package/lib/api/solana/solanaDefinitions.js +12 -25
- package/lib/api/stellar/api/index.d.ts +2 -3
- package/lib/api/stellar/api/index.js +2 -22
- package/lib/api/stellar/api/stellarGetAddress.d.ts +17 -27
- package/lib/api/stellar/api/stellarGetAddress.js +12 -101
- package/lib/api/stellar/api/stellarSignTransaction.d.ts +17 -21
- package/lib/api/stellar/api/stellarSignTransaction.js +39 -44
- package/lib/api/stellar/stellarSignTx.d.ts +7 -7
- package/lib/api/stellar/stellarSignTx.js +37 -51
- package/lib/api/telemetryGet.d.ts +14 -0
- package/lib/api/telemetryGet.js +26 -0
- package/lib/api/tezos/api/index.d.ts +3 -4
- package/lib/api/tezos/api/index.js +3 -29
- package/lib/api/tezos/api/tezosGetAddress.d.ts +17 -27
- package/lib/api/tezos/api/tezosGetAddress.js +12 -101
- package/lib/api/tezos/api/tezosGetPublicKey.d.ts +27 -20
- package/lib/api/tezos/api/tezosGetPublicKey.js +53 -37
- package/lib/api/tezos/api/tezosSignTransaction.d.ts +13 -11
- package/lib/api/tezos/api/tezosSignTransaction.js +20 -26
- package/lib/api/tezos/tezosSignTx.d.ts +66 -67
- package/lib/api/tezos/tezosSignTx.js +12 -19
- package/lib/api/thpGetCredentials.d.ts +12 -9
- package/lib/api/thpGetCredentials.js +21 -25
- package/lib/api/thpRemoveCredentials.d.ts +14 -7
- package/lib/api/thpRemoveCredentials.js +35 -30
- package/lib/api/tron/api/index.d.ts +3 -3
- package/lib/api/tron/api/index.js +3 -22
- package/lib/api/tron/api/tronComposeTransaction.d.ts +17 -0
- package/lib/api/tron/api/tronComposeTransaction.js +52 -0
- package/lib/api/tron/api/tronGetAddress.d.ts +17 -27
- package/lib/api/tron/api/tronGetAddress.js +12 -98
- package/lib/api/tron/api/tronSignTransaction.d.ts +16 -15
- package/lib/api/tron/api/tronSignTransaction.js +101 -27
- package/lib/api/tron/tronEncode.d.ts +11 -0
- package/lib/api/tron/tronEncode.js +157 -0
- package/lib/api/tron/tronProtobuf.d.ts +5 -0
- package/lib/api/tron/tronProtobuf.js +28 -0
- package/lib/api/unlockPath.d.ts +11 -9
- package/lib/api/unlockPath.js +18 -23
- package/lib/api/verifyMessage.d.ts +15 -9
- package/lib/api/verifyMessage.js +30 -34
- package/lib/api/wipeDevice.d.ts +19 -15
- package/lib/api/wipeDevice.js +22 -22
- package/lib/backend/BackendManager.d.ts +26 -20
- package/lib/backend/BackendManager.js +29 -29
- package/lib/backend/Blockchain.d.ts +78 -79
- package/lib/backend/Blockchain.js +34 -35
- package/lib/backend/BlockchainLink.d.ts +6 -6
- package/lib/backend/BlockchainLink.js +14 -27
- package/lib/backend/fees/BitcoinFeeLevels.d.ts +18 -19
- package/lib/backend/fees/BitcoinFeeLevels.js +11 -17
- package/lib/backend/fees/EthereumFeeLevels.d.ts +16 -17
- package/lib/backend/fees/EthereumFeeLevels.js +26 -22
- package/lib/backend/fees/MiscFeeLevels.d.ts +17 -18
- package/lib/backend/fees/MiscFeeLevels.js +13 -16
- package/lib/backend/fees/index.d.ts +4 -5
- package/lib/backend/fees/index.js +12 -21
- package/lib/core/AbstractMethod.d.ts +57 -72
- package/lib/core/AbstractMethod.js +92 -170
- package/lib/core/index.d.ts +25 -28
- package/lib/core/index.js +292 -493
- package/lib/core/method.d.ts +3 -4
- package/lib/core/method.js +9 -18
- package/lib/core/method.native.d.ts +2 -3
- package/lib/core/method.native.js +8 -19
- package/lib/core/onCallFirmwareUpdate.d.ts +33 -32
- package/lib/core/onCallFirmwareUpdate.js +103 -63
- package/lib/data/coinInfo.d.ts +86 -431
- package/lib/data/coinInfo.js +55 -57
- package/lib/data/config.d.ts +5 -30
- package/lib/data/config.js +52 -149
- package/lib/data/defaultFeeLevels.d.ts +10 -11
- package/lib/data/defaultFeeLevels.js +39 -23
- package/lib/data/enabledNetworksStore.d.ts +5 -0
- package/lib/data/enabledNetworksStore.js +20 -0
- package/lib/data/firmwareInfo.d.ts +39 -37
- package/lib/data/firmwareInfo.js +99 -167
- package/lib/data/firmwareReleaseStore.d.ts +10 -0
- package/lib/data/firmwareReleaseStore.js +16 -0
- package/lib/data/localFirmwareStore.d.ts +3 -0
- package/lib/data/localFirmwareStore.js +8 -0
- package/lib/data/protobufLoader.d.ts +1 -0
- package/lib/data/protobufLoader.js +30 -0
- package/lib/data/settingsStore.d.ts +6 -0
- package/lib/data/settingsStore.js +21 -0
- package/lib/device/Device.d.ts +255 -289
- package/lib/device/Device.js +203 -204
- package/lib/device/DeviceCommands.d.ts +82 -69
- package/lib/device/DeviceCommands.js +35 -36
- package/lib/device/DeviceCurrentSession.d.ts +746 -1093
- package/lib/device/DeviceCurrentSession.js +32 -53
- package/lib/device/DeviceList.d.ts +65 -59
- package/lib/device/DeviceList.js +80 -76
- package/lib/device/TransportList.d.ts +3 -9
- package/lib/device/TransportList.js +11 -50
- package/lib/device/TransportManager.d.ts +25 -22
- package/lib/device/TransportManager.js +15 -21
- package/lib/device/calculateRevisionForDevice.d.ts +8 -6
- package/lib/device/calculateRevisionForDevice.js +7 -15
- package/lib/device/checkFirmwareRevision.d.ts +20 -10
- package/lib/device/checkFirmwareRevision.js +43 -22
- package/lib/device/resolveDescriptorForTaproot.d.ts +13 -11
- package/lib/device/resolveDescriptorForTaproot.js +9 -15
- package/lib/device/thp/handshake.d.ts +3 -4
- package/lib/device/thp/handshake.js +27 -39
- package/lib/device/thp/index.d.ts +5 -6
- package/lib/device/thp/index.js +37 -41
- package/lib/device/thp/pairing.d.ts +13 -13
- package/lib/device/thp/pairing.js +88 -84
- package/lib/device/thp/session.d.ts +2 -3
- package/lib/device/thp/session.js +4 -12
- package/lib/device/thp/thpCall.d.ts +22 -32
- package/lib/device/thp/thpCall.js +14 -20
- package/lib/device/validateMessageSize.d.ts +2 -0
- package/lib/device/validateMessageSize.js +9 -0
- package/lib/device/workflow/changeLanguage.d.ts +18 -0
- package/lib/device/workflow/changeLanguage.js +62 -0
- package/lib/device/workflow/checkFirmwareHash.d.ts +10 -8
- package/lib/device/workflow/checkFirmwareHash.js +20 -28
- package/lib/device/workflow/checkFirmwareHashWithRetries.d.ts +5 -6
- package/lib/device/workflow/checkFirmwareHashWithRetries.js +9 -17
- package/lib/device/workflow/handshake.d.ts +11 -8
- package/lib/device/workflow/handshake.js +13 -21
- package/lib/device/workflow/trezorPushNotification.d.ts +5 -3
- package/lib/device/workflow/trezorPushNotification.js +28 -36
- package/lib/device/workflow/validateState.d.ts +2 -3
- package/lib/device/workflow/validateState.js +35 -59
- package/lib/events/ui-promise.d.ts +14 -14
- package/lib/events/ui-promise.js +1 -6
- package/lib/exports.d.ts +3 -5
- package/lib/exports.js +3 -18
- package/lib/impl/core-in-module.d.ts +33 -35
- package/lib/impl/core-in-module.js +124 -146
- package/lib/index.browser.d.ts +7 -0
- package/lib/index.browser.js +34 -0
- package/lib/index.d.ts +3 -9
- package/lib/index.js +15 -178
- package/lib/types/idevice.d.ts +110 -0
- package/lib/types/idevice.js +1 -0
- package/lib/types/typed-call-provider.d.ts +29 -0
- package/lib/types/typed-call-provider.js +1 -0
- package/lib/types/workflow.d.ts +13 -9
- package/lib/types/workflow.js +1 -6
- package/lib/utils/accountUtils.d.ts +4 -5
- package/lib/utils/accountUtils.js +28 -32
- package/lib/utils/addressUtils.d.ts +2 -3
- package/lib/utils/addressUtils.js +4 -12
- package/lib/utils/assetUtils.d.ts +8 -5
- package/lib/utils/assetUtils.js +36 -28
- package/lib/utils/assets.browser.d.ts +1 -0
- package/lib/utils/assets.browser.js +1 -0
- package/lib/utils/assets.d.ts +2 -3
- package/lib/utils/assets.js +8 -17
- package/lib/utils/assets.native.d.ts +2 -3
- package/lib/utils/assets.native.js +5 -12
- package/lib/utils/assetsTypes.d.ts +2 -3
- package/lib/utils/assetsTypes.js +1 -6
- package/lib/utils/buildOutputDescriptor.d.ts +20 -0
- package/lib/utils/buildOutputDescriptor.js +67 -0
- package/lib/utils/deviceFeaturesUtils.d.ts +4 -5
- package/lib/utils/deviceFeaturesUtils.js +24 -38
- package/lib/utils/ethereumUtils.d.ts +2 -3
- package/lib/utils/ethereumUtils.js +3 -11
- package/lib/utils/firmwareReleaseConfigUtils.d.ts +16 -7
- package/lib/utils/firmwareReleaseConfigUtils.js +71 -31
- package/lib/utils/firmwareUtils.d.ts +7 -7
- package/lib/utils/firmwareUtils.js +24 -37
- package/lib/utils/formatUtils.d.ts +6 -8
- package/lib/utils/formatUtils.js +21 -60
- package/lib/utils/hdnodeUtils.d.ts +2 -3
- package/lib/utils/hdnodeUtils.js +14 -25
- package/lib/utils/pathUtils.d.ts +1 -21
- package/lib/utils/pathUtils.js +1 -172
- package/lib/utils/paymentRequest.d.ts +8 -0
- package/lib/utils/paymentRequest.js +25 -0
- package/lib/utils/uiPromiseManager.d.ts +8 -43
- package/lib/utils/uiPromiseManager.js +19 -31
- package/lib/workers/workers.browser.d.ts +10 -0
- package/lib/workers/workers.browser.js +16 -0
- package/lib/workers/workers.d.ts +2 -2
- package/lib/workers/workers.js +8 -60
- package/lib/workers/workers.native.d.ts +2 -3
- package/lib/workers/workers.native.js +7 -20
- package/package.json +84 -75
- package/lib/api/eos/api/eosGetPublicKey.d.ts +0 -23
- package/lib/api/eos/api/eosGetPublicKey.js +0 -69
- package/lib/api/eos/api/eosSignTransaction.d.ts +0 -18
- package/lib/api/eos/api/eosSignTransaction.js +0 -48
- package/lib/api/eos/api/index.d.ts +0 -3
- package/lib/api/eos/api/index.js +0 -22
- package/lib/api/eos/eosSignTx.d.ts +0 -175
- package/lib/api/eos/eosSignTx.js +0 -344
- package/lib/api/getAccountDescriptor.d.ts +0 -22
- package/lib/api/getAccountDescriptor.js +0 -139
- package/lib/api/nem/api/index.d.ts +0 -3
- package/lib/api/nem/api/index.js +0 -22
- package/lib/api/nem/api/nemGetAddress.d.ts +0 -26
- package/lib/api/nem/api/nemGetAddress.js +0 -129
- package/lib/api/nem/api/nemSignTransaction.d.ts +0 -11
- package/lib/api/nem/api/nemSignTransaction.js +0 -39
- package/lib/api/nem/nemSignTx.d.ts +0 -78
- package/lib/api/nem/nemSignTx.js +0 -143
- package/lib/api/setProxy.d.ts +0 -8
- package/lib/api/setProxy.js +0 -32
- package/lib/api/solana/additionalInfo.d.ts +0 -10
- package/lib/api/solana/additionalInfo.js +0 -24
- package/lib/api/solana/solanaUtils.d.ts +0 -49
- package/lib/api/solana/solanaUtils.js +0 -279
- package/lib/constants/cardano.d.ts +0 -14
- package/lib/constants/cardano.js +0 -23
- package/lib/constants/errors.d.ts +0 -64
- package/lib/constants/errors.js +0 -87
- package/lib/constants/firmware.d.ts +0 -4
- package/lib/constants/firmware.js +0 -10
- package/lib/constants/index.d.ts +0 -8
- package/lib/constants/index.js +0 -27
- package/lib/constants/nem.d.ts +0 -29
- package/lib/constants/nem.js +0 -35
- package/lib/constants/network.d.ts +0 -17
- package/lib/constants/network.js +0 -21
- package/lib/constants/utxo.d.ts +0 -3
- package/lib/constants/utxo.js +0 -8
- package/lib/data/DataManager.d.ts +0 -31
- package/lib/data/DataManager.js +0 -100
- package/lib/data/analyticsInfo.d.ts +0 -6
- package/lib/data/analyticsInfo.js +0 -43
- package/lib/data/connectSettings.d.ts +0 -9
- package/lib/data/connectSettings.js +0 -147
- package/lib/data/thpSettings.d.ts +0 -3
- package/lib/data/thpSettings.js +0 -41
- package/lib/data/udevInfo.d.ts +0 -11
- package/lib/data/udevInfo.js +0 -31
- package/lib/data/version.d.ts +0 -6
- package/lib/data/version.js +0 -14
- package/lib/device/StateStorage.d.ts +0 -15
- package/lib/device/StateStorage.js +0 -40
- package/lib/device/workflow/index.d.ts +0 -2
- package/lib/device/workflow/index.js +0 -14
- package/lib/events/blockchain.d.ts +0 -66
- package/lib/events/blockchain.js +0 -22
- package/lib/events/call.d.ts +0 -46
- package/lib/events/call.js +0 -22
- package/lib/events/core.d.ts +0 -24
- package/lib/events/core.js +0 -32
- package/lib/events/device.d.ts +0 -70
- package/lib/events/device.js +0 -42
- package/lib/events/iframe.d.ts +0 -46
- package/lib/events/iframe.js +0 -22
- package/lib/events/index.d.ts +0 -68
- package/lib/events/index.js +0 -25
- package/lib/events/popup.d.ts +0 -88
- package/lib/events/popup.js +0 -29
- package/lib/events/transport.d.ts +0 -51
- package/lib/events/transport.js +0 -26
- package/lib/events/ui-request.d.ts +0 -266
- package/lib/events/ui-request.js +0 -57
- package/lib/events/ui-response.d.ts +0 -104
- package/lib/events/ui-response.js +0 -29
- package/lib/events/webextension.d.ts +0 -8
- package/lib/events/webextension.js +0 -14
- package/lib/factory.d.ts +0 -20
- package/lib/factory.js +0 -50
- package/lib/impl/dynamic.d.ts +0 -39
- package/lib/impl/dynamic.js +0 -125
- package/lib/index-browser.d.ts +0 -7
- package/lib/index-browser.js +0 -29
- package/lib/tsconfig.lib.tsbuildinfo +0 -1
- package/lib/types/account.d.ts +0 -20
- package/lib/types/account.js +0 -6
- package/lib/types/api/applyFlags.d.ts +0 -4
- package/lib/types/api/applyFlags.js +0 -6
- package/lib/types/api/applySettings.d.ts +0 -23
- package/lib/types/api/applySettings.js +0 -12
- package/lib/types/api/authenticateDevice.d.ts +0 -65
- package/lib/types/api/authenticateDevice.js +0 -14
- package/lib/types/api/authorizeCoinjoin.d.ts +0 -17
- package/lib/types/api/authorizeCoinjoin.js +0 -21
- package/lib/types/api/backupDevice.d.ts +0 -4
- package/lib/types/api/backupDevice.js +0 -6
- package/lib/types/api/bitcoin/index.d.ts +0 -101
- package/lib/types/api/bitcoin/index.js +0 -23
- package/lib/types/api/bleUnpair.d.ts +0 -4
- package/lib/types/api/bleUnpair.js +0 -6
- package/lib/types/api/blockchainDisconnect.d.ts +0 -5
- package/lib/types/api/blockchainDisconnect.js +0 -6
- package/lib/types/api/blockchainEstimateFee.d.ts +0 -26
- package/lib/types/api/blockchainEstimateFee.js +0 -6
- package/lib/types/api/blockchainEvmRpcCall.d.ts +0 -4
- package/lib/types/api/blockchainEvmRpcCall.js +0 -6
- package/lib/types/api/blockchainGetAccountBalanceHistory.d.ts +0 -4
- package/lib/types/api/blockchainGetAccountBalanceHistory.js +0 -6
- package/lib/types/api/blockchainGetCurrentFiatRates.d.ts +0 -4
- package/lib/types/api/blockchainGetCurrentFiatRates.js +0 -6
- package/lib/types/api/blockchainGetFiatRatesForTimestamps.d.ts +0 -4
- package/lib/types/api/blockchainGetFiatRatesForTimestamps.js +0 -6
- package/lib/types/api/blockchainGetInfo.d.ts +0 -4
- package/lib/types/api/blockchainGetInfo.js +0 -6
- package/lib/types/api/blockchainGetTransactions.d.ts +0 -7
- package/lib/types/api/blockchainGetTransactions.js +0 -6
- package/lib/types/api/blockchainSetCustomBackend.d.ts +0 -8
- package/lib/types/api/blockchainSetCustomBackend.js +0 -6
- package/lib/types/api/blockchainSubscribe.d.ts +0 -8
- package/lib/types/api/blockchainSubscribe.js +0 -6
- package/lib/types/api/blockchainSubscribeFiatRates.d.ts +0 -7
- package/lib/types/api/blockchainSubscribeFiatRates.js +0 -6
- package/lib/types/api/blockchainUnsubscribe.d.ts +0 -5
- package/lib/types/api/blockchainUnsubscribe.js +0 -6
- package/lib/types/api/blockchainUnsubscribeFiatRates.d.ts +0 -5
- package/lib/types/api/blockchainUnsubscribeFiatRates.js +0 -6
- package/lib/types/api/cancel.d.ts +0 -2
- package/lib/types/api/cancel.js +0 -6
- package/lib/types/api/cancelCoinjoinAuthorization.d.ts +0 -9
- package/lib/types/api/cancelCoinjoinAuthorization.js +0 -11
- package/lib/types/api/cardano/index.d.ts +0 -784
- package/lib/types/api/cardano/index.js +0 -241
- package/lib/types/api/cardanoComposeTransaction.d.ts +0 -150
- package/lib/types/api/cardanoComposeTransaction.js +0 -91
- package/lib/types/api/cardanoGetAddress.d.ts +0 -5
- package/lib/types/api/cardanoGetAddress.js +0 -6
- package/lib/types/api/cardanoGetNativeScriptHash.d.ts +0 -4
- package/lib/types/api/cardanoGetNativeScriptHash.js +0 -6
- package/lib/types/api/cardanoGetPublicKey.d.ts +0 -5
- package/lib/types/api/cardanoGetPublicKey.js +0 -6
- package/lib/types/api/cardanoSignMessage.d.ts +0 -4
- package/lib/types/api/cardanoSignMessage.js +0 -6
- package/lib/types/api/cardanoSignTransaction.d.ts +0 -10
- package/lib/types/api/cardanoSignTransaction.js +0 -6
- package/lib/types/api/changeLanguage.d.ts +0 -15
- package/lib/types/api/changeLanguage.js +0 -17
- package/lib/types/api/changePin.d.ts +0 -4
- package/lib/types/api/changePin.js +0 -6
- package/lib/types/api/changeWipeCode.d.ts +0 -4
- package/lib/types/api/changeWipeCode.js +0 -6
- package/lib/types/api/cipherKeyValue.d.ts +0 -18
- package/lib/types/api/cipherKeyValue.js +0 -18
- package/lib/types/api/composeTransaction.d.ts +0 -74
- package/lib/types/api/composeTransaction.js +0 -6
- package/lib/types/api/device.d.ts +0 -1
- package/lib/types/api/device.js +0 -1
- package/lib/types/api/disableWebUSB.d.ts +0 -2
- package/lib/types/api/disableWebUSB.js +0 -6
- package/lib/types/api/discoverAccounts.d.ts +0 -248
- package/lib/types/api/discoverAccounts.js +0 -210
- package/lib/types/api/dispose.d.ts +0 -2
- package/lib/types/api/dispose.js +0 -6
- package/lib/types/api/eos/index.d.ts +0 -784
- package/lib/types/api/eos/index.js +0 -124
- package/lib/types/api/eosGetPublicKey.d.ts +0 -5
- package/lib/types/api/eosGetPublicKey.js +0 -6
- package/lib/types/api/eosSignTransaction.d.ts +0 -5
- package/lib/types/api/eosSignTransaction.js +0 -6
- package/lib/types/api/ethereum/index.d.ts +0 -307
- package/lib/types/api/ethereum/index.js +0 -101
- package/lib/types/api/ethereumGetAddress.d.ts +0 -4
- package/lib/types/api/ethereumGetAddress.js +0 -6
- package/lib/types/api/ethereumGetPublicKey.d.ts +0 -5
- package/lib/types/api/ethereumGetPublicKey.js +0 -6
- package/lib/types/api/ethereumSignMessage.d.ts +0 -5
- package/lib/types/api/ethereumSignMessage.js +0 -6
- package/lib/types/api/ethereumSignTransaction.d.ts +0 -4
- package/lib/types/api/ethereumSignTransaction.js +0 -6
- package/lib/types/api/ethereumSignTypedData.d.ts +0 -6
- package/lib/types/api/ethereumSignTypedData.js +0 -6
- package/lib/types/api/ethereumVerifyMessage.d.ts +0 -5
- package/lib/types/api/ethereumVerifyMessage.js +0 -6
- package/lib/types/api/evoluGetDelegatedIdentityKey.d.ts +0 -9
- package/lib/types/api/evoluGetDelegatedIdentityKey.js +0 -6
- package/lib/types/api/evoluGetNode.d.ts +0 -4
- package/lib/types/api/evoluGetNode.js +0 -6
- package/lib/types/api/evoluSignRegistrationRequest.d.ts +0 -4
- package/lib/types/api/evoluSignRegistrationRequest.js +0 -6
- package/lib/types/api/firmwareUpdate.d.ts +0 -21
- package/lib/types/api/firmwareUpdate.js +0 -16
- package/lib/types/api/getAccountDescriptor.d.ts +0 -18
- package/lib/types/api/getAccountDescriptor.js +0 -16
- package/lib/types/api/getAccountInfo.d.ts +0 -16
- package/lib/types/api/getAccountInfo.js +0 -6
- package/lib/types/api/getAddress.d.ts +0 -48
- package/lib/types/api/getAddress.js +0 -17
- package/lib/types/api/getCoinInfo.d.ts +0 -6
- package/lib/types/api/getCoinInfo.js +0 -6
- package/lib/types/api/getDeviceState.d.ts +0 -8
- package/lib/types/api/getDeviceState.js +0 -6
- package/lib/types/api/getFeatures.d.ts +0 -4
- package/lib/types/api/getFeatures.js +0 -6
- package/lib/types/api/getFirmwareHash.d.ts +0 -4
- package/lib/types/api/getFirmwareHash.js +0 -6
- package/lib/types/api/getNonce.d.ts +0 -4
- package/lib/types/api/getNonce.js +0 -6
- package/lib/types/api/getOwnershipId.d.ts +0 -41
- package/lib/types/api/getOwnershipId.js +0 -16
- package/lib/types/api/getOwnershipProof.d.ts +0 -45
- package/lib/types/api/getOwnershipProof.js +0 -22
- package/lib/types/api/getPublicKey.d.ts +0 -37
- package/lib/types/api/getPublicKey.js +0 -31
- package/lib/types/api/getSettings.d.ts +0 -4
- package/lib/types/api/getSettings.js +0 -6
- package/lib/types/api/index.d.ts +0 -203
- package/lib/types/api/index.js +0 -6
- package/lib/types/api/init.d.ts +0 -7
- package/lib/types/api/init.js +0 -6
- package/lib/types/api/loadDevice.d.ts +0 -4
- package/lib/types/api/loadDevice.js +0 -6
- package/lib/types/api/manifest.d.ts +0 -3
- package/lib/types/api/manifest.js +0 -6
- package/lib/types/api/monero/index.d.ts +0 -280
- package/lib/types/api/monero/index.js +0 -178
- package/lib/types/api/moneroGetAddress.d.ts +0 -5
- package/lib/types/api/moneroGetAddress.js +0 -6
- package/lib/types/api/moneroGetWatchKey.d.ts +0 -4
- package/lib/types/api/moneroGetWatchKey.js +0 -6
- package/lib/types/api/moneroKeyImageSync.d.ts +0 -4
- package/lib/types/api/moneroKeyImageSync.js +0 -6
- package/lib/types/api/moneroSignTransaction.d.ts +0 -4
- package/lib/types/api/moneroSignTransaction.js +0 -6
- package/lib/types/api/nem/index.d.ts +0 -842
- package/lib/types/api/nem/index.js +0 -99
- package/lib/types/api/nemGetAddress.d.ts +0 -14
- package/lib/types/api/nemGetAddress.js +0 -12
- package/lib/types/api/nemSignTransaction.d.ts +0 -5
- package/lib/types/api/nemSignTransaction.js +0 -6
- package/lib/types/api/off.d.ts +0 -11
- package/lib/types/api/off.js +0 -6
- package/lib/types/api/on.d.ts +0 -14
- package/lib/types/api/on.js +0 -6
- package/lib/types/api/pushTransaction.d.ts +0 -16
- package/lib/types/api/pushTransaction.js +0 -16
- package/lib/types/api/recoveryDevice.d.ts +0 -17
- package/lib/types/api/recoveryDevice.js +0 -12
- package/lib/types/api/removeAllListeners.d.ts +0 -3
- package/lib/types/api/removeAllListeners.js +0 -6
- package/lib/types/api/renderWebUSBButton.d.ts +0 -2
- package/lib/types/api/renderWebUSBButton.js +0 -6
- package/lib/types/api/requestLogin.d.ts +0 -25
- package/lib/types/api/requestLogin.js +0 -16
- package/lib/types/api/requestWebUSBDevice.d.ts +0 -2
- package/lib/types/api/requestWebUSBDevice.js +0 -6
- package/lib/types/api/resetDevice.d.ts +0 -4
- package/lib/types/api/resetDevice.js +0 -6
- package/lib/types/api/ripple/index.d.ts +0 -41
- package/lib/types/api/ripple/index.js +0 -30
- package/lib/types/api/rippleGetAddress.d.ts +0 -4
- package/lib/types/api/rippleGetAddress.js +0 -6
- package/lib/types/api/rippleSignTransaction.d.ts +0 -4
- package/lib/types/api/rippleSignTransaction.js +0 -6
- package/lib/types/api/setBrightness.d.ts +0 -4
- package/lib/types/api/setBrightness.js +0 -6
- package/lib/types/api/setBusy.d.ts +0 -4
- package/lib/types/api/setBusy.js +0 -6
- package/lib/types/api/setProxy.d.ts +0 -8
- package/lib/types/api/setProxy.js +0 -6
- package/lib/types/api/setTransports.d.ts +0 -4
- package/lib/types/api/setTransports.js +0 -6
- package/lib/types/api/showDeviceTutorial.d.ts +0 -4
- package/lib/types/api/showDeviceTutorial.js +0 -6
- package/lib/types/api/signMessage.d.ts +0 -5
- package/lib/types/api/signMessage.js +0 -6
- package/lib/types/api/signTransaction.d.ts +0 -4
- package/lib/types/api/signTransaction.js +0 -6
- package/lib/types/api/solana/index.d.ts +0 -113
- package/lib/types/api/solana/index.js +0 -76
- package/lib/types/api/solanaComposeTransaction.d.ts +0 -4
- package/lib/types/api/solanaComposeTransaction.js +0 -6
- package/lib/types/api/solanaGetAddress.d.ts +0 -4
- package/lib/types/api/solanaGetAddress.js +0 -6
- package/lib/types/api/solanaGetPublicKey.d.ts +0 -5
- package/lib/types/api/solanaGetPublicKey.js +0 -6
- package/lib/types/api/solanaSignTransaction.d.ts +0 -4
- package/lib/types/api/solanaSignTransaction.js +0 -6
- package/lib/types/api/stellar/index.d.ts +0 -914
- package/lib/types/api/stellar/index.js +0 -194
- package/lib/types/api/stellarGetAddress.d.ts +0 -4
- package/lib/types/api/stellarGetAddress.js +0 -6
- package/lib/types/api/stellarSignTransaction.d.ts +0 -4
- package/lib/types/api/stellarSignTransaction.js +0 -6
- package/lib/types/api/tezos/index.d.ts +0 -163
- package/lib/types/api/tezos/index.js +0 -67
- package/lib/types/api/tezosGetAddress.d.ts +0 -4
- package/lib/types/api/tezosGetAddress.js +0 -6
- package/lib/types/api/tezosGetPublicKey.d.ts +0 -4
- package/lib/types/api/tezosGetPublicKey.js +0 -6
- package/lib/types/api/tezosSignTransaction.d.ts +0 -5
- package/lib/types/api/tezosSignTransaction.js +0 -6
- package/lib/types/api/thpGetCredentials.d.ts +0 -4
- package/lib/types/api/thpGetCredentials.js +0 -6
- package/lib/types/api/thpRemoveCredentials.d.ts +0 -7
- package/lib/types/api/thpRemoveCredentials.js +0 -6
- package/lib/types/api/tron/index.d.ts +0 -130
- package/lib/types/api/tron/index.js +0 -62
- package/lib/types/api/tronGetAddress.d.ts +0 -4
- package/lib/types/api/tronGetAddress.js +0 -6
- package/lib/types/api/tronSignTransaction.d.ts +0 -4
- package/lib/types/api/tronSignTransaction.js +0 -6
- package/lib/types/api/uiResponse.d.ts +0 -3
- package/lib/types/api/uiResponse.js +0 -6
- package/lib/types/api/unlockPath.d.ts +0 -10
- package/lib/types/api/unlockPath.js +0 -13
- package/lib/types/api/verifyMessage.d.ts +0 -5
- package/lib/types/api/verifyMessage.js +0 -6
- package/lib/types/api/wipeDevice.d.ts +0 -4
- package/lib/types/api/wipeDevice.js +0 -6
- package/lib/types/coinInfo.d.ts +0 -353
- package/lib/types/coinInfo.js +0 -79
- package/lib/types/device.d.ts +0 -133
- package/lib/types/device.js +0 -13
- package/lib/types/fees.d.ts +0 -36
- package/lib/types/fees.js +0 -39
- package/lib/types/firmware.d.ts +0 -25
- package/lib/types/firmware.js +0 -6
- package/lib/types/index.d.ts +0 -25
- package/lib/types/index.js +0 -39
- package/lib/types/params.d.ts +0 -93
- package/lib/types/params.js +0 -38
- package/lib/types/settings.d.ts +0 -80
- package/lib/types/settings.js +0 -6
- package/lib/types/utils.d.ts +0 -15
- package/lib/types/utils.js +0 -6
- package/lib/utils/assets-browser.d.ts +0 -3
- package/lib/utils/assets-browser.js +0 -29
- package/lib/utils/debug.d.ts +0 -7
- package/lib/utils/debug.js +0 -33
- package/lib/utils/interactionTimeout.d.ts +0 -10
- package/lib/utils/interactionTimeout.js +0 -37
- package/lib/utils/popupPromiseManager.d.ts +0 -8
- package/lib/utils/popupPromiseManager.js +0 -30
- package/lib/utils/proxy-event-emitter.d.ts +0 -21
- package/lib/utils/proxy-event-emitter.js +0 -69
- package/lib/utils/urlUtils.d.ts +0 -13
- package/lib/utils/urlUtils.js +0 -31
- package/lib/utils/versionCheck.d.ts +0 -3
- package/lib/utils/versionCheck.js +0 -16
- package/lib/workers/workers-browser.d.ts +0 -10
- package/lib/workers/workers-browser.js +0 -20
package/lib/core/index.js
CHANGED
|
@@ -1,129 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
sendCoreMessage
|
|
31
|
-
}) => {
|
|
32
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_UI_WINDOW));
|
|
33
|
-
return popupPromise.wait();
|
|
1
|
+
import EventEmitter from "events";
|
|
2
|
+
import { CORE_CALL, CORE_CALL_CANCEL, CORE_EVENT, DEVICE, POPUP, RESPONSE_EVENT, SET_ENABLED_NETWORKS, UI_EVENT, UI_REQUEST, UI_RESPONSE, createDeviceMessage, createResponseMessage, createTransportMessage, createUiMessage } from "@trezor/connect-common";
|
|
3
|
+
import { ERRORS } from "@trezor/connect-common/lib/constants/index.js";
|
|
4
|
+
import { parseLocalFirmwares } from "@trezor/connect-common/lib/data/connectSettings.js";
|
|
5
|
+
import { noopCreateLogger, noopLogger, setLogWriter } from "@trezor/connect-common/lib/utils/debug.js";
|
|
6
|
+
import { TRANSPORT, TRANSPORT_ERROR } from "@trezor/transport-common";
|
|
7
|
+
import { createDeferred, createLazy, getSynchronize, throwError } from "@trezor/utils";
|
|
8
|
+
import { getMethod } from "./method.js";
|
|
9
|
+
import { onCallFirmwareUpdate } from "./onCallFirmwareUpdate.js";
|
|
10
|
+
import { dispose as disposeBackend } from "../backend/BlockchainLink.js";
|
|
11
|
+
import * as enabledNetworksStore from "../data/enabledNetworksStore.js";
|
|
12
|
+
import { initializeFirmwareConfig } from "../data/firmwareInfo.js";
|
|
13
|
+
import * as firmwareReleaseStore from "../data/firmwareReleaseStore.js";
|
|
14
|
+
import * as localFirmwareStore from "../data/localFirmwareStore.js";
|
|
15
|
+
import { loadProtobufModules } from "../data/protobufLoader.js";
|
|
16
|
+
import * as settingsStore from "../data/settingsStore.js";
|
|
17
|
+
import { DeviceList, assertDeviceListConnected } from "../device/DeviceList.js";
|
|
18
|
+
import { validateState } from "../device/workflow/validateState.js";
|
|
19
|
+
import { createUiPromiseManager } from "../utils/uiPromiseManager.js";
|
|
20
|
+
const createSendCoreMessageWithCallId = (sendCoreMessage, callId) => message => {
|
|
21
|
+
const isUiRequestMessage = message.event === UI_EVENT && message.type.startsWith('ui-');
|
|
22
|
+
const hasCallId = 'callId' in message && Boolean(message.callId);
|
|
23
|
+
if (callId && isUiRequestMessage && !hasCallId) {
|
|
24
|
+
sendCoreMessage({
|
|
25
|
+
...message,
|
|
26
|
+
callId
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
sendCoreMessage(message);
|
|
34
31
|
};
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
const {
|
|
40
|
-
uiPromises,
|
|
41
|
-
deviceList,
|
|
42
|
-
sendCoreMessage
|
|
43
|
-
} = context;
|
|
44
|
-
(0, DeviceList_1.assertDeviceListConnected)(deviceList);
|
|
45
|
-
const isWebUsb = deviceList.getActiveTransports().some(t => t.type === 'WebUsbTransport');
|
|
32
|
+
const selectDevice = ({
|
|
33
|
+
deviceList
|
|
34
|
+
}, methodCallDevice) => {
|
|
35
|
+
assertDeviceListConnected(deviceList);
|
|
46
36
|
let device;
|
|
47
|
-
let showDeviceSelection = isWebUsb;
|
|
48
|
-
const isUsingPopup = DataManager_1.DataManager.getSettings('popup');
|
|
49
|
-
const origin = DataManager_1.DataManager.getSettings('origin');
|
|
50
|
-
const useCoreInPopup = DataManager_1.DataManager.getSettings('useCoreInPopup');
|
|
51
|
-
const {
|
|
52
|
-
preferredDevice
|
|
53
|
-
} = connect_common_1.storage.load().origin[origin] || {};
|
|
54
|
-
const preferredDeviceInList = preferredDevice?.state && deviceList.getDeviceByStaticState(preferredDevice.state);
|
|
55
37
|
if (methodCallDevice?.state?.staticSessionId) {
|
|
56
38
|
device = deviceList.getDeviceByStaticState(methodCallDevice.state.staticSessionId);
|
|
57
39
|
}
|
|
58
40
|
if (!device && methodCallDevice?.path) {
|
|
59
41
|
device = deviceList.getDeviceByPath(methodCallDevice.path);
|
|
60
42
|
}
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
device = preferredDeviceInList;
|
|
64
|
-
} else {
|
|
65
|
-
connect_common_1.storage.save(store => {
|
|
66
|
-
store.origin[origin] = {
|
|
67
|
-
...store.origin[origin],
|
|
68
|
-
preferredDevice: undefined
|
|
69
|
-
};
|
|
70
|
-
return store;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (device) {
|
|
75
|
-
showDeviceSelection = device.isUnreadable() || device.isUnacquired() && !!isUsingPopup;
|
|
76
|
-
} else {
|
|
77
|
-
const onlyDevice = deviceList.getOnlyDevice();
|
|
78
|
-
if (onlyDevice && (!isWebUsb || !isUsingPopup)) {
|
|
79
|
-
device = onlyDevice;
|
|
80
|
-
showDeviceSelection = device.isUnreadable() || device.isUnacquired() || !!useCoreInPopup;
|
|
81
|
-
} else {
|
|
82
|
-
showDeviceSelection = true;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (showDeviceSelection) {
|
|
86
|
-
uiPromises.create(events_2.UI.RECEIVE_DEVICE);
|
|
87
|
-
await waitForPopup(context);
|
|
88
|
-
(0, DeviceList_1.assertDeviceListConnected)(deviceList);
|
|
89
|
-
const onlyDevice = deviceList.getOnlyDevice();
|
|
90
|
-
if (onlyDevice && !onlyDevice.isUnreadable() && !onlyDevice.isUnacquired() && !isWebUsb && !useCoreInPopup) {
|
|
91
|
-
device = onlyDevice;
|
|
92
|
-
} else {
|
|
93
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.SELECT_DEVICE, {
|
|
94
|
-
webusb: isWebUsb,
|
|
95
|
-
devices: deviceList.getAllDevices().map(d => d.toMessageObject())
|
|
96
|
-
}));
|
|
97
|
-
if (uiPromises.exists(events_2.UI.RECEIVE_DEVICE)) {
|
|
98
|
-
const {
|
|
99
|
-
payload
|
|
100
|
-
} = await uiPromises.get(events_2.UI.RECEIVE_DEVICE);
|
|
101
|
-
if (payload.remember) {
|
|
102
|
-
const {
|
|
103
|
-
label,
|
|
104
|
-
path,
|
|
105
|
-
state
|
|
106
|
-
} = payload.device;
|
|
107
|
-
connect_common_1.storage.save(store => {
|
|
108
|
-
store.origin[origin] = {
|
|
109
|
-
...store.origin[origin],
|
|
110
|
-
preferredDevice: {
|
|
111
|
-
label,
|
|
112
|
-
path,
|
|
113
|
-
state
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
return store;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
device = deviceList.getDeviceByPath(payload.device.path);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} else if (uiPromises.exists(events_2.UI.RECEIVE_DEVICE)) {
|
|
123
|
-
await uiPromises.get(events_2.UI.RECEIVE_DEVICE);
|
|
43
|
+
if (!device) {
|
|
44
|
+
device = deviceList.getOnlyDevice();
|
|
124
45
|
}
|
|
125
46
|
if (!device) {
|
|
126
|
-
throw
|
|
47
|
+
throw ERRORS.TypedError('Device_NotFound');
|
|
127
48
|
}
|
|
128
49
|
return device;
|
|
129
50
|
};
|
|
@@ -132,244 +53,159 @@ const inner = async (context, method, device) => {
|
|
|
132
53
|
uiPromises,
|
|
133
54
|
sendCoreMessage
|
|
134
55
|
} = context;
|
|
135
|
-
const trustedHost = DataManager_1.DataManager.getSettings('trustedHost');
|
|
136
|
-
const isUsingPopup = DataManager_1.DataManager.getSettings('popup') ?? false;
|
|
137
56
|
const firmwareException = method.checkFirmwareRange();
|
|
138
57
|
if (firmwareException) {
|
|
139
|
-
|
|
140
|
-
if (firmwareException === events_2.UI.FIRMWARE_NOT_COMPATIBLE) {
|
|
141
|
-
await waitForPopup(context);
|
|
142
|
-
const uiPromise = uiPromises.create(events_2.UI.RECEIVE_CONFIRMATION, device);
|
|
143
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.FIRMWARE_NOT_COMPATIBLE, device.toMessageObject()));
|
|
144
|
-
const uiResp = await uiPromise.promise;
|
|
145
|
-
if (!uiResp.payload) {
|
|
146
|
-
throw constants_1.ERRORS.TypedError('Method_PermissionsNotGranted');
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
await waitForPopup(context);
|
|
150
|
-
sendCoreMessage((0, events_2.createUiMessage)(firmwareException, device.toMessageObject()));
|
|
151
|
-
await uiPromises.create(events_2.DEVICE.DISCONNECT, device).promise;
|
|
152
|
-
return Promise.reject(constants_1.ERRORS.TypedError('Method_Cancel'));
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
return Promise.reject(constants_1.ERRORS.TypedError('Device_FwException', firmwareException));
|
|
156
|
-
}
|
|
58
|
+
return Promise.reject(ERRORS.TypedError('Device_FwException', firmwareException));
|
|
157
59
|
}
|
|
158
|
-
const unexpectedMode = device.hasUnexpectedMode(method.allowDeviceMode
|
|
60
|
+
const unexpectedMode = device.hasUnexpectedMode(method.allowDeviceMode);
|
|
159
61
|
if (unexpectedMode) {
|
|
160
|
-
|
|
161
|
-
await waitForPopup(context);
|
|
162
|
-
sendCoreMessage((0, events_2.createUiMessage)(unexpectedMode, device.toMessageObject()));
|
|
163
|
-
await uiPromises.create(events_2.DEVICE.DISCONNECT, device).promise;
|
|
164
|
-
return Promise.reject(constants_1.ERRORS.TypedError('Device_ModeException', unexpectedMode));
|
|
165
|
-
}
|
|
166
|
-
return Promise.reject(constants_1.ERRORS.TypedError('Device_ModeException', unexpectedMode));
|
|
62
|
+
return Promise.reject(ERRORS.TypedError('Device_ModeException', unexpectedMode));
|
|
167
63
|
}
|
|
168
64
|
method.checkDeviceCapability();
|
|
169
|
-
method.checkPermissions({
|
|
170
|
-
origin: DataManager_1.DataManager.getSettings('origin')
|
|
171
|
-
});
|
|
172
|
-
if (!trustedHost && method.requiredPermissions.length > 0) {
|
|
173
|
-
await waitForPopup(context);
|
|
174
|
-
const uiPromise = uiPromises.create(events_2.UI.RECEIVE_PERMISSION, device);
|
|
175
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_PERMISSION, {
|
|
176
|
-
permissions: method.requiredPermissions,
|
|
177
|
-
device: device.toMessageObject()
|
|
178
|
-
}));
|
|
179
|
-
const {
|
|
180
|
-
granted,
|
|
181
|
-
remember
|
|
182
|
-
} = await uiPromise.promise.then(({
|
|
183
|
-
payload
|
|
184
|
-
}) => payload);
|
|
185
|
-
if (granted) {
|
|
186
|
-
method.savePermissions(!remember, {
|
|
187
|
-
origin: DataManager_1.DataManager.getSettings('origin')
|
|
188
|
-
});
|
|
189
|
-
} else {
|
|
190
|
-
return Promise.reject(constants_1.ERRORS.TypedError('Method_PermissionsNotGranted'));
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
65
|
const deviceNeedsBackup = device.features.backup_availability === 'Required';
|
|
194
66
|
if (deviceNeedsBackup) {
|
|
195
|
-
if (method.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
sendCoreMessage((0, analyticsInfo_1.enhanceMessageWithAnalytics)((0, events_2.createUiMessage)(events_2.UI.REQUEST_CONFIRMATION, {
|
|
67
|
+
if (method.confirmMissingBackup) {
|
|
68
|
+
const uiPromise = uiPromises.create(UI_RESPONSE.RECEIVE_CONFIRMATION, device);
|
|
69
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.REQUEST_CONFIRMATION, {
|
|
199
70
|
view: 'no-backup'
|
|
200
|
-
}
|
|
201
|
-
|
|
71
|
+
}, {
|
|
72
|
+
requestId: uiPromise.requestId
|
|
202
73
|
}));
|
|
203
74
|
const permitted = await uiPromise.promise.then(({
|
|
204
75
|
payload
|
|
205
76
|
}) => payload);
|
|
206
77
|
if (!permitted) {
|
|
207
|
-
return Promise.reject(
|
|
78
|
+
return Promise.reject(ERRORS.TypedError('Method_PermissionsNotGranted'));
|
|
208
79
|
}
|
|
209
80
|
}
|
|
210
|
-
|
|
211
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.DEVICE_NEEDS_BACKUP, device.toMessageObject()));
|
|
81
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.DEVICE_NEEDS_BACKUP, device.toMessageObject()));
|
|
212
82
|
}
|
|
213
83
|
if (device.firmwareStatus === 'outdated') {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
device: device.toMessageObject()
|
|
224
|
-
}));
|
|
225
|
-
const confirmed = await uiPromise.promise.then(({
|
|
226
|
-
payload
|
|
227
|
-
}) => payload);
|
|
228
|
-
if (!confirmed) {
|
|
229
|
-
return Promise.reject(constants_1.ERRORS.TypedError('Method_Cancel'));
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
const workflowCtx = {
|
|
234
|
-
device,
|
|
235
|
-
method,
|
|
236
|
-
signal: context.signal
|
|
237
|
-
};
|
|
238
|
-
await workflows.validateState(workflowCtx);
|
|
239
|
-
if (method.useUi) {
|
|
240
|
-
await waitForPopup(context);
|
|
241
|
-
} else {
|
|
242
|
-
sendCoreMessage((0, events_2.createPopupMessage)(events_2.POPUP.CANCEL_POPUP_REQUEST));
|
|
84
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.FIRMWARE_OUTDATED, device.toMessageObject()));
|
|
85
|
+
}
|
|
86
|
+
if (method.useDeviceState) {
|
|
87
|
+
await validateState({
|
|
88
|
+
device,
|
|
89
|
+
method,
|
|
90
|
+
signal: context.signal,
|
|
91
|
+
sendCoreMessage
|
|
92
|
+
});
|
|
243
93
|
}
|
|
244
94
|
try {
|
|
245
|
-
const response = await method.run(
|
|
246
|
-
|
|
95
|
+
const response = await method.run({
|
|
96
|
+
sendCoreMessage,
|
|
97
|
+
createUiPromise: uiPromises.create
|
|
98
|
+
});
|
|
99
|
+
return createResponseMessage(method.responseID, true, response, {
|
|
100
|
+
path: device.getUniquePath(),
|
|
101
|
+
state: device.getState(),
|
|
102
|
+
instance: device.getInstance()
|
|
103
|
+
});
|
|
247
104
|
} catch (error) {
|
|
248
105
|
return Promise.reject(error);
|
|
249
106
|
}
|
|
250
107
|
};
|
|
251
108
|
const onCall = async (context, message) => {
|
|
252
|
-
if (!message.id || !message.payload || message.type !==
|
|
253
|
-
throw
|
|
109
|
+
if (!message.id || !message.payload || message.type !== CORE_CALL) {
|
|
110
|
+
throw ERRORS.TypedError('Method_InvalidParameter', 'onCall: message.id or message.payload is missing');
|
|
254
111
|
}
|
|
255
112
|
const {
|
|
256
113
|
uiPromises,
|
|
257
114
|
callMethods,
|
|
258
115
|
methodSynchronize,
|
|
259
116
|
resolveWaitForFirstMethod,
|
|
260
|
-
sendCoreMessage
|
|
117
|
+
sendCoreMessage,
|
|
118
|
+
logger
|
|
261
119
|
} = context;
|
|
262
120
|
const responseID = message.id;
|
|
263
121
|
let method;
|
|
264
122
|
try {
|
|
265
123
|
method = await methodSynchronize(async () => {
|
|
266
|
-
|
|
267
|
-
const method2 = await
|
|
268
|
-
|
|
269
|
-
method2.postMessage = sendCoreMessage;
|
|
270
|
-
method2.createUiPromise = uiPromises.create;
|
|
271
|
-
method2.init();
|
|
124
|
+
logger.debug('loading method...');
|
|
125
|
+
const method2 = await getMethod(message);
|
|
126
|
+
logger.debug('method selected', method2.name);
|
|
272
127
|
await method2.initAsync?.();
|
|
273
128
|
return method2;
|
|
274
129
|
});
|
|
275
130
|
resolveWaitForFirstMethod();
|
|
276
131
|
callMethods.push(method);
|
|
277
132
|
} catch (error) {
|
|
278
|
-
sendCoreMessage((
|
|
279
|
-
sendCoreMessage((0, events_2.createResponseMessage)(responseID, false, {
|
|
133
|
+
sendCoreMessage(createResponseMessage(responseID, false, {
|
|
280
134
|
error
|
|
281
135
|
}));
|
|
282
136
|
return Promise.resolve();
|
|
283
137
|
}
|
|
284
|
-
if (
|
|
138
|
+
if (message.payload.__info) {
|
|
285
139
|
const response = method.getMethodInfo();
|
|
286
|
-
if (
|
|
140
|
+
if (message.payload.__precomposed) {
|
|
287
141
|
response.precomposed = await method.payloadToPrecomposed();
|
|
288
142
|
}
|
|
289
|
-
sendCoreMessage(
|
|
143
|
+
sendCoreMessage(createResponseMessage(method.responseID, true, response));
|
|
290
144
|
return Promise.resolve();
|
|
291
145
|
}
|
|
146
|
+
const sendCoreMessageWithCallId = createSendCoreMessageWithCallId(sendCoreMessage, method.callId);
|
|
147
|
+
const methodContext = {
|
|
148
|
+
...context,
|
|
149
|
+
sendCoreMessage: sendCoreMessageWithCallId
|
|
150
|
+
};
|
|
292
151
|
if (!method.useDevice) {
|
|
293
152
|
try {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const response = await method.run();
|
|
300
|
-
sendCoreMessage((0, events_2.createResponseMessage)(method.responseID, true, response));
|
|
153
|
+
const response = await method.run({
|
|
154
|
+
sendCoreMessage: sendCoreMessageWithCallId,
|
|
155
|
+
createUiPromise: uiPromises.create
|
|
156
|
+
});
|
|
157
|
+
sendCoreMessageWithCallId(createResponseMessage(method.responseID, true, response));
|
|
301
158
|
} catch (error) {
|
|
302
|
-
|
|
159
|
+
sendCoreMessageWithCallId(createResponseMessage(method.responseID, false, {
|
|
303
160
|
error
|
|
304
161
|
}));
|
|
305
162
|
}
|
|
306
163
|
return Promise.resolve();
|
|
307
164
|
}
|
|
308
|
-
|
|
309
|
-
origin: DataManager_1.DataManager.getSettings('origin')
|
|
310
|
-
})) {
|
|
311
|
-
sendCoreMessage((0, events_2.createPopupMessage)(events_2.POPUP.CANCEL_POPUP_REQUEST));
|
|
312
|
-
sendCoreMessage((0, events_2.createResponseMessage)(responseID, false, {
|
|
313
|
-
error: constants_1.ERRORS.TypedError('Method_NotAllowed')
|
|
314
|
-
}));
|
|
315
|
-
return Promise.resolve();
|
|
316
|
-
}
|
|
317
|
-
return await onCallDevice(context, message, method);
|
|
165
|
+
return await onCallDevice(methodContext, message, method);
|
|
318
166
|
};
|
|
319
167
|
const onCallDevice = async (context, message, method) => {
|
|
320
168
|
const {
|
|
321
169
|
deviceList,
|
|
322
170
|
callMethods,
|
|
323
|
-
sendCoreMessage
|
|
171
|
+
sendCoreMessage,
|
|
172
|
+
logger
|
|
324
173
|
} = context;
|
|
325
174
|
const responseID = message.id;
|
|
326
175
|
const {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
transports
|
|
331
|
-
} = DataManager_1.DataManager.getSettings();
|
|
176
|
+
transports,
|
|
177
|
+
pendingTransportEvent
|
|
178
|
+
} = settingsStore.get();
|
|
332
179
|
if (!deviceList.isConnected() && !deviceList.pendingConnection()) {
|
|
333
180
|
deviceList.init({
|
|
334
|
-
transports
|
|
181
|
+
transports,
|
|
182
|
+
pendingTransportEvent
|
|
335
183
|
});
|
|
336
184
|
}
|
|
337
185
|
await deviceList.pendingConnection();
|
|
338
|
-
const shouldRetry = ['web', 'webextension'].includes(env);
|
|
339
186
|
let tempDevice;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
await waitForPopup(context);
|
|
346
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.TRANSPORT));
|
|
347
|
-
if (deviceList.pendingConnection() && shouldRetry) {
|
|
348
|
-
while (deviceList.pendingConnection()) {
|
|
349
|
-
await deviceList.pendingConnection();
|
|
350
|
-
}
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
} else {
|
|
354
|
-
sendCoreMessage((0, events_2.createPopupMessage)(events_2.POPUP.CANCEL_POPUP_REQUEST));
|
|
355
|
-
}
|
|
356
|
-
sendCoreMessage((0, events_2.createResponseMessage)(responseID, false, {
|
|
357
|
-
error
|
|
358
|
-
}));
|
|
359
|
-
throw error;
|
|
187
|
+
try {
|
|
188
|
+
tempDevice = selectDevice(context, message.payload.device);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error.code === 'Transport_Missing') {
|
|
191
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.TRANSPORT));
|
|
360
192
|
}
|
|
193
|
+
sendCoreMessage(createResponseMessage(responseID, false, {
|
|
194
|
+
error
|
|
195
|
+
}));
|
|
196
|
+
throw error;
|
|
361
197
|
}
|
|
362
198
|
const device = tempDevice;
|
|
363
199
|
method.setDevice(device);
|
|
364
|
-
const previousCall = callMethods.filter(call => call && call !== method && call.device?.getUniquePath() === method.device
|
|
200
|
+
const previousCall = callMethods.filter(call => call && call !== method && call.device?.getUniquePath() === method.device?.getUniquePath());
|
|
365
201
|
if (previousCall.length > 0 && method.overridePreviousCall) {
|
|
366
202
|
previousCall.forEach(call => {
|
|
367
203
|
call.overridden = true;
|
|
368
204
|
});
|
|
369
|
-
const overrideError =
|
|
205
|
+
const overrideError = ERRORS.TypedError('Method_Override');
|
|
370
206
|
await device.interrupt(overrideError);
|
|
371
207
|
if (method.overridden) {
|
|
372
|
-
sendCoreMessage(
|
|
208
|
+
sendCoreMessage(createResponseMessage(method.responseID, false, {
|
|
373
209
|
error: overrideError
|
|
374
210
|
}));
|
|
375
211
|
throw overrideError;
|
|
@@ -378,20 +214,16 @@ const onCallDevice = async (context, message, method) => {
|
|
|
378
214
|
if (device.isUnacquired()) {
|
|
379
215
|
await device.currentRun;
|
|
380
216
|
} else {
|
|
381
|
-
sendCoreMessage(
|
|
382
|
-
error:
|
|
217
|
+
sendCoreMessage(createResponseMessage(responseID, false, {
|
|
218
|
+
error: ERRORS.TypedError('Device_CallInProgress')
|
|
383
219
|
}));
|
|
384
|
-
throw
|
|
220
|
+
throw ERRORS.TypedError('Device_CallInProgress');
|
|
385
221
|
}
|
|
386
222
|
}
|
|
387
223
|
device.setInstance(message.payload.device?.instance);
|
|
388
|
-
|
|
389
|
-
device.setState(method.deviceState);
|
|
390
|
-
}
|
|
224
|
+
device.setState(method.deviceState);
|
|
391
225
|
registerDeviceEvents(context, method)(device);
|
|
392
|
-
|
|
393
|
-
device.initStorage(new StateStorage_1.WebextensionStateStorage(origin));
|
|
394
|
-
}
|
|
226
|
+
method.resolveCardanoCapability();
|
|
395
227
|
let messageResponse;
|
|
396
228
|
try {
|
|
397
229
|
const innerAction = () => inner(context, method, device).then(response => {
|
|
@@ -404,29 +236,26 @@ const onCallDevice = async (context, message, method) => {
|
|
|
404
236
|
});
|
|
405
237
|
} catch (error) {
|
|
406
238
|
if (error.cause) {
|
|
407
|
-
|
|
239
|
+
logger.debug('device.run error caught, caused by:', error.cause);
|
|
408
240
|
}
|
|
409
241
|
if (error.code === 'Device_Disconnected') {
|
|
410
242
|
deviceList.addAuthPenalty(device);
|
|
411
243
|
}
|
|
412
244
|
if (method) {
|
|
413
|
-
if (deviceList.isConnected() && error.message ===
|
|
245
|
+
if (deviceList.isConnected() && error.message === TRANSPORT_ERROR.SESSION_WRONG_PREVIOUS) {
|
|
414
246
|
await deviceList.enumerate();
|
|
415
247
|
}
|
|
416
|
-
messageResponse =
|
|
248
|
+
messageResponse = createResponseMessage(method.responseID, false, {
|
|
417
249
|
error
|
|
418
250
|
});
|
|
419
251
|
}
|
|
420
252
|
} finally {
|
|
421
253
|
if (method.keepSession && method.deviceState && method.deviceState.sessionId !== device.getState()?.sessionId) {
|
|
422
|
-
|
|
254
|
+
device.emitDeviceChanged();
|
|
423
255
|
}
|
|
424
256
|
const response = messageResponse;
|
|
425
257
|
if (response) {
|
|
426
258
|
device.eventNames().forEach(e => device.removeAllListeners(e));
|
|
427
|
-
if (useCoreInPopup) {
|
|
428
|
-
sendCoreMessage(response);
|
|
429
|
-
}
|
|
430
259
|
closePopup(context);
|
|
431
260
|
cleanup(context);
|
|
432
261
|
if (method) {
|
|
@@ -435,55 +264,38 @@ const onCallDevice = async (context, message, method) => {
|
|
|
435
264
|
if (response.success) {
|
|
436
265
|
deviceList.removeAuthPenalty(device);
|
|
437
266
|
}
|
|
438
|
-
|
|
439
|
-
sendCoreMessage(response);
|
|
440
|
-
}
|
|
267
|
+
sendCoreMessage(response);
|
|
441
268
|
}
|
|
442
269
|
}
|
|
443
270
|
};
|
|
444
271
|
const cleanup = ({
|
|
445
272
|
uiPromises,
|
|
446
|
-
|
|
447
|
-
interactionTimeout
|
|
273
|
+
logger
|
|
448
274
|
}) => {
|
|
449
|
-
popupPromise.clear();
|
|
450
275
|
uiPromises.clear();
|
|
451
|
-
|
|
452
|
-
_log.debug('Cleanup...');
|
|
276
|
+
logger.debug('Cleanup...');
|
|
453
277
|
};
|
|
454
278
|
const closePopup = ({
|
|
455
|
-
popupPromise,
|
|
456
279
|
sendCoreMessage
|
|
457
280
|
}) => {
|
|
458
|
-
|
|
459
|
-
sendCoreMessage((0, events_2.createPopupMessage)(events_2.POPUP.CANCEL_POPUP_REQUEST));
|
|
460
|
-
}
|
|
461
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.CLOSE_UI_WINDOW));
|
|
281
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW));
|
|
462
282
|
};
|
|
463
|
-
const onDeviceButtonHandler = (device, context, method) =>
|
|
283
|
+
const onDeviceButtonHandler = (device, context, method) => ({
|
|
464
284
|
payload: request
|
|
465
285
|
}) => {
|
|
466
286
|
const {
|
|
467
287
|
sendCoreMessage
|
|
468
288
|
} = context;
|
|
469
|
-
const addressRequest = request.code === 'ButtonRequest_Address';
|
|
470
|
-
if (!addressRequest || addressRequest && method?.useUi) {
|
|
471
|
-
await waitForPopup(context);
|
|
472
|
-
}
|
|
473
289
|
const data = typeof method?.getButtonRequestData === 'function' && request.code ? method?.getButtonRequestData(request.code, request.name) : undefined;
|
|
474
|
-
|
|
475
|
-
sendCoreMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.BUTTON, {
|
|
290
|
+
sendCoreMessage(createDeviceMessage(DEVICE.BUTTON, {
|
|
476
291
|
...request,
|
|
477
292
|
device: device.toMessageObject()
|
|
478
293
|
}));
|
|
479
|
-
sendCoreMessage(
|
|
294
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.REQUEST_BUTTON, {
|
|
480
295
|
...request,
|
|
481
296
|
device: device.toMessageObject(),
|
|
482
297
|
data
|
|
483
298
|
}));
|
|
484
|
-
if (addressRequest && !method?.useUi) {
|
|
485
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.ADDRESS_VALIDATION, data));
|
|
486
|
-
}
|
|
487
299
|
};
|
|
488
300
|
const onDevicePinHandler = (device, context) => async ({
|
|
489
301
|
type,
|
|
@@ -493,18 +305,19 @@ const onDevicePinHandler = (device, context) => async ({
|
|
|
493
305
|
uiPromises,
|
|
494
306
|
sendCoreMessage
|
|
495
307
|
} = context;
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_PIN, {
|
|
308
|
+
const uiPromise = uiPromises.create(UI_RESPONSE.RECEIVE_PIN, device);
|
|
309
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
499
310
|
device: device.toMessageObject(),
|
|
500
311
|
type
|
|
312
|
+
}, {
|
|
313
|
+
requestId: uiPromise.requestId
|
|
501
314
|
}));
|
|
502
315
|
try {
|
|
503
316
|
const uiResp = await uiPromise.promise;
|
|
504
317
|
if (uiResp.payload == null) {
|
|
505
318
|
callback({
|
|
506
319
|
success: false,
|
|
507
|
-
error: new Error(`${
|
|
320
|
+
error: new Error(`${UI_RESPONSE.RECEIVE_PIN} missing payload`)
|
|
508
321
|
});
|
|
509
322
|
} else {
|
|
510
323
|
callback({
|
|
@@ -527,18 +340,19 @@ const onDeviceWordHandler = (device, context) => async ({
|
|
|
527
340
|
uiPromises,
|
|
528
341
|
sendCoreMessage
|
|
529
342
|
} = context;
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_WORD, {
|
|
343
|
+
const uiPromise = uiPromises.create(UI_RESPONSE.RECEIVE_WORD, device);
|
|
344
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.REQUEST_WORD, {
|
|
533
345
|
device: device.toMessageObject(),
|
|
534
346
|
type
|
|
347
|
+
}, {
|
|
348
|
+
requestId: uiPromise.requestId
|
|
535
349
|
}));
|
|
536
350
|
try {
|
|
537
351
|
const uiResp = await uiPromise.promise;
|
|
538
352
|
if (uiResp.payload == null) {
|
|
539
353
|
callback({
|
|
540
354
|
success: false,
|
|
541
|
-
error: new Error(`${
|
|
355
|
+
error: new Error(`${UI_RESPONSE.RECEIVE_WORD} missing payload`)
|
|
542
356
|
});
|
|
543
357
|
} else {
|
|
544
358
|
callback({
|
|
@@ -560,17 +374,18 @@ const onDevicePassphraseHandler = (device, context) => async ({
|
|
|
560
374
|
uiPromises,
|
|
561
375
|
sendCoreMessage
|
|
562
376
|
} = context;
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_PASSPHRASE, {
|
|
377
|
+
const uiPromise = uiPromises.create(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
|
|
378
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE, {
|
|
566
379
|
device: device.toMessageObject()
|
|
380
|
+
}, {
|
|
381
|
+
requestId: uiPromise.requestId
|
|
567
382
|
}));
|
|
568
383
|
try {
|
|
569
384
|
const uiResp = await uiPromise.promise;
|
|
570
385
|
if (uiResp.payload == null) {
|
|
571
386
|
callback({
|
|
572
387
|
success: false,
|
|
573
|
-
error: new Error(`${
|
|
388
|
+
error: new Error(`${UI_RESPONSE.RECEIVE_PASSPHRASE} missing payload`)
|
|
574
389
|
});
|
|
575
390
|
} else {
|
|
576
391
|
callback({
|
|
@@ -603,18 +418,19 @@ const onThpPairingHandler = (device, context) => async ({
|
|
|
603
418
|
uiPromises,
|
|
604
419
|
sendCoreMessage
|
|
605
420
|
} = context;
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_THP_PAIRING, {
|
|
421
|
+
const uiPromise = uiPromises.create(UI_RESPONSE.RECEIVE_THP_PAIRING_TAG, device);
|
|
422
|
+
sendCoreMessage(createUiMessage(UI_REQUEST.REQUEST_THP_PAIRING, {
|
|
609
423
|
device: device.toMessageObject(),
|
|
610
424
|
...payload
|
|
425
|
+
}, {
|
|
426
|
+
requestId: uiPromise.requestId
|
|
611
427
|
}));
|
|
612
428
|
try {
|
|
613
429
|
const uiResp = await uiPromise.promise;
|
|
614
430
|
if (uiResp.payload == null) {
|
|
615
431
|
callback({
|
|
616
432
|
success: false,
|
|
617
|
-
error: new Error(`${
|
|
433
|
+
error: new Error(`${UI_RESPONSE.RECEIVE_THP_PAIRING_TAG} missing payload`)
|
|
618
434
|
});
|
|
619
435
|
} else {
|
|
620
436
|
callback({
|
|
@@ -633,50 +449,72 @@ const onThpCredentialsChangedHandler = (device, context) => payload => {
|
|
|
633
449
|
const {
|
|
634
450
|
sendCoreMessage
|
|
635
451
|
} = context;
|
|
636
|
-
sendCoreMessage(
|
|
452
|
+
sendCoreMessage(createDeviceMessage(DEVICE.THP_CREDENTIALS_CHANGED, {
|
|
453
|
+
device: device.toMessageObject(),
|
|
454
|
+
...payload
|
|
455
|
+
}));
|
|
456
|
+
};
|
|
457
|
+
const onThpPhaseChangedHandler = (device, context) => payload => {
|
|
458
|
+
const {
|
|
459
|
+
sendCoreMessage
|
|
460
|
+
} = context;
|
|
461
|
+
sendCoreMessage(createDeviceMessage(DEVICE.THP_PAIRING_STATUS_CHANGED, {
|
|
637
462
|
device: device.toMessageObject(),
|
|
638
463
|
...payload
|
|
639
464
|
}));
|
|
640
465
|
};
|
|
641
466
|
const registerDeviceEvents = (context, method) => device => {
|
|
642
467
|
device.removeAllListeners();
|
|
643
|
-
device.on(
|
|
644
|
-
device.on(
|
|
645
|
-
device.on(
|
|
646
|
-
device.on(
|
|
647
|
-
device.on(
|
|
648
|
-
context.sendCoreMessage(
|
|
468
|
+
device.on(DEVICE.BUTTON, onDeviceButtonHandler(device, context, method));
|
|
469
|
+
device.on(DEVICE.PIN, onDevicePinHandler(device, context));
|
|
470
|
+
device.on(DEVICE.WORD, onDeviceWordHandler(device, context));
|
|
471
|
+
device.on(DEVICE.PASSPHRASE, (method?.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler)(device, context));
|
|
472
|
+
device.on(DEVICE.PASSPHRASE_ON_DEVICE, () => {
|
|
473
|
+
context.sendCoreMessage(createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
649
474
|
device: device.toMessageObject()
|
|
650
475
|
}));
|
|
651
476
|
});
|
|
652
|
-
device.on(
|
|
653
|
-
context.sendCoreMessage(
|
|
477
|
+
device.on(DEVICE.FIRMWARE_VERSION_CHANGED, payload => {
|
|
478
|
+
context.sendCoreMessage(createDeviceMessage(DEVICE.FIRMWARE_VERSION_CHANGED, payload));
|
|
654
479
|
});
|
|
655
|
-
device.on(
|
|
656
|
-
device.on(
|
|
480
|
+
device.on(DEVICE.THP_PAIRING, onThpPairingHandler(device, context));
|
|
481
|
+
device.on(DEVICE.THP_CREDENTIALS_CHANGED, onThpCredentialsChangedHandler(device, context));
|
|
482
|
+
device.on(DEVICE.THP_PAIRING_STATUS_CHANGED, onThpPhaseChangedHandler(device, context));
|
|
657
483
|
};
|
|
658
|
-
const
|
|
484
|
+
const abortRunningCall = (context, error, callId) => {
|
|
659
485
|
const {
|
|
660
486
|
uiPromises,
|
|
661
|
-
popupPromise,
|
|
662
487
|
deviceList,
|
|
663
488
|
callMethods,
|
|
664
489
|
resetWaitForFirstMethod,
|
|
665
490
|
sendCoreMessage
|
|
666
491
|
} = context;
|
|
667
|
-
|
|
492
|
+
if (callId) {
|
|
493
|
+
const method = callMethods.find(m => m.callId === callId);
|
|
494
|
+
if (!method) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (method.device?.isUsedHere()) {
|
|
498
|
+
method.device.interrupt(error);
|
|
499
|
+
} else {
|
|
500
|
+
sendCoreMessage(createResponseMessage(method.responseID, false, {
|
|
501
|
+
error
|
|
502
|
+
}));
|
|
503
|
+
}
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
668
506
|
if (deviceList.isConnected() && deviceList.getDeviceCount() > 0) {
|
|
669
507
|
deviceList.getAllDevices().forEach(d => {
|
|
670
508
|
if (d.isUsedHere()) {
|
|
671
509
|
d.interrupt(error);
|
|
672
510
|
} else {
|
|
673
511
|
const success = uiPromises.resolve({
|
|
674
|
-
type:
|
|
512
|
+
type: DEVICE.DISCONNECT,
|
|
675
513
|
payload: undefined
|
|
676
514
|
});
|
|
677
515
|
if (!success) {
|
|
678
516
|
callMethods.forEach(m => {
|
|
679
|
-
sendCoreMessage(
|
|
517
|
+
sendCoreMessage(createResponseMessage(m.responseID, false, {
|
|
680
518
|
error
|
|
681
519
|
}));
|
|
682
520
|
});
|
|
@@ -687,117 +525,81 @@ const onPopupClosed = (context, customErrorMessage) => {
|
|
|
687
525
|
});
|
|
688
526
|
} else {
|
|
689
527
|
uiPromises.rejectAll(error);
|
|
690
|
-
popupPromise.reject(error);
|
|
691
528
|
}
|
|
692
529
|
cleanup(context);
|
|
693
530
|
};
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
} = context;
|
|
700
|
-
const promiseExists = uiPromises.exists(events_2.UI.RECEIVE_DEVICE);
|
|
701
|
-
if (promiseExists && deviceList.isConnected()) {
|
|
702
|
-
const onlyDevice = deviceList.getOnlyDevice();
|
|
703
|
-
const isWebUsb = deviceList.getActiveTransports().some(t => t.type === 'WebUsbTransport');
|
|
704
|
-
if (onlyDevice && !isWebUsb) {
|
|
705
|
-
uiPromises.resolve({
|
|
706
|
-
type: events_2.UI.RECEIVE_DEVICE,
|
|
707
|
-
payload: {
|
|
708
|
-
device: onlyDevice.toMessageObject()
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
} else {
|
|
712
|
-
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.SELECT_DEVICE, {
|
|
713
|
-
webusb: isWebUsb,
|
|
714
|
-
devices: deviceList.getAllDevices().map(d => d.toMessageObject())
|
|
715
|
-
}));
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
if (interruptDevice) {
|
|
719
|
-
const {
|
|
720
|
-
path
|
|
721
|
-
} = interruptDevice;
|
|
722
|
-
const shouldClosePopup = uiPromises.disconnected(path);
|
|
723
|
-
if (shouldClosePopup) {
|
|
724
|
-
closePopup(context);
|
|
725
|
-
cleanup(context);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
531
|
+
const onPopupClosed = context => {
|
|
532
|
+
abortRunningCall(context, ERRORS.TypedError('Method_Interrupted'));
|
|
533
|
+
};
|
|
534
|
+
const onCallCancel = (context, reason, callId) => {
|
|
535
|
+
abortRunningCall(context, ERRORS.TypedError('Method_Cancel', reason), callId);
|
|
728
536
|
};
|
|
729
537
|
const initDeviceList = context => {
|
|
730
538
|
const {
|
|
731
539
|
deviceList,
|
|
732
|
-
sendCoreMessage
|
|
540
|
+
sendCoreMessage,
|
|
541
|
+
logger
|
|
733
542
|
} = context;
|
|
734
|
-
deviceList.on(
|
|
735
|
-
|
|
736
|
-
sendCoreMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CONNECT, device.toMessageObject()));
|
|
543
|
+
deviceList.on(DEVICE.CONNECT, device => {
|
|
544
|
+
sendCoreMessage(createDeviceMessage(DEVICE.CONNECT, device.toMessageObject()));
|
|
737
545
|
});
|
|
738
|
-
deviceList.on(
|
|
739
|
-
|
|
740
|
-
sendCoreMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CONNECT_UNACQUIRED, device.toMessageObject()));
|
|
546
|
+
deviceList.on(DEVICE.CONNECT_UNACQUIRED, device => {
|
|
547
|
+
sendCoreMessage(createDeviceMessage(DEVICE.CONNECT_UNACQUIRED, device.toMessageObject()));
|
|
741
548
|
});
|
|
742
|
-
deviceList.on(
|
|
743
|
-
|
|
744
|
-
sendCoreMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.DISCONNECT, device.toMessageObject()));
|
|
549
|
+
deviceList.on(DEVICE.DISCONNECT, device => {
|
|
550
|
+
sendCoreMessage(createDeviceMessage(DEVICE.DISCONNECT, device.toMessageObject()));
|
|
745
551
|
});
|
|
746
|
-
deviceList.on(
|
|
747
|
-
sendCoreMessage(
|
|
552
|
+
deviceList.on(DEVICE.CHANGED, device => {
|
|
553
|
+
sendCoreMessage(createDeviceMessage(DEVICE.CHANGED, device.toMessageObject()));
|
|
748
554
|
});
|
|
749
|
-
deviceList.on(
|
|
750
|
-
sendCoreMessage(
|
|
555
|
+
deviceList.on(DEVICE.TREZOR_PUSH_NOTIFICATION, payload => {
|
|
556
|
+
sendCoreMessage(createDeviceMessage(DEVICE.TREZOR_PUSH_NOTIFICATION, {
|
|
751
557
|
device: payload.device.toMessageObject(),
|
|
752
558
|
mode: payload.mode,
|
|
753
559
|
type: payload.type
|
|
754
560
|
}));
|
|
755
561
|
});
|
|
756
|
-
deviceList.on(
|
|
757
|
-
deviceList.on(
|
|
758
|
-
|
|
759
|
-
sendCoreMessage(
|
|
562
|
+
deviceList.on(TRANSPORT.START, transport => sendCoreMessage(createTransportMessage(TRANSPORT.START, transport)));
|
|
563
|
+
deviceList.on(TRANSPORT.ERROR, error => {
|
|
564
|
+
logger.warn('TRANSPORT.ERROR', error.error);
|
|
565
|
+
sendCoreMessage(createTransportMessage(TRANSPORT.ERROR, error));
|
|
760
566
|
});
|
|
761
567
|
};
|
|
762
|
-
class Core extends
|
|
568
|
+
export class Core extends EventEmitter {
|
|
763
569
|
abortController = new AbortController();
|
|
764
570
|
callMethods = [];
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
get interactionTimeout() {
|
|
771
|
-
return this._interactionTimeout ?? (0, utils_1.throwError)('Core not initialized: interactionTimeout');
|
|
772
|
-
}
|
|
571
|
+
methodSynchronize = getSynchronize();
|
|
572
|
+
uiPromises = createUiPromiseManager();
|
|
573
|
+
createLogger = noopCreateLogger;
|
|
574
|
+
coreLogger = noopLogger;
|
|
575
|
+
waitForFirstMethod = createDeferred();
|
|
773
576
|
_deviceList;
|
|
774
577
|
get deviceList() {
|
|
775
|
-
return this._deviceList ??
|
|
578
|
+
return this._deviceList ?? throwError('Core not initialized: deviceList');
|
|
776
579
|
}
|
|
777
580
|
sendCoreMessage(message) {
|
|
778
|
-
if (message.event ===
|
|
779
|
-
const index = this.callMethods.findIndex(call => call
|
|
581
|
+
if (message.event === RESPONSE_EVENT) {
|
|
582
|
+
const index = this.callMethods.findIndex(call => call?.responseID === message.id);
|
|
780
583
|
if (index >= 0) {
|
|
781
584
|
this.callMethods.splice(index, 1);
|
|
782
585
|
if (this.callMethods.length === 0) {
|
|
783
|
-
this.waitForFirstMethod =
|
|
586
|
+
this.waitForFirstMethod = createDeferred();
|
|
784
587
|
}
|
|
785
588
|
}
|
|
786
589
|
}
|
|
787
|
-
this.emit(
|
|
590
|
+
this.emit(CORE_EVENT, message);
|
|
788
591
|
}
|
|
789
592
|
getCoreContext() {
|
|
790
593
|
return {
|
|
791
594
|
signal: this.abortController.signal,
|
|
792
595
|
uiPromises: this.uiPromises,
|
|
793
|
-
popupPromise: this.popupPromise,
|
|
794
|
-
interactionTimeout: this.interactionTimeout,
|
|
795
596
|
deviceList: this.deviceList,
|
|
597
|
+
logger: this.coreLogger,
|
|
796
598
|
callMethods: this.callMethods,
|
|
797
599
|
methodSynchronize: this.methodSynchronize,
|
|
798
600
|
sendCoreMessage: this.sendCoreMessage.bind(this),
|
|
799
601
|
resetWaitForFirstMethod: () => {
|
|
800
|
-
this.waitForFirstMethod =
|
|
602
|
+
this.waitForFirstMethod = createDeferred();
|
|
801
603
|
},
|
|
802
604
|
resolveWaitForFirstMethod: () => {
|
|
803
605
|
this.waitForFirstMethod.resolve();
|
|
@@ -805,93 +607,97 @@ class Core extends events_1.default {
|
|
|
805
607
|
};
|
|
806
608
|
}
|
|
807
609
|
handleMessage(message) {
|
|
808
|
-
|
|
610
|
+
this.coreLogger.debug('handleMessage', message.type);
|
|
809
611
|
switch (message.type) {
|
|
810
|
-
case
|
|
811
|
-
this.
|
|
612
|
+
case POPUP.CLOSED:
|
|
613
|
+
onPopupClosed(this.getCoreContext());
|
|
812
614
|
break;
|
|
813
|
-
case
|
|
814
|
-
this.
|
|
815
|
-
onPopupClosed(this.getCoreContext(), message.payload ? message.payload.error : null);
|
|
615
|
+
case CORE_CALL_CANCEL:
|
|
616
|
+
onCallCancel(this.getCoreContext(), message.payload?.reason, message.payload?.callId);
|
|
816
617
|
break;
|
|
817
|
-
case
|
|
818
|
-
{
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
if (transports && !transports.includes('BridgeTransport')) {
|
|
822
|
-
transports.unshift('BridgeTransport');
|
|
823
|
-
}
|
|
824
|
-
settings.transports = transports;
|
|
825
|
-
resetTransports(this.getCoreContext());
|
|
826
|
-
break;
|
|
827
|
-
}
|
|
828
|
-
case transport_1.TRANSPORT.SET_TRANSPORTS:
|
|
829
|
-
DataManager_1.DataManager.getSettings().transports = message.payload.transports;
|
|
618
|
+
case TRANSPORT.SET_TRANSPORTS:
|
|
619
|
+
settingsStore.update({
|
|
620
|
+
transports: message.payload.transports
|
|
621
|
+
});
|
|
830
622
|
resetTransports(this.getCoreContext());
|
|
831
623
|
break;
|
|
832
|
-
case
|
|
624
|
+
case SET_ENABLED_NETWORKS:
|
|
625
|
+
enabledNetworksStore.add(message.payload);
|
|
626
|
+
break;
|
|
627
|
+
case TRANSPORT.REQUEST_DEVICE:
|
|
833
628
|
if (this.deviceList.isConnected()) {
|
|
834
629
|
this.deviceList.enumerate();
|
|
835
630
|
}
|
|
836
631
|
break;
|
|
837
|
-
case
|
|
838
|
-
this.sendCoreMessage(
|
|
632
|
+
case TRANSPORT.GET_INFO:
|
|
633
|
+
this.sendCoreMessage(createResponseMessage(message.id, true, this.getActiveTransports()));
|
|
839
634
|
break;
|
|
840
|
-
case
|
|
841
|
-
case
|
|
842
|
-
case
|
|
843
|
-
case
|
|
844
|
-
case
|
|
845
|
-
case
|
|
846
|
-
case
|
|
847
|
-
case
|
|
848
|
-
case events_2.UI.RECEIVE_FEE:
|
|
849
|
-
case events_2.UI.RECEIVE_WORD:
|
|
850
|
-
case events_2.UI.LOGIN_CHALLENGE_RESPONSE:
|
|
635
|
+
case UI_RESPONSE.RECEIVE_CONFIRMATION:
|
|
636
|
+
case UI_RESPONSE.RECEIVE_PIN:
|
|
637
|
+
case UI_RESPONSE.RECEIVE_PASSPHRASE:
|
|
638
|
+
case UI_RESPONSE.RECEIVE_THP_PAIRING_TAG:
|
|
639
|
+
case UI_RESPONSE.RECEIVE_ACCOUNT:
|
|
640
|
+
case UI_RESPONSE.RECEIVE_FEE:
|
|
641
|
+
case UI_RESPONSE.RECEIVE_WORD:
|
|
642
|
+
case UI_RESPONSE.RECEIVE_DISCOVERY_ACCOUNTS:
|
|
851
643
|
this.uiPromises.resolve(message);
|
|
852
644
|
break;
|
|
853
|
-
case
|
|
645
|
+
case UI_RESPONSE.RECEIVE_FIRMWARE:
|
|
854
646
|
{
|
|
855
|
-
const localFirmwares = message.payload &&
|
|
647
|
+
const localFirmwares = message.payload && parseLocalFirmwares(message.payload);
|
|
856
648
|
if (localFirmwares) {
|
|
857
|
-
|
|
649
|
+
localFirmwareStore.set(localFirmwares);
|
|
858
650
|
}
|
|
859
651
|
break;
|
|
860
652
|
}
|
|
861
|
-
case
|
|
653
|
+
case CORE_CALL:
|
|
862
654
|
if (message.payload.method === 'firmwareUpdate') {
|
|
863
|
-
|
|
655
|
+
if (message.payload.__info) {
|
|
656
|
+
this.sendCoreMessage(createResponseMessage(message.id, true, {
|
|
657
|
+
name: 'firmwareUpdate',
|
|
658
|
+
info: 'Update firmware',
|
|
659
|
+
requiredPermissions: [{
|
|
660
|
+
permission: 'internal'
|
|
661
|
+
}],
|
|
662
|
+
useUi: true,
|
|
663
|
+
useDevice: true,
|
|
664
|
+
useDeviceState: false
|
|
665
|
+
}));
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
assertDeviceListConnected(this.deviceList);
|
|
864
669
|
const coreContext = this.getCoreContext();
|
|
865
|
-
(
|
|
670
|
+
const sendCoreMessageWithCallId = createSendCoreMessageWithCallId(this.sendCoreMessage.bind(this), message.payload.callId);
|
|
671
|
+
onCallFirmwareUpdate({
|
|
866
672
|
params: message.payload,
|
|
867
673
|
context: {
|
|
868
674
|
deviceList: this.deviceList,
|
|
869
|
-
postMessage:
|
|
870
|
-
|
|
675
|
+
postMessage: sendCoreMessageWithCallId,
|
|
676
|
+
selectDevice: path => selectDevice(coreContext, {
|
|
871
677
|
path
|
|
872
678
|
}),
|
|
873
|
-
log:
|
|
679
|
+
log: this.coreLogger,
|
|
874
680
|
abortSignal: this.abortController.signal,
|
|
875
681
|
registerEvents: registerDeviceEvents(coreContext),
|
|
876
682
|
uiPromises: coreContext.uiPromises
|
|
877
683
|
}
|
|
878
684
|
}).then(payload => {
|
|
879
|
-
this.sendCoreMessage(
|
|
685
|
+
this.sendCoreMessage(createResponseMessage(message.id, true, payload));
|
|
880
686
|
}).catch(error => {
|
|
881
|
-
this.sendCoreMessage(
|
|
687
|
+
this.sendCoreMessage(createResponseMessage(message.id, false, {
|
|
882
688
|
error
|
|
883
689
|
}));
|
|
884
|
-
|
|
690
|
+
this.coreLogger.error('onCallFirmwareUpdate', error);
|
|
885
691
|
});
|
|
886
692
|
} else {
|
|
887
693
|
onCall(this.getCoreContext(), message).catch(error => {
|
|
888
|
-
|
|
694
|
+
this.coreLogger.error('onCall', error);
|
|
889
695
|
});
|
|
890
696
|
}
|
|
891
697
|
}
|
|
892
698
|
}
|
|
893
699
|
dispose() {
|
|
894
|
-
(
|
|
700
|
+
disposeBackend();
|
|
895
701
|
this.removeAllListeners();
|
|
896
702
|
this.abortController.abort();
|
|
897
703
|
this.deviceList.dispose();
|
|
@@ -912,44 +718,40 @@ class Core extends events_1.default {
|
|
|
912
718
|
}
|
|
913
719
|
async init(settings, onCoreEvent, logWriterFactory) {
|
|
914
720
|
if (logWriterFactory) {
|
|
915
|
-
|
|
721
|
+
setLogWriter(logWriterFactory);
|
|
916
722
|
}
|
|
917
|
-
|
|
723
|
+
this.createLogger = settings.createLogger ?? noopCreateLogger;
|
|
724
|
+
this.coreLogger = this.createLogger('Core');
|
|
725
|
+
const throttlePromise = createDeferred();
|
|
918
726
|
throttlePromise.promise.catch(() => {});
|
|
919
727
|
const onCoreEventThrottled = message => throttlePromise.promise.then(() => onCoreEvent(message));
|
|
920
728
|
try {
|
|
921
|
-
|
|
922
|
-
|
|
729
|
+
settingsStore.set({
|
|
730
|
+
...settings,
|
|
731
|
+
enabledNetworks: undefined
|
|
732
|
+
});
|
|
733
|
+
enabledNetworksStore.set(settings.enabledNetworks ?? []);
|
|
734
|
+
await firmwareReleaseStore.init(settings.firmwareChannel, false, initializeFirmwareConfig);
|
|
735
|
+
const localFirmwares = settings.localFirmwares && parseLocalFirmwares(settings.localFirmwares);
|
|
923
736
|
if (localFirmwares) {
|
|
924
|
-
|
|
737
|
+
localFirmwareStore.set(localFirmwares);
|
|
925
738
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
manifest
|
|
930
|
-
} = DataManager_1.DataManager.getSettings();
|
|
931
|
-
const messages = DataManager_1.DataManager.getProtobufMessages();
|
|
932
|
-
(0, debug_1.enableLog)(debug);
|
|
933
|
-
this._interactionTimeout = new interactionTimeout_1.InteractionTimeout(settings.popup ? settings.interactionTimeout : 0);
|
|
934
|
-
this._deviceList = new DeviceList_1.DeviceList({
|
|
935
|
-
debug,
|
|
936
|
-
messages,
|
|
937
|
-
priority,
|
|
938
|
-
manifest
|
|
739
|
+
await loadProtobufModules();
|
|
740
|
+
this._deviceList = new DeviceList({
|
|
741
|
+
createLogger: this.createLogger
|
|
939
742
|
});
|
|
940
743
|
initDeviceList(this.getCoreContext());
|
|
941
|
-
this.on(
|
|
744
|
+
this.on(CORE_EVENT, onCoreEventThrottled);
|
|
942
745
|
} catch (error) {
|
|
943
|
-
|
|
746
|
+
this.coreLogger.error('init', error);
|
|
944
747
|
throttlePromise.reject(error);
|
|
945
748
|
throw error;
|
|
946
749
|
}
|
|
947
750
|
const {
|
|
948
751
|
transports,
|
|
949
752
|
pendingTransportEvent,
|
|
950
|
-
transportReconnect
|
|
951
|
-
|
|
952
|
-
} = DataManager_1.DataManager.getSettings();
|
|
753
|
+
transportReconnect
|
|
754
|
+
} = settingsStore.get();
|
|
953
755
|
try {
|
|
954
756
|
this.deviceList.init({
|
|
955
757
|
transports,
|
|
@@ -957,21 +759,20 @@ class Core extends events_1.default {
|
|
|
957
759
|
transportReconnect
|
|
958
760
|
});
|
|
959
761
|
} catch (error) {
|
|
960
|
-
this.sendCoreMessage(
|
|
762
|
+
this.sendCoreMessage(createTransportMessage(TRANSPORT.ERROR, {
|
|
961
763
|
error
|
|
962
764
|
}));
|
|
963
765
|
throttlePromise.reject(error);
|
|
964
766
|
throw error;
|
|
965
767
|
}
|
|
966
|
-
if (!transportReconnect
|
|
768
|
+
if (!transportReconnect) {
|
|
967
769
|
await this.deviceList.pendingConnection();
|
|
968
770
|
}
|
|
969
|
-
this.on(
|
|
970
|
-
this.off(
|
|
771
|
+
this.on(CORE_EVENT, onCoreEvent);
|
|
772
|
+
this.off(CORE_EVENT, onCoreEventThrottled);
|
|
971
773
|
setTimeout(throttlePromise.resolve, 0);
|
|
972
774
|
}
|
|
973
775
|
}
|
|
974
|
-
exports.Core = Core;
|
|
975
776
|
const resetTransports = async ({
|
|
976
777
|
deviceList,
|
|
977
778
|
sendCoreMessage
|
|
@@ -980,7 +781,7 @@ const resetTransports = async ({
|
|
|
980
781
|
transports,
|
|
981
782
|
pendingTransportEvent,
|
|
982
783
|
transportReconnect
|
|
983
|
-
} =
|
|
784
|
+
} = settingsStore.get();
|
|
984
785
|
try {
|
|
985
786
|
await deviceList.init({
|
|
986
787
|
transports,
|
|
@@ -988,7 +789,7 @@ const resetTransports = async ({
|
|
|
988
789
|
transportReconnect
|
|
989
790
|
});
|
|
990
791
|
} catch (error) {
|
|
991
|
-
sendCoreMessage(
|
|
792
|
+
sendCoreMessage(createTransportMessage(TRANSPORT.ERROR, {
|
|
992
793
|
error
|
|
993
794
|
}));
|
|
994
795
|
}
|
|
@@ -1001,6 +802,4 @@ const initCore = async (...params) => {
|
|
|
1001
802
|
const disposeCore = core => {
|
|
1002
803
|
core.dispose();
|
|
1003
804
|
};
|
|
1004
|
-
const initCoreState = () =>
|
|
1005
|
-
exports.initCoreState = initCoreState;
|
|
1006
|
-
//# sourceMappingURL=index.js.map
|
|
805
|
+
export const initCoreState = () => createLazy(initCore, disposeCore);
|