diff options
author | Sebastian <sebasjm@gmail.com> | 2024-04-05 17:53:39 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-04-05 17:53:39 -0300 |
commit | cc38998803141c42511e878441a5a8b15a387436 (patch) | |
tree | 8a9279ccd6349aac98e649ca0b7394c0630a805d /packages/taler-util/src | |
parent | f5747b394d14f65d9bee342eb30edf47a36d9751 (diff) |
fix #8276
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r-- | packages/taler-util/src/http-client/bank-revenue.ts | 21 |
1 files changed, 13 insertions, 8 deletions
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<TalerRevenueHttpClient, prop>; +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); |