@incodetech/core 0.0.0-dev-20260507-85da360 → 0.0.0-dev-20260507-a2cd155
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/{BaseWasmProvider-QTXpU_qs.esm.js → BaseWasmProvider-C2cw9STp.esm.js} +91 -39
- package/dist/{WasmUtilProvider-Cj17GAox.esm.js → WasmUtilProvider-B8VtGgvF.esm.js} +1 -1
- package/dist/ae-signature.d.ts +1 -1
- package/dist/authentication.esm.js +6 -6
- package/dist/{authenticationManager-BMGIFm3Y.esm.js → authenticationManager-CO8WhECt.esm.js} +2 -2
- package/dist/{authenticationStateMachine-Dd9HMJiq.esm.js → authenticationStateMachine-BNH4XOow.esm.js} +2 -2
- package/dist/consent.d.ts +47 -47
- package/dist/cpf-ocr.d.ts +23 -23
- package/dist/{deepsightLoader-C1UShQg2.esm.js → deepsightLoader-HPZa6gSA.esm.js} +2 -2
- package/dist/document-capture.d.ts +71 -71
- package/dist/document-upload.d.ts +43 -43
- package/dist/ekyb.esm.js +3 -3
- package/dist/{ekybStateMachine-CIVtmica.esm.js → ekybStateMachine-DV9EXKSx.esm.js} +1 -1
- package/dist/electronic-signature.d.ts +1 -1
- package/dist/extensibility.esm.js +11 -11
- package/dist/{faceCaptureSetup-n0z3bm3G.esm.js → faceCaptureSetup-DPJ8f1ce.esm.js} +1 -1
- package/dist/flow.d.ts +2 -2
- package/dist/flow.esm.js +2 -2
- package/dist/{flowServices-BZnDn46f.esm.js → flowServices-CeE9Xzub.esm.js} +1 -1
- package/dist/home.d.ts +10 -10
- package/dist/id-ocr.d.ts +55 -55
- package/dist/id.esm.js +5 -5
- package/dist/{idCaptureManager-Dnvp0tN7.esm.js → idCaptureManager-Kz1QDPj-.esm.js} +1 -1
- package/dist/{idCaptureStateMachine-DERHrSfV.esm.js → idCaptureStateMachine-rFrwNi8M.esm.js} +4 -4
- package/dist/identity-reuse.d.ts +40 -40
- package/dist/{index-C62kGS4J.d.ts → index-BD8upvmp.d.ts} +119 -119
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +4 -4
- package/dist/mandatory-consent.d.ts +47 -47
- package/dist/qe-signature.d.ts +1 -1
- package/dist/{recordingService-DkKKvn0o.esm.js → recordingService-Dc8qrd2u.esm.js} +2 -2
- package/dist/selfie.esm.js +6 -6
- package/dist/{selfieManager-Bh9G13aS.esm.js → selfieManager-CNus5KCH.esm.js} +2 -2
- package/dist/{selfieStateMachine-DPHgsHPA.esm.js → selfieStateMachine-DCwYz6V1.esm.js} +2 -2
- package/dist/{session-CsUswFcx.esm.js → session-DPd529SS.esm.js} +1 -1
- package/dist/session.esm.js +1 -1
- package/dist/{setup-DGSuf74f.esm.js → setup-B72ayX57.esm.js} +371 -18
- package/dist/{setup-DKabjTK6.d.ts → setup-D3rE3N3K.d.ts} +13 -1
- package/dist/wasm.d.ts +2 -2
- package/dist/wasm.esm.js +5 -5
- package/dist/workflow.d.ts +82 -82
- package/dist/workflow.esm.js +9 -9
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as warmupWasm } from "./BaseWasmProvider-
|
|
2
|
-
import { t as WasmUtilProvider } from "./WasmUtilProvider-
|
|
1
|
+
import { c as SemaphoreProvider, n as warmupWasm, o as wasmCallWrapper, s as loadWasmModule } from "./BaseWasmProvider-C2cw9STp.esm.js";
|
|
2
|
+
import { t as WasmUtilProvider } from "./WasmUtilProvider-B8VtGgvF.esm.js";
|
|
3
3
|
import { t as BrowserTimerProvider } from "./BrowserTimerProvider-BZGH3sYJ.esm.js";
|
|
4
4
|
import { a as resetApi, i as isApiConfigured, n as getApi, o as setClient, r as getToken, s as setToken, t as api } from "./api-eqRXuVG-.esm.js";
|
|
5
5
|
import { _ as resetAnalyticsBatcher, g as getAnalyticsBatcher, m as createAnalyticsBatchingService, v as setAnalyticsBatcher } from "./events-Bt1azl2B.esm.js";
|
|
6
6
|
import { t as endpoints } from "./endpoints-B3V1U9Dg.esm.js";
|
|
7
|
-
import { i as resetSessionInit, r as initializeSession } from "./session-
|
|
7
|
+
import { i as resetSessionInit, r as initializeSession } from "./session-DPd529SS.esm.js";
|
|
8
8
|
|
|
9
9
|
//#region ../infra/src/http/createApi.ts
|
|
10
10
|
var FetchHttpError = class extends Error {
|
|
@@ -20,7 +20,7 @@ var FetchHttpError = class extends Error {
|
|
|
20
20
|
this.name = "FetchHttpError";
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
const buildQueryString = (query) => {
|
|
23
|
+
const buildQueryString$1 = (query) => {
|
|
24
24
|
if (!query) return "";
|
|
25
25
|
const params = new URLSearchParams();
|
|
26
26
|
Object.entries(query).forEach(([key, value]) => {
|
|
@@ -29,12 +29,12 @@ const buildQueryString = (query) => {
|
|
|
29
29
|
const str = params.toString();
|
|
30
30
|
return str ? `?${str}` : "";
|
|
31
31
|
};
|
|
32
|
-
const buildUrl = (baseURL, url, query) => {
|
|
33
|
-
const queryString = buildQueryString(query);
|
|
32
|
+
const buildUrl$1 = (baseURL, url, query) => {
|
|
33
|
+
const queryString = buildQueryString$1(query);
|
|
34
34
|
if (url.startsWith("http://") || url.startsWith("https://")) return `${url}${queryString}`;
|
|
35
35
|
return `${baseURL.endsWith("/") ? baseURL.slice(0, -1) : baseURL}${url.startsWith("/") ? url : `/${url}`}${queryString}`;
|
|
36
36
|
};
|
|
37
|
-
const prepareBody = (body) => {
|
|
37
|
+
const prepareBody$1 = (body) => {
|
|
38
38
|
if (body === null || body === void 0) return null;
|
|
39
39
|
if (body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer) return body;
|
|
40
40
|
if (typeof body === "object") return JSON.stringify(body);
|
|
@@ -53,7 +53,7 @@ const parseResponse = async (response, parseType) => {
|
|
|
53
53
|
}
|
|
54
54
|
return await response.text();
|
|
55
55
|
};
|
|
56
|
-
const DEFAULT_TIMEOUT = 3e4;
|
|
56
|
+
const DEFAULT_TIMEOUT$1 = 3e4;
|
|
57
57
|
const requestWithXHR = (fullUrl, method, mergedHeaders, requestBody, timeout, signal, onUploadProgress) => {
|
|
58
58
|
return new Promise((resolve, reject) => {
|
|
59
59
|
const xhr = new XMLHttpRequest();
|
|
@@ -118,13 +118,13 @@ const createApi = (config) => {
|
|
|
118
118
|
const client = {
|
|
119
119
|
defaults,
|
|
120
120
|
async request(requestConfig) {
|
|
121
|
-
const { method = "GET", url, headers: headers$1 = {}, query, params, body, signal, timeout = config.timeout ?? DEFAULT_TIMEOUT, parse, onUploadProgress, keepalive } = requestConfig;
|
|
122
|
-
const fullUrl = buildUrl(defaults.baseURL, url, params ?? query);
|
|
121
|
+
const { method = "GET", url, headers: headers$1 = {}, query, params, body, signal, timeout = config.timeout ?? DEFAULT_TIMEOUT$1, parse, onUploadProgress, keepalive } = requestConfig;
|
|
122
|
+
const fullUrl = buildUrl$1(defaults.baseURL, url, params ?? query);
|
|
123
123
|
const mergedHeaders = {
|
|
124
124
|
...defaults.headers,
|
|
125
125
|
...headers$1
|
|
126
126
|
};
|
|
127
|
-
const requestBody = prepareBody(body);
|
|
127
|
+
const requestBody = prepareBody$1(body);
|
|
128
128
|
let finalHeaders = mergedHeaders;
|
|
129
129
|
if (requestBody === null && (method === "POST" || method === "PUT" || method === "PATCH")) {
|
|
130
130
|
const { "Content-Type": _, ...headersWithoutContentType } = mergedHeaders;
|
|
@@ -227,6 +227,315 @@ const createApi = (config) => {
|
|
|
227
227
|
};
|
|
228
228
|
var createApi_default = createApi;
|
|
229
229
|
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region ../infra/src/wasm/wasmWebClient.ts
|
|
232
|
+
/**
|
|
233
|
+
* JavaScript bridge for the C++ `WebClient` exposed by `webLib.wasm`.
|
|
234
|
+
*
|
|
235
|
+
* The pinned WASM bundle ships a `WebClient` class alongside the ML pipeline
|
|
236
|
+
* APIs. This module instantiates it once (sharing the singleton `wasmModule`
|
|
237
|
+
* with `mlWasmJSApi`) and exposes a small TypeScript-friendly surface that
|
|
238
|
+
* `createWasmApi` can drive.
|
|
239
|
+
*
|
|
240
|
+
* Concurrency model mirrors the legacy implementation:
|
|
241
|
+
* - 4-slot semaphore keyed by per-request `threadId` so multiple HTTP calls
|
|
242
|
+
* can run in parallel without trampling shared C++ state.
|
|
243
|
+
* - Each WASM-side request method returns `false` while in flight; we
|
|
244
|
+
* busy-poll via {@link wasmCallWrapper}.
|
|
245
|
+
* - Result extraction (`getRequestResult`) is per-thread.
|
|
246
|
+
*
|
|
247
|
+
* Encryption is wired through the `encryptionEnabled` flag but defaults to
|
|
248
|
+
* `false`. End-to-end encryption (Phase 2) will re-call `setupConnection` with
|
|
249
|
+
* a real token + `encryptionEnabled = true`; that helper is a follow-up.
|
|
250
|
+
*/
|
|
251
|
+
const HTTP_CONCURRENCY = 4;
|
|
252
|
+
var WasmWebClientError = class extends Error {
|
|
253
|
+
constructor(message, statusCode, data) {
|
|
254
|
+
super(message);
|
|
255
|
+
this.name = "WasmWebClientError";
|
|
256
|
+
this.status = statusCode;
|
|
257
|
+
this.statusCode = statusCode;
|
|
258
|
+
if (statusCode > 0 || data !== void 0) this.response = {
|
|
259
|
+
status: statusCode,
|
|
260
|
+
data
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
let webClientApi = null;
|
|
265
|
+
let initPromise = null;
|
|
266
|
+
let semaphore = new SemaphoreProvider(HTTP_CONCURRENCY);
|
|
267
|
+
const isWebClientWasm = (mod) => {
|
|
268
|
+
return typeof mod.WebClient === "function";
|
|
269
|
+
};
|
|
270
|
+
const toStringRecord = (obj) => {
|
|
271
|
+
if (!obj) return void 0;
|
|
272
|
+
const result = {};
|
|
273
|
+
for (const key of Object.keys(obj)) {
|
|
274
|
+
const value = obj[key];
|
|
275
|
+
if (value === void 0 || value === null) continue;
|
|
276
|
+
result[key] = String(value);
|
|
277
|
+
}
|
|
278
|
+
return result;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Loads the shared WASM module (if not already loaded) and instantiates the
|
|
282
|
+
* C++ `WebClient`. Idempotent — repeated calls reuse the existing instance.
|
|
283
|
+
*/
|
|
284
|
+
async function initializeWasmWebClient(wasmPath, wasmSimdPath, glueCodePath, useSimd) {
|
|
285
|
+
if (webClientApi) return;
|
|
286
|
+
if (initPromise) return initPromise;
|
|
287
|
+
initPromise = (async () => {
|
|
288
|
+
try {
|
|
289
|
+
const { wasmModule } = await loadWasmModule({
|
|
290
|
+
wasmPath,
|
|
291
|
+
wasmSimdPath,
|
|
292
|
+
glueCodePath,
|
|
293
|
+
useSimd
|
|
294
|
+
});
|
|
295
|
+
if (!isWebClientWasm(wasmModule)) throw new Error("WASM module does not expose a WebClient class. Update webLib.wasm to a build that includes WebClient.");
|
|
296
|
+
webClientApi = new wasmModule.WebClient();
|
|
297
|
+
} catch (error) {
|
|
298
|
+
initPromise = null;
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
301
|
+
})();
|
|
302
|
+
return initPromise;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Configures the C++ WebClient connection. Safe to call multiple times — each
|
|
306
|
+
* call resets the underlying session and re-applies default headers.
|
|
307
|
+
*/
|
|
308
|
+
async function setupWasmConnection(apiURL, token, useSha256, encryptionEnabled, defaultHeaders) {
|
|
309
|
+
const api$1 = ensureReady();
|
|
310
|
+
api$1.resetSessionState?.();
|
|
311
|
+
api$1.createApi(apiURL, token, useSha256, encryptionEnabled);
|
|
312
|
+
api$1.setDefaultHeaders?.(defaultHeaders);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Executes a single HTTP request through the WASM WebClient.
|
|
316
|
+
*
|
|
317
|
+
* Acquires a semaphore slot for `threadId`, registers progress callbacks, runs
|
|
318
|
+
* the request via {@link wasmCallWrapper} (busy-polls until the WASM method
|
|
319
|
+
* returns `true`), then extracts the per-thread result. Throws
|
|
320
|
+
* {@link WasmWebClientError} on non-2xx or transport errors.
|
|
321
|
+
*/
|
|
322
|
+
async function executeWasmRequest(method, url, body, headers, params, timeout, onUploadProgress) {
|
|
323
|
+
const api$1 = ensureReady();
|
|
324
|
+
const stringParams = toStringRecord(params);
|
|
325
|
+
return semaphore.withLock(async (threadId) => {
|
|
326
|
+
if (onUploadProgress && api$1.setOnUploadProgress) api$1.setOnUploadProgress((event) => {
|
|
327
|
+
try {
|
|
328
|
+
onUploadProgress(event);
|
|
329
|
+
} catch (error) {
|
|
330
|
+
console.error("WasmWebClient: error in onUploadProgress callback", error);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
try {
|
|
334
|
+
await wasmCallWrapper(semaphore, () => callWasmMethod(api$1, method, threadId, url, body, headers, stringParams, timeout), false);
|
|
335
|
+
return readResult(api$1, threadId);
|
|
336
|
+
} finally {
|
|
337
|
+
api$1.clearOnUploadProgress?.(threadId);
|
|
338
|
+
api$1.clearOnDownloadProgress?.(threadId);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
function callWasmMethod(api$1, method, threadId, url, body, headers, params, timeout) {
|
|
343
|
+
switch (method) {
|
|
344
|
+
case "GET": return api$1.get(threadId, url, params, headers, timeout);
|
|
345
|
+
case "POST": return api$1.post(threadId, url, body ?? {}, headers, params, timeout);
|
|
346
|
+
case "PUT": return api$1.put(threadId, url, body ?? {}, headers, params, timeout);
|
|
347
|
+
case "PATCH": return api$1.patch(threadId, url, body ?? {}, headers, params, timeout);
|
|
348
|
+
case "DELETE": return api$1.del(threadId, url, body ?? {}, headers, params, timeout);
|
|
349
|
+
default: throw new Error(`Unsupported WASM HTTP method: ${method}`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function readResult(api$1, threadId) {
|
|
353
|
+
const response = api$1.getRequestResult(threadId);
|
|
354
|
+
if (response.hasError) throw new WasmWebClientError(response.errorMessage || "WasmWebClient request failed", response.statusCode, response.result);
|
|
355
|
+
return {
|
|
356
|
+
data: response.result,
|
|
357
|
+
status: response.statusCode
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function ensureReady() {
|
|
361
|
+
if (!webClientApi) throw new Error("WasmWebClient not initialized. Call initializeWasmWebClient() first.");
|
|
362
|
+
return webClientApi;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region ../infra/src/http/createWasmApi.ts
|
|
367
|
+
var WasmHttpError = class extends Error {
|
|
368
|
+
constructor(status, statusText, url, method, headers, data) {
|
|
369
|
+
super(`HTTP ${status} ${statusText}`);
|
|
370
|
+
this.ok = false;
|
|
371
|
+
this.status = status;
|
|
372
|
+
this.statusText = statusText;
|
|
373
|
+
this.url = url;
|
|
374
|
+
this.method = method;
|
|
375
|
+
this.headers = headers;
|
|
376
|
+
this.data = data;
|
|
377
|
+
this.name = "WasmHttpError";
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
const DEFAULT_TIMEOUT = 3e4;
|
|
381
|
+
const HTTP_METHODS = new Set([
|
|
382
|
+
"GET",
|
|
383
|
+
"POST",
|
|
384
|
+
"PUT",
|
|
385
|
+
"PATCH",
|
|
386
|
+
"DELETE"
|
|
387
|
+
]);
|
|
388
|
+
const buildQueryString = (query) => {
|
|
389
|
+
if (!query) return "";
|
|
390
|
+
const params = new URLSearchParams();
|
|
391
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
392
|
+
if (value !== void 0 && value !== null) params.append(key, String(value));
|
|
393
|
+
});
|
|
394
|
+
const str = params.toString();
|
|
395
|
+
return str ? `?${str}` : "";
|
|
396
|
+
};
|
|
397
|
+
const buildUrl = (baseURL, url, query) => {
|
|
398
|
+
const queryString = buildQueryString(query);
|
|
399
|
+
if (url.startsWith("http://") || url.startsWith("https://")) return `${url}${queryString}`;
|
|
400
|
+
return `${baseURL.endsWith("/") ? baseURL.slice(0, -1) : baseURL}${url.startsWith("/") ? url : `/${url}`}${queryString}`;
|
|
401
|
+
};
|
|
402
|
+
const prepareBody = (body) => {
|
|
403
|
+
if (body === null || body === void 0) return void 0;
|
|
404
|
+
if (body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof Uint8Array || typeof body === "string") return body;
|
|
405
|
+
if (typeof body === "object") return body;
|
|
406
|
+
return String(body);
|
|
407
|
+
};
|
|
408
|
+
const normalizeMethod = (method) => {
|
|
409
|
+
const upper = method.toUpperCase();
|
|
410
|
+
if (!HTTP_METHODS.has(upper)) throw new Error(`Unsupported HTTP method for WASM client: ${method}`);
|
|
411
|
+
return upper;
|
|
412
|
+
};
|
|
413
|
+
const getErrorStatus = (error) => {
|
|
414
|
+
if (error instanceof WasmWebClientError) return error.statusCode;
|
|
415
|
+
if (typeof error === "object" && error !== null) {
|
|
416
|
+
const record = error;
|
|
417
|
+
if (typeof record.statusCode === "number") return record.statusCode;
|
|
418
|
+
if (typeof record.status === "number") return record.status;
|
|
419
|
+
}
|
|
420
|
+
return 0;
|
|
421
|
+
};
|
|
422
|
+
const getErrorData = (error) => {
|
|
423
|
+
if (error instanceof WasmWebClientError) return error.response?.data ?? null;
|
|
424
|
+
return null;
|
|
425
|
+
};
|
|
426
|
+
const getErrorMessage = (error) => {
|
|
427
|
+
if (error instanceof Error) return error.message;
|
|
428
|
+
return "WasmWebClient request failed";
|
|
429
|
+
};
|
|
430
|
+
const withAbortSignal = async (promise, signal, error) => {
|
|
431
|
+
if (!signal) return await promise;
|
|
432
|
+
if (signal.aborted) throw error;
|
|
433
|
+
return await new Promise((resolve, reject) => {
|
|
434
|
+
const onAbort = () => reject(error);
|
|
435
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
436
|
+
promise.then(resolve, reject).finally(() => {
|
|
437
|
+
signal.removeEventListener("abort", onAbort);
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
};
|
|
441
|
+
const createWasmApi = async (config) => {
|
|
442
|
+
const headers = {
|
|
443
|
+
"Content-Type": "application/json",
|
|
444
|
+
Accept: "application/json",
|
|
445
|
+
"api-version": "1.0",
|
|
446
|
+
...config.customHeaders ?? {}
|
|
447
|
+
};
|
|
448
|
+
await initializeWasmWebClient(config.wasm.wasmPath, config.wasm.wasmSimdPath ?? config.wasm.wasmPath, config.wasm.glueCodePath, config.wasm.useSimd ?? true);
|
|
449
|
+
await setupWasmConnection(config.apiURL, "", config.useSha256 ?? false, config.encryptionEnabled ?? false, headers);
|
|
450
|
+
const defaults = {
|
|
451
|
+
baseURL: config.apiURL,
|
|
452
|
+
headers
|
|
453
|
+
};
|
|
454
|
+
const client = {
|
|
455
|
+
defaults,
|
|
456
|
+
async request(requestConfig) {
|
|
457
|
+
const { method = "GET", url, headers: requestHeaders = {}, query, params, body, signal, timeout = config.timeout ?? DEFAULT_TIMEOUT, onUploadProgress } = requestConfig;
|
|
458
|
+
const upperMethod = normalizeMethod(method);
|
|
459
|
+
const requestParams = params ?? query;
|
|
460
|
+
const fullUrl = buildUrl(defaults.baseURL, url, requestParams);
|
|
461
|
+
const mergedHeaders = {
|
|
462
|
+
...defaults.headers,
|
|
463
|
+
...requestHeaders
|
|
464
|
+
};
|
|
465
|
+
const requestBody = prepareBody(body);
|
|
466
|
+
const wasmProgress = onUploadProgress ? (progress) => {
|
|
467
|
+
if (progress.total > 0) onUploadProgress(Math.round(progress.loaded / progress.total * 100));
|
|
468
|
+
} : void 0;
|
|
469
|
+
const abortError = new WasmHttpError(0, "Request aborted", fullUrl, upperMethod, {}, null);
|
|
470
|
+
if (signal?.aborted) throw abortError;
|
|
471
|
+
try {
|
|
472
|
+
const response = await withAbortSignal(executeWasmRequest(upperMethod, url, requestBody, mergedHeaders, requestParams, timeout, wasmProgress), signal, abortError);
|
|
473
|
+
if (response.status < 200 || response.status >= 300) throw new WasmHttpError(response.status, "", fullUrl, upperMethod, {}, response.data);
|
|
474
|
+
return {
|
|
475
|
+
ok: true,
|
|
476
|
+
status: response.status,
|
|
477
|
+
statusText: "",
|
|
478
|
+
url: fullUrl,
|
|
479
|
+
headers: {},
|
|
480
|
+
data: response.data
|
|
481
|
+
};
|
|
482
|
+
} catch (error) {
|
|
483
|
+
if (error instanceof WasmHttpError) throw error;
|
|
484
|
+
throw new WasmHttpError(getErrorStatus(error), getErrorMessage(error), fullUrl, upperMethod, {}, getErrorData(error));
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
get(url, requestConfig) {
|
|
488
|
+
return client.request({
|
|
489
|
+
...requestConfig,
|
|
490
|
+
url,
|
|
491
|
+
method: "GET"
|
|
492
|
+
});
|
|
493
|
+
},
|
|
494
|
+
post(url, body, requestConfig) {
|
|
495
|
+
return client.request({
|
|
496
|
+
...requestConfig,
|
|
497
|
+
url,
|
|
498
|
+
body,
|
|
499
|
+
method: "POST"
|
|
500
|
+
});
|
|
501
|
+
},
|
|
502
|
+
put(url, body, requestConfig) {
|
|
503
|
+
return client.request({
|
|
504
|
+
...requestConfig,
|
|
505
|
+
url,
|
|
506
|
+
body,
|
|
507
|
+
method: "PUT"
|
|
508
|
+
});
|
|
509
|
+
},
|
|
510
|
+
patch(url, body, requestConfig) {
|
|
511
|
+
return client.request({
|
|
512
|
+
...requestConfig,
|
|
513
|
+
url,
|
|
514
|
+
body,
|
|
515
|
+
method: "PATCH"
|
|
516
|
+
});
|
|
517
|
+
},
|
|
518
|
+
delete(url, requestConfig) {
|
|
519
|
+
return client.request({
|
|
520
|
+
...requestConfig,
|
|
521
|
+
url,
|
|
522
|
+
method: "DELETE"
|
|
523
|
+
});
|
|
524
|
+
},
|
|
525
|
+
head() {
|
|
526
|
+
return Promise.reject(/* @__PURE__ */ new Error("HEAD is not supported by the WASM HTTP client"));
|
|
527
|
+
},
|
|
528
|
+
options() {
|
|
529
|
+
return Promise.reject(/* @__PURE__ */ new Error("OPTIONS is not supported by the WASM HTTP client"));
|
|
530
|
+
},
|
|
531
|
+
setHeader(name, value) {
|
|
532
|
+
defaults.headers[name] = value;
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
return client;
|
|
536
|
+
};
|
|
537
|
+
var createWasmApi_default = createWasmApi;
|
|
538
|
+
|
|
230
539
|
//#endregion
|
|
231
540
|
//#region ../infra/src/wasm/wasmDefaults.ts
|
|
232
541
|
const WASM_CDN_BASE_URL = "https://cdn.incodesmile.com/ml-wasm-kit-release";
|
|
@@ -356,6 +665,7 @@ var BrowserPageLifecycleProvider = class {
|
|
|
356
665
|
//#endregion
|
|
357
666
|
//#region src/setup.ts
|
|
358
667
|
let wasmConfig;
|
|
668
|
+
let storedHttpConfig;
|
|
359
669
|
let configured = false;
|
|
360
670
|
/**
|
|
361
671
|
* Initializes the SDK with the provided configuration.
|
|
@@ -418,11 +728,26 @@ async function setup(options) {
|
|
|
418
728
|
pageLifecycle: new BrowserPageLifecycleProvider(),
|
|
419
729
|
timer: BrowserTimerProvider.getInstance()
|
|
420
730
|
}));
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
731
|
+
const effectiveWasm = options.wasm ? resolveWasmConfig(options.wasm) : void 0;
|
|
732
|
+
if (options.apiURL) {
|
|
733
|
+
const client = effectiveWasm ? await createWasmApi_default({
|
|
734
|
+
apiURL: options.apiURL,
|
|
735
|
+
customHeaders: options.customHeaders,
|
|
736
|
+
timeout: options.timeout,
|
|
737
|
+
wasm: effectiveWasm
|
|
738
|
+
}) : createApi_default({
|
|
739
|
+
apiURL: options.apiURL,
|
|
740
|
+
customHeaders: options.customHeaders,
|
|
741
|
+
timeout: options.timeout
|
|
742
|
+
});
|
|
743
|
+
storedHttpConfig = {
|
|
744
|
+
apiURL: options.apiURL,
|
|
745
|
+
customHeaders: options.customHeaders,
|
|
746
|
+
timeout: options.timeout,
|
|
747
|
+
isWasm: Boolean(effectiveWasm)
|
|
748
|
+
};
|
|
749
|
+
setClient(client);
|
|
750
|
+
}
|
|
426
751
|
if (options.token && isApiConfigured()) {
|
|
427
752
|
setToken(options.token);
|
|
428
753
|
resetSessionInit();
|
|
@@ -433,7 +758,6 @@ async function setup(options) {
|
|
|
433
758
|
});
|
|
434
759
|
}
|
|
435
760
|
configured = true;
|
|
436
|
-
const effectiveWasm = options.wasm ? resolveWasmConfig(options.wasm) : void 0;
|
|
437
761
|
if (effectiveWasm) {
|
|
438
762
|
await warmupWasm(effectiveWasm);
|
|
439
763
|
await (await WasmUtilProvider.getInstance()).initialize({
|
|
@@ -469,6 +793,34 @@ async function initializeWasmUtil(config) {
|
|
|
469
793
|
});
|
|
470
794
|
}
|
|
471
795
|
/**
|
|
796
|
+
* Replaces the active HTTP client with the WASM-backed one. Used when WASM is
|
|
797
|
+
* loaded lazily (e.g. by the flow component) — `setup()` originally wired the
|
|
798
|
+
* fetch/XHR client because no `wasm` was provided, and this swap upgrades to
|
|
799
|
+
* `createWasmApi` once the WASM module is ready.
|
|
800
|
+
*
|
|
801
|
+
* No-op when no apiURL was originally configured, or when the active client is
|
|
802
|
+
* already the WASM one.
|
|
803
|
+
*
|
|
804
|
+
* @param config - Optional WASM configuration. Defaults to the config stored via `setWasmConfig`.
|
|
805
|
+
*/
|
|
806
|
+
async function upgradeToWasmHttpClient(config) {
|
|
807
|
+
if (!storedHttpConfig) return;
|
|
808
|
+
if (storedHttpConfig.isWasm) return;
|
|
809
|
+
const wasmConfigToUse = config ?? wasmConfig;
|
|
810
|
+
if (!wasmConfigToUse) return;
|
|
811
|
+
const resolved = resolveWasmConfig(wasmConfigToUse);
|
|
812
|
+
setClient(await createWasmApi_default({
|
|
813
|
+
apiURL: storedHttpConfig.apiURL,
|
|
814
|
+
customHeaders: storedHttpConfig.customHeaders,
|
|
815
|
+
timeout: storedHttpConfig.timeout,
|
|
816
|
+
wasm: resolved
|
|
817
|
+
}));
|
|
818
|
+
storedHttpConfig = {
|
|
819
|
+
...storedHttpConfig,
|
|
820
|
+
isWasm: true
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
472
824
|
* Checks if the SDK has been configured.
|
|
473
825
|
*
|
|
474
826
|
* @returns true if setup() has been called, false otherwise
|
|
@@ -485,8 +837,9 @@ function reset() {
|
|
|
485
837
|
resetAnalyticsBatcher();
|
|
486
838
|
configured = false;
|
|
487
839
|
wasmConfig = void 0;
|
|
840
|
+
storedHttpConfig = void 0;
|
|
488
841
|
WasmUtilProvider.resetInstance();
|
|
489
842
|
}
|
|
490
843
|
|
|
491
844
|
//#endregion
|
|
492
|
-
export { setup as a,
|
|
845
|
+
export { setup as a, buildDefaultWasmConfig as c, setWasmConfig as i, resolveWasmConfig as l, isConfigured as n, upgradeToWasmHttpClient as o, reset as r, DEFAULT_WASM_VERSION as s, initializeWasmUtil as t };
|
|
@@ -113,6 +113,18 @@ declare function setWasmConfig(config: WasmConfig): void;
|
|
|
113
113
|
* @throws Error if no config is provided and none is stored
|
|
114
114
|
*/
|
|
115
115
|
declare function initializeWasmUtil(config?: WasmConfig): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Replaces the active HTTP client with the WASM-backed one. Used when WASM is
|
|
118
|
+
* loaded lazily (e.g. by the flow component) — `setup()` originally wired the
|
|
119
|
+
* fetch/XHR client because no `wasm` was provided, and this swap upgrades to
|
|
120
|
+
* `createWasmApi` once the WASM module is ready.
|
|
121
|
+
*
|
|
122
|
+
* No-op when no apiURL was originally configured, or when the active client is
|
|
123
|
+
* already the WASM one.
|
|
124
|
+
*
|
|
125
|
+
* @param config - Optional WASM configuration. Defaults to the config stored via `setWasmConfig`.
|
|
126
|
+
*/
|
|
127
|
+
declare function upgradeToWasmHttpClient(config?: WasmConfig): Promise<void>;
|
|
116
128
|
/**
|
|
117
129
|
* Checks if the SDK has been configured.
|
|
118
130
|
*
|
|
@@ -124,4 +136,4 @@ declare function isConfigured(): boolean;
|
|
|
124
136
|
*/
|
|
125
137
|
declare function reset(): void;
|
|
126
138
|
//#endregion
|
|
127
|
-
export { reset as a, isConfigured as i, WasmConfig as n, setWasmConfig as o, initializeWasmUtil as r, setup as s, SetupOptions as t };
|
|
139
|
+
export { reset as a, upgradeToWasmHttpClient as c, isConfigured as i, WasmConfig as n, setWasmConfig as o, initializeWasmUtil as r, setup as s, SetupOptions as t };
|
package/dist/wasm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as WasmPipeline, r as warmupWasm, t as WarmupConfig } from "./warmup-DHGg8wQZ.js";
|
|
2
|
-
import { n as WasmConfig, o as setWasmConfig, r as initializeWasmUtil } from "./setup-
|
|
2
|
+
import { c as upgradeToWasmHttpClient, n as WasmConfig, o as setWasmConfig, r as initializeWasmUtil } from "./setup-D3rE3N3K.js";
|
|
3
3
|
|
|
4
4
|
//#region ../infra/src/wasm/wasmDefaults.d.ts
|
|
5
5
|
/** The WASM version bundled and tested with this SDK release. */
|
|
@@ -12,4 +12,4 @@ declare function buildDefaultWasmConfig(): WarmupConfig;
|
|
|
12
12
|
*/
|
|
13
13
|
declare function resolveWasmConfig(overrides?: Partial<WarmupConfig>): WarmupConfig;
|
|
14
14
|
//#endregion
|
|
15
|
-
export { DEFAULT_WASM_VERSION, type WasmConfig, type WasmPipeline, buildDefaultWasmConfig, initializeWasmUtil, resolveWasmConfig, setWasmConfig, warmupWasm };
|
|
15
|
+
export { DEFAULT_WASM_VERSION, type WasmConfig, type WasmPipeline, buildDefaultWasmConfig, initializeWasmUtil, resolveWasmConfig, setWasmConfig, upgradeToWasmHttpClient, warmupWasm };
|
package/dist/wasm.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { n as warmupWasm } from "./BaseWasmProvider-
|
|
3
|
-
import "./WasmUtilProvider-
|
|
1
|
+
import { c as buildDefaultWasmConfig, i as setWasmConfig, l as resolveWasmConfig, o as upgradeToWasmHttpClient, s as DEFAULT_WASM_VERSION, t as initializeWasmUtil } from "./setup-B72ayX57.esm.js";
|
|
2
|
+
import { n as warmupWasm } from "./BaseWasmProvider-C2cw9STp.esm.js";
|
|
3
|
+
import "./WasmUtilProvider-B8VtGgvF.esm.js";
|
|
4
4
|
import "./BrowserTimerProvider-BZGH3sYJ.esm.js";
|
|
5
5
|
import "./api-eqRXuVG-.esm.js";
|
|
6
6
|
import "./events-Bt1azl2B.esm.js";
|
|
7
7
|
import "./endpoints-B3V1U9Dg.esm.js";
|
|
8
|
-
import "./session-
|
|
8
|
+
import "./session-DPd529SS.esm.js";
|
|
9
9
|
import "./IpifyProvider-ByL6JYxg.esm.js";
|
|
10
10
|
import "./browserSimulation-CAH-V_iE.esm.js";
|
|
11
11
|
|
|
12
|
-
export { DEFAULT_WASM_VERSION, buildDefaultWasmConfig, initializeWasmUtil, resolveWasmConfig, setWasmConfig, warmupWasm };
|
|
12
|
+
export { DEFAULT_WASM_VERSION, buildDefaultWasmConfig, initializeWasmUtil, resolveWasmConfig, setWasmConfig, upgradeToWasmHttpClient, warmupWasm };
|