@incodetech/core 0.0.0-dev-20260409-a38d5e8 → 0.0.0-dev-20260409-09dfd52

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 (134) hide show
  1. package/dist/BrowserStorageProvider-CXaS5Ooj.esm.js +55 -0
  2. package/dist/{OpenViduRecordingProvider-Bn2meybK.esm.js → OpenViduRecordingProvider-D_cVAwYQ.esm.js} +1 -1
  3. package/dist/{WasmUtilProvider-BpZSvZbg.esm.js → WasmUtilProvider-mWSXzp7b.esm.js} +1 -1
  4. package/dist/{addressSearch-DOFI7lwy.esm.js → addressSearch-C26OZIx0.esm.js} +4 -4
  5. package/dist/antifraud.d.ts +1 -1
  6. package/dist/antifraud.esm.js +4 -37
  7. package/dist/antifraudStateMachine-B74mO8vr.esm.js +39 -0
  8. package/dist/authentication.d.ts +11 -11
  9. package/dist/authentication.esm.js +22 -19
  10. package/dist/authenticationManager-BBQHippG.esm.js +67 -0
  11. package/dist/{authenticationManager-C2mk36yK.d.ts → authenticationManager-DOTo1EYF.d.ts} +2 -2
  12. package/dist/{authenticationManager-C7dL_avf.esm.js → authenticationStateMachine-DCJ0ArAt.esm.js} +7 -67
  13. package/dist/{backCameraStream-tabTmwDS.esm.js → backCameraStream-D9g2wyil.esm.js} +3 -3
  14. package/dist/camera.d.ts +1 -1
  15. package/dist/camera.esm.js +3 -3
  16. package/dist/consent.d.ts +55 -55
  17. package/dist/consent.esm.js +4 -149
  18. package/dist/consentStateMachine-DIdJXJW0.esm.js +151 -0
  19. package/dist/cross-document-data-match.d.ts +1 -1
  20. package/dist/cross-document-data-match.esm.js +4 -4
  21. package/dist/curp-validation.d.ts +5 -5
  22. package/dist/curp-validation.esm.js +4 -417
  23. package/dist/curpValidationStateMachine-Dp5WB6__.esm.js +419 -0
  24. package/dist/{deepsightLoader-Cj6SyUQ-.esm.js → deepsightLoader-CaULV07H.esm.js} +10 -10
  25. package/dist/{deepsightService-ByD6uIs7.d.ts → deepsightService-S-tU77m-.d.ts} +2 -2
  26. package/dist/{deepsightService-BjgXl5hs.esm.js → deepsightService-rPGLH8Xp.esm.js} +5 -5
  27. package/dist/device.esm.js +3 -3
  28. package/dist/document-capture.d.ts +80 -78
  29. package/dist/document-capture.esm.js +8 -403
  30. package/dist/document-upload.d.ts +53 -53
  31. package/dist/document-upload.esm.js +7 -7
  32. package/dist/documentCaptureStateMachine-ByYOCKz5.esm.js +403 -0
  33. package/dist/ekyb.d.ts +3 -3
  34. package/dist/ekyb.esm.js +10 -655
  35. package/dist/ekybStateMachine-DRku_YmR.esm.js +653 -0
  36. package/dist/ekyc.d.ts +3 -3
  37. package/dist/ekyc.esm.js +6 -10614
  38. package/dist/ekycStateMachine-CSWaaWVl.esm.js +10615 -0
  39. package/dist/email.d.ts +3 -3
  40. package/dist/email.esm.js +6 -5
  41. package/dist/{emailManager-CU_hzrsl.d.ts → emailManager-D6CHM2QO.d.ts} +4 -3
  42. package/dist/emailManager-DByjyeY8.esm.js +238 -0
  43. package/dist/{emailManager-_9R4vm6g.esm.js → emailStateMachine-BoIkeCw5.esm.js} +6 -239
  44. package/dist/{events-DlHrOIRc.esm.js → events-W91zLpx4.esm.js} +5 -1
  45. package/dist/events.esm.js +2 -2
  46. package/dist/extensibility.d.ts +15 -15
  47. package/dist/extensibility.esm.js +33 -26
  48. package/dist/face-match.d.ts +7 -6
  49. package/dist/face-match.esm.js +8 -129
  50. package/dist/faceCaptureManagerFactory-Bspg2Tyf.esm.js +117 -0
  51. package/dist/{faceCaptureManagerFactory-Da_-ohdg.d.ts → faceCaptureManagerFactory-P2yy30KU.d.ts} +8 -8
  52. package/dist/{faceCaptureSetup-CaVWkjvE.esm.js → faceCaptureSetup-CQevz86q.esm.js} +5 -119
  53. package/dist/faceMatchStateMachine-CLterVEC.esm.js +127 -0
  54. package/dist/flow.d.ts +8 -13
  55. package/dist/flow.esm.js +10 -29
  56. package/dist/{flowCompletionService-B5JemmC6.esm.js → flowCompletionService-DZSDUXus.esm.js} +2 -2
  57. package/dist/{flowServices-p22wrYPf.esm.js → flowServices-YATk0fgY.esm.js} +3 -3
  58. package/dist/geolocation.d.ts +7 -6
  59. package/dist/geolocation.esm.js +7 -105
  60. package/dist/geolocationStateMachine-CRRUCl9K.esm.js +105 -0
  61. package/dist/{getDeviceClass-DEzz4cmY.esm.js → getDeviceClass-DBF-ExLR.esm.js} +1 -1
  62. package/dist/government-validation.d.ts +2 -2
  63. package/dist/government-validation.esm.js +5 -269
  64. package/dist/governmentValidationStateMachine-C_iPX9VE.esm.js +271 -0
  65. package/dist/http.esm.js +1 -1
  66. package/dist/id.d.ts +10 -10
  67. package/dist/id.esm.js +22 -20
  68. package/dist/idCaptureManager-CJfatzuY.esm.js +335 -0
  69. package/dist/{idCaptureManager-CV08v1e3.d.ts → idCaptureManager-CbZvdr9y.d.ts} +7 -7
  70. package/dist/{idCaptureManager-dyZzKv8L.esm.js → idCaptureStateMachine-gf-Q9piu.esm.js} +17 -346
  71. package/dist/index.d.ts +2 -2
  72. package/dist/index.esm.js +8 -8
  73. package/dist/{lib-Bavz2qmt.esm.js → lib-BzVJ-zxG.esm.js} +1 -1
  74. package/dist/mandatory-consent.d.ts +55 -55
  75. package/dist/mandatory-consent.esm.js +4 -124
  76. package/dist/mandatoryConsentStateMachine-BZNBJ1fK.esm.js +126 -0
  77. package/dist/{openviduLazy-vhrVZCr_.esm.js → openviduLazy-CLg_-u0m.esm.js} +2 -2
  78. package/dist/openviduLazy-rFXBtZVZ.esm.js +3 -0
  79. package/dist/{permissionServices-Cskq32Yd.esm.js → permissionServices-Cisv73eQ.esm.js} +2 -2
  80. package/dist/phone.d.ts +3 -3
  81. package/dist/phone.esm.js +6 -5
  82. package/dist/phoneManager-DhC4obPF.esm.js +258 -0
  83. package/dist/{phoneManager-ulJuGvJ8.d.ts → phoneManager-Zwr-qCnC.d.ts} +2 -2
  84. package/dist/{phoneManager-DerdUfd4.esm.js → phoneStateMachine-Cc_w4tC0.esm.js} +5 -258
  85. package/dist/{recordingService-483wQ6kR.esm.js → recordingService-CCfxUY7-.esm.js} +14 -68
  86. package/dist/redirect-to-mobile.d.ts +2 -2
  87. package/dist/redirect-to-mobile.esm.js +5 -247
  88. package/dist/redirectToMobileStateMachine-vOe27Ufw.esm.js +249 -0
  89. package/dist/runChildModule-DVC4JEjp.esm.js +27 -0
  90. package/dist/selfie.d.ts +11 -11
  91. package/dist/selfie.esm.js +22 -19
  92. package/dist/selfieManager-CorEST5h.esm.js +60 -0
  93. package/dist/{selfieManager-DCRP7X75.d.ts → selfieManager-DNwfxieF.d.ts} +2 -2
  94. package/dist/selfieStateMachine-3b19ON1z.esm.js +56 -0
  95. package/dist/{session-CUh77zj3.esm.js → session-B_rKSRql.esm.js} +4 -4
  96. package/dist/session.d.ts +1 -1
  97. package/dist/session.esm.js +6 -6
  98. package/dist/{setup-DpHakxsC.d.ts → setup-BYqwVLiv.d.ts} +1 -1
  99. package/dist/{setup-XpxfZgKn.esm.js → setup-DLvhsDol.esm.js} +6 -5
  100. package/dist/signature.d.ts +4 -3
  101. package/dist/signature.esm.js +6 -189
  102. package/dist/signatureStateMachine-CU92zCXU.esm.js +189 -0
  103. package/dist/{stats-DHDoqSBV.esm.js → stats-gFD2351t.esm.js} +1 -1
  104. package/dist/stats.esm.js +2 -2
  105. package/dist/{types-2OPf1pyv.d.ts → types-CYJ0Ish6.d.ts} +1 -1
  106. package/dist/types-CjsEZRcz.d.ts +35 -0
  107. package/dist/{types-CVJVQ7fp.d.ts → types-DU8HmI5U.d.ts} +1 -1
  108. package/dist/wasm.d.ts +2 -2
  109. package/dist/wasm.esm.js +8 -8
  110. package/dist/workflow.d.ts +813 -0
  111. package/dist/workflow.esm.js +600 -0
  112. package/package.json +7 -3
  113. package/dist/openviduLazy-BIPHozOu.esm.js +0 -3
  114. package/dist/selfieManager-DeOcNel4.esm.js +0 -110
  115. /package/dist/{Actor-Ba71-_30.d.ts → Actor-DbWH1K6E.d.ts} +0 -0
  116. /package/dist/{BaseWasmProvider-D-s_6M5H.esm.js → BaseWasmProvider-DoYDYH1z.esm.js} +0 -0
  117. /package/dist/{BrowserEnvironmentProvider-DaHeLJQw.esm.js → BrowserEnvironmentProvider-BtKLxTx4.esm.js} +0 -0
  118. /package/dist/{BrowserTimerProvider-BhD2MlHg.esm.js → BrowserTimerProvider-v7bpbrAk.esm.js} +0 -0
  119. /package/dist/{ITimerCapability-oixwa6nj.esm.js → ITimerCapability-BZO_FsCo.esm.js} +0 -0
  120. /package/dist/{Manager-BN2g_I8W.d.ts → Manager-DcPMRgTm.d.ts} +0 -0
  121. /package/dist/{MotionSensorProvider-CodM3e0E.esm.js → MotionSensorProvider-D90R4qwV.esm.js} +0 -0
  122. /package/dist/{StateMachine-BoJsfMvg.d.ts → StateMachine-BBuIgsHT.d.ts} +0 -0
  123. /package/dist/{api-DzpnV6O7.esm.js → api-aa9Mx20l.esm.js} +0 -0
  124. /package/dist/{browserSimulation-B4ubb2OL.esm.js → browserSimulation-DFqGKQAD.esm.js} +0 -0
  125. /package/dist/{camera-1eeGnAaL.d.ts → camera-DATT31my.d.ts} +0 -0
  126. /package/dist/{camera-DmkFpf5N.esm.js → camera-DpPQS_-5.esm.js} +0 -0
  127. /package/dist/{chunk-DsxENsBR.esm.js → chunk-YGHKo4MY.esm.js} +0 -0
  128. /package/dist/{displayErrors-BZLX7idb.d.ts → displayErrors-xrg0ejaS.d.ts} +0 -0
  129. /package/dist/{flowCompletionService-D-3YCHyO.d.ts → flowCompletionService-gxt5reFV.d.ts} +0 -0
  130. /package/dist/{getBrowser-Dtyt9J_h.esm.js → getBrowser-DCcD7H-M.esm.js} +0 -0
  131. /package/dist/{platform-Dv7a2fv-.esm.js → platform-DctkySJU.esm.js} +0 -0
  132. /package/dist/{types-D_QfFKxT.d.ts → types-CIjb0FKu.d.ts} +0 -0
  133. /package/dist/{warmup-CIj_wEV_.d.ts → warmup-Ckb1hN85.d.ts} +0 -0
  134. /package/dist/{xstate.esm-Bv55-lJ4.esm.js → xstate.esm-B7FPE6br.esm.js} +0 -0
@@ -0,0 +1,653 @@
1
+ import { t as api } from "./api-aa9Mx20l.esm.js";
2
+ import { _ as endpoints } from "./events-W91zLpx4.esm.js";
3
+ import { i as fromPromise, n as assign, t as setup } from "./xstate.esm-B7FPE6br.esm.js";
4
+ import { a as POSTAL_CODE_FORMAT_ERROR_KEYS, c as getPostalCodeMaxLength, i as FIXED_DIGIT_POSTAL_CODE_LENGTH, l as validatePostalCode, n as fillFromSuggestion, o as formatPostalCode, r as DYNAMIC_REQUIRED_KEY, s as getPostalCodeErrorKey, t as debounceSearchActor, u as usStateOptions } from "./addressSearch-C26OZIx0.esm.js";
5
+ import { t as getFlow } from "./flowServices-YATk0fgY.esm.js";
6
+
7
+ //#region src/modules/ekyb/ekybConstants.ts
8
+ const UBO_INPUT_LIMIT = 8;
9
+ /**
10
+ * Countries available in all environments.
11
+ * Sorted alphabetically by display name.
12
+ */
13
+ const SUPPORTED_COUNTRIES = [
14
+ "BR",
15
+ "CN",
16
+ "FR",
17
+ "DE",
18
+ "IL",
19
+ "IT",
20
+ "MX",
21
+ "ES",
22
+ "GB",
23
+ "US"
24
+ ];
25
+ /**
26
+ * Additional countries available only in dev/staging environments.
27
+ */
28
+ const DEV_ONLY_COUNTRIES = [
29
+ "CM",
30
+ "KE",
31
+ "NG"
32
+ ];
33
+ /**
34
+ * Union of all recognized country codes (prod + dev).
35
+ */
36
+ const ALL_COUNTRIES = [...SUPPORTED_COUNTRIES, ...DEV_ONLY_COUNTRIES];
37
+ const ALL_COUNTRIES_SET = new Set(ALL_COUNTRIES);
38
+ function isSupportedCountry(code) {
39
+ return ALL_COUNTRIES_SET.has(code);
40
+ }
41
+ const FIELD_ORDER = [
42
+ "name-user_input",
43
+ "taxId-user_input",
44
+ "street-user_input",
45
+ "houseNo-user_input",
46
+ "address2-user_input",
47
+ "city-user_input",
48
+ "state-user_input",
49
+ "postalCode-user_input"
50
+ ];
51
+ const FIELD_NAME_MAPPING = {
52
+ "name-user_input": "businessName",
53
+ "street-user_input": "street",
54
+ "houseNo-user_input": "houseNo",
55
+ "address2-user_input": "addressLine2",
56
+ "city-user_input": "city",
57
+ "state-user_input": "state",
58
+ "postalCode-user_input": "postalCode",
59
+ "taxId-user_input": "taxId"
60
+ };
61
+ const COUNTRIES_WITH_CNPJ_VALIDATION = ["BR"];
62
+ const COUNTRIES_WITH_SPECIAL_TAX_ID_RULES = [
63
+ "NG",
64
+ "CM",
65
+ "KE"
66
+ ];
67
+ const BUSINESS_NAME_OPTIONAL_COUNTRIES = [];
68
+ const ADDRESS_FULLY_OPTIONAL_COUNTRIES = [
69
+ "BR",
70
+ "GB",
71
+ "FR"
72
+ ];
73
+ const ADDRESS_FIELDS = [
74
+ "street",
75
+ "houseNo",
76
+ "addressLine2",
77
+ "city",
78
+ "state",
79
+ "postalCode"
80
+ ];
81
+ const ALL_COUNTRIES_OPTIONAL_FIELDS = ["ubo"];
82
+
83
+ //#endregion
84
+ //#region src/modules/ekyb/ekybValidators.ts
85
+ const CNPJ_FORMATTED_LENGTH = 18;
86
+ const CNPJ_CLEAN_LENGTH = 14;
87
+ const INVALID_CNPJ_PATTERNS = [
88
+ "00000000000000",
89
+ "11111111111111",
90
+ "22222222222222",
91
+ "33333333333333",
92
+ "44444444444444",
93
+ "55555555555555",
94
+ "66666666666666",
95
+ "77777777777777",
96
+ "88888888888888",
97
+ "99999999999999"
98
+ ];
99
+ const CNPJ_FIRST_DIGIT_FACTORS = [
100
+ 5,
101
+ 4,
102
+ 3,
103
+ 2,
104
+ 9,
105
+ 8,
106
+ 7,
107
+ 6,
108
+ 5,
109
+ 4,
110
+ 3,
111
+ 2
112
+ ];
113
+ const CNPJ_SECOND_DIGIT_FACTORS = [
114
+ 6,
115
+ 5,
116
+ 4,
117
+ 3,
118
+ 2,
119
+ 9,
120
+ 8,
121
+ 7,
122
+ 6,
123
+ 5,
124
+ 4,
125
+ 3,
126
+ 2
127
+ ];
128
+ function cleanCnpjString(cnpj) {
129
+ return cnpj.replace(/\./g, "").replace(/\//g, "").replace(/-/g, "");
130
+ }
131
+ function calculateVerificationDigit(cnpjString, factors) {
132
+ let digit = 11 - factors.reduce((acc, factor, index) => acc + Number.parseInt(cnpjString.charAt(index), 10) * factor, 0) % 11;
133
+ if (digit >= 10) digit = 0;
134
+ return digit.toString();
135
+ }
136
+ /**
137
+ * Validates a Brazilian CNPJ number (14-digit checksum).
138
+ * Accepts formatted (00.000.000/0000-00) or unformatted input.
139
+ */
140
+ function validateCNPJ(cnpjInput) {
141
+ if (!cnpjInput || typeof cnpjInput !== "string") return false;
142
+ let cnpj = cnpjInput.trim();
143
+ if (cnpj.length === CNPJ_FORMATTED_LENGTH) cnpj = cleanCnpjString(cnpj);
144
+ if (cnpj.length !== CNPJ_CLEAN_LENGTH) return false;
145
+ if (!/^\d+$/.test(cnpj)) return false;
146
+ if (INVALID_CNPJ_PATTERNS.includes(cnpj)) return false;
147
+ const first = calculateVerificationDigit(cnpj, CNPJ_FIRST_DIGIT_FACTORS);
148
+ if (cnpj.charAt(12) !== first) return false;
149
+ const second = calculateVerificationDigit(cnpj, CNPJ_SECOND_DIGIT_FACTORS);
150
+ if (cnpj.charAt(13) !== second) return false;
151
+ return true;
152
+ }
153
+
154
+ //#endregion
155
+ //#region src/modules/ekyb/ekybUtils.ts
156
+ /** Sorts modules based on a custom order; items not in order maintain relative position */
157
+ function sortModulesByOrder(modules, customOrder) {
158
+ return [...modules].sort((a, b) => {
159
+ const indexA = customOrder.indexOf(a);
160
+ const indexB = customOrder.indexOf(b);
161
+ if (indexA !== -1 && indexB !== -1) return indexA - indexB;
162
+ if (indexA !== -1) return -1;
163
+ if (indexB !== -1) return 1;
164
+ return 0;
165
+ });
166
+ }
167
+ /** Determines if a field is optional for the given country */
168
+ function isFieldOptional(fieldName, countryCode) {
169
+ if (ALL_COUNTRIES_OPTIONAL_FIELDS.includes(fieldName)) return true;
170
+ if (fieldName === "businessName") return BUSINESS_NAME_OPTIONAL_COUNTRIES.includes(countryCode);
171
+ if (fieldName === "addressLine2") return true;
172
+ if (ADDRESS_FIELDS.includes(fieldName)) return false;
173
+ if (fieldName === "taxId") return false;
174
+ return false;
175
+ }
176
+ /** Checks if at least one address field has a non-empty value */
177
+ function hasAtLeastOneAddressField(formData) {
178
+ return ADDRESS_FIELDS.some((field) => {
179
+ const value = formData[field];
180
+ return value !== void 0 && value.trim() !== "";
181
+ });
182
+ }
183
+ /** Returns false for countries where address is fully optional */
184
+ function requiresAddressValidation(countryCode) {
185
+ return !ADDRESS_FULLY_OPTIONAL_COUNTRIES.includes(countryCode);
186
+ }
187
+
188
+ //#endregion
189
+ //#region src/modules/ekyb/ekybActions.ts
190
+ const REQUIRED_ERROR_KEYS = new Set(["ekyb.error.requiredField"]);
191
+ const UBO_FIELD_LABELS = {
192
+ name: "ekyb.uboName",
193
+ surname: "ekyb.uboSurname"
194
+ };
195
+ function buildEkybFields(verificationFields, country, _hasUbos) {
196
+ let modules = verificationFields.filter((f) => f !== "ubos-user_input" && !f.startsWith("socure"));
197
+ if (country === "GB") modules = modules.filter((m) => m !== "state-user_input");
198
+ if (country === "MX") modules = modules.filter((m) => {
199
+ if (m === "ubos-user_input") return false;
200
+ const fieldName = FIELD_NAME_MAPPING[m] ?? m;
201
+ if (ADDRESS_FIELDS.includes(fieldName) && fieldName !== "postalCode") return false;
202
+ return true;
203
+ });
204
+ return sortModulesByOrder(modules, FIELD_ORDER).map((moduleName) => {
205
+ const fieldName = FIELD_NAME_MAPPING[moduleName] ?? moduleName;
206
+ const optional = isFieldOptional(fieldName, country);
207
+ const def = {
208
+ name: fieldName,
209
+ type: "text",
210
+ label: `ekyb.${fieldName}`,
211
+ required: !optional
212
+ };
213
+ if (fieldName === "taxId") {
214
+ def.required = true;
215
+ if (country === "CN") def.label = "verification.labels.prcId";
216
+ if (country === "BR") def.displayLabel = "CPF";
217
+ }
218
+ if (fieldName === "postalCode") def.maxLength = getPostalCodeMaxLength(country);
219
+ if (fieldName === "state" && country === "US") {
220
+ def.type = "dropdown";
221
+ def.options = usStateOptions;
222
+ def.placeholder = "verification.placeholder.state";
223
+ }
224
+ return def;
225
+ });
226
+ }
227
+ function getDefaultVerificationFields(config) {
228
+ if (config.verificationFields && config.verificationFields.length > 0) return config.verificationFields;
229
+ const fields = [];
230
+ if (config.checkBusinessName !== false) fields.push("name-user_input");
231
+ if (config.checkAddress !== false) fields.push("street-user_input", "houseNo-user_input", "address2-user_input", "city-user_input", "state-user_input", "postalCode-user_input");
232
+ if (config.checkTaxId !== false) fields.push("taxId-user_input");
233
+ if (config.checkUniqueBeneficialOwner !== false) fields.push("ubos-user_input");
234
+ return fields;
235
+ }
236
+ function validateEkybField(name, value, required, country) {
237
+ const val = (value ?? "").trim();
238
+ if (required && !val) return "ekyb.error.requiredField";
239
+ if (name === "taxId") {
240
+ if (COUNTRIES_WITH_CNPJ_VALIDATION.includes(country)) {
241
+ if (val && !validateCNPJ(val)) return "ekyb.error.invalidTaxId";
242
+ }
243
+ if (COUNTRIES_WITH_SPECIAL_TAX_ID_RULES.includes(country) && !val) return;
244
+ }
245
+ if (name === "postalCode" && val) {
246
+ if (!validatePostalCode(val, country)) return getPostalCodeErrorKey(country);
247
+ }
248
+ }
249
+ function computeEkybValidation(fields, values, country, ubos, hasUbos) {
250
+ const errors = {};
251
+ for (const field of fields) {
252
+ const val = values[field.name];
253
+ const err = validateEkybField(field.name, val, field.required, country);
254
+ if (err) errors[field.name] = err;
255
+ }
256
+ if (requiresAddressValidation(country)) {
257
+ const addressValues = {};
258
+ for (const f of ADDRESS_FIELDS) addressValues[f] = values[f];
259
+ if (!hasAtLeastOneAddressField(addressValues)) {
260
+ const requiredAddressFields = fields.filter((f) => ADDRESS_FIELDS.includes(f.name) && f.required);
261
+ for (const f of requiredAddressFields) if (!errors[f.name] && !(values[f.name] ?? "").trim()) errors[f.name] = "ekyb.error.requiredField";
262
+ }
263
+ }
264
+ if (hasUbos) for (let i = 0; i < ubos.length; i++) {
265
+ const isDefault = i === 0;
266
+ const hasAnyValue = ubos[i].name.trim() !== "" || ubos[i].surname.trim() !== "";
267
+ if (isDefault || hasAnyValue) {
268
+ if (!ubos[i].name.trim()) errors[`ubo-${i}-name`] = "ekyb.error.requiredField";
269
+ if (!ubos[i].surname.trim()) errors[`ubo-${i}-surname`] = "ekyb.error.requiredField";
270
+ }
271
+ }
272
+ return {
273
+ errors,
274
+ isValid: Object.keys(errors).length === 0
275
+ };
276
+ }
277
+ function computeDisplayErrors(errors, touched, submitAttempted, country, fields) {
278
+ const display = {};
279
+ const errorParams = {};
280
+ const fieldLabelMap = new Map(fields?.map((f) => [f.name, f.displayLabel ?? f.label]));
281
+ for (const [field, err] of Object.entries(errors)) {
282
+ const isRequiredErr = REQUIRED_ERROR_KEYS.has(err);
283
+ if (isRequiredErr && (submitAttempted || touched[field])) {
284
+ display[field] = DYNAMIC_REQUIRED_KEY;
285
+ const label = fieldLabelMap.get(field);
286
+ if (label) errorParams[field] = { fieldName: label };
287
+ else {
288
+ const uboMatch = field.match(/^ubo-\d+-(name|surname)$/);
289
+ if (uboMatch) errorParams[field] = { fieldName: UBO_FIELD_LABELS[uboMatch[1]] ?? field };
290
+ }
291
+ } else if (!isRequiredErr && touched[field]) display[field] = err;
292
+ if (display[field] && field === "postalCode" && POSTAL_CODE_FORMAT_ERROR_KEYS.has(err)) {
293
+ const fixedLen = FIXED_DIGIT_POSTAL_CODE_LENGTH[country];
294
+ if (fixedLen !== void 0) errorParams[field] = {
295
+ ...errorParams[field] ?? {},
296
+ length: fixedLen
297
+ };
298
+ else {
299
+ let maxLen = getPostalCodeMaxLength(country);
300
+ if (country === "US" || country === "BR") maxLen = maxLen - 1;
301
+ errorParams[field] = {
302
+ ...errorParams[field] ?? {},
303
+ maxLength: maxLen
304
+ };
305
+ }
306
+ }
307
+ }
308
+ return {
309
+ displayErrors: display,
310
+ errorParams
311
+ };
312
+ }
313
+ function processEkybFieldValue(name, value, country) {
314
+ if (name === "postalCode") return formatPostalCode(value, country);
315
+ return value;
316
+ }
317
+ function buildEkybSubmitPayload(ctx) {
318
+ const uboNames = ctx.ubos.filter((u) => u.name.trim() || u.surname.trim()).map((u) => `${u.name.trim()} ${u.surname.trim()}`.trim());
319
+ const payload = {
320
+ country: ctx.country,
321
+ plugins: ["ekyb"],
322
+ uboNames
323
+ };
324
+ for (const field of ctx.fields) {
325
+ const val = ctx.values[field.name];
326
+ if (val !== void 0 && val !== "") payload[field.name] = val;
327
+ }
328
+ return payload;
329
+ }
330
+
331
+ //#endregion
332
+ //#region src/modules/ekyb/ekybGuards.ts
333
+ const hasFlowIdGuard = ({ context }) => !!context.config.flowId;
334
+ const isValidGuard = ({ context }) => context.isValid;
335
+ const canAddUboGuard = ({ context }) => context.canAddUbo;
336
+ const isValidUboIndexGuard = ({ context, event }) => {
337
+ const { index } = event;
338
+ return Number.isInteger(index) && index >= 0 && index < context.ubos.length;
339
+ };
340
+ const isSupportedCountryGuard = ({ event }) => {
341
+ const { country } = event;
342
+ return isSupportedCountry(country);
343
+ };
344
+
345
+ //#endregion
346
+ //#region src/modules/ekyb/ekybServices.ts
347
+ /** Fetches the onboarding flow and extracts the EKYB module configuration */
348
+ async function fetchEkybModuleConfig(signal) {
349
+ const ekybModule = (await getFlow(signal)).flowModules.find((m) => m.key === "EKYB");
350
+ if (!ekybModule) throw new Error("EKYB module not found in flow configuration");
351
+ return ekybModule.configuration;
352
+ }
353
+ /** Submits eKYB business verification */
354
+ async function submitEkyb(data, signal) {
355
+ const res = await api.post(endpoints.ekybSubmit, data, { signal });
356
+ if (!res.ok) throw new Error(`POST ${endpoints.ekybSubmit} failed: ${res.status} ${res.statusText}`);
357
+ return res.data;
358
+ }
359
+
360
+ //#endregion
361
+ //#region src/modules/ekyb/ekybActors.ts
362
+ const fetchEkybModuleConfigActor = fromPromise(async ({ signal }) => fetchEkybModuleConfig(signal));
363
+ const submitEkybActor = fromPromise(async ({ input, signal }) => submitEkyb(input, signal));
364
+
365
+ //#endregion
366
+ //#region src/modules/ekyb/ekybStateMachine.ts
367
+ const ekybMachine = setup({
368
+ types: {
369
+ context: {},
370
+ events: {},
371
+ input: {}
372
+ },
373
+ actors: {
374
+ fetchEkybModuleConfig: fetchEkybModuleConfigActor,
375
+ submitEkyb: submitEkybActor,
376
+ debounceSearch: debounceSearchActor
377
+ },
378
+ actions: {
379
+ applyFetchedConfig: assign(({ event }) => {
380
+ const fetched = event.output;
381
+ const config = {
382
+ checkBusinessName: fetched.checkBusinessName,
383
+ checkAddress: fetched.checkAddress,
384
+ checkTaxId: fetched.checkTaxId,
385
+ checkUniqueBeneficialOwner: fetched.checkUniqueBeneficialOwner
386
+ };
387
+ const country = "US";
388
+ const vFields = getDefaultVerificationFields(config);
389
+ const hasUbos = config.checkUniqueBeneficialOwner !== false && vFields.includes("ubos-user_input");
390
+ const fields = buildEkybFields(vFields, country, hasUbos);
391
+ const values = { country };
392
+ const ubos = hasUbos ? [{
393
+ id: "ubo-1",
394
+ name: "",
395
+ surname: ""
396
+ }] : [];
397
+ const { errors, isValid } = computeEkybValidation(fields, values, country, ubos, hasUbos);
398
+ return {
399
+ config,
400
+ country,
401
+ availableCountries: ALL_COUNTRIES,
402
+ fields,
403
+ values,
404
+ errors,
405
+ isValid,
406
+ ubos,
407
+ canAddUbo: hasUbos,
408
+ hasUbos,
409
+ submitAttempted: false,
410
+ addressSuggestions: [],
411
+ _nextUboId: 2,
412
+ _searchQuery: ""
413
+ };
414
+ }),
415
+ setCountry: assign(({ context, event }) => {
416
+ const { country } = event;
417
+ const vFields = getDefaultVerificationFields(context.config);
418
+ const hasUbos = context.config.checkUniqueBeneficialOwner !== false && vFields.includes("ubos-user_input") && country !== "MX";
419
+ const fields = buildEkybFields(vFields, country, hasUbos);
420
+ let nextId = context._nextUboId;
421
+ let ubos;
422
+ if (hasUbos) if (context.ubos.length > 0) ubos = context.ubos;
423
+ else {
424
+ ubos = [{
425
+ id: `ubo-${nextId}`,
426
+ name: "",
427
+ surname: ""
428
+ }];
429
+ nextId += 1;
430
+ }
431
+ else ubos = [];
432
+ const newValues = {
433
+ ...context.values,
434
+ country,
435
+ state: ""
436
+ };
437
+ const { errors, isValid } = computeEkybValidation(fields, newValues, country, ubos, hasUbos);
438
+ return {
439
+ country,
440
+ fields,
441
+ values: newValues,
442
+ errors,
443
+ isValid,
444
+ ubos,
445
+ canAddUbo: hasUbos && ubos.length < UBO_INPUT_LIMIT,
446
+ hasUbos,
447
+ _nextUboId: nextId
448
+ };
449
+ }),
450
+ updateField: assign(({ context, event }) => {
451
+ const { name, value } = event;
452
+ const processed = processEkybFieldValue(name, value, context.country);
453
+ const newValues = {
454
+ ...context.values,
455
+ [name]: processed
456
+ };
457
+ const { errors, isValid } = computeEkybValidation(context.fields, newValues, context.country, context.ubos, context.hasUbos);
458
+ return {
459
+ values: newValues,
460
+ errors,
461
+ isValid
462
+ };
463
+ }),
464
+ addUbo: assign(({ context }) => {
465
+ const newId = context._nextUboId;
466
+ const ubos = [...context.ubos, {
467
+ id: `ubo-${newId}`,
468
+ name: "",
469
+ surname: ""
470
+ }];
471
+ const canAddUbo = ubos.length < UBO_INPUT_LIMIT;
472
+ const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
473
+ return {
474
+ ubos,
475
+ canAddUbo,
476
+ errors,
477
+ isValid,
478
+ _nextUboId: newId + 1
479
+ };
480
+ }),
481
+ removeUbo: assign(({ context, event }) => {
482
+ const { index } = event;
483
+ const ubos = context.ubos.filter((_, i) => i !== index);
484
+ const canAddUbo = ubos.length < UBO_INPUT_LIMIT;
485
+ const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
486
+ return {
487
+ ubos,
488
+ canAddUbo,
489
+ errors,
490
+ isValid
491
+ };
492
+ }),
493
+ setUboField: assign(({ context, event }) => {
494
+ const { index, field, value } = event;
495
+ const ubos = context.ubos.map((ubo, i) => i === index ? {
496
+ ...ubo,
497
+ [field]: value
498
+ } : ubo);
499
+ const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
500
+ return {
501
+ ubos,
502
+ errors,
503
+ isValid
504
+ };
505
+ }),
506
+ setErrorMessage: assign(({ event }) => ({ errorMessage: String(event.error ?? "verification.error") })),
507
+ clearErrorMessage: assign({ errorMessage: () => "" }),
508
+ markSubmitAttempted: assign({ submitAttempted: () => true }),
509
+ fillAddressFields: assign(({ context, event }) => {
510
+ const { suggestion } = event;
511
+ const activeFields = new Set(context.fields.map((f) => f.name));
512
+ const { values: newValues } = fillFromSuggestion(context.values, {}, suggestion, activeFields);
513
+ const { errors, isValid } = computeEkybValidation(context.fields, newValues, context.country, context.ubos, context.hasUbos);
514
+ return {
515
+ values: newValues,
516
+ addressSuggestions: [],
517
+ errors,
518
+ isValid
519
+ };
520
+ }),
521
+ setAddressSuggestions: assign(({ event }) => ({ addressSuggestions: event.suggestions }))
522
+ },
523
+ guards: {
524
+ hasFlowId: hasFlowIdGuard,
525
+ isValid: isValidGuard,
526
+ canAddUbo: canAddUboGuard,
527
+ isValidUboIndex: isValidUboIndexGuard,
528
+ isSupportedCountry: isSupportedCountryGuard
529
+ }
530
+ }).createMachine({
531
+ id: "ekyb",
532
+ initial: "idle",
533
+ context: ({ input }) => {
534
+ const country = "US";
535
+ const vFields = getDefaultVerificationFields(input.config);
536
+ const hasUbos = input.config.checkUniqueBeneficialOwner !== false && vFields.includes("ubos-user_input");
537
+ const fields = buildEkybFields(vFields, country, hasUbos);
538
+ const values = { country };
539
+ const ubos = hasUbos ? [{
540
+ id: "ubo-1",
541
+ name: "",
542
+ surname: ""
543
+ }] : [];
544
+ const { errors, isValid } = computeEkybValidation(fields, values, country, ubos, hasUbos);
545
+ return {
546
+ config: input.config,
547
+ country,
548
+ availableCountries: ALL_COUNTRIES,
549
+ fields,
550
+ values,
551
+ errors,
552
+ isValid,
553
+ ubos,
554
+ canAddUbo: hasUbos,
555
+ hasUbos,
556
+ errorMessage: "",
557
+ submitAttempted: false,
558
+ addressSuggestions: [],
559
+ _nextUboId: 2,
560
+ _searchQuery: ""
561
+ };
562
+ },
563
+ states: {
564
+ idle: { on: { LOAD: [{
565
+ target: "loading",
566
+ guard: "hasFlowId"
567
+ }, { target: "form" }] } },
568
+ loading: { invoke: {
569
+ id: "fetchEkybModuleConfig",
570
+ src: "fetchEkybModuleConfig",
571
+ onDone: {
572
+ target: "form",
573
+ actions: "applyFetchedConfig"
574
+ },
575
+ onError: "form"
576
+ } },
577
+ form: {
578
+ initial: "idle",
579
+ states: {
580
+ idle: {},
581
+ searching: {
582
+ invoke: {
583
+ id: "debounceSearch",
584
+ src: "debounceSearch",
585
+ input: ({ context }) => ({ query: context._searchQuery })
586
+ },
587
+ on: { RESULTS: {
588
+ target: "idle",
589
+ actions: "setAddressSuggestions"
590
+ } }
591
+ }
592
+ },
593
+ on: {
594
+ SET_COUNTRY: {
595
+ guard: "isSupportedCountry",
596
+ actions: "setCountry"
597
+ },
598
+ SET_FIELD: { actions: "updateField" },
599
+ SEARCH_ADDRESS: {
600
+ target: ".searching",
601
+ actions: assign(({ event }) => ({
602
+ _searchQuery: event.query,
603
+ addressSuggestions: []
604
+ }))
605
+ },
606
+ SELECT_ADDRESS: {
607
+ target: ".idle",
608
+ actions: "fillAddressFields"
609
+ },
610
+ ADD_UBO: {
611
+ guard: "canAddUbo",
612
+ actions: "addUbo"
613
+ },
614
+ REMOVE_UBO: {
615
+ guard: "isValidUboIndex",
616
+ actions: "removeUbo"
617
+ },
618
+ SET_UBO_FIELD: {
619
+ guard: "isValidUboIndex",
620
+ actions: "setUboField"
621
+ },
622
+ SUBMIT: [{
623
+ target: "submitting",
624
+ guard: "isValid"
625
+ }, { actions: "markSubmitAttempted" }],
626
+ CLOSE: { target: "closed" }
627
+ }
628
+ },
629
+ submitting: { invoke: {
630
+ id: "submitEkyb",
631
+ src: "submitEkyb",
632
+ input: ({ context }) => buildEkybSubmitPayload(context),
633
+ onDone: { target: "success" },
634
+ onError: {
635
+ target: "error",
636
+ actions: "setErrorMessage"
637
+ }
638
+ } },
639
+ success: { after: { 3e3: "finished" } },
640
+ error: { on: {
641
+ RETRY: {
642
+ target: "form",
643
+ actions: "clearErrorMessage"
644
+ },
645
+ CLOSE: { target: "closed" }
646
+ } },
647
+ finished: { type: "final" },
648
+ closed: { type: "final" }
649
+ }
650
+ });
651
+
652
+ //#endregion
653
+ export { SUPPORTED_COUNTRIES as a, DEV_ONLY_COUNTRIES as i, computeDisplayErrors as n, isSupportedCountry as o, ALL_COUNTRIES as r, ekybMachine as t };
package/dist/ekyc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { t as Manager } from "./Manager-BN2g_I8W.js";
2
- import "./Actor-Ba71-_30.js";
3
- import { n as AddressSuggestion, r as FieldDef, t as DisplayErrorsResult } from "./displayErrors-BZLX7idb.js";
1
+ import { t as Manager } from "./Manager-DcPMRgTm.js";
2
+ import "./Actor-DbWH1K6E.js";
3
+ import { n as AddressSuggestion, r as FieldDef, t as DisplayErrorsResult } from "./displayErrors-xrg0ejaS.js";
4
4
 
5
5
  //#region src/modules/ekyc/types.d.ts
6
6
  type EkycFieldSource = 'user_input' | 'document_scan' | 'poa_document' | 'phone_module_input' | 'email_module_input' | false;