@incodetech/web 2.0.1 → 2.1.0-rc.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.
- package/dist/ae-signature/ae-signature.es.js +15 -13
- package/dist/ae-signature/styles.css +3 -17
- package/dist/ae-signature/styles2.css +15 -5
- package/dist/aligndevicelottie-DY_bX_p8.js +12769 -0
- package/dist/antifraud/antifraud.es.js +23 -16
- package/dist/authentication/authentication.es.js +42 -27
- package/dist/autoFocusTitle-BzkUiELM.js +29 -0
- package/dist/{back-horizontal-hint-B8Brxh3U.js → back-horizontal-hint-D_8LptLm.js} +26 -26
- package/dist/back-tutorial-vb1MxlrT.js +14597 -0
- package/dist/{back-vertical-hint-BBo36dxn.js → back-vertical-hint-C1evxxq2.js} +27 -27
- package/dist/backdevicelottie-HypPqBz7.js +16690 -0
- package/dist/base.css +1258 -104
- package/dist/blurdevicelottie-CBXtBFiJ.js +15951 -0
- package/dist/bottomSheet-F1GJfQx_.js +39 -0
- package/dist/browser-ponyfill-CLLvZCVg.js +441 -0
- package/dist/button-CM_hgyIP.js +35 -0
- package/dist/checkbox-BoeLHKgp.js +96 -0
- package/dist/consent/consent.es.js +89 -73
- package/dist/consent/styles.css +35 -22
- package/dist/countrySelector-mSWyHSy4.js +60 -0
- package/dist/cpf-ocr/cpf-ocr.es.js +2 -0
- package/dist/cpfOcr-MtpRztkG.js +92 -0
- package/dist/cpfOcr-jJkYCfsX.js +2 -0
- package/dist/cross-document-data-match/cross-document-data-match.es.js +20 -16
- package/dist/curp-validation/curp-validation.es.js +247 -203
- package/dist/customFields-DXXt9HGM.js +140 -0
- package/dist/customWatchlist-DsW04UF6.js +36 -0
- package/dist/dateInputComposed-C_mh4XBg.js +69 -0
- package/dist/dateInputComposed-Cy6a7ymh.js +1 -0
- package/dist/defineProperty-mefzVtTv.js +39 -0
- package/dist/document-capture/document-capture.es.js +2 -0
- package/dist/document-capture/styles.css +2 -5
- package/dist/documentCapture-8ypBJehw.js +2 -0
- package/dist/documentCapture-BDV_921m.js +880 -0
- package/dist/dropdownComposed-CEWBSdGl.js +1 -0
- package/dist/dropdownComposed-_fgAlo_C.js +380 -0
- package/dist/dynamic-forms/styles.css +25 -13
- package/dist/dynamicForms-DyfnsS7E.js +352 -0
- package/dist/ekyb/ekyb.es.js +2 -2
- package/dist/ekyb/styles.css +2 -0
- package/dist/ekybModule-CIPGmCvD.js +279 -0
- package/dist/ekybModule-DFoYpheB.js +2 -0
- package/dist/ekyc/ekyc.es.js +2 -2
- package/dist/ekyc/styles.css +9 -7
- package/dist/ekycModule-BGzwgjl1.js +2 -0
- package/dist/ekycModule-BuTaC5ct.js +257 -0
- package/dist/electronic-signature/electronic-signature.es.js +2 -2
- package/dist/electronic-signature-B-Q7M0wK.js +430 -0
- package/dist/email/email.es.js +199 -66
- package/dist/emailInput-KZmhjOdZ.js +39 -0
- package/dist/errorIcon-DJRZpd8j.js +26 -0
- package/dist/expiredId-Q1t6aVpk.js +85 -0
- package/dist/extensibility-Cs3KQQdC.js +3070 -0
- package/dist/extensibility.es.js +26 -25
- package/dist/face-match/face-match.es.js +2 -2
- package/dist/face-match/styles.css +0 -4
- package/dist/faceMatch--RDHJe4t.js +343 -0
- package/dist/faceMatch-yEKPYaym.js +2 -0
- package/dist/field-comparison/field-comparison.es.js +2 -0
- package/dist/field-comparison/styles.css +16 -0
- package/dist/fieldComparison-CAF86bTC.js +88 -0
- package/dist/fieldComparison-D0an7T_g.js +2 -0
- package/dist/fiscal-qr/fiscal-qr.es.js +224 -0
- package/dist/fiscal-qr/styles.css +71 -0
- package/dist/{flip-animation-CgwRsEmK.js → flip-animation-BGRvygw9.js} +4221 -4221
- package/dist/flow/flow.es.js +619 -484
- package/dist/flow/styles.css +378 -418
- package/dist/{front-horizontal-hint-DGGGi8e1.js → front-horizontal-hint-Uf5bHCsd.js} +70 -70
- package/dist/{front-vertical-hint-CNr5mE6Q.js → front-vertical-hint-DdWNA45v.js} +81 -81
- package/dist/frontdevicelottie-CLqitJhG.js +17314 -0
- package/dist/geolocation/geolocation.es.js +486 -395
- package/dist/glaredevicelottie-BS04U6Fc.js +14478 -0
- package/dist/governmentValidation/governmentValidation.es.js +166 -93
- package/dist/governmentValidation/styles.css +0 -17
- package/dist/homeScreen-BZnIEDrV.js +264 -0
- package/dist/hooks-Da_yP_Dr.js +149 -0
- package/dist/i18n-CoCO2ZuN.js +2971 -0
- package/dist/icons-Dbs9ZfYM.js +360 -0
- package/dist/id/id.es.js +583 -414
- package/dist/id/styles.css +59 -43
- package/dist/id-laser-h-DX8UbVNH.js +467 -0
- package/dist/id-laser-v-DhnHdjlB.js +490 -0
- package/dist/id-tutorial-lj4iKtYT.js +13165 -0
- package/dist/id-verification/id-verification.es.js +21 -17
- package/dist/idOcr-CjGbb4dB.js +123 -0
- package/dist/identity-reuse/identity-reuse.es.js +311 -182
- package/dist/identity-reuse/styles.css +134 -80
- package/dist/incode-logo-57XFniXU.js +4 -0
- package/dist/incodeComponent-wfnHlnXx.js +63 -0
- package/dist/incodeModule-BUDoTwT9.js +13 -0
- package/dist/index.es.js +16 -13
- package/dist/inputComposed-BEn7_nZd.js +1 -0
- package/dist/inputComposed-CQ4AsvZg.js +99 -0
- package/dist/loadingIcon-B0ysgiNq.js +148 -0
- package/dist/lottie_light-Dp9Bz3mf.js +9031 -0
- package/dist/mandatoryConsent-r0PQHmv-.js +107 -0
- package/dist/modal-nTSaG7nB.js +139 -0
- package/dist/modal.hooks-D2xhIuHA.js +195 -0
- package/dist/numberedStep-CEtwZqLp.js +13 -0
- package/dist/optionAccessibleLabel-CnA-mNAU.js +202 -0
- package/dist/otpInput-_JmtVwa0.js +195 -0
- package/dist/page-DxGQj7Gk.js +71 -0
- package/dist/{passport-horizontal-hint-Bgquwtac.js → passport-horizontal-hint-Bbm2mvSn.js} +55 -55
- package/dist/{passport-tutorial-DwRwtPVX.js → passport-tutorial-zT1ZoA-D.js} +7096 -7084
- package/dist/{passport-vertical-hint-BT1D5BrW.js → passport-vertical-hint-DJbCtBiM.js} +49 -49
- package/dist/pdf-BZA70WbM.js +22398 -0
- package/dist/pdfViewer-BK-yVIve.js +114 -0
- package/dist/phone/phone.es.js +214 -70
- package/dist/phoneInputComposed-DjNdsmPE.js +12142 -0
- package/dist/processing-BM-wT-1W.js +8 -0
- package/dist/qe-signature/qe-signature.es.js +15 -13
- package/dist/radioGroupComposed-BNuaopVr.js +215 -0
- package/dist/redirect-to-mobile/redirect-to-mobile.es.js +2774 -0
- package/dist/redirect-to-mobile/styles.css +19 -269
- package/dist/registerIncodeElement-77NGCDsy.js +11 -0
- package/dist/requiredLabelHint-DEadtiwx.js +17 -0
- package/dist/richText-Cf9aMOCk.js +3153 -0
- package/dist/rolldown-runtime--E5BIlTp.js +33 -0
- package/dist/selfie/selfie.es.js +54 -37
- package/dist/selfie/styles.css +0 -4
- package/dist/selfieTutorial-CtruLyO2.js +2689 -0
- package/dist/signature/signature.es.js +778 -405
- package/dist/snackbar-CxepGC3e.js +16 -0
- package/dist/spinner-B6RxGFrI.js +1 -0
- package/dist/spinner-D8a_2LvW.js +42 -0
- package/dist/statusPage-DMYPUwRZ.js +28 -0
- package/dist/successIcon-BAyDPT7I.js +30 -0
- package/dist/tabs-C8npVBbk.js +103 -0
- package/dist/themes/dark.css +5 -0
- package/dist/themes/light.css +4 -0
- package/dist/transitionSpinner-DRRz-NV8.js +26 -0
- package/dist/{tutorial-9vHAHvMK.js → tutorial-D1qaY2Tm.js} +1105 -856
- package/dist/types/ae-signature.d.ts +4 -1
- package/dist/types/antifraud.d.ts +9 -3
- package/dist/types/authentication.d.ts +4 -1
- package/dist/types/consent.d.ts +4 -1
- package/dist/types/cpf-ocr.d.ts +12 -0
- package/dist/types/cross-document-data-match.d.ts +4 -1
- package/dist/types/curp-validation.d.ts +9 -3
- package/dist/types/document-capture.d.ts +37 -0
- package/dist/types/ekyb.d.ts +4 -1
- package/dist/types/ekyc.d.ts +4 -1
- package/dist/types/electronic-signature.d.ts +4 -1
- package/dist/types/email.d.ts +4 -1
- package/dist/types/extensibility.d.ts +40 -15
- package/dist/types/face-match.d.ts +4 -1
- package/dist/types/field-comparison.d.ts +38 -0
- package/dist/types/fiscal-qr.d.ts +43 -0
- package/dist/types/flow.d.ts +5 -2
- package/dist/types/geolocation.d.ts +4 -1
- package/dist/types/governmentValidation.d.ts +4 -1
- package/dist/types/id-verification.d.ts +4 -1
- package/dist/types/id.d.ts +4 -1
- package/dist/types/identity-reuse.d.ts +4 -1
- package/dist/types/index.d.ts +20 -2
- package/dist/types/phone.d.ts +4 -1
- package/dist/types/qe-signature.d.ts +4 -1
- package/dist/types/redirect-to-mobile.d.ts +17 -0
- package/dist/types/selfie.d.ts +4 -1
- package/dist/types/signature.d.ts +4 -1
- package/dist/types/watchlist.d.ts +4 -1
- package/dist/types/workflow.d.ts +55 -11
- package/dist/typography-YLgHHuao.js +45 -0
- package/dist/uiConfig-D2_wawvr.js +25 -0
- package/dist/useModuleLoader-CeJ2jL25.js +672 -0
- package/dist/vendor-preact-DThS2ZQ_.js +955 -0
- package/dist/verificationResult-Do5SpZ6X.js +64 -0
- package/dist/verifiedByIncode-DjXOdCml.js +103 -0
- package/dist/watchlist/watchlist.es.js +31 -28
- package/dist/watchlistForBusiness-BFFXC9d-.js +80 -0
- package/dist/workflow/styles.css +449 -427
- package/dist/workflow/workflow.es.js +268 -182
- package/package.json +32 -10
- package/dist/aligndevicelottie-DoV8xKjh.js +0 -12757
- package/dist/autoFocusTitle-QexamZ4i.js +0 -16
- package/dist/back-tutorial-1NOQobGO.js +0 -14585
- package/dist/backdevicelottie-C_ceuqY7.js +0 -16678
- package/dist/blurdevicelottie-UO14Y0WC.js +0 -15939
- package/dist/bottomSheet-DE_8TFEC.js +0 -31
- package/dist/browser-ponyfill-jOkuz57z.js +0 -299
- package/dist/button-DcCUEn2n.js +0 -24
- package/dist/checkbox-Cl57ltq_.js +0 -85
- package/dist/countrySelector-CE-JgIsv.js +0 -58
- package/dist/cpfOcr-D_tbwbvh.js +0 -78
- package/dist/customFields-CW38fQUv.js +0 -127
- package/dist/customWatchlist-D9_yjEQd.js +0 -33
- package/dist/dateInputComposed-BpAGsjN6.js +0 -55
- package/dist/dateInputComposed-DU3o6PAV.js +0 -1
- package/dist/defineProperty-Dh8nSJpJ.js +0 -39
- package/dist/documentCapture-xX-JT7ZY.js +0 -763
- package/dist/dropdownComposed-DFRBG22E.js +0 -284
- package/dist/dropdownComposed-DwTzc2YU.js +0 -1
- package/dist/dynamicForms-CJP1Ia6Q.js +0 -262
- package/dist/ekybModule-BSs7mndb.js +0 -280
- package/dist/ekybModule-D9M3E2Gm.js +0 -2
- package/dist/ekycModule-CU9pt5YN.js +0 -246
- package/dist/ekycModule-CZw9cLno.js +0 -2
- package/dist/electronic-signature-COYXjGdd.js +0 -410
- package/dist/emailInput-DppGf9pv.js +0 -37
- package/dist/expiredId-BnmzE8T3.js +0 -70
- package/dist/extensibility-CzEJfRwo.js +0 -2586
- package/dist/faceMatch-B8j0g0Yo.js +0 -2
- package/dist/faceMatch-BV8UD7tj.js +0 -201
- package/dist/frontdevicelottie-Bu6f9fDE.js +0 -17302
- package/dist/glaredevicelottie-B10axYs_.js +0 -14466
- package/dist/homeScreen-DnP1jw9A.js +0 -227
- package/dist/hooks-BVnGysT7.js +0 -80
- package/dist/i18n-9s4OSqwi.js +0 -2010
- package/dist/icons-Cc7zwchP.js +0 -310
- package/dist/id-laser-h-mBAzHVOK.js +0 -467
- package/dist/id-laser-v-CrFg4bcJ.js +0 -483
- package/dist/id-tutorial-BCr42Pnn.js +0 -13153
- package/dist/idOcr-CCjfWQvH.js +0 -94
- package/dist/incode-logo-DX016usY.js +0 -4
- package/dist/incodeComponent-C1o4M0ZK.js +0 -50
- package/dist/incodeModule-BqCjVgEI.js +0 -18
- package/dist/inputComposed-APSw8C7o.js +0 -89
- package/dist/inputComposed-XYrarFxS.js +0 -1
- package/dist/loadingIcon-BN5YRQUb.js +0 -104
- package/dist/mandatoryConsent-DssKMC3v.js +0 -100
- package/dist/modal-NMxsQHAO.js +0 -135
- package/dist/modal.hooks-CAjcIFZK.js +0 -126
- package/dist/numberedStep-CT-alrK5.js +0 -11
- package/dist/optionAccessibleLabel-CzEeX3Q4.js +0 -140
- package/dist/otpInput-DqRA_egd.js +0 -145
- package/dist/page-C1yT4DLb.js +0 -69
- package/dist/pdf-BurGZ08w.js +0 -14967
- package/dist/pdfViewer-BGBNL1Ea.js +0 -63
- package/dist/phoneInputComposed-bvWhGLFZ.js +0 -11206
- package/dist/processing-G_y3o32b.js +0 -6
- package/dist/radioGroupComposed-BbmvxmD2.js +0 -177
- package/dist/redirectToMobile-C3k1gloW.js +0 -1514
- package/dist/requiredLabelHint-BLwgqozE.js +0 -13
- package/dist/richText-DbJ5sl2n.js +0 -1973
- package/dist/rolldown-runtime-CYMK-g2i.js +0 -20
- package/dist/selfieTutorial-BgrlUMXP.js +0 -2677
- package/dist/snackbar-BDp8x7Cv.js +0 -14
- package/dist/spinner-B4dcie2T.js +0 -1
- package/dist/spinner-CKnjVHxw.js +0 -39
- package/dist/statusPage-CUI7ApcU.js +0 -28
- package/dist/successIcon-DbILeIz_.js +0 -28
- package/dist/tabs-DaPyP71c.js +0 -78
- package/dist/transitionSpinner-PIEPU2Vx.js +0 -17
- package/dist/types/cpf-ocr/styles.d.ts +0 -1
- package/dist/types/document-capture/styles.d.ts +0 -1
- package/dist/types/redirect-to-mobile/styles.d.ts +0 -1
- package/dist/typography-CxjaknHN.js +0 -28
- package/dist/uiConfig-CwpQ-IM6.js +0 -20
- package/dist/useModuleLoader-BFiVA41N.js +0 -432
- package/dist/vendor-preact-D6SntenC.js +0 -958
- package/dist/verificationResult-BrVbUJ4U.js +0 -97
- package/dist/verifiedByIncode-ChZBpqNy.js +0 -101
- package/dist/watchlistForBusiness-BcSNtHCV.js +0 -77
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
import { a as createI18n, i as setI18nInstance, n as useTranslation, r as hasI18nInstance } from "./i18n-CoCO2ZuN.js";
|
|
2
|
+
import { _ as y, l as A, p as d, v as u } from "./vendor-preact-DThS2ZQ_.js";
|
|
3
|
+
import { t as setUiConfig } from "./uiConfig-D2_wawvr.js";
|
|
4
|
+
import { t as Page } from "./page-DxGQj7Gk.js";
|
|
5
|
+
import { t as Button } from "./button-CM_hgyIP.js";
|
|
6
|
+
import { t as ErrorIcon } from "./errorIcon-DJRZpd8j.js";
|
|
7
|
+
import { initializeWasmUtil, resolveWasmConfig, setWasmConfig, upgradeToWasmHttpClient, warmupWasm } from "@incodetech/core/wasm";
|
|
8
|
+
import { getDeviceClass } from "@incodetech/core/device";
|
|
9
|
+
import { createOrchestratedFlowManager, getFlow, getRequiredWasmPipelines } from "@incodetech/core/flow";
|
|
10
|
+
import { getFinishStatus, initializeSession } from "@incodetech/core/session";
|
|
11
|
+
import { api } from "@incodetech/core/http";
|
|
12
|
+
//#region src/shared/terminalErrorPage/terminalErrorPage.tsx
|
|
13
|
+
/**
|
|
14
|
+
* Terminal error screen shown by `<incode-flow>` / `<incode-workflow>` when
|
|
15
|
+
* the SDK reaches an unrecoverable error state — both during initialization
|
|
16
|
+
* (e.g. `/omni/start` or `/omni/workflow/info` returns `4028` "not activated")
|
|
17
|
+
* and during the flow/workflow lifecycle (e.g. `/omni/workflow/process/node`,
|
|
18
|
+
* `/omni/finish-status`, or a child module's terminal error).
|
|
19
|
+
*
|
|
20
|
+
* When the error carries a backend-provided `error`/`message` (surfaced via
|
|
21
|
+
* `IncodeApiError.message` from core's service wrappers), it's rendered
|
|
22
|
+
* verbatim as the subtitle. Generic transport failures fall back to a
|
|
23
|
+
* translated default.
|
|
24
|
+
*
|
|
25
|
+
* Layout: `Page` is used for the Incode logo + optional "Verified by Incode"
|
|
26
|
+
* footer only — the title/subtitle/titleTopSlot slots are deliberately *not*
|
|
27
|
+
* used so we can vertically center the status block (icon + title + message)
|
|
28
|
+
* within the available height at every viewport size. The Try again button
|
|
29
|
+
* is anchored to the bottom of the content area. The screen intentionally
|
|
30
|
+
* has no close button — the only exit is "Try again", which delegates to
|
|
31
|
+
* `onRetry`.
|
|
32
|
+
*/
|
|
33
|
+
var TerminalErrorPage = ({ message, onRetry }) => {
|
|
34
|
+
const { t } = useTranslation();
|
|
35
|
+
const titleRef = A(null);
|
|
36
|
+
y(() => {
|
|
37
|
+
titleRef.current?.focus();
|
|
38
|
+
}, []);
|
|
39
|
+
const handleRetry = () => {
|
|
40
|
+
if (onRetry) {
|
|
41
|
+
onRetry();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (typeof window !== "undefined") window.location.reload();
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ u(Page, {
|
|
47
|
+
className: "IncodeTerminalErrorPage",
|
|
48
|
+
"data-testid": "terminal-error-page",
|
|
49
|
+
children: /* @__PURE__ */ u("div", {
|
|
50
|
+
class: "IncodeTerminalErrorPageBody",
|
|
51
|
+
children: [/* @__PURE__ */ u("div", {
|
|
52
|
+
class: "IncodeTerminalErrorPageStatus",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ u(ErrorIcon, { size: 64 }),
|
|
55
|
+
/* @__PURE__ */ u("h2", {
|
|
56
|
+
ref: titleRef,
|
|
57
|
+
class: "IncodeTerminalErrorPageTitle",
|
|
58
|
+
tabIndex: -1,
|
|
59
|
+
children: t("common.somethingWentWrong")
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ u("p", {
|
|
62
|
+
class: "IncodeTerminalErrorPageMessage",
|
|
63
|
+
children: message ?? t("common.unexpectedError")
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
}), /* @__PURE__ */ u("div", {
|
|
67
|
+
class: "IncodeTerminalErrorPageFooter",
|
|
68
|
+
children: /* @__PURE__ */ u(Button, {
|
|
69
|
+
onClick: handleRetry,
|
|
70
|
+
children: t("common.tryAgain")
|
|
71
|
+
})
|
|
72
|
+
})]
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/styles/generatePalette.ts
|
|
78
|
+
function hexToHsl(hex) {
|
|
79
|
+
let normalizedHex = hex.replace("#", "");
|
|
80
|
+
if (normalizedHex.length === 3) normalizedHex = normalizedHex.split("").map((char) => char + char).join("");
|
|
81
|
+
const result = /^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(normalizedHex);
|
|
82
|
+
if (!result) return null;
|
|
83
|
+
const r = Number.parseInt(result[1], 16) / 255;
|
|
84
|
+
const g = Number.parseInt(result[2], 16) / 255;
|
|
85
|
+
const b = Number.parseInt(result[3], 16) / 255;
|
|
86
|
+
const max = Math.max(r, g, b);
|
|
87
|
+
const min = Math.min(r, g, b);
|
|
88
|
+
let h = 0;
|
|
89
|
+
let s = 0;
|
|
90
|
+
const l = (max + min) / 2;
|
|
91
|
+
if (max !== min) {
|
|
92
|
+
const d = max - min;
|
|
93
|
+
s = l > .5 ? d / (2 - max - min) : d / (max + min);
|
|
94
|
+
switch (max) {
|
|
95
|
+
case r:
|
|
96
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
97
|
+
break;
|
|
98
|
+
case g:
|
|
99
|
+
h = ((b - r) / d + 2) / 6;
|
|
100
|
+
break;
|
|
101
|
+
case b:
|
|
102
|
+
h = ((r - g) / d + 4) / 6;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
h: h * 360,
|
|
108
|
+
s: s * 100,
|
|
109
|
+
l: l * 100
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function hslToHex(h, s, l) {
|
|
113
|
+
const hNorm = h / 360;
|
|
114
|
+
const sNorm = s / 100;
|
|
115
|
+
const lNorm = l / 100;
|
|
116
|
+
let r;
|
|
117
|
+
let g;
|
|
118
|
+
let b;
|
|
119
|
+
if (sNorm === 0) r = g = b = lNorm;
|
|
120
|
+
else {
|
|
121
|
+
const hue2rgb = (p, q, t) => {
|
|
122
|
+
if (t < 0) t += 1;
|
|
123
|
+
if (t > 1) t -= 1;
|
|
124
|
+
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
125
|
+
if (t < 1 / 2) return q;
|
|
126
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
127
|
+
return p;
|
|
128
|
+
};
|
|
129
|
+
const q = lNorm < .5 ? lNorm * (1 + sNorm) : lNorm + sNorm - lNorm * sNorm;
|
|
130
|
+
const p = 2 * lNorm - q;
|
|
131
|
+
r = hue2rgb(p, q, hNorm + 1 / 3);
|
|
132
|
+
g = hue2rgb(p, q, hNorm);
|
|
133
|
+
b = hue2rgb(p, q, hNorm - 1 / 3);
|
|
134
|
+
}
|
|
135
|
+
const toHex = (n) => {
|
|
136
|
+
const hex = Math.round(n * 255).toString(16);
|
|
137
|
+
return hex.length === 1 ? `0${hex}` : hex;
|
|
138
|
+
};
|
|
139
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
140
|
+
}
|
|
141
|
+
function generateBrandPalette(mainColor) {
|
|
142
|
+
const hsl = hexToHsl(mainColor);
|
|
143
|
+
if (!hsl) throw new Error(`Invalid color format: ${mainColor}`);
|
|
144
|
+
return {
|
|
145
|
+
"50": hslToHex(hsl.h, hsl.s, 95),
|
|
146
|
+
"200": hslToHex(hsl.h, hsl.s, 80),
|
|
147
|
+
"300": hslToHex(hsl.h, hsl.s, 65),
|
|
148
|
+
"400": hslToHex(hsl.h, hsl.s, Math.min(100, hsl.l + 10)),
|
|
149
|
+
"500": mainColor,
|
|
150
|
+
"600": hslToHex(hsl.h, hsl.s, Math.max(0, hsl.l - 10)),
|
|
151
|
+
"900": hslToHex(hsl.h, hsl.s, 20)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/styles/applyTheme.ts
|
|
156
|
+
function applyTheme(mainColor, buttonColor) {
|
|
157
|
+
if (typeof document === "undefined") return;
|
|
158
|
+
const palette = generateBrandPalette(mainColor);
|
|
159
|
+
let styleElement = document.getElementById("incode-theme");
|
|
160
|
+
if (!styleElement) {
|
|
161
|
+
styleElement = document.createElement("style");
|
|
162
|
+
styleElement.id = "incode-theme";
|
|
163
|
+
document.head.appendChild(styleElement);
|
|
164
|
+
}
|
|
165
|
+
const buttonTextColor = buttonColor || "#ffffff";
|
|
166
|
+
const css = `
|
|
167
|
+
:root,
|
|
168
|
+
:host {
|
|
169
|
+
--primitive-color-brand-50: ${palette["50"]};
|
|
170
|
+
--primitive-color-brand-200: ${palette["200"]};
|
|
171
|
+
--primitive-color-brand-300: ${palette["300"]};
|
|
172
|
+
--primitive-color-brand-400: ${palette["400"]};
|
|
173
|
+
--primitive-color-brand-500: ${palette["500"]};
|
|
174
|
+
--primitive-color-brand-600: ${palette["600"]};
|
|
175
|
+
--primitive-color-brand-900: ${palette["900"]};
|
|
176
|
+
--button-primary-text-default: ${buttonTextColor};
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
styleElement.textContent = css;
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/styles/fetchTheme.ts
|
|
183
|
+
async function fetchAssets() {
|
|
184
|
+
return (await api.get("/omni/asset/fetch-all")).data;
|
|
185
|
+
}
|
|
186
|
+
var dataUrlCache = /* @__PURE__ */ new Map();
|
|
187
|
+
async function urlToDataUrl(url) {
|
|
188
|
+
if (url.startsWith("data:")) return url;
|
|
189
|
+
const cached = dataUrlCache.get(url);
|
|
190
|
+
if (cached) return cached;
|
|
191
|
+
const blob = await (await fetch(url)).blob();
|
|
192
|
+
const dataUrl = await new Promise((resolve, reject) => {
|
|
193
|
+
const reader = new FileReader();
|
|
194
|
+
reader.onloadend = () => resolve(reader.result);
|
|
195
|
+
reader.onerror = reject;
|
|
196
|
+
reader.readAsDataURL(blob);
|
|
197
|
+
});
|
|
198
|
+
dataUrlCache.set(url, dataUrl);
|
|
199
|
+
return dataUrl;
|
|
200
|
+
}
|
|
201
|
+
async function fetchTheme$1() {
|
|
202
|
+
const assets = await fetchAssets();
|
|
203
|
+
if (!assets.theme) throw new Error("Theme URL not found in assets response");
|
|
204
|
+
const themeUrl = assets.theme;
|
|
205
|
+
const isAbsoluteUrl = themeUrl.startsWith("http://") || themeUrl.startsWith("https://");
|
|
206
|
+
let theme;
|
|
207
|
+
if (isAbsoluteUrl) {
|
|
208
|
+
const themeResponse = await fetch(themeUrl);
|
|
209
|
+
if (!themeResponse.ok) throw new Error(`Failed to fetch theme: ${themeResponse.statusText}`);
|
|
210
|
+
theme = await themeResponse.json();
|
|
211
|
+
} else theme = (await api.get(themeUrl)).data;
|
|
212
|
+
const logoUrl = assets["logo.png"] || assets["logo.svg"] || assets["logo.jpg"] || assets["logo.jpeg"] || assets["logo.webp"] || theme.logo;
|
|
213
|
+
let cachedLogoUrl = logoUrl;
|
|
214
|
+
if (logoUrl) cachedLogoUrl = await urlToDataUrl(logoUrl);
|
|
215
|
+
return {
|
|
216
|
+
...theme,
|
|
217
|
+
logo: cachedLogoUrl
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
async function fetchAndApplyTheme() {
|
|
221
|
+
const theme = await fetchTheme$1();
|
|
222
|
+
if (theme.main) applyTheme(theme.main, theme.buttonColor);
|
|
223
|
+
return theme;
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/modules/flow/flowInit.ts
|
|
227
|
+
var lazyIdModule = () => import("./id/id.es.js").then((m) => m.Id);
|
|
228
|
+
var loadLazyHomeScreen = () => import("./homeScreen-BZnIEDrV.js").then((m) => m.HomeScreen);
|
|
229
|
+
var homeScreenPreloadPromise;
|
|
230
|
+
/**
|
|
231
|
+
* Headless flow keys: backend-only steps with no UI. `<incode-flow>` renders
|
|
232
|
+
* an empty shell while the core machine for the step runs and resolves —
|
|
233
|
+
* see `flow.tsx`. Each key still resolves to its own core machine inside
|
|
234
|
+
* `getLazyCoreMachineLoader` (e.g. `IP_ADDRESS` → `noOpFlowModuleMachine`,
|
|
235
|
+
* `TRUST_GRAPH` → `trustGraphMachine`).
|
|
236
|
+
*/
|
|
237
|
+
var HEADLESS_FLOW_MODULE_KEYS = new Set(["IP_ADDRESS", "TRUST_GRAPH"]);
|
|
238
|
+
function getLazyCoreMachineLoader(moduleKey) {
|
|
239
|
+
if (moduleKey === "IP_ADDRESS") return () => import("@incodetech/core/flow").then((m) => m.noOpFlowModuleMachine);
|
|
240
|
+
if (moduleKey === "TRUST_GRAPH") return () => import("@incodetech/core/trust-graph").then((m) => m.trustGraphMachine);
|
|
241
|
+
if (moduleKey === "REDIRECT_TO_MOBILE") return () => import("@incodetech/core/redirect-to-mobile").then((m) => m.redirectToMobileMachine);
|
|
242
|
+
if (moduleKey === "PHONE") return () => import("@incodetech/core/phone").then((m) => m.phoneMachine);
|
|
243
|
+
if (moduleKey === "EMAIL") return () => import("@incodetech/core/email").then((m) => m.emailMachine);
|
|
244
|
+
if (moduleKey === "SELFIE") return () => import("@incodetech/core/selfie").then((m) => m.selfieMachine);
|
|
245
|
+
if (moduleKey === "AUTHENTICATION") return () => import("@incodetech/core/authentication").then((m) => m.authenticationMachine);
|
|
246
|
+
if (moduleKey === "ID" || moduleKey === "TUTORIAL_ID" || moduleKey === "SECOND_ID") return () => import("@incodetech/core/id").then((m) => m.idCaptureMachine);
|
|
247
|
+
if (moduleKey === "ID_OCR") return () => import("@incodetech/core/id-ocr").then((m) => m.idOcrStateMachine);
|
|
248
|
+
if (moduleKey === "CPF_OCR") return () => import("@incodetech/core/cpf-ocr").then((m) => m.cpfOcrMachine);
|
|
249
|
+
if (moduleKey === "FACE_MATCH") return () => import("@incodetech/core/face-match").then((m) => m.faceMatchMachine);
|
|
250
|
+
if (moduleKey === "CURP_VALIDATION") return () => import("@incodetech/core/curp-validation").then((m) => m.curpValidationMachine);
|
|
251
|
+
if (moduleKey === "GOVT_VALIDATION_PROVISIONING" || moduleKey === "INE_VALIDATION") return () => import("@incodetech/core/government-validation").then((m) => m.governmentValidationMachine);
|
|
252
|
+
if (moduleKey === "GEOLOCATION") return () => import("@incodetech/core/geolocation").then((m) => m.geolocationMachine);
|
|
253
|
+
if (moduleKey === "EXTERNAL_VERIFICATION") return () => import("@incodetech/core/ekyc").then((m) => m.ekycMachine);
|
|
254
|
+
if (moduleKey === "EKYB") return () => import("@incodetech/core/ekyb").then((m) => m.ekybMachine);
|
|
255
|
+
if (moduleKey === "DOCUMENT_CAPTURE" || moduleKey === "ADDRESS") return () => import("@incodetech/core/document-capture").then((m) => m.documentCaptureMachine);
|
|
256
|
+
if (moduleKey === "COMBINED_CONSENT") return () => import("@incodetech/core/consent").then((m) => m.consentMachine);
|
|
257
|
+
if (moduleKey === "MANDATORY_CONSENT" || moduleKey === "ML_CONSENT") return () => import("@incodetech/core/mandatory-consent").then((m) => m.mandatoryConsentMachine);
|
|
258
|
+
if (moduleKey === "SIGNATURE") return () => import("@incodetech/core/signature").then((m) => m.signatureMachine);
|
|
259
|
+
if (moduleKey === "ANTIFRAUD") return () => import("@incodetech/core/antifraud").then((m) => m.antifraudMachine);
|
|
260
|
+
if (moduleKey === "CUSTOM_FIELDS") return () => import("@incodetech/core/custom-fields").then((m) => m.customFieldsMachine);
|
|
261
|
+
if (moduleKey === "WATCHLIST") return () => import("@incodetech/core/watchlist").then((m) => m.watchlistMachine);
|
|
262
|
+
if (moduleKey === "WATCHLIST_BUSINESS") return () => import("@incodetech/core/watchlist-for-business").then((m) => m.watchlistForBusinessMachine);
|
|
263
|
+
if (moduleKey === "INCODE_WATCHLIST") return () => import("@incodetech/core/custom-watchlist").then((m) => m.customWatchlistMachine);
|
|
264
|
+
if (moduleKey === "AE_SIGNATURE") return () => import("@incodetech/core/ae-signature").then((m) => m.aeSignatureMachine);
|
|
265
|
+
if (moduleKey === "QE_SIGNATURE") return () => import("@incodetech/core/qe-signature").then((m) => m.qeSignatureMachine);
|
|
266
|
+
if (moduleKey === "CROSS_DOCUMENT_DATA_MATCH") return () => import("@incodetech/core/cross-document-data-match").then((m) => m.crossDocumentDataMatchMachine);
|
|
267
|
+
if (moduleKey === "DYNAMIC_FORMS") return () => import("@incodetech/core/dynamic-forms").then((m) => m.dynamicFormsMachine);
|
|
268
|
+
if (moduleKey === "FIELD_COMPARISON") return () => import("@incodetech/core/field-comparison").then((m) => m.fieldComparisonMachine);
|
|
269
|
+
if (moduleKey === "FISCAL_QR") return () => import("@incodetech/core/fiscal-qr").then((m) => m.fiscalQrMachine);
|
|
270
|
+
}
|
|
271
|
+
function buildLazyCoreRegistryForFlow(flowModules) {
|
|
272
|
+
const registry = {};
|
|
273
|
+
for (const flowModule of flowModules) {
|
|
274
|
+
const moduleKey = flowModule.key;
|
|
275
|
+
if (registry[moduleKey]) continue;
|
|
276
|
+
const loader = getLazyCoreMachineLoader(moduleKey);
|
|
277
|
+
if (loader) registry[moduleKey] = loader;
|
|
278
|
+
}
|
|
279
|
+
return registry;
|
|
280
|
+
}
|
|
281
|
+
var LAZY_UI_MODULES = {
|
|
282
|
+
REDIRECT_TO_MOBILE: () => import("./redirect-to-mobile/redirect-to-mobile.es.js").then((m) => m.RedirectToMobile),
|
|
283
|
+
PHONE: () => import("./phone/phone.es.js").then((m) => m.Phone),
|
|
284
|
+
EMAIL: () => import("./email/email.es.js").then((m) => m.Email),
|
|
285
|
+
SELFIE: () => import("./selfie/selfie.es.js").then((m) => m.Selfie),
|
|
286
|
+
AUTHENTICATION: () => import("./authentication/authentication.es.js").then((m) => m.Authentication),
|
|
287
|
+
ID: lazyIdModule,
|
|
288
|
+
ID_CAPTURE: lazyIdModule,
|
|
289
|
+
TUTORIAL_ID: lazyIdModule,
|
|
290
|
+
SECOND_ID: lazyIdModule,
|
|
291
|
+
FACE_MATCH: () => import("./faceMatch-yEKPYaym.js").then((m) => m.FaceMatch),
|
|
292
|
+
CURP_VALIDATION: () => import("./curp-validation/curp-validation.es.js").then((m) => m.CurpValidation),
|
|
293
|
+
GOVT_VALIDATION_PROVISIONING: () => import("./governmentValidation/governmentValidation.es.js").then((m) => m.GovernmentValidation),
|
|
294
|
+
INE_VALIDATION: () => import("./governmentValidation/governmentValidation.es.js").then((m) => m.GovernmentValidation),
|
|
295
|
+
GEOLOCATION: () => import("./geolocation/geolocation.es.js").then((m) => m.Geolocation),
|
|
296
|
+
EXTERNAL_VERIFICATION: () => import("./ekycModule-BGzwgjl1.js").then((m) => m.EkycModule),
|
|
297
|
+
EKYB: () => import("./ekybModule-DFoYpheB.js").then((m) => m.EkybModule),
|
|
298
|
+
DOCUMENT_CAPTURE: () => import("./documentCapture-8ypBJehw.js").then((m) => m.DocumentCapture),
|
|
299
|
+
ADDRESS: () => import("./documentCapture-8ypBJehw.js").then((m) => m.DocumentCapture),
|
|
300
|
+
COMBINED_CONSENT: () => import("./consent/consent.es.js").then((m) => m.Consent),
|
|
301
|
+
MANDATORY_CONSENT: () => import("./mandatoryConsent-r0PQHmv-.js").then((m) => m.MandatoryConsent),
|
|
302
|
+
ML_CONSENT: () => import("./mandatoryConsent-r0PQHmv-.js").then((m) => m.MandatoryConsent),
|
|
303
|
+
SIGNATURE: () => import("./signature/signature.es.js").then((m) => m.Signature),
|
|
304
|
+
ID_OCR: () => import("./idOcr-CjGbb4dB.js").then((m) => m.IdOcr),
|
|
305
|
+
CPF_OCR: () => import("./cpfOcr-jJkYCfsX.js").then((m) => m.CpfOcr),
|
|
306
|
+
ANTIFRAUD: () => import("./antifraud/antifraud.es.js").then((m) => m.Antifraud),
|
|
307
|
+
CUSTOM_FIELDS: () => import("./customFields-DXXt9HGM.js").then((m) => m.CustomFields),
|
|
308
|
+
WATCHLIST: () => import("./watchlist/watchlist.es.js").then((m) => m.Watchlist),
|
|
309
|
+
WATCHLIST_BUSINESS: () => import("./watchlistForBusiness-BFFXC9d-.js").then((m) => m.WatchlistForBusiness),
|
|
310
|
+
INCODE_WATCHLIST: () => import("./customWatchlist-DsW04UF6.js").then((m) => m.CustomWatchlist),
|
|
311
|
+
AE_SIGNATURE: () => import("./ae-signature/ae-signature.es.js").then((m) => m.AeSignature),
|
|
312
|
+
QE_SIGNATURE: () => import("./qe-signature/qe-signature.es.js").then((m) => m.QeSignature),
|
|
313
|
+
CROSS_DOCUMENT_DATA_MATCH: () => import("./cross-document-data-match/cross-document-data-match.es.js").then((m) => m.CrossDocumentDataMatch),
|
|
314
|
+
DYNAMIC_FORMS: () => import("./dynamicForms-DyfnsS7E.js").then((m) => m.DynamicForms),
|
|
315
|
+
FIELD_COMPARISON: () => import("./fieldComparison-D0an7T_g.js").then((m) => m.FieldComparison),
|
|
316
|
+
FISCAL_QR: () => import("./fiscal-qr/fiscal-qr.es.js").then((m) => m.FiscalQr)
|
|
317
|
+
};
|
|
318
|
+
function loadHomeScreen() {
|
|
319
|
+
return loadLazyHomeScreen();
|
|
320
|
+
}
|
|
321
|
+
function preloadHomeScreen() {
|
|
322
|
+
if (homeScreenPreloadPromise) return;
|
|
323
|
+
homeScreenPreloadPromise = loadHomeScreen();
|
|
324
|
+
homeScreenPreloadPromise.catch(() => {
|
|
325
|
+
homeScreenPreloadPromise = void 0;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
var redirectToMobilePreloadPromise;
|
|
329
|
+
/**
|
|
330
|
+
* Eagerly prefetches the REDIRECT_TO_MOBILE UI + core chunks.
|
|
331
|
+
* Call on desktop during flow init so the QR paints instantly when the
|
|
332
|
+
* orchestrator injects REDIRECT_TO_MOBILE as the first step.
|
|
333
|
+
*/
|
|
334
|
+
function preloadRedirectToMobile() {
|
|
335
|
+
if (redirectToMobilePreloadPromise) return;
|
|
336
|
+
const uiLoader = LAZY_UI_MODULES.REDIRECT_TO_MOBILE;
|
|
337
|
+
const coreLoader = getLazyCoreMachineLoader("REDIRECT_TO_MOBILE");
|
|
338
|
+
const promises = [];
|
|
339
|
+
if (uiLoader) promises.push(uiLoader());
|
|
340
|
+
if (coreLoader) promises.push(coreLoader());
|
|
341
|
+
redirectToMobilePreloadPromise = Promise.all(promises);
|
|
342
|
+
redirectToMobilePreloadPromise.catch(() => {
|
|
343
|
+
redirectToMobilePreloadPromise = void 0;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
function createFlowManager(options = {}) {
|
|
347
|
+
const scopedLazyModules = {};
|
|
348
|
+
const isDesktop = options.isDesktop ?? getDeviceClass() === "desktop";
|
|
349
|
+
const { enableHome, ...flowFetchOptions } = options;
|
|
350
|
+
let endScreen = {
|
|
351
|
+
endScreenTitle: null,
|
|
352
|
+
endScreenText: null
|
|
353
|
+
};
|
|
354
|
+
const manager = createOrchestratedFlowManager({
|
|
355
|
+
enableHome,
|
|
356
|
+
getFlow: async (signal) => {
|
|
357
|
+
const flow = await getFlow(signal, {
|
|
358
|
+
...flowFetchOptions,
|
|
359
|
+
isDesktop
|
|
360
|
+
});
|
|
361
|
+
const scopedRegistry = buildLazyCoreRegistryForFlow(flow.flowModules ?? []);
|
|
362
|
+
for (const key of Object.keys(scopedLazyModules)) delete scopedLazyModules[key];
|
|
363
|
+
Object.assign(scopedLazyModules, scopedRegistry);
|
|
364
|
+
return flow;
|
|
365
|
+
},
|
|
366
|
+
getFinishStatus: async (flowId, signal) => {
|
|
367
|
+
return {
|
|
368
|
+
...await getFinishStatus(flowId, signal),
|
|
369
|
+
...endScreen
|
|
370
|
+
};
|
|
371
|
+
},
|
|
372
|
+
lazyModules: scopedLazyModules
|
|
373
|
+
});
|
|
374
|
+
return Object.assign(manager, { setEndScreenTexts(endScreenTitle, endScreenText) {
|
|
375
|
+
endScreen = {
|
|
376
|
+
endScreenTitle,
|
|
377
|
+
endScreenText
|
|
378
|
+
};
|
|
379
|
+
} });
|
|
380
|
+
}
|
|
381
|
+
async function setupSDK(options) {
|
|
382
|
+
await initializeSession({ token: options.token });
|
|
383
|
+
if (hasI18nInstance()) return;
|
|
384
|
+
setI18nInstance(createI18n(options.lang ? { lang: options.lang } : void 0));
|
|
385
|
+
}
|
|
386
|
+
async function initializeFlowManager(options) {
|
|
387
|
+
const { token, lang, flowManager } = options;
|
|
388
|
+
await setupSDK({
|
|
389
|
+
token,
|
|
390
|
+
lang
|
|
391
|
+
});
|
|
392
|
+
flowManager.load();
|
|
393
|
+
}
|
|
394
|
+
async function fetchTheme() {
|
|
395
|
+
try {
|
|
396
|
+
const theme = await fetchAndApplyTheme();
|
|
397
|
+
const uiConfig = {
|
|
398
|
+
logoSrc: theme.logo,
|
|
399
|
+
subtitle: theme.subtitle,
|
|
400
|
+
hideFooterBranding: theme.hideFooterBranding
|
|
401
|
+
};
|
|
402
|
+
setUiConfig(uiConfig);
|
|
403
|
+
return {
|
|
404
|
+
theme,
|
|
405
|
+
uiConfig
|
|
406
|
+
};
|
|
407
|
+
} catch {
|
|
408
|
+
return {};
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function warmupWasmIfNeeded(managerState, wasmConfig) {
|
|
412
|
+
if (managerState.currentStep === "REDIRECT_TO_MOBILE") return;
|
|
413
|
+
const requiredPipelines = getRequiredWasmPipelines(managerState.flow);
|
|
414
|
+
if (requiredPipelines.length > 0) {
|
|
415
|
+
const resolved = resolveWasmConfig({
|
|
416
|
+
...wasmConfig ?? {},
|
|
417
|
+
pipelines: requiredPipelines
|
|
418
|
+
});
|
|
419
|
+
const configToStore = {
|
|
420
|
+
...resolved,
|
|
421
|
+
pipelines: resolved.pipelines ? [...resolved.pipelines] : void 0
|
|
422
|
+
};
|
|
423
|
+
setWasmConfig(configToStore);
|
|
424
|
+
warmupWasm(resolved).then(() => initializeWasmUtil(configToStore)).then(() => upgradeToWasmHttpClient(configToStore)).catch((error) => {
|
|
425
|
+
console.error("WASM warmup failed:", error);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function preloadFirstModule(managerState) {
|
|
430
|
+
const firstStep = managerState.currentStep;
|
|
431
|
+
if (firstStep) {
|
|
432
|
+
const loader = LAZY_UI_MODULES[firstStep];
|
|
433
|
+
if (loader) loader().catch(() => {});
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/modules/flow/unsupportedModule.tsx
|
|
438
|
+
var UnsupportedModule = ({ moduleKey, onNext }) => {
|
|
439
|
+
return /* @__PURE__ */ u("section", {
|
|
440
|
+
class: "IncodeUnsupportedModule",
|
|
441
|
+
"aria-live": "polite",
|
|
442
|
+
children: /* @__PURE__ */ u("div", {
|
|
443
|
+
class: "IncodeUnsupportedModuleContent",
|
|
444
|
+
children: [
|
|
445
|
+
/* @__PURE__ */ u("h2", {
|
|
446
|
+
class: "IncodeUnsupportedModuleTitle",
|
|
447
|
+
children: "Module not available"
|
|
448
|
+
}),
|
|
449
|
+
/* @__PURE__ */ u("p", {
|
|
450
|
+
class: "IncodeUnsupportedModuleMessage",
|
|
451
|
+
children: [
|
|
452
|
+
"The \"",
|
|
453
|
+
moduleKey,
|
|
454
|
+
"\" module is not yet supported in this version."
|
|
455
|
+
]
|
|
456
|
+
}),
|
|
457
|
+
/* @__PURE__ */ u(Button, {
|
|
458
|
+
onClick: onNext,
|
|
459
|
+
class: "IncodeUnsupportedModuleButton",
|
|
460
|
+
"data-testid": "unsupported-module-next-button",
|
|
461
|
+
children: "Next"
|
|
462
|
+
})
|
|
463
|
+
]
|
|
464
|
+
})
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/modules/flow/extractIncodeStatus.ts
|
|
469
|
+
/**
|
|
470
|
+
* Extract the Incode-specific status code (e.g. `4028` for "Flow is not
|
|
471
|
+
* activated", `4081`/`4083` for QR failures) from an error caught during SDK
|
|
472
|
+
* init.
|
|
473
|
+
*
|
|
474
|
+
* Both `QrValidationError` and `IncodeApiError` (thrown from core's
|
|
475
|
+
* `validateQrUuid`/`createSession`/`getWorkflowConfig`) expose a numeric
|
|
476
|
+
* `status` field, so a duck-typed check is enough — no class-level coupling
|
|
477
|
+
* to core, which keeps this safe under stale `dist/*.d.ts` during local dev.
|
|
478
|
+
*/
|
|
479
|
+
function extractIncodeStatus(err) {
|
|
480
|
+
if (typeof err === "object" && err !== null && "status" in err && typeof err.status === "number") return err.status;
|
|
481
|
+
}
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region src/shared/selfLoading/resolveApiKey.ts
|
|
484
|
+
function toHex(buffer) {
|
|
485
|
+
return Array.from(new Uint8Array(buffer), (value) => value.toString(16).padStart(2, "0")).join("");
|
|
486
|
+
}
|
|
487
|
+
async function sha1(value) {
|
|
488
|
+
const subtle = globalThis.crypto?.subtle;
|
|
489
|
+
if (!subtle) throw new Error("SHA-1 is not available in this environment");
|
|
490
|
+
return toHex(await subtle.digest("SHA-1", new TextEncoder().encode(value)));
|
|
491
|
+
}
|
|
492
|
+
async function resolveApiKey(config) {
|
|
493
|
+
if (typeof config.apiKey === "string") return config.apiKey;
|
|
494
|
+
if (typeof config.clientId === "string") return sha1(config.clientId);
|
|
495
|
+
throw new Error("Self-loading mode requires apiKey or clientId");
|
|
496
|
+
}
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/modules/flow/headlessModule.ts
|
|
499
|
+
var HeadlessWorkflowModule = () => null;
|
|
500
|
+
var lazyHeadlessWorkflowModule = () => Promise.resolve(HeadlessWorkflowModule);
|
|
501
|
+
var HEADLESS_WORKFLOW_MODULE_KEYS = new Set(["IDENTITY_SEARCH"]);
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/modules/flow/useModuleLoader.ts
|
|
504
|
+
function getLoadErrorMessage(error, fallbackMessage) {
|
|
505
|
+
return error instanceof Error ? error.message : fallbackMessage;
|
|
506
|
+
}
|
|
507
|
+
var loadedComponents = /* @__PURE__ */ new WeakMap();
|
|
508
|
+
var inflightLoaders = /* @__PURE__ */ new WeakMap();
|
|
509
|
+
function getLoaderKey(loader) {
|
|
510
|
+
return loader;
|
|
511
|
+
}
|
|
512
|
+
function getCachedComponent(loader) {
|
|
513
|
+
if (!loader) return void 0;
|
|
514
|
+
return loadedComponents.get(getLoaderKey(loader));
|
|
515
|
+
}
|
|
516
|
+
function loadComponent(loader) {
|
|
517
|
+
const key = getLoaderKey(loader);
|
|
518
|
+
const cached = loadedComponents.get(key);
|
|
519
|
+
if (cached) return Promise.resolve(cached);
|
|
520
|
+
const inflight = inflightLoaders.get(key);
|
|
521
|
+
if (inflight) return inflight;
|
|
522
|
+
const promise = loader().then((Component) => {
|
|
523
|
+
loadedComponents.set(key, Component);
|
|
524
|
+
inflightLoaders.delete(key);
|
|
525
|
+
return Component;
|
|
526
|
+
}).catch((error) => {
|
|
527
|
+
inflightLoaders.delete(key);
|
|
528
|
+
throw error;
|
|
529
|
+
});
|
|
530
|
+
inflightLoaders.set(key, promise);
|
|
531
|
+
return promise;
|
|
532
|
+
}
|
|
533
|
+
function computeInitialState(loader) {
|
|
534
|
+
if (!loader) return { status: "idle" };
|
|
535
|
+
const cached = getCachedComponent(loader);
|
|
536
|
+
if (cached) return {
|
|
537
|
+
status: "loaded",
|
|
538
|
+
Component: cached
|
|
539
|
+
};
|
|
540
|
+
return { status: "loading" };
|
|
541
|
+
}
|
|
542
|
+
function resolveModuleLoader(moduleKey, modules, headlessModuleKeys) {
|
|
543
|
+
if (!moduleKey) return void 0;
|
|
544
|
+
return modules[moduleKey] ?? (headlessModuleKeys?.has(moduleKey) ? lazyHeadlessWorkflowModule : void 0);
|
|
545
|
+
}
|
|
546
|
+
function useLazyComponentLoader(options) {
|
|
547
|
+
const { loader, onLoading, onLoaded, onError } = options;
|
|
548
|
+
const [state, setState] = d(() => computeInitialState(loader));
|
|
549
|
+
const prevLoaderRef = A(loader);
|
|
550
|
+
const onLoadingRef = A(onLoading);
|
|
551
|
+
const onLoadedRef = A(onLoaded);
|
|
552
|
+
const onErrorRef = A(onError);
|
|
553
|
+
y(() => {
|
|
554
|
+
onLoadingRef.current = onLoading;
|
|
555
|
+
onLoadedRef.current = onLoaded;
|
|
556
|
+
onErrorRef.current = onError;
|
|
557
|
+
}, [
|
|
558
|
+
onLoading,
|
|
559
|
+
onLoaded,
|
|
560
|
+
onError
|
|
561
|
+
]);
|
|
562
|
+
if (prevLoaderRef.current !== loader) {
|
|
563
|
+
prevLoaderRef.current = loader;
|
|
564
|
+
setState(computeInitialState(loader));
|
|
565
|
+
}
|
|
566
|
+
y(() => {
|
|
567
|
+
if (!loader) return;
|
|
568
|
+
if (getCachedComponent(loader)) {
|
|
569
|
+
onLoadedRef.current?.();
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
onLoadingRef.current?.();
|
|
573
|
+
let cancelled = false;
|
|
574
|
+
loadComponent(loader).then((Component) => {
|
|
575
|
+
if (!cancelled) {
|
|
576
|
+
setState({
|
|
577
|
+
status: "loaded",
|
|
578
|
+
Component
|
|
579
|
+
});
|
|
580
|
+
onLoadedRef.current?.();
|
|
581
|
+
}
|
|
582
|
+
}).catch((error) => {
|
|
583
|
+
if (!cancelled) {
|
|
584
|
+
const errorMessage = getLoadErrorMessage(error, "Failed to load component");
|
|
585
|
+
setState({
|
|
586
|
+
status: "error",
|
|
587
|
+
error: errorMessage
|
|
588
|
+
});
|
|
589
|
+
onErrorRef.current?.(errorMessage);
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
return () => {
|
|
593
|
+
cancelled = true;
|
|
594
|
+
};
|
|
595
|
+
}, [loader]);
|
|
596
|
+
return state;
|
|
597
|
+
}
|
|
598
|
+
function useModuleLoader(options) {
|
|
599
|
+
const { moduleKey, modules, headlessModuleKeys, onModuleLoading, onModuleLoaded, onError } = options;
|
|
600
|
+
const [unsupportedModuleKey, setUnsupportedModuleKey] = d(void 0);
|
|
601
|
+
const loader = resolveModuleLoader(moduleKey, modules, headlessModuleKeys);
|
|
602
|
+
const state = useLazyComponentLoader({
|
|
603
|
+
loader,
|
|
604
|
+
onLoading: moduleKey ? () => onModuleLoading?.(moduleKey) : void 0,
|
|
605
|
+
onLoaded: moduleKey ? () => onModuleLoaded?.(moduleKey) : void 0,
|
|
606
|
+
onError: moduleKey ? (errorMessage) => onError?.(`Failed to load ${moduleKey}: ${errorMessage}`) : void 0
|
|
607
|
+
});
|
|
608
|
+
y(() => {
|
|
609
|
+
if (!moduleKey) {
|
|
610
|
+
setUnsupportedModuleKey(void 0);
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
if (!loader) setUnsupportedModuleKey(moduleKey);
|
|
614
|
+
else setUnsupportedModuleKey(void 0);
|
|
615
|
+
}, [loader, moduleKey]);
|
|
616
|
+
if (!moduleKey) return { status: "idle" };
|
|
617
|
+
if (unsupportedModuleKey) return {
|
|
618
|
+
status: "unsupported",
|
|
619
|
+
moduleKey: unsupportedModuleKey
|
|
620
|
+
};
|
|
621
|
+
if (state.status === "idle" || state.status === "loading") return {
|
|
622
|
+
status: "loading",
|
|
623
|
+
moduleKey
|
|
624
|
+
};
|
|
625
|
+
if (state.status === "error") return {
|
|
626
|
+
status: "error",
|
|
627
|
+
moduleKey,
|
|
628
|
+
error: state.error
|
|
629
|
+
};
|
|
630
|
+
return {
|
|
631
|
+
status: "loaded",
|
|
632
|
+
moduleKey,
|
|
633
|
+
Component: state.Component
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function useModulePreloader(options) {
|
|
637
|
+
const { moduleKey, modules } = options;
|
|
638
|
+
const loader = moduleKey ? modules[moduleKey] : void 0;
|
|
639
|
+
const state = useLazyComponentLoader({ loader });
|
|
640
|
+
return loader != null && state.status === "loaded";
|
|
641
|
+
}
|
|
642
|
+
function schedulePrefetch(run) {
|
|
643
|
+
if (typeof requestIdleCallback !== "undefined") requestIdleCallback(() => {
|
|
644
|
+
run();
|
|
645
|
+
});
|
|
646
|
+
else setTimeout(run, 0);
|
|
647
|
+
}
|
|
648
|
+
function usePrefetchNextModule(steps, currentStepIndex, modules, currentModuleLoaded) {
|
|
649
|
+
const prefetchedRef = A(/* @__PURE__ */ new Set());
|
|
650
|
+
y(() => {
|
|
651
|
+
if (!currentModuleLoaded) return;
|
|
652
|
+
if (currentStepIndex < steps.length - 1) {
|
|
653
|
+
const nextStep = steps[currentStepIndex + 1];
|
|
654
|
+
if (nextStep && !prefetchedRef.current.has(nextStep)) {
|
|
655
|
+
prefetchedRef.current.add(nextStep);
|
|
656
|
+
const loader = modules[nextStep];
|
|
657
|
+
if (loader) schedulePrefetch(() => {
|
|
658
|
+
loader().catch(() => {
|
|
659
|
+
prefetchedRef.current.delete(nextStep);
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}, [
|
|
665
|
+
steps,
|
|
666
|
+
currentStepIndex,
|
|
667
|
+
modules,
|
|
668
|
+
currentModuleLoaded
|
|
669
|
+
]);
|
|
670
|
+
}
|
|
671
|
+
//#endregion
|
|
672
|
+
export { warmupWasmIfNeeded as _, resolveApiKey as a, HEADLESS_FLOW_MODULE_KEYS as c, fetchTheme as d, initializeFlowManager as f, setupSDK as g, preloadRedirectToMobile as h, HEADLESS_WORKFLOW_MODULE_KEYS as i, LAZY_UI_MODULES as l, preloadHomeScreen as m, useModulePreloader as n, extractIncodeStatus as o, preloadFirstModule as p, usePrefetchNextModule as r, UnsupportedModule as s, useModuleLoader as t, createFlowManager as u, fetchAndApplyTheme as v, TerminalErrorPage as y };
|