@incodetech/core 2.4.1-agentic.5 → 2.4.1-agentic.7
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/DateFormattingProvider-DPq9zco-.esm.js +25 -0
- package/dist/{FaceDetectionProvider-ZiDiL_hY.esm.js → FaceDetectionProvider-CFYVWVLU.esm.js} +7 -7
- package/dist/addressSearch-D6cKPWmk.esm.js +72 -0
- package/dist/ae-signature.esm.js +1 -1
- package/dist/antifraud.esm.js +2 -2
- package/dist/{antifraudManager-BObuHBjn.esm.js → antifraudManager-CbIwM35x.esm.js} +2 -2
- package/dist/{antifraudStateMachine-Dfrd2-26.esm.js → antifraudStateMachine-qNNXrlsP.esm.js} +1 -1
- package/dist/{api-CpP4PS4S.esm.js → api-C_P9YXbL.esm.js} +1 -0
- package/dist/{apiError-CeyLcwt3.esm.js → apiError-B-pHP4hU.esm.js} +1 -1
- package/dist/{attemptCarry-WOkfvFMw.esm.js → attemptCarry-BaAXPR_w.esm.js} +1 -1
- package/dist/authentication.d.ts +3 -3
- package/dist/authentication.esm.js +2 -2
- package/dist/{authenticationManager-ffZXiENz.esm.js → authenticationManager-Cw5nswyP.esm.js} +4 -4
- package/dist/{authenticationManager-CWmh7aSY.d.ts → authenticationManager-DKLRA91K.d.ts} +1 -1
- package/dist/{authenticationStateMachine-ebqsPLXI.esm.js → authenticationStateMachine-Czd4u-94.esm.js} +3 -3
- package/dist/{browser-pQZA35G2-Bu4in9gN.esm.js → browser-pQZA35G2-DJEJnmCd.esm.js} +1 -1
- package/dist/certificate-issuance.esm.js +2 -2
- package/dist/{certificateIssuanceManager-IRO_1Ug6.esm.js → certificateIssuanceManager-CrF3wjCH.esm.js} +2 -2
- package/dist/{certificateIssuanceStateMachine-CjxTBZuH.esm.js → certificateIssuanceStateMachine-uSD9IkcV.esm.js} +1 -1
- package/dist/consent.d.ts +1 -1
- package/dist/consent.esm.js +2 -2
- package/dist/{consentManager-DXetSxcx.d.ts → consentManager-7aHaehwF.d.ts} +4 -4
- package/dist/{consentManager-DMlSL6Ax.esm.js → consentManager-BD7wwgat.esm.js} +2 -2
- package/dist/{consentStateMachine-DIYSMxKQ.esm.js → consentStateMachine-BAiLDE3D.esm.js} +1 -1
- package/dist/{cpf-uAZTPUBy.esm.js → cpf-BIADjddF.esm.js} +1 -25
- package/dist/cross-document-data-match.esm.js +1 -1
- package/dist/{crossDocumentDataMatchManager-BFTdiEDB.esm.js → crossDocumentDataMatchManager-CUc1uACE.esm.js} +2 -2
- package/dist/curp-validation.d.ts +1 -1
- package/dist/curp-validation.esm.js +2 -2
- package/dist/{curpValidationManager-z8428oCM.d.ts → curpValidationManager-Crz3bnCo.d.ts} +1 -1
- package/dist/{curpValidationManager-DNpC3wyf.esm.js → curpValidationManager-DBfZSQbu.esm.js} +2 -2
- package/dist/{curpValidationStateMachine-B3iVsDyt.esm.js → curpValidationStateMachine-DyAEyScb.esm.js} +2 -2
- package/dist/custom-fields.esm.js +1 -1
- package/dist/custom-watchlist.esm.js +2 -2
- package/dist/{customFieldsManager-CvI-pDT3.esm.js → customFieldsManager-BZhIPyaY.esm.js} +2 -2
- package/dist/{customWatchlistManager-BuHtUb0y.esm.js → customWatchlistManager-B4cmxi__.esm.js} +2 -2
- package/dist/{customWatchlistStateMachine-CiVD9wyF.esm.js → customWatchlistStateMachine-ZZoDGRAZ.esm.js} +1 -1
- package/dist/{deepsightLoader-CJbBiTpq.esm.js → deepsightLoader-UDNbSO_O.esm.js} +3 -3
- package/dist/{addressSearch-DzbE9Ogt.esm.js → definitionSource-1vPLtuXE.esm.js} +1 -72
- package/dist/{desktopCameraElection-BGMtYwk3.esm.js → desktopCameraElection-m2dAj6Zu.esm.js} +1 -1
- package/dist/document-capture.esm.js +2 -2
- package/dist/{documentCaptureManager-DLPqruXJ.esm.js → documentCaptureManager-v57klTso.esm.js} +2 -2
- package/dist/{documentCaptureStateMachine-DCvWQhFG.esm.js → documentCaptureStateMachine-CgCtimSa.esm.js} +2 -2
- package/dist/dynamic-forms.esm.js +2 -2
- package/dist/{dynamicFormsManager-C1pBbCWs.esm.js → dynamicFormsManager-Bx4jzvI6.esm.js} +2 -2
- package/dist/{dynamicFormsStateMachine-iVdrXC1r.esm.js → dynamicFormsStateMachine-DK-O_wyz.esm.js} +2 -2
- package/dist/ekyb.d.ts +1 -1
- package/dist/ekyb.esm.js +2 -2
- package/dist/{ekybManager-OZ0SeXvq.esm.js → ekybManager-DgBvPmSW.esm.js} +2 -2
- package/dist/{ekybStateMachine-BDh-yJkS.esm.js → ekybStateMachine-mo6zRyPH.esm.js} +6 -4
- package/dist/ekyc-prefill.d.ts +17 -0
- package/dist/ekyc-prefill.esm.js +3 -0
- package/dist/ekyc.d.ts +2 -2
- package/dist/ekyc.esm.js +3 -3
- package/dist/{ekycManager-DymCvmVB.esm.js → ekycManager-Bwv-qYAZ.esm.js} +2 -2
- package/dist/{ekycManager-DlGIn9wA.d.ts → ekycManager-CERRvIfg.d.ts} +1 -1
- package/dist/ekycPrefillManager-DHfC1T9s.d.ts +565 -0
- package/dist/ekycPrefillManager-Pgb16lcO.esm.js +102 -0
- package/dist/ekycPrefillStateMachine-j_WwaTPe.esm.js +686 -0
- package/dist/ekycRules-B7vXnbdg.esm.js +319 -0
- package/dist/{ekycStateMachine-CoFCUJ2z.esm.js → ekycStateMachine-DlN1RCob.esm.js} +418 -533
- package/dist/{ekycUtils-GRuMELYr.esm.js → ekycUtils-K6VJXnOg.esm.js} +18 -6
- package/dist/electronic-signature.esm.js +1 -1
- package/dist/{electronicSignatureManager-CHe4KM2h.esm.js → electronicSignatureManager-BG10ax7f.esm.js} +3 -3
- package/dist/email.esm.js +2 -2
- package/dist/{emailManager-CGoE3CUe.esm.js → emailManager-BSaGg1Gl.esm.js} +2 -2
- package/dist/{emailStateMachine-KgHfDNvM.esm.js → emailStateMachine-CaoPZtZN.esm.js} +2 -2
- package/dist/{events-ggpBBaZ8.esm.js → events-kU5WJU4B.esm.js} +1 -1
- package/dist/events.esm.js +1 -1
- package/dist/extensibility.d.ts +14 -13
- package/dist/extensibility.esm.js +36 -35
- package/dist/face-match.esm.js +2 -2
- package/dist/{faceCaptureManagerFactory-GmZMp6TR.esm.js → faceCaptureManagerFactory-DDnkBGNU.esm.js} +2 -2
- package/dist/{faceCaptureManagerFactory-DV2ULUYS.d.ts → faceCaptureManagerFactory-ZudYP6Qp.d.ts} +3 -3
- package/dist/{faceCaptureSetup--MEv7wIJ.esm.js → faceCaptureSetup-C0svTi1Y.esm.js} +9 -9
- package/dist/{faceMatchManager-D2xKPjjQ.esm.js → faceMatchManager-qPJsa5Ac.esm.js} +2 -2
- package/dist/{faceMatchStateMachine-CUvwiQi9.esm.js → faceMatchStateMachine-D90ZHY1r.esm.js} +2 -2
- package/dist/{feature-management-hZhfjdAu.esm.js → feature-management-jqhhP3Bu.esm.js} +1 -1
- package/dist/feature-management.esm.js +1 -1
- package/dist/field-comparison.esm.js +1 -1
- package/dist/{fieldComparisonManager-DgDbEeFZ.esm.js → fieldComparisonManager-BLLj_Ey1.esm.js} +2 -2
- package/dist/fiscal-qr.esm.js +1 -1
- package/dist/{fiscalQrManager-BZeklojR.esm.js → fiscalQrManager-Bh3rxb7Y.esm.js} +2 -2
- package/dist/flow-events.d.ts +1 -1
- package/dist/flow.d.ts +9 -8
- package/dist/flow.esm.js +46 -10
- package/dist/{flowCompletionService-E8ipjpAG.esm.js → flowCompletionService-BNoVcNAa.esm.js} +2 -2
- package/dist/{flowServices-Co77kn9L.esm.js → flowServices-Bzlb_4VT.esm.js} +8 -8
- package/dist/geolocation.esm.js +2 -2
- package/dist/{geolocationManager-C8DY8c1D.esm.js → geolocationManager-Ck2V9vfc.esm.js} +2 -2
- package/dist/{geolocationStateMachine-BluJR9Ew.esm.js → geolocationStateMachine-toB05StJ.esm.js} +3 -3
- package/dist/government-validation.esm.js +2 -2
- package/dist/{governmentValidationManager-CjChjZ3C.esm.js → governmentValidationManager-D5HkBqfr.esm.js} +2 -2
- package/dist/{governmentValidationStateMachine-AEbn3Afi.esm.js → governmentValidationStateMachine-BwMClTqC.esm.js} +1 -1
- package/dist/home.d.ts +1 -1
- package/dist/home.esm.js +1 -1
- package/dist/http.esm.js +1 -1
- package/dist/id-ocr.d.ts +2 -2
- package/dist/id-ocr.esm.js +3 -19
- package/dist/id-selfie-flow.d.ts +1 -1
- package/dist/id-selfie-flow.esm.js +6 -6
- package/dist/id-verification.esm.js +2 -2
- package/dist/id.d.ts +2 -2
- package/dist/id.esm.js +3 -3
- package/dist/{idCaptureManager-6amWi8Ko.esm.js → idCaptureManager-BXs_sb4-.esm.js} +6 -6
- package/dist/{idCaptureManager-CCA2D1Ah.d.ts → idCaptureManager-NRGuCVv2.d.ts} +2 -2
- package/dist/{idCaptureServices-Bpa4MmVC.esm.js → idCaptureServices-DEhJe_fA.esm.js} +4 -4
- package/dist/{idCaptureStateMachine-BzBA2B4_.esm.js → idCaptureStateMachine-CH3gW-gJ.esm.js} +42 -14
- package/dist/idOcrCpfUtils-Nfln1Psb.esm.js +18 -0
- package/dist/{idOcrManager-BTdHlJ9D.d.ts → idOcrManager-B5xeI2lg.d.ts} +2 -2
- package/dist/{idOcrManager-xyEZNOBa.esm.js → idOcrManager-BMK2oou0.esm.js} +2 -2
- package/dist/{idOcrStateMachine-DNKXh4Rn.esm.js → idOcrStateMachine-RjNycN07.esm.js} +8 -7
- package/dist/{idVerificationManager-DdnvYfgN.esm.js → idVerificationManager-4wY-Ee4j.esm.js} +2 -2
- package/dist/{idVerificationStateMachine-DtIBCa32.esm.js → idVerificationStateMachine-Bj00uWvh.esm.js} +1 -1
- package/dist/identity-reuse.d.ts +1 -1
- package/dist/identity-reuse.esm.js +2 -2
- package/dist/{identityReuseManager-CcpovlfD.esm.js → identityReuseManager-CCZ-ES2E.esm.js} +2 -2
- package/dist/{identityReuseManager-B1birg5X.d.ts → identityReuseManager-ooAbp6Kc.d.ts} +4 -4
- package/dist/{identityReuseStateMachine-DxZFWy47.esm.js → identityReuseStateMachine-BtpkGpYZ.esm.js} +1 -1
- package/dist/{index-DC0P2Vzw.d.ts → index-BGnYn_4J.d.ts} +1 -1
- package/dist/{index-bD4-zpjs.d.ts → index-DlVDVTcf.d.ts} +31 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/{invokeOnCaptureCallback-BJ0GVHGr.esm.js → invokeOnCaptureCallback-BkvXSZfa.esm.js} +1 -1
- package/dist/kyb-checks.esm.js +2 -2
- package/dist/{kybChecksManager-CbqLrEox.esm.js → kybChecksManager-PIRw77NR.esm.js} +1 -1
- package/dist/{kybChecksStateMachine-B_GS-KmL.esm.js → kybChecksStateMachine-Deabuca9.esm.js} +5 -4
- package/dist/mandatory-consent.d.ts +2 -2
- package/dist/mandatory-consent.esm.js +2 -2
- package/dist/{mandatoryConsentManager-B4vCYslr.esm.js → mandatoryConsentManager-BBeOo3Sz.esm.js} +2 -2
- package/dist/{mandatoryConsentManager-CEn59Ytw.d.ts → mandatoryConsentManager-Dr3pcPt_.d.ts} +5 -5
- package/dist/{mandatoryConsentStateMachine-DWslYPA3.esm.js → mandatoryConsentStateMachine-BJEyS63E.esm.js} +1 -1
- package/dist/{multipartRecordingService-BTqkHGG9.esm.js → multipartRecordingService-2iVLb-2Y.esm.js} +1 -1
- package/dist/phone.esm.js +2 -2
- package/dist/{phoneFormat-JJNaWthV.esm.js → phoneFormat-DEpESpz2.esm.js} +13 -1
- package/dist/{phoneManager-Dy5tODCU.esm.js → phoneManager-BylOWecM.esm.js} +2 -2
- package/dist/{phoneServices-DJgyOzU2.esm.js → phoneServices-Crge7uSV.esm.js} +1 -1
- package/dist/{phoneStateMachine-DnlPhnw7.esm.js → phoneStateMachine-CHnhCS-4.esm.js} +2 -2
- package/dist/{processFaceMatch-Bst83HaS.esm.js → processFaceMatch-BveUAHts.esm.js} +1 -1
- package/dist/qe-signature.esm.js +1 -1
- package/dist/{recordingService-CTko6Cjn.esm.js → recordingService-DKXaaOHO.esm.js} +2 -2
- package/dist/redirect-to-mobile.esm.js +2 -2
- package/dist/{redirectToMobileManager-CCSNyi19.esm.js → redirectToMobileManager-DUpLyXsq.esm.js} +2 -2
- package/dist/{redirectToMobileStateMachine-BKyOdAUe.esm.js → redirectToMobileStateMachine-D0DW4y-f.esm.js} +1 -1
- package/dist/{resolveForm-O7-r79VA.esm.js → resolveForm-f9PhUo9j.esm.js} +1 -209
- package/dist/{runChildModule-DHDczcGZ.esm.js → runChildModule-CMxMWHBm.esm.js} +2 -2
- package/dist/{sdkVersion-CxaRTa9r.esm.js → sdkVersion-C8FKcN44.esm.js} +1 -1
- package/dist/selfie.d.ts +3 -3
- package/dist/selfie.esm.js +9 -9
- package/dist/{selfieErrorUtils-Dk0ofKio.esm.js → selfieErrorUtils-CS1xwN-1.esm.js} +1 -1
- package/dist/{selfieManager-DmZFzs1-.d.ts → selfieManager-BPOlD-UN.d.ts} +1 -1
- package/dist/{selfieManager-EgnSX_Hu.esm.js → selfieManager-DBc_zThO.esm.js} +4 -4
- package/dist/{selfieStateMachine-B8pBvum8.esm.js → selfieStateMachine-C3mqlhwI.esm.js} +3 -3
- package/dist/{session-CaliXPVw.esm.js → session-C9v6HFIu.esm.js} +4 -4
- package/dist/session.d.ts +1 -1
- package/dist/session.esm.js +5 -5
- package/dist/{sessionInitializer-Tr_ZkaSs.esm.js → sessionInitializer-CVFa4wKw.esm.js} +7 -7
- package/dist/{setup-Bz4l-E3R.esm.js → setup-BlJx-S74.esm.js} +10 -13
- package/dist/{setup-Dyv1tJFj.d.ts → setup-prV5HQCQ.d.ts} +1 -1
- package/dist/signature.esm.js +2 -2
- package/dist/{signatureManager-CwqjcxPg.esm.js → signatureManager-QlegdTo3.esm.js} +2 -2
- package/dist/{signatureStateMachine-DBVDd1Eu.esm.js → signatureStateMachine-DFbbbFwg.esm.js} +1 -1
- package/dist/{stats-CatA2dea.esm.js → stats-Bv5PiWvo.esm.js} +1 -1
- package/dist/stats.esm.js +1 -1
- package/dist/step-up.d.ts +3 -5
- package/dist/step-up.esm.js +5 -11
- package/dist/{tri-CKUbuky5.esm.js → tri-DFho7f3x.esm.js} +3 -32
- package/dist/tri.d.ts +1 -1
- package/dist/tri.esm-DgtAka_v.esm.js +2145 -0
- package/dist/tri.esm.js +1 -1
- package/dist/{trueSightService-DDdJ8TrY.esm.js → trueSightService-B3SMJJ9O.esm.js} +3 -3
- package/dist/trust-graph.esm.js +1 -1
- package/dist/{types-Csh8vzPo.d.ts → types-0Rr7etmf.d.ts} +1 -1
- package/dist/types-B2M1IPZn.d.ts +6 -0
- package/dist/{types-BEVHQbbC.d.ts → types-BD9sV5oG.d.ts} +1 -1
- package/dist/{types-CuMJ2M7D.d.ts → types-BaDx6utW.d.ts} +4 -1
- package/dist/{types-BPm1JSu7.d.ts → types-BpJ21a4T.d.ts} +1 -1
- package/dist/{types-CJ7Yl9K-.d.ts → types-Bpo97EOh.d.ts} +4 -2
- package/dist/{types-CRaFu6wS.d.ts → types-CquDWYfv.d.ts} +6 -2
- package/dist/types-D9vIGFbl.d.ts +115 -0
- package/dist/{types-Cd0J0F9D.d.ts → types-NMBsvLIN.d.ts} +1 -1
- package/dist/usStates-CwOQ2kAx.esm.js +209 -0
- package/dist/video-selfie.d.ts +1 -1
- package/dist/video-selfie.esm.js +6 -6
- package/dist/{videoSelfieCameraWarmer-Dsk8JQNy.esm.js → videoSelfieCameraWarmer-BtlqdcFh.esm.js} +4 -4
- package/dist/{videoSelfieStepDetector-Dv3Mgws-.d.ts → videoSelfieStepDetector-B78BE_x9.d.ts} +2 -2
- package/dist/wasm.d.ts +1 -1
- package/dist/wasm.esm.js +1 -1
- package/dist/watchlist-for-business.esm.js +2 -2
- package/dist/watchlist.esm.js +2 -2
- package/dist/{watchlistForBusinessManager-DqUpAEj_.esm.js → watchlistForBusinessManager-DOYmIiaj.esm.js} +2 -2
- package/dist/{watchlistForBusinessStateMachine-DdaPl2PS.esm.js → watchlistForBusinessStateMachine-D8qIyL8w.esm.js} +1 -1
- package/dist/{watchlistManager-CdpXzT4B.esm.js → watchlistManager-BJGLRv-x.esm.js} +2 -2
- package/dist/{watchlistStateMachine-ofHW_lPk.esm.js → watchlistStateMachine-DeLfuGSl.esm.js} +1 -1
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.esm.js +42 -36
- package/package.json +6 -1
- package/dist/tri.esm-DvgaFxHR.esm.js +0 -3838
- package/dist/types-J6g6iKe_.d.ts +0 -6
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { t as getLocalIsoDate } from "./IBrowserEnvironmentCapability-D7JG7ML3.esm.js";
|
|
2
|
+
import { n as loadPhoneValidation, t as getPhoneValidation } from "./phoneValidation-OggtfjRt.esm.js";
|
|
3
|
+
import { a as isValidRut, i as isValidInDrivingLicenseNumber, n as isValidEsDni, r as isValidFiPersonalIdentityCode, t as isValidCurp } from "./nationalIds-B91f_RuB.esm.js";
|
|
4
|
+
import { a as getPostalCodeMaxLength, i as getPostalCodeErrorKey, n as FIXED_DIGIT_POSTAL_CODE_LENGTH, o as validatePostalCode, s as STREET_LEVEL_REQUIRED_ERROR } from "./definitionSource-1vPLtuXE.esm.js";
|
|
5
|
+
import { r as DYNAMIC_REQUIRED_KEY } from "./resolveForm-f9PhUo9j.esm.js";
|
|
6
|
+
import { t as validateCPF } from "./cpf-BIADjddF.esm.js";
|
|
7
|
+
import { a as hasNameCharacters, c as isWithinMaxAge, i as hasDigitCount, l as matchesCharTemplate, o as isInNumericRange, r as hasAllowedCharacters, s as isNotFuture } from "./phoneFormat-DEpESpz2.esm.js";
|
|
8
|
+
//#region src/modules/ekyc/ekycValidators.ts
|
|
9
|
+
async function loadPhoneValidator() {
|
|
10
|
+
if (!await loadPhoneValidation()) throw new Error("Failed to load the phone validation rules");
|
|
11
|
+
}
|
|
12
|
+
/** Progressively formats an SSN as XXX-XX-XXXX */
|
|
13
|
+
function formatSSN(value) {
|
|
14
|
+
const ssn = value?.replace(/\D/g, "") ?? "";
|
|
15
|
+
if (ssn.length < 4) return ssn;
|
|
16
|
+
if (ssn.length < 6) return `${ssn.slice(0, 3)}-${ssn.slice(3)}`;
|
|
17
|
+
return `${ssn.slice(0, 3)}-${ssn.slice(3, 5)}-${ssn.slice(5, 9)}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Strips characters a name can't contain, as the user types. Keeps everything
|
|
21
|
+
* `nameCharacters` allows (letters from any script with their combining marks,
|
|
22
|
+
* spaces, hyphens, and straight or typographic apostrophes), plus the commas
|
|
23
|
+
* and acute accents (´) SDKv1 kept, so it never strips a valid name.
|
|
24
|
+
*/
|
|
25
|
+
function cleanName(name) {
|
|
26
|
+
return (name ?? "").replace(/[^\p{L}\p{M}\s,'’´-]/gu, "").slice(0, 100);
|
|
27
|
+
}
|
|
28
|
+
const PO_BOX_REGEX = /POBox|P\.O\.Box|pobox|postofficebox|postbox|po\.box|p\.o\.box/i;
|
|
29
|
+
/** Returns true if the address looks like a P.O. Box */
|
|
30
|
+
function isPoBox(address) {
|
|
31
|
+
return PO_BOX_REGEX.test(address.replace(/\s/g, ""));
|
|
32
|
+
}
|
|
33
|
+
function validatePhone(phone, country) {
|
|
34
|
+
return getPhoneValidation()?.isValid(phone, country) ?? false;
|
|
35
|
+
}
|
|
36
|
+
/** The phone's national significant number, or the value as typed. */
|
|
37
|
+
function formatPhoneNational(phone, country) {
|
|
38
|
+
return getPhoneValidation()?.nationalNumber(phone, country) ?? phone;
|
|
39
|
+
}
|
|
40
|
+
const ONE_OF_REQUIRED_ERROR_KEY = "verification.errors.dobOrSsnRequired";
|
|
41
|
+
/** The error key a `oneOfRequired` group shows: its own message, or DOB-or-SSN. */
|
|
42
|
+
const oneOfRequiredErrorKey = (rule) => rule.message ?? "verification.errors.dobOrSsnRequired";
|
|
43
|
+
const PHONE_INVALID_KEY = "verification.errors.phoneInvalid";
|
|
44
|
+
const INVALID_ID_NUMBER_KEY = "verification.errors.invalidIdNumber";
|
|
45
|
+
/** The digitCount message: one length, a list of lengths, or a range. */
|
|
46
|
+
const digitCountError = (rule) => {
|
|
47
|
+
if (rule.lengths?.length === 1) return {
|
|
48
|
+
key: "verification.errors.exactDigits",
|
|
49
|
+
params: { length: rule.lengths[0] }
|
|
50
|
+
};
|
|
51
|
+
if (rule.lengths) return {
|
|
52
|
+
key: "verification.errors.digitsOneOf",
|
|
53
|
+
params: { lengths: rule.lengths }
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
key: "verification.errors.digitsBetween",
|
|
57
|
+
params: {
|
|
58
|
+
min: rule.min ?? 0,
|
|
59
|
+
max: rule.max ?? 0
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* A national ID check: blank passes, anything else must satisfy `isValid`.
|
|
65
|
+
* The error is the vocabulary's message for these rules; a definition names
|
|
66
|
+
* its own with the rule's `message`.
|
|
67
|
+
*/
|
|
68
|
+
const idNumberValidator = (isValid) => (value) => {
|
|
69
|
+
if (value.trim().length === 0) return void 0;
|
|
70
|
+
if (isValid(value)) return void 0;
|
|
71
|
+
return { key: INVALID_ID_NUMBER_KEY };
|
|
72
|
+
};
|
|
73
|
+
const normalizeFieldValue = (value) => typeof value === "string" ? value : String(value ?? "");
|
|
74
|
+
const SSN_FORMAT_REGEX = /^\d{3}-\d{2}-\d{4}$/;
|
|
75
|
+
const EMAIL_FORMAT_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
76
|
+
const buildPostalCodeParams = (country) => {
|
|
77
|
+
const fixedLen = FIXED_DIGIT_POSTAL_CODE_LENGTH[country];
|
|
78
|
+
if (fixedLen !== void 0) return { length: fixedLen };
|
|
79
|
+
let maxLen = getPostalCodeMaxLength(country);
|
|
80
|
+
if (country === "US" || country === "BR") maxLen = maxLen - 1;
|
|
81
|
+
return { maxLength: maxLen };
|
|
82
|
+
};
|
|
83
|
+
const requiredError = (field) => {
|
|
84
|
+
const fieldName = field.displayLabel ?? field.label;
|
|
85
|
+
return fieldName ? {
|
|
86
|
+
key: DYNAMIC_REQUIRED_KEY,
|
|
87
|
+
params: { fieldName }
|
|
88
|
+
} : { key: DYNAMIC_REQUIRED_KEY };
|
|
89
|
+
};
|
|
90
|
+
const isFilled = (values, name) => normalizeFieldValue(values[name]).trim().length > 0;
|
|
91
|
+
const createValidators = () => {
|
|
92
|
+
const validators = {
|
|
93
|
+
required: (value, _rule, field) => {
|
|
94
|
+
if (value.trim().length > 0) return void 0;
|
|
95
|
+
return requiredError(field);
|
|
96
|
+
},
|
|
97
|
+
requiredIfFilled: (value, rule, field, values) => {
|
|
98
|
+
if (rule.type !== "requiredIfFilled") return void 0;
|
|
99
|
+
if (value.trim().length > 0) return void 0;
|
|
100
|
+
return rule.fields.some((name) => isFilled(values, name)) ? requiredError(field) : void 0;
|
|
101
|
+
},
|
|
102
|
+
rulesByOption: (value, rule, field, values) => {
|
|
103
|
+
if (rule.type !== "rulesByOption") return void 0;
|
|
104
|
+
if (value.trim().length === 0) return void 0;
|
|
105
|
+
const option = normalizeFieldValue(values[rule.selector]).trim();
|
|
106
|
+
const rules = Object.prototype.hasOwnProperty.call(rule.cases, option) ? rule.cases[option] : void 0;
|
|
107
|
+
return evaluateRules(value, rules, field, values, validators);
|
|
108
|
+
},
|
|
109
|
+
streetLevelRequired: (value) => {
|
|
110
|
+
if (value.trim().length > 0) return void 0;
|
|
111
|
+
return STREET_LEVEL_REQUIRED_ERROR;
|
|
112
|
+
},
|
|
113
|
+
cpf: (value) => {
|
|
114
|
+
if (value.trim().length === 0) return void 0;
|
|
115
|
+
return validateCPF(value) ? void 0 : { key: "verification.errors.invalidTaxId" };
|
|
116
|
+
},
|
|
117
|
+
ssnFormat: (value) => {
|
|
118
|
+
if (value.trim().length === 0) return void 0;
|
|
119
|
+
return SSN_FORMAT_REGEX.test(value) ? void 0 : { key: "verification.errors.ssnFormat" };
|
|
120
|
+
},
|
|
121
|
+
noPoBox: (value) => {
|
|
122
|
+
if (value.trim().length === 0) return void 0;
|
|
123
|
+
return isPoBox(value) ? { key: "verification.errors.poBox" } : void 0;
|
|
124
|
+
},
|
|
125
|
+
postalCodeFormat: (value, rule) => {
|
|
126
|
+
if (rule.type !== "postalCodeFormat") return void 0;
|
|
127
|
+
if (value.trim().length === 0) return void 0;
|
|
128
|
+
if (validatePostalCode(value, rule.country)) return void 0;
|
|
129
|
+
return {
|
|
130
|
+
key: getPostalCodeErrorKey(rule.country),
|
|
131
|
+
params: buildPostalCodeParams(rule.country)
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
phoneFormat: (value, rule) => {
|
|
135
|
+
if (rule.type !== "phoneFormat") return void 0;
|
|
136
|
+
const trimmed = value.trim();
|
|
137
|
+
if (rule.optional && trimmed.length === 0) return void 0;
|
|
138
|
+
return validatePhone(trimmed, rule.country) ? void 0 : { key: "verification.errors.phoneInvalid" };
|
|
139
|
+
},
|
|
140
|
+
emailFormat: (value) => {
|
|
141
|
+
if (value.trim().length === 0) return void 0;
|
|
142
|
+
return EMAIL_FORMAT_REGEX.test(value) ? void 0 : { key: "verification.errors.emailInvalid" };
|
|
143
|
+
},
|
|
144
|
+
exactLength: (value, rule) => {
|
|
145
|
+
if (rule.type !== "exactLength") return void 0;
|
|
146
|
+
if (value.trim().length === 0) return void 0;
|
|
147
|
+
return value.length === rule.length ? void 0 : { key: "verification.errors.exactly10Characters" };
|
|
148
|
+
},
|
|
149
|
+
nameCharacters: (value) => {
|
|
150
|
+
if (value.trim().length === 0) return void 0;
|
|
151
|
+
return hasNameCharacters(value.trim()) ? void 0 : { key: "verification.errors.nameCharacters" };
|
|
152
|
+
},
|
|
153
|
+
notFuture: (value) => {
|
|
154
|
+
if (value.trim().length === 0) return void 0;
|
|
155
|
+
return isNotFuture(value.trim(), getLocalIsoDate()) ? void 0 : { key: "verification.errors.futureDate" };
|
|
156
|
+
},
|
|
157
|
+
maxAge: (value, rule) => {
|
|
158
|
+
if (rule.type !== "maxAge") return void 0;
|
|
159
|
+
if (value.trim().length === 0) return void 0;
|
|
160
|
+
return isWithinMaxAge(value.trim(), getLocalIsoDate(), rule.years) ? void 0 : { key: "verification.errors.dateOfBirthMaxAge" };
|
|
161
|
+
},
|
|
162
|
+
phoneDigits: (value, rule) => {
|
|
163
|
+
if (rule.type !== "phoneDigits") return void 0;
|
|
164
|
+
const trimmed = value.trim();
|
|
165
|
+
if (trimmed.length === 0) return void 0;
|
|
166
|
+
const national = getPhoneValidation()?.nationalNumber(trimmed, rule.country);
|
|
167
|
+
if (!national) return { key: PHONE_INVALID_KEY };
|
|
168
|
+
return national.length >= rule.min && national.length <= rule.max ? void 0 : { key: PHONE_INVALID_KEY };
|
|
169
|
+
},
|
|
170
|
+
digitCount: (value, rule) => {
|
|
171
|
+
if (rule.type !== "digitCount") return void 0;
|
|
172
|
+
if (value.trim().length === 0) return void 0;
|
|
173
|
+
return hasDigitCount(value.trim(), rule) ? void 0 : digitCountError(rule);
|
|
174
|
+
},
|
|
175
|
+
allowedCharacters: (value, rule) => {
|
|
176
|
+
if (rule.type !== "allowedCharacters") return void 0;
|
|
177
|
+
if (value.trim().length === 0) return void 0;
|
|
178
|
+
return hasAllowedCharacters(value.trim(), rule.classes, rule.extra) ? void 0 : { key: "verification.errors.invalidCharacters" };
|
|
179
|
+
},
|
|
180
|
+
charTemplate: (value, rule) => {
|
|
181
|
+
if (rule.type !== "charTemplate") return void 0;
|
|
182
|
+
if (value.trim().length === 0) return void 0;
|
|
183
|
+
return matchesCharTemplate(value.trim(), rule.templates, rule.ignoreCase) ? void 0 : { key: "verification.errors.invalidFormat" };
|
|
184
|
+
},
|
|
185
|
+
numericRange: (value, rule) => {
|
|
186
|
+
if (rule.type !== "numericRange") return void 0;
|
|
187
|
+
if (value.trim().length === 0) return void 0;
|
|
188
|
+
return isInNumericRange(value.trim(), rule.min, rule.max) ? void 0 : {
|
|
189
|
+
key: "verification.errors.numberBetween",
|
|
190
|
+
params: {
|
|
191
|
+
min: rule.min,
|
|
192
|
+
max: rule.max
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
rut: idNumberValidator(isValidRut),
|
|
197
|
+
esDni: idNumberValidator(isValidEsDni),
|
|
198
|
+
fiPersonalIdentityCode: idNumberValidator(isValidFiPersonalIdentityCode),
|
|
199
|
+
inDrivingLicenseNumber: idNumberValidator(isValidInDrivingLicenseNumber),
|
|
200
|
+
curp: idNumberValidator((value) => isValidCurp(value.trim())),
|
|
201
|
+
oneOfRequired: (_value, rule, _field, values) => {
|
|
202
|
+
if (rule.type !== "oneOfRequired") return void 0;
|
|
203
|
+
return rule.fields.some((name) => isFilled(values, name)) ? void 0 : { key: oneOfRequiredErrorKey(rule) };
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
return validators;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* A rule's own message key shows instead of the validator's, keeping its
|
|
210
|
+
* params. `oneOfRequired` already shows its message.
|
|
211
|
+
*/
|
|
212
|
+
const withRuleMessage = (error, rule) => !rule.message || error.key === rule.message ? error : {
|
|
213
|
+
...error,
|
|
214
|
+
key: rule.message
|
|
215
|
+
};
|
|
216
|
+
const evaluateRules = (value, rules, field, values, validators) => {
|
|
217
|
+
if (!rules) return void 0;
|
|
218
|
+
for (const rule of rules) {
|
|
219
|
+
const error = validators[rule.type](value, rule, field, values);
|
|
220
|
+
if (error) return withRuleMessage(error, rule);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
function validateEkycForm(values, fields) {
|
|
224
|
+
const validators = createValidators();
|
|
225
|
+
return fields.reduce((errors, field) => {
|
|
226
|
+
const value = normalizeFieldValue(values[field.name]);
|
|
227
|
+
const error = evaluateRules(value, field.validation, field, values, validators);
|
|
228
|
+
if (error) errors[field.name] = error;
|
|
229
|
+
return errors;
|
|
230
|
+
}, {});
|
|
231
|
+
}
|
|
232
|
+
function validateEkycField(values, fieldName, fields) {
|
|
233
|
+
const field = fields.find((f) => f.name === fieldName);
|
|
234
|
+
if (!field) return void 0;
|
|
235
|
+
const validators = createValidators();
|
|
236
|
+
const value = normalizeFieldValue(values[field.name]);
|
|
237
|
+
return evaluateRules(value, field.validation, field, values, validators);
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/modules/ekyc/ekycRules.ts
|
|
241
|
+
/** Vocabulary rules expressed as today's `EkycValidationRule` objects. */
|
|
242
|
+
const RULES = {
|
|
243
|
+
cpf: () => ({ type: "cpf" }),
|
|
244
|
+
ssnFormat: () => ({ type: "ssnFormat" }),
|
|
245
|
+
noPoBox: () => ({ type: "noPoBox" }),
|
|
246
|
+
emailFormat: () => ({ type: "emailFormat" }),
|
|
247
|
+
postalCodeFormat: ({ country }) => ({
|
|
248
|
+
type: "postalCodeFormat",
|
|
249
|
+
country
|
|
250
|
+
}),
|
|
251
|
+
phoneFormat: ({ country, required }) => ({
|
|
252
|
+
type: "phoneFormat",
|
|
253
|
+
country,
|
|
254
|
+
optional: !required
|
|
255
|
+
}),
|
|
256
|
+
exactLength: ({ params }) => ({
|
|
257
|
+
type: "exactLength",
|
|
258
|
+
length: params.length
|
|
259
|
+
}),
|
|
260
|
+
nameCharacters: () => ({ type: "nameCharacters" }),
|
|
261
|
+
notFuture: () => ({ type: "notFuture" }),
|
|
262
|
+
maxAge: ({ params }) => ({
|
|
263
|
+
type: "maxAge",
|
|
264
|
+
years: params.years
|
|
265
|
+
}),
|
|
266
|
+
phoneDigits: ({ country, params }) => ({
|
|
267
|
+
type: "phoneDigits",
|
|
268
|
+
country,
|
|
269
|
+
min: params.min,
|
|
270
|
+
max: params.max
|
|
271
|
+
}),
|
|
272
|
+
digitCount: ({ params }) => ({
|
|
273
|
+
type: "digitCount",
|
|
274
|
+
...params.lengths !== void 0 && { lengths: [...params.lengths] },
|
|
275
|
+
...params.min !== void 0 && { min: params.min },
|
|
276
|
+
...params.max !== void 0 && { max: params.max }
|
|
277
|
+
}),
|
|
278
|
+
allowedCharacters: ({ params }) => ({
|
|
279
|
+
type: "allowedCharacters",
|
|
280
|
+
classes: [...params.classes],
|
|
281
|
+
...params.extra !== void 0 && { extra: params.extra }
|
|
282
|
+
}),
|
|
283
|
+
charTemplate: ({ params }) => ({
|
|
284
|
+
type: "charTemplate",
|
|
285
|
+
templates: [...params.templates],
|
|
286
|
+
...params.ignoreCase !== void 0 && { ignoreCase: params.ignoreCase }
|
|
287
|
+
}),
|
|
288
|
+
numericRange: ({ params }) => ({
|
|
289
|
+
type: "numericRange",
|
|
290
|
+
min: params.min,
|
|
291
|
+
max: params.max
|
|
292
|
+
}),
|
|
293
|
+
rut: () => ({ type: "rut" }),
|
|
294
|
+
esDni: () => ({ type: "esDni" }),
|
|
295
|
+
fiPersonalIdentityCode: () => ({ type: "fiPersonalIdentityCode" }),
|
|
296
|
+
inDrivingLicenseNumber: () => ({ type: "inDrivingLicenseNumber" }),
|
|
297
|
+
curp: () => ({ type: "curp" })
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* A field's vocabulary rules as today's `EkycValidationRule`s, which
|
|
301
|
+
* `validateEkycField` runs. eKYC Pre-fill validates with them too.
|
|
302
|
+
*/
|
|
303
|
+
function projectRules(rules, country, required) {
|
|
304
|
+
return rules.flatMap((rule) => {
|
|
305
|
+
const project = RULES[rule.id];
|
|
306
|
+
if (!project) return [];
|
|
307
|
+
const projected = project({
|
|
308
|
+
country,
|
|
309
|
+
required,
|
|
310
|
+
params: rule.params ?? {}
|
|
311
|
+
});
|
|
312
|
+
return [rule.message ? {
|
|
313
|
+
...projected,
|
|
314
|
+
message: rule.message.key
|
|
315
|
+
} : projected];
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
//#endregion
|
|
319
|
+
export { formatPhoneNational as a, oneOfRequiredErrorKey as c, cleanName as i, validateEkycField as l, projectRules as n, formatSSN as o, ONE_OF_REQUIRED_ERROR_KEY as r, loadPhoneValidator as s, RULES as t, validateEkycForm as u };
|