@incodetech/core 0.0.0-dev-20260923-1a4dbec8 → 0.0.0-dev-20260924-9e40faf4

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 (76) hide show
  1. package/dist/{BrowserDiagnosticsCryptoProvider-B5poAx1_.esm.js → BrowserDiagnosticsCryptoProvider-D0e-1PEZ.esm.js} +1 -1
  2. package/dist/{FaceDetectionProvider-Ydsahps4.esm.js → FaceDetectionProvider-DbssECIq.esm.js} +4 -4
  3. package/dist/{ekycStateMachine-BjNeL6ce.esm.js → PhoneValidationProvider-Dok_Det7.esm.js} +160 -779
  4. package/dist/ae-signature.esm.js +1 -1
  5. package/dist/{apiError-B5izenZ8.esm.js → apiError-BBsde_zZ.esm.js} +1 -1
  6. package/dist/authentication.esm.js +2 -2
  7. package/dist/{authenticationManager-xf4GoLxc.esm.js → authenticationManager-CfHmU40H.esm.js} +3 -3
  8. package/dist/{authenticationStateMachine-BkvMIijO.esm.js → authenticationStateMachine-DIijLkkt.esm.js} +2 -2
  9. package/dist/curp-validation.esm.js +2 -2
  10. package/dist/{curpValidationManager-BzS_Dlcq.esm.js → curpValidationManager-BHocstXa.esm.js} +13 -20
  11. package/dist/{curpValidationStateMachine-Bg_Lsk2V.esm.js → curpValidationStateMachine-CDcMdfvW.esm.js} +1 -1
  12. package/dist/{deepsightLoader-L0JGAPDe.esm.js → deepsightLoader-Cxt11Cx1.esm.js} +3 -3
  13. package/dist/document-capture.d.ts +1 -1
  14. package/dist/document-capture.esm.js +1 -1
  15. package/dist/{documentCaptureManager-CbAGkHWh.d.ts → documentCaptureManager-C8eO0hbv.d.ts} +1 -1
  16. package/dist/{documentCaptureManager-7aQhPQnb.esm.js → documentCaptureManager-CLtex74O.esm.js} +7 -14
  17. package/dist/dynamic-forms.esm.js +2 -2
  18. package/dist/{dynamicFormsManager-l_3MYzBs.esm.js → dynamicFormsManager-CXKgiYov.esm.js} +1 -1
  19. package/dist/{dynamicFormsStateMachine-DOF7ba6-.esm.js → dynamicFormsStateMachine-CJ8bA1oW.esm.js} +1 -1
  20. package/dist/ekyb.esm.js +3 -3
  21. package/dist/{ekybManager-lxNzE1kk.esm.js → ekybManager-BSIlNfRf.esm.js} +21 -25
  22. package/dist/{ekybStateMachine-DNBBT-S9.esm.js → ekybStateMachine-z0t8szV3.esm.js} +1 -1
  23. package/dist/ekyc.esm.js +2 -2
  24. package/dist/{ekycManager-DoGZkFZQ.esm.js → ekycManager-DEbkqrHx.esm.js} +27 -34
  25. package/dist/ekycStateMachine-UjaYNdNf.esm.js +688 -0
  26. package/dist/electronic-signature.esm.js +1 -1
  27. package/dist/{electronicSignatureManager-COJYfU0x.esm.js → electronicSignatureManager-B-IMLsp-.esm.js} +5 -5
  28. package/dist/email.esm.js +1 -1
  29. package/dist/{emailManager-CTNtCZJI.esm.js → emailManager-CeSfUjcz.esm.js} +17 -23
  30. package/dist/extensibility.d.ts +3 -3
  31. package/dist/extensibility.esm.js +17 -17
  32. package/dist/{faceCaptureManagerFactory-CIj0Cuh2.esm.js → faceCaptureManagerFactory-SDNPwwLR.esm.js} +2 -2
  33. package/dist/{faceCaptureSetup-LKIkhOFU.esm.js → faceCaptureSetup-bzpheUcb.esm.js} +3 -3
  34. package/dist/{feature-management-BdEYtp-i.esm.js → feature-management-B_C9uoMn.esm.js} +1 -1
  35. package/dist/feature-management.esm.js +1 -1
  36. package/dist/flow.esm.js +3 -3
  37. package/dist/{flowCompletionService-__FouXqN.esm.js → flowCompletionService-Cu5uEJuu.esm.js} +1 -1
  38. package/dist/{flowServices-Bzs_X1o4.esm.js → flowServices-BQtiexrG.esm.js} +4 -4
  39. package/dist/geolocation.esm.js +2 -2
  40. package/dist/{geolocationManager-B9ljrS0X.esm.js → geolocationManager-DSDFdGbn.esm.js} +4 -5
  41. package/dist/{geolocationStateMachine-DjxU3gOp.esm.js → geolocationStateMachine-BJR0ZbYj.esm.js} +1 -1
  42. package/dist/id-selfie-flow.esm.js +7 -7
  43. package/dist/id.esm.js +3 -3
  44. package/dist/{idCaptureDefaults-BJglMiCL.esm.js → idCaptureDefaults-BRdqVIve.esm.js} +1 -1
  45. package/dist/{idCaptureManager-C2DaehZ0.esm.js → idCaptureManager-xHV3aAVd.esm.js} +3 -3
  46. package/dist/{idCaptureServices-B3rNM_gb.esm.js → idCaptureServices-P9BCoM4V.esm.js} +3 -3
  47. package/dist/{idCaptureStateMachine-CnAu9UcE.esm.js → idCaptureStateMachine-BM3TBJhd.esm.js} +9 -9
  48. package/dist/identity-reuse.d.ts +1 -1
  49. package/dist/{identityReuseManager-BBE2R_S7.d.ts → identityReuseManager-x2QG6QAm.d.ts} +4 -4
  50. package/dist/index.esm.js +1 -1
  51. package/dist/personhood.esm.js +4 -4
  52. package/dist/phone.d.ts +1 -1
  53. package/dist/phone.esm.js +1 -1
  54. package/dist/{phoneManager-DNzWb7_d.d.ts → phoneManager-D4FVaENS.d.ts} +9 -1
  55. package/dist/{phoneManager-tPB-SJvp.esm.js → phoneManager-Do-HaC6Z.esm.js} +19 -17
  56. package/dist/qe-signature.esm.js +1 -1
  57. package/dist/{runChildModule-CNOpKnr8.esm.js → runChildModule-BpOMtasT.esm.js} +1 -1
  58. package/dist/{sdkVersion-DD5MTu4p.esm.js → sdkVersion-DQRoTd6P.esm.js} +1 -1
  59. package/dist/selfie.esm.js +5 -5
  60. package/dist/{selfieManager-BLCxM_Ci.esm.js → selfieManager-CNW7zH1i.esm.js} +3 -3
  61. package/dist/{selfieStateMachine-BYUhydKm.esm.js → selfieStateMachine-R9J8mADt.esm.js} +2 -2
  62. package/dist/{session-cbcxp2lM.esm.js → session-BEhlnolX.esm.js} +3 -3
  63. package/dist/session.esm.js +4 -4
  64. package/dist/{sessionInitializer-BQnUIKSb.esm.js → sessionInitializer-DV11I5N9.esm.js} +3 -3
  65. package/dist/{setup-CzOLxZwN.esm.js → setup--2aSSY35.esm.js} +4 -4
  66. package/dist/signature.esm.js +1 -1
  67. package/dist/{signatureManager-BEhnPTe8.esm.js → signatureManager-CS217sC0.esm.js} +4 -8
  68. package/dist/{trueSightService-BWs2WTYv.esm.js → trueSightService-BFrcoNz3.esm.js} +2 -2
  69. package/dist/video-selfie.esm.js +4 -4
  70. package/dist/{videoSelfieCameraWarmer-BnPBPjIw.esm.js → videoSelfieCameraWarmer-Cx0iEoav.esm.js} +3 -3
  71. package/dist/wasm.esm.js +2 -2
  72. package/dist/watchlist-for-business.esm.js +1 -1
  73. package/dist/{watchlistForBusinessManager-CwMC60YS.esm.js → watchlistForBusinessManager-BUWO4S6n.esm.js} +4 -2
  74. package/dist/workflow.d.ts +4 -4
  75. package/dist/workflow.esm.js +16 -16
  76. package/package.json +3 -3
@@ -0,0 +1,688 @@
1
+ import { t as api } from "./api-Bx3gKW_y.esm.js";
2
+ import { t as endpoints } from "./endpoints-B-3Q-LUw.esm.js";
3
+ import { a as ADDRESS_STATE_SOURCES, c as EMAIL_SOURCES, d as NAME_SOURCES, f as POSTAL_CODE_SOURCES, h as TAX_ID_SOURCES, i as toEkycConfig, l as HOUSE_NO_SOURCES, m as STREET_SOURCES, n as getEKYCFields, o as CITY_SOURCES, p as STATE_CODE_HINTS, r as isFieldOptional, s as COUNTRY_SELECTOR_DISABLED_SOURCES, t as getEKYCCountry, u as MIDDLE_NAME_SOURCES } from "./ekycUtils-Dew1rBG0.esm.js";
4
+ import { i as assign, t as setup } from "./xstate.esm-Bg3FuvIs.esm.js";
5
+ import { n as fromPromise } from "./xstate-actors.esm-Ccyzgxj1.esm.js";
6
+ import { a as getPostalCodeMaxLength, c as STREET_LEVEL_REQUIRED_ERROR, d as usStateOptions, i as getPostalCodeErrorKey, l as fillFromSuggestion, n as FIXED_DIGIT_POSTAL_CODE_LENGTH, o as validatePostalCode, r as formatPostalCode, s as DYNAMIC_REQUIRED_KEY, t as debounceSearchActor, u as getStreetLevelErrorForSuggestion } from "./addressSearch-Dnwc7dMx.esm.js";
7
+ import { t as PhoneValidationProvider } from "./PhoneValidationProvider-Dok_Det7.esm.js";
8
+ import { t as validateCPF } from "./cpf-BIADjddF.esm.js";
9
+ //#region src/modules/ekyc/ekycValidators.ts
10
+ const phoneValidator = new PhoneValidationProvider();
11
+ /** Progressively formats an SSN as XXX-XX-XXXX */
12
+ function formatSSN(value) {
13
+ const ssn = value?.replace(/\D/g, "") ?? "";
14
+ if (ssn.length < 4) return ssn;
15
+ if (ssn.length < 6) return `${ssn.slice(0, 3)}-${ssn.slice(3)}`;
16
+ return `${ssn.slice(0, 3)}-${ssn.slice(3, 5)}-${ssn.slice(5, 9)}`;
17
+ }
18
+ /**
19
+ * Strips invalid characters from a name.
20
+ * Fixes SDKv1 regex syntax issue — allows letters, accented chars, spaces, commas, apostrophes.
21
+ */
22
+ function cleanName(name) {
23
+ return (name ?? "").replace(/[^a-zA-ZñÑáéíóúÁÉÍÓÚ\s,'´]/g, "").slice(0, 100);
24
+ }
25
+ const PO_BOX_REGEX = /POBox|P\.O\.Box|pobox|postofficebox|postbox|po\.box|p\.o\.box/i;
26
+ /** Returns true if the address looks like a P.O. Box */
27
+ function isPoBox(address) {
28
+ return PO_BOX_REGEX.test(address.replace(/\s/g, ""));
29
+ }
30
+ function validatePhone(phone, country) {
31
+ return phoneValidator.isValid(phone, country);
32
+ }
33
+ function formatPhoneE164(phone, country) {
34
+ return phoneValidator.formatE164(phone, country) ?? phone;
35
+ }
36
+ const SSN_FORMAT_REGEX = /^\d{3}-\d{2}-\d{4}$/;
37
+ const EMAIL_FORMAT_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
38
+ const buildPostalCodeParams = (country) => {
39
+ const fixedLen = FIXED_DIGIT_POSTAL_CODE_LENGTH[country];
40
+ if (fixedLen !== void 0) return { length: fixedLen };
41
+ let maxLen = getPostalCodeMaxLength(country);
42
+ if (country === "US" || country === "BR") maxLen = maxLen - 1;
43
+ return { maxLength: maxLen };
44
+ };
45
+ const createValidators = () => ({
46
+ required: (value, _rule, field) => {
47
+ if (value.trim().length > 0) return void 0;
48
+ const fieldName = field.displayLabel ?? field.label;
49
+ return fieldName ? {
50
+ key: DYNAMIC_REQUIRED_KEY,
51
+ params: { fieldName }
52
+ } : { key: DYNAMIC_REQUIRED_KEY };
53
+ },
54
+ streetLevelRequired: (value) => {
55
+ if (value.trim().length > 0) return void 0;
56
+ return STREET_LEVEL_REQUIRED_ERROR;
57
+ },
58
+ cpf: (value) => {
59
+ if (value.trim().length === 0) return void 0;
60
+ return validateCPF(value) ? void 0 : { key: "verification.errors.invalidTaxId" };
61
+ },
62
+ ssnFormat: (value) => {
63
+ if (value.trim().length === 0) return void 0;
64
+ return SSN_FORMAT_REGEX.test(value) ? void 0 : { key: "verification.errors.ssnFormat" };
65
+ },
66
+ noPoBox: (value) => {
67
+ if (value.trim().length === 0) return void 0;
68
+ return isPoBox(value) ? { key: "verification.errors.poBox" } : void 0;
69
+ },
70
+ postalCodeFormat: (value, rule) => {
71
+ if (rule.type !== "postalCodeFormat") return void 0;
72
+ if (value.trim().length === 0) return void 0;
73
+ if (validatePostalCode(value, rule.country)) return void 0;
74
+ return {
75
+ key: getPostalCodeErrorKey(rule.country),
76
+ params: buildPostalCodeParams(rule.country)
77
+ };
78
+ },
79
+ phoneFormat: (value, rule) => {
80
+ if (rule.type !== "phoneFormat") return void 0;
81
+ const trimmed = value.trim();
82
+ if (rule.optional && trimmed.length === 0) return void 0;
83
+ return validatePhone(trimmed, rule.country) ? void 0 : { key: "verification.errors.phoneInvalid" };
84
+ },
85
+ emailFormat: (value) => {
86
+ if (value.trim().length === 0) return void 0;
87
+ return EMAIL_FORMAT_REGEX.test(value) ? void 0 : { key: "verification.errors.emailInvalid" };
88
+ },
89
+ exactLength: (value, rule) => {
90
+ if (rule.type !== "exactLength") return void 0;
91
+ if (value.trim().length === 0) return void 0;
92
+ return value.length === rule.length ? void 0 : { key: "verification.errors.exactly10Characters" };
93
+ }
94
+ });
95
+ const normalizeFieldValue = (value) => typeof value === "string" ? value : String(value ?? "");
96
+ const evaluateRules = (value, rules, field, validators) => {
97
+ if (!rules) return void 0;
98
+ for (const rule of rules) {
99
+ const error = validators[rule.type](value, rule, field);
100
+ if (error) return error;
101
+ }
102
+ };
103
+ function validateEkycForm(values, fields) {
104
+ const validators = createValidators();
105
+ return fields.reduce((errors, field) => {
106
+ const value = normalizeFieldValue(values[field.name]);
107
+ const error = evaluateRules(value, field.validation, field, validators);
108
+ if (error) errors[field.name] = error;
109
+ return errors;
110
+ }, {});
111
+ }
112
+ function validateEkycField(values, fieldName, fields) {
113
+ const field = fields.find((f) => f.name === fieldName);
114
+ if (!field) return void 0;
115
+ const validators = createValidators();
116
+ const value = normalizeFieldValue(values[field.name]);
117
+ return evaluateRules(value, field.validation, field, validators);
118
+ }
119
+ //#endregion
120
+ //#region src/modules/ekyc/ekycActions.ts
121
+ function buildValidationRules(field, country, configSource) {
122
+ const rules = [];
123
+ if (field.required) rules.push({ type: "required" });
124
+ if (field.name === "taxId" && country === "BR") rules.push({ type: "cpf" });
125
+ if (field.name === "ssn" && (country === "US" || country === "CA")) rules.push({ type: "ssnFormat" });
126
+ if (field.name === "street") rules.push({ type: "noPoBox" });
127
+ if (field.name === "postalCode") rules.push({
128
+ type: "postalCodeFormat",
129
+ country
130
+ });
131
+ if (field.name === "phone") rules.push({
132
+ type: "phoneFormat",
133
+ country,
134
+ optional: isFieldOptional("phone", configSource)
135
+ });
136
+ if (field.name === "email") rules.push({ type: "emailFormat" });
137
+ if (field.name === "panNumber") rules.push({
138
+ type: "exactLength",
139
+ length: 10
140
+ });
141
+ return rules;
142
+ }
143
+ function buildFieldDefs(fields, configSource, country, enablePhoneRisk = false) {
144
+ const defs = [];
145
+ const add = (name, type, label, source, opts) => {
146
+ if (source === false) return;
147
+ const def = {
148
+ name,
149
+ type,
150
+ label,
151
+ source,
152
+ required: !isFieldOptional(name, configSource),
153
+ ...opts
154
+ };
155
+ const validation = buildValidationRules(def, country, configSource);
156
+ if (validation.length > 0) def.validation = validation;
157
+ defs.push(def);
158
+ };
159
+ const nameSource = fields.name || (NAME_SOURCES.includes(configSource) ? "user_input" : false);
160
+ if (nameSource) {
161
+ add("firstName", "text", "verification.labels.firstName", nameSource, {
162
+ maxLength: 100,
163
+ placeholder: "verification.placeholder.firstName"
164
+ });
165
+ if (MIDDLE_NAME_SOURCES.includes(configSource)) add("middleName", "text", "verification.labels.middleName", nameSource, {
166
+ maxLength: 100,
167
+ placeholder: "verification.placeholder.middleName",
168
+ optional: true
169
+ });
170
+ add("surName", "text", country === "US" ? "verification.labels.lastName" : "verification.labels.surName", nameSource, {
171
+ maxLength: 100,
172
+ placeholder: country === "US" ? "verification.placeholder.lastName" : "verification.placeholder.surname"
173
+ });
174
+ if (country === "MX") add("maternalSurname", "text", "verification.labels.maternalSurname", nameSource, {
175
+ maxLength: 100,
176
+ placeholder: "verification.placeholder.maternalSurname"
177
+ });
178
+ }
179
+ if (fields["date of birth"]) add("dateOfBirth", "date", "verification.labels.dateOfBirth", fields["date of birth"]);
180
+ const emailSource = fields.email || (EMAIL_SOURCES.includes(configSource) ? "user_input" : false);
181
+ if (emailSource) add("email", "text", "verification.labels.email", emailSource, { placeholder: "verification.placeholder.email" });
182
+ if (fields.phone) {
183
+ const phoneCountrySelectorDisabled = enablePhoneRisk && configSource !== "PHONE_RISK_1" || COUNTRY_SELECTOR_DISABLED_SOURCES.includes(configSource);
184
+ add("phone", "phone", "verification.labels.phone", fields.phone, { disableCountrySelector: phoneCountrySelectorDisabled });
185
+ }
186
+ if (fields.SSN) if (country === "BR" || TAX_ID_SOURCES.includes(configSource)) add("taxId", "text", "verification.labels.taxId", fields.SSN, { ...country === "BR" && { displayLabel: "CPF" } });
187
+ else if (country === "CN") add("ssn", "text", "verification.labels.prcId", fields.SSN);
188
+ else add("ssn", "text", "verification.labels.ssn", fields.SSN, { maxLength: 11 });
189
+ if (fields.nationality) if (country === "BR") add("nationality", "dropdown", "verification.labels.nationality", fields.nationality, { options: [
190
+ {
191
+ value: "brazilian",
192
+ label: "verification.labels.brazilian"
193
+ },
194
+ {
195
+ value: "naturalizedBrazilian",
196
+ label: "verification.labels.naturalizedBrazilian"
197
+ },
198
+ {
199
+ value: "foreigner",
200
+ label: "verification.labels.foreigner"
201
+ },
202
+ {
203
+ value: "brazilianBornAbroad",
204
+ label: "verification.labels.brazilianBornAbroad"
205
+ }
206
+ ] });
207
+ else add("nationality", "text", "verification.labels.nationality", fields.nationality);
208
+ if (fields.last4SSN) add("last4SSN", "text", "verification.labels.last4SSN", fields.last4SSN, { maxLength: 4 });
209
+ if (fields.idNum) add("idNum", "text", "verification.labels.idNum", fields.idNum, { maxLength: 13 });
210
+ if (fields.idNum1) add("idNum1", "text", "verification.labels.idNum1", fields.idNum1);
211
+ if (fields.gender) add("gender", "radio", "verification.labels.gender", fields.gender, { options: [{
212
+ value: "F",
213
+ label: "common.female"
214
+ }, {
215
+ value: "M",
216
+ label: "common.male"
217
+ }] });
218
+ if (fields.panNumber) add("panNumber", "text", "verification.labels.panNumber", fields.panNumber, { maxLength: 10 });
219
+ const addAddressFields = () => {
220
+ const needsAddress = HOUSE_NO_SOURCES.includes(configSource) || STREET_SOURCES.includes(configSource) || ADDRESS_STATE_SOURCES.includes(configSource);
221
+ const addrSource = fields.address || (needsAddress ? "user_input" : false);
222
+ if (!addrSource) return;
223
+ if (HOUSE_NO_SOURCES.includes(configSource)) add("houseNo", "text", "verification.labels.houseNo", addrSource, { section: "address" });
224
+ if (STREET_SOURCES.includes(configSource)) add("street", "text", "verification.labels.street", addrSource, { section: "address" });
225
+ if (CITY_SOURCES.includes(configSource)) add("city", "text", "verification.labels.city", addrSource, { section: "address" });
226
+ if (ADDRESS_STATE_SOURCES.includes(configSource)) add("state", country === "US" ? "dropdown" : "text", country === "US" ? "verification.labels.chooseState" : "verification.labels.state", addrSource, {
227
+ section: "address",
228
+ ...country === "US" ? {
229
+ options: usStateOptions,
230
+ placeholder: "verification.placeholder.state"
231
+ } : {
232
+ placeholder: "verification.placeholder.stateCode",
233
+ placeholderParams: { states: STATE_CODE_HINTS[country] ?? "" }
234
+ }
235
+ });
236
+ if (POSTAL_CODE_SOURCES.includes(configSource)) add("postalCode", "text", country === "US" ? "verification.labels.zipCode" : "verification.labels.postalCode", addrSource, {
237
+ section: "address",
238
+ maxLength: getPostalCodeMaxLength(country)
239
+ });
240
+ };
241
+ const addDriversLicenseFields = () => {
242
+ if (fields.dlNumber) add("dlNumber", "text", "verification.labels.dlNumber", fields.dlNumber, { section: "driverLicense" });
243
+ if (fields.dlState) add("dlState", "dropdown", "verification.labels.dlState", fields.dlState, {
244
+ section: "driverLicense",
245
+ options: usStateOptions,
246
+ placeholder: "verification.placeholder.state"
247
+ });
248
+ if (fields.dlExpireAt) add("dlExpireAt", "date", "verification.labels.dlExpireAt", fields.dlExpireAt, { section: "driverLicense" });
249
+ };
250
+ if (configSource === "US_TELCO_1") {
251
+ addDriversLicenseFields();
252
+ addAddressFields();
253
+ } else {
254
+ addAddressFields();
255
+ addDriversLicenseFields();
256
+ }
257
+ return defs;
258
+ }
259
+ function applyPrefill(fields, ocrData, otpStatus, _country) {
260
+ const values = {};
261
+ const prefilled = {};
262
+ const readonlyFields = [];
263
+ let hideEmail = false;
264
+ if (fields.name === "document_scan" && ocrData?.name) {
265
+ if (ocrData.name.firstName) {
266
+ values.firstName = ocrData.name.firstName;
267
+ prefilled.firstName = true;
268
+ readonlyFields.push("firstName");
269
+ }
270
+ if (ocrData.name.paternalLastName) {
271
+ values.surName = ocrData.name.paternalLastName;
272
+ prefilled.surName = true;
273
+ readonlyFields.push("surName");
274
+ }
275
+ if (ocrData.name.middleName) {
276
+ values.middleName = ocrData.name.middleName;
277
+ prefilled.middleName = true;
278
+ readonlyFields.push("middleName");
279
+ }
280
+ if (ocrData.name.maternalLastName) {
281
+ values.maternalSurname = ocrData.name.maternalLastName;
282
+ prefilled.maternalSurname = true;
283
+ readonlyFields.push("maternalSurname");
284
+ }
285
+ }
286
+ if (fields["date of birth"] === "document_scan" && ocrData?.birthDate) {
287
+ values.dateOfBirth = ocrData.birthDate;
288
+ prefilled.dateOfBirth = true;
289
+ readonlyFields.push("dateOfBirth");
290
+ }
291
+ const addressSource = fields.address;
292
+ if (addressSource === "document_scan" || addressSource === "poa_document") {
293
+ const addrData = addressSource === "poa_document" ? ocrData?.addressFieldsFromStatement ?? void 0 : ocrData?.addressFields ?? ocrData?.checkedAddressBean ?? void 0;
294
+ if (addrData) {
295
+ if (addrData.street) {
296
+ values.street = addrData.street;
297
+ prefilled.street = true;
298
+ readonlyFields.push("street");
299
+ }
300
+ if (addrData.city) {
301
+ values.city = addrData.city;
302
+ prefilled.city = true;
303
+ readonlyFields.push("city");
304
+ }
305
+ if (addrData.state) {
306
+ values.state = addrData.state;
307
+ prefilled.state = true;
308
+ readonlyFields.push("state");
309
+ }
310
+ if (addrData.postalCode) {
311
+ values.postalCode = addrData.postalCode;
312
+ prefilled.postalCode = true;
313
+ readonlyFields.push("postalCode");
314
+ }
315
+ if (addrData.houseNumber) {
316
+ values.houseNo = addrData.houseNumber;
317
+ prefilled.houseNo = true;
318
+ readonlyFields.push("houseNo");
319
+ }
320
+ }
321
+ }
322
+ if (fields.phone === "phone_module_input" && otpStatus?.phone) {
323
+ values.phone = otpStatus.phone;
324
+ prefilled.phone = true;
325
+ readonlyFields.push("phone");
326
+ }
327
+ if (fields.email === "email_module_input" && otpStatus?.email) {
328
+ values.email = otpStatus.email;
329
+ prefilled.email = true;
330
+ hideEmail = true;
331
+ }
332
+ return {
333
+ values,
334
+ prefilled,
335
+ hideEmail,
336
+ readonlyFields
337
+ };
338
+ }
339
+ function buildSubmitPayload(ctx) {
340
+ const payload = {};
341
+ for (const field of ctx.fields) {
342
+ const val = ctx.values[field.name];
343
+ if (val !== void 0 && val !== "") payload[field.name] = val;
344
+ }
345
+ if (payload.nationality) payload.nationality = payload.nationality.toUpperCase();
346
+ if (ctx.fieldsCountry) payload.countryCode = ctx.fieldsCountry;
347
+ if (ctx.hideEmail && ctx.values.email) payload.email = ctx.values.email;
348
+ if (payload.ssn && (ctx.fieldsCountry === "US" || ctx.fieldsCountry === "CA")) payload.ssn = payload.ssn.replace(/-/g, "");
349
+ if (payload.postalCode) payload.postalCode = payload.postalCode.replace(/[-\s]/g, "");
350
+ if (payload.phone) payload.phone = formatPhoneE164(payload.phone, ctx.fieldsCountry);
351
+ if (payload.state) payload.state = payload.state.toUpperCase();
352
+ if (ctx.configSource === "UK_CREDIT_BUREAU_1" && payload.countryCode) payload.country = payload.countryCode;
353
+ if (ctx.configSource === "US_DRIVERS_LICENSE_1" && payload.dlState) payload.state = payload.dlState;
354
+ return {
355
+ ...payload,
356
+ plugins: ["kyc"],
357
+ source: ctx.configSource
358
+ };
359
+ }
360
+ function processFieldValue(name, value, fieldsCountry) {
361
+ if ((name === "firstName" || name === "surName" || name === "middleName" || name === "maternalSurname") && value) return cleanName(value);
362
+ if (name === "ssn" && (fieldsCountry === "US" || fieldsCountry === "CA")) return formatSSN(value);
363
+ if (name === "postalCode") return formatPostalCode(value, fieldsCountry);
364
+ if (name === "panNumber") return value.replace(/[^a-zA-Z0-9]/g, "").toUpperCase();
365
+ return value;
366
+ }
367
+ //#endregion
368
+ //#region src/modules/ekyc/ekycServices.ts
369
+ /** Fetches module configuration for EXTERNAL_VERIFICATION */
370
+ async function fetchModuleConfig(flowId, signal) {
371
+ const url = `${endpoints.moduleConfig}?id=${encodeURIComponent(flowId)}&moduleKey=EXTERNAL_VERIFICATION`;
372
+ const res = await api.get(url, { signal });
373
+ if (!res.ok) throw new Error(`GET ${url} failed: ${res.status} ${res.statusText}`);
374
+ return res.data;
375
+ }
376
+ /** Fetches OCR data for pre-fill */
377
+ async function fetchOcrData(signal) {
378
+ const res = await api.get(endpoints.ocrData, { signal });
379
+ if (!res.ok) throw new Error(`GET ${endpoints.ocrData} failed: ${res.status} ${res.statusText}`);
380
+ return res.data;
381
+ }
382
+ /** Fetches phone/email from prior OTP modules */
383
+ async function fetchOtpStatus(signal) {
384
+ const res = await api.get(endpoints.otpStatus, { signal });
385
+ if (!res.ok) throw new Error(`GET ${endpoints.otpStatus} failed: ${res.status} ${res.statusText}`);
386
+ return res.data;
387
+ }
388
+ var EkycSubmitError = class extends Error {
389
+ constructor(status, apiError) {
390
+ super(`POST ${endpoints.ekycSubmit} failed: ${status} – ${apiError}`);
391
+ this.name = "EkycSubmitError";
392
+ this.status = status;
393
+ this.apiError = apiError;
394
+ }
395
+ };
396
+ /** Submits eKYC verification */
397
+ async function submitEkyc(data, signal) {
398
+ try {
399
+ return (await api.post(endpoints.ekycSubmit, data, { signal })).data;
400
+ } catch (err) {
401
+ const httpErr = err;
402
+ if (typeof httpErr.status === "number") {
403
+ const body = httpErr.data;
404
+ const apiError = body?.error ?? body?.message ?? String(err);
405
+ throw new EkycSubmitError(httpErr.status, apiError);
406
+ }
407
+ throw err;
408
+ }
409
+ }
410
+ //#endregion
411
+ //#region src/modules/ekyc/ekycGuards.ts
412
+ const hasNoValidationErrorsGuard = ({ context }) => Object.keys(context.validationErrors ?? {}).length === 0;
413
+ const hasFlowIdGuard = ({ context }) => !!context.config.flowId;
414
+ const hasVerificationFieldsGuard = ({ context }) => !!context.config.verificationFields;
415
+ const COUNTRY_NOT_SUPPORTED_MSG = "Request unsuccessful. Country not supported for EKYC.";
416
+ const isCountryNotSupportedGuard = ({ event }) => {
417
+ const err = event.error;
418
+ return err instanceof EkycSubmitError && err.status === 400 && err.apiError === COUNTRY_NOT_SUPPORTED_MSG;
419
+ };
420
+ //#endregion
421
+ //#region src/modules/ekyc/ekycActors.ts
422
+ const fetchModuleConfigActor = fromPromise(async ({ input, signal }) => fetchModuleConfig(input.flowId, signal));
423
+ const fetchPrefillDataActor = fromPromise(async ({ signal }) => {
424
+ const [ocrData, otpStatus] = await Promise.all([fetchOcrData(signal).catch(() => void 0), fetchOtpStatus(signal).catch(() => void 0)]);
425
+ return {
426
+ ocrData,
427
+ otpStatus
428
+ };
429
+ });
430
+ const submitEkycActor = fromPromise(async ({ input, signal }) => submitEkyc(input, signal));
431
+ //#endregion
432
+ //#region src/modules/ekyc/ekycStateMachine.ts
433
+ const ADDRESS_AUTOCOMPLETE_KEYS = [
434
+ "street",
435
+ "city",
436
+ "state",
437
+ "postalCode",
438
+ "houseNo"
439
+ ];
440
+ const omitKeys = (errors, keys) => {
441
+ if (!errors) return void 0;
442
+ const next = { ...errors };
443
+ for (const key of keys) delete next[key];
444
+ return Object.keys(next).length > 0 ? next : void 0;
445
+ };
446
+ const ekycMachine = setup({
447
+ types: {
448
+ context: {},
449
+ events: {},
450
+ input: {}
451
+ },
452
+ actors: {
453
+ fetchModuleConfig: fetchModuleConfigActor,
454
+ fetchPrefillData: fetchPrefillDataActor,
455
+ submitEkyc: submitEkycActor,
456
+ debounceSearch: debounceSearchActor
457
+ },
458
+ actions: {
459
+ setModuleConfig: assign(({ context, event }) => {
460
+ const config = event.output;
461
+ const source = config.source ?? context.config.source ?? "";
462
+ const country = context.config.fieldsCountry ?? getEKYCCountry(source);
463
+ const vFields = getEKYCFields(config);
464
+ return {
465
+ moduleConfig: config,
466
+ verificationFields: vFields,
467
+ configSource: source,
468
+ fieldsCountry: country,
469
+ fields: buildFieldDefs(vFields, source, country, config.enablePhoneRisk)
470
+ };
471
+ }),
472
+ applyPrefillData: assign(({ context, event }) => {
473
+ const { ocrData, otpStatus } = event.output;
474
+ const { values, prefilled, hideEmail, readonlyFields } = applyPrefill(context.verificationFields, ocrData, otpStatus, context.fieldsCountry);
475
+ return {
476
+ values,
477
+ prefilled,
478
+ hideEmail,
479
+ fields: context.fields.map((f) => ({
480
+ ...f,
481
+ readonly: readonlyFields.includes(f.name) ? true : f.readonly
482
+ }))
483
+ };
484
+ }),
485
+ updateField: assign(({ context, event }) => {
486
+ if (event.type !== "DATA_CHANGED") return {};
487
+ const processedValue = processFieldValue(event.name, event.value, context.fieldsCountry);
488
+ return {
489
+ values: {
490
+ ...context.values,
491
+ [event.name]: processedValue
492
+ },
493
+ submitError: ""
494
+ };
495
+ }),
496
+ clearFieldValidationError: assign(({ context, event }) => {
497
+ if (event.type !== "DATA_CHANGED") return {};
498
+ const errs = context.validationErrors;
499
+ if (!errs?.[event.name]) return {};
500
+ const next = { ...errs };
501
+ delete next[event.name];
502
+ return { validationErrors: Object.keys(next).length > 0 ? next : void 0 };
503
+ }),
504
+ validateFormField: assign(({ context, event }) => {
505
+ if (event.type !== "VALIDATE_FIELD") return {};
506
+ const message = validateEkycField(context.values, event.name, context.fields);
507
+ const next = { ...context.validationErrors ?? {} };
508
+ if (message) next[event.name] = message;
509
+ else delete next[event.name];
510
+ return { validationErrors: Object.keys(next).length > 0 ? next : void 0 };
511
+ }),
512
+ computeValidationResult: assign(({ context }) => {
513
+ const errors = validateEkycForm(context.values, context.fields);
514
+ return { validationErrors: Object.keys(errors).length > 0 ? errors : void 0 };
515
+ }),
516
+ fillAddressFields: assign(({ context, event }) => {
517
+ const { suggestion } = event;
518
+ const activeFields = new Set(context.fields.map((f) => f.name));
519
+ const { values: newValues } = fillFromSuggestion(context.values, {}, suggestion, activeFields);
520
+ const clearedErrors = omitKeys(context.validationErrors, ADDRESS_AUTOCOMPLETE_KEYS);
521
+ const streetError = getStreetLevelErrorForSuggestion(suggestion, activeFields);
522
+ const validationErrors = {
523
+ ...clearedErrors ?? {},
524
+ ...streetError !== void 0 ? { street: streetError } : {}
525
+ };
526
+ return {
527
+ values: newValues,
528
+ addressSuggestions: [],
529
+ _searchQuery: "",
530
+ validationErrors: Object.keys(validationErrors).length > 0 ? validationErrors : void 0,
531
+ submitError: ""
532
+ };
533
+ }),
534
+ setAddressSuggestions: assign(({ event }) => ({ addressSuggestions: event.suggestions })),
535
+ setErrorMessage: assign(({ event }) => ({ errorMessage: String(event.error ?? "verification.error") })),
536
+ clearErrorMessage: assign({ errorMessage: () => "" }),
537
+ setSubmitError: assign(() => ({ submitError: "verification.errors.countryNotSupported" })),
538
+ clearSubmitError: assign({ submitError: () => "" })
539
+ },
540
+ guards: {
541
+ hasNoValidationErrors: hasNoValidationErrorsGuard,
542
+ hasFlowId: hasFlowIdGuard,
543
+ hasVerificationFields: hasVerificationFieldsGuard,
544
+ isCountryNotSupported: isCountryNotSupportedGuard
545
+ }
546
+ }).createMachine({
547
+ id: "ekyc",
548
+ initial: "idle",
549
+ context: ({ input }) => {
550
+ const config = toEkycConfig(input.config);
551
+ return {
552
+ config,
553
+ moduleConfig: void 0,
554
+ verificationFields: {},
555
+ configSource: config.source ?? "",
556
+ fieldsCountry: config.fieldsCountry ?? "",
557
+ fields: [],
558
+ values: {},
559
+ addressSuggestions: [],
560
+ prefilled: {},
561
+ hideEmail: false,
562
+ errorMessage: "",
563
+ submitError: "",
564
+ _searchQuery: ""
565
+ };
566
+ },
567
+ states: {
568
+ idle: { on: { LOAD: [
569
+ {
570
+ target: "loading",
571
+ guard: "hasFlowId"
572
+ },
573
+ {
574
+ target: "prefilling",
575
+ guard: "hasVerificationFields",
576
+ actions: assign(({ context }) => {
577
+ const vFields = context.config.verificationFields;
578
+ const source = context.config.source ?? "";
579
+ const country = context.config.fieldsCountry ?? getEKYCCountry(source);
580
+ return {
581
+ verificationFields: vFields,
582
+ configSource: source,
583
+ fieldsCountry: country,
584
+ fields: buildFieldDefs(vFields, source, country, context.config.enablePhoneRisk)
585
+ };
586
+ })
587
+ },
588
+ { target: "misconfigured" }
589
+ ] } },
590
+ loading: { invoke: {
591
+ id: "fetchModuleConfig",
592
+ src: "fetchModuleConfig",
593
+ input: ({ context }) => ({ flowId: context.config.flowId }),
594
+ onDone: {
595
+ target: "prefilling",
596
+ actions: "setModuleConfig"
597
+ },
598
+ onError: {
599
+ target: "error",
600
+ actions: "setErrorMessage"
601
+ }
602
+ } },
603
+ prefilling: { invoke: {
604
+ id: "fetchPrefillData",
605
+ src: "fetchPrefillData",
606
+ onDone: {
607
+ target: "form",
608
+ actions: "applyPrefillData"
609
+ },
610
+ onError: { target: "form" }
611
+ } },
612
+ form: {
613
+ initial: "inputting",
614
+ states: {
615
+ inputting: { on: {
616
+ DATA_CHANGED: { actions: ["updateField", "clearFieldValidationError"] },
617
+ VALIDATE_FIELD: { actions: "validateFormField" },
618
+ SUBMIT: { target: "validatingSubmit" }
619
+ } },
620
+ searching: {
621
+ invoke: {
622
+ id: "debounceSearch",
623
+ src: "debounceSearch",
624
+ input: ({ context }) => ({ query: context._searchQuery })
625
+ },
626
+ on: {
627
+ DATA_CHANGED: { actions: ["updateField", "clearFieldValidationError"] },
628
+ VALIDATE_FIELD: { actions: "validateFormField" },
629
+ RESULTS: {
630
+ target: "inputting",
631
+ actions: "setAddressSuggestions"
632
+ }
633
+ }
634
+ },
635
+ validatingSubmit: {
636
+ entry: "computeValidationResult",
637
+ always: [{
638
+ guard: "hasNoValidationErrors",
639
+ target: "#ekyc.submitting"
640
+ }, { target: "inputting" }]
641
+ }
642
+ },
643
+ on: {
644
+ SEARCH_ADDRESS: {
645
+ target: ".searching",
646
+ actions: assign(({ event }) => ({
647
+ _searchQuery: event.query,
648
+ addressSuggestions: []
649
+ }))
650
+ },
651
+ SELECT_ADDRESS: {
652
+ target: ".inputting",
653
+ actions: "fillAddressFields"
654
+ },
655
+ SKIP: { target: "#ekyc.finished" },
656
+ CLOSE: { target: "#ekyc.closed" }
657
+ }
658
+ },
659
+ submitting: { invoke: {
660
+ id: "submitEkyc",
661
+ src: "submitEkyc",
662
+ input: ({ context }) => buildSubmitPayload(context),
663
+ onDone: { target: "success" },
664
+ onError: [{
665
+ target: "form",
666
+ guard: "isCountryNotSupported",
667
+ actions: "setSubmitError"
668
+ }, {
669
+ target: "error",
670
+ actions: "setErrorMessage"
671
+ }]
672
+ } },
673
+ success: { after: { 3e3: "finished" } },
674
+ error: { on: {
675
+ RETRY: {
676
+ target: "form",
677
+ actions: "clearErrorMessage"
678
+ },
679
+ SKIP: { target: "finished" },
680
+ CLOSE: { target: "closed" }
681
+ } },
682
+ misconfigured: { on: { CLOSE: { target: "closed" } } },
683
+ finished: { type: "final" },
684
+ closed: { type: "final" }
685
+ }
686
+ });
687
+ //#endregion
688
+ export { ekycMachine as t };
@@ -1,2 +1,2 @@
1
- import { a as NAMIRIAL_QES_CONSENT_KEYS, c as areAllConsented, i as AE_CONSENT_KEYS, l as getConsentKeys, n as createElectronicSignatureManagerFromActor, o as NAMIRIAL_QES_PROVIDER_CODE, r as electronicSignatureMachine, s as QE_CONSENT_KEYS, t as createElectronicSignatureManager, u as getDefaultConsentChecks } from "./electronicSignatureManager-COJYfU0x.esm.js";
1
+ import { a as NAMIRIAL_QES_CONSENT_KEYS, c as areAllConsented, i as AE_CONSENT_KEYS, l as getConsentKeys, n as createElectronicSignatureManagerFromActor, o as NAMIRIAL_QES_PROVIDER_CODE, r as electronicSignatureMachine, s as QE_CONSENT_KEYS, t as createElectronicSignatureManager, u as getDefaultConsentChecks } from "./electronicSignatureManager-B-IMLsp-.esm.js";
2
2
  export { AE_CONSENT_KEYS, NAMIRIAL_QES_CONSENT_KEYS, NAMIRIAL_QES_PROVIDER_CODE, QE_CONSENT_KEYS, areAllConsented, createElectronicSignatureManager, createElectronicSignatureManagerFromActor, electronicSignatureMachine, getConsentKeys, getDefaultConsentChecks };