commit df1fdbc5ecc4d18a9b5a28b066b1ac7098953a39 parent 6bd8d385dcadd5df0a85e7a93a66ac764e959592 Author: Antoine A <> Date: Wed, 8 Apr 2026 21:23:42 +0200 common: add token auth suport for wire gateway API Diffstat:
34 files changed, 147 insertions(+), 110 deletions(-)
diff --git a/packages/taler-harness/src/env1.ts b/packages/taler-harness/src/env1.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2021 Taler Systems S.A. + (C) 2021, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -51,6 +51,7 @@ export async function runEnv1(t: GlobalTestState): Promise<void> { exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: "exchange", password: "password", }, diff --git a/packages/taler-harness/src/harness/environments.ts b/packages/taler-harness/src/harness/environments.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -587,6 +587,7 @@ export async function createSimpleTestkudosEnvironmentV3( const exchangeBankAccount: HarnessExchangeBankAccount = { wireGatewayApiBaseUrl, wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, @@ -1367,6 +1368,7 @@ export async function createKycTestkudosEnvironmentFull( await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, @@ -1473,6 +1475,7 @@ export async function createKycTestkudosEnvironmentFull( const exchangeBankAccount: HarnessExchangeBankAccount = { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, @@ -1573,6 +1576,7 @@ export async function createKycTestkudosEnvironment( await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, @@ -1619,6 +1623,7 @@ export async function createKycTestkudosEnvironment( const exchangeBankAccount: HarnessExchangeBankAccount = { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020-2025 Taler Systems S.A. + (C) 2020-2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -28,6 +28,8 @@ import { AccessToken, AmountJson, Amounts, + BasicAuth, + BasicOrTokenAuth, ConfigSources, Configuration, CoreApiResponse, @@ -50,7 +52,6 @@ import { TalerMerchantInstanceHttpClient, TalerMerchantManagementHttpClient, TalerProtocolDuration, - TalerWireGatewayAuth, TalerWireGatewayHttpClient, Transaction, TransactionIdStr, @@ -676,11 +677,12 @@ class BankServiceBase { protected globalTestState: GlobalTestState, protected bankConfig: BankConfig, protected configFile: string, - ) {} + ) { } - getAdminAuth(): { username: string; password: string } { + getAdminAuth(): BasicAuth { // Bank admin PW is brutally hard-coded in tests right now. return { + type: "basic", username: "admin", password: "admin-password", }; @@ -696,7 +698,7 @@ export type HarnessAccountRestriction = export interface HarnessExchangeBankAccount { accountPaytoUri: PaytoString; wireGatewayApiBaseUrl: string; - wireGatewayAuth: TalerWireGatewayAuth; + wireGatewayAuth: BasicAuth; conversionUrl?: string; /** * If set, the harness will not automatically configure the wire fee for this account. @@ -710,8 +712,7 @@ export interface HarnessExchangeBankAccount { */ export class FakebankService extends BankServiceBase - implements BankServiceHandle -{ + implements BankServiceHandle { proc: ProcessWrapper | undefined; http = createPlatformHttpLib({ enableThrottling: false }); @@ -817,6 +818,7 @@ export class FakebankService }); return { wireGatewayAuth: { + type: "basic", username: accountName, password, }, @@ -910,7 +912,7 @@ export class LibeufinNexusService { private gc: GlobalTestState, private bc: NexusConfig, private configFile: string, - ) {} + ) { } async dbinit(): Promise<void> { await sh( @@ -931,8 +933,7 @@ export const harnessBankAdminCreds: Credentials = { */ export class LibeufinBankService extends BankServiceBase - implements BankServiceHandle -{ + implements BankServiceHandle { proc: ProcessWrapper | undefined; http = createPlatformHttpLib({ enableThrottling: false }); @@ -1155,7 +1156,7 @@ export interface BankServiceHandle { start(): Promise<void>; pingUntilAvailable(): Promise<void>; stop(): Promise<void>; - getAdminAuth(): { username: string; password: string }; + getAdminAuth(): BasicOrTokenAuth; getAdminTok(): Promise<AccessToken>; @@ -1536,7 +1537,7 @@ export class ExchangeService implements ExchangeServiceInterface { private exchangeConfig: ExchangeConfig, private configFilename: string, private keyPair: EddsaKeyPair, - ) {} + ) { } get name() { return this.exchangeConfig.name; @@ -2017,7 +2018,7 @@ export class BrowserService { constructor( private globalState: GlobalTestState, private type: "firefox" | "chrome", - ) {} + ) { } async stop(): Promise<void> { const driver = this.driver; @@ -2056,8 +2057,8 @@ export class BrowserService { `web-browser`, process.env.BROWSER_PATH ? { - PATH: process.env.BROWSER_PATH, - } + PATH: process.env.BROWSER_PATH, + } : undefined, ); break; @@ -2075,8 +2076,8 @@ export class BrowserService { `web-browser`, process.env.BROWSER_PATH ? { - PATH: process.env.BROWSER_PATH, - } + PATH: process.env.BROWSER_PATH, + } : undefined, ); break; @@ -2117,7 +2118,7 @@ export class MerchantService implements MerchantServiceInterface { private globalState: GlobalTestState, private merchantConfig: MerchantConfig, private configFilename: string, - ) {} + ) { } private currentTimetravelOffsetMs: number | undefined; @@ -2764,7 +2765,7 @@ export class WalletClient { return client.call(operation, payload); } - constructor(private args: WalletClientArgs) {} + constructor(private args: WalletClientArgs) { } async connect(): Promise<void> { const waiter = this.waiter; @@ -2846,11 +2847,9 @@ export class WalletCli { ? `--crypto-worker=${cliOpts.cryptoWorkerType}` : ""; const logName = `wallet-${self.name}`; - const command = `taler-wallet-cli ${ - self.timetravelArg ?? "" - } ${cryptoWorkerArg} --no-throttle -LTRACE --skip-defaults --wallet-db '${ - self.dbfile - }' api '${op}' ${shellWrap(JSON.stringify(payload))}`; + const command = `taler-wallet-cli ${self.timetravelArg ?? "" + } ${cryptoWorkerArg} --no-throttle -LTRACE --skip-defaults --wallet-db '${self.dbfile + }' api '${op}' ${shellWrap(JSON.stringify(payload))}`; const resp = await sh(self.globalTestState, logName, command); logger.trace(`command: ${j2s(command)}`); logger.info("--- wallet core response ---"); @@ -2971,7 +2970,7 @@ export async function doMerchantKycAuth( t: GlobalTestState, req: { exchangeBankAccount: HarnessExchangeBankAccount; - bankAdminAuth: { username: string; password: string }; + bankAdminAuth: BasicOrTokenAuth; merchant: MerchantServiceInterface; merchantAdminAccessToken: AccessToken; bankClient: TalerCorebankApiClient; diff --git a/packages/taler-harness/src/harness/tops.ts b/packages/taler-harness/src/harness/tops.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2025 Taler Systems S.A. + (C) 2025, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -621,6 +621,7 @@ export async function createTopsEnvironment( await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, @@ -732,6 +733,7 @@ export async function createTopsEnvironment( const exchangeBankAccount: HarnessExchangeBankAccount = { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, diff --git a/packages/taler-harness/src/integrationtests/test-bank-api.ts b/packages/taler-harness/src/integrationtests/test-bank-api.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020-2025 Taler Systems S.A. + (C) 2020-2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,6 +18,7 @@ * Imports. */ import { + BasicAuth, CreditDebitIndicator, TalerCorebankApiClient, TalerWireGatewayHttpClient, @@ -67,7 +68,8 @@ export async function runBankApiTest(t: GlobalTestState) { let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw-password"; let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); - let wireGatewayAuth = { + let wireGatewayAuth: BasicAuth = { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }; diff --git a/packages/taler-harness/src/integrationtests/test-currency-scope-separation.ts b/packages/taler-harness/src/integrationtests/test-currency-scope-separation.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -83,6 +83,7 @@ export async function runCurrencyScopeSeparationTest(t: GlobalTestState) { bank.corebankApiBaseUrl, ).href, wireGatewayAuth: { + type: "basic", username: "myexchange", password: "password", }, @@ -95,6 +96,7 @@ export async function runCurrencyScopeSeparationTest(t: GlobalTestState) { bank.corebankApiBaseUrl, ).href, wireGatewayAuth: { + type: "basic", username: "myexchange2", password: "password", }, diff --git a/packages/taler-harness/src/integrationtests/test-currency-scope.ts b/packages/taler-harness/src/integrationtests/test-currency-scope.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -81,6 +81,7 @@ export async function runCurrencyScopeTest(t: GlobalTestState) { bank.corebankApiBaseUrl, ).href, wireGatewayAuth: { + type: "basic", username: "myexchange", password: "password", }, @@ -93,6 +94,7 @@ export async function runCurrencyScopeTest(t: GlobalTestState) { bank.corebankApiBaseUrl, ).href, wireGatewayAuth: { + type: "basic", username: "myexchange2", password: "password", }, diff --git a/packages/taler-harness/src/integrationtests/test-deposit-fault.ts b/packages/taler-harness/src/integrationtests/test-deposit-fault.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -75,6 +75,7 @@ export async function runDepositFaultTest(t: GlobalTestState) { await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, @@ -159,7 +160,7 @@ export async function runDepositFaultTest(t: GlobalTestState) { caughtDeposit.resolve(JSON.parse(td.decode(ctx.requestBody))); } }, - async modifyResponse(ctx: FaultInjectionResponseContext) {}, + async modifyResponse(ctx: FaultInjectionResponseContext) { }, }); const depositResp = await walletClient.call( diff --git a/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts b/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020-2025 Taler Systems S.A. + (C) 2020-2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -77,6 +77,7 @@ export async function runExchangeManagementFaultTest( await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, diff --git a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -131,6 +131,7 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) { await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, @@ -182,7 +183,7 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) { id: "minst1", name: "minst1", paytoUris: [getTestHarnessPaytoForLabel("minst1")], - }, {adminAccessToken}); + }, { adminAccessToken }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-fee-regression.ts b/packages/taler-harness/src/integrationtests/test-fee-regression.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -75,6 +75,7 @@ export async function createMyTestkudosEnvironment( const exchangeBankAccount: HarnessExchangeBankAccount = { wireGatewayAuth: { + type: "basic", password: exchangeBankPassword, username: exchangeBankUsername, }, diff --git a/packages/taler-harness/src/integrationtests/test-libeufin-bank.ts b/packages/taler-harness/src/integrationtests/test-libeufin-bank.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -83,6 +83,7 @@ export async function runLibeufinBankTest(t: GlobalTestState) { exchange.addBankAccount("1", { wireGatewayApiBaseUrl, wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPw, }, @@ -115,7 +116,7 @@ export async function runLibeufinBankTest(t: GlobalTestState) { id: "minst1", name: "minst1", paytoUris: [getTestHarnessPaytoForLabel("minst1")], - }, {adminAccessToken}); + }, { adminAccessToken }); const { walletClient } = await createWalletDaemonWithClient(t, { name: "wallet", @@ -176,6 +177,7 @@ export async function runLibeufinBankTest(t: GlobalTestState) { await wireGatewayApiAdminClient.addIncoming({ auth: { + type: "basic", username: adminUser, password: adminPassword, }, diff --git a/packages/taler-harness/src/integrationtests/test-libeufin-conversion.ts b/packages/taler-harness/src/integrationtests/test-libeufin-conversion.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -89,6 +89,7 @@ export async function runLibeufinConversionTest(t: GlobalTestState) { exchange.addBankAccount("1", { wireGatewayApiBaseUrl, wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPw, }, @@ -99,6 +100,7 @@ export async function runLibeufinConversionTest(t: GlobalTestState) { exchange.addBankAccount("conv", { wireGatewayApiBaseUrl, wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPw, }, diff --git a/packages/taler-harness/src/integrationtests/test-merchant-acctsel.ts b/packages/taler-harness/src/integrationtests/test-merchant-acctsel.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2021 Taler Systems S.A. + (C) 2021, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -62,6 +62,7 @@ export async function runMerchantAcctselTest(t: GlobalTestState) { accountPaytoUri: paytoXtb, wireGatewayApiBaseUrl: "http://localhost:8082/", wireGatewayAuth: { + type: "basic", password: "test", username: "test", }, @@ -78,6 +79,7 @@ export async function runMerchantAcctselTest(t: GlobalTestState) { accountPaytoUri: paytoIban, wireGatewayApiBaseUrl: "http://localhost:8082/", wireGatewayAuth: { + type: "basic", password: "test", username: "test", }, diff --git a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -94,6 +94,7 @@ export async function createConfusedMerchantTestkudosEnvironment( await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, @@ -146,7 +147,7 @@ export async function createConfusedMerchantTestkudosEnvironment( id: "minst1", name: "minst1", paytoUris: [getTestHarnessPaytoForLabel("minst1")], - }, {adminAccessToken}); + }, { adminAccessToken }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-multiexchange.ts b/packages/taler-harness/src/integrationtests/test-multiexchange.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -83,6 +83,7 @@ export async function runMultiExchangeTest(t: GlobalTestState) { bank.corebankApiBaseUrl, ).href, wireGatewayAuth: { + type: "basic", username: "myexchange", password: "password", }, @@ -91,6 +92,7 @@ export async function runMultiExchangeTest(t: GlobalTestState) { let exchangeTwoBankAccount: HarnessExchangeBankAccount = { wireGatewayAuth: { + type: "basic", username: "myexchange2", password: "password", }, @@ -171,7 +173,7 @@ export async function runMultiExchangeTest(t: GlobalTestState) { defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), - }, {adminAccessToken}); + }, { adminAccessToken }); const { walletClient, walletService } = await createWalletDaemonWithClient( t, diff --git a/packages/taler-harness/src/integrationtests/test-payment-fault.ts b/packages/taler-harness/src/integrationtests/test-payment-fault.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -77,6 +77,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) { await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, diff --git a/packages/taler-harness/src/integrationtests/test-payment-multiple.ts b/packages/taler-harness/src/integrationtests/test-payment-multiple.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -69,6 +69,7 @@ async function setupTest(t: GlobalTestState): Promise<{ await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, @@ -124,14 +125,14 @@ async function setupTest(t: GlobalTestState): Promise<{ id: "minst1", name: "minst1", paytoUris: [getTestHarnessPaytoForLabel("minst1")], - }, {adminAccessToken}); + }, { adminAccessToken }); console.log("setup done!"); return { merchant, bankClient, - merchantAdminAccessToken:adminAccessToken, + merchantAdminAccessToken: adminAccessToken, exchange, }; } diff --git a/packages/taler-harness/src/integrationtests/test-revocation.ts b/packages/taler-harness/src/integrationtests/test-revocation.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -98,6 +98,7 @@ async function createTestEnvironment( const exchangeBankAccount: HarnessExchangeBankAccount = { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, diff --git a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -77,6 +77,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, diff --git a/packages/taler-harness/src/integrationtests/test-wallet-balance.ts b/packages/taler-harness/src/integrationtests/test-wallet-balance.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -20,6 +20,7 @@ import { AccessToken, Amounts, + BasicAuth, Duration, j2s, PreparePayResultType, @@ -27,7 +28,6 @@ import { TalerCorebankApiClient, TalerMerchantApi, TalerMerchantInstanceHttpClient, - TalerWireGatewayAuth, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { defaultCoinConfig } from "../harness/denomStructures.js"; @@ -100,7 +100,8 @@ async function createMyEnvironment( `accounts/${exchangeBankUsername}/taler-wire-gateway/`, bank.corebankApiBaseUrl, ).href; - const wireGatewayAuth: TalerWireGatewayAuth = { + const wireGatewayAuth: BasicAuth = { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }; diff --git a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,12 +18,12 @@ * Imports. */ import { + BasicAuth, ExchangeEntryStatus, NotificationType, TalerCorebankApiClient, TalerError, TalerErrorCode, - TalerWireGatewayAuth, WalletNotification, j2s, } from "@gnu-taler/taler-util"; @@ -66,7 +66,8 @@ export async function runWalletDd48Test(t: GlobalTestState) { let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw-password"; let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); - const wireGatewayAuth: TalerWireGatewayAuth = { + const wireGatewayAuth: BasicAuth = { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }; @@ -187,7 +188,7 @@ export async function runWalletDd48Test(t: GlobalTestState) { x.type === NotificationType.ExchangeStateTransition && x.oldExchangeState == null && x.newExchangeState?.exchangeEntryStatus === - ExchangeEntryStatus.Ephemeral, + ExchangeEntryStatus.Ephemeral, ), ); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-exchange-features.ts b/packages/taler-harness/src/integrationtests/test-wallet-exchange-features.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022-2023 Taler Systems S.A. + (C) 2022-2023, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -69,6 +69,7 @@ export async function runWalletExchangeFeaturesTest(t: GlobalTestState) { const exchangeBankAccount: HarnessExchangeBankAccount = { wireGatewayApiBaseUrl, wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, diff --git a/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts b/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -19,10 +19,10 @@ */ import { AmountString, + BasicAuth, ExchangeUpdateStatus, NotificationType, TalerCorebankApiClient, - TalerWireGatewayAuth, j2s, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; @@ -85,7 +85,8 @@ export async function runWalletExchangeUpdateTest( }, }); - const wireGatewayAuth: TalerWireGatewayAuth = { + const wireGatewayAuth: BasicAuth = { + type: "basic", username: "myexchange", password: "password", }; diff --git a/packages/taler-harness/src/integrationtests/test-wallet-insufficient-balance.ts b/packages/taler-harness/src/integrationtests/test-wallet-insufficient-balance.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020-2025 Taler Systems S.A. + (C) 2020-2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -19,6 +19,7 @@ */ import { AmountString, + BasicAuth, j2s, Logger, PaymentInsufficientBalanceDetails, @@ -26,7 +27,6 @@ import { succeedOrThrow, TalerErrorCode, TalerMerchantInstanceHttpClient, - TalerWireGatewayAuth, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; @@ -81,7 +81,8 @@ export async function runWalletInsufficientBalanceTest(t: GlobalTestState) { bank.corebankApiBaseUrl, ).href; - const wireGatewayAuth: TalerWireGatewayAuth = { + const wireGatewayAuth: BasicAuth = { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }; diff --git a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,10 +18,10 @@ * Imports. */ import { + BasicAuth, Duration, NotificationType, TalerCorebankApiClient, - TalerWireGatewayAuth, TransactionMajorState, TransactionMinorState, } from "@gnu-taler/taler-util"; @@ -66,7 +66,8 @@ export async function runWalletNotificationsTest(t: GlobalTestState) { let exchangeBankPassword = "mypw-password"; let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); - const wireGatewayAuth: TalerWireGatewayAuth = { + const wireGatewayAuth: BasicAuth = { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }; diff --git a/packages/taler-harness/src/integrationtests/test-wallet-observability.ts b/packages/taler-harness/src/integrationtests/test-wallet-observability.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,9 +18,9 @@ * Imports. */ import { + BasicAuth, NotificationType, TalerCorebankApiClient, - TalerWireGatewayAuth, WalletNotification, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; @@ -60,7 +60,8 @@ export async function runWalletObservabilityTest(t: GlobalTestState) { let exchangeBankPassword = "mypw-password"; let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); - const wireGatewayAuth: TalerWireGatewayAuth = { + const wireGatewayAuth: BasicAuth = { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }; diff --git a/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts b/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,13 +18,13 @@ * Imports. */ import { + BasicAuth, Duration, PreparePayResultType, succeedOrThrow, TalerCorebankApiClient, TalerMerchantApi, TalerMerchantInstanceHttpClient, - TalerWireGatewayAuth, TransactionMajorState, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; @@ -76,7 +76,8 @@ export async function runWalletWirefeesTest(t: GlobalTestState) { let exchangeBankUsername = "exchange"; let exchangeBankPassword = "mypw-password"; let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername); - const wireGatewayAuth: TalerWireGatewayAuth = { + const wireGatewayAuth: BasicAuth = { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }; diff --git a/packages/taler-harness/src/integrationtests/test-wire-metadata.ts b/packages/taler-harness/src/integrationtests/test-wire-metadata.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2021 Taler Systems S.A. + (C) 2021, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -83,6 +83,7 @@ export async function runWireMetadataTest(t: GlobalTestState) { const exchangeBankAccount: HarnessExchangeBankAccount = { wireGatewayApiBaseUrl, wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -162,6 +162,7 @@ export async function runWithdrawalConversionTest(t: GlobalTestState) { bank.corebankApiBaseUrl, ).href, wireGatewayAuth: { + type: "basic", username: "myexchange", password: "password", }, @@ -217,7 +218,7 @@ export async function runWithdrawalConversionTest(t: GlobalTestState) { defaultWireTransferDelay: Duration.toTalerProtocolDuration( Duration.fromSpec({ minutes: 1 }), ), - }, {adminAccessToken}); + }, { adminAccessToken }); const { walletClient } = await createWalletDaemonWithClient(t, { name: "wallet", diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-fakebank.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-fakebank.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -53,6 +53,7 @@ export async function runWithdrawalFakebankTest(t: GlobalTestState) { exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: "exchange", password: "password", }, diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -94,6 +94,7 @@ export async function runWithdrawalFeesTest(t: GlobalTestState) { await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: exchangeBankUsername, password: exchangeBankPassword, }, diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2020, 2026 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -66,6 +66,7 @@ export async function runWithdrawalHugeTest(t: GlobalTestState) { await exchange.addBankAccount("1", { wireGatewayAuth: { + type: "basic", username: "exchange", password: "password", }, diff --git a/packages/taler-util/src/http-client/bank-wire.ts b/packages/taler-util/src/http-client/bank-wire.ts @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { HttpRequestLibrary, makeBasicAuthHeader, readTalerErrorResponse } from "../http-common.js"; +import { HttpRequestLibrary, readTalerErrorResponse } from "../http-common.js"; import { HttpStatusCode } from "../http-status-codes.js"; import { createPlatformHttpLib } from "../http.js"; import { @@ -32,7 +32,12 @@ import { codecForOutgoingHistory, codecForTransferResponse, } from "../types-taler-wire-gateway.js"; -import { addLongPollingParam, addPaginationParams } from "./utils.js"; +import { + addLongPollingParam, + addPaginationParams, + BasicOrTokenAuth, + createAuthorizationHeader, +} from "./utils.js"; import { LongPollParams, PaginationParams } from "../types-taler-common.js"; import * as TalerWireGatewayApi from "../types-taler-wire-gateway.js"; @@ -49,11 +54,6 @@ export type TalerWireGatewayResultByMethod<prop extends keyof TalerWireGatewayHt export type TalerWireGatewayErrorsByMethod<prop extends keyof TalerWireGatewayHttpClient> = FailCasesByMethod<TalerWireGatewayHttpClient, prop>; -export interface TalerWireGatewayAuth { - username: string; - password: string; -} - /** * The API is used by the exchange to trigger transactions and query * incoming transactions, as well as by the auditor to query incoming @@ -109,13 +109,13 @@ export class TalerWireGatewayHttpClient { */ async makeWireTransfer(req: { body: TalerWireGatewayApi.TransferRequest; - auth: { username: string; password: string }; + auth?: BasicOrTokenAuth; }) { const url = new URL(`transfer`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "POST", headers: { - Authorization: makeBasicAuthHeader(req.auth.username, req.auth.password), + Authorization: createAuthorizationHeader(req.auth), }, body: req.body, }); @@ -150,7 +150,7 @@ export class TalerWireGatewayHttpClient { params?: { status?: TalerWireGatewayApi.WireTransferStatus; } & PaginationParams; - auth: TalerWireGatewayAuth; + auth?: BasicOrTokenAuth; }) { const url = new URL(`transfers`, this.baseUrl); if (req.params) { @@ -162,7 +162,7 @@ export class TalerWireGatewayHttpClient { const resp = await this.httpLib.fetch(url.href, { method: "GET", headers: { - Authorization: makeBasicAuthHeader(req.auth.username, req.auth.password), + Authorization: createAuthorizationHeader(req.auth), }, }); switch (resp.status) { @@ -186,12 +186,12 @@ export class TalerWireGatewayHttpClient { * https://docs.taler.net/core/api-bank-wire.html#get--transfers-$ROW_ID * */ - async getTransferStatus(req: { auth: TalerWireGatewayAuth; rowId?: number }) { + async getTransferStatus(req: { rowId?: number; auth?: BasicOrTokenAuth }) { const url = new URL(`transfers/${req.rowId}`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "GET", headers: { - Authorization: makeBasicAuthHeader(req.auth.username, req.auth.password), + Authorization: createAuthorizationHeader(req.auth), }, }); switch (resp.status) { @@ -212,7 +212,7 @@ export class TalerWireGatewayHttpClient { */ async getHistoryIncoming(req: { params?: PaginationParams & LongPollParams; - auth: TalerWireGatewayAuth; + auth?: BasicOrTokenAuth; }) { const url = new URL(`history/incoming`, this.baseUrl); addPaginationParams(url, req.params); @@ -220,7 +220,7 @@ export class TalerWireGatewayHttpClient { const resp = await this.httpLib.fetch(url.href, { method: "GET", headers: { - Authorization: makeBasicAuthHeader(req.auth.username, req.auth.password), + Authorization: createAuthorizationHeader(req.auth), }, }); switch (resp.status) { @@ -245,8 +245,8 @@ export class TalerWireGatewayHttpClient { * */ async getHistoryOutgoing(req: { - auth: TalerWireGatewayAuth; params?: PaginationParams & LongPollParams; + auth?: BasicOrTokenAuth; }) { const url = new URL(`history/outgoing`, this.baseUrl); addPaginationParams(url, req.params); @@ -254,7 +254,7 @@ export class TalerWireGatewayHttpClient { const resp = await this.httpLib.fetch(url.href, { method: "GET", headers: { - Authorization: makeBasicAuthHeader(req.auth.username, req.auth.password), + Authorization: createAuthorizationHeader(req.auth), }, }); switch (resp.status) { @@ -280,13 +280,13 @@ export class TalerWireGatewayHttpClient { */ async addIncoming(req: { body: TalerWireGatewayApi.AddIncomingRequest; - auth: { username: string; password: string }; + auth?: BasicOrTokenAuth; }) { const url = new URL(`admin/add-incoming`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "POST", headers: { - Authorization: makeBasicAuthHeader(req.auth.username, req.auth.password), + Authorization: createAuthorizationHeader(req.auth), }, body: req.body, }); @@ -316,15 +316,12 @@ export class TalerWireGatewayHttpClient { * https://docs.taler.net/core/api-bank-wire.html#post--admin-add-kycauth * */ - async addKycAuth(req: { - body: TalerWireGatewayApi.AddKycauthRequest; - auth: { username: string; password: string }; - }) { + async addKycAuth(req: { body: TalerWireGatewayApi.AddKycauthRequest; auth?: BasicOrTokenAuth }) { const url = new URL(`admin/add-kycauth`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "POST", headers: { - Authorization: makeBasicAuthHeader(req.auth.username, req.auth.password), + Authorization: createAuthorizationHeader(req.auth), }, body: req.body, }); @@ -341,15 +338,12 @@ export class TalerWireGatewayHttpClient { } /** https://docs.taler.net/core/api-bank-wire.html#post--admin-add-mapped */ - async addMapped(req: { - body: TalerWireGatewayApi.AddMappedRequest; - auth: { username: string; password: string }; - }) { + async addMapped(req: { body: TalerWireGatewayApi.AddMappedRequest; auth?: BasicOrTokenAuth }) { const url = new URL(`admin/add-mapped`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "POST", headers: { - Authorization: makeBasicAuthHeader(req.auth.username, req.auth.password), + Authorization: createAuthorizationHeader(req.auth), }, body: req.body, });