From cc38998803141c42511e878441a5a8b15a387436 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 5 Apr 2024 17:53:39 -0300 Subject: fix #8276 --- packages/taler-util/src/http-client/bank-revenue.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'packages/taler-util') diff --git a/packages/taler-util/src/http-client/bank-revenue.ts b/packages/taler-util/src/http-client/bank-revenue.ts index b195e8c8f..34afe7d86 100644 --- a/packages/taler-util/src/http-client/bank-revenue.ts +++ b/packages/taler-util/src/http-client/bank-revenue.ts @@ -44,6 +44,10 @@ export type TalerBankRevenueErrorsByMethod< prop extends keyof TalerRevenueHttpClient, > = FailCasesByMethod; +type UsernameAndPassword = { + username: string; + password: string; +}; /** * The API is used by the merchant (or other parties) to query * for incoming transactions to their account. @@ -69,33 +73,34 @@ export class TalerRevenueHttpClient { * https://docs.taler.net/core/api-bank-revenue.html#get--config * */ - async getConfig() { + async getConfig(auth?: UsernameAndPassword) { const url = new URL(`config`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "GET", + headers: { + Authorization: auth + ? makeBasicAuthHeader(auth.username, auth.password) + : undefined, + }, }); switch (resp.status) { case HttpStatusCode.Ok: return opSuccessFromHttp(resp, codecForRevenueConfig()); + case HttpStatusCode.Unauthorized: + return opKnownHttpFailure(resp.status, resp); case HttpStatusCode.NotFound: return opKnownHttpFailure(resp.status, resp); default: return opUnknownFailure(resp, await readTalerErrorResponse(resp)); } } - /** * https://docs.taler.net/core/api-bank-revenue.html#get--history * * @returns */ async getHistory( - auth: - | { - username: string; - password: string; - } - | undefined, + auth?: UsernameAndPassword, params?: PaginationParams & LongPollParams, ) { const url = new URL(`history`, this.baseUrl); -- cgit v1.2.3