@incodetech/core 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/{BrowserStorageProvider-CuOW1Er2.esm.js → BrowserStorageProvider-BpJM-gIl.esm.js} +8 -1
- package/dist/{IpifyProvider-D7jx52AL.esm.js → IpifyProvider-D4LWD15E.esm.js} +28 -0
- package/dist/{MotionSensorProvider-4v7xkqAp.esm.js → MotionSensorProvider-Bx7Mpzt0.esm.js} +63 -13
- package/dist/{OpenViduRecordingProvider-CMu6XVdc.esm.js → OpenViduRecordingProvider-O4GjBseO.esm.js} +1 -1
- package/dist/StateMachine-BC_nGvrc.d.ts +2 -0
- package/dist/StreamCanvasCapture-ImiDQdVA.esm.js +118 -0
- package/dist/StreamCanvasCapture-yyl20qd9.d.ts +152 -0
- package/dist/{BaseWasmProvider-C_DLEI40.esm.js → WasmUtilProvider-CiEN7Gjn.esm.js} +183 -11
- package/dist/{addressSearch-BpTbTWCa.esm.js → addressSearch-DvmWXKZg.esm.js} +63 -57
- package/dist/{ae-signature-DDDZmWXj.esm.js → ae-signature-BFZta3TZ.esm.js} +1 -1
- package/dist/ae-signature.d.ts +3 -3
- package/dist/ae-signature.esm.js +6 -5
- package/dist/antifraud.d.ts +5 -46
- package/dist/antifraud.esm.js +6 -43
- package/dist/antifraudManager-CkV4u-LE.esm.js +55 -0
- package/dist/antifraudManager-CznnhyvD.d.ts +63 -0
- package/dist/{antifraudStateMachine-O0TMf6yc.esm.js → antifraudStateMachine-Ccrb-Jxc.esm.js} +2 -2
- package/dist/apiError-B-j-gyDx.esm.js +51 -0
- package/dist/authentication.d.ts +13 -11
- package/dist/authentication.esm.js +26 -22
- package/dist/{authenticationManager-C83GNIhl.d.ts → authenticationManager-CIVY80H9.d.ts} +4 -4
- package/dist/{authenticationManager-5M-fKzXx.esm.js → authenticationManager-ZNotsWnC.esm.js} +6 -6
- package/dist/{authenticationStateMachine-BMZqatiF.esm.js → authenticationStateMachine-DksVbF_H.esm.js} +21 -9
- package/dist/{backCameraStream-DMdMeGk2.esm.js → backCameraStream-D7Wo4Nbx.esm.js} +95 -7
- package/dist/{session-CrkWAs-q.esm.js → browserSimulation-B1dWiXp7.esm.js} +61 -476
- package/dist/camera.d.ts +4 -3
- package/dist/camera.esm.js +4 -3
- package/dist/canvas-SKcRBxsk.esm.js +230 -0
- package/dist/consent.d.ts +4 -398
- package/dist/consent.esm.js +6 -77
- package/dist/consentManager-BLd51QiW.d.ts +419 -0
- package/dist/consentManager-BYo9Nu1r.esm.js +90 -0
- package/dist/{consentStateMachine-CCT-B60O.esm.js → consentStateMachine-BG3yL8aC.esm.js} +9 -6
- package/dist/cpf-ocr.d.ts +4 -199
- package/dist/cpf-ocr.esm.js +8 -177
- package/dist/cpfOcrManager-BnieFXuG.d.ts +216 -0
- package/dist/cpfOcrManager-sSKegxox.esm.js +190 -0
- package/dist/cross-document-data-match.d.ts +1 -1
- package/dist/cross-document-data-match.esm.js +4 -4
- package/dist/curp-validation.d.ts +8 -158
- package/dist/curp-validation.esm.js +6 -108
- package/dist/curpValidationManager-CFem6zP9.esm.js +122 -0
- package/dist/curpValidationManager-RttixpIc.d.ts +184 -0
- package/dist/{curpValidationStateMachine-CitWLr2c.esm.js → curpValidationStateMachine-B7V_qp66.esm.js} +20 -13
- package/dist/custom-fields.d.ts +2 -2
- package/dist/custom-fields.esm.js +4 -4
- package/dist/custom-watchlist.d.ts +1 -1
- package/dist/custom-watchlist.esm.js +4 -41
- package/dist/customWatchlistStateMachine-HmFybXLX.esm.js +50 -0
- package/dist/{deepsightLoader-Cm4JIT_z.esm.js → deepsightLoader-65k1Appi.esm.js} +19 -10
- package/dist/{deepsightService-CEVxzehb.d.ts → deepsightService-B7ShOkWL.d.ts} +8 -160
- package/dist/deepsightService-CrHmvx8X.esm.js +276 -0
- package/dist/device.esm.js +4 -3
- package/dist/document-capture.d.ts +995 -86
- package/dist/document-capture.esm.js +34 -8
- package/dist/document-upload.d.ts +47 -47
- package/dist/document-upload.esm.js +7 -7
- package/dist/{documentCaptureStateMachine-BqzTDy9k.esm.js → documentCaptureStateMachine-WYV1r9le.esm.js} +90 -6
- package/dist/dynamic-forms.d.ts +20 -5
- package/dist/dynamic-forms.esm.js +150 -61
- package/dist/ekyb.d.ts +32 -13
- package/dist/ekyb.esm.js +25 -15
- package/dist/{ekybStateMachine-CyMx_kg-.esm.js → ekybStateMachine-aYixw2sL.esm.js} +319 -207
- package/dist/ekyc.d.ts +10 -78
- package/dist/ekyc.esm.js +17 -12
- package/dist/{ekycStateMachine-oeO0Iekd.esm.js → ekycStateMachine-CXbpaJJn.esm.js} +201 -113
- package/dist/electronic-signature.d.ts +3 -3
- package/dist/electronic-signature.esm.js +5 -4
- package/dist/{electronicSignatureManager-D9OHzTpG.esm.js → electronicSignatureManager-BaECdJ1u.esm.js} +91 -23
- package/dist/email.d.ts +4 -3
- package/dist/email.esm.js +6 -5
- package/dist/{emailManager-wAV0LE-H.esm.js → emailManager--D5G3ChB.esm.js} +30 -7
- package/dist/{emailManager-DIfnS5g1.d.ts → emailManager-lAzDoQOs.d.ts} +66 -8
- package/dist/{emailStateMachine-DOf4j58N.esm.js → emailStateMachine-CxTOMAjC.esm.js} +46 -11
- package/dist/{endpoints-CnN3SyDa.esm.js → endpoints-BeTK0Mlt.esm.js} +6 -3
- package/dist/{events-D6-e4vok.esm.js → events-Dvvriq9l.esm.js} +3 -1
- package/dist/events.d.ts +2 -0
- package/dist/events.esm.js +1 -1
- package/dist/extensibility.d.ts +32 -16
- package/dist/extensibility.esm.js +55 -33
- package/dist/face-match.d.ts +32 -2
- package/dist/face-match.esm.js +5 -5
- package/dist/{faceCaptureManagerFactory-yqtpxjnN.d.ts → faceCaptureManagerFactory-C_hRHx8a.d.ts} +35 -11
- package/dist/{faceCaptureManagerFactory-Dh2PdGlF.esm.js → faceCaptureManagerFactory-kqbUqtrr.esm.js} +21 -5
- package/dist/{faceCaptureSetup-B3faSpYA.esm.js → faceCaptureSetup-CtvHWd3x.esm.js} +68 -183
- package/dist/{faceMatchStateMachine-DNFrxTFS.esm.js → faceMatchStateMachine-DdGXUBnx.esm.js} +60 -6
- package/dist/field-comparison.d.ts +4 -0
- package/dist/field-comparison.esm.js +7 -0
- package/dist/fieldComparisonManager-Bu5TaSr3.d.ts +76 -0
- package/dist/fieldComparisonManager-COGI2ARD.esm.js +162 -0
- package/dist/fiscal-qr.d.ts +59 -0
- package/dist/fiscal-qr.esm.js +323 -0
- package/dist/flow-events.d.ts +6 -5
- package/dist/flow.d.ts +23 -15
- package/dist/flow.esm.js +63 -17
- package/dist/flowCompletionService-BdR2cGgB.d.ts +19 -0
- package/dist/flowCompletionService-DdGojV9K.esm.js +20 -0
- package/dist/{flowServices-PiNsxLfK.esm.js → flowServices-BTuHLHVr.esm.js} +10 -5
- package/dist/geolocation.d.ts +4 -4
- package/dist/geolocation.esm.js +6 -6
- package/dist/{geolocationStateMachine-asasuHY2.esm.js → geolocationStateMachine-Dvh7X0wF.esm.js} +5 -5
- package/dist/getBrowser-C8DP7oTB.esm.js +8 -0
- package/dist/{getBrowser-BSXUTWXw.esm.js → getDeviceClass-C0olyNFS.esm.js} +1 -8
- package/dist/{getDeviceClass-BSntT9_j.esm.js → getDeviceClass-C8Do2qYu.esm.js} +1 -1
- package/dist/government-validation.d.ts +28 -8
- package/dist/government-validation.esm.js +19 -8
- package/dist/{governmentValidationStateMachine-BDDYrJTo.esm.js → governmentValidationStateMachine-DcJ-BfsC.esm.js} +35 -77
- package/dist/home.d.ts +15 -14
- package/dist/home.esm.js +2 -2
- package/dist/http-Cai3IoLS.esm.js +0 -0
- package/dist/http.esm.js +1 -0
- package/dist/id-ocr.d.ts +54 -54
- package/dist/id-ocr.esm.js +5 -5
- package/dist/id-verification.d.ts +27 -27
- package/dist/id-verification.esm.js +4 -4
- package/dist/id.d.ts +12 -10
- package/dist/id.esm.js +36 -26
- package/dist/{idCaptureManager-Fyd0eam-.d.ts → idCaptureManager-D-QYESvF.d.ts} +28 -14
- package/dist/{idCaptureManager-D0ktk7Hh.esm.js → idCaptureManager-DGVv5l1_.esm.js} +22 -7
- package/dist/{idCaptureStateMachine-dwlBUjbC.esm.js → idCaptureStateMachine-DHi7HydI.esm.js} +172 -123
- package/dist/{idOcrStateMachine-YbjjC_Gg.esm.js → idOcrStateMachine-CDQ5d_VM.esm.js} +4 -4
- package/dist/{idVerificationStateMachine-xbw9HP1Z.esm.js → idVerificationStateMachine-kRxwImzO.esm.js} +2 -2
- package/dist/identity-reuse.d.ts +4 -530
- package/dist/identity-reuse.esm.js +8 -274
- package/dist/identityReuseManager-C6n_97dw.esm.js +95 -0
- package/dist/identityReuseManager-DwLtVzUn.d.ts +428 -0
- package/dist/identityReuseStateMachine-BfE5YiEr.esm.js +148 -0
- package/dist/{index-BcRG8rtJ.d.ts → index-B5hPA0Bg.d.ts} +2 -2
- package/dist/{index-ChHWNH48.d.ts → index-B9NysVDB.d.ts} +469 -195
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +10 -8
- package/dist/{invokeOnCaptureCallback-rc6kBHo5.esm.js → invokeOnCaptureCallback-ygByVdnn.esm.js} +1 -1
- package/dist/{lib-BB0B_qQX.esm.js → lib-BY67lgbq.esm.js} +1 -1
- package/dist/mandatory-consent.d.ts +8 -412
- package/dist/mandatory-consent.esm.js +6 -76
- package/dist/mandatoryConsentManager-H6D18cZB.esm.js +89 -0
- package/dist/mandatoryConsentManager-KfIlURRY.d.ts +429 -0
- package/dist/{mandatoryConsentStateMachine-Cnco1jvn.esm.js → mandatoryConsentStateMachine-DtQNW1ji.esm.js} +6 -6
- package/dist/openviduLazy-B8L--0oe.esm.js +3 -0
- package/dist/{openviduLazy-Cok70ZSg.esm.js → openviduLazy-Dh14JNJc.esm.js} +2 -2
- package/dist/otp-CGMdUzBC.esm.js +33 -0
- package/dist/otp-DF5A0sFx.d.ts +8 -0
- package/dist/permissionGuards-C1ispV96.esm.js +23 -0
- package/dist/permissionServices-CG3bMSfG.esm.js +130 -0
- package/dist/phone.d.ts +4 -3
- package/dist/phone.esm.js +6 -5
- package/dist/{phoneManager-DAJbGhlY.esm.js → phoneManager-BmF-0Ez4.esm.js} +30 -7
- package/dist/{phoneManager-B6M30hKE.d.ts → phoneManager-fPmIBYQK.d.ts} +65 -7
- package/dist/{phoneStateMachine-CuPARRaT.esm.js → phoneStateMachine-BiV0yoEx.esm.js} +46 -11
- package/dist/{qe-signature-DFo_Cc-I.esm.js → qe-signature-CUYPcHVo.esm.js} +1 -1
- package/dist/qe-signature.d.ts +3 -3
- package/dist/qe-signature.esm.js +6 -5
- package/dist/{recordingService-Ig2UgbLv.esm.js → recordingService-Bn9EdCmz.esm.js} +197 -179
- package/dist/redirect-to-mobile.d.ts +6 -104
- package/dist/redirect-to-mobile.esm.js +6 -99
- package/dist/redirectToMobileManager-BNe3IzC_.d.ts +178 -0
- package/dist/redirectToMobileManager-Dy3t7o0C.esm.js +159 -0
- package/dist/{redirectToMobileStateMachine-BOEqe46A.esm.js → redirectToMobileStateMachine-DyAdRxfP.esm.js} +28 -19
- package/dist/{runChildModule-CqqwqAkW.esm.js → runChildModule-CuoHZ1cx.esm.js} +35 -3
- package/dist/selfie.d.ts +13 -11
- package/dist/selfie.esm.js +27 -23
- package/dist/{selfieManager-Duisl7qN.esm.js → selfieManager-BjCoKRy0.esm.js} +6 -6
- package/dist/{selfieManager-D0lSgd-J.d.ts → selfieManager-dUbKRzOh.d.ts} +4 -4
- package/dist/{selfieStateMachine-D76whWEf.esm.js → selfieStateMachine-b4F2q9zw.esm.js} +5 -3
- package/dist/session-DoVb-OcB.esm.js +152 -0
- package/dist/session.d.ts +37 -5
- package/dist/session.esm.js +12 -7
- package/dist/sessionInitializer-B8H5MsXM.esm.js +366 -0
- package/dist/{setup-C5AITV8m.d.ts → setup-BbkprdVv.d.ts} +57 -6
- package/dist/{setup-DPPAxmXf.esm.js → setup-BqEfrdja.esm.js} +162 -24
- package/dist/signature.d.ts +2 -2
- package/dist/signature.esm.js +4 -4
- package/dist/{signatureStateMachine-B5-QVUve.esm.js → signatureStateMachine-C5qqYLRz.esm.js} +3 -3
- package/dist/stats-BMNUG1AU.esm.js +41 -0
- package/dist/stats.d.ts +13 -2
- package/dist/stats.esm.js +3 -2
- package/dist/trust-graph.d.ts +33 -4
- package/dist/trust-graph.esm.js +21 -15
- package/dist/{types-CFV9G_7j.d.ts → types-Bj9hdFjU.d.ts} +1 -1
- package/dist/{types-BP1m8VRw.d.ts → types-DOUhndhT.d.ts} +14 -2
- package/dist/types-DsnEVMhr.esm.js +34 -0
- package/dist/types-DvGZI7BF.d.ts +131 -0
- package/dist/{types-B06Ypu2F.d.ts → types-NuT8ftBV.d.ts} +1 -1
- package/dist/types-ya0LN_MX.d.ts +5 -0
- package/dist/{warmup-CEcppFiS.d.ts → warmup-Dg8Lh-50.d.ts} +8 -0
- package/dist/wasm.d.ts +6 -4
- package/dist/wasm.esm.js +11 -9
- package/dist/watchlist-for-business.d.ts +1 -1
- package/dist/watchlist-for-business.esm.js +5 -73
- package/dist/watchlist.d.ts +1 -1
- package/dist/watchlist.esm.js +4 -41
- package/dist/watchlistForBusinessStateMachine-DMl8j2Ov.esm.js +74 -0
- package/dist/watchlistStateMachine-DmQlqI6L.esm.js +50 -0
- package/dist/workflow.d.ts +150 -97
- package/dist/workflow.esm.js +156 -80
- package/package.json +19 -1
- package/dist/StateMachine-BCQrZJhf.d.ts +0 -2
- package/dist/WasmUtilProvider-j98OJf-S.esm.js +0 -114
- package/dist/browserSimulation-gxD8cSpM.esm.js +0 -20
- package/dist/deepsightService-O74l4Y__.esm.js +0 -489
- package/dist/displayErrors-DqJ_IbsG.d.ts +0 -39
- package/dist/flowCompletionService-DhkT4SRY.d.ts +0 -10
- package/dist/flowCompletionService-P54yzGvA.esm.js +0 -13
- package/dist/openviduLazy-Cm0XFh_v.esm.js +0 -3
- package/dist/permissionServices-D_i6nzEw.esm.js +0 -50
- package/dist/stats-CIfiPzb1.esm.js +0 -16
- package/dist/types-CAD4va6a.d.ts +0 -5
- package/dist/watchlistServices-DMbUhkBX.esm.js +0 -12
- /package/dist/{Actor-CI32dTbG.d.ts → Actor-Y0_Fj-KL.d.ts} +0 -0
- /package/dist/{ITimerCapability-C67ZRskg.esm.js → ITimerCapability-CB0I1Uf2.esm.js} +0 -0
- /package/dist/{Manager-C8PrhBOx.d.ts → Manager-BHn8wH8K.d.ts} +0 -0
- /package/dist/{camera-PA2Ljri3.esm.js → camera-DJWm3V4g.esm.js} +0 -0
- /package/dist/{camera-DBSxa6ML.d.ts → camera-SRBpPq2X.d.ts} +0 -0
- /package/dist/{chunk-CRF6K_H_.esm.js → chunk-CMUKZ2uL.esm.js} +0 -0
- /package/dist/{cpf-PPz2Njto.esm.js → cpf-BRzggV8G.esm.js} +0 -0
- /package/dist/{dateUtils-UoN5xswP.esm.js → dateUtils-AksLQmgV.esm.js} +0 -0
- /package/dist/{platform-CfrjKhmi.esm.js → platform-SKvEfCBh.esm.js} +0 -0
- /package/dist/{xstate.esm-B70JrNqo.esm.js → xstate.esm-C9wncMQa.esm.js} +0 -0
|
@@ -1,10 +1,75 @@
|
|
|
1
1
|
import { t as api } from "./api-CESGtpbH.esm.js";
|
|
2
|
-
import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-
|
|
3
|
-
import { t as endpoints } from "./endpoints-
|
|
4
|
-
import { a as fromPromise, c as createManager, r as assign, s as createActor, t as setup } from "./xstate.esm-
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as isoDateToMs } from "./dateUtils-UoN5xswP.esm.js";
|
|
2
|
+
import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-Dvvriq9l.esm.js";
|
|
3
|
+
import { t as endpoints } from "./endpoints-BeTK0Mlt.esm.js";
|
|
4
|
+
import { a as fromPromise, c as createManager, r as assign, s as createActor, t as setup } from "./xstate.esm-C9wncMQa.esm.js";
|
|
5
|
+
import { t as isoDateToMs } from "./dateUtils-AksLQmgV.esm.js";
|
|
7
6
|
|
|
7
|
+
//#region src/modules/dynamic-forms/dynamicFormsFields.ts
|
|
8
|
+
function getEffectiveType(question) {
|
|
9
|
+
return question.inputType ?? question.overrides ?? "TEXT";
|
|
10
|
+
}
|
|
11
|
+
const FORMAT_ERROR_KEY_BY_TYPE = {
|
|
12
|
+
PHONE: "phone.invalidPhone",
|
|
13
|
+
EMAIL: "verification.errors.emailInvalid",
|
|
14
|
+
CPF: "dynamicForms.invalidCpf"
|
|
15
|
+
};
|
|
16
|
+
function buildQuestionValidation(question) {
|
|
17
|
+
const effectiveType = getEffectiveType(question);
|
|
18
|
+
const rules = [];
|
|
19
|
+
if (!question.isOptional) rules.push({ type: "required" });
|
|
20
|
+
const formatErrorKey = FORMAT_ERROR_KEY_BY_TYPE[effectiveType];
|
|
21
|
+
if (formatErrorKey) rules.push({
|
|
22
|
+
type: "formatViaAnswerValidity",
|
|
23
|
+
errorKey: formatErrorKey
|
|
24
|
+
});
|
|
25
|
+
return rules;
|
|
26
|
+
}
|
|
27
|
+
function buildScreenFields(formScreen) {
|
|
28
|
+
return formScreen.questions.map((q) => ({
|
|
29
|
+
questionId: q.questionId,
|
|
30
|
+
inputType: getEffectiveType(q),
|
|
31
|
+
isOptional: q.isOptional ?? false,
|
|
32
|
+
validation: buildQuestionValidation(q)
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/modules/dynamic-forms/dynamicFormsValidators.ts
|
|
38
|
+
const VALIDATORS = {
|
|
39
|
+
required: ({ value }) => value.trim().length === 0 ? "dynamicForms.fieldRequired" : void 0,
|
|
40
|
+
formatViaAnswerValidity: ({ questionId, answerValidity }, rule) => answerValidity[questionId] === false ? rule.errorKey : void 0
|
|
41
|
+
};
|
|
42
|
+
const normalizeValue = (value) => typeof value === "string" ? value : String(value ?? "");
|
|
43
|
+
function evaluateRules(input, rules) {
|
|
44
|
+
for (const rule of rules) {
|
|
45
|
+
const error = rule.type === "required" ? VALIDATORS.required(input) : VALIDATORS.formatViaAnswerValidity(input, rule);
|
|
46
|
+
if (error) return error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Runs full-screen validation. Returns first failing key per field; empty = pass. */
|
|
50
|
+
function validateScreenForm(answers, fields, answerValidity) {
|
|
51
|
+
return fields.reduce((errors, field) => {
|
|
52
|
+
const error = evaluateRules({
|
|
53
|
+
value: normalizeValue(answers[field.questionId]),
|
|
54
|
+
questionId: field.questionId,
|
|
55
|
+
answerValidity
|
|
56
|
+
}, field.validation);
|
|
57
|
+
if (error) errors[field.questionId] = error;
|
|
58
|
+
return errors;
|
|
59
|
+
}, {});
|
|
60
|
+
}
|
|
61
|
+
/** Runs single-field validation (blur). Unknown `questionId` → `undefined`. */
|
|
62
|
+
function validateScreenField(answers, questionId, fields, answerValidity) {
|
|
63
|
+
const field = fields.find((f) => f.questionId === questionId);
|
|
64
|
+
if (!field) return void 0;
|
|
65
|
+
return evaluateRules({
|
|
66
|
+
value: normalizeValue(answers[questionId]),
|
|
67
|
+
questionId,
|
|
68
|
+
answerValidity
|
|
69
|
+
}, field.validation);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
8
73
|
//#region src/modules/dynamic-forms/dynamicFormsServices.ts
|
|
9
74
|
async function fetchForms(flowId, signal) {
|
|
10
75
|
const url = `${endpoints.moduleConfig}?id=${encodeURIComponent(flowId)}&moduleKey=DYNAMIC_FORMS`;
|
|
@@ -23,22 +88,6 @@ async function submitFormAnswer(params, signal) {
|
|
|
23
88
|
|
|
24
89
|
//#endregion
|
|
25
90
|
//#region src/modules/dynamic-forms/dynamicFormsStateMachine.ts
|
|
26
|
-
/**
|
|
27
|
-
* Returns default answers for a screen, seeding 'NO' for every YESNO question.
|
|
28
|
-
* An untouched checkbox must submit a value — this is a domain rule, not a UI concern.
|
|
29
|
-
*/
|
|
30
|
-
function seedDefaultAnswers(formScreen) {
|
|
31
|
-
if (!formScreen) return {};
|
|
32
|
-
const defaults = {};
|
|
33
|
-
for (const q of formScreen.questions) if ((q.inputType ?? q.overrides) === "YESNO") defaults[q.questionId] = "NO";
|
|
34
|
-
return defaults;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Transforms a raw answer value before submission based on question type.
|
|
38
|
-
* - CPF: strips formatting characters (dots and dash)
|
|
39
|
-
* - DATE: converts ISO date string (YYYY-MM-DD) to Unix milliseconds string
|
|
40
|
-
* - All others: pass through as-is
|
|
41
|
-
*/
|
|
42
91
|
function transformAnswerValue(inputType, value) {
|
|
43
92
|
switch (inputType) {
|
|
44
93
|
case "CPF": return value.replace(/[-.]/g, "");
|
|
@@ -46,6 +95,18 @@ function transformAnswerValue(inputType, value) {
|
|
|
46
95
|
default: return value;
|
|
47
96
|
}
|
|
48
97
|
}
|
|
98
|
+
const removeKey = (errors, key) => {
|
|
99
|
+
if (!errors?.[key]) return errors;
|
|
100
|
+
const next = { ...errors };
|
|
101
|
+
delete next[key];
|
|
102
|
+
return Object.keys(next).length > 0 ? next : void 0;
|
|
103
|
+
};
|
|
104
|
+
const upsertKey = (errors, key, message) => {
|
|
105
|
+
const next = { ...errors ?? {} };
|
|
106
|
+
if (message) next[key] = message;
|
|
107
|
+
else delete next[key];
|
|
108
|
+
return Object.keys(next).length > 0 ? next : void 0;
|
|
109
|
+
};
|
|
49
110
|
const dynamicFormsMachine = setup({
|
|
50
111
|
types: {
|
|
51
112
|
context: {},
|
|
@@ -73,38 +134,51 @@ const dynamicFormsMachine = setup({
|
|
|
73
134
|
actions: {
|
|
74
135
|
setScreens: assign(({ event }) => {
|
|
75
136
|
const screens = event.output.screens;
|
|
137
|
+
const firstScreen = screens[0];
|
|
76
138
|
return {
|
|
77
139
|
screens,
|
|
78
|
-
answers:
|
|
140
|
+
answers: {},
|
|
141
|
+
currentScreenFields: firstScreen ? buildScreenFields(firstScreen) : []
|
|
79
142
|
};
|
|
80
143
|
}),
|
|
81
144
|
setAnswer: assign(({ context, event }) => {
|
|
82
145
|
const e = event;
|
|
83
|
-
const question = context.screens[context.currentScreenIndex]?.questions.find((q) => q.questionId === e.questionId);
|
|
84
|
-
const effectiveType = question?.inputType ?? question?.overrides;
|
|
85
|
-
const newAnswerValidity = { ...context.answerValidity };
|
|
86
|
-
if (effectiveType === "CPF") newAnswerValidity[e.questionId] = validateCPF(e.value);
|
|
87
146
|
return {
|
|
88
147
|
answers: {
|
|
89
148
|
...context.answers,
|
|
90
149
|
[e.questionId]: e.value
|
|
91
150
|
},
|
|
92
|
-
|
|
151
|
+
validationErrors: removeKey(context.validationErrors, e.questionId)
|
|
93
152
|
};
|
|
94
153
|
}),
|
|
95
154
|
setAnswerValidity: assign(({ context, event }) => {
|
|
96
155
|
const e = event;
|
|
97
|
-
return {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
156
|
+
return {
|
|
157
|
+
answerValidity: {
|
|
158
|
+
...context.answerValidity,
|
|
159
|
+
[e.questionId]: e.isValid
|
|
160
|
+
},
|
|
161
|
+
validationErrors: removeKey(context.validationErrors, e.questionId)
|
|
162
|
+
};
|
|
163
|
+
}),
|
|
164
|
+
validateFormField: assign(({ context, event }) => {
|
|
165
|
+
if (event.type !== "VALIDATE_FIELD") return {};
|
|
166
|
+
const message = validateScreenField(context.answers, event.questionId, context.currentScreenFields, context.answerValidity);
|
|
167
|
+
return { validationErrors: upsertKey(context.validationErrors, event.questionId, message) };
|
|
168
|
+
}),
|
|
169
|
+
computeValidationResult: assign(({ context }) => {
|
|
170
|
+
const errors = validateScreenForm(context.answers, context.currentScreenFields, context.answerValidity);
|
|
171
|
+
return { validationErrors: Object.keys(errors).length > 0 ? errors : void 0 };
|
|
101
172
|
}),
|
|
102
173
|
advanceScreen: assign(({ context }) => {
|
|
103
174
|
const nextIndex = context.currentScreenIndex + 1;
|
|
175
|
+
const nextScreen = context.screens[nextIndex];
|
|
104
176
|
return {
|
|
105
177
|
currentScreenIndex: nextIndex,
|
|
106
|
-
answers:
|
|
107
|
-
answerValidity: {}
|
|
178
|
+
answers: {},
|
|
179
|
+
answerValidity: {},
|
|
180
|
+
currentScreenFields: nextScreen ? buildScreenFields(nextScreen) : [],
|
|
181
|
+
validationErrors: void 0
|
|
108
182
|
};
|
|
109
183
|
}),
|
|
110
184
|
markCompleted: assign({ result: "completed" }),
|
|
@@ -113,19 +187,22 @@ const dynamicFormsMachine = setup({
|
|
|
113
187
|
guards: {
|
|
114
188
|
hasPreloadedScreens: ({ context }) => (context.config.screens?.length ?? 0) > 0,
|
|
115
189
|
hasFlowId: ({ context }) => !!context.config.flowId,
|
|
116
|
-
isLastScreen: ({ context }) => context.currentScreenIndex >= context.screens.length - 1
|
|
190
|
+
isLastScreen: ({ context }) => context.currentScreenIndex >= context.screens.length - 1,
|
|
191
|
+
isScreenValid: ({ context }) => Object.keys(context.validationErrors ?? {}).length === 0
|
|
117
192
|
}
|
|
118
193
|
}).createMachine({
|
|
119
194
|
id: "dynamicForms",
|
|
120
195
|
initial: "idle",
|
|
121
196
|
context: ({ input }) => {
|
|
122
197
|
const screens = input.config.screens ?? [];
|
|
198
|
+
const firstScreen = screens[0];
|
|
123
199
|
return {
|
|
124
200
|
config: input.config,
|
|
125
201
|
screens,
|
|
126
202
|
currentScreenIndex: 0,
|
|
127
|
-
answers:
|
|
203
|
+
answers: {},
|
|
128
204
|
answerValidity: {},
|
|
205
|
+
currentScreenFields: firstScreen ? buildScreenFields(firstScreen) : [],
|
|
129
206
|
result: null
|
|
130
207
|
};
|
|
131
208
|
},
|
|
@@ -154,11 +231,24 @@ const dynamicFormsMachine = setup({
|
|
|
154
231
|
actions: "markSkipped"
|
|
155
232
|
}
|
|
156
233
|
} },
|
|
157
|
-
inputting: {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
234
|
+
inputting: {
|
|
235
|
+
initial: "editing",
|
|
236
|
+
states: {
|
|
237
|
+
editing: { on: {
|
|
238
|
+
ANSWER_CHANGED: { actions: "setAnswer" },
|
|
239
|
+
ANSWER_VALIDITY_CHANGED: { actions: "setAnswerValidity" },
|
|
240
|
+
VALIDATE_FIELD: { actions: "validateFormField" },
|
|
241
|
+
SUBMIT: { target: "validatingSubmit" }
|
|
242
|
+
} },
|
|
243
|
+
validatingSubmit: {
|
|
244
|
+
entry: "computeValidationResult",
|
|
245
|
+
always: [{
|
|
246
|
+
guard: "isScreenValid",
|
|
247
|
+
target: "#dynamicForms.submitting"
|
|
248
|
+
}, { target: "editing" }]
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
},
|
|
162
252
|
submitting: { invoke: {
|
|
163
253
|
id: "submitScreenAnswers",
|
|
164
254
|
src: "submitScreenAnswers",
|
|
@@ -229,32 +319,24 @@ function createDynamicFormsActor(options) {
|
|
|
229
319
|
* manager.stop();
|
|
230
320
|
* ```
|
|
231
321
|
*/
|
|
232
|
-
function
|
|
233
|
-
return
|
|
234
|
-
if (q.isOptional) return true;
|
|
235
|
-
if ((q.inputType ?? q.overrides) === "YESNO") return true;
|
|
236
|
-
const value = answers[q.questionId];
|
|
237
|
-
return value !== void 0 && value !== "";
|
|
238
|
-
});
|
|
322
|
+
function hasNoErrors(errors) {
|
|
323
|
+
return Object.keys(errors ?? {}).length === 0;
|
|
239
324
|
}
|
|
240
325
|
function mapState(snapshot) {
|
|
241
326
|
const typedSnapshot = snapshot;
|
|
242
327
|
const { context } = typedSnapshot;
|
|
243
328
|
if (typedSnapshot.matches("idle")) return { status: "idle" };
|
|
244
329
|
if (typedSnapshot.matches("loadingScreens")) return { status: "loadingScreens" };
|
|
245
|
-
if (typedSnapshot.matches("inputting")) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
canSubmit: currentScreen ? isScreenComplete(context.answers, currentScreen) && allFormatsValid : false
|
|
256
|
-
};
|
|
257
|
-
}
|
|
330
|
+
if (typedSnapshot.matches("inputting")) return {
|
|
331
|
+
status: "inputting",
|
|
332
|
+
currentScreen: context.screens[context.currentScreenIndex],
|
|
333
|
+
screenIndex: context.currentScreenIndex,
|
|
334
|
+
totalScreens: context.screens.length,
|
|
335
|
+
answers: context.answers,
|
|
336
|
+
answerValidity: context.answerValidity,
|
|
337
|
+
validationErrors: context.validationErrors,
|
|
338
|
+
canSubmit: hasNoErrors(context.validationErrors)
|
|
339
|
+
};
|
|
258
340
|
if (typedSnapshot.matches("submitting")) {
|
|
259
341
|
const currentScreen = context.screens[context.currentScreenIndex];
|
|
260
342
|
return {
|
|
@@ -263,7 +345,8 @@ function mapState(snapshot) {
|
|
|
263
345
|
totalScreens: context.screens.length,
|
|
264
346
|
currentScreen,
|
|
265
347
|
answers: context.answers,
|
|
266
|
-
answerValidity: context.answerValidity
|
|
348
|
+
answerValidity: context.answerValidity,
|
|
349
|
+
validationErrors: context.validationErrors
|
|
267
350
|
};
|
|
268
351
|
}
|
|
269
352
|
if (typedSnapshot.matches("success")) return { status: "success" };
|
|
@@ -294,6 +377,12 @@ function createApi({ actor }) {
|
|
|
294
377
|
isValid
|
|
295
378
|
});
|
|
296
379
|
},
|
|
380
|
+
validateField(questionId) {
|
|
381
|
+
actor.send({
|
|
382
|
+
type: "VALIDATE_FIELD",
|
|
383
|
+
questionId
|
|
384
|
+
});
|
|
385
|
+
},
|
|
297
386
|
submit() {
|
|
298
387
|
actor.send({ type: "SUBMIT" });
|
|
299
388
|
},
|
package/dist/ekyb.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as Manager } from "./Manager-
|
|
2
|
-
import "./Actor-
|
|
3
|
-
import "./camera-
|
|
4
|
-
import "./types-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { t as Manager } from "./Manager-BHn8wH8K.js";
|
|
2
|
+
import "./Actor-Y0_Fj-KL.js";
|
|
3
|
+
import "./camera-SRBpPq2X.js";
|
|
4
|
+
import "./types-Bj9hdFjU.js";
|
|
5
|
+
import { c as AddressSuggestion, l as FieldDef } from "./types-DvGZI7BF.js";
|
|
6
|
+
import { i as FlowModuleConfig } from "./types-DOUhndhT.js";
|
|
7
7
|
|
|
8
8
|
//#region src/modules/ekyb/types.d.ts
|
|
9
9
|
type UboEntry = {
|
|
@@ -30,8 +30,24 @@ type EkybConfig = {
|
|
|
30
30
|
checkTaxId?: boolean;
|
|
31
31
|
checkUniqueBeneficialOwner?: boolean;
|
|
32
32
|
};
|
|
33
|
+
type EkybValidationRule = {
|
|
34
|
+
type: 'required';
|
|
35
|
+
} | {
|
|
36
|
+
type: 'streetLevelRequired';
|
|
37
|
+
} | {
|
|
38
|
+
type: 'cnpj';
|
|
39
|
+
} | {
|
|
40
|
+
type: 'postalCodeFormat';
|
|
41
|
+
country: string;
|
|
42
|
+
};
|
|
43
|
+
type EkybValidationError = {
|
|
44
|
+
key: string;
|
|
45
|
+
params?: Record<string, string | number>;
|
|
46
|
+
};
|
|
47
|
+
type EkybValidationErrors = Partial<Record<string, EkybValidationError>>;
|
|
33
48
|
type EkybFieldDef = FieldDef & {
|
|
34
49
|
optionalForCountries?: string[];
|
|
50
|
+
validation?: EkybValidationRule[];
|
|
35
51
|
};
|
|
36
52
|
type EkybCountry = 'BR' | 'US' | 'GB' | 'ES' | 'IT' | 'FR' | 'DE' | 'IL' | 'MX' | 'CN' | 'NG' | 'CM' | 'KE';
|
|
37
53
|
//#endregion
|
|
@@ -53,12 +69,16 @@ type EkybFormState = {
|
|
|
53
69
|
availableCountries: readonly string[];
|
|
54
70
|
fields: EkybFieldDef[];
|
|
55
71
|
values: EkybFormValues;
|
|
56
|
-
|
|
72
|
+
validationErrors?: EkybValidationErrors;
|
|
73
|
+
/**
|
|
74
|
+
* True when no validation errors are currently displayed.
|
|
75
|
+
* Optimistic semantic: starts true on initial empty form.
|
|
76
|
+
* Derived as `Object.keys(validationErrors ?? {}).length === 0`.
|
|
77
|
+
*/
|
|
57
78
|
isValid: boolean;
|
|
58
79
|
ubos: UboEntry[];
|
|
59
80
|
canAddUbo: boolean;
|
|
60
81
|
addressSuggestions: AddressSuggestion[];
|
|
61
|
-
submitAttempted: boolean;
|
|
62
82
|
};
|
|
63
83
|
type EkybSubmittingState = {
|
|
64
84
|
status: 'submitting';
|
|
@@ -88,8 +108,10 @@ declare function createEkybManager(options: CreateEkybActorOptions): Manager<Eky
|
|
|
88
108
|
load(): void;
|
|
89
109
|
/** Sets the country and resets/revalidates fields */
|
|
90
110
|
setCountry(country: string): void;
|
|
91
|
-
/** Sets a form field value and
|
|
111
|
+
/** Sets a form field value and clears its current validation error */
|
|
92
112
|
setField(name: string, value: string): void;
|
|
113
|
+
/** Runs single-field validation (call on blur) */
|
|
114
|
+
validateField(name: string): void;
|
|
93
115
|
/** Adds a new UBO entry (max 8) */
|
|
94
116
|
addUbo(): void;
|
|
95
117
|
/** Removes a UBO entry by index */
|
|
@@ -109,9 +131,6 @@ declare function createEkybManager(options: CreateEkybActorOptions): Manager<Eky
|
|
|
109
131
|
};
|
|
110
132
|
type EkybManager = ReturnType<typeof createEkybManager>;
|
|
111
133
|
//#endregion
|
|
112
|
-
//#region src/modules/ekyb/ekybActions.d.ts
|
|
113
|
-
declare function computeDisplayErrors(errors: Record<string, string>, touched: Record<string, boolean>, submitAttempted: boolean, country: string, fields?: EkybFieldDef[]): DisplayErrorsResult;
|
|
114
|
-
//#endregion
|
|
115
134
|
//#region src/modules/ekyb/ekybServices.d.ts
|
|
116
135
|
type EkybFlowConfig = FlowModuleConfig['EKYB'];
|
|
117
136
|
//#endregion
|
|
@@ -145,4 +164,4 @@ declare const DEV_ONLY_COUNTRIES: readonly EkybCountry[];
|
|
|
145
164
|
declare const ALL_COUNTRIES: readonly EkybCountry[];
|
|
146
165
|
declare function isSupportedCountry(code: string): code is EkybCountry;
|
|
147
166
|
//#endregion
|
|
148
|
-
export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, type AddressSuggestion as EkybAddressSuggestion, type EkybConfig, type EkybCountry, type EkybFieldDef, type EkybFlowConfig, type EkybManager, type EkybState,
|
|
167
|
+
export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, type AddressSuggestion as EkybAddressSuggestion, type EkybConfig, type EkybCountry, type EkybFieldDef, type EkybFlowConfig, type EkybManager, type EkybState, type EkybValidationError, type EkybValidationErrors, SUPPORTED_COUNTRIES, type UboEntry, createEkybManager, ekybMachine, isSupportedCountry, toEkybConfig };
|
package/dist/ekyb.esm.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import "./BrowserTimerProvider-DhNc_x02.esm.js";
|
|
2
2
|
import "./api-CESGtpbH.esm.js";
|
|
3
|
-
import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-
|
|
4
|
-
import "./endpoints-
|
|
5
|
-
import "./
|
|
6
|
-
import "./IpifyProvider-
|
|
7
|
-
import "./browserSimulation-
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import "./
|
|
11
|
-
import "./
|
|
3
|
+
import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-Dvvriq9l.esm.js";
|
|
4
|
+
import "./endpoints-BeTK0Mlt.esm.js";
|
|
5
|
+
import "./stats-BMNUG1AU.esm.js";
|
|
6
|
+
import "./IpifyProvider-D4LWD15E.esm.js";
|
|
7
|
+
import "./browserSimulation-B1dWiXp7.esm.js";
|
|
8
|
+
import "./sessionInitializer-B8H5MsXM.esm.js";
|
|
9
|
+
import "./platform-SKvEfCBh.esm.js";
|
|
10
|
+
import "./getBrowser-C8DP7oTB.esm.js";
|
|
11
|
+
import { c as createManager, s as createActor } from "./xstate.esm-C9wncMQa.esm.js";
|
|
12
|
+
import "./apiError-B-j-gyDx.esm.js";
|
|
13
|
+
import { a as SUPPORTED_COUNTRIES, i as DEV_ONLY_COUNTRIES, n as toEkybConfig, o as isSupportedCountry, r as ALL_COUNTRIES, t as ekybMachine } from "./ekybStateMachine-aYixw2sL.esm.js";
|
|
14
|
+
import "./addressSearch-DvmWXKZg.esm.js";
|
|
15
|
+
import "./session-DoVb-OcB.esm.js";
|
|
16
|
+
import "./flowServices-BTuHLHVr.esm.js";
|
|
12
17
|
|
|
13
18
|
//#region src/modules/ekyb/ekybActor.ts
|
|
14
19
|
/**
|
|
@@ -31,12 +36,11 @@ function mapState(snapshot) {
|
|
|
31
36
|
availableCountries: context.availableCountries,
|
|
32
37
|
fields: context.fields,
|
|
33
38
|
values: context.values,
|
|
34
|
-
|
|
35
|
-
isValid: context.
|
|
39
|
+
validationErrors: context.validationErrors,
|
|
40
|
+
isValid: Object.keys(context.validationErrors ?? {}).length === 0,
|
|
36
41
|
ubos: context.ubos,
|
|
37
42
|
canAddUbo: context.canAddUbo,
|
|
38
|
-
addressSuggestions: context.addressSuggestions
|
|
39
|
-
submitAttempted: context.submitAttempted
|
|
43
|
+
addressSuggestions: context.addressSuggestions
|
|
40
44
|
};
|
|
41
45
|
if (typedSnapshot.matches("submitting")) return { status: "submitting" };
|
|
42
46
|
if (typedSnapshot.matches("success")) return { status: "success" };
|
|
@@ -61,11 +65,17 @@ function createApi({ actor, trackElementClicked }) {
|
|
|
61
65
|
},
|
|
62
66
|
setField(name, value) {
|
|
63
67
|
actor.send({
|
|
64
|
-
type: "
|
|
68
|
+
type: "DATA_CHANGED",
|
|
65
69
|
name,
|
|
66
70
|
value
|
|
67
71
|
});
|
|
68
72
|
},
|
|
73
|
+
validateField(name) {
|
|
74
|
+
actor.send({
|
|
75
|
+
type: "VALIDATE_FIELD",
|
|
76
|
+
name
|
|
77
|
+
});
|
|
78
|
+
},
|
|
69
79
|
addUbo() {
|
|
70
80
|
trackElementClicked?.("addUbo");
|
|
71
81
|
actor.send({ type: "ADD_UBO" });
|
|
@@ -124,4 +134,4 @@ function createEkybManager(options) {
|
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
//#endregion
|
|
127
|
-
export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, SUPPORTED_COUNTRIES,
|
|
137
|
+
export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, SUPPORTED_COUNTRIES, createEkybManager, ekybMachine, isSupportedCountry, toEkybConfig };
|