diff options
Diffstat (limited to 'packages/taler-util/src/http-client/bank-core.ts')
-rw-r--r-- | packages/taler-util/src/http-client/bank-core.ts | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/packages/taler-util/src/http-client/bank-core.ts b/packages/taler-util/src/http-client/bank-core.ts index 50cedefa9..dbb6c7112 100644 --- a/packages/taler-util/src/http-client/bank-core.ts +++ b/packages/taler-util/src/http-client/bank-core.ts @@ -122,12 +122,13 @@ export class TalerCoreBankHttpClient { * https://docs.taler.net/core/api-corebank.html#delete--accounts-$USERNAME * */ - async deleteAccount(auth: UserAndToken) { + async deleteAccount(auth: UserAndToken, cid?: string) { const url = new URL(`accounts/${auth.username}`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "DELETE", headers: { - Authorization: makeBearerTokenAuthHeader(auth.token) + Authorization: makeBearerTokenAuthHeader(auth.token), + "X-Challenge-Id": cid, }, }); switch (resp.status) { @@ -152,13 +153,14 @@ export class TalerCoreBankHttpClient { * https://docs.taler.net/core/api-corebank.html#patch--accounts-$USERNAME * */ - async updateAccount(auth: UserAndToken, body: TalerCorebankApi.AccountReconfiguration) { + async updateAccount(auth: UserAndToken, body: TalerCorebankApi.AccountReconfiguration, cid?: string) { const url = new URL(`accounts/${auth.username}`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "PATCH", body, headers: { - Authorization: makeBearerTokenAuthHeader(auth.token) + Authorization: makeBearerTokenAuthHeader(auth.token), + "X-Challenge-Id": cid, }, }); switch (resp.status) { @@ -186,13 +188,14 @@ export class TalerCoreBankHttpClient { * https://docs.taler.net/core/api-corebank.html#patch--accounts-$USERNAME-auth * */ - async updatePassword(auth: UserAndToken, body: TalerCorebankApi.AccountPasswordChange) { + async updatePassword(auth: UserAndToken, body: TalerCorebankApi.AccountPasswordChange, cid?: string) { const url = new URL(`accounts/${auth.username}/auth`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "PATCH", body, headers: { - Authorization: makeBearerTokenAuthHeader(auth.token) + Authorization: makeBearerTokenAuthHeader(auth.token), + "X-Challenge-Id": cid, }, }); switch (resp.status) { @@ -328,12 +331,13 @@ export class TalerCoreBankHttpClient { * https://docs.taler.net/core/api-corebank.html#post--accounts-$USERNAME-transactions * */ - async createTransaction(auth: UserAndToken, body: TalerCorebankApi.CreateTransactionRequest) { + async createTransaction(auth: UserAndToken, body: TalerCorebankApi.CreateTransactionRequest, cid?: string) { const url = new URL(`accounts/${auth.username}/transactions`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "POST", headers: { - Authorization: makeBearerTokenAuthHeader(auth.token) + Authorization: makeBearerTokenAuthHeader(auth.token), + "X-Challenge-Id": cid, }, body, }); @@ -409,12 +413,13 @@ export class TalerCoreBankHttpClient { * https://docs.taler.net/core/api-corebank.html#post--accounts-$USERNAME-withdrawals-$WITHDRAWAL_ID-confirm * */ - async confirmWithdrawalById(auth: UserAndToken, wid: string) { + async confirmWithdrawalById(auth: UserAndToken, wid: string, cid?: string) { const url = new URL(`accounts/${auth.username}/withdrawals/${wid}/confirm`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "POST", headers: { - Authorization: makeBearerTokenAuthHeader(auth.token) + Authorization: makeBearerTokenAuthHeader(auth.token), + "X-Challenge-Id": cid, }, }); switch (resp.status) { @@ -470,12 +475,13 @@ export class TalerCoreBankHttpClient { * https://docs.taler.net/core/api-corebank.html#post--accounts-$USERNAME-cashouts * */ - async createCashout(auth: UserAndToken, body: TalerCorebankApi.CashoutRequest) { + async createCashout(auth: UserAndToken, body: TalerCorebankApi.CashoutRequest, cid?: string) { const url = new URL(`accounts/${auth.username}/cashouts`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "POST", headers: { - Authorization: makeBearerTokenAuthHeader(auth.token) + Authorization: makeBearerTokenAuthHeader(auth.token), + "X-Challenge-Id": cid, }, body, }); @@ -685,13 +691,14 @@ export class TalerCoreBankHttpClient { } } - async confirmChallenge(auth: UserAndToken, cid: string) { + async confirmChallenge(auth: UserAndToken, cid: string, body: TalerCorebankApi.ChallengeSolve) { const url = new URL(`accounts/${auth.username}/challenge/${cid}/confirm`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "POST", headers: { Authorization: makeBearerTokenAuthHeader(auth.token) }, + body, }); switch (resp.status) { case HttpStatusCode.NoContent: return opEmptySuccess() |