@incodetech/core 0.0.0-dev-20261123-cce29715 → 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.
- package/dist/{FaceDetectionProvider-kKx1YFhL.esm.js → FaceDetectionProvider-CSiQ4_ay.esm.js} +4 -4
- package/dist/ae-signature.esm.js +1 -1
- package/dist/{apiError-DyQlf7pI.esm.js → apiError-D8p92jfK.esm.js} +1 -1
- package/dist/authentication.d.ts +3 -3
- package/dist/authentication.esm.js +2 -2
- package/dist/{authenticationManager-BJElkTsj.d.ts → authenticationManager-CLG0PAw9.d.ts} +1 -1
- package/dist/{authenticationManager-DuJZntLr.esm.js → authenticationManager-DzwIWNvb.esm.js} +3 -3
- package/dist/{authenticationStateMachine-FJu61T6B.esm.js → authenticationStateMachine-QgXVzF_L.esm.js} +3 -3
- package/dist/consent.d.ts +1 -1
- package/dist/{consentManager-B0YKqYtZ.d.ts → consentManager-Bx_osBME.d.ts} +4 -4
- package/dist/curp-validation.d.ts +1 -1
- package/dist/{curpValidationManager-CmL52FU8.d.ts → curpValidationManager-CA9w3fO6.d.ts} +1 -1
- package/dist/{deepsightCaptureConfig-Boptke9Z.esm.js → deepsightCaptureConfig-Bcrw2pFu.esm.js} +2 -2
- package/dist/{deepsightLoader-B4hiGB68.esm.js → deepsightLoader-DRDK4yts.esm.js} +4 -4
- package/dist/{desktopCameraElection-C4TjN5pn.esm.js → desktopCameraElection-BvPHvAA4.esm.js} +4 -4
- package/dist/document-signature.esm.js +1 -1
- package/dist/{documentSignatureStateMachine-CL3tYalT.esm.js → documentSignatureStateMachine-PMOkZDCn.esm.js} +1 -1
- package/dist/dynamic-forms.esm.js +2 -2
- package/dist/{dynamicFormsManager-Cmg9f9mV.esm.js → dynamicFormsManager-BOQRxy_t.esm.js} +1 -1
- package/dist/{dynamicFormsStateMachine-BSSMKnJK.esm.js → dynamicFormsStateMachine-Bv8m-KhL.esm.js} +1 -1
- package/dist/ekyb.d.ts +1 -1
- package/dist/ekyb.esm.js +2 -2
- package/dist/{ekybManager-DukDpi6T.esm.js → ekybManager-Dt7Z6NEX.esm.js} +1 -1
- package/dist/{ekybStateMachine-CZW_DJPi.esm.js → ekybStateMachine-DExt873D.esm.js} +1 -1
- package/dist/ekyc-prefill.d.ts +5 -4
- package/dist/ekyc-prefill.esm.js +2 -2
- package/dist/ekyc.esm.js +3 -3
- package/dist/{ekycManager-Dsv9J-cK.esm.js → ekycManager-N2EAITDJ.esm.js} +1 -1
- package/dist/{ekycPrefillManager-C798byU3.esm.js → ekycPrefillManager-B1i-Fgy-.esm.js} +1 -1
- package/dist/{ekycPrefillManager-BcLhkpp8.d.ts → ekycPrefillManager-BzM-GMVT.d.ts} +5 -5
- package/dist/{ekycPrefillStateMachine-B9pcpVb4.esm.js → ekycPrefillStateMachine-DlUZGMCd.esm.js} +333 -131
- package/dist/{ekycRules-BH_Ll_0A.esm.js → ekycRules-B7kUzSgu.esm.js} +117 -1
- package/dist/{ekycStateMachine-D305_ReU.esm.js → ekycStateMachine-1qQi52Ih.esm.js} +2 -113
- package/dist/{ekycUtils-DEvtEyBI.esm.js → ekycUtils-D4CwNG7Y.esm.js} +5 -3
- package/dist/electronic-signature.esm.js +1 -1
- package/dist/{electronicSignatureManager-DBnwX3nv.esm.js → electronicSignatureManager-YyQFeYTi.esm.js} +1 -1
- package/dist/extensibility.d.ts +12 -12
- package/dist/extensibility.esm.js +13 -13
- package/dist/{faceCaptureManagerFactory-CHqmyOjM.d.ts → faceCaptureManagerFactory-BNY7JNj3.d.ts} +3 -3
- package/dist/{faceCaptureManagerFactory-pSb7HIK6.esm.js → faceCaptureManagerFactory-BOu2eQns.esm.js} +2 -2
- package/dist/{faceCaptureSetup-BTxn1bsz.esm.js → faceCaptureSetup-CopYy5_O.esm.js} +7 -7
- package/dist/{feature-management-BqzU1p4m.esm.js → feature-management-CGHalFcv.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 +5 -5
- package/dist/flow.esm.js +3 -3
- package/dist/{flowCompletionService-DFRGVClO.esm.js → flowCompletionService-BETSa4vN.esm.js} +1 -1
- package/dist/{flowServices-W8ut4kGu.esm.js → flowServices-Adu2JkFA.esm.js} +5 -5
- package/dist/geolocation.esm.js +2 -2
- package/dist/{geolocationManager-BYMMQRWc.esm.js → geolocationManager-CFSS2JSp.esm.js} +1 -1
- package/dist/{geolocationStateMachine-BYi5j53h.esm.js → geolocationStateMachine-yhJy-Oli.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 +17 -1
- 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-CgkQW3Xc.d.ts → idCaptureManager-DksvDJ5Y.d.ts} +2 -2
- package/dist/{idCaptureManager-DNTXCoVj.esm.js → idCaptureManager-biMO4ti8.esm.js} +4 -4
- package/dist/{idCaptureServices-CY0QB_He.esm.js → idCaptureServices-DsBCDgPq.esm.js} +2 -2
- package/dist/{idCaptureStateMachine-teGR624y.esm.js → idCaptureStateMachine-DSVxM1sV.esm.js} +11 -11
- package/dist/{idOcrManager-DflRx-_u.d.ts → idOcrManager-CNGVEZ7B.d.ts} +1 -1
- package/dist/identity-reuse.d.ts +1 -1
- package/dist/{identityReuseManager-CZ-qJ_Aa.d.ts → identityReuseManager-D_jiHp1n.d.ts} +4 -4
- package/dist/{index-CoePktWH.d.ts → index-BsqGSj_x.d.ts} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/kyb-checks.esm.js +2 -2
- package/dist/{kybChecksManager-C3mVvCpX.esm.js → kybChecksManager-BELqX_Lm.esm.js} +1 -1
- package/dist/{kybChecksStateMachine-CvBvaSwt.esm.js → kybChecksStateMachine-DK41gj76.esm.js} +1 -1
- package/dist/mandatory-consent.d.ts +2 -2
- package/dist/{mandatoryConsentManager-Cktplm8q.d.ts → mandatoryConsentManager-B4-gw9FV.d.ts} +5 -5
- package/dist/qe-signature.esm.js +1 -1
- package/dist/{recordingService-BoukNWOP.esm.js → recordingService-C092bHW7.esm.js} +1 -1
- package/dist/{runChildModule-WEiP1CHt.esm.js → runChildModule-BImyqF65.esm.js} +1 -1
- package/dist/{sdkVersion-rBrLj4z4.esm.js → sdkVersion-BGEzZXPX.esm.js} +1 -1
- package/dist/selfie.d.ts +3 -3
- package/dist/selfie.esm.js +7 -7
- package/dist/{selfieErrorUtils-sNftEqTJ.esm.js → selfieErrorUtils-BbrtgKm7.esm.js} +1 -1
- package/dist/{selfieManager-DrBYj5kA.d.ts → selfieManager-CSxlf4Ls.d.ts} +1 -1
- package/dist/{selfieManager-DaJ5z3ZG.esm.js → selfieManager-Cdj5fjRN.esm.js} +3 -3
- package/dist/{selfieStateMachine-RxD_sQuA.esm.js → selfieStateMachine-CAlutNlH.esm.js} +3 -3
- package/dist/{session-90UDuAvu.esm.js → session-BlpaoMHX.esm.js} +4 -4
- package/dist/session.d.ts +1 -1
- package/dist/session.esm.js +4 -4
- package/dist/{sessionInitializer-K4d-YTT2.esm.js → sessionInitializer-DmGppDQX.esm.js} +4 -4
- package/dist/{setup-DDyxHA7n.esm.js → setup-DA07nIIF.esm.js} +5 -5
- package/dist/trueSight-BAtlP0U8.esm.js +1 -0
- package/dist/{trueSightService-8VpJ29NU.esm.js → trueSightService-DSDSHENR.esm.js} +1 -1
- package/dist/{types-B-PIc0en.d.ts → types-Ct3OFmQs.d.ts} +25 -9
- package/dist/{types-DHpz4Y37.d.ts → types-CzoXVfgt.d.ts} +1 -1
- package/dist/{types-C1056-J1.d.ts → types-DQ2BSAKU.d.ts} +1 -1
- package/dist/types-DQACmFP1.d.ts +6 -0
- package/dist/{types-4Re9FSOw.d.ts → types-D_-0O9pg.d.ts} +1 -1
- package/dist/{types-CEGG70FK.d.ts → types-E4jPC3M2.d.ts} +1 -1
- package/dist/{types-b0l9b83G.d.ts → types-eMmhwENp.d.ts} +1 -1
- package/dist/video-selfie.d.ts +1 -1
- package/dist/video-selfie.esm.js +3 -3
- package/dist/{videoSelfieCameraWarmer-uFAo6650.esm.js → videoSelfieCameraWarmer-DWrg6vQd.esm.js} +3 -3
- package/dist/{videoSelfieStepDetector-DC_Qh7qI.d.ts → videoSelfieStepDetector-Cu7EZdcz.d.ts} +2 -2
- package/dist/wasm.esm.js +1 -1
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.esm.js +19 -19
- package/package.json +1 -1
- package/dist/idOcrCpfUtils-D5Gwskxu.esm.js +0 -18
- package/dist/trueSight-d5W-WDyQ.esm.js +0 -1
- package/dist/types-BtrJ5fkm.d.ts +0 -6
package/dist/{ekycPrefillStateMachine-B9pcpVb4.esm.js → ekycPrefillStateMachine-DlUZGMCd.esm.js}
RENAMED
|
@@ -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-
|
|
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
|
|
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
|
-
|
|
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
|
|
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.
|
|
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: {
|
|
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: {
|
|
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
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
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
|
-
/**
|
|
156
|
-
const
|
|
157
|
-
/**
|
|
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.
|
|
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:
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
/**
|
|
188
|
-
|
|
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
|
-
*
|
|
364
|
+
* Translates the served configuration into the kernel's `ResolveContext`:
|
|
196
365
|
*
|
|
197
|
-
* -
|
|
198
|
-
* -
|
|
199
|
-
* - `
|
|
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
|
|
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
|
|
208
|
-
const
|
|
209
|
-
const
|
|
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
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
|
|
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
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
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
|
-
|
|
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
|
|
343
|
-
if (!
|
|
344
|
-
console.warn(`[ekyc-prefill] No form definition for
|
|
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 {
|
|
532
|
+
const { context, unknownMandatory } = toEkycPrefillContext(definition, config);
|
|
348
533
|
if (unknownMandatory.length > 0) return void 0;
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
console.warn(
|
|
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
|
|
355
|
-
|
|
356
|
-
const
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
561
|
+
fields: new Map(rendered.map(({ field }) => [field.name, field]))
|
|
365
562
|
};
|
|
366
563
|
}
|
|
367
|
-
/**
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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(
|
|
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.
|
|
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 }
|