@incodetech/core 2.0.1 → 2.1.0-rc.1

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 (218) hide show
  1. package/dist/{BrowserStorageProvider-CuOW1Er2.esm.js → BrowserStorageProvider-BpJM-gIl.esm.js} +8 -1
  2. package/dist/{IpifyProvider-D7jx52AL.esm.js → IpifyProvider-D4LWD15E.esm.js} +28 -0
  3. package/dist/{MotionSensorProvider-4v7xkqAp.esm.js → MotionSensorProvider-Bx7Mpzt0.esm.js} +63 -13
  4. package/dist/{OpenViduRecordingProvider-CMu6XVdc.esm.js → OpenViduRecordingProvider-O4GjBseO.esm.js} +1 -1
  5. package/dist/StateMachine-BC_nGvrc.d.ts +2 -0
  6. package/dist/StreamCanvasCapture-ImiDQdVA.esm.js +118 -0
  7. package/dist/StreamCanvasCapture-yyl20qd9.d.ts +152 -0
  8. package/dist/{BaseWasmProvider-C_DLEI40.esm.js → WasmUtilProvider-BKWm8rSA.esm.js} +202 -11
  9. package/dist/{addressSearch-BpTbTWCa.esm.js → addressSearch-DvmWXKZg.esm.js} +63 -57
  10. package/dist/{ae-signature-DDDZmWXj.esm.js → ae-signature-BFZta3TZ.esm.js} +1 -1
  11. package/dist/ae-signature.d.ts +3 -3
  12. package/dist/ae-signature.esm.js +6 -5
  13. package/dist/antifraud.d.ts +5 -46
  14. package/dist/antifraud.esm.js +6 -43
  15. package/dist/antifraudManager-CkV4u-LE.esm.js +55 -0
  16. package/dist/antifraudManager-CznnhyvD.d.ts +63 -0
  17. package/dist/{antifraudStateMachine-O0TMf6yc.esm.js → antifraudStateMachine-Ccrb-Jxc.esm.js} +2 -2
  18. package/dist/apiError-B-j-gyDx.esm.js +51 -0
  19. package/dist/authentication.d.ts +13 -11
  20. package/dist/authentication.esm.js +26 -22
  21. package/dist/{authenticationManager-5M-fKzXx.esm.js → authenticationManager-BlR6mSaG.esm.js} +6 -6
  22. package/dist/{authenticationManager-C83GNIhl.d.ts → authenticationManager-CaiQbp-q.d.ts} +4 -4
  23. package/dist/{authenticationStateMachine-BMZqatiF.esm.js → authenticationStateMachine-DkcGUMw5.esm.js} +21 -9
  24. package/dist/{backCameraStream-DMdMeGk2.esm.js → backCameraStream-D7Wo4Nbx.esm.js} +95 -7
  25. package/dist/{session-CrkWAs-q.esm.js → browserSimulation-B1dWiXp7.esm.js} +61 -476
  26. package/dist/camera.d.ts +4 -3
  27. package/dist/camera.esm.js +4 -3
  28. package/dist/canvas-SKcRBxsk.esm.js +230 -0
  29. package/dist/consent.d.ts +4 -398
  30. package/dist/consent.esm.js +6 -77
  31. package/dist/consentManager-BYo9Nu1r.esm.js +90 -0
  32. package/dist/consentManager-Cg5Sk2tv.d.ts +419 -0
  33. package/dist/{consentStateMachine-CCT-B60O.esm.js → consentStateMachine-BG3yL8aC.esm.js} +9 -6
  34. package/dist/cpf-ocr.d.ts +4 -199
  35. package/dist/cpf-ocr.esm.js +8 -177
  36. package/dist/cpfOcrManager-Dg1s_TY5.d.ts +216 -0
  37. package/dist/cpfOcrManager-sSKegxox.esm.js +190 -0
  38. package/dist/cross-document-data-match.d.ts +1 -1
  39. package/dist/cross-document-data-match.esm.js +4 -4
  40. package/dist/curp-validation.d.ts +8 -158
  41. package/dist/curp-validation.esm.js +6 -108
  42. package/dist/curpValidationManager-CFem6zP9.esm.js +122 -0
  43. package/dist/curpValidationManager-RttixpIc.d.ts +184 -0
  44. package/dist/{curpValidationStateMachine-CitWLr2c.esm.js → curpValidationStateMachine-B7V_qp66.esm.js} +20 -13
  45. package/dist/custom-fields.d.ts +2 -2
  46. package/dist/custom-fields.esm.js +4 -4
  47. package/dist/custom-watchlist.d.ts +1 -1
  48. package/dist/custom-watchlist.esm.js +4 -41
  49. package/dist/customWatchlistStateMachine-HmFybXLX.esm.js +50 -0
  50. package/dist/{deepsightLoader-Cm4JIT_z.esm.js → deepsightLoader-8tnddNx-.esm.js} +19 -10
  51. package/dist/deepsightService-CrHmvx8X.esm.js +276 -0
  52. package/dist/{deepsightService-CEVxzehb.d.ts → deepsightService-Dh5P-hLf.d.ts} +13 -160
  53. package/dist/device.esm.js +4 -3
  54. package/dist/document-capture.d.ts +989 -80
  55. package/dist/document-capture.esm.js +34 -8
  56. package/dist/document-upload.d.ts +44 -44
  57. package/dist/document-upload.esm.js +7 -7
  58. package/dist/{documentCaptureStateMachine-BqzTDy9k.esm.js → documentCaptureStateMachine-CUTUzUw_.esm.js} +90 -6
  59. package/dist/dynamic-forms.d.ts +20 -5
  60. package/dist/dynamic-forms.esm.js +150 -61
  61. package/dist/ekyb.d.ts +32 -13
  62. package/dist/ekyb.esm.js +25 -15
  63. package/dist/{ekybStateMachine-CyMx_kg-.esm.js → ekybStateMachine-klc-AImJ.esm.js} +319 -207
  64. package/dist/ekyc.d.ts +10 -78
  65. package/dist/ekyc.esm.js +17 -12
  66. package/dist/{ekycStateMachine-oeO0Iekd.esm.js → ekycStateMachine-CXbpaJJn.esm.js} +201 -113
  67. package/dist/electronic-signature.d.ts +3 -3
  68. package/dist/electronic-signature.esm.js +5 -4
  69. package/dist/{electronicSignatureManager-D9OHzTpG.esm.js → electronicSignatureManager-BaECdJ1u.esm.js} +91 -23
  70. package/dist/email.d.ts +4 -3
  71. package/dist/email.esm.js +6 -5
  72. package/dist/{emailManager-wAV0LE-H.esm.js → emailManager--D5G3ChB.esm.js} +30 -7
  73. package/dist/{emailManager-DIfnS5g1.d.ts → emailManager-lAzDoQOs.d.ts} +66 -8
  74. package/dist/{emailStateMachine-DOf4j58N.esm.js → emailStateMachine-CxTOMAjC.esm.js} +46 -11
  75. package/dist/{endpoints-CnN3SyDa.esm.js → endpoints-BeTK0Mlt.esm.js} +6 -3
  76. package/dist/{events-D6-e4vok.esm.js → events-Dvvriq9l.esm.js} +3 -1
  77. package/dist/events.d.ts +2 -0
  78. package/dist/events.esm.js +1 -1
  79. package/dist/extensibility.d.ts +41 -16
  80. package/dist/extensibility.esm.js +55 -33
  81. package/dist/face-match.d.ts +21 -2
  82. package/dist/face-match.esm.js +5 -5
  83. package/dist/{faceCaptureManagerFactory-yqtpxjnN.d.ts → faceCaptureManagerFactory-CjdBUS6s.d.ts} +48 -17
  84. package/dist/{faceCaptureManagerFactory-Dh2PdGlF.esm.js → faceCaptureManagerFactory-ej2j1LMr.esm.js} +21 -5
  85. package/dist/{faceCaptureSetup-B3faSpYA.esm.js → faceCaptureSetup-B9t6bYze.esm.js} +68 -183
  86. package/dist/{faceMatchStateMachine-DNFrxTFS.esm.js → faceMatchStateMachine-DeXXzSuz.esm.js} +62 -6
  87. package/dist/field-comparison.d.ts +4 -0
  88. package/dist/field-comparison.esm.js +7 -0
  89. package/dist/fieldComparisonManager-Bu5TaSr3.d.ts +76 -0
  90. package/dist/fieldComparisonManager-COGI2ARD.esm.js +162 -0
  91. package/dist/fiscal-qr.d.ts +59 -0
  92. package/dist/fiscal-qr.esm.js +323 -0
  93. package/dist/flow-events.d.ts +6 -5
  94. package/dist/flow.d.ts +23 -15
  95. package/dist/flow.esm.js +56 -17
  96. package/dist/flowCompletionService-BdR2cGgB.d.ts +19 -0
  97. package/dist/flowCompletionService-DdGojV9K.esm.js +20 -0
  98. package/dist/{flowServices-PiNsxLfK.esm.js → flowServices-ChgTNggJ.esm.js} +10 -5
  99. package/dist/geolocation.d.ts +4 -4
  100. package/dist/geolocation.esm.js +6 -6
  101. package/dist/{geolocationStateMachine-asasuHY2.esm.js → geolocationStateMachine-Dvh7X0wF.esm.js} +5 -5
  102. package/dist/getBrowser-C8DP7oTB.esm.js +8 -0
  103. package/dist/{getBrowser-BSXUTWXw.esm.js → getDeviceClass-C0olyNFS.esm.js} +1 -8
  104. package/dist/{getDeviceClass-BSntT9_j.esm.js → getDeviceClass-C8Do2qYu.esm.js} +1 -1
  105. package/dist/government-validation.d.ts +28 -8
  106. package/dist/government-validation.esm.js +19 -8
  107. package/dist/{governmentValidationStateMachine-BDDYrJTo.esm.js → governmentValidationStateMachine-DcJ-BfsC.esm.js} +35 -77
  108. package/dist/home.d.ts +15 -14
  109. package/dist/home.esm.js +2 -2
  110. package/dist/http-Cai3IoLS.esm.js +0 -0
  111. package/dist/http.esm.js +1 -0
  112. package/dist/id-ocr.d.ts +54 -54
  113. package/dist/id-ocr.esm.js +5 -5
  114. package/dist/id-verification.d.ts +27 -27
  115. package/dist/id-verification.esm.js +4 -4
  116. package/dist/id.d.ts +12 -10
  117. package/dist/id.esm.js +70 -27
  118. package/dist/{idCaptureManager-Fyd0eam-.d.ts → idCaptureManager-ChCNmgBj.d.ts} +40 -20
  119. package/dist/{idCaptureManager-D0ktk7Hh.esm.js → idCaptureManager-D3pwWutw.esm.js} +22 -7
  120. package/dist/{idCaptureStateMachine-dwlBUjbC.esm.js → idCaptureStateMachine-B3AiDIsT.esm.js} +172 -123
  121. package/dist/{idOcrStateMachine-YbjjC_Gg.esm.js → idOcrStateMachine-CDQ5d_VM.esm.js} +4 -4
  122. package/dist/{idVerificationStateMachine-xbw9HP1Z.esm.js → idVerificationStateMachine-kRxwImzO.esm.js} +2 -2
  123. package/dist/identity-reuse.d.ts +4 -530
  124. package/dist/identity-reuse.esm.js +8 -274
  125. package/dist/identityReuseManager-C6n_97dw.esm.js +95 -0
  126. package/dist/identityReuseManager-Cww-NDtd.d.ts +428 -0
  127. package/dist/identityReuseStateMachine-BfE5YiEr.esm.js +148 -0
  128. package/dist/{index-BcRG8rtJ.d.ts → index-B5hPA0Bg.d.ts} +2 -2
  129. package/dist/{index-ChHWNH48.d.ts → index-B9NysVDB.d.ts} +469 -195
  130. package/dist/index.d.ts +2 -2
  131. package/dist/index.esm.js +10 -8
  132. package/dist/{invokeOnCaptureCallback-rc6kBHo5.esm.js → invokeOnCaptureCallback-ygByVdnn.esm.js} +1 -1
  133. package/dist/{lib-BB0B_qQX.esm.js → lib-BY67lgbq.esm.js} +1 -1
  134. package/dist/mandatory-consent.d.ts +8 -412
  135. package/dist/mandatory-consent.esm.js +6 -76
  136. package/dist/mandatoryConsentManager-Dq6WiOZh.d.ts +429 -0
  137. package/dist/mandatoryConsentManager-H6D18cZB.esm.js +89 -0
  138. package/dist/{mandatoryConsentStateMachine-Cnco1jvn.esm.js → mandatoryConsentStateMachine-DtQNW1ji.esm.js} +6 -6
  139. package/dist/openviduLazy-B8L--0oe.esm.js +3 -0
  140. package/dist/{openviduLazy-Cok70ZSg.esm.js → openviduLazy-Dh14JNJc.esm.js} +2 -2
  141. package/dist/otp-CGMdUzBC.esm.js +33 -0
  142. package/dist/otp-DF5A0sFx.d.ts +8 -0
  143. package/dist/permissionGuards-D0wGddy7.esm.js +23 -0
  144. package/dist/permissionServices-Doec4X5L.esm.js +130 -0
  145. package/dist/phone.d.ts +4 -3
  146. package/dist/phone.esm.js +6 -5
  147. package/dist/{phoneManager-DAJbGhlY.esm.js → phoneManager-BmF-0Ez4.esm.js} +30 -7
  148. package/dist/{phoneManager-B6M30hKE.d.ts → phoneManager-fPmIBYQK.d.ts} +65 -7
  149. package/dist/{phoneStateMachine-CuPARRaT.esm.js → phoneStateMachine-BiV0yoEx.esm.js} +46 -11
  150. package/dist/{qe-signature-DFo_Cc-I.esm.js → qe-signature-CUYPcHVo.esm.js} +1 -1
  151. package/dist/qe-signature.d.ts +3 -3
  152. package/dist/qe-signature.esm.js +6 -5
  153. package/dist/{recordingService-Ig2UgbLv.esm.js → recordingService-yRw7hfzU.esm.js} +197 -179
  154. package/dist/redirect-to-mobile.d.ts +6 -104
  155. package/dist/redirect-to-mobile.esm.js +6 -99
  156. package/dist/redirectToMobileManager-BNe3IzC_.d.ts +178 -0
  157. package/dist/redirectToMobileManager-Dy3t7o0C.esm.js +159 -0
  158. package/dist/{redirectToMobileStateMachine-BOEqe46A.esm.js → redirectToMobileStateMachine-DyAdRxfP.esm.js} +28 -19
  159. package/dist/{runChildModule-CqqwqAkW.esm.js → runChildModule-CuoHZ1cx.esm.js} +35 -3
  160. package/dist/selfie.d.ts +13 -11
  161. package/dist/selfie.esm.js +53 -24
  162. package/dist/{selfieManager-Duisl7qN.esm.js → selfieManager-BNuTIGAz.esm.js} +6 -6
  163. package/dist/{selfieManager-D0lSgd-J.d.ts → selfieManager-C2y_t6DG.d.ts} +4 -4
  164. package/dist/{selfieStateMachine-D76whWEf.esm.js → selfieStateMachine-Bv99bZJE.esm.js} +5 -3
  165. package/dist/session-DoVb-OcB.esm.js +152 -0
  166. package/dist/session.d.ts +37 -5
  167. package/dist/session.esm.js +12 -7
  168. package/dist/sessionInitializer-DRB-hgbV.esm.js +366 -0
  169. package/dist/{setup-C5AITV8m.d.ts → setup-BwCluiw3.d.ts} +86 -6
  170. package/dist/{setup-DPPAxmXf.esm.js → setup-CUO4mErT.esm.js} +175 -25
  171. package/dist/signature.d.ts +2 -2
  172. package/dist/signature.esm.js +4 -4
  173. package/dist/{signatureStateMachine-B5-QVUve.esm.js → signatureStateMachine-C5qqYLRz.esm.js} +3 -3
  174. package/dist/stats-BMNUG1AU.esm.js +41 -0
  175. package/dist/stats.d.ts +13 -2
  176. package/dist/stats.esm.js +3 -2
  177. package/dist/trust-graph.d.ts +33 -4
  178. package/dist/trust-graph.esm.js +21 -15
  179. package/dist/{types-CFV9G_7j.d.ts → types-Bj9hdFjU.d.ts} +1 -1
  180. package/dist/{types-BP1m8VRw.d.ts → types-DOUhndhT.d.ts} +14 -2
  181. package/dist/types-DsnEVMhr.esm.js +34 -0
  182. package/dist/types-DvGZI7BF.d.ts +131 -0
  183. package/dist/{types-B06Ypu2F.d.ts → types-NuT8ftBV.d.ts} +1 -1
  184. package/dist/types-ya0LN_MX.d.ts +5 -0
  185. package/dist/{warmup-CEcppFiS.d.ts → warmup-Dg8Lh-50.d.ts} +8 -0
  186. package/dist/wasm.d.ts +6 -4
  187. package/dist/wasm.esm.js +11 -9
  188. package/dist/watchlist-for-business.d.ts +1 -1
  189. package/dist/watchlist-for-business.esm.js +5 -73
  190. package/dist/watchlist.d.ts +1 -1
  191. package/dist/watchlist.esm.js +4 -41
  192. package/dist/watchlistForBusinessStateMachine-DMl8j2Ov.esm.js +74 -0
  193. package/dist/watchlistStateMachine-DmQlqI6L.esm.js +50 -0
  194. package/dist/workflow.d.ts +146 -100
  195. package/dist/workflow.esm.js +116 -66
  196. package/package.json +19 -1
  197. package/dist/StateMachine-BCQrZJhf.d.ts +0 -2
  198. package/dist/WasmUtilProvider-j98OJf-S.esm.js +0 -114
  199. package/dist/browserSimulation-gxD8cSpM.esm.js +0 -20
  200. package/dist/deepsightService-O74l4Y__.esm.js +0 -489
  201. package/dist/displayErrors-DqJ_IbsG.d.ts +0 -39
  202. package/dist/flowCompletionService-DhkT4SRY.d.ts +0 -10
  203. package/dist/flowCompletionService-P54yzGvA.esm.js +0 -13
  204. package/dist/openviduLazy-Cm0XFh_v.esm.js +0 -3
  205. package/dist/permissionServices-D_i6nzEw.esm.js +0 -50
  206. package/dist/stats-CIfiPzb1.esm.js +0 -16
  207. package/dist/types-CAD4va6a.d.ts +0 -5
  208. package/dist/watchlistServices-DMbUhkBX.esm.js +0 -12
  209. /package/dist/{Actor-CI32dTbG.d.ts → Actor-Y0_Fj-KL.d.ts} +0 -0
  210. /package/dist/{ITimerCapability-C67ZRskg.esm.js → ITimerCapability-CB0I1Uf2.esm.js} +0 -0
  211. /package/dist/{Manager-C8PrhBOx.d.ts → Manager-BHn8wH8K.d.ts} +0 -0
  212. /package/dist/{camera-PA2Ljri3.esm.js → camera-DJWm3V4g.esm.js} +0 -0
  213. /package/dist/{camera-DBSxa6ML.d.ts → camera-SRBpPq2X.d.ts} +0 -0
  214. /package/dist/{chunk-CRF6K_H_.esm.js → chunk-CMUKZ2uL.esm.js} +0 -0
  215. /package/dist/{cpf-PPz2Njto.esm.js → cpf-BRzggV8G.esm.js} +0 -0
  216. /package/dist/{dateUtils-UoN5xswP.esm.js → dateUtils-AksLQmgV.esm.js} +0 -0
  217. /package/dist/{platform-CfrjKhmi.esm.js → platform-SKvEfCBh.esm.js} +0 -0
  218. /package/dist/{xstate.esm-B70JrNqo.esm.js → xstate.esm-C9wncMQa.esm.js} +0 -0
@@ -1,8 +1,8 @@
1
1
  import { t as api } from "./api-CESGtpbH.esm.js";
2
- import { t as endpoints } from "./endpoints-CnN3SyDa.esm.js";
3
- import { a as fromPromise, r as assign, t as setup } from "./xstate.esm-B70JrNqo.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-BpTbTWCa.esm.js";
5
- import { t as getFlow } from "./flowServices-PiNsxLfK.esm.js";
2
+ import { t as endpoints } from "./endpoints-BeTK0Mlt.esm.js";
3
+ import { a as fromPromise, r as assign, t as setup } from "./xstate.esm-C9wncMQa.esm.js";
4
+ 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-DvmWXKZg.esm.js";
5
+ import { t as getFlow } from "./flowServices-ChgTNggJ.esm.js";
6
6
 
7
7
  //#region src/modules/ekyb/ekybConstants.ts
8
8
  const UBO_INPUT_LIMIT = 8;
@@ -59,11 +59,6 @@ const FIELD_NAME_MAPPING = {
59
59
  "taxId-user_input": "taxId"
60
60
  };
61
61
  const COUNTRIES_WITH_CNPJ_VALIDATION = ["BR"];
62
- const COUNTRIES_WITH_SPECIAL_TAX_ID_RULES = [
63
- "NG",
64
- "CM",
65
- "KE"
66
- ];
67
62
  const BUSINESS_NAME_OPTIONAL_COUNTRIES = [];
68
63
  const ADDRESS_FULLY_OPTIONAL_COUNTRIES = [
69
64
  "BR",
@@ -79,9 +74,10 @@ const ADDRESS_FIELDS = [
79
74
  "postalCode"
80
75
  ];
81
76
  const ALL_COUNTRIES_OPTIONAL_FIELDS = ["ubo"];
82
-
83
- //#endregion
84
- //#region src/modules/ekyb/ekybValidators.ts
77
+ const UBO_FIELD_LABELS = {
78
+ name: "ekyb.uboName",
79
+ surname: "ekyb.uboSurname"
80
+ };
85
81
  const CNPJ_FORMATTED_LENGTH = 18;
86
82
  const CNPJ_CLEAN_LENGTH = 14;
87
83
  const INVALID_CNPJ_PATTERNS = [
@@ -125,31 +121,6 @@ const CNPJ_SECOND_DIGIT_FACTORS = [
125
121
  3,
126
122
  2
127
123
  ];
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
124
 
154
125
  //#endregion
155
126
  //#region src/modules/ekyb/ekybUtils.ts
@@ -206,12 +177,187 @@ function requiresAddressValidation(countryCode) {
206
177
  }
207
178
 
208
179
  //#endregion
209
- //#region src/modules/ekyb/ekybActions.ts
210
- const REQUIRED_ERROR_KEYS = new Set(["ekyb.error.requiredField"]);
211
- const UBO_FIELD_LABELS = {
212
- name: "ekyb.uboName",
213
- surname: "ekyb.uboSurname"
180
+ //#region src/modules/ekyb/ekybValidators.ts
181
+ function cleanCnpjString(cnpj) {
182
+ return cnpj.replace(/\./g, "").replace(/\//g, "").replace(/-/g, "");
183
+ }
184
+ function calculateVerificationDigit(cnpjString, factors) {
185
+ let digit = 11 - factors.reduce((acc, factor, index) => acc + Number.parseInt(cnpjString.charAt(index), 10) * factor, 0) % 11;
186
+ if (digit >= 10) digit = 0;
187
+ return digit.toString();
188
+ }
189
+ /**
190
+ * Validates a Brazilian CNPJ number (14-digit checksum).
191
+ * Accepts formatted (00.000.000/0000-00) or unformatted input.
192
+ */
193
+ function validateCNPJ(cnpjInput) {
194
+ if (!cnpjInput || typeof cnpjInput !== "string") return false;
195
+ let cnpj = cnpjInput.trim();
196
+ if (cnpj.length === CNPJ_FORMATTED_LENGTH) cnpj = cleanCnpjString(cnpj);
197
+ if (cnpj.length !== CNPJ_CLEAN_LENGTH) return false;
198
+ if (!/^\d+$/.test(cnpj)) return false;
199
+ if (INVALID_CNPJ_PATTERNS.includes(cnpj)) return false;
200
+ const first = calculateVerificationDigit(cnpj, CNPJ_FIRST_DIGIT_FACTORS);
201
+ if (cnpj.charAt(12) !== first) return false;
202
+ const second = calculateVerificationDigit(cnpj, CNPJ_SECOND_DIGIT_FACTORS);
203
+ if (cnpj.charAt(13) !== second) return false;
204
+ return true;
205
+ }
206
+ const buildPostalCodeParams = (country) => {
207
+ const fixedLen = FIXED_DIGIT_POSTAL_CODE_LENGTH[country];
208
+ if (fixedLen !== void 0) return { length: fixedLen };
209
+ let maxLen = getPostalCodeMaxLength(country);
210
+ if (country === "US" || country === "BR") maxLen = maxLen - 1;
211
+ return { maxLength: maxLen };
214
212
  };
213
+ const createValidators = () => ({
214
+ required: (value, _rule, field) => {
215
+ if (value.trim().length > 0) return void 0;
216
+ const fieldName = field.displayLabel ?? field.label;
217
+ return fieldName ? {
218
+ key: DYNAMIC_REQUIRED_KEY,
219
+ params: { fieldName }
220
+ } : { key: DYNAMIC_REQUIRED_KEY };
221
+ },
222
+ streetLevelRequired: (value) => {
223
+ if (value.trim().length > 0) return void 0;
224
+ return STREET_LEVEL_REQUIRED_ERROR;
225
+ },
226
+ cnpj: (value) => {
227
+ if (value.trim().length === 0) return void 0;
228
+ return validateCNPJ(value) ? void 0 : { key: "ekyb.error.invalidTaxId" };
229
+ },
230
+ postalCodeFormat: (value, rule) => {
231
+ if (rule.type !== "postalCodeFormat") return void 0;
232
+ if (value.trim().length === 0) return void 0;
233
+ if (validatePostalCode(value, rule.country)) return void 0;
234
+ return {
235
+ key: getPostalCodeErrorKey(rule.country),
236
+ params: buildPostalCodeParams(rule.country)
237
+ };
238
+ }
239
+ });
240
+ const normalizeFieldValue = (value) => typeof value === "string" ? value : String(value ?? "");
241
+ const evaluateRules = (value, rules, field, validators) => {
242
+ if (!rules) return void 0;
243
+ for (const rule of rules) {
244
+ const error = validators[rule.type](value, rule, field);
245
+ if (error) return error;
246
+ }
247
+ };
248
+ /**
249
+ * Address group: when no address field is filled (for countries that require
250
+ * address validation), marks required address fields with a required error.
251
+ * Per-field errors take precedence — this is merged last in validateEkybForm.
252
+ */
253
+ function validateAddressGroup(fields, values, country) {
254
+ if (!requiresAddressValidation(country)) return {};
255
+ const addressValues = {};
256
+ for (const f of ADDRESS_FIELDS) addressValues[f] = values[f];
257
+ if (hasAtLeastOneAddressField(addressValues)) return {};
258
+ const errors = {};
259
+ const requiredAddressFields = fields.filter((f) => ADDRESS_FIELDS.includes(f.name) && f.required);
260
+ for (const f of requiredAddressFields) if (!(values[f.name] ?? "").trim()) {
261
+ const fieldName = f.displayLabel ?? f.label;
262
+ errors[f.name] = {
263
+ key: DYNAMIC_REQUIRED_KEY,
264
+ params: { fieldName }
265
+ };
266
+ }
267
+ return errors;
268
+ }
269
+ /**
270
+ * UBO group: marks required UBO name/surname fields when the UBO entry
271
+ * has been interacted with (first UBO always validates; subsequent UBOs
272
+ * only validate if either field has a value).
273
+ */
274
+ function validateUboGroup(ubos, hasUbos) {
275
+ if (!hasUbos) return {};
276
+ const errors = {};
277
+ for (let i = 0; i < ubos.length; i++) {
278
+ const isDefault = i === 0;
279
+ const hasAnyValue = ubos[i].name.trim() !== "" || ubos[i].surname.trim() !== "";
280
+ if (isDefault || hasAnyValue) {
281
+ if (!ubos[i].name.trim()) errors[`ubo-${i}-name`] = {
282
+ key: DYNAMIC_REQUIRED_KEY,
283
+ params: { fieldName: UBO_FIELD_LABELS.name }
284
+ };
285
+ if (!ubos[i].surname.trim()) errors[`ubo-${i}-surname`] = {
286
+ key: DYNAMIC_REQUIRED_KEY,
287
+ params: { fieldName: UBO_FIELD_LABELS.surname }
288
+ };
289
+ }
290
+ }
291
+ return errors;
292
+ }
293
+ /**
294
+ * Full-form validation: per-field pass, then address cross-field pass, then
295
+ * UBO pass. Per-field errors take precedence over cross-field errors for
296
+ * the same key.
297
+ */
298
+ function validateEkybForm(values, fields, country, ubos, hasUbos) {
299
+ const validators = createValidators();
300
+ const perField = fields.reduce((acc, field) => {
301
+ const error = evaluateRules(normalizeFieldValue(values[field.name]), field.validation, field, validators);
302
+ if (error) acc[field.name] = error;
303
+ return acc;
304
+ }, {});
305
+ const addressGroup = validateAddressGroup(fields, values, country);
306
+ const uboGroup = validateUboGroup(ubos, hasUbos);
307
+ return {
308
+ ...addressGroup,
309
+ ...perField,
310
+ ...uboGroup
311
+ };
312
+ }
313
+ /**
314
+ * Single-field validation (per-field only, no cross-field passes).
315
+ * Intended for blur-triggered validation of regular form fields.
316
+ */
317
+ function validateEkybField(values, fieldName, fields) {
318
+ const field = fields.find((f) => f.name === fieldName);
319
+ if (!field) return void 0;
320
+ const validators = createValidators();
321
+ return evaluateRules(normalizeFieldValue(values[field.name]), field.validation, field, validators);
322
+ }
323
+ /**
324
+ * Single UBO field validation (blur-triggered).
325
+ * fieldKey format: `ubo-{index}-name` or `ubo-{index}-surname`.
326
+ * Returns undefined for non-default UBOs whose peer field is also empty
327
+ * (user hasn't started filling that UBO entry yet).
328
+ */
329
+ function validateEkybUboField(ubos, fieldKey) {
330
+ const match = fieldKey.match(/^ubo-(\d+)-(name|surname)$/);
331
+ if (!match) return void 0;
332
+ const index = Number(match[1]);
333
+ const field = match[2];
334
+ if (index < 0 || index >= ubos.length) return void 0;
335
+ const ubo = ubos[index];
336
+ const isDefault = index === 0;
337
+ const hasAnyValue = ubo.name.trim() !== "" || ubo.surname.trim() !== "";
338
+ if (!isDefault && !hasAnyValue) return void 0;
339
+ if (!ubo[field].trim()) return {
340
+ key: DYNAMIC_REQUIRED_KEY,
341
+ params: { fieldName: UBO_FIELD_LABELS[field] }
342
+ };
343
+ }
344
+ /** Returns true when CNPJ validation applies for the given country. */
345
+ function requiresCnpjValidation(country) {
346
+ return COUNTRIES_WITH_CNPJ_VALIDATION.includes(country);
347
+ }
348
+
349
+ //#endregion
350
+ //#region src/modules/ekyb/ekybActions.ts
351
+ function buildEkybValidationRules(fieldName, required, country) {
352
+ const rules = [];
353
+ if (required) rules.push({ type: "required" });
354
+ if (fieldName === "taxId" && requiresCnpjValidation(country)) rules.push({ type: "cnpj" });
355
+ if (fieldName === "postalCode") rules.push({
356
+ type: "postalCodeFormat",
357
+ country
358
+ });
359
+ return rules;
360
+ }
215
361
  function buildEkybFields(verificationFields, country, _hasUbos) {
216
362
  let modules = verificationFields.filter((f) => f !== "ubos-user_input" && !f.startsWith("socure"));
217
363
  if (country === "GB") modules = modules.filter((m) => m !== "state-user_input");
@@ -241,6 +387,8 @@ function buildEkybFields(verificationFields, country, _hasUbos) {
241
387
  def.options = usStateOptions;
242
388
  def.placeholder = "verification.placeholder.state";
243
389
  }
390
+ const validation = buildEkybValidationRules(fieldName, def.required, country);
391
+ if (validation.length > 0) def.validation = validation;
244
392
  return def;
245
393
  });
246
394
  }
@@ -253,83 +401,6 @@ function getDefaultVerificationFields(config) {
253
401
  if (config.checkUniqueBeneficialOwner !== false) fields.push("ubos-user_input");
254
402
  return fields;
255
403
  }
256
- function validateEkybField(name, value, required, country) {
257
- const val = (value ?? "").trim();
258
- if (required && !val) return "ekyb.error.requiredField";
259
- if (name === "taxId") {
260
- if (COUNTRIES_WITH_CNPJ_VALIDATION.includes(country)) {
261
- if (val && !validateCNPJ(val)) return "ekyb.error.invalidTaxId";
262
- }
263
- if (COUNTRIES_WITH_SPECIAL_TAX_ID_RULES.includes(country) && !val) return;
264
- }
265
- if (name === "postalCode" && val) {
266
- if (!validatePostalCode(val, country)) return getPostalCodeErrorKey(country);
267
- }
268
- }
269
- function computeEkybValidation(fields, values, country, ubos, hasUbos) {
270
- const errors = {};
271
- for (const field of fields) {
272
- const val = values[field.name];
273
- const err = validateEkybField(field.name, val, field.required, country);
274
- if (err) errors[field.name] = err;
275
- }
276
- if (requiresAddressValidation(country)) {
277
- const addressValues = {};
278
- for (const f of ADDRESS_FIELDS) addressValues[f] = values[f];
279
- if (!hasAtLeastOneAddressField(addressValues)) {
280
- const requiredAddressFields = fields.filter((f) => ADDRESS_FIELDS.includes(f.name) && f.required);
281
- for (const f of requiredAddressFields) if (!errors[f.name] && !(values[f.name] ?? "").trim()) errors[f.name] = "ekyb.error.requiredField";
282
- }
283
- }
284
- if (hasUbos) for (let i = 0; i < ubos.length; i++) {
285
- const isDefault = i === 0;
286
- const hasAnyValue = ubos[i].name.trim() !== "" || ubos[i].surname.trim() !== "";
287
- if (isDefault || hasAnyValue) {
288
- if (!ubos[i].name.trim()) errors[`ubo-${i}-name`] = "ekyb.error.requiredField";
289
- if (!ubos[i].surname.trim()) errors[`ubo-${i}-surname`] = "ekyb.error.requiredField";
290
- }
291
- }
292
- return {
293
- errors,
294
- isValid: Object.keys(errors).length === 0
295
- };
296
- }
297
- function computeDisplayErrors(errors, touched, submitAttempted, country, fields) {
298
- const display = {};
299
- const errorParams = {};
300
- const fieldLabelMap = new Map(fields?.map((f) => [f.name, f.displayLabel ?? f.label]));
301
- for (const [field, err] of Object.entries(errors)) {
302
- const isRequiredErr = REQUIRED_ERROR_KEYS.has(err);
303
- if (isRequiredErr && (submitAttempted || touched[field])) {
304
- display[field] = DYNAMIC_REQUIRED_KEY;
305
- const label = fieldLabelMap.get(field);
306
- if (label) errorParams[field] = { fieldName: label };
307
- else {
308
- const uboMatch = field.match(/^ubo-\d+-(name|surname)$/);
309
- if (uboMatch) errorParams[field] = { fieldName: UBO_FIELD_LABELS[uboMatch[1]] ?? field };
310
- }
311
- } else if (!isRequiredErr && touched[field]) display[field] = err;
312
- if (display[field] && field === "postalCode" && POSTAL_CODE_FORMAT_ERROR_KEYS.has(err)) {
313
- const fixedLen = FIXED_DIGIT_POSTAL_CODE_LENGTH[country];
314
- if (fixedLen !== void 0) errorParams[field] = {
315
- ...errorParams[field] ?? {},
316
- length: fixedLen
317
- };
318
- else {
319
- let maxLen = getPostalCodeMaxLength(country);
320
- if (country === "US" || country === "BR") maxLen = maxLen - 1;
321
- errorParams[field] = {
322
- ...errorParams[field] ?? {},
323
- maxLength: maxLen
324
- };
325
- }
326
- }
327
- }
328
- return {
329
- displayErrors: display,
330
- errorParams
331
- };
332
- }
333
404
  function processEkybFieldValue(name, value, country) {
334
405
  if (name === "postalCode") return formatPostalCode(value, country);
335
406
  return value;
@@ -351,7 +422,7 @@ function buildEkybSubmitPayload(ctx) {
351
422
  //#endregion
352
423
  //#region src/modules/ekyb/ekybGuards.ts
353
424
  const hasFlowIdGuard = ({ context }) => !!context.config.flowId;
354
- const isValidGuard = ({ context }) => context.isValid;
425
+ const hasNoValidationErrorsGuard = ({ context }) => Object.keys(context.validationErrors ?? {}).length === 0;
355
426
  const canAddUboGuard = ({ context }) => context.canAddUbo;
356
427
  const isValidUboIndexGuard = ({ context, event }) => {
357
428
  const { index } = event;
@@ -384,6 +455,13 @@ const submitEkybActor = fromPromise(async ({ input, signal }) => submitEkyb(inpu
384
455
 
385
456
  //#endregion
386
457
  //#region src/modules/ekyb/ekybStateMachine.ts
458
+ const ADDRESS_AUTOCOMPLETE_KEYS = [
459
+ "street",
460
+ "city",
461
+ "state",
462
+ "postalCode",
463
+ "houseNo"
464
+ ];
387
465
  const ekybMachine = setup({
388
466
  types: {
389
467
  context: {},
@@ -407,26 +485,20 @@ const ekybMachine = setup({
407
485
  const country = "US";
408
486
  const vFields = getDefaultVerificationFields(config);
409
487
  const hasUbos = config.checkUniqueBeneficialOwner !== false && vFields.includes("ubos-user_input");
410
- const fields = buildEkybFields(vFields, country, hasUbos);
411
- const values = { country };
412
- const ubos = hasUbos ? [{
413
- id: "ubo-1",
414
- name: "",
415
- surname: ""
416
- }] : [];
417
- const { errors, isValid } = computeEkybValidation(fields, values, country, ubos, hasUbos);
418
488
  return {
419
489
  config,
420
490
  country,
421
491
  availableCountries: ALL_COUNTRIES,
422
- fields,
423
- values,
424
- errors,
425
- isValid,
426
- ubos,
492
+ fields: buildEkybFields(vFields, country, hasUbos),
493
+ values: { country },
494
+ validationErrors: void 0,
495
+ ubos: hasUbos ? [{
496
+ id: "ubo-1",
497
+ name: "",
498
+ surname: ""
499
+ }] : [],
427
500
  canAddUbo: hasUbos,
428
501
  hasUbos,
429
- submitAttempted: false,
430
502
  addressSuggestions: [],
431
503
  _nextUboId: 2,
432
504
  _searchQuery: ""
@@ -449,18 +521,15 @@ const ekybMachine = setup({
449
521
  nextId += 1;
450
522
  }
451
523
  else ubos = [];
452
- const newValues = {
453
- ...context.values,
454
- country,
455
- state: ""
456
- };
457
- const { errors, isValid } = computeEkybValidation(fields, newValues, country, ubos, hasUbos);
458
524
  return {
459
525
  country,
460
526
  fields,
461
- values: newValues,
462
- errors,
463
- isValid,
527
+ values: {
528
+ ...context.values,
529
+ country,
530
+ state: ""
531
+ },
532
+ validationErrors: void 0,
464
533
  ubos,
465
534
  canAddUbo: hasUbos && ubos.length < UBO_INPUT_LIMIT,
466
535
  hasUbos,
@@ -468,18 +537,33 @@ const ekybMachine = setup({
468
537
  };
469
538
  }),
470
539
  updateField: assign(({ context, event }) => {
471
- const { name, value } = event;
472
- const processed = processEkybFieldValue(name, value, context.country);
473
- const newValues = {
540
+ if (event.type !== "DATA_CHANGED") return {};
541
+ const processed = processEkybFieldValue(event.name, event.value, context.country);
542
+ return { values: {
474
543
  ...context.values,
475
- [name]: processed
476
- };
477
- const { errors, isValid } = computeEkybValidation(context.fields, newValues, context.country, context.ubos, context.hasUbos);
478
- return {
479
- values: newValues,
480
- errors,
481
- isValid
482
- };
544
+ [event.name]: processed
545
+ } };
546
+ }),
547
+ clearFieldValidationError: assign(({ context, event }) => {
548
+ if (event.type !== "DATA_CHANGED") return {};
549
+ const errs = context.validationErrors;
550
+ if (!errs?.[event.name]) return {};
551
+ const next = { ...errs };
552
+ delete next[event.name];
553
+ return { validationErrors: Object.keys(next).length > 0 ? next : void 0 };
554
+ }),
555
+ validateFormField: assign(({ context, event }) => {
556
+ if (event.type !== "VALIDATE_FIELD") return {};
557
+ const { name } = event;
558
+ const message = /^ubo-\d+-(name|surname)$/.test(name) ? validateEkybUboField(context.ubos, name) : validateEkybField(context.values, name, context.fields);
559
+ const next = { ...context.validationErrors ?? {} };
560
+ if (message) next[name] = message;
561
+ else delete next[name];
562
+ return { validationErrors: Object.keys(next).length > 0 ? next : void 0 };
563
+ }),
564
+ computeValidationResult: assign(({ context }) => {
565
+ const errors = validateEkybForm(context.values, context.fields, context.country, context.ubos, context.hasUbos);
566
+ return { validationErrors: Object.keys(errors).length > 0 ? errors : void 0 };
483
567
  }),
484
568
  addUbo: assign(({ context }) => {
485
569
  const newId = context._nextUboId;
@@ -488,13 +572,9 @@ const ekybMachine = setup({
488
572
  name: "",
489
573
  surname: ""
490
574
  }];
491
- const canAddUbo = ubos.length < UBO_INPUT_LIMIT;
492
- const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
493
575
  return {
494
576
  ubos,
495
- canAddUbo,
496
- errors,
497
- isValid,
577
+ canAddUbo: ubos.length < UBO_INPUT_LIMIT,
498
578
  _nextUboId: newId + 1
499
579
  };
500
580
  }),
@@ -502,12 +582,27 @@ const ekybMachine = setup({
502
582
  const { index } = event;
503
583
  const ubos = context.ubos.filter((_, i) => i !== index);
504
584
  const canAddUbo = ubos.length < UBO_INPUT_LIMIT;
505
- const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
585
+ const errs = context.validationErrors;
586
+ let newErrors;
587
+ if (errs) {
588
+ const next = {};
589
+ for (const [key, val] of Object.entries(errs)) {
590
+ const match = key.match(/^ubo-(\d+)-(name|surname)$/);
591
+ if (!match) {
592
+ next[key] = val;
593
+ continue;
594
+ }
595
+ const uboIdx = Number(match[1]);
596
+ if (uboIdx === index) continue;
597
+ const newIdx = uboIdx > index ? uboIdx - 1 : uboIdx;
598
+ next[`ubo-${newIdx}-${match[2]}`] = val;
599
+ }
600
+ newErrors = Object.keys(next).length > 0 ? next : void 0;
601
+ }
506
602
  return {
507
603
  ubos,
508
604
  canAddUbo,
509
- errors,
510
- isValid
605
+ validationErrors: newErrors
511
606
  };
512
607
  }),
513
608
  setUboField: assign(({ context, event }) => {
@@ -516,33 +611,46 @@ const ekybMachine = setup({
516
611
  ...ubo,
517
612
  [field]: value
518
613
  } : ubo);
519
- const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
614
+ const fieldKey = `ubo-${index}-${field}`;
615
+ const errs = context.validationErrors;
616
+ if (!errs?.[fieldKey]) return { ubos };
617
+ const next = { ...errs };
618
+ delete next[fieldKey];
520
619
  return {
521
620
  ubos,
522
- errors,
523
- isValid
621
+ validationErrors: Object.keys(next).length > 0 ? next : void 0
524
622
  };
525
623
  }),
526
624
  setErrorMessage: assign(({ event }) => ({ errorMessage: String(event.error ?? "verification.error") })),
527
625
  clearErrorMessage: assign({ errorMessage: () => "" }),
528
- markSubmitAttempted: assign({ submitAttempted: () => true }),
529
626
  fillAddressFields: assign(({ context, event }) => {
530
627
  const { suggestion } = event;
531
628
  const activeFields = new Set(context.fields.map((f) => f.name));
532
629
  const { values: newValues } = fillFromSuggestion(context.values, {}, suggestion, activeFields);
533
- const { errors, isValid } = computeEkybValidation(context.fields, newValues, context.country, context.ubos, context.hasUbos);
630
+ const errs = context.validationErrors;
631
+ let newErrors = errs;
632
+ if (errs) {
633
+ const next = { ...errs };
634
+ for (const key of ADDRESS_AUTOCOMPLETE_KEYS) delete next[key];
635
+ newErrors = Object.keys(next).length > 0 ? next : void 0;
636
+ }
637
+ const streetError = getStreetLevelErrorForSuggestion(suggestion, activeFields);
638
+ if (streetError !== void 0) newErrors = {
639
+ ...newErrors,
640
+ street: streetError
641
+ };
534
642
  return {
535
643
  values: newValues,
536
644
  addressSuggestions: [],
537
- errors,
538
- isValid
645
+ _searchQuery: "",
646
+ validationErrors: newErrors
539
647
  };
540
648
  }),
541
649
  setAddressSuggestions: assign(({ event }) => ({ addressSuggestions: event.suggestions }))
542
650
  },
543
651
  guards: {
544
652
  hasFlowId: hasFlowIdGuard,
545
- isValid: isValidGuard,
653
+ hasNoValidationErrors: hasNoValidationErrorsGuard,
546
654
  canAddUbo: canAddUboGuard,
547
655
  isValidUboIndex: isValidUboIndexGuard,
548
656
  isSupportedCountry: isSupportedCountryGuard
@@ -555,27 +663,21 @@ const ekybMachine = setup({
555
663
  const country = "US";
556
664
  const vFields = getDefaultVerificationFields(config);
557
665
  const hasUbos = config.checkUniqueBeneficialOwner !== false && vFields.includes("ubos-user_input");
558
- const fields = buildEkybFields(vFields, country, hasUbos);
559
- const values = { country };
560
- const ubos = hasUbos ? [{
561
- id: "ubo-1",
562
- name: "",
563
- surname: ""
564
- }] : [];
565
- const { errors, isValid } = computeEkybValidation(fields, values, country, ubos, hasUbos);
566
666
  return {
567
667
  config,
568
668
  country,
569
669
  availableCountries: ALL_COUNTRIES,
570
- fields,
571
- values,
572
- errors,
573
- isValid,
574
- ubos,
670
+ fields: buildEkybFields(vFields, country, hasUbos),
671
+ values: { country },
672
+ validationErrors: void 0,
673
+ ubos: hasUbos ? [{
674
+ id: "ubo-1",
675
+ name: "",
676
+ surname: ""
677
+ }] : [],
575
678
  canAddUbo: hasUbos,
576
679
  hasUbos,
577
680
  errorMessage: "",
578
- submitAttempted: false,
579
681
  addressSuggestions: [],
580
682
  _nextUboId: 2,
581
683
  _searchQuery: ""
@@ -596,19 +698,34 @@ const ekybMachine = setup({
596
698
  onError: "form"
597
699
  } },
598
700
  form: {
599
- initial: "idle",
701
+ initial: "inputting",
600
702
  states: {
601
- idle: {},
703
+ inputting: { on: {
704
+ DATA_CHANGED: { actions: ["updateField", "clearFieldValidationError"] },
705
+ VALIDATE_FIELD: { actions: "validateFormField" },
706
+ SUBMIT: { target: "validatingSubmit" }
707
+ } },
602
708
  searching: {
603
709
  invoke: {
604
710
  id: "debounceSearch",
605
711
  src: "debounceSearch",
606
712
  input: ({ context }) => ({ query: context._searchQuery })
607
713
  },
608
- on: { RESULTS: {
609
- target: "idle",
610
- actions: "setAddressSuggestions"
611
- } }
714
+ on: {
715
+ DATA_CHANGED: { actions: ["updateField", "clearFieldValidationError"] },
716
+ VALIDATE_FIELD: { actions: "validateFormField" },
717
+ RESULTS: {
718
+ target: "inputting",
719
+ actions: "setAddressSuggestions"
720
+ }
721
+ }
722
+ },
723
+ validatingSubmit: {
724
+ entry: "computeValidationResult",
725
+ always: [{
726
+ guard: "hasNoValidationErrors",
727
+ target: "#ekyb.submitting"
728
+ }, { target: "inputting" }]
612
729
  }
613
730
  },
614
731
  on: {
@@ -616,18 +733,6 @@ const ekybMachine = setup({
616
733
  guard: "isSupportedCountry",
617
734
  actions: "setCountry"
618
735
  },
619
- SET_FIELD: { actions: "updateField" },
620
- SEARCH_ADDRESS: {
621
- target: ".searching",
622
- actions: assign(({ event }) => ({
623
- _searchQuery: event.query,
624
- addressSuggestions: []
625
- }))
626
- },
627
- SELECT_ADDRESS: {
628
- target: ".idle",
629
- actions: "fillAddressFields"
630
- },
631
736
  ADD_UBO: {
632
737
  guard: "canAddUbo",
633
738
  actions: "addUbo"
@@ -640,10 +745,17 @@ const ekybMachine = setup({
640
745
  guard: "isValidUboIndex",
641
746
  actions: "setUboField"
642
747
  },
643
- SUBMIT: [{
644
- target: "submitting",
645
- guard: "isValid"
646
- }, { actions: "markSubmitAttempted" }],
748
+ SEARCH_ADDRESS: {
749
+ target: ".searching",
750
+ actions: assign(({ event }) => ({
751
+ _searchQuery: event.query,
752
+ addressSuggestions: []
753
+ }))
754
+ },
755
+ SELECT_ADDRESS: {
756
+ target: ".inputting",
757
+ actions: "fillAddressFields"
758
+ },
647
759
  CLOSE: { target: "closed" }
648
760
  }
649
761
  },
@@ -671,4 +783,4 @@ const ekybMachine = setup({
671
783
  });
672
784
 
673
785
  //#endregion
674
- export { DEV_ONLY_COUNTRIES as a, ALL_COUNTRIES as i, computeDisplayErrors as n, SUPPORTED_COUNTRIES as o, toEkybConfig as r, isSupportedCountry as s, ekybMachine as t };
786
+ export { SUPPORTED_COUNTRIES as a, DEV_ONLY_COUNTRIES as i, toEkybConfig as n, isSupportedCountry as o, ALL_COUNTRIES as r, ekybMachine as t };