diff options
author | Florian Dold <florian@dold.me> | 2023-06-06 17:18:53 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-06-06 17:18:53 +0200 |
commit | 698f356659b1c2b029eaaa22c74f3474ff2f99c1 (patch) | |
tree | 1f551f06c06d2db0c408e2fb80a2f2be71811cc3 /packages/taler-wallet-core/src/operations/exchanges.ts | |
parent | 002ab0dab7b83c5999b0f82c430e716c718251e6 (diff) | |
download | wallet-core-698f356659b1c2b029eaaa22c74f3474ff2f99c1.tar.xz |
wallet-core: check base URL reported by exchange
Diffstat (limited to 'packages/taler-wallet-core/src/operations/exchanges.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/exchanges.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index 29d2451e6..40ef22c6d 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -38,11 +38,13 @@ import { j2s, LibtoolVersion, Logger, + makeErrorDetail, NotificationType, parsePaytoUri, Recoup, TalerError, TalerErrorCode, + TalerErrorDetail, TalerPreciseTimestamp, TalerProtocolDuration, TalerProtocolTimestamp, @@ -421,6 +423,7 @@ export async function provideExchangeRecordInTx( } interface ExchangeKeysDownloadResult { + baseUrl: string; masterPublicKey: string; currency: string; auditors: ExchangeAuditor[]; @@ -486,6 +489,7 @@ async function downloadExchangeKeysInfo( return { masterPublicKey: exchangeKeysJsonUnchecked.master_public_key, currency, + baseUrl: exchangeKeysJsonUnchecked.base_url, auditors: exchangeKeysJsonUnchecked.auditors, currentDenominations: exchangeKeysJsonUnchecked.denoms.map((d) => denominationRecordFromKeys( @@ -650,6 +654,20 @@ export async function updateExchangeFromUrlHandler( keysInfo.globalFees, keysInfo.masterPublicKey, ); + if (keysInfo.baseUrl != exchangeBaseUrl) { + logger.warn("exchange base URL mismatch"); + const errorDetail: TalerErrorDetail = makeErrorDetail( + TalerErrorCode.WALLET_EXCHANGE_BASE_URL_MISMATCH, + { + urlWallet: exchangeBaseUrl, + urlExchange: keysInfo.baseUrl, + }, + ); + return { + type: OperationAttemptResultType.Error, + errorDetail, + }; + } logger.info("finished validating exchange /wire info"); |