@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
@@ -1,23 +1,40 @@
1
+ import { t as getLocalIsoDate } from "./IBrowserEnvironmentCapability-D7JG7ML3.esm.js";
1
2
  import { t as api, u as endpoints } from "./api-BNxrW8xK.esm.js";
2
- import { i as toIncodeApiError } from "./apiError-Dxfixsln.esm.js";
3
+ import { i as toIncodeApiError } from "./apiError-D8p92jfK.esm.js";
3
4
  import { n as loadPhoneValidation } from "./phoneValidation-OggtfjRt.esm.js";
4
5
  import { i as assign, t as setup } from "./xstate.esm-CIqUf_i6.esm.js";
5
6
  import { n as fromPromise } from "./xstate-actors.esm-BCcwgosu.esm.js";
6
- import { i as cleanName, l as validateEkycField, n as projectRules, o as formatSSN } from "./ekycRules-BH_Ll_0A.esm.js";
7
+ import { d as validateEkycField, i as projectRules, p as resolvePrefill, r as isProjectableRule, t as RULES } from "./ekycRules-B7kUzSgu.esm.js";
7
8
  import { t as createBundledDefinitionSource } from "./definitionSource-B-Z2EgJJ.esm.js";
8
9
  import { n as checkSupport, t as resolveForm } from "./resolveForm-DaaQSVWp.esm.js";
9
10
  import { t as formatPhoneE164 } from "./phoneFormat-C3q0Ukh4.esm.js";
10
- import { t as formatCPF } from "./idOcrCpfUtils-D5Gwskxu.esm.js";
11
+ //#region src/internal/forms/formatValue.ts
12
+ /**
13
+ * A typed or prefilled value after the field's input formats
14
+ * (`input.format`), in order. Formats the registry doesn't implement are
15
+ * skipped: call `checkSupport` first for a definition that wasn't bundled.
16
+ * Only the registry's transforms are read, so a module that formats but
17
+ * doesn't validate with the kernel yet can pass just those.
18
+ */
19
+ function formatValue(field, value, registry, env) {
20
+ return (field.input?.format ?? []).reduce((formatted, ref) => {
21
+ const transform = registry.transforms.get(ref.id);
22
+ return transform ? transform.apply(formatted, ref.params ?? {}, env) : formatted;
23
+ }, value);
24
+ }
25
+ //#endregion
11
26
  //#region src/modules/ekyc-prefill/ekycPrefillConfig.ts
12
27
  const isString = (value) => typeof value === "string" && value !== "";
13
28
  function toConfigField(raw) {
14
29
  if (typeof raw !== "object" || raw === null) return void 0;
15
- const { field, check, mandatory } = raw;
30
+ const { field, check, mandatory, source, displayMode } = raw;
16
31
  if (!isString(field)) return void 0;
17
32
  return {
18
33
  field,
19
34
  check: check === true,
20
- mandatory: mandatory === true
35
+ mandatory: mandatory === true,
36
+ ...isString(source) && { source },
37
+ ...isString(displayMode) && { displayMode }
21
38
  };
22
39
  }
23
40
  /**
@@ -28,7 +45,8 @@ function toConfigField(raw) {
28
45
  * check hides the field.
29
46
  * - `fields` stays `undefined` when the configuration has no `fields` array:
30
47
  * the flat dashboard shape, which the module can't render.
31
- * - `source`, `displayMode` and other per-field keys are dropped.
48
+ * - A field's `source` and `displayMode` are kept when served as non-empty
49
+ * strings; other per-field keys are dropped.
32
50
  */
33
51
  function toEkycPrefillConfig(raw) {
34
52
  const config = raw ?? {};
@@ -45,16 +63,18 @@ function toEkycPrefillConfig(raw) {
45
63
  //#endregion
46
64
  //#region ../form-definitions/generated/ekycprefill.ts
47
65
  const EKYCPREFILL_DEFINITIONS = {
48
- "ekycprefill/BR": {
66
+ "ekycprefill/BR/BR_PREFILL": {
49
67
  schemaVersion: 1,
50
- vocabulary: "1.0",
51
- id: "ekycprefill/BR",
68
+ vocabulary: "1.4",
69
+ id: "ekycprefill/BR/BR_PREFILL",
52
70
  module: "ekycprefill",
53
71
  country: "BR",
72
+ source: "BR_PREFILL",
54
73
  fields: [{
55
74
  name: "taxIdNumber",
56
75
  kind: "text",
57
76
  group: "ssn",
77
+ required: true,
58
78
  label: { key: "verification.labels.taxId" },
59
79
  displayLabel: {
60
80
  key: "verification.labels.cpf",
@@ -62,7 +82,24 @@ const EKYCPREFILL_DEFINITIONS = {
62
82
  },
63
83
  input: {
64
84
  maxLength: 14,
65
- keyboard: "numeric"
85
+ keyboard: "numeric",
86
+ format: [{
87
+ id: "digitGroups",
88
+ params: {
89
+ groups: [
90
+ 3,
91
+ 3,
92
+ 3,
93
+ 2
94
+ ],
95
+ separator: ".",
96
+ separators: [
97
+ ".",
98
+ ".",
99
+ "-"
100
+ ]
101
+ }
102
+ }]
66
103
  },
67
104
  rules: [{ id: "cpf" }],
68
105
  payload: { transforms: [{
@@ -72,20 +109,25 @@ const EKYCPREFILL_DEFINITIONS = {
72
109
  }],
73
110
  submit: {
74
111
  static: { plugins: ["kyc-prefill"] },
75
- context: { countryCode: "country" }
112
+ context: {
113
+ countryCode: "country",
114
+ source: "source"
115
+ }
76
116
  }
77
117
  },
78
- "ekycprefill/US": {
118
+ "ekycprefill/US/US_PREFILL": {
79
119
  schemaVersion: 1,
80
120
  vocabulary: "1.3",
81
- id: "ekycprefill/US",
121
+ id: "ekycprefill/US/US_PREFILL",
82
122
  module: "ekycprefill",
83
123
  country: "US",
124
+ source: "US_PREFILL",
84
125
  fields: [
85
126
  {
86
127
  name: "phone",
87
128
  kind: "phone",
88
129
  group: "phone",
130
+ required: true,
89
131
  label: { key: "verification.labels.phone" },
90
132
  input: { autofill: "phone" },
91
133
  phone: { lockCountry: true },
@@ -111,7 +153,18 @@ const EKYCPREFILL_DEFINITIONS = {
111
153
  label: { key: "verification.labels.ssn" },
112
154
  input: {
113
155
  maxLength: 11,
114
- keyboard: "numeric"
156
+ keyboard: "numeric",
157
+ format: [{
158
+ id: "digitGroups",
159
+ params: {
160
+ groups: [
161
+ 3,
162
+ 2,
163
+ 4
164
+ ],
165
+ separator: "-"
166
+ }
167
+ }]
115
168
  },
116
169
  rules: [{ id: "ssnFormat" }],
117
170
  payload: { transforms: [{
@@ -128,13 +181,88 @@ const EKYCPREFILL_DEFINITIONS = {
128
181
  input: {
129
182
  maxLength: 100,
130
183
  autofill: "familyName"
131
- }
184
+ },
185
+ rules: [{ id: "nameCharacters" }]
132
186
  }
133
187
  ],
188
+ groupRules: [{
189
+ id: "oneOfRequired",
190
+ fields: [
191
+ "dateOfBirth",
192
+ "ssn",
193
+ "surName"
194
+ ],
195
+ message: {
196
+ key: "ekycPrefill.errors.requireAnyOf",
197
+ text: "Provide at least one of {{fields}}"
198
+ }
199
+ }],
200
+ submit: {
201
+ static: { plugins: ["kyc-prefill"] },
202
+ context: {
203
+ countryCode: "country",
204
+ source: "source"
205
+ }
206
+ }
207
+ },
208
+ "ekycprefill/US/US_PREFILL_EXPRESS": {
209
+ schemaVersion: 1,
210
+ vocabulary: "1.0",
211
+ id: "ekycprefill/US/US_PREFILL_EXPRESS",
212
+ module: "ekycprefill",
213
+ country: "US",
214
+ source: "US_PREFILL_EXPRESS",
215
+ fields: [{
216
+ name: "phone",
217
+ kind: "phone",
218
+ group: "phone",
219
+ required: true,
220
+ label: { key: "verification.labels.phone" },
221
+ input: { autofill: "phone" },
222
+ phone: { lockCountry: true },
223
+ rules: [{ id: "phoneFormat" }],
224
+ payload: { transforms: [{ id: "e164" }] }
225
+ }],
134
226
  submit: {
135
227
  static: { plugins: ["kyc-prefill"] },
136
- context: { countryCode: "country" }
228
+ context: {
229
+ countryCode: "country",
230
+ source: "source"
231
+ }
232
+ }
233
+ }
234
+ };
235
+ //#endregion
236
+ //#region src/internal/forms/rules/digitGroups.ts
237
+ /**
238
+ * `digitGroups`: formats digits as the user types, such as an SSN shown as
239
+ * 3-2-4 (`groups: [3, 2, 4]`, `separator: "-"`). Other characters are
240
+ * dropped, digits past the last group are cut, and a separator appears once
241
+ * the next group has a digit (`1234` is `123-4`).
242
+ *
243
+ * `separators` (vocabulary 1.4) gives the separator after each group, in
244
+ * order, such as a CPF shown as 3.3.3-2 (`separators: [".", ".", "-"]`). A
245
+ * gap past the end of the list uses `separator`.
246
+ */
247
+ const digitGroups = {
248
+ id: "digitGroups",
249
+ apply: (value, params) => {
250
+ const groups = Array.isArray(params.groups) ? params.groups.filter((size) => typeof size === "number") : [];
251
+ const separator = typeof params.separator === "string" ? params.separator : "";
252
+ const separators = Array.isArray(params.separators) ? params.separators : [];
253
+ const separatorAfter = (index) => {
254
+ const own = separators[index];
255
+ return typeof own === "string" ? own : separator;
256
+ };
257
+ let digits = value.replace(/[^0-9]/g, "");
258
+ let formatted = "";
259
+ for (const [index, size] of groups.entries()) {
260
+ if (!digits) break;
261
+ if (index > 0) formatted += separatorAfter(index - 1);
262
+ formatted += digits.slice(0, size);
263
+ digits = digits.slice(size);
137
264
  }
265
+ return formatted;
138
266
  }
139
267
  };
140
268
  //#endregion
@@ -142,22 +270,33 @@ const EKYCPREFILL_DEFINITIONS = {
142
270
  /**
143
271
  * eKYC Pre-fill adapter for form definitions.
144
272
  *
145
- * The catalog (`catalog/ekycprefill`) holds one definition per country with
146
- * every input the country's sources take, all optional: their kind, label,
147
- * rules and request key. The served module configuration decides the rest
148
- * (ENG-61990): which inputs show (`check`), which are required (`mandatory`)
149
- * and which are "at least one of" (`requireAnyOf`). This overlays the served
150
- * configuration on the country's definition, so eKYC Pre-fill runs the same
151
- * kernel (`checkSupport`, `resolveForm`) as eKYC, eKYB and KYB Checks. It
152
- * goes away once the backend serves form definitions itself.
273
+ * The catalog (`catalog/ekycprefill`) holds one definition per backend
274
+ * source, keyed by (source, country) as eKYC's are: the inputs the source
275
+ * takes, which are required and which are "at least one of", with their
276
+ * labels, rules and request keys. The served module configuration
277
+ * (ENG-61990) turns inputs on (`check`) and says where each value comes from
278
+ * (`source`) and how it shows (`displayMode`). This adapter selects the
279
+ * definition and translates the configuration into a `ResolveContext`. It
280
+ * never changes the definition, so a definition the backend serves later
281
+ * takes the same path.
153
282
  */
154
283
  const EKYC_PREFILL_MODULE = "ekycprefill";
155
- /** The message of the "at least one of" rule. Its `fields` param lists the members' labels. */
156
- const ANY_OF_MESSAGE_KEY = "ekycPrefill.errors.requireAnyOf";
157
- /** What the projection can express: exactly the ids the catalog uses. */
284
+ /** Request transforms `buildSubmitBody` applies. */
285
+ const PAYLOAD_TRANSFORMS = /* @__PURE__ */ new Set(["e164", "stripSeparators"]);
286
+ /**
287
+ * Typing formats (`input.format`) the module applies as the user types, with
288
+ * the kernel's implementations: the SSN's and the CPF's `digitGroups`.
289
+ */
290
+ const EKYC_PREFILL_INPUT_FORMATS = /* @__PURE__ */ new Map([[digitGroups.id, digitGroups]]);
291
+ const ONE_OF_REQUIRED = "oneOfRequired";
292
+ /**
293
+ * The ids this build can render, validate and send. Rules are the ones eKYC's
294
+ * rule projection (`projectRules`) knows, because Pre-fill validates with it
295
+ * until the kernel does (ENG-63327).
296
+ */
158
297
  const EKYC_PREFILL_SUPPORTED_IDS = {
159
298
  schemaVersions: [1],
160
- vocabulary: "1.3",
299
+ vocabulary: "1.4",
161
300
  kinds: /* @__PURE__ */ new Set([
162
301
  "text",
163
302
  "date",
@@ -169,86 +308,126 @@ const EKYC_PREFILL_SUPPORTED_IDS = {
169
308
  "ssn",
170
309
  "name"
171
310
  ]),
172
- rules: /* @__PURE__ */ new Set([
173
- "phoneFormat",
174
- "notFuture",
175
- "maxAge",
176
- "ssnFormat",
177
- "cpf"
178
- ]),
179
- transforms: /* @__PURE__ */ new Set(["e164", "stripSeparators"]),
180
- groupRules: /* @__PURE__ */ new Set(["oneOfRequired"]),
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]),
181
314
  optionLists: /* @__PURE__ */ new Set(),
182
315
  conditions: /* @__PURE__ */ new Set(),
183
316
  prefillSources: /* @__PURE__ */ new Set(),
184
317
  flags: /* @__PURE__ */ new Set()
185
318
  };
319
+ /**
320
+ * Module configuration's value sources → the vocabulary's prefill origins
321
+ * (each origin's `configValues`). Pre-fill doesn't bundle the vocabulary, so
322
+ * a test pins this table to it.
323
+ */
324
+ const PREFILL_ORIGINS = /* @__PURE__ */ new Map([
325
+ ["userInput", "userInput"],
326
+ ["document", "document"],
327
+ ["poa", "poa"],
328
+ ["phoneModuleInput", "phoneModule"],
329
+ ["emailModuleInput", "emailModule"]
330
+ ]);
331
+ /** Origins whose values another module verified (the vocabulary's `locks`). */
332
+ const LOCKING_ORIGINS = ["phoneModule", "emailModule"];
186
333
  const bundled = createBundledDefinitionSource(EKYCPREFILL_DEFINITIONS);
187
- /** The catalog definition for a country, or `undefined` when it has none. */
188
- function selectEkycPrefillDefinition(country) {
334
+ /**
335
+ * The definition for exactly this source and country, or `undefined` when
336
+ * there is none. Bundled today; a served definition source (P4) plugs in
337
+ * here, and nothing after selection changes.
338
+ */
339
+ function selectEkycPrefillDefinition(source, country) {
189
340
  return bundled.select({
190
341
  module: EKYC_PREFILL_MODULE,
342
+ source,
191
343
  country
192
344
  });
193
345
  }
346
+ const projectable = /* @__PURE__ */ new WeakMap();
347
+ /**
348
+ * Whether every part of a definition maps onto what Pre-fill does today:
349
+ * the supported ids, rules its validators project with valid params, request
350
+ * transforms `buildSubmitBody` applies, typing formats it applies, at most
351
+ * one `oneOfRequired` rule (the form shows one "at least one of" message),
352
+ * and no collections.
353
+ */
354
+ function isProjectableEkycPrefillDefinition(definition) {
355
+ let result = projectable.get(definition);
356
+ if (result === void 0) {
357
+ const groupRules = definition.groupRules ?? [];
358
+ result = definition.module === "ekycprefill" && checkSupport(definition, EKYC_PREFILL_SUPPORTED_IDS).supported && definition.fields.every((field) => (field.rules ?? []).every(isProjectableRule) && (field.payload?.transforms ?? []).every((transform) => PAYLOAD_TRANSFORMS.has(transform.id)) && (field.input?.format ?? []).every((format) => EKYC_PREFILL_INPUT_FORMATS.has(format.id))) && groupRules.length <= 1 && groupRules.every((rule) => rule.id === ONE_OF_REQUIRED && !rule.message?.params) && !definition.collections?.length;
359
+ projectable.set(definition, result);
360
+ }
361
+ return result;
362
+ }
194
363
  /**
195
- * Applies the served configuration to the country's definition:
364
+ * Translates the served configuration into the kernel's `ResolveContext`:
196
365
  *
197
- * - a field shows only when its served `check` is `true`; its group is on;
198
- * - a shown field is required when served `mandatory`;
199
- * - `requireAnyOf`, kept to the shown fields, becomes a `oneOfRequired`
200
- * rule. One member left is simply required, so it gets the usual
201
- * asterisk and message instead of an "at least one of" message;
202
- * - the served `source` goes into the request body, as a served definition
203
- * would carry it.
366
+ * - `check: true` turns the field's group on;
367
+ * - `source` becomes the group's prefill origin;
368
+ * - `displayMode` becomes the group's display mode.
204
369
  *
205
- * A served input the definition has no field for is left out with a warning.
370
+ * A shown input the definition has no field for is left out with a warning.
371
+ * `mandatory` and `requireAnyOf` are not read here: the definition decides
372
+ * requiredness (see `ekycPrefillDrift`).
206
373
  */
207
- function toEkycPrefillResolution(definition, config) {
208
- const served = new Map((config.fields ?? []).map((field) => [field.field, field]));
209
- const known = new Set(definition.fields.map((field) => field.name));
374
+ function toEkycPrefillContext(definition, config) {
375
+ const groupOf = new Map(definition.fields.map((field) => [field.name, field.group]));
376
+ const groups = {};
377
+ const origins = {};
378
+ const displayModes = {};
210
379
  const unknownMandatory = [];
211
- for (const field of served.values()) {
212
- if (known.has(field.field) || !field.check) continue;
213
- console.warn(`[ekyc-prefill] No "${field.field}" field for ${definition.id}; it is not shown`);
214
- if (field.mandatory) unknownMandatory.push(field.field);
215
- }
216
- const shown = definition.fields.filter((field) => served.get(field.name)?.check === true);
217
- const shownNames = new Set(shown.map((field) => field.name));
218
- const anyOf = [...new Set(config.requireAnyOf)].filter((name) => shownNames.has(name));
219
- const loneMember = anyOf.length === 1 ? anyOf[0] : void 0;
220
- const fields = shown.map((field) => ({
221
- ...field,
222
- required: served.get(field.name)?.mandatory === true || field.name === loneMember
223
- }));
224
- const groupRules = anyOf.length > 1 ? [{
225
- id: "oneOfRequired",
226
- fields: anyOf,
227
- message: {
228
- key: ANY_OF_MESSAGE_KEY,
229
- text: "Provide at least one of {{fields}}"
380
+ for (const field of config.fields ?? []) {
381
+ const group = groupOf.get(field.field);
382
+ if (group === void 0) {
383
+ if (!field.check) continue;
384
+ console.warn(`[ekyc-prefill] No "${field.field}" field for ${definition.id}; it is not shown`);
385
+ if (field.mandatory) unknownMandatory.push(field.field);
386
+ continue;
230
387
  }
231
- }] : [];
388
+ if (field.check) groups[group] = true;
389
+ const origin = field.source && PREFILL_ORIGINS.get(field.source);
390
+ if (origin) origins[group] = origin;
391
+ if (field.displayMode) displayModes[group] = field.displayMode;
392
+ }
232
393
  return {
233
- definition: {
234
- ...definition,
235
- ...config.source && { source: config.source },
236
- fields,
237
- groupRules,
238
- submit: {
239
- ...definition.submit,
240
- context: {
241
- ...definition.submit.context,
242
- ...config.source && { source: "source" }
243
- }
244
- }
394
+ context: {
395
+ groups,
396
+ origins,
397
+ displayModes,
398
+ lockingOrigins: LOCKING_ORIGINS
245
399
  },
246
- context: { groups: Object.fromEntries(fields.map((field) => [field.group, true])) },
247
400
  unknownMandatory
248
401
  };
249
402
  }
403
+ const sorted = (names) => [...new Set(names)].sort();
404
+ const listOf = (names) => `[${names.join(", ")}]`;
405
+ /**
406
+ * Where the served `mandatory` and `requireAnyOf` disagree with the resolved
407
+ * definition, one line each: the required fields, and the shown members of
408
+ * its "at least one of" rule. The definition wins; the module logs these, and
409
+ * the contract test fails on any.
410
+ */
411
+ function ekycPrefillDrift(form, config) {
412
+ const shown = new Set(form.fields.map(({ field }) => field.name));
413
+ const servedRequired = sorted((config.fields ?? []).filter((field) => field.check && field.mandatory).map((field) => field.field).filter((name) => shown.has(name)));
414
+ const required = sorted(form.fields.filter((field) => field.required).map(({ field }) => field.name));
415
+ 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));
417
+ const lines = [];
418
+ if (listOf(servedRequired) !== listOf(required)) lines.push(`required: served ${listOf(servedRequired)}, definition ${listOf(required)}`);
419
+ if (listOf(servedAnyOf) !== listOf(anyOf)) lines.push(`at least one of: served ${listOf(servedAnyOf)}, definition ${listOf(anyOf)}`);
420
+ return lines;
421
+ }
250
422
  //#endregion
251
423
  //#region src/modules/ekyc-prefill/ekycPrefillFields.ts
424
+ /**
425
+ * eKYC Pre-fill on the forms kernel: selects the source's definition,
426
+ * resolves it against the served configuration, projects it to
427
+ * `EkycPrefillFieldDef`s, and validates and submits from those. Validation
428
+ * runs the definition's rules through eKYC's `validateEkycField` until the
429
+ * kernel validates (ENG-63327).
430
+ */
252
431
  const PHONE_INVALID_ERROR = { key: "verification.errors.phoneInvalid" };
253
432
  /** Vocabulary autofill ids → HTML `autocomplete` tokens (WCAG 2.2 SC 1.3.5). */
254
433
  const AUTOCOMPLETE = {
@@ -269,19 +448,11 @@ const TYPES = {
269
448
  date: "date",
270
449
  phone: "phone"
271
450
  };
272
- /** The as-you-type format a field's rule or group implies. */
273
- function formatAsOf(field) {
274
- const rules = new Set((field.rules ?? []).map((rule) => rule.id));
275
- if (rules.has("cpf")) return "cpf";
276
- if (rules.has("ssnFormat")) return "ssn";
277
- if (field.group === "name") return "name";
278
- }
279
- function projectField(resolved, country) {
451
+ function projectField(resolved, country, displayMode) {
280
452
  const { field, required, phoneLocked } = resolved;
281
453
  const validation = required ? [{ type: "required" }] : [];
282
454
  validation.push(...projectRules(field.rules ?? [], country, required));
283
455
  const autoComplete = field.input?.autofill ? AUTOCOMPLETE[field.input.autofill] : void 0;
284
- const formatAs = formatAsOf(field);
285
456
  return {
286
457
  name: field.name,
287
458
  type: TYPES[field.kind] ?? "text",
@@ -291,10 +462,10 @@ function projectField(resolved, country) {
291
462
  ...field.placeholder && { placeholder: field.placeholder.key },
292
463
  ...field.input?.maxLength !== void 0 && { maxLength: field.input.maxLength },
293
464
  ...field.kind === "phone" && { disableCountrySelector: phoneLocked },
465
+ ...displayMode === "readOnly" && { readonly: true },
294
466
  ...field.widget === "masked" && { masked: true },
295
467
  ...field.input?.keyboard === "numeric" && { numeric: true },
296
468
  ...autoComplete && { autoComplete },
297
- ...formatAs && { formatAs },
298
469
  validation
299
470
  };
300
471
  }
@@ -322,56 +493,88 @@ function toSubmitPlan(definition) {
322
493
  };
323
494
  }
324
495
  const preparedForms = /* @__PURE__ */ new WeakMap();
496
+ function prepared(config) {
497
+ if (preparedForms.has(config)) return preparedForms.get(config) ?? void 0;
498
+ const result = prepare(config);
499
+ preparedForms.set(config, result ?? null);
500
+ return result;
501
+ }
502
+ /**
503
+ * Pre-fill reads no field values yet (its catalog lists no prefill sources),
504
+ * so `resolvePrefill` gets none and only decides display modes. These checks
505
+ * never run; they reject any value, so none could slip in unchecked.
506
+ */
507
+ const NO_VALUES = {};
508
+ const NO_PREFILL_CHECKS = {
509
+ format: (_field, value) => value,
510
+ isValid: () => false
511
+ };
325
512
  /**
326
- * The served configuration on the forms kernel: the country's definition,
327
- * overlaid with the served requiredness, checked, resolved and projected.
328
- * `undefined` when the module can't render it: no `fields` (the flat
329
- * dashboard shape), no source or country, no definition for the country, a
330
- * mandatory input the definition doesn't know, no input to show, or an
331
- * overlay that fails `checkSupport`, which would be a bug in the adapter.
513
+ * The served configuration on the forms kernel: the source's definition,
514
+ * checked, resolved against the configuration and projected. `undefined`
515
+ * when the module can't render it: no `fields` (the flat dashboard shape),
516
+ * no source or country, no definition for the pair, a mandatory input the
517
+ * definition doesn't know, a definition this build can't render, or no input
518
+ * to show. The definition decides requiredness; where the served `mandatory`
519
+ * or `requireAnyOf` disagree, a warning names the difference.
332
520
  */
333
521
  function prepareEkycPrefillForm(config) {
334
- if (preparedForms.has(config)) return preparedForms.get(config) ?? void 0;
335
- const prepared = prepare(config);
336
- preparedForms.set(config, prepared ?? null);
337
- return prepared;
522
+ return prepared(config)?.form;
338
523
  }
339
524
  function prepare(config) {
340
525
  const { country, source, fields } = config;
341
526
  if (!fields || !country || !source) return void 0;
342
- const catalog = selectEkycPrefillDefinition(country);
343
- if (!catalog) {
344
- console.warn(`[ekyc-prefill] No form definition for country ${country}`);
527
+ const definition = selectEkycPrefillDefinition(source, country);
528
+ if (!definition) {
529
+ console.warn(`[ekyc-prefill] No form definition for source ${source} in ${country}`);
345
530
  return;
346
531
  }
347
- const { definition, context, unknownMandatory } = toEkycPrefillResolution(catalog, config);
532
+ const { context, unknownMandatory } = toEkycPrefillContext(definition, config);
348
533
  if (unknownMandatory.length > 0) return void 0;
349
- const support = checkSupport(definition, EKYC_PREFILL_SUPPORTED_IDS);
350
- if (!support.supported) {
351
- console.warn("[ekyc-prefill] Unsupported form definition", support.problems);
534
+ if (!isProjectableEkycPrefillDefinition(definition)) {
535
+ const support = checkSupport(definition, EKYC_PREFILL_SUPPORTED_IDS);
536
+ console.warn(`[ekyc-prefill] ${definition.id} can't be rendered by this build`, support.supported ? [] : support.problems);
352
537
  return;
353
538
  }
354
- const resolved = resolveForm(definition, context);
355
- if (resolved.fields.length === 0) return void 0;
356
- const [anyOf] = resolved.groupRules;
539
+ const form = resolveForm(definition, context);
540
+ for (const line of ekycPrefillDrift(form, config)) console.warn(`[ekyc-prefill] ${definition.id}: ${line}; the definition applies`);
541
+ const { fields: prefilled } = resolvePrefill(form, context, NO_VALUES, NO_PREFILL_CHECKS);
542
+ const rendered = prefilled.filter((field) => field.displayMode !== "hidden");
543
+ if (rendered.length === 0) return void 0;
544
+ const renderedNames = new Set(rendered.map(({ field }) => field.name));
545
+ const [anyOf] = form.groupRules;
546
+ const members = (anyOf?.fields ?? []).filter((name) => renderedNames.has(name));
547
+ const loneMember = members.length === 1 ? members[0] : void 0;
357
548
  return {
358
- country,
359
- fields: resolved.fields.map((field) => projectField(field, country)),
360
- anyOf: anyOf && {
361
- fields: [...anyOf.fields],
362
- message: anyOf.rule.message?.key ?? anyOf.rule.id
549
+ form: {
550
+ country,
551
+ fields: rendered.map((field) => projectField({
552
+ ...field,
553
+ required: field.required || field.field.name === loneMember
554
+ }, country, field.displayMode)),
555
+ anyOf: anyOf && members.length > 1 ? {
556
+ fields: members,
557
+ message: anyOf.rule.message?.key ?? anyOf.rule.id
558
+ } : void 0,
559
+ submit: toSubmitPlan(definition)
363
560
  },
364
- submit: toSubmitPlan(definition)
561
+ fields: new Map(rendered.map(({ field }) => [field.name, field]))
365
562
  };
366
563
  }
367
- /** Formats a value as it is typed. */
368
- function formatFieldValue(field, value) {
369
- switch (field?.formatAs) {
370
- case "cpf": return formatCPF(value);
371
- case "ssn": return formatSSN(value);
372
- case "name": return value ? cleanName(value) : value;
373
- default: return value;
374
- }
564
+ /**
565
+ * Formats a value as it is typed, with the field's typing formats from its
566
+ * definition (`input.format`), such as the SSN's and the CPF's
567
+ * `digitGroups`. A field without one, or unknown, keeps the value as typed.
568
+ */
569
+ function formatFieldValue(config, name, value) {
570
+ const form = prepared(config);
571
+ const field = form?.fields.get(name);
572
+ if (!form || !field) return value;
573
+ return formatValue(field, value, { transforms: EKYC_PREFILL_INPUT_FORMATS }, {
574
+ country: form.form.country,
575
+ today: getLocalIsoDate(),
576
+ deps: {}
577
+ });
375
578
  }
376
579
  const isBlank = (value) => (value ?? "").trim() === "";
377
580
  const asEkycFields = (fields) => fields.map(({ name, type, label, displayLabel, required, validation }) => ({
@@ -495,10 +698,9 @@ const ekycPrefillMachine = setup({
495
698
  setFieldValue: assign(({ context, event }) => {
496
699
  const { name, value, isValid } = event;
497
700
  const prepared = context.prepared;
498
- const field = prepared.fields.find((f) => f.name === name);
499
701
  const values = {
500
702
  ...context.values,
501
- [name]: formatFieldValue(field, value)
703
+ [name]: formatFieldValue(context.config, name, value)
502
704
  };
503
705
  const invalidFormats = { ...context.invalidFormats };
504
706
  if (isValid === false) invalidFormats[name] = true;
@@ -541,7 +743,7 @@ const ekycPrefillMachine = setup({
541
743
  ...context.errors,
542
744
  phone: PHONE_INVALID_ERROR
543
745
  } };
544
- const cpfField = prepared.fields.find((field) => field.formatAs === "cpf");
746
+ const cpfField = prepared.fields.find((field) => field.validation.some((rule) => rule.type === "cpf"));
545
747
  if (cpfField && names.length === 1) return { errors: {
546
748
  ...context.errors,
547
749
  [cpfField.name]: { key: CPF_INVALID_KEY }