@incodetech/core 0.0.0-dev-20260403-eccc51c → 0.0.0-dev-20260407-4677d7f
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--AzPfwOm.esm.js → BaseWasmProvider-CQgeReKV.esm.js} +1 -785
- package/dist/MotionSensorProvider-BTDLt08l.esm.js +254 -0
- package/dist/StateMachine-8d441d6x.d.ts +2 -0
- package/dist/{WasmUtilProvider-BonqBWdj.esm.js → WasmUtilProvider-C45HStLj.esm.js} +1 -1
- package/dist/{addressSearch-DC5By0cC.esm.js → addressSearch-C5qzDvkN.esm.js} +15 -8
- package/dist/antifraud.d.ts +1 -1
- package/dist/antifraud.esm.js +3 -3
- package/dist/authentication.d.ts +11 -9
- package/dist/authentication.esm.js +18 -13
- package/dist/{authenticationManager-B4gSCgrO.esm.js → authenticationManager-CW4qxgcq.esm.js} +7 -6
- package/dist/{authenticationManager-Bd10YGSO.d.ts → authenticationManager-CiXsOTdM.d.ts} +2 -2
- package/dist/{backCameraStream-DF_d7hTz.esm.js → backCameraStream-CUo1USCT.esm.js} +2 -2
- package/dist/camera.d.ts +16 -0
- package/dist/camera.esm.js +5 -0
- package/dist/consent.d.ts +52 -52
- package/dist/consent.esm.js +3 -3
- package/dist/curp-validation.d.ts +5 -5
- package/dist/curp-validation.esm.js +3 -3
- package/dist/{deepsightLoader-DKgEdLIS.esm.js → deepsightLoader-Bs5jHgca.esm.js} +10 -7
- package/dist/deepsightService-C3gQ_9Ml.esm.js +493 -0
- package/dist/{deepsightService-Ciu0atv5.d.ts → deepsightService-CMAtxAC9.d.ts} +193 -197
- package/dist/device.d.ts +46 -0
- package/dist/device.esm.js +106 -0
- package/dist/document-capture.d.ts +78 -78
- package/dist/document-capture.esm.js +6 -6
- package/dist/document-upload.d.ts +53 -53
- package/dist/document-upload.esm.js +6 -6
- package/dist/ekyb.d.ts +3 -3
- package/dist/ekyb.esm.js +11 -10
- package/dist/ekyc.d.ts +3 -3
- package/dist/ekyc.esm.js +104 -22
- package/dist/email.d.ts +3 -3
- package/dist/email.esm.js +5 -5
- package/dist/{emailManager-CpAwvP3v.esm.js → emailManager-CZ2IGW0g.esm.js} +4 -4
- package/dist/{emailManager-BQPIJR_O.d.ts → emailManager-DEIxY7l6.d.ts} +2 -2
- package/dist/events-BlVGS-8F.esm.js +472 -0
- package/dist/events.d.ts +232 -0
- package/dist/events.esm.js +4 -0
- package/dist/extensibility.d.ts +15 -13
- package/dist/extensibility.esm.js +25 -20
- package/dist/face-match.d.ts +1 -1
- package/dist/face-match.esm.js +3 -3
- package/dist/{faceCaptureManagerFactory-CdwpYykv.d.ts → faceCaptureManagerFactory-CWj-nXdx.d.ts} +8 -6
- package/dist/{faceCaptureSetup-DbXgtcp7.esm.js → faceCaptureSetup-DIE5cftl.esm.js} +13 -10
- package/dist/flow.d.ts +7 -6
- package/dist/flow.esm.js +8 -8
- package/dist/{flowCompletionService-TnWijsSw.esm.js → flowCompletionService-N6-xypy-.esm.js} +2 -2
- package/dist/{flowServices-CO2sIR3D.esm.js → flowServices-xgqnJ64L.esm.js} +3 -3
- package/dist/geolocation.d.ts +2 -2
- package/dist/geolocation.esm.js +4 -4
- package/dist/getBrowser-B800KRAi.esm.js +41 -0
- package/dist/getDeviceClass-BKd2FOAf.esm.js +14 -0
- package/dist/government-validation.d.ts +2 -2
- package/dist/government-validation.esm.js +4 -4
- package/dist/http.d.ts +57 -0
- package/dist/http.esm.js +3 -0
- package/dist/id.d.ts +11 -10
- package/dist/id.esm.js +19 -15
- package/dist/{idCaptureManager-IdqsAASp.d.ts → idCaptureManager-H-rkXnbK.d.ts} +7 -6
- package/dist/{idCaptureManager-DaLU1ug7.esm.js → idCaptureManager-SHBRQ-X_.esm.js} +15 -11
- package/dist/index.d.ts +3 -611
- package/dist/index.esm.js +10 -562
- package/dist/{lib-i-4qLKdG.esm.js → lib-Cq5Wc-Hd.esm.js} +1 -1
- package/dist/mandatory-consent.d.ts +58 -58
- package/dist/mandatory-consent.esm.js +3 -3
- package/dist/permissionServices-CDqkkway.esm.js +50 -0
- package/dist/phone.d.ts +3 -3
- package/dist/phone.esm.js +5 -5
- package/dist/{phoneManager-DA8WUJtl.d.ts → phoneManager-Clfbrs6b.d.ts} +2 -2
- package/dist/{phoneManager-BAPHSXx8.esm.js → phoneManager-CscgaER2.esm.js} +4 -4
- package/dist/{StreamCanvasCapture-DkpkIgyL.esm.js → recordingsRepository-blYn-iKZ.esm.js} +157 -215
- package/dist/redirect-to-mobile.d.ts +2 -2
- package/dist/redirect-to-mobile.esm.js +4 -4
- package/dist/selfie.d.ts +11 -9
- package/dist/selfie.esm.js +18 -13
- package/dist/{selfieManager-BSkzncsa.esm.js → selfieManager-DeGqD5aN.esm.js} +5 -4
- package/dist/{selfieManager-Dft5wZQ_.d.ts → selfieManager-h_hhEefT.d.ts} +2 -2
- package/dist/{session-OglUYC9l.esm.js → session-PLjFj_T3.esm.js} +5 -19
- package/dist/session.d.ts +46 -2
- package/dist/session.esm.js +7 -4
- package/dist/setup-DJ3dFl5k.d.ts +120 -0
- package/dist/setup-fvDWE7f8.esm.js +450 -0
- package/dist/signature.d.ts +2 -2
- package/dist/signature.esm.js +3 -3
- package/dist/{stats-BVigf5Rn.esm.js → stats-BZ1kFW4p.esm.js} +1 -1
- package/dist/stats.esm.js +2 -2
- package/dist/{types-CiLyvJGb.d.ts → types-T0VjZW3T.d.ts} +1 -1
- package/dist/types-qhLxpptI.d.ts +5 -0
- package/dist/{types-D8Y1faI5.d.ts → types-zH5PDmSe.d.ts} +1 -1
- package/dist/{StateMachine-CM_aOfNL.d.ts → warmup-CEOVQKby.d.ts} +1 -4
- package/dist/wasm.d.ts +15 -0
- package/dist/wasm.esm.js +10 -0
- package/dist/{Manager-C6AGXEq_.esm.js → xstate.esm-BXrcOcSC.esm.js} +103 -507
- package/package.json +18 -2
- package/dist/endpoints-CI5-28jT.esm.js +0 -69
- package/dist/id-CzDAG_kM.esm.js +0 -0
- package/dist/index-BuVKc9bv.d.ts +0 -1
- /package/dist/{Actor-By8WNHi-.d.ts → Actor-C-jivmFF.d.ts} +0 -0
- /package/dist/{BrowserEnvironmentProvider-BECjyw3_.esm.js → BrowserEnvironmentProvider--xQUs3sg.esm.js} +0 -0
- /package/dist/{BrowserTimerProvider-CIqH6hJp.esm.js → BrowserTimerProvider-CkHEwJFa.esm.js} +0 -0
- /package/dist/{Manager-CCT_-HuZ.d.ts → Manager-BqFybBV-.d.ts} +0 -0
- /package/dist/{api-C2uzxrpN.esm.js → api-CyI8qTie.esm.js} +0 -0
- /package/dist/{browserSimulation-DYAk0Ipe.esm.js → browserSimulation-yzDdWSBf.esm.js} +0 -0
- /package/dist/{camera-6XJdOeBF.d.ts → camera-CKsQVNlH.d.ts} +0 -0
- /package/dist/{camera-DAuRUvnp.esm.js → camera-CsT06Zqy.esm.js} +0 -0
- /package/dist/{chunk-D6hkk-hd.esm.js → chunk-BcQWkoAq.esm.js} +0 -0
- /package/dist/{displayErrors-CGJwvrTl.d.ts → displayErrors-CjMXlBnu.d.ts} +0 -0
- /package/dist/{flowCompletionService-BOd4Rk8n.d.ts → flowCompletionService-BV6ThEJ1.d.ts} +0 -0
- /package/dist/{platform-DdhkonXk.esm.js → platform-Dcuv6w60.esm.js} +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { n as WasmPipeline } from "./warmup-CEOVQKby.js";
|
|
2
|
+
|
|
3
|
+
//#region src/setup.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WASM warmup configuration. Path fields are optional; omitted values resolve to the Incode CDN defaults.
|
|
7
|
+
*/
|
|
8
|
+
type WasmConfig = {
|
|
9
|
+
/** Path to the WASM binary */
|
|
10
|
+
wasmPath?: string;
|
|
11
|
+
/** Path to the SIMD-optimized WASM binary (optional) */
|
|
12
|
+
wasmSimdPath?: string;
|
|
13
|
+
/** Path to the WASM glue code */
|
|
14
|
+
glueCodePath?: string;
|
|
15
|
+
/** Whether to use SIMD optimizations (default: true) */
|
|
16
|
+
useSimd?: boolean;
|
|
17
|
+
/** Which pipelines to preload models for */
|
|
18
|
+
pipelines?: WasmPipeline[];
|
|
19
|
+
/**
|
|
20
|
+
* Base path for ML model files. Models will be loaded from `${modelsBasePath}/${modelFileName}`.
|
|
21
|
+
* If not provided, models are expected in a 'models' subdirectory relative to the WASM binary.
|
|
22
|
+
*/
|
|
23
|
+
modelsBasePath?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Configuration options for the SDK setup.
|
|
27
|
+
*/
|
|
28
|
+
type SetupOptions = {
|
|
29
|
+
/** The base URL for the API. When omitted, no HTTP client is created — useful when all API actors are overridden via .provide(). */
|
|
30
|
+
apiURL?: string;
|
|
31
|
+
/** The session token for API requests (optional - can be set later or omitted for createSession calls) */
|
|
32
|
+
token?: string;
|
|
33
|
+
/** Custom headers to include in all requests */
|
|
34
|
+
customHeaders?: Record<string, string>;
|
|
35
|
+
/** Request timeout in milliseconds */
|
|
36
|
+
timeout?: number;
|
|
37
|
+
/**
|
|
38
|
+
* WASM warmup config.
|
|
39
|
+
* - Omit (default): loads automatically from the Incode CDN using the SDK's built-in version.
|
|
40
|
+
* - `false`: opt out of WASM entirely.
|
|
41
|
+
* - Object: override paths for self-hosting or a specific version.
|
|
42
|
+
*/
|
|
43
|
+
wasm?: WasmConfig | false;
|
|
44
|
+
/** Optional hosting app identifier for fingerprint tracking */
|
|
45
|
+
hostingApp?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Initializes the SDK with the provided configuration.
|
|
49
|
+
* Must be called before using any SDK functionality.
|
|
50
|
+
*
|
|
51
|
+
* WASM loads automatically from the Incode CDN unless explicitly disabled or overridden.
|
|
52
|
+
*
|
|
53
|
+
* @param options - Configuration options for the SDK
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { setup } from '@incodetech/core';
|
|
58
|
+
*
|
|
59
|
+
* // Zero-config: WASM loads automatically from CDN
|
|
60
|
+
* await setup({ apiURL: 'https://api.incode.com', token: 'session-token' });
|
|
61
|
+
*
|
|
62
|
+
* // Opt out of WASM
|
|
63
|
+
* await setup({ apiURL: 'https://api.incode.com', token: 'session-token', wasm: false });
|
|
64
|
+
*
|
|
65
|
+
* // Self-hosted / custom version (full or partial path overrides)
|
|
66
|
+
* await setup({
|
|
67
|
+
* apiURL: 'https://api.incode.com',
|
|
68
|
+
* token: 'session-token',
|
|
69
|
+
* wasm: {
|
|
70
|
+
* wasmPath: '/my-cdn/webLib.wasm',
|
|
71
|
+
* glueCodePath: '/my-cdn/webLib.js',
|
|
72
|
+
* },
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* // Partial override: only models path, rest from CDN
|
|
76
|
+
* await setup({
|
|
77
|
+
* apiURL: 'https://api.incode.com',
|
|
78
|
+
* token: 'session-token',
|
|
79
|
+
* wasm: { modelsBasePath: 'https://my-cdn/models' },
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* // Sessionless setup (all API actors overridden via .provide())
|
|
83
|
+
* await setup({
|
|
84
|
+
* wasm: {
|
|
85
|
+
* wasmPath: '/wasm/ml-wasm.wasm',
|
|
86
|
+
* glueCodePath: '/wasm/ml-wasm.js',
|
|
87
|
+
* pipelines: ['selfie'],
|
|
88
|
+
* },
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function setup(options: SetupOptions): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Sets the WASM configuration without performing warmup.
|
|
95
|
+
* Useful when WASM warmup is handled separately (e.g., conditionally based on flow).
|
|
96
|
+
*
|
|
97
|
+
* @param config - WASM configuration to store
|
|
98
|
+
*/
|
|
99
|
+
declare function setWasmConfig(config: WasmConfig): void;
|
|
100
|
+
/**
|
|
101
|
+
* Initializes WasmUtilProvider with the stored WASM configuration.
|
|
102
|
+
* Should be called after warmupWasm() completes when using conditional warmup.
|
|
103
|
+
* This ensures image encryption works properly.
|
|
104
|
+
*
|
|
105
|
+
* @param config - Optional WASM configuration. If not provided, uses the stored config from setWasmConfig().
|
|
106
|
+
* @throws Error if no config is provided and none is stored
|
|
107
|
+
*/
|
|
108
|
+
declare function initializeWasmUtil(config?: WasmConfig): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Checks if the SDK has been configured.
|
|
111
|
+
*
|
|
112
|
+
* @returns true if setup() has been called, false otherwise
|
|
113
|
+
*/
|
|
114
|
+
declare function isConfigured(): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Resets the SDK configuration. Useful for testing.
|
|
117
|
+
*/
|
|
118
|
+
declare function reset(): void;
|
|
119
|
+
//#endregion
|
|
120
|
+
export { reset as a, isConfigured as i, WasmConfig as n, setWasmConfig as o, initializeWasmUtil as r, setup as s, SetupOptions as t };
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { n as warmupWasm } from "./BaseWasmProvider-CQgeReKV.esm.js";
|
|
2
|
+
import { t as WasmUtilProvider } from "./WasmUtilProvider-C45HStLj.esm.js";
|
|
3
|
+
import { a as resetApi, o as setClient, s as setToken } from "./api-CyI8qTie.esm.js";
|
|
4
|
+
import { h as flushEventQueue } from "./events-BlVGS-8F.esm.js";
|
|
5
|
+
import { i as resetSessionInit, r as initializeSession } from "./session-PLjFj_T3.esm.js";
|
|
6
|
+
|
|
7
|
+
//#region ../infra/src/http/createApi.ts
|
|
8
|
+
var FetchHttpError = class extends Error {
|
|
9
|
+
constructor(status, statusText, url, method, headers, data) {
|
|
10
|
+
super(`HTTP ${status} ${statusText}`);
|
|
11
|
+
this.ok = false;
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.statusText = statusText;
|
|
14
|
+
this.url = url;
|
|
15
|
+
this.method = method;
|
|
16
|
+
this.headers = headers;
|
|
17
|
+
this.data = data;
|
|
18
|
+
this.name = "FetchHttpError";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const buildQueryString = (query) => {
|
|
22
|
+
if (!query) return "";
|
|
23
|
+
const params = new URLSearchParams();
|
|
24
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
25
|
+
if (value !== void 0 && value !== null) params.append(key, String(value));
|
|
26
|
+
});
|
|
27
|
+
const str = params.toString();
|
|
28
|
+
return str ? `?${str}` : "";
|
|
29
|
+
};
|
|
30
|
+
const buildUrl = (baseURL, url, query) => {
|
|
31
|
+
const queryString = buildQueryString(query);
|
|
32
|
+
if (url.startsWith("http://") || url.startsWith("https://")) return `${url}${queryString}`;
|
|
33
|
+
return `${baseURL.endsWith("/") ? baseURL.slice(0, -1) : baseURL}${url.startsWith("/") ? url : `/${url}`}${queryString}`;
|
|
34
|
+
};
|
|
35
|
+
const prepareBody = (body) => {
|
|
36
|
+
if (body === null || body === void 0) return null;
|
|
37
|
+
if (body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer) return body;
|
|
38
|
+
if (typeof body === "object") return JSON.stringify(body);
|
|
39
|
+
return String(body);
|
|
40
|
+
};
|
|
41
|
+
const parseResponse = async (response, parseType) => {
|
|
42
|
+
if (parseType === "response") return response;
|
|
43
|
+
if (parseType === "blob") return await response.blob();
|
|
44
|
+
if (parseType === "arrayBuffer") return await response.arrayBuffer();
|
|
45
|
+
if (parseType === "text") return await response.text();
|
|
46
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
47
|
+
if (parseType === "json" || contentType.includes("application/json")) try {
|
|
48
|
+
return await response.json();
|
|
49
|
+
} catch {
|
|
50
|
+
return await response.text();
|
|
51
|
+
}
|
|
52
|
+
return await response.text();
|
|
53
|
+
};
|
|
54
|
+
const DEFAULT_TIMEOUT = 3e4;
|
|
55
|
+
const requestWithXHR = (fullUrl, method, mergedHeaders, requestBody, timeout, signal, onUploadProgress) => {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const xhr = new XMLHttpRequest();
|
|
58
|
+
xhr.open(method, fullUrl, true);
|
|
59
|
+
Object.entries(mergedHeaders).forEach(([key, value]) => {
|
|
60
|
+
xhr.setRequestHeader(key, value);
|
|
61
|
+
});
|
|
62
|
+
xhr.timeout = timeout;
|
|
63
|
+
xhr.upload.onprogress = (event) => {
|
|
64
|
+
if (event.lengthComputable) {
|
|
65
|
+
const percentComplete = event.loaded / event.total * 100;
|
|
66
|
+
onUploadProgress(Math.round(percentComplete));
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
xhr.onload = () => {
|
|
70
|
+
const responseHeaders = {};
|
|
71
|
+
xhr.getAllResponseHeaders().split("\r\n").forEach((line) => {
|
|
72
|
+
const parts = line.split(": ");
|
|
73
|
+
if (parts.length === 2) responseHeaders[parts[0].toLowerCase()] = parts[1];
|
|
74
|
+
});
|
|
75
|
+
let data;
|
|
76
|
+
try {
|
|
77
|
+
if ((xhr.getResponseHeader("content-type") ?? "").includes("application/json")) data = JSON.parse(xhr.responseText);
|
|
78
|
+
else data = xhr.responseText;
|
|
79
|
+
} catch {
|
|
80
|
+
data = xhr.responseText;
|
|
81
|
+
}
|
|
82
|
+
if (xhr.status >= 200 && xhr.status < 300) resolve({
|
|
83
|
+
ok: true,
|
|
84
|
+
status: xhr.status,
|
|
85
|
+
statusText: xhr.statusText,
|
|
86
|
+
url: fullUrl,
|
|
87
|
+
headers: responseHeaders,
|
|
88
|
+
data
|
|
89
|
+
});
|
|
90
|
+
else reject(new FetchHttpError(xhr.status, xhr.statusText, fullUrl, method, responseHeaders, data));
|
|
91
|
+
};
|
|
92
|
+
xhr.onerror = () => {
|
|
93
|
+
reject(new FetchHttpError(0, "Network Error", fullUrl, method, {}, null));
|
|
94
|
+
};
|
|
95
|
+
xhr.ontimeout = () => {
|
|
96
|
+
reject(new FetchHttpError(0, "Request timeout", fullUrl, method, {}, null));
|
|
97
|
+
};
|
|
98
|
+
if (signal) signal.addEventListener("abort", () => {
|
|
99
|
+
xhr.abort();
|
|
100
|
+
reject(new FetchHttpError(0, "Request aborted", fullUrl, method, {}, null));
|
|
101
|
+
});
|
|
102
|
+
xhr.send(requestBody);
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const createApi = (config) => {
|
|
106
|
+
const headers = {
|
|
107
|
+
"Content-Type": "application/json",
|
|
108
|
+
Accept: "application/json",
|
|
109
|
+
"api-version": "1.0",
|
|
110
|
+
...config.customHeaders ?? {}
|
|
111
|
+
};
|
|
112
|
+
const defaults = {
|
|
113
|
+
baseURL: config.apiURL,
|
|
114
|
+
headers
|
|
115
|
+
};
|
|
116
|
+
const client = {
|
|
117
|
+
defaults,
|
|
118
|
+
async request(requestConfig) {
|
|
119
|
+
const { method = "GET", url, headers: headers$1 = {}, query, params, body, signal, timeout = config.timeout ?? DEFAULT_TIMEOUT, parse, onUploadProgress } = requestConfig;
|
|
120
|
+
const fullUrl = buildUrl(defaults.baseURL, url, params ?? query);
|
|
121
|
+
const mergedHeaders = {
|
|
122
|
+
...defaults.headers,
|
|
123
|
+
...headers$1
|
|
124
|
+
};
|
|
125
|
+
const requestBody = prepareBody(body);
|
|
126
|
+
let finalHeaders = mergedHeaders;
|
|
127
|
+
if (requestBody === null && (method === "POST" || method === "PUT" || method === "PATCH")) {
|
|
128
|
+
const { "Content-Type": _, ...headersWithoutContentType } = mergedHeaders;
|
|
129
|
+
finalHeaders = headersWithoutContentType;
|
|
130
|
+
}
|
|
131
|
+
if (onUploadProgress) {
|
|
132
|
+
if (requestBody !== null && typeof ReadableStream !== "undefined" && requestBody instanceof ReadableStream) throw new Error("Upload progress tracking is not supported for ReadableStream bodies");
|
|
133
|
+
return requestWithXHR(fullUrl, method, finalHeaders, requestBody, timeout, signal, onUploadProgress);
|
|
134
|
+
}
|
|
135
|
+
const controller = new AbortController();
|
|
136
|
+
const abortSignal = signal ?? controller.signal;
|
|
137
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
138
|
+
try {
|
|
139
|
+
const response = await fetch(fullUrl, {
|
|
140
|
+
method,
|
|
141
|
+
headers: finalHeaders,
|
|
142
|
+
body: requestBody,
|
|
143
|
+
signal: abortSignal
|
|
144
|
+
});
|
|
145
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
146
|
+
const responseHeaders = {};
|
|
147
|
+
response.headers.forEach((value, key) => {
|
|
148
|
+
responseHeaders[key] = value;
|
|
149
|
+
});
|
|
150
|
+
const data = await parseResponse(response, parse);
|
|
151
|
+
if (!response.ok) throw new FetchHttpError(response.status, response.statusText, fullUrl, method, responseHeaders, data);
|
|
152
|
+
return {
|
|
153
|
+
ok: true,
|
|
154
|
+
status: response.status,
|
|
155
|
+
statusText: response.statusText,
|
|
156
|
+
url: fullUrl,
|
|
157
|
+
headers: responseHeaders,
|
|
158
|
+
data
|
|
159
|
+
};
|
|
160
|
+
} catch (error) {
|
|
161
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
162
|
+
if (error instanceof FetchHttpError) throw error;
|
|
163
|
+
if (error instanceof Error && error.name === "AbortError") throw new FetchHttpError(0, "Request timeout", fullUrl, method, {}, null);
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
get(url, config$1) {
|
|
168
|
+
return client.request({
|
|
169
|
+
...config$1,
|
|
170
|
+
url,
|
|
171
|
+
method: "GET"
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
post(url, body, config$1) {
|
|
175
|
+
return client.request({
|
|
176
|
+
...config$1,
|
|
177
|
+
url,
|
|
178
|
+
body,
|
|
179
|
+
method: "POST"
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
put(url, body, config$1) {
|
|
183
|
+
return client.request({
|
|
184
|
+
...config$1,
|
|
185
|
+
url,
|
|
186
|
+
body,
|
|
187
|
+
method: "PUT"
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
patch(url, body, config$1) {
|
|
191
|
+
return client.request({
|
|
192
|
+
...config$1,
|
|
193
|
+
url,
|
|
194
|
+
body,
|
|
195
|
+
method: "PATCH"
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
delete(url, config$1) {
|
|
199
|
+
return client.request({
|
|
200
|
+
...config$1,
|
|
201
|
+
url,
|
|
202
|
+
method: "DELETE"
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
head(url, config$1) {
|
|
206
|
+
return client.request({
|
|
207
|
+
...config$1,
|
|
208
|
+
url,
|
|
209
|
+
method: "HEAD"
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
options(url, config$1) {
|
|
213
|
+
return client.request({
|
|
214
|
+
...config$1,
|
|
215
|
+
url,
|
|
216
|
+
method: "OPTIONS"
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
setHeader(name, value) {
|
|
220
|
+
defaults.headers[name] = value;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
return client;
|
|
224
|
+
};
|
|
225
|
+
var createApi_default = createApi;
|
|
226
|
+
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region ../infra/src/wasm/wasmDefaults.ts
|
|
229
|
+
const WASM_CDN_BASE_URL = "https://cdn.incodesmile.com/ml-wasm-kit-release";
|
|
230
|
+
/** The WASM version bundled and tested with this SDK release. */
|
|
231
|
+
const DEFAULT_WASM_VERSION = "v2.12.84";
|
|
232
|
+
const PATH_KEYS = [
|
|
233
|
+
"wasmPath",
|
|
234
|
+
"wasmSimdPath",
|
|
235
|
+
"glueCodePath",
|
|
236
|
+
"modelsBasePath"
|
|
237
|
+
];
|
|
238
|
+
function isBlank(value) {
|
|
239
|
+
return value.trim() === "";
|
|
240
|
+
}
|
|
241
|
+
function hasDisallowedControlChars(value) {
|
|
242
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
243
|
+
const code = value.charCodeAt(i);
|
|
244
|
+
if (code < 32 || code === 127) return true;
|
|
245
|
+
}
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
function isMalformedPath(value) {
|
|
249
|
+
const trimmed = value.trim();
|
|
250
|
+
if (trimmed === "") return false;
|
|
251
|
+
if (hasDisallowedControlChars(trimmed)) return true;
|
|
252
|
+
if (/^https?:\/\//i.test(trimmed)) try {
|
|
253
|
+
new URL(trimmed);
|
|
254
|
+
return false;
|
|
255
|
+
} catch {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
function warnInvalidWasmPath(field, reason) {
|
|
261
|
+
if (reason === "empty") {
|
|
262
|
+
console.warn(`[Incode SDK] wasm.${field} is empty. Falling back to CDN default.`);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
console.warn(`[Incode SDK] wasm.${field} appears malformed. Falling back to CDN default.`);
|
|
266
|
+
}
|
|
267
|
+
function warnMalformedWasmPath(field) {
|
|
268
|
+
console.warn(`[Incode SDK] wasm.${field} appears malformed. Check the URL or path.`);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Validates merged WASM path strings. When overrides contained blank path
|
|
272
|
+
* values, callers should have already fallen back to defaults before this runs.
|
|
273
|
+
*/
|
|
274
|
+
function validateWasmPaths(config) {
|
|
275
|
+
for (const key of PATH_KEYS) {
|
|
276
|
+
const value = config[key];
|
|
277
|
+
if (typeof value === "string" && isMalformedPath(value)) warnMalformedWasmPath(key);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function pickPath(key, overrides, defaultValue) {
|
|
281
|
+
if (!overrides || !(key in overrides)) return defaultValue;
|
|
282
|
+
const raw = overrides[key];
|
|
283
|
+
if (raw === void 0) return defaultValue;
|
|
284
|
+
if (typeof raw !== "string") return defaultValue;
|
|
285
|
+
if (isBlank(raw)) {
|
|
286
|
+
warnInvalidWasmPath(key, "empty");
|
|
287
|
+
return defaultValue;
|
|
288
|
+
}
|
|
289
|
+
if (isMalformedPath(raw)) {
|
|
290
|
+
warnInvalidWasmPath(key, "malformed");
|
|
291
|
+
return defaultValue;
|
|
292
|
+
}
|
|
293
|
+
return raw.trim();
|
|
294
|
+
}
|
|
295
|
+
/** Builds the standard WarmupConfig from the Incode CDN. */
|
|
296
|
+
function buildDefaultWasmConfig() {
|
|
297
|
+
const base = `${WASM_CDN_BASE_URL}/${DEFAULT_WASM_VERSION}`;
|
|
298
|
+
return {
|
|
299
|
+
wasmPath: `${base}/webLib.wasm`,
|
|
300
|
+
wasmSimdPath: `${base}/webLibSimd.wasm`,
|
|
301
|
+
glueCodePath: `${base}/webLib.js`,
|
|
302
|
+
modelsBasePath: `${base}/models`
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Merges optional WASM path overrides with CDN defaults. Explicit non-blank
|
|
307
|
+
* paths take precedence. Blank override strings log a warning and fall back to defaults.
|
|
308
|
+
*/
|
|
309
|
+
function resolveWasmConfig(overrides) {
|
|
310
|
+
const defaults = buildDefaultWasmConfig();
|
|
311
|
+
if (!overrides) return defaults;
|
|
312
|
+
const simdDefault = defaults.wasmSimdPath ?? defaults.wasmPath;
|
|
313
|
+
const modelsDefault = defaults.modelsBasePath ?? (() => {
|
|
314
|
+
const lastSlash = defaults.wasmPath.lastIndexOf("/");
|
|
315
|
+
return lastSlash === -1 ? "models" : `${defaults.wasmPath.substring(0, lastSlash)}/models`;
|
|
316
|
+
})();
|
|
317
|
+
const merged = {
|
|
318
|
+
wasmPath: pickPath("wasmPath", overrides, defaults.wasmPath),
|
|
319
|
+
wasmSimdPath: pickPath("wasmSimdPath", overrides, simdDefault),
|
|
320
|
+
glueCodePath: pickPath("glueCodePath", overrides, defaults.glueCodePath),
|
|
321
|
+
modelsBasePath: pickPath("modelsBasePath", overrides, modelsDefault),
|
|
322
|
+
useSimd: overrides.useSimd,
|
|
323
|
+
pipelines: overrides.pipelines,
|
|
324
|
+
pipelineModels: overrides.pipelineModels
|
|
325
|
+
};
|
|
326
|
+
validateWasmPaths(merged);
|
|
327
|
+
return merged;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/setup.ts
|
|
332
|
+
let wasmConfig;
|
|
333
|
+
let configured = false;
|
|
334
|
+
/**
|
|
335
|
+
* Initializes the SDK with the provided configuration.
|
|
336
|
+
* Must be called before using any SDK functionality.
|
|
337
|
+
*
|
|
338
|
+
* WASM loads automatically from the Incode CDN unless explicitly disabled or overridden.
|
|
339
|
+
*
|
|
340
|
+
* @param options - Configuration options for the SDK
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* import { setup } from '@incodetech/core';
|
|
345
|
+
*
|
|
346
|
+
* // Zero-config: WASM loads automatically from CDN
|
|
347
|
+
* await setup({ apiURL: 'https://api.incode.com', token: 'session-token' });
|
|
348
|
+
*
|
|
349
|
+
* // Opt out of WASM
|
|
350
|
+
* await setup({ apiURL: 'https://api.incode.com', token: 'session-token', wasm: false });
|
|
351
|
+
*
|
|
352
|
+
* // Self-hosted / custom version (full or partial path overrides)
|
|
353
|
+
* await setup({
|
|
354
|
+
* apiURL: 'https://api.incode.com',
|
|
355
|
+
* token: 'session-token',
|
|
356
|
+
* wasm: {
|
|
357
|
+
* wasmPath: '/my-cdn/webLib.wasm',
|
|
358
|
+
* glueCodePath: '/my-cdn/webLib.js',
|
|
359
|
+
* },
|
|
360
|
+
* });
|
|
361
|
+
*
|
|
362
|
+
* // Partial override: only models path, rest from CDN
|
|
363
|
+
* await setup({
|
|
364
|
+
* apiURL: 'https://api.incode.com',
|
|
365
|
+
* token: 'session-token',
|
|
366
|
+
* wasm: { modelsBasePath: 'https://my-cdn/models' },
|
|
367
|
+
* });
|
|
368
|
+
*
|
|
369
|
+
* // Sessionless setup (all API actors overridden via .provide())
|
|
370
|
+
* await setup({
|
|
371
|
+
* wasm: {
|
|
372
|
+
* wasmPath: '/wasm/ml-wasm.wasm',
|
|
373
|
+
* glueCodePath: '/wasm/ml-wasm.js',
|
|
374
|
+
* pipelines: ['selfie'],
|
|
375
|
+
* },
|
|
376
|
+
* });
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
async function setup(options) {
|
|
380
|
+
if (options.apiURL) {
|
|
381
|
+
setClient(createApi_default({
|
|
382
|
+
apiURL: options.apiURL,
|
|
383
|
+
customHeaders: options.customHeaders,
|
|
384
|
+
timeout: options.timeout
|
|
385
|
+
}));
|
|
386
|
+
if (options.token) {
|
|
387
|
+
setToken(options.token);
|
|
388
|
+
flushEventQueue();
|
|
389
|
+
initializeSession({ hostingApp: options.hostingApp }).catch((error) => {
|
|
390
|
+
console.warn("Session initialization failed:", error);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
configured = true;
|
|
395
|
+
const effectiveWasm = options.wasm === false ? void 0 : resolveWasmConfig(options.wasm);
|
|
396
|
+
if (effectiveWasm) {
|
|
397
|
+
await warmupWasm(effectiveWasm);
|
|
398
|
+
await (await WasmUtilProvider.getInstance()).initialize({
|
|
399
|
+
...effectiveWasm,
|
|
400
|
+
pipelines: effectiveWasm.pipelines ? [...effectiveWasm.pipelines] : void 0
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Sets the WASM configuration without performing warmup.
|
|
406
|
+
* Useful when WASM warmup is handled separately (e.g., conditionally based on flow).
|
|
407
|
+
*
|
|
408
|
+
* @param config - WASM configuration to store
|
|
409
|
+
*/
|
|
410
|
+
function setWasmConfig(config) {
|
|
411
|
+
wasmConfig = config;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Initializes WasmUtilProvider with the stored WASM configuration.
|
|
415
|
+
* Should be called after warmupWasm() completes when using conditional warmup.
|
|
416
|
+
* This ensures image encryption works properly.
|
|
417
|
+
*
|
|
418
|
+
* @param config - Optional WASM configuration. If not provided, uses the stored config from setWasmConfig().
|
|
419
|
+
* @throws Error if no config is provided and none is stored
|
|
420
|
+
*/
|
|
421
|
+
async function initializeWasmUtil(config) {
|
|
422
|
+
const wasmConfigToUse = config ?? wasmConfig;
|
|
423
|
+
if (!wasmConfigToUse) throw new Error("WASM config is required. Provide config parameter or call setWasmConfig() first.");
|
|
424
|
+
const resolved = resolveWasmConfig(wasmConfigToUse);
|
|
425
|
+
await (await WasmUtilProvider.getInstance()).initialize({
|
|
426
|
+
...resolved,
|
|
427
|
+
pipelines: resolved.pipelines ? [...resolved.pipelines] : void 0
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Checks if the SDK has been configured.
|
|
432
|
+
*
|
|
433
|
+
* @returns true if setup() has been called, false otherwise
|
|
434
|
+
*/
|
|
435
|
+
function isConfigured() {
|
|
436
|
+
return configured;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Resets the SDK configuration. Useful for testing.
|
|
440
|
+
*/
|
|
441
|
+
function reset() {
|
|
442
|
+
resetApi();
|
|
443
|
+
resetSessionInit();
|
|
444
|
+
configured = false;
|
|
445
|
+
wasmConfig = void 0;
|
|
446
|
+
WasmUtilProvider.resetInstance();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
//#endregion
|
|
450
|
+
export { setup as a, resolveWasmConfig as c, setWasmConfig as i, isConfigured as n, DEFAULT_WASM_VERSION as o, reset as r, buildDefaultWasmConfig as s, initializeWasmUtil as t };
|
package/dist/signature.d.ts
CHANGED
package/dist/signature.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as api } from "./api-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
1
|
+
import { t as api } from "./api-CyI8qTie.esm.js";
|
|
2
|
+
import { _ as endpoints, m as addEvent, n as eventModuleNames, o as createManagerInstrumentation, r as eventScreenNames } from "./events-BlVGS-8F.esm.js";
|
|
3
|
+
import { a as createActor, i as fromPromise, n as assign, o as createManager, t as setup } from "./xstate.esm-BXrcOcSC.esm.js";
|
|
4
4
|
|
|
5
5
|
//#region src/modules/signature/signatureServices.ts
|
|
6
6
|
/**
|
package/dist/stats.esm.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { AnyStateMachine, StateMachine, fromPromise } from "xstate";
|
|
2
|
-
|
|
3
1
|
//#region ../infra/src/wasm/warmup.d.ts
|
|
4
|
-
|
|
5
2
|
/**
|
|
6
3
|
* All available ML pipelines in the SDK.
|
|
7
4
|
* - 'selfie' - Face detection for selfie capture
|
|
@@ -55,4 +52,4 @@ interface WarmupConfig {
|
|
|
55
52
|
*/
|
|
56
53
|
declare function warmupWasm(config: WarmupConfig): Promise<void>;
|
|
57
54
|
//#endregion
|
|
58
|
-
export { WasmPipeline as
|
|
55
|
+
export { WasmPipeline as n, warmupWasm as r, WarmupConfig as t };
|
package/dist/wasm.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { n as WasmPipeline, r as warmupWasm, t as WarmupConfig } from "./warmup-CEOVQKby.js";
|
|
2
|
+
import { n as WasmConfig, o as setWasmConfig, r as initializeWasmUtil } from "./setup-DJ3dFl5k.js";
|
|
3
|
+
|
|
4
|
+
//#region ../infra/src/wasm/wasmDefaults.d.ts
|
|
5
|
+
/** The WASM version bundled and tested with this SDK release. */
|
|
6
|
+
declare const DEFAULT_WASM_VERSION = "v2.12.84";
|
|
7
|
+
/** Builds the standard WarmupConfig from the Incode CDN. */
|
|
8
|
+
declare function buildDefaultWasmConfig(): WarmupConfig;
|
|
9
|
+
/**
|
|
10
|
+
* Merges optional WASM path overrides with CDN defaults. Explicit non-blank
|
|
11
|
+
* paths take precedence. Blank override strings log a warning and fall back to defaults.
|
|
12
|
+
*/
|
|
13
|
+
declare function resolveWasmConfig(overrides?: Partial<WarmupConfig>): WarmupConfig;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DEFAULT_WASM_VERSION, type WasmConfig, type WasmPipeline, buildDefaultWasmConfig, initializeWasmUtil, resolveWasmConfig, setWasmConfig, warmupWasm };
|
package/dist/wasm.esm.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { c as resolveWasmConfig, i as setWasmConfig, o as DEFAULT_WASM_VERSION, s as buildDefaultWasmConfig, t as initializeWasmUtil } from "./setup-fvDWE7f8.esm.js";
|
|
2
|
+
import { n as warmupWasm } from "./BaseWasmProvider-CQgeReKV.esm.js";
|
|
3
|
+
import "./WasmUtilProvider-C45HStLj.esm.js";
|
|
4
|
+
import "./api-CyI8qTie.esm.js";
|
|
5
|
+
import "./events-BlVGS-8F.esm.js";
|
|
6
|
+
import "./session-PLjFj_T3.esm.js";
|
|
7
|
+
import "./BrowserEnvironmentProvider--xQUs3sg.esm.js";
|
|
8
|
+
import "./browserSimulation-yzDdWSBf.esm.js";
|
|
9
|
+
|
|
10
|
+
export { DEFAULT_WASM_VERSION, buildDefaultWasmConfig, initializeWasmUtil, resolveWasmConfig, setWasmConfig, warmupWasm };
|