aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-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
-rw-r--r--packages/web-util/src/utils/http-impl.sw.ts9
4 files changed, 17 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;
}
diff --git a/packages/web-util/src/utils/http-impl.sw.ts b/packages/web-util/src/utils/http-impl.sw.ts
index 7b168b739..21e328363 100644
--- a/packages/web-util/src/utils/http-impl.sw.ts
+++ b/packages/web-util/src/utils/http-impl.sw.ts
@@ -99,6 +99,15 @@ export class BrowserFetchHttpLib implements HttpRequestLibrary {
});
}
+ /**
+ * default header assume everything is json
+ * in case of formData the content-type will be
+ * auto generated
+ */
+ if (myBody instanceof FormData) {
+ delete requestHeadersMap["Content-Type"]
+ }
+
const controller = new AbortController();
let timeoutId: ReturnType<typeof setTimeout> | undefined;
if (requestTimeout.d_ms !== "forever") {