aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-08-20 12:20:20 -0300
committerSebastian <sebasjm@gmail.com>2024-08-21 10:25:25 -0300
commitc63b6481d62278488dac3870c88917f39c4d2b13 (patch)
tree39175e80370ba5e57c6e7909b63f9299e4999b5c /packages/taler-util
parent7dc29f9bc4cb3a8a1943ede93e5b0834f67d9788 (diff)
add support for FormData
Diffstat (limited to 'packages/taler-util')
-rw-r--r--packages/taler-util/src/http-client/exchange.ts8
-rw-r--r--packages/taler-util/src/http-common.ts2
-rw-r--r--packages/taler-util/src/types-taler-exchange.ts2
3 files changed, 8 insertions, 4 deletions
diff --git a/packages/taler-util/src/http-client/exchange.ts b/packages/taler-util/src/http-client/exchange.ts
index 790c890f8..9b7635cb4 100644
--- a/packages/taler-util/src/http-client/exchange.ts
+++ b/packages/taler-util/src/http-client/exchange.ts
@@ -51,6 +51,7 @@ import {
codecForExchangeConfig,
codecForExchangeKeys,
codecForKycProcessClientInformation,
+ codecForKycProcessStartInformation,
codecForLegitimizationNeededResponse
} from "../types-taler-exchange.js";
import { CacheEvictor, addMerchantPaginationParams, nullEvictor } from "./utils.js";
@@ -319,17 +320,18 @@ export class TalerExchangeHttpClient {
* https://docs.taler.net/core/api-exchange.html#post--kyc-start-$ID
*
*/
- async startKycProcess(requirement: KycRequirementInformationId) {
+ async startKycProcess(requirement: KycRequirementInformationId, body: object = {}) {
const url = new URL(`kyc-start/${requirement}`, this.baseUrl);
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
+ body
});
switch (resp.status) {
- case HttpStatusCode.NoContent:
- return opEmptySuccess(resp);
+ case HttpStatusCode.Ok:
+ return opSuccessFromHttp(resp, codecForKycProcessStartInformation());
case HttpStatusCode.NotFound:
return opKnownHttpFailure(resp.status, resp);
case HttpStatusCode.Conflict:
diff --git a/packages/taler-util/src/http-common.ts b/packages/taler-util/src/http-common.ts
index 6f537dda2..7e7173ac5 100644
--- a/packages/taler-util/src/http-common.ts
+++ b/packages/taler-util/src/http-common.ts
@@ -502,6 +502,8 @@ export function encodeBody(body: unknown): ArrayBuffer {
return body.buffer;
} else if (body instanceof ArrayBuffer) {
return body;
+ } else if (typeof body === "object" && body.constructor.name === "FormData") {
+ return body as ArrayBuffer;
} else if (typeof body === "object") {
return textEncoder.encode(JSON.stringify(body)).buffer;
}
diff --git a/packages/taler-util/src/types-taler-exchange.ts b/packages/taler-util/src/types-taler-exchange.ts
index dcd62bec2..0cd722239 100644
--- a/packages/taler-util/src/types-taler-exchange.ts
+++ b/packages/taler-util/src/types-taler-exchange.ts
@@ -2483,7 +2483,7 @@ export const codecForKycProcessClientInformation =
)
.build("TalerExchangeApi.KycProcessClientInformation");
-interface KycProcessStartInformation {
+export interface KycProcessStartInformation {
// URL to open.
redirect_url: string;
}