aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/http-client/authentication.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src/http-client/authentication.ts')
-rw-r--r--packages/taler-util/src/http-client/authentication.ts33
1 files changed, 32 insertions, 1 deletions
diff --git a/packages/taler-util/src/http-client/authentication.ts b/packages/taler-util/src/http-client/authentication.ts
index fa48f3da6..7e3297ff0 100644
--- a/packages/taler-util/src/http-client/authentication.ts
+++ b/packages/taler-util/src/http-client/authentication.ts
@@ -88,9 +88,37 @@ export class TalerAuthenticationHttpClient {
}
/**
- *
+ * FIXME: merge this with createAccessTokenBearer the protocol of both
+ * services need to reply the same
+ *
* @returns
*/
+ async createAccessTokenBearer_BANK(token: AccessToken, body: TokenRequest) {
+ const url = new URL(`token`, this.baseUrl);
+ const resp = await this.httpLib.fetch(url.href, {
+ method: "POST",
+ headers: {
+ Authorization: makeBearerTokenAuthHeader(token),
+ },
+ body,
+ });
+ switch (resp.status) {
+ case HttpStatusCode.Ok:
+ return opSuccessFromHttp(resp, codecForTokenSuccessResponse());
+ //FIXME: missing in docs
+ case HttpStatusCode.Unauthorized:
+ return opKnownHttpFailure(resp.status, resp);
+ case HttpStatusCode.NotFound:
+ return opKnownHttpFailure(resp.status, resp);
+ default:
+ return opUnknownFailure(resp, await readTalerErrorResponse(resp));
+ }
+ }
+
+ /**
+ *
+ * @returns
+ */
async createAccessTokenBearer(token: AccessToken, body: TokenRequest) {
const url = new URL(`token`, this.baseUrl);
const resp = await this.httpLib.fetch(url.href, {
@@ -125,6 +153,9 @@ export class TalerAuthenticationHttpClient {
case HttpStatusCode.Ok:
return opEmptySuccess(resp);
//FIXME: missing in docs
+ case HttpStatusCode.NoContent:
+ return opEmptySuccess(resp);
+ //FIXME: missing in docs
case HttpStatusCode.NotFound:
return opKnownHttpFailure(resp.status, resp);
default: