aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-06-26 14:22:34 -0300
committerSebastian <sebasjm@gmail.com>2023-06-26 14:22:34 -0300
commit87fc6ebf48afc297ed1e2a0fd503a8401c0deb08 (patch)
tree20a262aa38e0f3dbf937bf994a970ded1e0f1c8a /packages/taler-wallet-core/src/operations
parent1e173e279f32eadcd9b24f4a8564a2f894a8867a (diff)
downloadwallet-core-87fc6ebf48afc297ed1e2a0fd503a8401c0deb08.tar.xz
if checkmasterpub is specified, throw if master pub is not equal to the expected value
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r--packages/taler-wallet-core/src/operations/exchanges.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts
index 29c370e2c..56ef672dc 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -75,7 +75,13 @@ import {
GetReadWriteAccess,
} from "../util/query.js";
import { WALLET_EXCHANGE_PROTOCOL_VERSION } from "../versions.js";
-import { OperationAttemptResult, OperationAttemptResultType, runTaskWithErrorReporting, TaskIdentifiers, unwrapOperationHandlerResultOrThrow } from "./common.js";
+import {
+ OperationAttemptResult,
+ OperationAttemptResultType,
+ runTaskWithErrorReporting,
+ TaskIdentifiers,
+ unwrapOperationHandlerResultOrThrow,
+} from "./common.js";
const logger = new Logger("exchanges.ts");
@@ -544,6 +550,7 @@ export async function updateExchangeFromUrl(
ws: InternalWalletState,
baseUrl: string,
options: {
+ checkMasterPub?: string;
forceNow?: boolean;
cancellationToken?: CancellationToken;
} = {},
@@ -570,6 +577,7 @@ export async function updateExchangeFromUrlHandler(
ws: InternalWalletState,
exchangeBaseUrl: string,
options: {
+ checkMasterPub?: string;
forceNow?: boolean;
cancellationToken?: CancellationToken;
} = {},
@@ -605,6 +613,13 @@ export async function updateExchangeFromUrlHandler(
)
) {
logger.info("using existing exchange info");
+
+ if (options.checkMasterPub) {
+ if (exchangeDetails.masterPublicKey !== options.checkMasterPub) {
+ throw Error(`master public key mismatch`);
+ }
+ }
+
return {
type: OperationAttemptResultType.Finished,
result: { exchange, exchangeDetails },
@@ -621,6 +636,12 @@ export async function updateExchangeFromUrlHandler(
timeout,
);
+ if (options.checkMasterPub) {
+ if (keysInfo.masterPublicKey !== options.checkMasterPub) {
+ throw Error(`master public key mismatch`);
+ }
+ }
+
logger.info("updating exchange /wire info");
const wireInfoDownload = await downloadExchangeWireInfo(
exchangeBaseUrl,