[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 02/02: complain about merchant base URL mismatch, f
From: |
gnunet |
Subject: |
[taler-wallet-core] 02/02: complain about merchant base URL mismatch, fixing #6616 |
Date: |
Tue, 03 Nov 2020 16:46:52 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
commit 0d37ec5e91f6704261070e01bb77d7c46f85b7a2
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Nov 3 16:46:43 2020 +0100
complain about merchant base URL mismatch, fixing #6616
---
packages/taler-wallet-core/src/operations/errors.ts | 8 ++++++++
packages/taler-wallet-core/src/operations/pay.ts | 20 +++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/packages/taler-wallet-core/src/operations/errors.ts
b/packages/taler-wallet-core/src/operations/errors.ts
index de78203e..4eeda898 100644
--- a/packages/taler-wallet-core/src/operations/errors.ts
+++ b/packages/taler-wallet-core/src/operations/errors.ts
@@ -31,6 +31,14 @@ import { TalerErrorCode } from "../TalerErrorCode";
* but the error has already been reported by writing it to the database.
*/
export class OperationFailedAndReportedError extends Error {
+ static fromCode(
+ ec: TalerErrorCode,
+ message: string,
+ details: Record<string, unknown>,
+ ): OperationFailedAndReportedError {
+ return new OperationFailedAndReportedError(makeErrorDetails(ec, message,
details));
+ }
+
constructor(public operationError: TalerErrorDetails) {
super(operationError.message);
diff --git a/packages/taler-wallet-core/src/operations/pay.ts
b/packages/taler-wallet-core/src/operations/pay.ts
index 8dbc2af4..0c45290f 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -56,7 +56,11 @@ import * as Amounts from "../util/amounts";
import { AmountJson } from "../util/amounts";
import { Logger } from "../util/logging";
import { parsePayUri } from "../util/taleruri";
-import { guardOperationException, OperationFailedError } from "./errors";
+import {
+ guardOperationException,
+ OperationFailedAndReportedError,
+ OperationFailedError,
+} from "./errors";
import { createRefreshGroup, getTotalRefreshCost } from "./refresh";
import { InternalWalletState, EXCHANGE_COINS_LOCK } from "./state";
import {
@@ -661,6 +665,20 @@ async function processDownloadProposalImpl(
);
const fulfillmentUrl = parsedContractTerms.fulfillment_url;
+ const baseUrlForDownload = proposal.merchantBaseUrl;
+ const baseUrlFromContractTerms = parsedContractTerms.merchant_base_url;
+
+ if (baseUrlForDownload !== baseUrlFromContractTerms) {
+ throw OperationFailedAndReportedError.fromCode(
+ TalerErrorCode.WALLET_CONTRACT_TERMS_BASE_URL_MISMATCH,
+ "merchant base URL mismatch",
+ {
+ baseUrlForDownload,
+ baseUrlFromContractTerms,
+ },
+ );
+ }
+
await ws.db.runWithWriteTransaction(
[Stores.proposals, Stores.purchases],
async (tx) => {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.