@incodetech/core 0.0.0-dev-20261123-f3cecd0f → 0.0.0-dev-20261123-4e85f134

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.
Files changed (111) hide show
  1. package/dist/{FaceDetectionProvider-BI2xJOZi.esm.js → FaceDetectionProvider-CSiQ4_ay.esm.js} +4 -4
  2. package/dist/ae-signature.esm.js +1 -1
  3. package/dist/{apiError-Dxfixsln.esm.js → apiError-D8p92jfK.esm.js} +1 -1
  4. package/dist/authentication.d.ts +3 -3
  5. package/dist/authentication.esm.js +2 -2
  6. package/dist/{authenticationManager-BJElkTsj.d.ts → authenticationManager-CLG0PAw9.d.ts} +1 -1
  7. package/dist/{authenticationManager-BVx-rrQx.esm.js → authenticationManager-DzwIWNvb.esm.js} +3 -3
  8. package/dist/{authenticationStateMachine-Bi3xyJd8.esm.js → authenticationStateMachine-QgXVzF_L.esm.js} +3 -3
  9. package/dist/consent.d.ts +1 -1
  10. package/dist/{consentManager-Duzd8paN.d.ts → consentManager-Bx_osBME.d.ts} +9 -9
  11. package/dist/curp-validation.d.ts +1 -1
  12. package/dist/{curpValidationManager-CmL52FU8.d.ts → curpValidationManager-CA9w3fO6.d.ts} +1 -1
  13. package/dist/{deepsightCaptureConfig-Bp3ttC6f.esm.js → deepsightCaptureConfig-Bcrw2pFu.esm.js} +2 -2
  14. package/dist/{deepsightLoader-AlFo55X0.esm.js → deepsightLoader-DRDK4yts.esm.js} +4 -4
  15. package/dist/{desktopCameraElection-CNXGgnSo.esm.js → desktopCameraElection-BvPHvAA4.esm.js} +4 -4
  16. package/dist/document-capture.d.ts +1 -1
  17. package/dist/document-signature.esm.js +1 -1
  18. package/dist/{documentCaptureManager-DOgJTJ4F.d.ts → documentCaptureManager-DLWTqjUr.d.ts} +5 -5
  19. package/dist/{documentSignatureStateMachine-_51mBEGo.esm.js → documentSignatureStateMachine-PMOkZDCn.esm.js} +1 -1
  20. package/dist/dynamic-forms.esm.js +2 -2
  21. package/dist/{dynamicFormsManager-CmGK8Nmm.esm.js → dynamicFormsManager-BOQRxy_t.esm.js} +1 -1
  22. package/dist/{dynamicFormsStateMachine-BUzOuzaA.esm.js → dynamicFormsStateMachine-Bv8m-KhL.esm.js} +1 -1
  23. package/dist/ekyb.d.ts +1 -1
  24. package/dist/ekyb.esm.js +2 -2
  25. package/dist/{ekybManager-C49pcveL.esm.js → ekybManager-Dt7Z6NEX.esm.js} +1 -1
  26. package/dist/{ekybStateMachine-IWnhPTLm.esm.js → ekybStateMachine-DExt873D.esm.js} +1 -1
  27. package/dist/ekyc-prefill.d.ts +5 -4
  28. package/dist/ekyc-prefill.esm.js +2 -2
  29. package/dist/ekyc.esm.js +3 -3
  30. package/dist/{ekycManager-CsknO0Rw.esm.js → ekycManager-N2EAITDJ.esm.js} +1 -1
  31. package/dist/{ekycPrefillManager-ObAVm5GR.esm.js → ekycPrefillManager-B1i-Fgy-.esm.js} +1 -1
  32. package/dist/{ekycPrefillManager-C11D5yiF.d.ts → ekycPrefillManager-BzM-GMVT.d.ts} +6 -6
  33. package/dist/{ekycPrefillStateMachine-BoVSVydv.esm.js → ekycPrefillStateMachine-DlUZGMCd.esm.js} +333 -131
  34. package/dist/{ekycRules-BH_Ll_0A.esm.js → ekycRules-B7kUzSgu.esm.js} +117 -1
  35. package/dist/{ekycStateMachine-CJHaHgfD.esm.js → ekycStateMachine-1qQi52Ih.esm.js} +274 -361
  36. package/dist/{ekycUtils-DEvtEyBI.esm.js → ekycUtils-D4CwNG7Y.esm.js} +5 -3
  37. package/dist/electronic-signature.esm.js +1 -1
  38. package/dist/{electronicSignatureManager-BNxHsiOA.esm.js → electronicSignatureManager-YyQFeYTi.esm.js} +1 -1
  39. package/dist/extensibility.d.ts +14 -14
  40. package/dist/extensibility.esm.js +13 -13
  41. package/dist/{faceCaptureManagerFactory-CHqmyOjM.d.ts → faceCaptureManagerFactory-BNY7JNj3.d.ts} +3 -3
  42. package/dist/{faceCaptureManagerFactory-DlQAlE2f.esm.js → faceCaptureManagerFactory-BOu2eQns.esm.js} +2 -2
  43. package/dist/{faceCaptureSetup-B7RaB0_O.esm.js → faceCaptureSetup-CopYy5_O.esm.js} +7 -7
  44. package/dist/{feature-management-CfDygYqM.esm.js → feature-management-CGHalFcv.esm.js} +1 -1
  45. package/dist/feature-management.esm.js +1 -1
  46. package/dist/flow-events.d.ts +1 -1
  47. package/dist/flow.d.ts +5 -5
  48. package/dist/flow.esm.js +3 -3
  49. package/dist/{flowCompletionService-BBk66S3P.esm.js → flowCompletionService-BETSa4vN.esm.js} +1 -1
  50. package/dist/{flowServices-DtMnUqOb.esm.js → flowServices-Adu2JkFA.esm.js} +5 -5
  51. package/dist/geolocation.d.ts +1 -1
  52. package/dist/geolocation.esm.js +2 -2
  53. package/dist/{geolocationManager-Del2ddmt.d.ts → geolocationManager-CENrvxpK.d.ts} +1 -1
  54. package/dist/{geolocationManager-BiKEQCE2.esm.js → geolocationManager-CFSS2JSp.esm.js} +1 -1
  55. package/dist/{geolocationStateMachine-FtmVonRL.esm.js → geolocationStateMachine-yhJy-Oli.esm.js} +1 -1
  56. package/dist/home.d.ts +1 -1
  57. package/dist/id-ocr.d.ts +1 -1
  58. package/dist/id-ocr.esm.js +17 -1
  59. package/dist/id-selfie-flow.d.ts +1 -1
  60. package/dist/id-selfie-flow.esm.js +6 -6
  61. package/dist/id.d.ts +2 -2
  62. package/dist/id.esm.js +3 -3
  63. package/dist/{idCaptureManager-CgkQW3Xc.d.ts → idCaptureManager-DksvDJ5Y.d.ts} +2 -2
  64. package/dist/{idCaptureManager-ColRR6SE.esm.js → idCaptureManager-biMO4ti8.esm.js} +4 -4
  65. package/dist/{idCaptureServices-Bss4WmTf.esm.js → idCaptureServices-DsBCDgPq.esm.js} +2 -2
  66. package/dist/{idCaptureStateMachine-DZD2WfHO.esm.js → idCaptureStateMachine-DSVxM1sV.esm.js} +11 -11
  67. package/dist/{idOcrManager-C3BHGgSb.d.ts → idOcrManager-CNGVEZ7B.d.ts} +1 -1
  68. package/dist/identity-reuse.d.ts +1 -1
  69. package/dist/{identityReuseManager-CZ-qJ_Aa.d.ts → identityReuseManager-D_jiHp1n.d.ts} +4 -4
  70. package/dist/{index-CoePktWH.d.ts → index-BsqGSj_x.d.ts} +1 -1
  71. package/dist/index.esm.js +1 -1
  72. package/dist/kyb-checks.esm.js +2 -2
  73. package/dist/{kybChecksManager-BG31cWgX.esm.js → kybChecksManager-BELqX_Lm.esm.js} +1 -1
  74. package/dist/{kybChecksStateMachine-BmNu0IZs.esm.js → kybChecksStateMachine-DK41gj76.esm.js} +1 -1
  75. package/dist/mandatory-consent.d.ts +2 -2
  76. package/dist/{mandatoryConsentManager-kzr5kdc_.d.ts → mandatoryConsentManager-B4-gw9FV.d.ts} +10 -10
  77. package/dist/qe-signature.esm.js +1 -1
  78. package/dist/{recordingService-CAnEoIxy.esm.js → recordingService-C092bHW7.esm.js} +1 -1
  79. package/dist/{runChildModule-CYyC2Qsm.esm.js → runChildModule-BImyqF65.esm.js} +1 -1
  80. package/dist/{sdkVersion-CbYAyk-3.esm.js → sdkVersion-BGEzZXPX.esm.js} +1 -1
  81. package/dist/selfie.d.ts +3 -3
  82. package/dist/selfie.esm.js +7 -7
  83. package/dist/{selfieErrorUtils-DFZDaTym.esm.js → selfieErrorUtils-BbrtgKm7.esm.js} +1 -1
  84. package/dist/{selfieManager-DrBYj5kA.d.ts → selfieManager-CSxlf4Ls.d.ts} +1 -1
  85. package/dist/{selfieManager-ByE5lOdT.esm.js → selfieManager-Cdj5fjRN.esm.js} +3 -3
  86. package/dist/{selfieStateMachine-aApsBvH8.esm.js → selfieStateMachine-CAlutNlH.esm.js} +3 -3
  87. package/dist/{session-CjD_xiZa.esm.js → session-BlpaoMHX.esm.js} +4 -4
  88. package/dist/session.d.ts +1 -1
  89. package/dist/session.esm.js +4 -4
  90. package/dist/{sessionInitializer-B7b9nwEd.esm.js → sessionInitializer-DmGppDQX.esm.js} +4 -4
  91. package/dist/{setup-D6Gomd33.esm.js → setup-DA07nIIF.esm.js} +5 -5
  92. package/dist/trueSight-BAtlP0U8.esm.js +1 -0
  93. package/dist/{trueSightService-BHmpDnvW.esm.js → trueSightService-DSDSHENR.esm.js} +1 -1
  94. package/dist/{types-B-PIc0en.d.ts → types-Ct3OFmQs.d.ts} +25 -9
  95. package/dist/{types-DHpz4Y37.d.ts → types-CzoXVfgt.d.ts} +1 -1
  96. package/dist/{types-C1056-J1.d.ts → types-DQ2BSAKU.d.ts} +1 -1
  97. package/dist/types-DQACmFP1.d.ts +6 -0
  98. package/dist/{types-4Re9FSOw.d.ts → types-D_-0O9pg.d.ts} +1 -1
  99. package/dist/{types-CEGG70FK.d.ts → types-E4jPC3M2.d.ts} +1 -1
  100. package/dist/{types-b0l9b83G.d.ts → types-eMmhwENp.d.ts} +1 -1
  101. package/dist/video-selfie.d.ts +1 -1
  102. package/dist/video-selfie.esm.js +3 -3
  103. package/dist/{videoSelfieCameraWarmer-O-uRRcju.esm.js → videoSelfieCameraWarmer-DWrg6vQd.esm.js} +3 -3
  104. package/dist/{videoSelfieStepDetector-DC_Qh7qI.d.ts → videoSelfieStepDetector-Cu7EZdcz.d.ts} +2 -2
  105. package/dist/wasm.esm.js +1 -1
  106. package/dist/workflow.d.ts +1 -1
  107. package/dist/workflow.esm.js +19 -19
  108. package/package.json +1 -1
  109. package/dist/idOcrCpfUtils-D5Gwskxu.esm.js +0 -18
  110. package/dist/trueSight-CsGhFXTr.esm.js +0 -1
  111. package/dist/types-BtrJ5fkm.d.ts +0 -6
@@ -2,95 +2,14 @@ import { t as api, u as endpoints } from "./api-BNxrW8xK.esm.js";
2
2
  import { t as getPhoneValidation } from "./phoneValidation-OggtfjRt.esm.js";
3
3
  import { i as assign, t as setup } from "./xstate.esm-CIqUf_i6.esm.js";
4
4
  import { n as fromPromise } from "./xstate-actors.esm-BCcwgosu.esm.js";
5
- import { a as formatPhoneNational, c as oneOfRequiredErrorKey, i as cleanName, l as validateEkycField, n as projectRules, o as formatSSN, s as loadPhoneValidator, t as RULES, u as validateEkycForm } from "./ekycRules-BH_Ll_0A.esm.js";
5
+ import { c as formatSSN, d as validateEkycField, f as validateEkycForm, i as projectRules, l as loadPhoneValidator, n as isCount, o as cleanName, p as resolvePrefill, r as isProjectableRule, s as formatPhoneNational, t as RULES, u as oneOfRequiredErrorKey } from "./ekycRules-B7kUzSgu.esm.js";
6
6
  import { n as usStates, t as usStateOptions } from "./usStates-CwOQ2kAx.esm.js";
7
7
  import { a as getPostalCodeMaxLength, c as fillFromSuggestion, l as getStreetLevelErrorForSuggestion, n as formatPostalCode, t as createBundledDefinitionSource, u as keepSuggestionInOptions } from "./definitionSource-B-Z2EgJJ.esm.js";
8
8
  import { n as checkSupport, t as resolveForm } from "./resolveForm-DaaQSVWp.esm.js";
9
9
  import { n as searchAddress, r as isFormDefinitionsEnabled, t as debounceSearchActor } from "./addressSearch-BKlynuBr.esm.js";
10
- import { C as TAX_ID_SOURCES, S as STREET_SOURCES, _ as MIDDLE_NAME_SOURCES, a as getEKYCFields, b as POSTAL_CODE_SOURCES, c as resolveEkycSource, d as APARTMENT_SOURCES, f as CITY_SOURCES, g as HOUSE_NO_SOURCES, h as EMAIL_SOURCES, i as getEKYCDisplayModes, l as toEkycConfig, m as COUNTRY_SELECTOR_DISABLED_SOURCES, o as isFieldOptional, p as COUNTRY_CODE_OMITTED_SOURCES, r as getEKYCCountry, s as mapToEKYCvalue, t as EKYC_GROUP_KEYS, u as ADDRESS_STATE_SOURCES, v as NAME_SOURCES, w as VOCABULARY, x as STATE_CODE_HINTS, y as ONE_OF_REQUIRED_GROUPS } from "./ekycUtils-DEvtEyBI.esm.js";
10
+ import { C as TAX_ID_SOURCES, S as STREET_SOURCES, _ as MIDDLE_NAME_SOURCES, a as getEKYCFields, b as POSTAL_CODE_SOURCES, c as resolveEkycSource, d as APARTMENT_SOURCES, f as CITY_SOURCES, g as HOUSE_NO_SOURCES, h as EMAIL_SOURCES, i as getEKYCDisplayModes, l as toEkycConfig, m as COUNTRY_SELECTOR_DISABLED_SOURCES, o as isFieldOptional, p as COUNTRY_CODE_OMITTED_SOURCES, r as getEKYCCountry, s as mapToEKYCvalue, t as EKYC_GROUP_KEYS, u as ADDRESS_STATE_SOURCES, v as NAME_SOURCES, w as VOCABULARY, x as STATE_CODE_HINTS, y as ONE_OF_REQUIRED_GROUPS } from "./ekycUtils-D4CwNG7Y.esm.js";
11
11
  import { t as DateFormattingProvider } from "./DateFormattingProvider-DPq9zco-.esm.js";
12
12
  import { t as formatPhoneE164 } from "./phoneFormat-C3q0Ukh4.esm.js";
13
- //#region src/internal/forms/resolvePrefill.ts
14
- const DISPLAY_MODES = /* @__PURE__ */ new Set([
15
- "editable",
16
- "readOnly",
17
- "hidden"
18
- ]);
19
- const ONE_OF_REQUIRED = "oneOfRequired";
20
- const filled = (value) => value !== void 0 && value.trim() !== "";
21
- function configuredMode(context, group) {
22
- const mode = context.displayModes?.[group];
23
- return mode !== void 0 && DISPLAY_MODES.has(mode) ? mode : "editable";
24
- }
25
- /** The field's prefill source for its group's origin, if it lists one. */
26
- function sourceFor(field, context) {
27
- const origin = context.origins?.[field.group];
28
- if (!origin) return void 0;
29
- return field.prefill?.find((id) => id.startsWith(`${origin}.`));
30
- }
31
- /**
32
- * Decides each shown field's prefilled value and display mode, from the
33
- * resolved form, module configuration's origins and display modes, and the
34
- * values the module read. Pure and synchronous.
35
- *
36
- * A value that fails its field's checks is dropped. A group configured
37
- * `hidden` or `readOnly` becomes `editable` as a whole when one of its
38
- * required fields has no value, or when a `oneOfRequired` rule over it has
39
- * none, so the user can always complete the form. An optional field without
40
- * a value keeps its mode and sends nothing. An editable field filled from one
41
- * of the context's `lockingOrigins` shows read-only.
42
- */
43
- function resolvePrefill(form, context, data, checks) {
44
- const candidates = {};
45
- for (const { field } of form.fields) {
46
- const source = sourceFor(field, context);
47
- const raw = source ? data[source] : void 0;
48
- if (filled(raw)) candidates[field.name] = checks.format(field, raw);
49
- }
50
- const values = {};
51
- for (const { field } of form.fields) {
52
- const value = candidates[field.name];
53
- if (filled(value) && checks.isValid(field, value, candidates)) values[field.name] = value;
54
- }
55
- const isRequired = (resolved) => resolved.required || resolved.requiredIfFilled.some((name) => filled(values[name]));
56
- const promoted = /* @__PURE__ */ new Set();
57
- const promote = (group) => {
58
- if (configuredMode(context, group) !== "editable") promoted.add(group);
59
- };
60
- for (const resolved of form.fields) if (isRequired(resolved) && !filled(values[resolved.field.name])) promote(resolved.field.group);
61
- const groupOf = new Map(form.fields.map(({ field }) => [field.name, field.group]));
62
- for (const { rule, fields } of form.groupRules) {
63
- if (rule.id !== ONE_OF_REQUIRED) continue;
64
- if (fields.some((name) => filled(values[name]))) continue;
65
- for (const name of fields) {
66
- const group = groupOf.get(name);
67
- if (group) promote(group);
68
- }
69
- }
70
- return {
71
- fields: form.fields.map((resolved) => {
72
- const { group, name } = resolved.field;
73
- if (promoted.has(group)) return {
74
- ...resolved,
75
- displayMode: "editable",
76
- displayReason: "promoted"
77
- };
78
- const configured = configuredMode(context, group);
79
- const origin = context.origins?.[group];
80
- if (configured === "editable" && filled(values[name]) && origin !== void 0 && context.lockingOrigins?.includes(origin)) return {
81
- ...resolved,
82
- displayMode: "readOnly",
83
- displayReason: "locked"
84
- };
85
- return {
86
- ...resolved,
87
- displayMode: configured,
88
- displayReason: "configured"
89
- };
90
- }),
91
- values
92
- };
93
- }
94
13
  const brStateOptions = Object.values({
95
14
  AC: {
96
15
  code: "AC",
@@ -205,12 +124,124 @@ const brStateOptions = Object.values({
205
124
  label: state.name
206
125
  }));
207
126
  //#endregion
208
- //#region src/shared/validators/textRules.ts
209
- const CHARACTER_CLASSES = [
210
- "letter",
211
- "digit",
212
- "space"
213
- ];
127
+ //#region src/modules/ekyc/ekycPrefill.ts
128
+ /**
129
+ * eKYC prefill data for form definitions: turns the `ocr-data` and
130
+ * `otp-status` responses into values keyed by the vocabulary's prefill source
131
+ * ids (`document.firstName`, `phoneModule.phone`, …). The forms kernel then
132
+ * decides which of them a field uses and how it shows (`resolvePrefill`).
133
+ */
134
+ const dateFormatting = new DateFormattingProvider();
135
+ const fromSuggestion = (suggestion) => ({
136
+ street: suggestion.street,
137
+ houseNumber: suggestion.houseNumber,
138
+ city: suggestion.city,
139
+ state: suggestion.stateCode,
140
+ postalCode: suggestion.postalCode
141
+ });
142
+ const DRIVERS_LICENSE = "DriversLicense";
143
+ /** OCR sends some dates as epoch milliseconds in a string, such as `issuedAt`. */
144
+ const epochMs = (value) => typeof value === "string" && /^\d+$/.test(value) ? Number(value) : value;
145
+ const US_STATE_CODES = Object.fromEntries(Object.values(usStates).flatMap(({ code, name }) => [[code, code], [name.toUpperCase(), code]]));
146
+ /** A US state code or name as its code, such as `California` → `CA`. */
147
+ function usStateCode(value) {
148
+ return value ? US_STATE_CODES[value.trim().toUpperCase()] : void 0;
149
+ }
150
+ /**
151
+ * The first name and surname of a scanned document. Uses the OCR's
152
+ * `firstName` / `paternalLastName`. Only when OCR sent no name part at all does
153
+ * it split `fullName`, which is all some documents send (the Indian PAN card):
154
+ * the last word is the surname and the words before it the first name, so a
155
+ * middle name is kept. Any name part blocks the split, because the other
156
+ * sources still fill `middleName` / `maternalLastName` from those parts and a
157
+ * split would repeat them or replace a part OCR did send. A one-word
158
+ * `fullName` gives no surname.
159
+ */
160
+ function resolveOcrName(name) {
161
+ const firstName = name?.firstName?.trim() ?? "";
162
+ const surName = name?.paternalLastName?.trim() ?? "";
163
+ const hasNameParts = Boolean(firstName || surName || name?.middleName?.trim() || name?.maternalLastName?.trim());
164
+ const words = name?.fullName?.trim().split(/\s+/).filter(Boolean) ?? [];
165
+ if (hasNameParts || words.length < 2) return {
166
+ firstName,
167
+ surName
168
+ };
169
+ return {
170
+ firstName: words.slice(0, -1).join(" "),
171
+ surName: words[words.length - 1]
172
+ };
173
+ }
174
+ /** The proof-of-address statement address, whichever shape it came in. */
175
+ function statementAddress(ocr) {
176
+ const fromStatement = ocr.addressFromStatement;
177
+ const parsed = typeof fromStatement === "object" ? fromStatement : void 0;
178
+ const fields = ocr.addressFieldsFromStatement;
179
+ return {
180
+ label: parsed?.address ?? (typeof fromStatement === "string" ? fromStatement : void 0) ?? fields?.label,
181
+ street: parsed?.street ?? fields?.street,
182
+ houseNumber: parsed?.houseNumber ?? fields?.houseNumber,
183
+ city: parsed?.city ?? fields?.city,
184
+ state: parsed?.state ?? fields?.state,
185
+ postalCode: parsed?.postalCode ?? fields?.postalCode
186
+ };
187
+ }
188
+ /** The address search queries to try for each origin, in order. */
189
+ function prefillAddressQueries(ocr) {
190
+ if (!ocr) return {
191
+ document: [],
192
+ poa: []
193
+ };
194
+ const documentQueries = ocr.addressFields || ocr.checkedAddressBean ? [ocr.address, ocr.checkedAddress] : [];
195
+ return {
196
+ document: [...new Set(documentQueries.filter((q) => Boolean(q)))],
197
+ poa: [statementAddress(ocr).label].filter((q) => Boolean(q))
198
+ };
199
+ }
200
+ function addressEntries(origin, parts) {
201
+ return [
202
+ [`${origin}.street`, parts.street],
203
+ [`${origin}.houseNumber`, parts.houseNumber],
204
+ [`${origin}.city`, parts.city],
205
+ [`${origin}.state`, parts.state],
206
+ [`${origin}.postalCode`, parts.postalCode]
207
+ ];
208
+ }
209
+ /** Each prefill source id this module can fill, and how. */
210
+ const SOURCES = {
211
+ "document.firstName": (ocr) => resolveOcrName(ocr.name).firstName,
212
+ "document.middleName": (ocr) => ocr.name?.middleName,
213
+ "document.paternalLastName": (ocr) => resolveOcrName(ocr.name).surName,
214
+ "document.maternalLastName": (ocr) => ocr.name?.maternalLastName,
215
+ "document.birthDate": (ocr) => dateFormatting.utcToIsoDateString(ocr.birthDate),
216
+ "document.issueDate": (ocr) => dateFormatting.utcToIsoDateString(epochMs(ocr.issuedAt)),
217
+ "document.documentNumber": (ocr) => ocr.documentNumber,
218
+ "document.personalNumber": (ocr) => ocr.personalNumber,
219
+ "document.driversLicenseNumber": (ocr) => ocr.typeOfId === DRIVERS_LICENSE ? ocr.documentNumber : void 0,
220
+ "document.driversLicenseState": (ocr) => ocr.typeOfId === DRIVERS_LICENSE ? usStateCode(ocr.issuingState) : void 0,
221
+ "poa.firstName": (ocr) => ocr.poaName?.trim().split(/\s+/)[0],
222
+ "poa.lastName": (ocr) => ocr.poaName?.trim().split(/\s+/).slice(1).join(" ") || void 0,
223
+ "phoneModule.phone": (_ocr, otp) => otp.phone,
224
+ "emailModule.email": (_ocr, otp) => otp.email
225
+ };
226
+ const ADDRESS_SOURCES = [...addressEntries("document", {}), ...addressEntries("poa", {})].map(([id]) => id);
227
+ /** Every prefill source id eKYC can fill, for `EKYC_SUPPORTED_IDS`. */
228
+ const EKYC_PREFILL_SOURCES = [...Object.keys(SOURCES), ...ADDRESS_SOURCES];
229
+ /**
230
+ * The session's prefill values by source id. An address comes from its
231
+ * suggestion when one was found, otherwise from the OCR address fields.
232
+ */
233
+ function buildPrefillData(ocr, otp, matches = {}) {
234
+ const ocrData = ocr ?? {};
235
+ const otpData = otp ?? {};
236
+ const documentAddress = matches.document ? fromSuggestion(matches.document) : ocrData.addressFields ?? ocrData.checkedAddressBean ?? {};
237
+ const poaAddress = matches.poa ? fromSuggestion(matches.poa) : statementAddress(ocrData);
238
+ const entries = [
239
+ ...Object.entries(SOURCES).map(([id, read]) => [id, read(ocrData, otpData, matches)]),
240
+ ...addressEntries("document", documentAddress),
241
+ ...addressEntries("poa", poaAddress)
242
+ ];
243
+ return Object.fromEntries(entries.filter(([, value]) => Boolean(value)));
244
+ }
214
245
  //#endregion
215
246
  //#region ../form-definitions/generated/ekyc.ts
216
247
  const EKYC_DEFINITIONS = {
@@ -6997,250 +7028,6 @@ const caProvinceOptions = Object.values({
6997
7028
  value: province.code,
6998
7029
  label: province.name
6999
7030
  }));
7000
- const inStateOptions = Object.values({
7001
- AN: {
7002
- code: "AN",
7003
- name: "Andaman and Nicobar Islands"
7004
- },
7005
- AP: {
7006
- code: "AP",
7007
- name: "Andhra Pradesh"
7008
- },
7009
- AR: {
7010
- code: "AR",
7011
- name: "Arunachal Pradesh"
7012
- },
7013
- AS: {
7014
- code: "AS",
7015
- name: "Assam"
7016
- },
7017
- BR: {
7018
- code: "BR",
7019
- name: "Bihar"
7020
- },
7021
- CH: {
7022
- code: "CH",
7023
- name: "Chandigarh"
7024
- },
7025
- CT: {
7026
- code: "CT",
7027
- name: "Chhattisgarh"
7028
- },
7029
- DH: {
7030
- code: "DH",
7031
- name: "Dadra and Nagar Haveli and Daman and Diu"
7032
- },
7033
- DL: {
7034
- code: "DL",
7035
- name: "Delhi"
7036
- },
7037
- GA: {
7038
- code: "GA",
7039
- name: "Goa"
7040
- },
7041
- GJ: {
7042
- code: "GJ",
7043
- name: "Gujarat"
7044
- },
7045
- HR: {
7046
- code: "HR",
7047
- name: "Haryana"
7048
- },
7049
- HP: {
7050
- code: "HP",
7051
- name: "Himachal Pradesh"
7052
- },
7053
- JK: {
7054
- code: "JK",
7055
- name: "Jammu and Kashmir"
7056
- },
7057
- JH: {
7058
- code: "JH",
7059
- name: "Jharkhand"
7060
- },
7061
- KA: {
7062
- code: "KA",
7063
- name: "Karnataka"
7064
- },
7065
- KL: {
7066
- code: "KL",
7067
- name: "Kerala"
7068
- },
7069
- LA: {
7070
- code: "LA",
7071
- name: "Ladakh"
7072
- },
7073
- LD: {
7074
- code: "LD",
7075
- name: "Lakshadweep"
7076
- },
7077
- MP: {
7078
- code: "MP",
7079
- name: "Madhya Pradesh"
7080
- },
7081
- MH: {
7082
- code: "MH",
7083
- name: "Maharashtra"
7084
- },
7085
- MN: {
7086
- code: "MN",
7087
- name: "Manipur"
7088
- },
7089
- ML: {
7090
- code: "ML",
7091
- name: "Meghalaya"
7092
- },
7093
- MZ: {
7094
- code: "MZ",
7095
- name: "Mizoram"
7096
- },
7097
- NL: {
7098
- code: "NL",
7099
- name: "Nagaland"
7100
- },
7101
- OR: {
7102
- code: "OR",
7103
- name: "Odisha"
7104
- },
7105
- PY: {
7106
- code: "PY",
7107
- name: "Puducherry"
7108
- },
7109
- PB: {
7110
- code: "PB",
7111
- name: "Punjab"
7112
- },
7113
- RJ: {
7114
- code: "RJ",
7115
- name: "Rajasthan"
7116
- },
7117
- SK: {
7118
- code: "SK",
7119
- name: "Sikkim"
7120
- },
7121
- TN: {
7122
- code: "TN",
7123
- name: "Tamil Nadu"
7124
- },
7125
- TG: {
7126
- code: "TG",
7127
- name: "Telangana"
7128
- },
7129
- TR: {
7130
- code: "TR",
7131
- name: "Tripura"
7132
- },
7133
- UP: {
7134
- code: "UP",
7135
- name: "Uttar Pradesh"
7136
- },
7137
- UK: {
7138
- code: "UK",
7139
- name: "Uttarakhand"
7140
- },
7141
- WB: {
7142
- code: "WB",
7143
- name: "West Bengal"
7144
- }
7145
- }).map((state) => ({
7146
- value: state.code,
7147
- label: state.name
7148
- }));
7149
- //#endregion
7150
- //#region src/modules/ekyc/ekycPrefill.ts
7151
- /**
7152
- * eKYC prefill data for form definitions: turns the `ocr-data` and
7153
- * `otp-status` responses into values keyed by the vocabulary's prefill source
7154
- * ids (`document.firstName`, `phoneModule.phone`, …). The forms kernel then
7155
- * decides which of them a field uses and how it shows (`resolvePrefill`).
7156
- */
7157
- const dateFormatting = new DateFormattingProvider();
7158
- const fromSuggestion = (suggestion) => ({
7159
- street: suggestion.street,
7160
- houseNumber: suggestion.houseNumber,
7161
- city: suggestion.city,
7162
- state: suggestion.stateCode,
7163
- postalCode: suggestion.postalCode
7164
- });
7165
- const DRIVERS_LICENSE = "DriversLicense";
7166
- /** OCR sends some dates as epoch milliseconds in a string, such as `issuedAt`. */
7167
- const epochMs = (value) => typeof value === "string" && /^\d+$/.test(value) ? Number(value) : value;
7168
- const US_STATE_CODES = Object.fromEntries(Object.values(usStates).flatMap(({ code, name }) => [[code, code], [name.toUpperCase(), code]]));
7169
- /** A US state code or name as its code, such as `California` → `CA`. */
7170
- function usStateCode(value) {
7171
- return value ? US_STATE_CODES[value.trim().toUpperCase()] : void 0;
7172
- }
7173
- /** The proof-of-address statement address, whichever shape it came in. */
7174
- function statementAddress(ocr) {
7175
- const fromStatement = ocr.addressFromStatement;
7176
- const parsed = typeof fromStatement === "object" ? fromStatement : void 0;
7177
- const fields = ocr.addressFieldsFromStatement;
7178
- return {
7179
- label: parsed?.address ?? (typeof fromStatement === "string" ? fromStatement : void 0) ?? fields?.label,
7180
- street: parsed?.street ?? fields?.street,
7181
- houseNumber: parsed?.houseNumber ?? fields?.houseNumber,
7182
- city: parsed?.city ?? fields?.city,
7183
- state: parsed?.state ?? fields?.state,
7184
- postalCode: parsed?.postalCode ?? fields?.postalCode
7185
- };
7186
- }
7187
- /** The address search queries to try for each origin, in order. */
7188
- function prefillAddressQueries(ocr) {
7189
- if (!ocr) return {
7190
- document: [],
7191
- poa: []
7192
- };
7193
- const documentQueries = ocr.addressFields || ocr.checkedAddressBean ? [ocr.address, ocr.checkedAddress] : [];
7194
- return {
7195
- document: [...new Set(documentQueries.filter((q) => Boolean(q)))],
7196
- poa: [statementAddress(ocr).label].filter((q) => Boolean(q))
7197
- };
7198
- }
7199
- function addressEntries(origin, parts) {
7200
- return [
7201
- [`${origin}.street`, parts.street],
7202
- [`${origin}.houseNumber`, parts.houseNumber],
7203
- [`${origin}.city`, parts.city],
7204
- [`${origin}.state`, parts.state],
7205
- [`${origin}.postalCode`, parts.postalCode]
7206
- ];
7207
- }
7208
- /** Each prefill source id this module can fill, and how. */
7209
- const SOURCES = {
7210
- "document.firstName": (ocr) => ocr.name?.firstName,
7211
- "document.middleName": (ocr) => ocr.name?.middleName,
7212
- "document.paternalLastName": (ocr) => ocr.name?.paternalLastName,
7213
- "document.maternalLastName": (ocr) => ocr.name?.maternalLastName,
7214
- "document.birthDate": (ocr) => dateFormatting.utcToIsoDateString(ocr.birthDate),
7215
- "document.issueDate": (ocr) => dateFormatting.utcToIsoDateString(epochMs(ocr.issuedAt)),
7216
- "document.documentNumber": (ocr) => ocr.documentNumber,
7217
- "document.personalNumber": (ocr) => ocr.personalNumber,
7218
- "document.driversLicenseNumber": (ocr) => ocr.typeOfId === DRIVERS_LICENSE ? ocr.documentNumber : void 0,
7219
- "document.driversLicenseState": (ocr) => ocr.typeOfId === DRIVERS_LICENSE ? usStateCode(ocr.issuingState) : void 0,
7220
- "poa.firstName": (ocr) => ocr.poaName?.trim().split(/\s+/)[0],
7221
- "poa.lastName": (ocr) => ocr.poaName?.trim().split(/\s+/).slice(1).join(" ") || void 0,
7222
- "phoneModule.phone": (_ocr, otp) => otp.phone,
7223
- "emailModule.email": (_ocr, otp) => otp.email
7224
- };
7225
- const ADDRESS_SOURCES = [...addressEntries("document", {}), ...addressEntries("poa", {})].map(([id]) => id);
7226
- /** Every prefill source id eKYC can fill, for `EKYC_SUPPORTED_IDS`. */
7227
- const EKYC_PREFILL_SOURCES = [...Object.keys(SOURCES), ...ADDRESS_SOURCES];
7228
- /**
7229
- * The session's prefill values by source id. An address comes from its
7230
- * suggestion when one was found, otherwise from the OCR address fields.
7231
- */
7232
- function buildPrefillData(ocr, otp, matches = {}) {
7233
- const ocrData = ocr ?? {};
7234
- const otpData = otp ?? {};
7235
- const documentAddress = matches.document ? fromSuggestion(matches.document) : ocrData.addressFields ?? ocrData.checkedAddressBean ?? {};
7236
- const poaAddress = matches.poa ? fromSuggestion(matches.poa) : statementAddress(ocrData);
7237
- const entries = [
7238
- ...Object.entries(SOURCES).map(([id, read]) => [id, read(ocrData, otpData, matches)]),
7239
- ...addressEntries("document", documentAddress),
7240
- ...addressEntries("poa", poaAddress)
7241
- ];
7242
- return Object.fromEntries(entries.filter(([, value]) => Boolean(value)));
7243
- }
7244
7031
  //#endregion
7245
7032
  //#region src/modules/ekyc/ekycForm.ts
7246
7033
  /**
@@ -7261,7 +7048,155 @@ function buildPrefillData(ocr, otp, matches = {}) {
7261
7048
  const OPTION_LISTS = {
7262
7049
  US_STATES: usStateOptions,
7263
7050
  BR_STATES: brStateOptions,
7264
- IN_STATES: inStateOptions,
7051
+ IN_STATES: Object.values({
7052
+ AN: {
7053
+ code: "AN",
7054
+ name: "Andaman and Nicobar Islands"
7055
+ },
7056
+ AP: {
7057
+ code: "AP",
7058
+ name: "Andhra Pradesh"
7059
+ },
7060
+ AR: {
7061
+ code: "AR",
7062
+ name: "Arunachal Pradesh"
7063
+ },
7064
+ AS: {
7065
+ code: "AS",
7066
+ name: "Assam"
7067
+ },
7068
+ BR: {
7069
+ code: "BR",
7070
+ name: "Bihar"
7071
+ },
7072
+ CH: {
7073
+ code: "CH",
7074
+ name: "Chandigarh"
7075
+ },
7076
+ CT: {
7077
+ code: "CT",
7078
+ name: "Chhattisgarh"
7079
+ },
7080
+ DH: {
7081
+ code: "DH",
7082
+ name: "Dadra and Nagar Haveli and Daman and Diu"
7083
+ },
7084
+ DL: {
7085
+ code: "DL",
7086
+ name: "Delhi"
7087
+ },
7088
+ GA: {
7089
+ code: "GA",
7090
+ name: "Goa"
7091
+ },
7092
+ GJ: {
7093
+ code: "GJ",
7094
+ name: "Gujarat"
7095
+ },
7096
+ HR: {
7097
+ code: "HR",
7098
+ name: "Haryana"
7099
+ },
7100
+ HP: {
7101
+ code: "HP",
7102
+ name: "Himachal Pradesh"
7103
+ },
7104
+ JK: {
7105
+ code: "JK",
7106
+ name: "Jammu and Kashmir"
7107
+ },
7108
+ JH: {
7109
+ code: "JH",
7110
+ name: "Jharkhand"
7111
+ },
7112
+ KA: {
7113
+ code: "KA",
7114
+ name: "Karnataka"
7115
+ },
7116
+ KL: {
7117
+ code: "KL",
7118
+ name: "Kerala"
7119
+ },
7120
+ LA: {
7121
+ code: "LA",
7122
+ name: "Ladakh"
7123
+ },
7124
+ LD: {
7125
+ code: "LD",
7126
+ name: "Lakshadweep"
7127
+ },
7128
+ MP: {
7129
+ code: "MP",
7130
+ name: "Madhya Pradesh"
7131
+ },
7132
+ MH: {
7133
+ code: "MH",
7134
+ name: "Maharashtra"
7135
+ },
7136
+ MN: {
7137
+ code: "MN",
7138
+ name: "Manipur"
7139
+ },
7140
+ ML: {
7141
+ code: "ML",
7142
+ name: "Meghalaya"
7143
+ },
7144
+ MZ: {
7145
+ code: "MZ",
7146
+ name: "Mizoram"
7147
+ },
7148
+ NL: {
7149
+ code: "NL",
7150
+ name: "Nagaland"
7151
+ },
7152
+ OR: {
7153
+ code: "OR",
7154
+ name: "Odisha"
7155
+ },
7156
+ PY: {
7157
+ code: "PY",
7158
+ name: "Puducherry"
7159
+ },
7160
+ PB: {
7161
+ code: "PB",
7162
+ name: "Punjab"
7163
+ },
7164
+ RJ: {
7165
+ code: "RJ",
7166
+ name: "Rajasthan"
7167
+ },
7168
+ SK: {
7169
+ code: "SK",
7170
+ name: "Sikkim"
7171
+ },
7172
+ TN: {
7173
+ code: "TN",
7174
+ name: "Tamil Nadu"
7175
+ },
7176
+ TG: {
7177
+ code: "TG",
7178
+ name: "Telangana"
7179
+ },
7180
+ TR: {
7181
+ code: "TR",
7182
+ name: "Tripura"
7183
+ },
7184
+ UP: {
7185
+ code: "UP",
7186
+ name: "Uttar Pradesh"
7187
+ },
7188
+ UK: {
7189
+ code: "UK",
7190
+ name: "Uttarakhand"
7191
+ },
7192
+ WB: {
7193
+ code: "WB",
7194
+ name: "West Bengal"
7195
+ }
7196
+ }).map((state) => ({
7197
+ value: state.code,
7198
+ label: state.name
7199
+ })),
7265
7200
  CA_PROVINCES: caProvinceOptions,
7266
7201
  PH_ID_TYPES: [
7267
7202
  {
@@ -7278,25 +7213,6 @@ const OPTION_LISTS = {
7278
7213
  }
7279
7214
  ]
7280
7215
  };
7281
- const isCount = (value) => typeof value === "number" && Number.isInteger(value) && value > 0;
7282
- const isInteger = (value) => typeof value === "number" && Number.isInteger(value);
7283
- const isNonEmptyArrayOf = (value, item) => Array.isArray(value) && value.length > 0 && value.every(item);
7284
- const isString = (value) => typeof value === "string";
7285
- const isCharacterClass = (value) => CHARACTER_CLASSES.includes(value);
7286
- /**
7287
- * Params a projected rule reads. The compiler checks params against the
7288
- * vocabulary too; this keeps a definition that skipped it, such as a served
7289
- * one later, from projecting a broken rule.
7290
- */
7291
- const RULE_PARAMS = {
7292
- exactLength: ({ length }) => isCount(length),
7293
- phoneDigits: ({ min, max }) => isCount(min) && isCount(max) && min <= max,
7294
- digitCount: ({ lengths, min, max }) => lengths !== void 0 ? isNonEmptyArrayOf(lengths, isCount) && min === void 0 && max === void 0 : isCount(min) && isCount(max) && min <= max,
7295
- allowedCharacters: ({ classes, extra }) => isNonEmptyArrayOf(classes, isCharacterClass) && (extra === void 0 || isString(extra)),
7296
- charTemplate: ({ templates, ignoreCase }) => isNonEmptyArrayOf(templates, (t) => isString(t) && t !== "") && (ignoreCase === void 0 || typeof ignoreCase === "boolean"),
7297
- numericRange: ({ min, max }) => isInteger(min) && isInteger(max) && min <= max,
7298
- maxAge: ({ years }) => isCount(years)
7299
- };
7300
7216
  /**
7301
7217
  * What the projection can express today. Request-body transforms are listed
7302
7218
  * because `buildSubmitPayload` already applies them, on the fields
@@ -7407,10 +7323,6 @@ function phoneFormatOf(field) {
7407
7323
  * this cache; key it by definition id and version then.
7408
7324
  */
7409
7325
  const projectable = /* @__PURE__ */ new WeakMap();
7410
- /** Whether a field rule maps onto a validator: known, valid params, no message. */
7411
- function isProjectableRule(rule) {
7412
- return Object.prototype.hasOwnProperty.call(RULES, rule.id) && plainKey(rule.message) && (RULE_PARAMS[rule.id]?.(rule.params ?? {}) ?? true);
7413
- }
7414
7326
  /**
7415
7327
  * `oneOfRequired` shows its own message key, or today's DOB-or-SSN message
7416
7328
  * when it has none, which only fits date of birth and SSN.
@@ -7789,12 +7701,13 @@ function applyPrefill(fields, ocrData, otpStatus, _country) {
7789
7701
  const readonlyFields = [];
7790
7702
  let hideEmail = false;
7791
7703
  if (fields.name === "document_scan" && ocrData?.name) {
7792
- if (ocrData.name.firstName) {
7793
- values.firstName = ocrData.name.firstName;
7704
+ const { firstName, surName } = resolveOcrName(ocrData.name);
7705
+ if (firstName) {
7706
+ values.firstName = firstName;
7794
7707
  prefilled.firstName = true;
7795
7708
  }
7796
- if (ocrData.name.paternalLastName) {
7797
- values.surName = ocrData.name.paternalLastName;
7709
+ if (surName) {
7710
+ values.surName = surName;
7798
7711
  prefilled.surName = true;
7799
7712
  }
7800
7713
  if (ocrData.name.middleName) {