@incodetech/core 0.0.0-dev-20260515-ec7243b → 0.0.0-dev-20260515-a07df20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ae-signature.d.ts +1 -1
- package/dist/consent.d.ts +47 -47
- package/dist/cpf-ocr.d.ts +17 -17
- package/dist/curp-validation.d.ts +75 -2
- package/dist/curp-validation.esm.js +13 -4
- package/dist/{curpValidationStateMachine-BN9UT3zL.esm.js → curpValidationStateMachine-CitWLr2c.esm.js} +221 -98
- package/dist/document-capture.d.ts +74 -74
- package/dist/document-upload.d.ts +43 -43
- package/dist/ekyb.esm.js +3 -3
- package/dist/{ekybStateMachine-De42Qutp.esm.js → ekybStateMachine-BihTKkNC.esm.js} +1 -1
- package/dist/electronic-signature.d.ts +1 -1
- package/dist/extensibility.esm.js +3 -3
- package/dist/flow.d.ts +2 -2
- package/dist/flow.esm.js +2 -2
- package/dist/{flowServices-BQMlQN1H.esm.js → flowServices-DZAOYIFW.esm.js} +1 -1
- package/dist/home.d.ts +10 -10
- package/dist/id-ocr.d.ts +52 -52
- package/dist/id-verification.d.ts +25 -25
- package/dist/id.esm.js +3 -3
- package/dist/{idCaptureManager-BOt9d3Fz.esm.js → idCaptureManager-Ch64CD8w.esm.js} +1 -1
- package/dist/{idCaptureStateMachine-DNXJkuyQ.esm.js → idCaptureStateMachine-KxWTQqcZ.esm.js} +1 -1
- package/dist/identity-reuse.d.ts +47 -47
- package/dist/{index-BHLL4aAw.d.ts → index-CNUtzsRO.d.ts} +119 -119
- package/dist/index.esm.js +2 -2
- package/dist/mandatory-consent.d.ts +50 -50
- package/dist/qe-signature.d.ts +1 -1
- package/dist/{session-g31RJBDt.esm.js → session-CONcSjo_.esm.js} +1 -1
- package/dist/session.esm.js +1 -1
- package/dist/{setup-DfIZcesP.esm.js → setup-BWHiqu6S.esm.js} +1 -1
- package/dist/wasm.esm.js +2 -2
- package/dist/workflow.d.ts +84 -84
- package/dist/workflow.esm.js +5 -5
- package/package.json +1 -1
|
@@ -2,54 +2,6 @@ import { t as api } from "./api-CESGtpbH.esm.js";
|
|
|
2
2
|
import { t as endpoints } from "./endpoints-CnN3SyDa.esm.js";
|
|
3
3
|
import { a as fromPromise, r as assign, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
|
|
4
4
|
|
|
5
|
-
//#region src/modules/curp-validation/curpFields.ts
|
|
6
|
-
/**
|
|
7
|
-
* Declarative schema for the CURP generation form.
|
|
8
|
-
*
|
|
9
|
-
* `secondLastName` is intentionally optional: many people in Mexico have
|
|
10
|
-
* only a single paternal surname.
|
|
11
|
-
*/
|
|
12
|
-
const GENERATE_CURP_FIELDS = [
|
|
13
|
-
{
|
|
14
|
-
key: "name",
|
|
15
|
-
labelKey: "curp.labels.firstName",
|
|
16
|
-
type: "text",
|
|
17
|
-
required: true,
|
|
18
|
-
autoComplete: "given-name"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
key: "firstLastName",
|
|
22
|
-
labelKey: "curp.labels.firstLast",
|
|
23
|
-
type: "text",
|
|
24
|
-
required: true
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
key: "secondLastName",
|
|
28
|
-
labelKey: "curp.labels.secondLast",
|
|
29
|
-
type: "text",
|
|
30
|
-
required: false
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
key: "gender",
|
|
34
|
-
labelKey: "curp.labels.genderV2",
|
|
35
|
-
type: "dropdown",
|
|
36
|
-
required: true
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
key: "birthDate",
|
|
40
|
-
labelKey: "curp.labels.dob",
|
|
41
|
-
type: "date",
|
|
42
|
-
required: true
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
key: "birthState",
|
|
46
|
-
labelKey: "curp.labels.birthState",
|
|
47
|
-
type: "dropdown",
|
|
48
|
-
required: true
|
|
49
|
-
}
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
5
|
//#region src/modules/curp-validation/curpValidationUtils.ts
|
|
54
6
|
const CURP_PATTERN = /^([A-Z][AEIOUX][A-Z]{2}\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])[HMX](?:AS|B[CS]|C[CLMSH]|D[FG]|G[TR]|HG|JC|M[CNS]|N[ETL]|OC|PL|Q[TR]|S[PLR]|T[CSL]|VZ|YN|ZS)[B-DF-HJ-NP-TV-Z]{3}[A-Z\d])(\d)$/;
|
|
55
7
|
const CURP_LENGTH = 18;
|
|
@@ -195,14 +147,6 @@ const mexicanStates = [
|
|
|
195
147
|
label: "Zacatecas"
|
|
196
148
|
}
|
|
197
149
|
];
|
|
198
|
-
/**
|
|
199
|
-
* Returns `true` when every required field of {@link GENERATE_CURP_FIELDS}
|
|
200
|
-
* has a non-empty value. Optional fields (e.g. `secondLastName`) are not
|
|
201
|
-
* checked.
|
|
202
|
-
*/
|
|
203
|
-
function isGenerateFormValid(form) {
|
|
204
|
-
return GENERATE_CURP_FIELDS.filter((f) => f.required).every((f) => Boolean(form[f.key]));
|
|
205
|
-
}
|
|
206
150
|
|
|
207
151
|
//#endregion
|
|
208
152
|
//#region src/modules/curp-validation/curpValidationServices.ts
|
|
@@ -230,6 +174,134 @@ async function addCurpV2(form, signal) {
|
|
|
230
174
|
return res.data;
|
|
231
175
|
}
|
|
232
176
|
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/modules/curp-validation/curpFields.ts
|
|
179
|
+
/**
|
|
180
|
+
* Declarative schema for the CURP generation form.
|
|
181
|
+
*
|
|
182
|
+
* `secondLastName` is intentionally optional: many people in Mexico have
|
|
183
|
+
* only a single paternal surname. It carries no validation rules.
|
|
184
|
+
*/
|
|
185
|
+
const GENERATE_CURP_FIELDS = [
|
|
186
|
+
{
|
|
187
|
+
key: "name",
|
|
188
|
+
labelKey: "curp.labels.firstName",
|
|
189
|
+
type: "text",
|
|
190
|
+
required: true,
|
|
191
|
+
autoComplete: "given-name",
|
|
192
|
+
validation: [{ type: "required" }]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
key: "firstLastName",
|
|
196
|
+
labelKey: "curp.labels.firstLast",
|
|
197
|
+
type: "text",
|
|
198
|
+
required: true,
|
|
199
|
+
validation: [{ type: "required" }]
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
key: "secondLastName",
|
|
203
|
+
labelKey: "curp.labels.secondLast",
|
|
204
|
+
type: "text",
|
|
205
|
+
required: false
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
key: "gender",
|
|
209
|
+
labelKey: "curp.labels.genderV2",
|
|
210
|
+
type: "dropdown",
|
|
211
|
+
required: true,
|
|
212
|
+
validation: [{ type: "required" }]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
key: "birthDate",
|
|
216
|
+
labelKey: "curp.labels.dob",
|
|
217
|
+
type: "date",
|
|
218
|
+
required: true,
|
|
219
|
+
validation: [{ type: "required" }]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
key: "birthState",
|
|
223
|
+
labelKey: "curp.labels.birthState",
|
|
224
|
+
type: "dropdown",
|
|
225
|
+
required: true,
|
|
226
|
+
validation: [{ type: "required" }]
|
|
227
|
+
}
|
|
228
|
+
];
|
|
229
|
+
/**
|
|
230
|
+
* Config for the single field on the CURP entry gateway screen.
|
|
231
|
+
*
|
|
232
|
+
* Validation contains only `curpFormat` — there is intentionally no
|
|
233
|
+
* `required` rule. The user can legitimately leave this field empty
|
|
234
|
+
* and use the "I don't have my CURP" button to switch to the Generate
|
|
235
|
+
* flow; surfacing a "required" error on blur of an empty field would
|
|
236
|
+
* be misleading.
|
|
237
|
+
*
|
|
238
|
+
* The Continue button on this screen is gated by a UI-level no-op guard
|
|
239
|
+
* (`curp.length === 0`) instead, which lives in `curpInput.tsx`.
|
|
240
|
+
*/
|
|
241
|
+
const ENTER_CURP_FIELD = {
|
|
242
|
+
key: "curp",
|
|
243
|
+
labelKey: "curp.placeholder.curp",
|
|
244
|
+
validation: [{ type: "curpFormat" }]
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/modules/curp-validation/curpValidators.ts
|
|
249
|
+
/**
|
|
250
|
+
* Registry of pure validator functions keyed by rule type.
|
|
251
|
+
*
|
|
252
|
+
* Each validator returns an i18n key when the value violates the rule,
|
|
253
|
+
* or `undefined` when the rule passes. Order of evaluation for a field
|
|
254
|
+
* is the order rules appear in that field's `validation` array; the
|
|
255
|
+
* first failing rule wins.
|
|
256
|
+
*/
|
|
257
|
+
const createValidators = () => ({
|
|
258
|
+
required: (value) => value.trim().length === 0 ? "curp.errors.fieldRequired" : void 0,
|
|
259
|
+
curpFormat: (value) => {
|
|
260
|
+
if (value.trim().length === 0) return void 0;
|
|
261
|
+
return isValidCurp(value) ? void 0 : "curp.errors.invalidCurpFormat";
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
const normalizeFieldValue = (value) => typeof value === "string" ? value : String(value ?? "");
|
|
265
|
+
const evaluateRules = (value, validation, validators) => {
|
|
266
|
+
if (!validation) return void 0;
|
|
267
|
+
for (const rule of validation) {
|
|
268
|
+
const error = validators[rule.type](value);
|
|
269
|
+
if (error) return error;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Runs every Generate-CURP field through its validation rules and returns
|
|
274
|
+
* a map of field-key → first failing i18n error key. Fields that pass are
|
|
275
|
+
* absent from the result. An empty object signals "no errors".
|
|
276
|
+
*/
|
|
277
|
+
const validateGenerateCurpForm = (data, fields) => {
|
|
278
|
+
const validators = createValidators();
|
|
279
|
+
return fields.reduce((errors, field) => {
|
|
280
|
+
const error = evaluateRules(normalizeFieldValue(data[field.key]), field.validation, validators);
|
|
281
|
+
if (error) errors[field.key] = error;
|
|
282
|
+
return errors;
|
|
283
|
+
}, {});
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Runs a single Generate-CURP field through its validation rules.
|
|
287
|
+
* Returns the first failing i18n error key, or `undefined`.
|
|
288
|
+
*/
|
|
289
|
+
const validateGenerateCurpField = (data, fieldKey, fields) => {
|
|
290
|
+
const field = fields.find((f) => f.key === fieldKey);
|
|
291
|
+
if (!field) return void 0;
|
|
292
|
+
const validators = createValidators();
|
|
293
|
+
return evaluateRules(normalizeFieldValue(data[fieldKey]), field.validation, validators);
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Runs the single CURP-entry field through its validation rules.
|
|
297
|
+
* Used by both the on-blur validator and the submit-click validator
|
|
298
|
+
* on the CURP entry gateway screen.
|
|
299
|
+
*/
|
|
300
|
+
const validateEnterCurpField = (curp, field = ENTER_CURP_FIELD) => {
|
|
301
|
+
const validators = createValidators();
|
|
302
|
+
return evaluateRules(normalizeFieldValue(curp), field.validation, validators);
|
|
303
|
+
};
|
|
304
|
+
|
|
233
305
|
//#endregion
|
|
234
306
|
//#region src/modules/curp-validation/curpValidationStateMachine.ts
|
|
235
307
|
const DEFAULT_GENERATE_FORM = {
|
|
@@ -240,6 +312,24 @@ const DEFAULT_GENERATE_FORM = {
|
|
|
240
312
|
birthDate: "",
|
|
241
313
|
birthState: ""
|
|
242
314
|
};
|
|
315
|
+
const removeKey = (errors, key) => {
|
|
316
|
+
if (!errors?.[key]) return errors;
|
|
317
|
+
const next = { ...errors };
|
|
318
|
+
delete next[key];
|
|
319
|
+
return Object.keys(next).length > 0 ? next : void 0;
|
|
320
|
+
};
|
|
321
|
+
const removeKeys = (errors, keys) => {
|
|
322
|
+
if (!errors) return void 0;
|
|
323
|
+
const next = { ...errors };
|
|
324
|
+
for (const key of keys) delete next[key];
|
|
325
|
+
return Object.keys(next).length > 0 ? next : void 0;
|
|
326
|
+
};
|
|
327
|
+
const upsertKey = (errors, key, message) => {
|
|
328
|
+
const next = { ...errors ?? {} };
|
|
329
|
+
if (message) next[key] = message;
|
|
330
|
+
else delete next[key];
|
|
331
|
+
return Object.keys(next).length > 0 ? next : void 0;
|
|
332
|
+
};
|
|
243
333
|
const curpValidationMachine = setup({
|
|
244
334
|
types: {
|
|
245
335
|
context: {},
|
|
@@ -259,36 +349,44 @@ const curpValidationMachine = setup({
|
|
|
259
349
|
},
|
|
260
350
|
actions: {
|
|
261
351
|
setCurpFromOcr: assign(({ event }) => {
|
|
262
|
-
|
|
263
|
-
return {
|
|
264
|
-
curp,
|
|
265
|
-
isValid: isValidCurp(curp)
|
|
266
|
-
};
|
|
352
|
+
return { curp: (event.output?.curp ?? "").toUpperCase() };
|
|
267
353
|
}),
|
|
268
354
|
setCurp: assign(({ event }) => {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
355
|
+
return { curp: event.curp.toUpperCase() };
|
|
356
|
+
}),
|
|
357
|
+
clearEnterCurpFieldError: assign(({ context }) => ({ enterCurpValidationErrors: removeKey(context.enterCurpValidationErrors, "curp") })),
|
|
358
|
+
validateEnterCurpFieldAction: assign(({ context }) => ({ enterCurpValidationErrors: upsertKey(context.enterCurpValidationErrors, "curp", validateEnterCurpField(context.curp)) })),
|
|
359
|
+
computeEnterCurpValidationResult: assign(({ context }) => {
|
|
360
|
+
const message = validateEnterCurpField(context.curp);
|
|
361
|
+
return { enterCurpValidationErrors: message ? { curp: message } : void 0 };
|
|
274
362
|
}),
|
|
363
|
+
resetEnterCurpValidationErrors: assign({ enterCurpValidationErrors: () => void 0 }),
|
|
275
364
|
setGenerateForm: assign(({ context, event }) => {
|
|
276
365
|
const e = event;
|
|
277
|
-
const form = {
|
|
278
|
-
...context.generateForm,
|
|
279
|
-
...e.form
|
|
280
|
-
};
|
|
281
366
|
return {
|
|
282
|
-
generateForm:
|
|
283
|
-
|
|
367
|
+
generateForm: {
|
|
368
|
+
...context.generateForm,
|
|
369
|
+
...e.form
|
|
370
|
+
},
|
|
371
|
+
generateCurpValidationErrors: removeKeys(context.generateCurpValidationErrors, Object.keys(e.form))
|
|
284
372
|
};
|
|
285
373
|
}),
|
|
374
|
+
validateGenerateCurpFieldAction: assign(({ context, event }) => {
|
|
375
|
+
if (event.type !== "VALIDATE_FIELD") return {};
|
|
376
|
+
if (event.field === "curp") return {};
|
|
377
|
+
const message = validateGenerateCurpField(context.generateForm, event.field, GENERATE_CURP_FIELDS);
|
|
378
|
+
return { generateCurpValidationErrors: upsertKey(context.generateCurpValidationErrors, event.field, message) };
|
|
379
|
+
}),
|
|
380
|
+
computeGenerateValidationResult: assign(({ context }) => {
|
|
381
|
+
const errors = validateGenerateCurpForm(context.generateForm, GENERATE_CURP_FIELDS);
|
|
382
|
+
return { generateCurpValidationErrors: Object.keys(errors).length > 0 ? errors : void 0 };
|
|
383
|
+
}),
|
|
384
|
+
resetGenerateCurpValidationErrors: assign({ generateCurpValidationErrors: () => void 0 }),
|
|
286
385
|
setGeneratedCurp: assign(({ event }) => {
|
|
287
386
|
const curp = event.output?.curp ?? "";
|
|
288
387
|
return {
|
|
289
388
|
generatedCurp: curp,
|
|
290
|
-
curp
|
|
291
|
-
isValid: isValidCurp(curp)
|
|
389
|
+
curp
|
|
292
390
|
};
|
|
293
391
|
}),
|
|
294
392
|
decrementRetries: assign(({ context }) => ({ retriesLeft: Math.max(0, context.retriesLeft - 1) })),
|
|
@@ -315,9 +413,8 @@ const curpValidationMachine = setup({
|
|
|
315
413
|
isVerifySuccess: ({ event }) => {
|
|
316
414
|
return event.output?.success === true;
|
|
317
415
|
},
|
|
318
|
-
|
|
319
|
-
isGenerateFormValidGuard: ({ context }) => context.
|
|
320
|
-
isValidCurpGuard: ({ context }) => context.isValid
|
|
416
|
+
shouldVerify: ({ context }) => context.curp.trim().length > 0 && Object.keys(context.enterCurpValidationErrors ?? {}).length === 0,
|
|
417
|
+
isGenerateFormValidGuard: ({ context }) => Object.keys(context.generateCurpValidationErrors ?? {}).length === 0
|
|
321
418
|
}
|
|
322
419
|
}).createMachine({
|
|
323
420
|
id: "curpValidation",
|
|
@@ -325,9 +422,7 @@ const curpValidationMachine = setup({
|
|
|
325
422
|
context: ({ input }) => ({
|
|
326
423
|
config: input.config,
|
|
327
424
|
curp: "",
|
|
328
|
-
isValid: false,
|
|
329
425
|
generateForm: { ...DEFAULT_GENERATE_FORM },
|
|
330
|
-
isGenerateFormValid: false,
|
|
331
426
|
retriesLeft: input.config.maxRetries ?? 1,
|
|
332
427
|
generatedCurp: void 0,
|
|
333
428
|
error: void 0,
|
|
@@ -354,18 +449,32 @@ const curpValidationMachine = setup({
|
|
|
354
449
|
},
|
|
355
450
|
on: { CLOSE: "closed" }
|
|
356
451
|
},
|
|
357
|
-
enterCurp: {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
452
|
+
enterCurp: {
|
|
453
|
+
entry: "resetEnterCurpValidationErrors",
|
|
454
|
+
initial: "inputting",
|
|
455
|
+
states: {
|
|
456
|
+
inputting: { on: {
|
|
457
|
+
SET_CURP: { actions: ["setCurp", "clearEnterCurpFieldError"] },
|
|
458
|
+
VALIDATE_FIELD: {
|
|
459
|
+
guard: ({ event }) => event.field === "curp",
|
|
460
|
+
actions: "validateEnterCurpFieldAction"
|
|
461
|
+
},
|
|
462
|
+
VERIFY: { target: "validatingVerify" },
|
|
463
|
+
SWITCH_TO_GENERATE: {
|
|
464
|
+
target: "#curpValidation.generateCurp",
|
|
465
|
+
actions: "setFromGenerate"
|
|
466
|
+
}
|
|
467
|
+
} },
|
|
468
|
+
validatingVerify: {
|
|
469
|
+
entry: "computeEnterCurpValidationResult",
|
|
470
|
+
always: [{
|
|
471
|
+
guard: "shouldVerify",
|
|
472
|
+
target: "#curpValidation.verifying"
|
|
473
|
+
}, { target: "inputting" }]
|
|
474
|
+
}
|
|
366
475
|
},
|
|
367
|
-
CLOSE: "closed"
|
|
368
|
-
}
|
|
476
|
+
on: { CLOSE: "#curpValidation.closed" }
|
|
477
|
+
},
|
|
369
478
|
verifying: {
|
|
370
479
|
invoke: {
|
|
371
480
|
id: "verifyCurp",
|
|
@@ -406,14 +515,28 @@ const curpValidationMachine = setup({
|
|
|
406
515
|
guard: ({ context }) => context.retriesLeft <= 0
|
|
407
516
|
}] }
|
|
408
517
|
},
|
|
409
|
-
generateCurp: {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
518
|
+
generateCurp: {
|
|
519
|
+
entry: "resetGenerateCurpValidationErrors",
|
|
520
|
+
initial: "inputting",
|
|
521
|
+
states: {
|
|
522
|
+
inputting: { on: {
|
|
523
|
+
SET_GENERATE_FORM: { actions: "setGenerateForm" },
|
|
524
|
+
VALIDATE_FIELD: {
|
|
525
|
+
guard: ({ event }) => event.field !== "curp",
|
|
526
|
+
actions: "validateGenerateCurpFieldAction"
|
|
527
|
+
},
|
|
528
|
+
GENERATE: { target: "validatingGenerate" }
|
|
529
|
+
} },
|
|
530
|
+
validatingGenerate: {
|
|
531
|
+
entry: "computeGenerateValidationResult",
|
|
532
|
+
always: [{
|
|
533
|
+
guard: "isGenerateFormValidGuard",
|
|
534
|
+
target: "#curpValidation.generating"
|
|
535
|
+
}, { target: "inputting" }]
|
|
536
|
+
}
|
|
414
537
|
},
|
|
415
|
-
CLOSE: "closed"
|
|
416
|
-
}
|
|
538
|
+
on: { CLOSE: "#curpValidation.closed" }
|
|
539
|
+
},
|
|
417
540
|
generating: {
|
|
418
541
|
invoke: {
|
|
419
542
|
id: "generateCurpActor",
|
|
@@ -469,4 +592,4 @@ const curpValidationMachine = setup({
|
|
|
469
592
|
});
|
|
470
593
|
|
|
471
594
|
//#endregion
|
|
472
|
-
export { mexicanStates as n, GENERATE_CURP_FIELDS as r, curpValidationMachine as t };
|
|
595
|
+
export { mexicanStates as i, ENTER_CURP_FIELD as n, GENERATE_CURP_FIELDS as r, curpValidationMachine as t };
|