@soliton-id/web-sdk 1.2.0 → 1.4.0

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.
@@ -0,0 +1,541 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // sdk/src/white-label.ts
38
+ var white_label_exports = {};
39
+ __export(white_label_exports, {
40
+ default: () => white_label_default,
41
+ open: () => open
42
+ });
43
+ module.exports = __toCommonJS(white_label_exports);
44
+
45
+ // sdk/src/theme.ts
46
+ var MAX_THEME_PARAM_LENGTH = 4096;
47
+ var COLOR_KEYS = {
48
+ background: true,
49
+ surface: true,
50
+ surfaceMuted: true,
51
+ text: true,
52
+ textMuted: true,
53
+ border: true,
54
+ primary: true,
55
+ primaryPressed: true,
56
+ onPrimary: true,
57
+ accent: true,
58
+ progress: true,
59
+ success: true,
60
+ warning: true,
61
+ error: true,
62
+ illustration: true,
63
+ overlay: true,
64
+ cameraBackground: true,
65
+ oval: true,
66
+ ovalProgress: true,
67
+ closeButton: true
68
+ };
69
+ var COLOR_KEY_ORDER = Object.keys(COLOR_KEYS);
70
+ var COLOR_SCHEMES = ["auto", "light", "dark"];
71
+ var HEX_COLOR_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
72
+ var MAX_LISTED = 20;
73
+ var MAX_LISTED_NAME = 40;
74
+ var hasOwn = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
75
+ function isRecord(value) {
76
+ return typeof value === "object" && value !== null && !Array.isArray(value);
77
+ }
78
+ function isUnset(value) {
79
+ return value === void 0 || value === null;
80
+ }
81
+ function isHexColor(value) {
82
+ return typeof value === "string" && value.length <= 7 && HEX_COLOR_RE.test(value);
83
+ }
84
+ function filterPalette(value, path, ignored) {
85
+ if (!isRecord(value)) {
86
+ ignored.push(path);
87
+ return void 0;
88
+ }
89
+ const valid = {};
90
+ for (const key of Object.keys(value)) {
91
+ const color = value[key];
92
+ if (isUnset(color)) continue;
93
+ if (hasOwn(COLOR_KEYS, key) && isHexColor(color)) {
94
+ valid[key] = color;
95
+ } else {
96
+ ignored.push(`${path}.${key}`);
97
+ }
98
+ }
99
+ const out = {};
100
+ let kept = false;
101
+ for (const key of COLOR_KEY_ORDER) {
102
+ const color = valid[key];
103
+ if (color !== void 0) {
104
+ out[key] = color;
105
+ kept = true;
106
+ }
107
+ }
108
+ return kept ? out : void 0;
109
+ }
110
+ function filterTheme(input, ignored) {
111
+ let colorScheme;
112
+ let colors;
113
+ let darkColors;
114
+ for (const key of Object.keys(input)) {
115
+ const value = input[key];
116
+ if (isUnset(value)) continue;
117
+ if (key === "colorScheme") {
118
+ if (typeof value === "string" && COLOR_SCHEMES.indexOf(value) !== -1) {
119
+ colorScheme = value;
120
+ } else {
121
+ ignored.push(key);
122
+ }
123
+ } else if (key === "colors") {
124
+ colors = filterPalette(value, key, ignored);
125
+ } else if (key === "darkColors") {
126
+ darkColors = filterPalette(value, key, ignored);
127
+ } else {
128
+ ignored.push(key);
129
+ }
130
+ }
131
+ if (colorScheme === void 0 && colors === void 0 && darkColors === void 0) {
132
+ return null;
133
+ }
134
+ const theme = {};
135
+ if (colorScheme !== void 0) theme.colorScheme = colorScheme;
136
+ if (colors !== void 0) theme.colors = colors;
137
+ if (darkColors !== void 0) theme.darkColors = darkColors;
138
+ return theme;
139
+ }
140
+ function listNames(names) {
141
+ const shown = names.slice(0, MAX_LISTED).map((name) => name.length > MAX_LISTED_NAME ? `${name.slice(0, MAX_LISTED_NAME)}...` : name);
142
+ const more = names.length - shown.length;
143
+ return shown.join(", ") + (more > 0 ? ` and ${more} more` : "");
144
+ }
145
+ function warn(message) {
146
+ try {
147
+ if (typeof console !== "undefined" && typeof console.warn === "function") {
148
+ console.warn(message);
149
+ }
150
+ } catch (e) {
151
+ }
152
+ }
153
+ function prepareTheme(source, warnPrefix, maxLength = MAX_THEME_PARAM_LENGTH) {
154
+ const ignored = [];
155
+ let theme = null;
156
+ let whole = "";
157
+ try {
158
+ const input = source.theme;
159
+ if (isUnset(input)) return { theme: null, param: null };
160
+ if (isRecord(input)) {
161
+ theme = filterTheme(input, ignored);
162
+ } else {
163
+ whole = "it is not an object";
164
+ }
165
+ } catch (e) {
166
+ theme = null;
167
+ whole = "it could not be read";
168
+ }
169
+ let param = null;
170
+ if (theme !== null) {
171
+ const json = JSON.stringify(theme);
172
+ if (json.length > maxLength) {
173
+ theme = null;
174
+ whole = `it is longer than ${maxLength} characters`;
175
+ } else {
176
+ param = json;
177
+ }
178
+ }
179
+ if (whole !== "") {
180
+ warn(`${warnPrefix} theme ignored: ${whole}.`);
181
+ } else if (ignored.length > 0) {
182
+ warn(
183
+ `${warnPrefix} theme: ignored ${listNames(ignored)}. Colors must be "#rgb" or "#rrggbb" and colorScheme "auto", "light" or "dark".`
184
+ );
185
+ }
186
+ return { theme, param };
187
+ }
188
+ function prefersDark() {
189
+ try {
190
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches === true;
191
+ } catch (e) {
192
+ return false;
193
+ }
194
+ }
195
+ function activePalette(theme) {
196
+ var _a;
197
+ if (theme === null) return void 0;
198
+ const scheme = (_a = theme.colorScheme) != null ? _a : "auto";
199
+ const dark = scheme === "dark" || scheme === "auto" && prefersDark();
200
+ return dark ? theme.darkColors : theme.colors;
201
+ }
202
+ function relativeLuminance(hex) {
203
+ const digits = hex.length === 4 ? hex.slice(1).split("").map((digit) => digit + digit).join("") : hex.slice(1);
204
+ const channel = (offset) => {
205
+ const value = parseInt(digits.slice(offset, offset + 2), 16) / 255;
206
+ return value <= 0.04045 ? value / 12.92 : Math.pow((value + 0.055) / 1.055, 2.4);
207
+ };
208
+ return 0.2126 * channel(0) + 0.7152 * channel(2) + 0.0722 * channel(4);
209
+ }
210
+ function contrastRatio(a, b) {
211
+ const la = relativeLuminance(a);
212
+ const lb = relativeLuminance(b);
213
+ return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
214
+ }
215
+
216
+ // sdk/src/overlay.ts
217
+ var MAX_Z_INDEX = "2147483647";
218
+ var DEFAULT_BACKDROP = "#0f110b";
219
+ var DEFAULT_CLOSE_FILL = "rgba(0,0,0,0.45)";
220
+ var LIGHT_INK = { hex: "#ffffff", rgb: "255,255,255" };
221
+ var DARK_INK = { hex: DEFAULT_BACKDROP, rgb: "15,17,11" };
222
+ function inkOn(backdrop) {
223
+ return contrastRatio(DARK_INK.hex, backdrop) > contrastRatio(LIGHT_INK.hex, backdrop) ? DARK_INK.rgb : LIGHT_INK.rgb;
224
+ }
225
+ var openOverlayCount = 0;
226
+ var savedBodyOverflow = "";
227
+ function createOverlay(iframeSrc, onCloseClick, names, backdrop, closeFill) {
228
+ const background = backdrop != null ? backdrop : DEFAULT_BACKDROP;
229
+ const ink = backdrop === void 0 ? LIGHT_INK.rgb : inkOn(backdrop);
230
+ const closeInk = closeFill === void 0 ? LIGHT_INK.rgb : inkOn(closeFill);
231
+ const doc = document;
232
+ const container = doc.createElement("div");
233
+ container.setAttribute(names.marker, "overlay");
234
+ container.style.cssText = [
235
+ "position:fixed",
236
+ "inset:0",
237
+ `z-index:${MAX_Z_INDEX}`,
238
+ `background:${background}`,
239
+ "display:block"
240
+ ].join(";");
241
+ const style = doc.createElement("style");
242
+ style.textContent = `@keyframes ${names.animation}{to{transform:rotate(360deg)}}`;
243
+ container.appendChild(style);
244
+ const loading = doc.createElement("div");
245
+ loading.setAttribute(names.marker, "loading");
246
+ loading.style.cssText = [
247
+ "position:absolute",
248
+ "inset:0",
249
+ "display:flex",
250
+ "flex-direction:column",
251
+ "align-items:center",
252
+ "justify-content:center",
253
+ "gap:14px",
254
+ `color:rgba(${ink},0.75)`,
255
+ "font:14px/1.4 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"
256
+ ].join(";");
257
+ const spinner = doc.createElement("div");
258
+ spinner.style.cssText = [
259
+ "width:22px",
260
+ "height:22px",
261
+ "border-radius:999px",
262
+ `border:2px solid rgba(${ink},0.25)`,
263
+ `border-top-color:rgba(${ink},0.9)`,
264
+ `animation:${names.animation} 0.8s linear infinite`
265
+ ].join(";");
266
+ const loadingText = doc.createElement("div");
267
+ loadingText.textContent = "Loading secure verification...";
268
+ loading.appendChild(spinner);
269
+ loading.appendChild(loadingText);
270
+ container.appendChild(loading);
271
+ const iframe = doc.createElement("iframe");
272
+ iframe.setAttribute("allow", "camera; microphone; fullscreen; autoplay");
273
+ iframe.setAttribute("title", names.title);
274
+ iframe.style.cssText = [
275
+ "position:absolute",
276
+ "inset:0",
277
+ "width:100%",
278
+ "height:100%",
279
+ "border:0",
280
+ "display:block"
281
+ ].join(";");
282
+ iframe.src = iframeSrc;
283
+ container.appendChild(iframe);
284
+ const closeButton = doc.createElement("button");
285
+ closeButton.type = "button";
286
+ closeButton.setAttribute("aria-label", "Close verification");
287
+ closeButton.textContent = "\xD7";
288
+ closeButton.style.cssText = [
289
+ "position:absolute",
290
+ "top:14px",
291
+ "right:14px",
292
+ "width:36px",
293
+ "height:36px",
294
+ "border-radius:999px",
295
+ `border:1px solid rgba(${closeInk},0.3)`,
296
+ `background:${closeFill != null ? closeFill : DEFAULT_CLOSE_FILL}`,
297
+ `color:rgba(${closeInk},0.85)`,
298
+ "font:20px/1 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif",
299
+ "cursor:pointer",
300
+ "padding:0"
301
+ ].join(";");
302
+ closeButton.addEventListener("click", onCloseClick);
303
+ container.appendChild(closeButton);
304
+ if (openOverlayCount === 0) {
305
+ savedBodyOverflow = doc.body.style.overflow;
306
+ }
307
+ openOverlayCount += 1;
308
+ doc.body.style.overflow = "hidden";
309
+ doc.body.appendChild(container);
310
+ let destroyed = false;
311
+ return {
312
+ iframe,
313
+ markReady() {
314
+ loading.style.display = "none";
315
+ },
316
+ destroy() {
317
+ if (destroyed) return;
318
+ destroyed = true;
319
+ openOverlayCount -= 1;
320
+ if (openOverlayCount === 0) {
321
+ doc.body.style.overflow = savedBodyOverflow;
322
+ }
323
+ if (container.parentNode) container.parentNode.removeChild(container);
324
+ }
325
+ };
326
+ }
327
+
328
+ // sdk/src/core.ts
329
+ var AUTO_CLOSE_DELAY_MS = 250;
330
+ var HELLO_INTERVAL_MS = 250;
331
+ var HELLO_MAX_PINGS = 40;
332
+ var READY_TIMEOUT_MS = 3e4;
333
+ function openOverlay(options, names, parseUrl) {
334
+ var _a;
335
+ if (!options || typeof options.url !== "string") {
336
+ throw new Error(`${names.errorPrefix} open() requires an options object with a "url"`);
337
+ }
338
+ if (typeof options.onComplete !== "function") {
339
+ throw new Error(`${names.errorPrefix} open() requires an onComplete callback`);
340
+ }
341
+ const { url, hostedOrigin } = parseUrl(options.url, options.verificationOrigin);
342
+ const src = new URL(url.toString());
343
+ src.searchParams.set("mode", "embed");
344
+ src.searchParams.set("sdk", "1");
345
+ for (const [key, value] of (_a = names.params) != null ? _a : []) src.searchParams.set(key, value);
346
+ if (options.locale) src.searchParams.set("locale", options.locale);
347
+ const theme = prepareTheme(options, names.errorPrefix);
348
+ if (theme.param !== null) src.searchParams.set("theme", theme.param);
349
+ let closed = false;
350
+ let terminalDelivered = false;
351
+ let loadTimedOut = false;
352
+ let autoCloseTimer = null;
353
+ let readyTimer = null;
354
+ const palette = activePalette(theme.theme);
355
+ const overlay = createOverlay(
356
+ src.toString(),
357
+ () => close(),
358
+ names.overlay,
359
+ palette == null ? void 0 : palette.overlay,
360
+ palette == null ? void 0 : palette.closeButton
361
+ );
362
+ let helloPings = 0;
363
+ const postHello = () => {
364
+ var _a2;
365
+ helloPings += 1;
366
+ if (helloPings > HELLO_MAX_PINGS) {
367
+ stopHello();
368
+ return;
369
+ }
370
+ try {
371
+ (_a2 = overlay.iframe.contentWindow) == null ? void 0 : _a2.postMessage(
372
+ { protocol: names.protocol, type: names.hello },
373
+ hostedOrigin
374
+ );
375
+ } catch (e) {
376
+ }
377
+ };
378
+ const helloTimer = setInterval(postHello, HELLO_INTERVAL_MS);
379
+ const onIframeLoad = () => postHello();
380
+ overlay.iframe.addEventListener("load", onIframeLoad);
381
+ function stopHello() {
382
+ clearInterval(helloTimer);
383
+ overlay.iframe.removeEventListener("load", onIframeLoad);
384
+ }
385
+ function stopReadyWait() {
386
+ if (readyTimer !== null) clearTimeout(readyTimer);
387
+ readyTimer = null;
388
+ }
389
+ const onMessage = (event) => {
390
+ var _a2;
391
+ if (closed || loadTimedOut || terminalDelivered) return;
392
+ if (event.origin !== hostedOrigin) return;
393
+ if (!overlay.iframe.contentWindow || event.source !== overlay.iframe.contentWindow) {
394
+ return;
395
+ }
396
+ const data = event.data;
397
+ if (!data || typeof data !== "object" || data.protocol !== names.protocol) {
398
+ return;
399
+ }
400
+ stopHello();
401
+ switch (data.type) {
402
+ case names.ready:
403
+ stopReadyWait();
404
+ overlay.markReady();
405
+ break;
406
+ case names.complete: {
407
+ if (terminalDelivered) break;
408
+ stopReadyWait();
409
+ terminalDelivered = true;
410
+ autoCloseTimer = setTimeout(() => close(), AUTO_CLOSE_DELAY_MS);
411
+ options.onComplete({
412
+ verificationId: typeof data.verificationId === "string" ? data.verificationId : ""
413
+ });
414
+ break;
415
+ }
416
+ case names.error:
417
+ stopReadyWait();
418
+ (_a2 = options.onError) == null ? void 0 : _a2.call(options, {
419
+ code: typeof data.code === "string" ? data.code : "internal",
420
+ message: typeof data.message === "string" ? data.message : ""
421
+ });
422
+ break;
423
+ case names.close:
424
+ close();
425
+ break;
426
+ default:
427
+ break;
428
+ }
429
+ };
430
+ window.addEventListener("message", onMessage);
431
+ readyTimer = setTimeout(() => {
432
+ var _a2;
433
+ if (readyTimer === null || closed || terminalDelivered) return;
434
+ loadTimedOut = true;
435
+ try {
436
+ (_a2 = options.onError) == null ? void 0 : _a2.call(options, {
437
+ code: "load_timeout",
438
+ message: "Verification did not load. Please try again."
439
+ });
440
+ } finally {
441
+ close();
442
+ }
443
+ }, READY_TIMEOUT_MS);
444
+ function close() {
445
+ var _a2;
446
+ if (closed) return;
447
+ closed = true;
448
+ if (autoCloseTimer !== null) clearTimeout(autoCloseTimer);
449
+ stopReadyWait();
450
+ stopHello();
451
+ window.removeEventListener("message", onMessage);
452
+ overlay.destroy();
453
+ if (!terminalDelivered) (_a2 = options.onClose) == null ? void 0 : _a2.call(options);
454
+ }
455
+ return { close };
456
+ }
457
+
458
+ // sdk/src/trustedOrigin.ts
459
+ function trustedOrigin(value) {
460
+ const url = new URL(value);
461
+ const local = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
462
+ if (url.origin !== value || url.username || url.password || value.includes("*") || url.protocol !== "https:" && !(url.protocol === "http:" && local)) {
463
+ throw new Error("Use an exact HTTPS origin (HTTP loopback is allowed for development)");
464
+ }
465
+ return url.origin;
466
+ }
467
+
468
+ // sdk/src/urlCheck.ts
469
+ var HOSTED_PATH_RE = /^\/v\/[0-9a-f]{32}$/;
470
+ function checkHostedUrl(raw, prefix, configuredOrigin, checkUnconfigured) {
471
+ let url;
472
+ try {
473
+ url = new URL(raw);
474
+ } catch (e) {
475
+ throw new Error(`${prefix} "url" is not a valid absolute URL`);
476
+ }
477
+ if (configuredOrigin !== void 0) {
478
+ if (url.origin !== configuredOrigin) {
479
+ throw new Error(`${prefix} "url" does not match the configured verificationOrigin`);
480
+ }
481
+ } else if (checkUnconfigured) {
482
+ checkUnconfigured(url);
483
+ } else {
484
+ throw new Error(`${prefix} open() requires "verificationOrigin"`);
485
+ }
486
+ if (url.username || url.password) {
487
+ throw new Error(`${prefix} "url" must not embed credentials`);
488
+ }
489
+ if (!HOSTED_PATH_RE.test(url.pathname)) {
490
+ throw new Error(
491
+ `${prefix} "url" does not look like a hosted verification URL (/v/{token})`
492
+ );
493
+ }
494
+ return { url, hostedOrigin: url.origin };
495
+ }
496
+
497
+ // sdk/src/white-label.ts
498
+ var ERROR_PREFIX = "Verification SDK:";
499
+ var DEFAULT_TITLE = "Identity verification";
500
+ var PROTOCOL = "idv-v1";
501
+ var NAMES = {
502
+ protocol: PROTOCOL,
503
+ hello: "idv:hello",
504
+ ready: "idv:ready",
505
+ complete: "idv:complete",
506
+ error: "idv:error",
507
+ close: "idv:close",
508
+ errorPrefix: ERROR_PREFIX,
509
+ overlay: {
510
+ marker: "data-idv-sdk",
511
+ animation: "idv-sdk-spin",
512
+ title: DEFAULT_TITLE
513
+ },
514
+ params: [["embed_protocol", PROTOCOL]]
515
+ };
516
+ function parseVerificationUrl(raw, verificationOrigin) {
517
+ if (typeof verificationOrigin !== "string" || verificationOrigin === "") {
518
+ throw new Error(
519
+ `${ERROR_PREFIX} open() requires "verificationOrigin", the exact origin of your verification host (for example https://verify.example.com)`
520
+ );
521
+ }
522
+ let configuredOrigin;
523
+ try {
524
+ configuredOrigin = trustedOrigin(verificationOrigin);
525
+ } catch (e) {
526
+ throw new Error(
527
+ `${ERROR_PREFIX} "verificationOrigin" must be an exact HTTPS origin such as https://verify.example.com (HTTP loopback is allowed for development)`
528
+ );
529
+ }
530
+ return checkHostedUrl(raw, ERROR_PREFIX, configuredOrigin);
531
+ }
532
+ function open(options) {
533
+ const title = options && typeof options.title === "string" && options.title.trim() !== "" ? options.title : DEFAULT_TITLE;
534
+ return openOverlay(
535
+ options,
536
+ __spreadProps(__spreadValues({}, NAMES), { overlay: __spreadProps(__spreadValues({}, NAMES.overlay), { title }) }),
537
+ parseVerificationUrl
538
+ );
539
+ }
540
+ var verification = { open };
541
+ var white_label_default = verification;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * White-label entry: the same open() as the default entry, for a
3
+ * verification page served on the integrator's own hostname. It has no
4
+ * built-in hosts (verificationOrigin is required and the URL must sit on
5
+ * exactly that origin) and uses neutral names everywhere the host page can
6
+ * see them: the iframe title, the overlay's DOM markers and spinner, thrown
7
+ * error messages, and the idv-v1 postMessage protocol.
8
+ *
9
+ * idv-v1 COMPATIBILITY CONTRACT: the same message shapes as the default
10
+ * protocol, under different names, frozen on the same terms. Parent -> child:
11
+ * { protocol: "idv-v1", type: "idv:hello" }. Child -> parent: idv:ready,
12
+ * idv:complete { verificationId }, idv:error { code, message }, idv:close.
13
+ * The iframe URL also carries embed_protocol=idv-v1 so the hosted page names
14
+ * even a message it sends before any hello arrives. The hosted-page
15
+ * counterpart is app/utils/embedMessaging.ts; keep the two in sync.
16
+ *
17
+ * Keep this module and everything it imports free of the default entry's
18
+ * names: sdk/build.mjs fails the build if its output contains them.
19
+ */
20
+ import type { ThemeColorKey, ThemeColors, VerificationTheme } from "./theme";
21
+ export type { ThemeColorKey, ThemeColors, VerificationTheme };
22
+ export interface VerificationOptions {
23
+ /**
24
+ * Hosted verification URL minted by your backend. Its origin must equal
25
+ * verificationOrigin exactly.
26
+ */
27
+ url: string;
28
+ /**
29
+ * Required. Exact HTTPS origin of your verification host, for example
30
+ * https://verify.example.com (HTTP loopback is allowed for development).
31
+ * Take it from your integration configuration, never from the URL or any
32
+ * other browser input. Only this origin is framed and trusted.
33
+ */
34
+ verificationOrigin: string;
35
+ /**
36
+ * Terminal state reached (pass OR final fail; deliberately not
37
+ * distinguished here). Carries only the verification id: confirm the
38
+ * verdict server-side using the ID saved at creation.
39
+ */
40
+ onComplete: (e: {
41
+ verificationId: string;
42
+ }) => void;
43
+ /** Flow-level errors: link_expired, link_invalid, origin_not_allowed,
44
+ * storage_unavailable, link_unavailable, link_already_used,
45
+ * consent_required, capture_failed, internal, load_timeout. link_already_used means the
46
+ * capture was already started from this link in another browser or device,
47
+ * or the check had already finished when this browser came back to it (a
48
+ * reload or a new tab in the same browser otherwise continues it): start a
49
+ * new session for the user. Using up the tries ends with onComplete, as
50
+ * after a final failed take. capture_failed means the capture could not be
51
+ * completed on this device (its last try never reached the server): there is
52
+ * no verdict, the check stays open and expires unfinished; start a new
53
+ * session for the user.
54
+ * A load_timeout closes the overlay after this callback and
55
+ * invokes onClose, never onComplete. */
56
+ onError?: (e: {
57
+ code: string;
58
+ message: string;
59
+ }) => void;
60
+ /** Flow closed before completion, including an initial load timeout. */
61
+ onClose?: () => void;
62
+ /** Reserved; passed through to the hosted page as a query param. */
63
+ locale?: string;
64
+ /** Accessible title of the iframe. Defaults to "Identity verification". */
65
+ title?: string;
66
+ /**
67
+ * Optional colors for the hosted verification screens, the camera screen
68
+ * and the close button included. Only the light flashes during the check
69
+ * keep their own colors.
70
+ */
71
+ theme?: VerificationTheme;
72
+ }
73
+ export interface VerificationHandle {
74
+ close(): void;
75
+ }
76
+ export declare function open(options: VerificationOptions): VerificationHandle;
77
+ declare const verification: {
78
+ open: typeof open;
79
+ };
80
+ export default verification;