@incodetech/core 0.0.0-dev-20261124-bcd99b1e → 0.0.0-dev-20261125-a91bf928
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/{FaceDetectionProvider-D4ncumfe.esm.js → FaceDetectionProvider-D-1rS3WB.esm.js} +4 -4
- package/dist/{definitionSource-B-Z2EgJJ.esm.js → addressSearch-DKdOJ_e-.esm.js} +67 -8
- package/dist/ae-signature.esm.js +1 -1
- package/dist/{phoneFormat-C3q0Ukh4.esm.js → allowedCharacters-Bnir--CN.esm.js} +1 -11
- package/dist/{apiError-a7tezk_O.esm.js → apiError-CxKf45Ky.esm.js} +1 -1
- package/dist/authentication.d.ts +3 -3
- package/dist/authentication.esm.js +2 -2
- package/dist/{authenticationManager-Cp64l__H.d.ts → authenticationManager-BManpfgb.d.ts} +1 -1
- package/dist/{authenticationManager-IpVKgxPn.esm.js → authenticationManager-CThxh6EJ.esm.js} +3 -3
- package/dist/{authenticationStateMachine-B4CuMBgC.esm.js → authenticationStateMachine-DN122Cii.esm.js} +3 -3
- package/dist/{calendarDate-DcqGuEht.esm.js → calendarDate-D2zWfUlA.esm.js} +1 -1
- package/dist/{cnpj-Bl_olpdX.esm.js → cnpj-CVq3vL39.esm.js} +1 -9
- package/dist/cnpj-D5cxwIe-.esm.js +9 -0
- package/dist/curp-validation.d.ts +1 -1
- package/dist/curp-validation.esm.js +2 -2
- package/dist/{curpValidationManager-C6WmQToS.esm.js → curpValidationManager-4v5qMUXm.esm.js} +1 -1
- package/dist/{curpValidationManager-Dynwqu2z.d.ts → curpValidationManager-9U7zMZt8.d.ts} +1 -1
- package/dist/{curpValidationStateMachine-BbJ4YAzE.esm.js → curpValidationStateMachine-BPkEZtmd.esm.js} +1 -1
- package/dist/custom-fields.esm.js +1 -1
- package/dist/{customFieldsManager-BBy6X9nh.esm.js → customFieldsManager-BX3u8VPe.esm.js} +1 -1
- package/dist/{deepsightCaptureConfig-D0PCzVcM.esm.js → deepsightCaptureConfig-B7HX2BKP.esm.js} +2 -2
- package/dist/{deepsightLoader-nbl5Dhvf.esm.js → deepsightLoader-C_fdJi9H.esm.js} +4 -4
- package/dist/definitionSource-C_pmsYIx.esm.js +12 -0
- package/dist/{desktopCameraElection-C2jhy2Fd.esm.js → desktopCameraElection-A7IPW-RU.esm.js} +4 -4
- package/dist/document-capture.d.ts +1 -1
- package/dist/document-signature.esm.js +1 -1
- package/dist/{documentCaptureManager-DOgJTJ4F.d.ts → documentCaptureManager-sJWgqtUy.d.ts} +4 -4
- package/dist/{documentSignatureStateMachine-DoeIrTmr.esm.js → documentSignatureStateMachine-ClNEf1FQ.esm.js} +1 -1
- package/dist/dynamic-forms.esm.js +2 -2
- package/dist/{dynamicFormsManager-D_QpTKfT.esm.js → dynamicFormsManager-nl9-642J.esm.js} +1 -1
- package/dist/{dynamicFormsStateMachine-D_KmQwDZ.esm.js → dynamicFormsStateMachine-DwjwenOE.esm.js} +2 -2
- package/dist/ekyb.d.ts +4 -4
- package/dist/ekyb.esm.js +2 -2
- package/dist/{ekybManager-BG7eju18.esm.js → ekybManager-B-tbtSFb.esm.js} +1 -1
- package/dist/{ekybManager-BflWuTe4.d.ts → ekybManager-DZdSXQMK.d.ts} +2 -2
- package/dist/{ekybStateMachine-Bc-m_PHQ.esm.js → ekybStateMachine-BC4eZWrb.esm.js} +5 -4
- package/dist/ekyc-prefill.d.ts +3 -4
- package/dist/ekyc-prefill.esm.js +2 -2
- package/dist/ekyc.d.ts +3 -3
- package/dist/ekyc.esm.js +2 -2
- package/dist/{ekycManager-BPUHoUHy.esm.js → ekycManager-CDxoP5gL.esm.js} +1 -1
- package/dist/{ekycManager-BldDiWTJ.d.ts → ekycManager-DusmB-4j.d.ts} +2 -2
- package/dist/{ekycPrefillManager-qgG_uUKA.d.ts → ekycPrefillManager-BwmPXfhY.d.ts} +17 -17
- package/dist/{ekycPrefillManager-BaX95xIW.esm.js → ekycPrefillManager-Cu5EAnkQ.esm.js} +6 -7
- package/dist/{ekycPrefillStateMachine-C8FEAHbH.esm.js → ekycPrefillStateMachine-DdHdgSaW.esm.js} +567 -165
- package/dist/{ekycStateMachine-Cq94FpIm.esm.js → ekycStateMachine-CM1YRW27.esm.js} +483 -155
- package/dist/electronic-signature.esm.js +1 -1
- package/dist/{electronicSignatureManager-bgoE6nL8.esm.js → electronicSignatureManager-knl_X2jh.esm.js} +1 -1
- package/dist/extensibility.d.ts +15 -15
- package/dist/extensibility.esm.js +17 -17
- package/dist/{faceCaptureManagerFactory-DvH9-zIi.esm.js → faceCaptureManagerFactory-D0eN82qj.esm.js} +2 -2
- package/dist/{faceCaptureManagerFactory-BZ2XHhkj.d.ts → faceCaptureManagerFactory-Dm7p3T_t.d.ts} +3 -3
- package/dist/{faceCaptureSetup-DuFiwK9F.esm.js → faceCaptureSetup-BfedgErd.esm.js} +7 -7
- package/dist/{feature-management-DiL2uBlX.esm.js → feature-management-BD2hrfZ3.esm.js} +1 -1
- package/dist/feature-management.esm.js +1 -1
- package/dist/flow-events.d.ts +1 -1
- package/dist/flow.d.ts +7 -7
- package/dist/flow.esm.js +3 -3
- package/dist/{flowCompletionService-Bs4oWd_W.esm.js → flowCompletionService-DlXzGwgu.esm.js} +1 -1
- package/dist/{flowServices-KLGZ3eWm.esm.js → flowServices-CxTdN-OL.esm.js} +4 -4
- package/dist/formErrors-lSfh7Y8J.esm.js +512 -0
- package/dist/geolocation.d.ts +1 -1
- package/dist/geolocation.esm.js +2 -2
- package/dist/{geolocationManager-Del2ddmt.d.ts → geolocationManager-CENrvxpK.d.ts} +1 -1
- package/dist/{geolocationManager-el4FUmYy.esm.js → geolocationManager-Ch5lOvYH.esm.js} +1 -1
- package/dist/{geolocationStateMachine-BnM-qTe3.esm.js → geolocationStateMachine-EN7it_FF.esm.js} +1 -1
- package/dist/home.d.ts +1 -1
- package/dist/id-ocr.d.ts +1 -1
- package/dist/id-ocr.esm.js +2 -2
- package/dist/id-selfie-flow.d.ts +1 -1
- package/dist/id-selfie-flow.esm.js +6 -6
- package/dist/id.d.ts +2 -2
- package/dist/id.esm.js +3 -3
- package/dist/{idCaptureManager-UnWwLa3I.esm.js → idCaptureManager-CH2bkanx.esm.js} +4 -4
- package/dist/{idCaptureManager-Co4ZZ-pd.d.ts → idCaptureManager-jjNknNiP.d.ts} +2 -2
- package/dist/{idCaptureServices-DFUdwccM.esm.js → idCaptureServices-BN57-oba.esm.js} +2 -2
- package/dist/{idCaptureStateMachine-DGWGB0Tz.esm.js → idCaptureStateMachine-DIM0ZxBY.esm.js} +11 -11
- package/dist/{idOcrManager-C3BHGgSb.d.ts → idOcrManager-C0C7lFGd.d.ts} +1 -1
- package/dist/{idOcrManager-XTbpfHoF.esm.js → idOcrManager-Dl9eNhT8.esm.js} +1 -1
- package/dist/{idOcrStateMachine-B-00PgPh.esm.js → idOcrStateMachine-CEkUWxGy.esm.js} +1 -1
- package/dist/{index-RghgiJVx.d.ts → index-B-K_tV2Q.d.ts} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/kyb-checks.d.ts +3 -3
- package/dist/kyb-checks.esm.js +2 -2
- package/dist/{kybChecksManager-CbkCctw0.esm.js → kybChecksManager-Bh-oiXei.esm.js} +2 -2
- package/dist/{kybChecksManager-B7Di9auB.d.ts → kybChecksManager-CKDy1mel.d.ts} +1 -1
- package/dist/{kybChecksStateMachine-BeB_cgk4.esm.js → kybChecksStateMachine-WIdi80Sq.esm.js} +175 -178
- package/dist/mandatory-consent.d.ts +2 -2
- package/dist/{mandatoryConsentManager-B_eFZmo-.d.ts → mandatoryConsentManager-Bwl0YPwg.d.ts} +1 -1
- package/dist/numericRange-zDZFvRb8.esm.js +274 -0
- package/dist/qe-signature.esm.js +1 -1
- package/dist/{recordingService-PUU8CObN.esm.js → recordingService-5o50qJ9A.esm.js} +1 -1
- package/dist/{runChildModule-BOvtfM8r.esm.js → runChildModule-vqgSWeEF.esm.js} +1 -1
- package/dist/{sdkVersion-thMGaHAC.esm.js → sdkVersion-C3x7ZDSE.esm.js} +1 -1
- package/dist/selfie.d.ts +3 -3
- package/dist/selfie.esm.js +7 -7
- package/dist/{selfieErrorUtils-CqudCvHN.esm.js → selfieErrorUtils-BB-nxdeJ.esm.js} +1 -1
- package/dist/{selfieManager-DWRVOhOE.esm.js → selfieManager-CpV6Lw0q.esm.js} +3 -3
- package/dist/{selfieManager-CKm034l4.d.ts → selfieManager-DOwu6Ukf.d.ts} +1 -1
- package/dist/{selfieStateMachine-CNELgWFK.esm.js → selfieStateMachine-Bxi31PsA.esm.js} +3 -3
- package/dist/{session-pNSU6n3-.esm.js → session-syFGvfFW.esm.js} +4 -4
- package/dist/session.d.ts +1 -1
- package/dist/session.esm.js +4 -4
- package/dist/{sessionInitializer-BzvYgZCQ.esm.js → sessionInitializer-C4cinkbs.esm.js} +4 -4
- package/dist/{setup-BQVlJnC0.esm.js → setup-cZWqRr7-.esm.js} +5 -5
- package/dist/trueSight-DK2Q1w9z.esm.js +1 -0
- package/dist/{trueSightService-DjwNQ37t.esm.js → trueSightService-Bm5K21-R.esm.js} +1 -1
- package/dist/types-BTJWXYHA.d.ts +6 -0
- package/dist/{types-BgRHw-dR.d.ts → types-BaA0Qscz.d.ts} +1 -1
- package/dist/{types-_rJ2GjgK.d.ts → types-BqDc7tER.d.ts} +1 -1
- package/dist/{types-DFgJ26nw.d.ts → types-CH9u9ikn.d.ts} +1 -1
- package/dist/{types-Dy4XI7jR.d.ts → types-CRzImo5V.d.ts} +1 -1
- package/dist/{types-BiUMy0Vp.d.ts → types-CoXJsu1W.d.ts} +1 -1
- package/dist/{textRules-D4NRinKY.d.ts → types-D6Q1D1kx.d.ts} +1 -9
- package/dist/{types-CTaL0XJz.d.ts → types-DWqO7owj.d.ts} +2 -24
- package/dist/{types-mK4qyHxM.d.ts → types-g3NuVCT9.d.ts} +16 -29
- package/dist/{types-aKXf9SVN.d.ts → types-ia31g4VQ.d.ts} +3 -3
- package/dist/{types-Bdes6iC1.d.ts → types-tOSLpcSa.d.ts} +10 -2
- package/dist/video-selfie.d.ts +1 -1
- package/dist/video-selfie.esm.js +3 -3
- package/dist/{videoSelfieCameraWarmer-M25qqewS.esm.js → videoSelfieCameraWarmer-B5atbHuu.esm.js} +3 -3
- package/dist/{videoSelfieStepDetector-BBXE3DnI.d.ts → videoSelfieStepDetector-Dfj7UUF3.d.ts} +2 -2
- package/dist/wasm.esm.js +1 -1
- package/dist/watchlist-for-business.esm.js +2 -2
- package/dist/{watchlistForBusinessManager-DxeSH80T.esm.js → watchlistForBusinessManager-CiSWk1Lh.esm.js} +1 -1
- package/dist/{watchlistForBusinessStateMachine-BC9UWLuZ.esm.js → watchlistForBusinessStateMachine-DiQW42sd.esm.js} +3 -2
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.esm.js +21 -21
- package/package.json +1 -1
- package/dist/addressSearch-BKlynuBr.esm.js +0 -71
- package/dist/ekycRules-B7kUzSgu.esm.js +0 -598
- package/dist/trueSight-CiveOb7r.esm.js +0 -1
- package/dist/types-J7D0pbWH.d.ts +0 -6
package/dist/{ekycPrefillStateMachine-C8FEAHbH.esm.js → ekycPrefillStateMachine-DdHdgSaW.esm.js}
RENAMED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { t as getLocalIsoDate } from "./IBrowserEnvironmentCapability-D7JG7ML3.esm.js";
|
|
2
2
|
import { t as api, u as endpoints } from "./api-BNxrW8xK.esm.js";
|
|
3
|
-
import { i as toIncodeApiError } from "./apiError-
|
|
3
|
+
import { i as toIncodeApiError } from "./apiError-CxKf45Ky.esm.js";
|
|
4
4
|
import { n as loadPhoneValidation } from "./phoneValidation-OggtfjRt.esm.js";
|
|
5
5
|
import { i as assign, t as setup } from "./xstate.esm-CIqUf_i6.esm.js";
|
|
6
6
|
import { n as fromPromise } from "./xstate-actors.esm-BCcwgosu.esm.js";
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
7
|
+
import { t as isValidCurp } from "./curp-DZGvefg3.esm.js";
|
|
8
|
+
import { a as matchesCharTemplate, c as digitCountError, d as isValidRut, f as isValidInDrivingLicenseNumber, i as isWithinMaxAge, l as hasDigitCount, m as isValidEsDni, n as isNotFuture, o as isPoBox, p as isValidFiPersonalIdentityCode, r as hasNameCharacters, s as isEmailFormat, t as isInNumericRange, u as resolvePrefill } from "./numericRange-zDZFvRb8.esm.js";
|
|
9
|
+
import { t as validateCNPJ } from "./cnpj-CVq3vL39.esm.js";
|
|
9
10
|
import { n as checkSupport, t as resolveForm } from "./resolveForm-DaaQSVWp.esm.js";
|
|
10
|
-
import { t as
|
|
11
|
+
import { a as e164, c as setFieldValue, d as createFormRegistry, f as supportedIds, i as oneOfRequired, l as validateAllValues, m as withMessage, n as requiredError, o as allowedCharacters, p as buildPayload, r as trim, s as phoneDeps, t as STRUCTURE_MESSAGES, u as validateFieldValue } from "./formErrors-lSfh7Y8J.esm.js";
|
|
12
|
+
import { t as createBundledDefinitionSource } from "./definitionSource-C_pmsYIx.esm.js";
|
|
13
|
+
import { t as validateCPF } from "./cpf-DDXMTLYr.esm.js";
|
|
11
14
|
//#region src/internal/forms/formatValue.ts
|
|
12
15
|
/**
|
|
13
16
|
* A typed or prefilled value after the field's input formats
|
|
@@ -102,7 +105,7 @@ const EKYCPREFILL_DEFINITIONS = {
|
|
|
102
105
|
}]
|
|
103
106
|
},
|
|
104
107
|
rules: [{ id: "cpf" }],
|
|
105
|
-
payload: { transforms: [{
|
|
108
|
+
payload: { transforms: [{ id: "trim" }, {
|
|
106
109
|
id: "stripSeparators",
|
|
107
110
|
params: { chars: ".-" }
|
|
108
111
|
}] }
|
|
@@ -143,7 +146,8 @@ const EKYCPREFILL_DEFINITIONS = {
|
|
|
143
146
|
rules: [{ id: "notFuture" }, {
|
|
144
147
|
id: "maxAge",
|
|
145
148
|
params: { years: 120 }
|
|
146
|
-
}]
|
|
149
|
+
}],
|
|
150
|
+
payload: { transforms: [{ id: "trim" }] }
|
|
147
151
|
},
|
|
148
152
|
{
|
|
149
153
|
name: "ssn",
|
|
@@ -167,7 +171,7 @@ const EKYCPREFILL_DEFINITIONS = {
|
|
|
167
171
|
}]
|
|
168
172
|
},
|
|
169
173
|
rules: [{ id: "ssnFormat" }],
|
|
170
|
-
payload: { transforms: [{
|
|
174
|
+
payload: { transforms: [{ id: "trim" }, {
|
|
171
175
|
id: "stripSeparators",
|
|
172
176
|
params: { chars: "-" }
|
|
173
177
|
}] }
|
|
@@ -182,7 +186,8 @@ const EKYCPREFILL_DEFINITIONS = {
|
|
|
182
186
|
maxLength: 100,
|
|
183
187
|
autofill: "familyName"
|
|
184
188
|
},
|
|
185
|
-
rules: [{ id: "nameCharacters" }]
|
|
189
|
+
rules: [{ id: "nameCharacters" }],
|
|
190
|
+
payload: { transforms: [{ id: "trim" }] }
|
|
186
191
|
}
|
|
187
192
|
],
|
|
188
193
|
groupRules: [{
|
|
@@ -233,6 +238,80 @@ const EKYCPREFILL_DEFINITIONS = {
|
|
|
233
238
|
}
|
|
234
239
|
};
|
|
235
240
|
//#endregion
|
|
241
|
+
//#region src/internal/forms/rules/charTemplate.ts
|
|
242
|
+
const isTemplate = (value) => typeof value === "string" && value !== "";
|
|
243
|
+
/**
|
|
244
|
+
* `charTemplate`, leading and trailing whitespace ignored as eKYC trims the
|
|
245
|
+
* value first. Without a non-empty list of non-empty templates, or with an
|
|
246
|
+
* `ignoreCase` that isn't a boolean, the rule passes.
|
|
247
|
+
*/
|
|
248
|
+
const charTemplate = {
|
|
249
|
+
id: "charTemplate",
|
|
250
|
+
test: (value, { templates, ignoreCase }) => {
|
|
251
|
+
if (!Array.isArray(templates) || templates.length === 0 || !templates.every(isTemplate) || ignoreCase !== void 0 && typeof ignoreCase !== "boolean") return true;
|
|
252
|
+
return matchesCharTemplate(value.trim(), templates, ignoreCase);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/internal/forms/rules/cnpj.ts
|
|
257
|
+
/**
|
|
258
|
+
* `cnpj`: a Brazilian CNPJ, as eKYB checks it: 14 digits, or the
|
|
259
|
+
* 18-character `00.000.000/0000-00` layout, with surrounding whitespace
|
|
260
|
+
* ignored.
|
|
261
|
+
*/
|
|
262
|
+
const cnpj = {
|
|
263
|
+
id: "cnpj",
|
|
264
|
+
test: (value) => validateCNPJ(value)
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/internal/forms/rules/cpf.ts
|
|
268
|
+
/**
|
|
269
|
+
* `cpf`: a Brazilian CPF, as eKYC and eKYC Pre-fill check it, on the value as
|
|
270
|
+
* typed: 11 digits, or the 14-character `000.000.000-00` layout.
|
|
271
|
+
*/
|
|
272
|
+
const cpf = {
|
|
273
|
+
id: "cpf",
|
|
274
|
+
test: (value) => validateCPF(value)
|
|
275
|
+
};
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/internal/forms/rules/curp.ts
|
|
278
|
+
/**
|
|
279
|
+
* `curp`: the Mexican CURP layout, as the CURP module checks it. The value is
|
|
280
|
+
* trimmed first, as eKYC does today.
|
|
281
|
+
*/
|
|
282
|
+
const curp = {
|
|
283
|
+
id: "curp",
|
|
284
|
+
test: (value) => isValidCurp(value.trim())
|
|
285
|
+
};
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/internal/forms/rules/digitCount.ts
|
|
288
|
+
const isCount = (value) => typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
289
|
+
/**
|
|
290
|
+
* The rule's counts, in the two shapes its message can name: `lengths` alone
|
|
291
|
+
* (a non-empty list of positive whole numbers), or both `min` and `max` with
|
|
292
|
+
* `min` no greater than `max`. These are the params eKYC accepts.
|
|
293
|
+
*/
|
|
294
|
+
function countOf({ lengths, min, max }) {
|
|
295
|
+
if (lengths !== void 0) return Array.isArray(lengths) && lengths.length > 0 && lengths.every(isCount) && min === void 0 && max === void 0 ? { lengths } : void 0;
|
|
296
|
+
return isCount(min) && isCount(max) && min <= max ? {
|
|
297
|
+
min,
|
|
298
|
+
max
|
|
299
|
+
} : void 0;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* `digitCount`, leading and trailing whitespace ignored as eKYC trims the
|
|
303
|
+
* value first. With params of another shape, such as `min` alone, the rule
|
|
304
|
+
* passes: no message names an open range.
|
|
305
|
+
*/
|
|
306
|
+
const digitCount = {
|
|
307
|
+
id: "digitCount",
|
|
308
|
+
test: (value, params) => {
|
|
309
|
+
const count = countOf(params);
|
|
310
|
+
return !count || hasDigitCount(value.trim(), count);
|
|
311
|
+
},
|
|
312
|
+
error: (params) => digitCountError(countOf(params) ?? {})
|
|
313
|
+
};
|
|
314
|
+
//#endregion
|
|
236
315
|
//#region src/internal/forms/rules/digitGroups.ts
|
|
237
316
|
/**
|
|
238
317
|
* `digitGroups`: formats digits as the user types, such as an SSN shown as
|
|
@@ -266,6 +345,336 @@ const digitGroups = {
|
|
|
266
345
|
}
|
|
267
346
|
};
|
|
268
347
|
//#endregion
|
|
348
|
+
//#region src/internal/forms/rules/e164NoPlus.ts
|
|
349
|
+
/** `e164NoPlus`: the phone as E.164 without the `+`. */
|
|
350
|
+
const e164NoPlus = {
|
|
351
|
+
id: "e164NoPlus",
|
|
352
|
+
apply: (value, params, env) => e164.apply(value, params, env).replace(/^\+/, "")
|
|
353
|
+
};
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/internal/forms/rules/emailFormat.ts
|
|
356
|
+
/** `emailFormat`: an email's shape, the value as typed, as eKYC checks it. */
|
|
357
|
+
const emailFormat = {
|
|
358
|
+
id: "emailFormat",
|
|
359
|
+
test: (value) => isEmailFormat(value)
|
|
360
|
+
};
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/internal/forms/rules/esDni.ts
|
|
363
|
+
/** `esDni`: a Spanish DNI, as eKYC checks it. */
|
|
364
|
+
const esDni = {
|
|
365
|
+
id: "esDni",
|
|
366
|
+
test: (value) => isValidEsDni(value)
|
|
367
|
+
};
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/internal/forms/rules/exactLength.ts
|
|
370
|
+
/**
|
|
371
|
+
* `exactLength`: exactly `length` characters, the value as typed. Characters
|
|
372
|
+
* are Unicode code points, as `maxLength` counts them; eKYC counts UTF-16
|
|
373
|
+
* units, which differs only for characters outside the BMP, such as emoji.
|
|
374
|
+
* Without a positive whole `length` the rule passes. The message is the
|
|
375
|
+
* vocabulary's, without params, as eKYC gives it.
|
|
376
|
+
*/
|
|
377
|
+
const exactLength = {
|
|
378
|
+
id: "exactLength",
|
|
379
|
+
test: (value, { length }) => typeof length !== "number" || !Number.isInteger(length) || length < 1 || [...value].length === length
|
|
380
|
+
};
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/internal/forms/rules/fiPersonalIdentityCode.ts
|
|
383
|
+
/**
|
|
384
|
+
* `fiPersonalIdentityCode`: a Finnish personal identity code, as eKYC checks
|
|
385
|
+
* it.
|
|
386
|
+
*/
|
|
387
|
+
const fiPersonalIdentityCode = {
|
|
388
|
+
id: "fiPersonalIdentityCode",
|
|
389
|
+
test: (value) => isValidFiPersonalIdentityCode(value)
|
|
390
|
+
};
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region src/internal/forms/rules/inDrivingLicenseNumber.ts
|
|
393
|
+
/**
|
|
394
|
+
* `inDrivingLicenseNumber`: an Indian driving licence number, as eKYC checks
|
|
395
|
+
* it.
|
|
396
|
+
*/
|
|
397
|
+
const inDrivingLicenseNumber = {
|
|
398
|
+
id: "inDrivingLicenseNumber",
|
|
399
|
+
test: (value) => isValidInDrivingLicenseNumber(value)
|
|
400
|
+
};
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/internal/forms/rules/maxAge.ts
|
|
403
|
+
const isYears = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
404
|
+
/**
|
|
405
|
+
* `maxAge`: at most `years` full years before `env.today`, trimmed as eKYC
|
|
406
|
+
* checks it. Unusable params pass.
|
|
407
|
+
*/
|
|
408
|
+
const maxAge = {
|
|
409
|
+
id: "maxAge",
|
|
410
|
+
test: (value, params, env) => isYears(params.years) ? isWithinMaxAge(value.trim(), env.today, params.years) : true
|
|
411
|
+
};
|
|
412
|
+
//#endregion
|
|
413
|
+
//#region src/internal/forms/rules/nameCharacters.ts
|
|
414
|
+
/**
|
|
415
|
+
* `nameCharacters`: a name's characters. Leading and trailing whitespace is
|
|
416
|
+
* ignored, as eKYC trims the value before checking it.
|
|
417
|
+
*/
|
|
418
|
+
const nameCharacters = {
|
|
419
|
+
id: "nameCharacters",
|
|
420
|
+
test: (value) => hasNameCharacters(value.trim())
|
|
421
|
+
};
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/internal/forms/rules/nationalNumber.ts
|
|
424
|
+
/**
|
|
425
|
+
* `nationalNumber`: the phone's national significant number, without the
|
|
426
|
+
* calling code or a trunk 0. While the phone rules aren't loaded, or the
|
|
427
|
+
* number can't be read, it stays as typed.
|
|
428
|
+
*/
|
|
429
|
+
const nationalNumber = {
|
|
430
|
+
id: "nationalNumber",
|
|
431
|
+
apply: (value, _params, env) => env.deps.phone?.nationalNumber(value, env.country) ?? value
|
|
432
|
+
};
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/internal/forms/rules/noPoBox.ts
|
|
435
|
+
/** `noPoBox`: the street doesn't describe a P.O. box, as eKYC checks it. */
|
|
436
|
+
const noPoBox = {
|
|
437
|
+
id: "noPoBox",
|
|
438
|
+
test: (value) => !isPoBox(value)
|
|
439
|
+
};
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/internal/forms/rules/notFuture.ts
|
|
442
|
+
/** `notFuture`: on or before `env.today`, trimmed as eKYC checks it. */
|
|
443
|
+
const notFuture = {
|
|
444
|
+
id: "notFuture",
|
|
445
|
+
test: (value, _params, env) => isNotFuture(value.trim(), env.today)
|
|
446
|
+
};
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/internal/forms/rules/numericRange.ts
|
|
449
|
+
const isWhole = (value) => typeof value === "number" && Number.isInteger(value);
|
|
450
|
+
/** Whole-number `min` and `max` with `min` no greater than `max`. */
|
|
451
|
+
function rangeOf({ min, max }) {
|
|
452
|
+
return isWhole(min) && isWhole(max) && min <= max ? {
|
|
453
|
+
min,
|
|
454
|
+
max
|
|
455
|
+
} : void 0;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* `numericRange`, leading and trailing whitespace ignored as eKYC trims the
|
|
459
|
+
* value first. The message names the range (`min`, `max`). Without a usable
|
|
460
|
+
* range the rule passes.
|
|
461
|
+
*/
|
|
462
|
+
const numericRange = {
|
|
463
|
+
id: "numericRange",
|
|
464
|
+
test: (value, params) => {
|
|
465
|
+
const range = rangeOf(params);
|
|
466
|
+
return !range || isInNumericRange(value.trim(), range.min, range.max);
|
|
467
|
+
},
|
|
468
|
+
error: (params) => {
|
|
469
|
+
const range = rangeOf(params);
|
|
470
|
+
return {
|
|
471
|
+
key: "verification.errors.numberBetween",
|
|
472
|
+
...range && { params: {
|
|
473
|
+
min: range.min,
|
|
474
|
+
max: range.max
|
|
475
|
+
} }
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/internal/forms/rules/phoneDigits.ts
|
|
481
|
+
const isDigitCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
482
|
+
/**
|
|
483
|
+
* `phoneDigits`: the national significant number has `min` to `max` digits,
|
|
484
|
+
* so the calling code and a trunk prefix don't count. As in eKYC, the value
|
|
485
|
+
* is trimmed, and a number the phone rules can't read fails, as does every
|
|
486
|
+
* phone while they aren't loaded. Unusable params pass.
|
|
487
|
+
*/
|
|
488
|
+
const phoneDigits = {
|
|
489
|
+
id: "phoneDigits",
|
|
490
|
+
test: (value, params, env) => {
|
|
491
|
+
const { min, max } = params;
|
|
492
|
+
if (!isDigitCount(min) || !isDigitCount(max) || min > max) return true;
|
|
493
|
+
const national = env.deps.phone?.nationalNumber(value.trim(), env.country);
|
|
494
|
+
if (!national) return false;
|
|
495
|
+
return national.length >= min && national.length <= max;
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region src/internal/forms/rules/phoneFormat.ts
|
|
500
|
+
/**
|
|
501
|
+
* `phoneFormat`: a valid number for its own country, without its leading and
|
|
502
|
+
* trailing whitespace, as eKYC checks it. While the phone rules aren't loaded
|
|
503
|
+
* every phone fails, as in eKYC.
|
|
504
|
+
*/
|
|
505
|
+
const phoneFormat = {
|
|
506
|
+
id: "phoneFormat",
|
|
507
|
+
test: (value, _params, env) => env.deps.phone?.isValid(value.trim(), env.country) ?? false
|
|
508
|
+
};
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/internal/forms/rules/postalCodeFormat.ts
|
|
511
|
+
/**
|
|
512
|
+
* `postalCodeFormat`: the postal format of the form's country, checked on the
|
|
513
|
+
* value as typed, as eKYC does. The tables and the message, which depends on
|
|
514
|
+
* the country, come from `env.deps.postal`; without them every value passes.
|
|
515
|
+
*/
|
|
516
|
+
const postalCodeFormat = {
|
|
517
|
+
id: "postalCodeFormat",
|
|
518
|
+
test: (value, _params, env) => env.deps.postal ? env.deps.postal.isValid(value, env.country) : true,
|
|
519
|
+
error: (_params, env) => {
|
|
520
|
+
const postal = env.deps.postal;
|
|
521
|
+
if (!postal) return { key: "postalCodeFormat" };
|
|
522
|
+
return {
|
|
523
|
+
key: postal.errorKey(env.country),
|
|
524
|
+
params: postal.params(env.country)
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region src/internal/forms/rules/rulesByOption.ts
|
|
530
|
+
const isCaseRule = (value) => typeof value === "object" && value !== null && typeof value.id === "string";
|
|
531
|
+
/**
|
|
532
|
+
* `rulesByOption`: the `target` field must pass the rules listed for the
|
|
533
|
+
* `selector` field's current value. It runs only while both are shown and the
|
|
534
|
+
* target has a value; a value with no case adds no rules. The error goes on
|
|
535
|
+
* the target: a case rule's own message first, then the group rule's
|
|
536
|
+
* message, then the rule's own error.
|
|
537
|
+
*/
|
|
538
|
+
const rulesByOption = {
|
|
539
|
+
id: "rulesByOption",
|
|
540
|
+
check: ({ rule, fields, values, isEmpty, checkRule }) => {
|
|
541
|
+
const { selector, target, cases } = rule.params ?? {};
|
|
542
|
+
if (typeof selector !== "string" || typeof target !== "string") return {};
|
|
543
|
+
if (!fields.includes(selector) || !fields.includes(target)) return {};
|
|
544
|
+
if (isEmpty(target)) return {};
|
|
545
|
+
if (typeof cases !== "object" || cases === null || Array.isArray(cases)) return {};
|
|
546
|
+
const option = String(values[selector] ?? "").trim();
|
|
547
|
+
const rules = Object.prototype.hasOwnProperty.call(cases, option) ? cases[option] : void 0;
|
|
548
|
+
if (!Array.isArray(rules)) return {};
|
|
549
|
+
const value = String(values[target]);
|
|
550
|
+
for (const ref of rules) {
|
|
551
|
+
if (!isCaseRule(ref)) continue;
|
|
552
|
+
const error = checkRule(ref, value);
|
|
553
|
+
if (!error) continue;
|
|
554
|
+
return { [target]: rule.message && !ref.message ? withMessage(error, rule.message) : error };
|
|
555
|
+
}
|
|
556
|
+
return {};
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region src/internal/forms/rules/rut.ts
|
|
561
|
+
/** `rut`: a Chilean RUT, as eKYC checks it. */
|
|
562
|
+
const rut = {
|
|
563
|
+
id: "rut",
|
|
564
|
+
test: (value) => isValidRut(value)
|
|
565
|
+
};
|
|
566
|
+
//#endregion
|
|
567
|
+
//#region src/internal/forms/checks/ssnFormat.ts
|
|
568
|
+
/** Nine digits in 3-2-4 groups, each `-` between the groups optional. */
|
|
569
|
+
const SSN_PATTERN = /^[0-9]{3}-?[0-9]{2}-?[0-9]{4}$/;
|
|
570
|
+
/**
|
|
571
|
+
* Whether a value is a US SSN as the vocabulary defines it: nine digits, with
|
|
572
|
+
* optional `-` separators in the 3-2-4 groups (`123456789`, `123-45-6789`,
|
|
573
|
+
* `123-456789`).
|
|
574
|
+
*/
|
|
575
|
+
function isSsnFormat(value) {
|
|
576
|
+
return SSN_PATTERN.test(value);
|
|
577
|
+
}
|
|
578
|
+
//#endregion
|
|
579
|
+
//#region src/internal/forms/rules/ssnFormat.ts
|
|
580
|
+
/**
|
|
581
|
+
* `ssnFormat`: a US SSN, the value as typed. eKYC's own validator still
|
|
582
|
+
* requires both dashes; this follows the vocabulary.
|
|
583
|
+
*/
|
|
584
|
+
const ssnFormat = {
|
|
585
|
+
id: "ssnFormat",
|
|
586
|
+
test: (value) => isSsnFormat(value)
|
|
587
|
+
};
|
|
588
|
+
//#endregion
|
|
589
|
+
//#region src/internal/forms/rules/stripSeparators.ts
|
|
590
|
+
/**
|
|
591
|
+
* `stripSeparators`: removes spaces, `-`, `.` and `/`, or the characters in
|
|
592
|
+
* `chars`. "Spaces" means any whitespace, as eKYC's input format reads it.
|
|
593
|
+
*/
|
|
594
|
+
const stripSeparators = {
|
|
595
|
+
id: "stripSeparators",
|
|
596
|
+
apply: (value, params) => {
|
|
597
|
+
if (typeof params.chars !== "string") return value.replace(/[\s./-]/g, "");
|
|
598
|
+
const remove = new Set(params.chars);
|
|
599
|
+
return [...value].filter((char) => !remove.has(char)).join("");
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
//#endregion
|
|
603
|
+
//#region src/internal/forms/rules/uppercase.ts
|
|
604
|
+
/** `uppercase`: converts letters to uppercase, over Unicode code points. */
|
|
605
|
+
const uppercase = {
|
|
606
|
+
id: "uppercase",
|
|
607
|
+
apply: (value) => value.toUpperCase()
|
|
608
|
+
};
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/internal/forms/rules/index.ts
|
|
611
|
+
/** Every vocabulary rule, in vocabulary order. */
|
|
612
|
+
const STANDARD_RULES = [
|
|
613
|
+
ssnFormat,
|
|
614
|
+
cpf,
|
|
615
|
+
cnpj,
|
|
616
|
+
postalCodeFormat,
|
|
617
|
+
phoneFormat,
|
|
618
|
+
emailFormat,
|
|
619
|
+
noPoBox,
|
|
620
|
+
exactLength,
|
|
621
|
+
nameCharacters,
|
|
622
|
+
notFuture,
|
|
623
|
+
maxAge,
|
|
624
|
+
digitCount,
|
|
625
|
+
allowedCharacters,
|
|
626
|
+
charTemplate,
|
|
627
|
+
numericRange,
|
|
628
|
+
rut,
|
|
629
|
+
esDni,
|
|
630
|
+
fiPersonalIdentityCode,
|
|
631
|
+
inDrivingLicenseNumber,
|
|
632
|
+
curp,
|
|
633
|
+
phoneDigits
|
|
634
|
+
];
|
|
635
|
+
/** Every vocabulary transform, in vocabulary order. */
|
|
636
|
+
const STANDARD_TRANSFORMS = [
|
|
637
|
+
uppercase,
|
|
638
|
+
stripSeparators,
|
|
639
|
+
e164,
|
|
640
|
+
trim,
|
|
641
|
+
nationalNumber,
|
|
642
|
+
e164NoPlus,
|
|
643
|
+
digitGroups
|
|
644
|
+
];
|
|
645
|
+
/** Every vocabulary group rule, in vocabulary order. */
|
|
646
|
+
const STANDARD_GROUP_RULES = [oneOfRequired, rulesByOption];
|
|
647
|
+
//#endregion
|
|
648
|
+
//#region src/shared/ruleMessages.ts
|
|
649
|
+
/**
|
|
650
|
+
* Each rule's default message, as the vocabulary gives it, for a registry
|
|
651
|
+
* that doesn't bundle the vocabulary (eKYC Pre-fill). Its own file, so only
|
|
652
|
+
* that registry's bundle carries it. A test pins it to the
|
|
653
|
+
* vocabulary. A rule with no default (`postalCodeFormat`, `digitCount`) gives
|
|
654
|
+
* its own message.
|
|
655
|
+
*/
|
|
656
|
+
const RULE_MESSAGES = {
|
|
657
|
+
ssnFormat: "verification.errors.ssnFormat",
|
|
658
|
+
cpf: "verification.errors.invalidTaxId",
|
|
659
|
+
cnpj: "ekyb.error.invalidTaxId",
|
|
660
|
+
phoneFormat: "verification.errors.phoneInvalid",
|
|
661
|
+
emailFormat: "verification.errors.emailInvalid",
|
|
662
|
+
noPoBox: "verification.errors.poBox",
|
|
663
|
+
exactLength: "verification.errors.exactly10Characters",
|
|
664
|
+
nameCharacters: "verification.errors.nameCharacters",
|
|
665
|
+
notFuture: "verification.errors.futureDate",
|
|
666
|
+
maxAge: "verification.errors.dateOfBirthMaxAge",
|
|
667
|
+
allowedCharacters: "verification.errors.invalidCharacters",
|
|
668
|
+
charTemplate: "verification.errors.invalidFormat",
|
|
669
|
+
numericRange: "verification.errors.numberBetween",
|
|
670
|
+
rut: "verification.errors.invalidIdNumber",
|
|
671
|
+
esDni: "verification.errors.invalidIdNumber",
|
|
672
|
+
fiPersonalIdentityCode: "verification.errors.invalidIdNumber",
|
|
673
|
+
inDrivingLicenseNumber: "verification.errors.invalidIdNumber",
|
|
674
|
+
curp: "verification.errors.invalidIdNumber",
|
|
675
|
+
phoneDigits: "verification.errors.phoneInvalid"
|
|
676
|
+
};
|
|
677
|
+
//#endregion
|
|
269
678
|
//#region src/modules/ekyc-prefill/ekycPrefillDefinition.ts
|
|
270
679
|
/**
|
|
271
680
|
* eKYC Pre-fill adapter for form definitions.
|
|
@@ -278,39 +687,65 @@ const digitGroups = {
|
|
|
278
687
|
* (`source`) and how it shows (`displayMode`). This adapter selects the
|
|
279
688
|
* definition and translates the configuration into a `ResolveContext`. It
|
|
280
689
|
* never changes the definition, so a definition the backend serves later
|
|
281
|
-
* takes the same path.
|
|
690
|
+
* takes the same path. Values are checked and the request is built by the
|
|
691
|
+
* kernel with the standard registry (`EKYC_PREFILL_REGISTRY`).
|
|
282
692
|
*/
|
|
283
693
|
const EKYC_PREFILL_MODULE = "ekycprefill";
|
|
284
|
-
/**
|
|
285
|
-
|
|
694
|
+
/**
|
|
695
|
+
* Every rule and transform the kernel implements, so a rule the Pre-fill
|
|
696
|
+
* catalog starts using needs no change here. It is the standard registry
|
|
697
|
+
* without the vocabulary in the bundle: the default messages, groups and
|
|
698
|
+
* version come from small tables a test pins to it.
|
|
699
|
+
*/
|
|
700
|
+
const EKYC_PREFILL_REGISTRY = createFormRegistry({
|
|
701
|
+
schemaVersions: [1],
|
|
702
|
+
vocabulary: "1.4",
|
|
703
|
+
kinds: [
|
|
704
|
+
"text",
|
|
705
|
+
"date",
|
|
706
|
+
"phone"
|
|
707
|
+
],
|
|
708
|
+
groups: [
|
|
709
|
+
"name",
|
|
710
|
+
"dateOfBirth",
|
|
711
|
+
"phone",
|
|
712
|
+
"ssn"
|
|
713
|
+
],
|
|
714
|
+
rules: STANDARD_RULES,
|
|
715
|
+
transforms: STANDARD_TRANSFORMS,
|
|
716
|
+
groupRules: STANDARD_GROUP_RULES,
|
|
717
|
+
messages: RULE_MESSAGES,
|
|
718
|
+
flags: ["payload.omitWhenEmpty"],
|
|
719
|
+
required: requiredError,
|
|
720
|
+
structure: STRUCTURE_MESSAGES
|
|
721
|
+
});
|
|
286
722
|
/**
|
|
287
723
|
* Typing formats (`input.format`) the module applies as the user types, with
|
|
288
724
|
* the kernel's implementations: the SSN's and the CPF's `digitGroups`.
|
|
289
725
|
*/
|
|
290
726
|
const EKYC_PREFILL_INPUT_FORMATS = /* @__PURE__ */ new Map([[digitGroups.id, digitGroups]]);
|
|
291
|
-
const ONE_OF_REQUIRED = "oneOfRequired";
|
|
727
|
+
const ONE_OF_REQUIRED$1 = "oneOfRequired";
|
|
292
728
|
/**
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
729
|
+
* A rule its environment can't check yet: `postalCodeFormat` needs the postal
|
|
730
|
+
* tables, which Pre-fill doesn't load (its env only has the phone rules).
|
|
731
|
+
* Left out of the supported ids, a definition that uses it is refused rather
|
|
732
|
+
* than checked by nothing.
|
|
733
|
+
*/
|
|
734
|
+
const NEEDS_UNLOADED_DEPS = /* @__PURE__ */ new Set(["postalCodeFormat"]);
|
|
735
|
+
/**
|
|
736
|
+
* The ids this build can render, validate and send: the registry's rules and
|
|
737
|
+
* transforms, and only what the form renders. It shows text, date and phone
|
|
738
|
+
* fields and one "at least one of" rule, with no option lists or conditions.
|
|
296
739
|
*/
|
|
297
740
|
const EKYC_PREFILL_SUPPORTED_IDS = {
|
|
298
|
-
|
|
299
|
-
|
|
741
|
+
...supportedIds(EKYC_PREFILL_REGISTRY),
|
|
742
|
+
rules: new Set([...EKYC_PREFILL_REGISTRY.rules.keys()].filter((id) => !NEEDS_UNLOADED_DEPS.has(id))),
|
|
300
743
|
kinds: /* @__PURE__ */ new Set([
|
|
301
744
|
"text",
|
|
302
745
|
"date",
|
|
303
746
|
"phone"
|
|
304
747
|
]),
|
|
305
|
-
|
|
306
|
-
"phone",
|
|
307
|
-
"dateOfBirth",
|
|
308
|
-
"ssn",
|
|
309
|
-
"name"
|
|
310
|
-
]),
|
|
311
|
-
rules: new Set(Object.keys(RULES)),
|
|
312
|
-
transforms: /* @__PURE__ */ new Set([...PAYLOAD_TRANSFORMS, ...EKYC_PREFILL_INPUT_FORMATS.keys()]),
|
|
313
|
-
groupRules: /* @__PURE__ */ new Set([ONE_OF_REQUIRED]),
|
|
748
|
+
groupRules: /* @__PURE__ */ new Set([ONE_OF_REQUIRED$1]),
|
|
314
749
|
optionLists: /* @__PURE__ */ new Set(),
|
|
315
750
|
conditions: /* @__PURE__ */ new Set(),
|
|
316
751
|
prefillSources: /* @__PURE__ */ new Set(),
|
|
@@ -318,8 +753,7 @@ const EKYC_PREFILL_SUPPORTED_IDS = {
|
|
|
318
753
|
};
|
|
319
754
|
/**
|
|
320
755
|
* Module configuration's value sources → the vocabulary's prefill origins
|
|
321
|
-
* (each origin's `configValues`).
|
|
322
|
-
* a test pins this table to it.
|
|
756
|
+
* (each origin's `configValues`). A test pins this table to the vocabulary.
|
|
323
757
|
*/
|
|
324
758
|
const PREFILL_ORIGINS = /* @__PURE__ */ new Map([
|
|
325
759
|
["userInput", "userInput"],
|
|
@@ -345,17 +779,16 @@ function selectEkycPrefillDefinition(source, country) {
|
|
|
345
779
|
}
|
|
346
780
|
const projectable = /* @__PURE__ */ new WeakMap();
|
|
347
781
|
/**
|
|
348
|
-
* Whether
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* one `oneOfRequired` rule (the form shows one "at least one of" message),
|
|
782
|
+
* Whether the form can render a definition: the supported ids, typing
|
|
783
|
+
* formats it applies, at most one `oneOfRequired` rule without message params
|
|
784
|
+
* (the form shows one "at least one of" hint and lists its members itself),
|
|
352
785
|
* and no collections.
|
|
353
786
|
*/
|
|
354
787
|
function isProjectableEkycPrefillDefinition(definition) {
|
|
355
788
|
let result = projectable.get(definition);
|
|
356
789
|
if (result === void 0) {
|
|
357
790
|
const groupRules = definition.groupRules ?? [];
|
|
358
|
-
result = definition.module === "ekycprefill" && checkSupport(definition, EKYC_PREFILL_SUPPORTED_IDS).supported && definition.fields.every((field) => (field.
|
|
791
|
+
result = definition.module === "ekycprefill" && checkSupport(definition, EKYC_PREFILL_SUPPORTED_IDS).supported && definition.fields.every((field) => (field.input?.format ?? []).every((format) => EKYC_PREFILL_INPUT_FORMATS.has(format.id))) && groupRules.length <= 1 && groupRules.every((rule) => rule.id === ONE_OF_REQUIRED$1 && !rule.message?.params) && !definition.collections?.length;
|
|
359
792
|
projectable.set(definition, result);
|
|
360
793
|
}
|
|
361
794
|
return result;
|
|
@@ -413,7 +846,7 @@ function ekycPrefillDrift(form, config) {
|
|
|
413
846
|
const servedRequired = sorted((config.fields ?? []).filter((field) => field.check && field.mandatory).map((field) => field.field).filter((name) => shown.has(name)));
|
|
414
847
|
const required = sorted(form.fields.filter((field) => field.required).map(({ field }) => field.name));
|
|
415
848
|
const servedAnyOf = sorted(config.requireAnyOf.filter((name) => shown.has(name)));
|
|
416
|
-
const anyOf = sorted(form.groupRules.filter(({ rule }) => rule.id === ONE_OF_REQUIRED).flatMap(({ fields }) => fields));
|
|
849
|
+
const anyOf = sorted(form.groupRules.filter(({ rule }) => rule.id === ONE_OF_REQUIRED$1).flatMap(({ fields }) => fields));
|
|
417
850
|
const lines = [];
|
|
418
851
|
if (listOf(servedRequired) !== listOf(required)) lines.push(`required: served ${listOf(servedRequired)}, definition ${listOf(required)}`);
|
|
419
852
|
if (listOf(servedAnyOf) !== listOf(anyOf)) lines.push(`at least one of: served ${listOf(servedAnyOf)}, definition ${listOf(anyOf)}`);
|
|
@@ -423,10 +856,11 @@ function ekycPrefillDrift(form, config) {
|
|
|
423
856
|
//#region src/modules/ekyc-prefill/ekycPrefillFields.ts
|
|
424
857
|
/**
|
|
425
858
|
* eKYC Pre-fill on the forms kernel: selects the source's definition,
|
|
426
|
-
* resolves it against the served configuration
|
|
427
|
-
* `EkycPrefillFieldDef`s
|
|
428
|
-
*
|
|
429
|
-
*
|
|
859
|
+
* resolves it against the served configuration and projects it to
|
|
860
|
+
* `EkycPrefillFieldDef`s. Values are checked with the kernel's
|
|
861
|
+
* `validateForm` and the request body is the kernel's `buildPayload`, both
|
|
862
|
+
* with `EKYC_PREFILL_REGISTRY`. The resolved form never leaves this file, so
|
|
863
|
+
* no kernel type reaches the published `.d.ts`.
|
|
430
864
|
*/
|
|
431
865
|
const PHONE_INVALID_ERROR = { key: "verification.errors.phoneInvalid" };
|
|
432
866
|
/** Vocabulary autofill ids → HTML `autocomplete` tokens (WCAG 2.2 SC 1.3.5). */
|
|
@@ -448,10 +882,9 @@ const TYPES = {
|
|
|
448
882
|
date: "date",
|
|
449
883
|
phone: "phone"
|
|
450
884
|
};
|
|
451
|
-
|
|
885
|
+
const ONE_OF_REQUIRED = "oneOfRequired";
|
|
886
|
+
function projectField(resolved, displayMode) {
|
|
452
887
|
const { field, required, phoneLocked } = resolved;
|
|
453
|
-
const validation = required ? [{ type: "required" }] : [];
|
|
454
|
-
validation.push(...projectRules(field.rules ?? [], country, required));
|
|
455
888
|
const autoComplete = field.input?.autofill ? AUTOCOMPLETE[field.input.autofill] : void 0;
|
|
456
889
|
return {
|
|
457
890
|
name: field.name,
|
|
@@ -465,31 +898,36 @@ function projectField(resolved, country, displayMode) {
|
|
|
465
898
|
...displayMode === "readOnly" && { readonly: true },
|
|
466
899
|
...field.widget === "masked" && { masked: true },
|
|
467
900
|
...field.input?.keyboard === "numeric" && { numeric: true },
|
|
468
|
-
...autoComplete && { autoComplete }
|
|
469
|
-
validation
|
|
901
|
+
...autoComplete && { autoComplete }
|
|
470
902
|
};
|
|
471
903
|
}
|
|
472
|
-
/**
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
904
|
+
/**
|
|
905
|
+
* The form the kernel checks: only the rendered fields, and the "at least one
|
|
906
|
+
* of" rule over its rendered members. With one member left, that member is
|
|
907
|
+
* required instead, so it shows the usual asterisk and required message (CK1
|
|
908
|
+
* decision K13); with none, the rule goes. A copy: the definition and the
|
|
909
|
+
* resolved form are never changed.
|
|
910
|
+
*/
|
|
911
|
+
function requireLoneMember(form, rendered) {
|
|
912
|
+
const lone = /* @__PURE__ */ new Set();
|
|
913
|
+
const groupRules = form.groupRules.flatMap((groupRule) => {
|
|
914
|
+
const members = groupRule.fields.filter((name) => rendered.has(name));
|
|
915
|
+
if (groupRule.rule.id === ONE_OF_REQUIRED && members.length <= 1) {
|
|
916
|
+
for (const name of members) lone.add(name);
|
|
917
|
+
return [];
|
|
918
|
+
}
|
|
919
|
+
return [{
|
|
920
|
+
...groupRule,
|
|
921
|
+
fields: members
|
|
922
|
+
}];
|
|
923
|
+
});
|
|
479
924
|
return {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
...
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
name: field.name,
|
|
487
|
-
key: field.payload?.key ?? field.name,
|
|
488
|
-
transforms: (field.payload?.transforms ?? []).map((transform) => ({
|
|
489
|
-
id: transform.id,
|
|
490
|
-
...typeof transform.params?.chars === "string" && { chars: transform.params.chars }
|
|
491
|
-
}))
|
|
492
|
-
}))
|
|
925
|
+
...form,
|
|
926
|
+
fields: form.fields.filter(({ field }) => rendered.has(field.name)).map((resolved) => lone.has(resolved.field.name) ? {
|
|
927
|
+
...resolved,
|
|
928
|
+
required: true
|
|
929
|
+
} : resolved),
|
|
930
|
+
groupRules
|
|
493
931
|
};
|
|
494
932
|
}
|
|
495
933
|
const preparedForms = /* @__PURE__ */ new WeakMap();
|
|
@@ -521,6 +959,10 @@ const NO_PREFILL_CHECKS = {
|
|
|
521
959
|
function prepareEkycPrefillForm(config) {
|
|
522
960
|
return prepared(config)?.form;
|
|
523
961
|
}
|
|
962
|
+
/** What the kernel checks the form's values against. */
|
|
963
|
+
function ekycPrefillFormCheck(config) {
|
|
964
|
+
return prepared(config)?.check;
|
|
965
|
+
}
|
|
524
966
|
function prepare(config) {
|
|
525
967
|
const { country, source, fields } = config;
|
|
526
968
|
if (!fields || !country || !source) return void 0;
|
|
@@ -536,27 +978,36 @@ function prepare(config) {
|
|
|
536
978
|
console.warn(`[ekyc-prefill] ${definition.id} can't be rendered by this build`, support.supported ? [] : support.problems);
|
|
537
979
|
return;
|
|
538
980
|
}
|
|
539
|
-
const
|
|
540
|
-
for (const line of ekycPrefillDrift(
|
|
541
|
-
const { fields: prefilled } = resolvePrefill(
|
|
981
|
+
const resolved = resolveForm(definition, context);
|
|
982
|
+
for (const line of ekycPrefillDrift(resolved, config)) console.warn(`[ekyc-prefill] ${definition.id}: ${line}; the definition applies`);
|
|
983
|
+
const { fields: prefilled } = resolvePrefill(resolved, context, NO_VALUES, NO_PREFILL_CHECKS);
|
|
542
984
|
const rendered = prefilled.filter((field) => field.displayMode !== "hidden");
|
|
543
985
|
if (rendered.length === 0) return void 0;
|
|
544
|
-
const
|
|
986
|
+
const form = requireLoneMember(resolved, new Set(rendered.map(({ field }) => field.name)));
|
|
987
|
+
const required = new Set(form.fields.filter((field) => field.required).map(({ field }) => field.name));
|
|
545
988
|
const [anyOf] = form.groupRules;
|
|
546
|
-
const members = (anyOf?.fields ?? []).filter((name) => renderedNames.has(name));
|
|
547
|
-
const loneMember = members.length === 1 ? members[0] : void 0;
|
|
548
989
|
return {
|
|
549
990
|
form: {
|
|
550
991
|
country,
|
|
551
992
|
fields: rendered.map((field) => projectField({
|
|
552
993
|
...field,
|
|
553
|
-
required:
|
|
554
|
-
},
|
|
555
|
-
anyOf: anyOf &&
|
|
556
|
-
fields:
|
|
994
|
+
required: required.has(field.field.name)
|
|
995
|
+
}, field.displayMode)),
|
|
996
|
+
anyOf: anyOf && {
|
|
997
|
+
fields: [...anyOf.fields],
|
|
557
998
|
message: anyOf.rule.message?.key ?? anyOf.rule.id
|
|
558
|
-
}
|
|
559
|
-
|
|
999
|
+
}
|
|
1000
|
+
},
|
|
1001
|
+
check: {
|
|
1002
|
+
form,
|
|
1003
|
+
registry: EKYC_PREFILL_REGISTRY,
|
|
1004
|
+
env: () => ({
|
|
1005
|
+
country,
|
|
1006
|
+
today: getLocalIsoDate(),
|
|
1007
|
+
source,
|
|
1008
|
+
deps: phoneDeps()
|
|
1009
|
+
}),
|
|
1010
|
+
invalidFormatError: PHONE_INVALID_ERROR
|
|
560
1011
|
},
|
|
561
1012
|
fields: new Map(rendered.map(({ field }) => [field.name, field]))
|
|
562
1013
|
};
|
|
@@ -576,57 +1027,26 @@ function formatFieldValue(config, name, value) {
|
|
|
576
1027
|
deps: {}
|
|
577
1028
|
});
|
|
578
1029
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
name,
|
|
582
|
-
type,
|
|
583
|
-
label,
|
|
584
|
-
...displayLabel && { displayLabel },
|
|
585
|
-
required,
|
|
586
|
-
validation,
|
|
587
|
-
source: "user_input"
|
|
588
|
-
}));
|
|
589
|
-
/**
|
|
590
|
-
* A field's first failing rule. A phone the input itself reports as
|
|
591
|
-
* malformed fails as invalid.
|
|
592
|
-
*/
|
|
593
|
-
function validateField(prepared, values, name, invalidFormats = {}) {
|
|
594
|
-
const error = validateEkycField(values, name, asEkycFields(prepared.fields));
|
|
595
|
-
if (error) return error;
|
|
596
|
-
if (invalidFormats[name] && !isBlank(values[name])) return PHONE_INVALID_ERROR;
|
|
597
|
-
}
|
|
598
|
-
/** Every field's error. The "at least one of" rule is reported apart, by `isAnyOfMissing`. */
|
|
599
|
-
function validateForm(prepared, values, invalidFormats = {}) {
|
|
600
|
-
const errors = {};
|
|
601
|
-
for (const field of prepared.fields) {
|
|
602
|
-
const error = validateField(prepared, values, field.name, invalidFormats);
|
|
603
|
-
if (error) errors[field.name] = error;
|
|
604
|
-
}
|
|
605
|
-
return errors;
|
|
1030
|
+
/** The rendered field with this rule, such as the CPF's `cpf`. */
|
|
1031
|
+
function fieldWithRule(config, rule) {
|
|
1032
|
+
for (const [name, field] of prepared(config)?.fields ?? []) if (field.rules?.some((ref) => ref.id === rule)) return name;
|
|
606
1033
|
}
|
|
607
|
-
/** Whether
|
|
608
|
-
function
|
|
609
|
-
return
|
|
610
|
-
}
|
|
611
|
-
function stripChars(value, chars) {
|
|
612
|
-
const remove = new Set(chars ?? " -./");
|
|
613
|
-
return [...value].filter((char) => !remove.has(char)).join("");
|
|
1034
|
+
/** Whether a rendered field's request needs the phone rules (`e164`). */
|
|
1035
|
+
function needsPhoneRules(config) {
|
|
1036
|
+
return [...prepared(config)?.fields.values() ?? []].some((field) => field.payload?.transforms?.some((transform) => transform.id === "e164"));
|
|
614
1037
|
}
|
|
615
1038
|
/**
|
|
616
|
-
* The `POST /omni/externalVerification/ekyc-prefill` body: the
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
body[field.key] = value;
|
|
628
|
-
}
|
|
629
|
-
return body;
|
|
1039
|
+
* The `POST /omni/externalVerification/ekyc-prefill` body: the kernel's
|
|
1040
|
+
* request body for the rendered fields. Empty values are left out, each
|
|
1041
|
+
* value goes through its transforms (`trim`, `stripSeparators`, `e164`), then
|
|
1042
|
+
* the static and context keys.
|
|
1043
|
+
*/
|
|
1044
|
+
function buildEkycPrefillBody(config, values) {
|
|
1045
|
+
const check = prepared(config)?.check;
|
|
1046
|
+
if (!check) return {};
|
|
1047
|
+
const { body, problems } = buildPayload(check.form, values, check.registry, check.env());
|
|
1048
|
+
if (problems.length > 0) console.warn("[ekyc-prefill] Request body problems", problems);
|
|
1049
|
+
return { ...body };
|
|
630
1050
|
}
|
|
631
1051
|
//#endregion
|
|
632
1052
|
//#region src/modules/ekyc-prefill/ekycPrefillServices.ts
|
|
@@ -653,8 +1073,6 @@ const CPF_INVALID_KEY = "verification.errors.invalidTaxId";
|
|
|
653
1073
|
const requirePhoneRules = async () => {
|
|
654
1074
|
if (!await loadPhoneValidation()) throw new Error("Failed to load the phone validation rules");
|
|
655
1075
|
};
|
|
656
|
-
/** Only the `e164` transform needs the phone rules to build the body. */
|
|
657
|
-
const needsPhoneRules = (submit) => submit.fields.some((field) => field.transforms.some((transform) => transform.id === "e164"));
|
|
658
1076
|
/**
|
|
659
1077
|
* The HTTP and body statuses of a failed request. Read by shape rather than
|
|
660
1078
|
* `instanceof IncodeApiError`, so a test or story double reaches each branch.
|
|
@@ -680,8 +1098,8 @@ const ekycPrefillMachine = setup({
|
|
|
680
1098
|
if (input.hasPhone) await requirePhoneRules();
|
|
681
1099
|
}),
|
|
682
1100
|
submit: fromPromise(async ({ input, signal }) => {
|
|
683
|
-
if (needsPhoneRules(input.
|
|
684
|
-
return submitEkycPrefill(
|
|
1101
|
+
if (needsPhoneRules(input.config)) await requirePhoneRules();
|
|
1102
|
+
return submitEkycPrefill(buildEkycPrefillBody(input.config, input.values), signal);
|
|
685
1103
|
})
|
|
686
1104
|
},
|
|
687
1105
|
actions: {
|
|
@@ -697,56 +1115,41 @@ const ekycPrefillMachine = setup({
|
|
|
697
1115
|
}),
|
|
698
1116
|
setFieldValue: assign(({ context, event }) => {
|
|
699
1117
|
const { name, value, isValid } = event;
|
|
700
|
-
const
|
|
701
|
-
const
|
|
702
|
-
...context.values,
|
|
703
|
-
[name]: formatFieldValue(context.config, name, value)
|
|
704
|
-
};
|
|
705
|
-
const invalidFormats = { ...context.invalidFormats };
|
|
706
|
-
if (isValid === false) invalidFormats[name] = true;
|
|
707
|
-
else delete invalidFormats[name];
|
|
708
|
-
const errors = { ...context.errors };
|
|
709
|
-
delete errors[name];
|
|
1118
|
+
const formatted = formatFieldValue(context.config, name, value);
|
|
1119
|
+
const check = ekycPrefillFormCheck(context.config);
|
|
710
1120
|
return {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
1121
|
+
...check ? setFieldValue(context, {
|
|
1122
|
+
type: "SET_FIELD",
|
|
1123
|
+
name,
|
|
1124
|
+
value: formatted,
|
|
1125
|
+
isValid
|
|
1126
|
+
}, check) : { values: {
|
|
1127
|
+
...context.values,
|
|
1128
|
+
[name]: formatted
|
|
1129
|
+
} },
|
|
1130
|
+
submitError: void 0
|
|
716
1131
|
};
|
|
717
1132
|
}),
|
|
718
1133
|
validateOneField: assign(({ context, event }) => {
|
|
719
1134
|
const { name } = event;
|
|
720
|
-
const
|
|
721
|
-
|
|
722
|
-
const errors = { ...context.errors };
|
|
723
|
-
if (error) errors[name] = error;
|
|
724
|
-
else delete errors[name];
|
|
725
|
-
const leftEmptyMember = !!prepared.anyOf?.fields.includes(name) && isAnyOfMissing(prepared, context.values);
|
|
726
|
-
return {
|
|
727
|
-
errors,
|
|
728
|
-
anyOfError: context.anyOfError || leftEmptyMember
|
|
729
|
-
};
|
|
1135
|
+
const check = ekycPrefillFormCheck(context.config);
|
|
1136
|
+
return { errors: check ? validateFieldValue(context, name, check) : {} };
|
|
730
1137
|
}),
|
|
731
1138
|
validateAll: assign(({ context }) => {
|
|
732
|
-
const
|
|
733
|
-
return {
|
|
734
|
-
errors: validateForm(prepared, context.values, context.invalidFormats),
|
|
735
|
-
anyOfError: isAnyOfMissing(prepared, context.values)
|
|
736
|
-
};
|
|
1139
|
+
const check = ekycPrefillFormCheck(context.config);
|
|
1140
|
+
return { errors: check ? validateAllValues(context, check) : {} };
|
|
737
1141
|
}),
|
|
738
1142
|
applyRejection: assign(({ context, event }) => {
|
|
739
1143
|
const error = errorOf(event);
|
|
740
|
-
const
|
|
741
|
-
const names = prepared.fields.map((field) => field.name);
|
|
1144
|
+
const names = context.prepared.fields.map((field) => field.name);
|
|
742
1145
|
if (statusesOf(error).status === PHONE_REJECTED_STATUS && names.includes("phone")) return { errors: {
|
|
743
1146
|
...context.errors,
|
|
744
1147
|
phone: PHONE_INVALID_ERROR
|
|
745
1148
|
} };
|
|
746
|
-
const cpfField =
|
|
1149
|
+
const cpfField = fieldWithRule(context.config, "cpf");
|
|
747
1150
|
if (cpfField && names.length === 1) return { errors: {
|
|
748
1151
|
...context.errors,
|
|
749
|
-
[cpfField
|
|
1152
|
+
[cpfField]: { key: CPF_INVALID_KEY }
|
|
750
1153
|
} };
|
|
751
1154
|
return { submitError: SUBMIT_REJECTED_KEY };
|
|
752
1155
|
}),
|
|
@@ -767,7 +1170,7 @@ const ekycPrefillMachine = setup({
|
|
|
767
1170
|
phoneRulesFailed: ({ context }) => context.phoneRulesFailed,
|
|
768
1171
|
isAutoExecution: ({ context }) => context.config.autoExecution,
|
|
769
1172
|
canRender: ({ context }) => !!prepareEkycPrefillForm(context.config),
|
|
770
|
-
isValid: ({ context }) => Object.keys(context.errors).length === 0 &&
|
|
1173
|
+
isValid: ({ context }) => Object.keys(context.errors).length === 0 && !!context.prepared,
|
|
771
1174
|
isBadRequest: ({ event }) => httpStatusOf(errorOf(event)) === 400,
|
|
772
1175
|
isForbidden: ({ event }) => httpStatusOf(errorOf(event)) === 403,
|
|
773
1176
|
isLimitReached: ({ event }) => httpStatusOf(errorOf(event)) === 429
|
|
@@ -781,7 +1184,6 @@ const ekycPrefillMachine = setup({
|
|
|
781
1184
|
values: {},
|
|
782
1185
|
errors: {},
|
|
783
1186
|
invalidFormats: {},
|
|
784
|
-
anyOfError: false,
|
|
785
1187
|
phoneRulesLoaded: false,
|
|
786
1188
|
phoneRulesFailed: false,
|
|
787
1189
|
submitError: void 0,
|
|
@@ -833,7 +1235,7 @@ const ekycPrefillMachine = setup({
|
|
|
833
1235
|
id: "submit",
|
|
834
1236
|
src: "submit",
|
|
835
1237
|
input: ({ context }) => ({
|
|
836
|
-
|
|
1238
|
+
config: context.config,
|
|
837
1239
|
values: context.values
|
|
838
1240
|
}),
|
|
839
1241
|
onDone: { target: "finished" },
|
|
@@ -884,4 +1286,4 @@ const ekycPrefillMachine = setup({
|
|
|
884
1286
|
}
|
|
885
1287
|
});
|
|
886
1288
|
//#endregion
|
|
887
|
-
export {
|
|
1289
|
+
export { ekycPrefillFormCheck as n, toEkycPrefillConfig as r, ekycPrefillMachine as t };
|