@flonkid/kyc 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +55 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +55 -30
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var react = require('react');
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
|
|
6
6
|
// src/shared/constants.ts
|
|
7
|
-
var SDK_VERSION = "1.8.
|
|
7
|
+
var SDK_VERSION = "1.8.1";
|
|
8
8
|
var DEFAULT_WIDGET_URL = "https://widget.flonk.id";
|
|
9
9
|
var DEFAULT_API_BASE = "https://api.flonk.id/v1";
|
|
10
10
|
var WIDGET_EVENTS = {
|
|
@@ -90,21 +90,31 @@ async function fetchWithTimeout(url, init = {}, timeoutMs = DEFAULT_FETCH_TIMEOU
|
|
|
90
90
|
clearTimeout(timer);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
var widgetTokenInflight = /* @__PURE__ */ new Map();
|
|
93
94
|
async function fetchWidgetToken(pk, apiBase) {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
const key = `${apiBase}|${pk}`;
|
|
96
|
+
const existing = widgetTokenInflight.get(key);
|
|
97
|
+
if (existing) return existing;
|
|
98
|
+
const promise = (async () => {
|
|
99
|
+
const res = await fetchWithTimeout(`${apiBase}/public/widget-token`, {
|
|
100
|
+
headers: { "x-kyc-pk": pk },
|
|
101
|
+
credentials: "include"
|
|
102
|
+
});
|
|
103
|
+
if (!res.ok) {
|
|
104
|
+
let message = `Widget token request failed (${res.status})`;
|
|
105
|
+
try {
|
|
106
|
+
const b = await res.json();
|
|
107
|
+
message = b.error || b.message || message;
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
throw new Error(message);
|
|
104
111
|
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
112
|
+
return res.json();
|
|
113
|
+
})().finally(() => {
|
|
114
|
+
widgetTokenInflight.delete(key);
|
|
115
|
+
});
|
|
116
|
+
widgetTokenInflight.set(key, promise);
|
|
117
|
+
return promise;
|
|
108
118
|
}
|
|
109
119
|
var BRANDING_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
110
120
|
var brandingCache = /* @__PURE__ */ new Map();
|
|
@@ -159,25 +169,35 @@ function validateServerUrl(url) {
|
|
|
159
169
|
throw new Error(`Invalid serverUrl: ${url}`);
|
|
160
170
|
}
|
|
161
171
|
}
|
|
172
|
+
var sessionCreateInflight = /* @__PURE__ */ new Map();
|
|
162
173
|
async function fetchSessionFromServer(serverUrl, clientMetadata, requestHeaders) {
|
|
163
174
|
validateServerUrl(serverUrl);
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
const key = `${serverUrl}|${JSON.stringify(clientMetadata ?? null)}`;
|
|
176
|
+
const existing = sessionCreateInflight.get(key);
|
|
177
|
+
if (existing) return existing;
|
|
178
|
+
const promise = (async () => {
|
|
179
|
+
const res = await fetchWithTimeout(serverUrl, {
|
|
180
|
+
method: "POST",
|
|
181
|
+
headers: { "Content-Type": "application/json", ...requestHeaders },
|
|
182
|
+
credentials: "include",
|
|
183
|
+
body: JSON.stringify({ clientMetadata })
|
|
184
|
+
});
|
|
185
|
+
if (!res.ok) {
|
|
186
|
+
let message = `Session request failed (${res.status})`;
|
|
187
|
+
try {
|
|
188
|
+
const body = await res.json();
|
|
189
|
+
if (body.error) message = body.error;
|
|
190
|
+
else if (body.message) message = body.message;
|
|
191
|
+
} catch {
|
|
192
|
+
}
|
|
193
|
+
throw new Error(message);
|
|
177
194
|
}
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
195
|
+
return res.json();
|
|
196
|
+
})().finally(() => {
|
|
197
|
+
sessionCreateInflight.delete(key);
|
|
198
|
+
});
|
|
199
|
+
sessionCreateInflight.set(key, promise);
|
|
200
|
+
return promise;
|
|
181
201
|
}
|
|
182
202
|
async function fetchPublicSession(apiBase, sessionId, embedToken) {
|
|
183
203
|
const res = await fetchWithTimeout(`${apiBase}/public/session/${sessionId}`, {
|
|
@@ -1014,6 +1034,11 @@ var FlonkKYC = class {
|
|
|
1014
1034
|
if (session.mlAutoCaptureEnabled) params.mlAutoCaptureEnabled = "true";
|
|
1015
1035
|
if (session.mlCropEnabled !== false) params.mlCropEnabled = "true";
|
|
1016
1036
|
if (session.mlVerifyEnabled) params.mlVerifyEnabled = "true";
|
|
1037
|
+
if (session.vaultReuseEnabled) params.vaultReuseEnabled = "true";
|
|
1038
|
+
if (session.vaultReuseChallenge) params.vaultReuseChallenge = session.vaultReuseChallenge;
|
|
1039
|
+
if (session.faceAutoCapture) params.faceAutoCapture = JSON.stringify(session.faceAutoCapture);
|
|
1040
|
+
if (session.project) params.project = JSON.stringify(session.project);
|
|
1041
|
+
params.policyReady = "1";
|
|
1017
1042
|
if (designTokens?.colors) {
|
|
1018
1043
|
params.designTokens = JSON.stringify(designTokens);
|
|
1019
1044
|
}
|