@incodetech/core 2.4.0 → 2.4.1-agentic

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 (228) hide show
  1. package/dist/{FaceDetectionProvider-DcPOC2gS.esm.js → FaceDetectionProvider-B83VmClw.esm.js} +29 -64
  2. package/dist/IBrowserEnvironmentCapability-D7JG7ML3.esm.js +16 -0
  3. package/dist/IGeolocationCapability-r49Qo7rR.d.ts +10 -0
  4. package/dist/{IWasmUtilCapability-GF2n7sfm.d.ts → IWasmUtilCapability-Cqiaxydi.d.ts} +31 -4
  5. package/dist/{PhoneValidationProvider-SZiOS0jB.esm.js → PhoneValidationProvider-Co4zk2en.esm.js} +7 -0
  6. package/dist/{StreamCanvasCapture-7JRf-2ck.d.ts → StreamCanvasCapture-C3xNfOsv.d.ts} +12 -3
  7. package/dist/{WasmUtilProvider-DtJuBdt-.esm.js → WasmUtilProvider-GTkoJyFY.esm.js} +75 -22
  8. package/dist/{addressSearch-DPjIKJrX.esm.js → addressSearch-41sMcnJk.esm.js} +72 -31
  9. package/dist/{advanceableErrors-q_pfU3Cn.esm.js → advanceableErrors-k-U-cL5m.esm.js} +1 -2
  10. package/dist/ae-signature.esm.js +1 -1
  11. package/dist/antifraud.esm.js +2 -2
  12. package/dist/{antifraudManager-CaweCYnY.esm.js → antifraudManager-CQ08atTC.esm.js} +2 -2
  13. package/dist/{antifraudStateMachine-DRl0UVyA.esm.js → antifraudStateMachine-BcsUTTIr.esm.js} +1 -1
  14. package/dist/{api-Cz90EHyu.esm.js → api-BO8JA7Pf.esm.js} +6 -5
  15. package/dist/{apiError-DPwFas2f.esm.js → apiError-CfuIvnUy.esm.js} +1 -1
  16. package/dist/attemptCarry-BjTJ6bMQ.esm.js +45 -0
  17. package/dist/authentication.d.ts +3 -3
  18. package/dist/authentication.esm.js +2 -2
  19. package/dist/{authenticationManager-BIZC55Bi.d.ts → authenticationManager-C-cOki0Y.d.ts} +1 -1
  20. package/dist/{authenticationManager-2Lr5V_7p.esm.js → authenticationManager-DvmklBTE.esm.js} +5 -5
  21. package/dist/{authenticationStateMachine-C99B0GFP.esm.js → authenticationStateMachine-BL2ptOA0.esm.js} +3 -3
  22. package/dist/{backCameraStream-CMvXj4X4.esm.js → backCameraStream-C5_NNfUN.esm.js} +3 -43
  23. package/dist/{browser-DlFgHpoC-DnyrCR8r.esm.js → browser-pQZA35G2-DtkAf6sn.esm.js} +161 -150
  24. package/dist/{camera-sIa9ceW2.esm.js → camera-E_Kcre4O.esm.js} +15 -23
  25. package/dist/camera.esm.js +1 -1
  26. package/dist/certificate-issuance.esm.js +2 -2
  27. package/dist/{certificateIssuanceManager-BfeMv2PU.esm.js → certificateIssuanceManager-CM0fuqDC.esm.js} +2 -2
  28. package/dist/{certificateIssuanceStateMachine-Frgjbjw8.esm.js → certificateIssuanceStateMachine-kksIUOPD.esm.js} +2 -2
  29. package/dist/cnpj-Co1ottYN.esm.js +77 -0
  30. package/dist/connectivity-HSl0diCx.esm.js +133 -0
  31. package/dist/consent.d.ts +1 -1
  32. package/dist/consent.esm.js +2 -2
  33. package/dist/{consentManager-CvEu8h_W.esm.js → consentManager-CBwFozhv.esm.js} +4 -3
  34. package/dist/{consentManager-Cv_0QKLD.d.ts → consentManager-_q9yJUku.d.ts} +14 -7
  35. package/dist/{consentStateMachine-DJTgN_-1.esm.js → consentStateMachine-CpmRAcr2.esm.js} +20 -7
  36. package/dist/cross-document-data-match.esm.js +1 -1
  37. package/dist/{crossDocumentDataMatchManager-Cu141CE8.esm.js → crossDocumentDataMatchManager-64O8t10a.esm.js} +2 -2
  38. package/dist/curp-validation.d.ts +1 -1
  39. package/dist/curp-validation.esm.js +2 -2
  40. package/dist/{curpValidationManager-B-z9q5V3.esm.js → curpValidationManager-CLgJQcx0.esm.js} +3 -2
  41. package/dist/{curpValidationManager-C9sqoh9n.d.ts → curpValidationManager-CXpFE-Mv.d.ts} +1 -1
  42. package/dist/{curpValidationStateMachine-vDEFLMPw.esm.js → curpValidationStateMachine-Bx9YhVkJ.esm.js} +28 -20
  43. package/dist/custom-fields.esm.js +1 -1
  44. package/dist/custom-watchlist.esm.js +2 -2
  45. package/dist/{customFieldsManager-D1ex2cFM.esm.js → customFieldsManager-DWt_0YtJ.esm.js} +2 -2
  46. package/dist/{customWatchlistManager-CTI-SGk0.esm.js → customWatchlistManager-D8o-2Nej.esm.js} +2 -2
  47. package/dist/{customWatchlistStateMachine-hmRd0f2I.esm.js → customWatchlistStateMachine-Sbi6DIcK.esm.js} +1 -1
  48. package/dist/{deepsightLoader-DeNvGU3c.esm.js → deepsightLoader-DMxtowCm.esm.js} +6 -28
  49. package/dist/{deepsightService-CKTYDIXD.esm.js → deepsightService-twg3bXqY.esm.js} +20 -59
  50. package/dist/{createCameraCycleOwnership-Dj_LHUvN.esm.js → desktopCameraElection-kHY2IDJi.esm.js} +177 -40
  51. package/dist/device.esm.js +2 -2
  52. package/dist/document-capture.d.ts +2 -2
  53. package/dist/document-capture.esm.js +2 -2
  54. package/dist/{documentCaptureManager-DkyDtm3Y.d.ts → documentCaptureManager-6tnnDkMX.d.ts} +14 -2
  55. package/dist/{documentCaptureManager-DUJwpKC5.esm.js → documentCaptureManager-CMSC_Mhd.esm.js} +26 -19
  56. package/dist/{documentCaptureStateMachine-B8i7GnLh.esm.js → documentCaptureStateMachine-BCwD5Rto.esm.js} +43 -35
  57. package/dist/dynamic-forms.d.ts +2 -2
  58. package/dist/dynamic-forms.esm.js +2 -2
  59. package/dist/{dynamicFormsManager-C0dHs1ty.d.ts → dynamicFormsManager-9kwY8Bf5.d.ts} +1 -1
  60. package/dist/{dynamicFormsManager-DiKYjcF3.esm.js → dynamicFormsManager-DU6W1e20.esm.js} +2 -2
  61. package/dist/{dynamicFormsStateMachine-DEI45xYW.esm.js → dynamicFormsStateMachine-C8Z7k3vo.esm.js} +2 -2
  62. package/dist/ekyb.d.ts +4 -4
  63. package/dist/ekyb.esm.js +3 -3
  64. package/dist/{ekybManager-BaZ_7CEu.d.ts → ekybManager-TB6ZG5lX.d.ts} +2 -2
  65. package/dist/{ekybManager-8WLkNcqg.esm.js → ekybManager-TGfqyjuu.esm.js} +2 -2
  66. package/dist/{ekybStateMachine-BLRT45Ex.esm.js → ekybStateMachine-DBgFuEPK.esm.js} +26 -44
  67. package/dist/ekyc.d.ts +3 -3
  68. package/dist/ekyc.esm.js +3 -3
  69. package/dist/{ekycManager-DW-ynodd.d.ts → ekycManager-BSQteIfC.d.ts} +1 -1
  70. package/dist/{ekycManager-BO-Lui3t.esm.js → ekycManager-C2cgG2Pl.esm.js} +2 -2
  71. package/dist/ekycStateMachine-CuNF7z4O.esm.js +7505 -0
  72. package/dist/ekycUtils-BFncpC4F.esm.js +1401 -0
  73. package/dist/electronic-signature.esm.js +1 -1
  74. package/dist/{electronicSignatureManager-CcIMOb_Y.esm.js → electronicSignatureManager-C7pqXsRm.esm.js} +4 -4
  75. package/dist/email.esm.js +2 -2
  76. package/dist/{emailManager-ButFktRm.esm.js → emailManager-FH_CP0cT.esm.js} +2 -2
  77. package/dist/{emailStateMachine-BXtlC0NV.esm.js → emailStateMachine-Cx-uTaBV.esm.js} +32 -20
  78. package/dist/{events-Du2A4-Qr.esm.js → events-CQteqXfy.esm.js} +2 -2
  79. package/dist/events.esm.js +1 -1
  80. package/dist/extensibility.d.ts +34 -20
  81. package/dist/extensibility.esm.js +34 -34
  82. package/dist/{externalFetch-DrR9xshk.esm.js → externalFetch-CQY41QT1.esm.js} +4 -1
  83. package/dist/face-match.d.ts +1 -1
  84. package/dist/face-match.esm.js +2 -2
  85. package/dist/{faceCaptureManagerFactory-1hzeS_rB.d.ts → faceCaptureManagerFactory-C-xKdj-d.d.ts} +71 -66
  86. package/dist/{faceCaptureManagerFactory-BlGvXzXA.esm.js → faceCaptureManagerFactory-CBm05KnT.esm.js} +4 -4
  87. package/dist/{faceCaptureSetup-TY8RXc2N.esm.js → faceCaptureSetup-BQjCbL51.esm.js} +82 -64
  88. package/dist/{faceMatchManager-DWFUQjMQ.esm.js → faceMatchManager-B2zp7yP4.esm.js} +2 -2
  89. package/dist/{faceMatchManager-DIgG-UFS.d.ts → faceMatchManager-Z4UDLwAv.d.ts} +16 -7
  90. package/dist/{faceMatchStateMachine-CUCvlydD.esm.js → faceMatchStateMachine-ByTMQCUC.esm.js} +40 -27
  91. package/dist/{feature-management-B5rR10uS.esm.js → feature-management-DjAG5lsJ.esm.js} +1 -1
  92. package/dist/feature-management.esm.js +1 -1
  93. package/dist/field-comparison.esm.js +1 -1
  94. package/dist/{fieldComparisonManager-v3knTYV_.esm.js → fieldComparisonManager-CC0vKmpf.esm.js} +2 -2
  95. package/dist/fiscal-qr.esm.js +1 -1
  96. package/dist/{fiscalQrManager-Dt9fHG7h.esm.js → fiscalQrManager-Be-r4oZj.esm.js} +4 -4
  97. package/dist/flow-events.d.ts +1 -1
  98. package/dist/flow.d.ts +10 -10
  99. package/dist/flow.esm.js +8 -11
  100. package/dist/{flowCompletionService-BDI5QpfR.esm.js → flowCompletionService-ChMU2v79.esm.js} +2 -2
  101. package/dist/{flowServices-roD0oIQL.esm.js → flowServices-g2tVWsJl.esm.js} +8 -50
  102. package/dist/geolocation.d.ts +1 -1
  103. package/dist/geolocation.esm.js +2 -2
  104. package/dist/{geolocationManager-Dn24g1fl.d.ts → geolocationManager-6e1i9UIR.d.ts} +15 -17
  105. package/dist/{geolocationManager-DnONzWL5.esm.js → geolocationManager-DLbvZwUB.esm.js} +6 -8
  106. package/dist/{geolocationStateMachine-eWy_G4Os.esm.js → geolocationStateMachine-CAJVongM.esm.js} +12 -8
  107. package/dist/{getDeviceClass-bsWdEDxP.esm.js → getDeviceClass-DoIWuKI8.esm.js} +1 -1
  108. package/dist/government-validation.esm.js +2 -2
  109. package/dist/{governmentValidationManager-BtXWHICu.esm.js → governmentValidationManager-CkX9TEkh.esm.js} +2 -2
  110. package/dist/{governmentValidationStateMachine-COL-Vs48.esm.js → governmentValidationStateMachine-PTPCP26N.esm.js} +1 -1
  111. package/dist/home.d.ts +1 -1
  112. package/dist/home.esm.js +1 -1
  113. package/dist/http.esm.js +1 -1
  114. package/dist/id-ocr.esm.js +2 -2
  115. package/dist/id-selfie-flow.d.ts +1 -1
  116. package/dist/id-selfie-flow.esm.js +9 -9
  117. package/dist/id-verification.esm.js +2 -2
  118. package/dist/id.d.ts +3 -16
  119. package/dist/id.esm.js +3 -3
  120. package/dist/{idCaptureDefaults-BGsG2OAs.esm.js → idCaptureDefaults-MSQoqScU.esm.js} +3 -3
  121. package/dist/{idCaptureManager-0M02hSuC.d.ts → idCaptureManager-DzTfQ1Am.d.ts} +66 -5
  122. package/dist/{idCaptureManager-BrfYjCm_.esm.js → idCaptureManager-zZdTcpG1.esm.js} +63 -17
  123. package/dist/{idCaptureServices-BSj6EH2l.esm.js → idCaptureServices-8OHinO0N.esm.js} +9 -9
  124. package/dist/{idCaptureStateMachine-dXKBYHQp.esm.js → idCaptureStateMachine-B3G6XoDG.esm.js} +914 -536
  125. package/dist/{idOcrManager-D3-HNMXP.esm.js → idOcrManager-B64-fjWg.esm.js} +2 -2
  126. package/dist/{idOcrStateMachine-DyENX6Ki.esm.js → idOcrStateMachine-B1aZnobs.esm.js} +2 -2
  127. package/dist/{idVerificationManager-iWz7Avkr.esm.js → idVerificationManager-_Kebv-Ue.esm.js} +2 -2
  128. package/dist/{idVerificationStateMachine-CL1kUdBe.esm.js → idVerificationStateMachine-DQn6c84z.esm.js} +1 -1
  129. package/dist/identity-reuse.esm.js +2 -2
  130. package/dist/{identityReuseManager-CD1ucp1d.esm.js → identityReuseManager-DDXkNVZi.esm.js} +2 -2
  131. package/dist/{identityReuseStateMachine-DfV81wQC.esm.js → identityReuseStateMachine-Bcnkbjf8.esm.js} +1 -1
  132. package/dist/{index-BKOWUhxG.d.ts → index-DEfwds5y.d.ts} +55 -8
  133. package/dist/{index-CKQ9QBZP.d.ts → index-DMDAk85K.d.ts} +1 -1
  134. package/dist/index.d.ts +1 -1
  135. package/dist/index.esm.js +1 -1
  136. package/dist/{invokeOnCaptureCallback-DYrkOXO6.esm.js → invokeOnCaptureCallback-CXIBwBeE.esm.js} +1 -1
  137. package/dist/mandatory-consent.d.ts +2 -2
  138. package/dist/mandatory-consent.esm.js +2 -2
  139. package/dist/{mandatoryConsentManager-Cwqx1nK7.esm.js → mandatoryConsentManager-43W5d_8G.esm.js} +4 -3
  140. package/dist/{mandatoryConsentManager-BQ43yndC.d.ts → mandatoryConsentManager-xx3mY-xw.d.ts} +11 -4
  141. package/dist/{mandatoryConsentStateMachine-pXWqAHo_.esm.js → mandatoryConsentStateMachine-CVlgdlnt.esm.js} +20 -7
  142. package/dist/{multipartRecordingService-CLwrF5wD.esm.js → multipartRecordingService-DMBxHKS2.esm.js} +3 -13
  143. package/dist/nationalIds-B91f_RuB.esm.js +99 -0
  144. package/dist/{permissionGuards-gcy3U0SL.esm.js → permissionGuards-B3OPL8Si.esm.js} +1 -1
  145. package/dist/{permissionServices-Ca-tSNhT.esm.js → permissionServices-DnBAN_hW.esm.js} +4 -4
  146. package/dist/phone-number.d.ts +7 -1
  147. package/dist/phone-number.esm.js +15 -2
  148. package/dist/phone.d.ts +1 -1
  149. package/dist/phone.esm.js +2 -2
  150. package/dist/{phoneManager-BO-LTih5.d.ts → phoneManager-6nrJkvkG.d.ts} +5 -0
  151. package/dist/{phoneManager-KKUq-Vgo.esm.js → phoneManager-C6jut_pz.esm.js} +3 -3
  152. package/dist/{phoneStateMachine-D2QWS2cu.esm.js → phoneStateMachine-T1-drWfG.esm.js} +37 -25
  153. package/dist/{phoneValidation-DnBcNUNh.esm.js → phoneValidation-OggtfjRt.esm.js} +1 -2
  154. package/dist/{platform-DkcRc9JV.esm.js → platform-aPh7gTWh.esm.js} +15 -1
  155. package/dist/processFaceMatch-BWme3kVV.esm.js +21 -0
  156. package/dist/qe-signature.esm.js +1 -1
  157. package/dist/redirect-to-mobile.d.ts +2 -2
  158. package/dist/redirect-to-mobile.esm.js +2 -2
  159. package/dist/{redirectToMobileManager-uHW3dyuQ.esm.js → redirectToMobileManager-BJXC6Kx9.esm.js} +4 -3
  160. package/dist/{redirectToMobileManager-CVsvpVbQ.d.ts → redirectToMobileManager-Dm9ctRCC.d.ts} +3 -1
  161. package/dist/{redirectToMobileStateMachine-b-H-ipGM.esm.js → redirectToMobileStateMachine-BBMAc2Gb.esm.js} +27 -6
  162. package/dist/{runChildModule-BF_atgNx.esm.js → runChildModule-DPHTqSdF.esm.js} +3 -3
  163. package/dist/{sdkVersion-CsIbltJF.esm.js → sdkVersion-C3_P-Qbq.esm.js} +1 -1
  164. package/dist/selfie.d.ts +4 -4
  165. package/dist/selfie.esm.js +10 -10
  166. package/dist/{selfieErrorUtils-BY0-YbPW.esm.js → selfieErrorUtils-BL0BLMnp.esm.js} +1 -1
  167. package/dist/{selfieManager-BJdNu_nd.d.ts → selfieManager-BMmpUii2.d.ts} +1 -1
  168. package/dist/{selfieManager-vAAwzsHk.esm.js → selfieManager-Cbliomv7.esm.js} +5 -5
  169. package/dist/{selfieStateMachine-BFVp3ElQ.esm.js → selfieStateMachine-B5m_Kn0O.esm.js} +3 -3
  170. package/dist/{session-CpwfoVdH.esm.js → session-DAaAewMX.esm.js} +77 -9
  171. package/dist/session.d.ts +96 -10
  172. package/dist/session.esm.js +7 -6
  173. package/dist/{sessionInitializer-BTjYgE-V.esm.js → sessionInitializer-CWFT4dfw.esm.js} +402 -202
  174. package/dist/{setup-BInNAvQw.esm.js → setup-CDAKwTr7.esm.js} +32 -19
  175. package/dist/{setup-YPKTUCY5.d.ts → setup-D9qt8YVU.d.ts} +2 -2
  176. package/dist/signature.esm.js +2 -2
  177. package/dist/{signatureManager-f_dPAGXn.esm.js → signatureManager-BeEVCcsC.esm.js} +2 -2
  178. package/dist/{signatureStateMachine-C-nUq_oq.esm.js → signatureStateMachine-_1c1vSid.esm.js} +1 -1
  179. package/dist/{stats-BEvexnKC.esm.js → stats-BpMz-hTP.esm.js} +1 -1
  180. package/dist/stats.esm.js +1 -1
  181. package/dist/{tri-xzRLIIMN.esm.js → tri-BajQnjbf.esm.js} +142 -8
  182. package/dist/tri.d.ts +1 -1
  183. package/dist/tri.esm-CzTNi5Q_.esm.js +3826 -0
  184. package/dist/tri.esm.js +1 -1
  185. package/dist/{trueSightService-BMT-TubT.esm.js → trueSightService-BujtUIW6.esm.js} +19 -10
  186. package/dist/trust-graph.esm.js +1 -1
  187. package/dist/{types-yPH8lAH-.d.ts → types--3HDl2SF.d.ts} +2 -2
  188. package/dist/types-B2FK_wYb.d.ts +249 -0
  189. package/dist/types-B9C8W01q.d.ts +34 -0
  190. package/dist/{types-0L-eFDmr.d.ts → types-C397LhmN.d.ts} +1 -1
  191. package/dist/types-D9r3zRfY.d.ts +6 -0
  192. package/dist/{types-DPIDuhut.d.ts → types-DNVzoRvi.d.ts} +2 -1
  193. package/dist/{types-B6HsSzpk.d.ts → types-DuD8TRJU.d.ts} +3 -2
  194. package/dist/{types-Ckir_BEs.d.ts → types-PTZHRhGX.d.ts} +1 -1
  195. package/dist/{types-DUnFZ08M.d.ts → types-ZTZelfbM.d.ts} +2 -2
  196. package/dist/{types-CK8Jbjkp.d.ts → types-e8fCsvvk.d.ts} +1 -1
  197. package/dist/{types-BAxn7MpY.d.ts → types-xEEWCx1j.d.ts} +123 -48
  198. package/dist/{urlUtils-6jsE6rKp.esm.js → urlUtils-eYiyWjh0.esm.js} +4 -1
  199. package/dist/video-selfie.d.ts +8 -8
  200. package/dist/video-selfie.esm.js +95 -22
  201. package/dist/{videoSelfieCameraWarmer-D1xA0u8y.esm.js → videoSelfieCameraWarmer-DjkPpoj_.esm.js} +18 -21
  202. package/dist/{videoSelfieStepDetector-CGsTltqB.d.ts → videoSelfieStepDetector-RfSmlFFW.d.ts} +9 -4
  203. package/dist/{warmup-BElYWRh7.esm.js → warmup-BkfxQZsC.esm.js} +175 -11
  204. package/dist/wasm.d.ts +2 -2
  205. package/dist/wasm.esm.js +3 -3
  206. package/dist/{wasmDsFlagSync-CYj5LL9z.esm.js → wasmDsFlagSync-BhU5H2oR.esm.js} +1 -1
  207. package/dist/wasmMetadataVersionSync-U8EFUr1T.esm.js +27 -0
  208. package/dist/{wasmWebClient-BjZw_7OB.esm.js → wasmWebClient-DTj9auyA.esm.js} +43 -17
  209. package/dist/watchlist-for-business.d.ts +2 -1
  210. package/dist/watchlist-for-business.esm.js +2 -2
  211. package/dist/watchlist.esm.js +2 -2
  212. package/dist/{watchlistForBusinessManager-CZZOFkGl.esm.js → watchlistForBusinessManager-CVay6-9A.esm.js} +37 -7
  213. package/dist/{watchlistForBusinessManager-B3GDPZrr.d.ts → watchlistForBusinessManager-DX2AyM4Y.d.ts} +54 -18
  214. package/dist/watchlistForBusinessStateMachine-DA6K5na4.esm.js +166 -0
  215. package/dist/{watchlistManager-DXtX94SN.esm.js → watchlistManager-B8gQ_rw3.esm.js} +2 -2
  216. package/dist/{watchlistStateMachine-McALifag.esm.js → watchlistStateMachine-CSi_ZhtT.esm.js} +1 -1
  217. package/dist/workflow.d.ts +5 -2
  218. package/dist/workflow.esm.js +57 -47
  219. package/package.json +2 -1
  220. package/dist/IBrowserEnvironmentCapability-DEaRRk-R.esm.js +0 -9
  221. package/dist/ekycStateMachine-CDnI_NRq.esm.js +0 -1443
  222. package/dist/ekycUtils-zY8CdKJL.esm.js +0 -300
  223. package/dist/thumbmark.esm-CRc0cYvz.esm.js +0 -1242
  224. package/dist/tri.esm-BIjHhBJ2.esm.js +0 -2620
  225. package/dist/types-BvLo3U4u.d.ts +0 -134
  226. package/dist/types-zOgZqMni.d.ts +0 -6
  227. package/dist/watchlistForBusinessStateMachine-B66E7jud.esm.js +0 -78
  228. /package/dist/{types-BSBzhHRH2.d.ts → types-BSBzhHRH.d.ts} +0 -0
@@ -1,1443 +0,0 @@
1
- import { t as api, u as endpoints } from "./api-Cz90EHyu.esm.js";
2
- import { _ as STATE_CODE_HINTS, a as toEkycConfig, c as CITY_SOURCES, d as EMAIL_SOURCES, f as HOUSE_NO_SOURCES, g as POSTAL_CODE_SOURCES, h as ONE_OF_REQUIRED_GROUPS, i as resolveEkycSource, l as COUNTRY_CODE_OMITTED_SOURCES, m as NAME_SOURCES, n as getEKYCFields, o as ADDRESS_STATE_SOURCES, p as MIDDLE_NAME_SOURCES, r as isFieldOptional, s as APARTMENT_SOURCES, t as getEKYCCountry, u as COUNTRY_SELECTOR_DISABLED_SOURCES, v as STREET_SOURCES, y as TAX_ID_SOURCES } from "./ekycUtils-zY8CdKJL.esm.js";
3
- import { i as assign, t as setup } from "./xstate.esm-DSajW7CJ.esm.js";
4
- import { n as fromPromise } from "./xstate-actors.esm-8Gzepa_A.esm.js";
5
- import { a as FIXED_DIGIT_POSTAL_CODE_LENGTH, c as getPostalCodeMaxLength, d as STREET_LEVEL_REQUIRED_ERROR, f as fillFromSuggestion, i as checkSupport, l as validatePostalCode, m as usStateOptions, n as resolveForm, o as formatPostalCode, p as getStreetLevelErrorForSuggestion, r as createBundledDefinitionSource, s as getPostalCodeErrorKey, t as debounceSearchActor, u as DYNAMIC_REQUIRED_KEY } from "./addressSearch-DPjIKJrX.esm.js";
6
- import { n as DateFormattingProvider, t as validateCPF } from "./cpf-uAZTPUBy.esm.js";
7
- import { n as loadPhoneValidation, t as getPhoneValidation } from "./phoneValidation-DnBcNUNh.esm.js";
8
- //#region src/modules/ekyc/ekycValidators.ts
9
- async function loadPhoneValidator() {
10
- if (!await loadPhoneValidation()) throw new Error("Failed to load the phone validation rules");
11
- }
12
- /** Progressively formats an SSN as XXX-XX-XXXX */
13
- function formatSSN(value) {
14
- const ssn = value?.replace(/\D/g, "") ?? "";
15
- if (ssn.length < 4) return ssn;
16
- if (ssn.length < 6) return `${ssn.slice(0, 3)}-${ssn.slice(3)}`;
17
- return `${ssn.slice(0, 3)}-${ssn.slice(3, 5)}-${ssn.slice(5, 9)}`;
18
- }
19
- /**
20
- * Strips invalid characters from a name.
21
- * Fixes SDKv1 regex syntax issue — allows letters, accented chars, spaces, commas, apostrophes.
22
- */
23
- function cleanName(name) {
24
- return (name ?? "").replace(/[^a-zA-ZñÑáéíóúÁÉÍÓÚ\s,'´]/g, "").slice(0, 100);
25
- }
26
- const PO_BOX_REGEX = /POBox|P\.O\.Box|pobox|postofficebox|postbox|po\.box|p\.o\.box/i;
27
- /** Returns true if the address looks like a P.O. Box */
28
- function isPoBox(address) {
29
- return PO_BOX_REGEX.test(address.replace(/\s/g, ""));
30
- }
31
- function validatePhone(phone, country) {
32
- return getPhoneValidation()?.isValid(phone, country) ?? false;
33
- }
34
- function formatPhoneE164(phone, country) {
35
- return getPhoneValidation()?.formatE164(phone, country) ?? phone;
36
- }
37
- const ONE_OF_REQUIRED_ERROR_KEY = "verification.errors.dobOrSsnRequired";
38
- const normalizeFieldValue = (value) => typeof value === "string" ? value : String(value ?? "");
39
- const SSN_FORMAT_REGEX = /^\d{3}-\d{2}-\d{4}$/;
40
- const EMAIL_FORMAT_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
41
- const buildPostalCodeParams = (country) => {
42
- const fixedLen = FIXED_DIGIT_POSTAL_CODE_LENGTH[country];
43
- if (fixedLen !== void 0) return { length: fixedLen };
44
- let maxLen = getPostalCodeMaxLength(country);
45
- if (country === "US" || country === "BR") maxLen = maxLen - 1;
46
- return { maxLength: maxLen };
47
- };
48
- const createValidators = () => ({
49
- required: (value, _rule, field) => {
50
- if (value.trim().length > 0) return void 0;
51
- const fieldName = field.displayLabel ?? field.label;
52
- return fieldName ? {
53
- key: DYNAMIC_REQUIRED_KEY,
54
- params: { fieldName }
55
- } : { key: DYNAMIC_REQUIRED_KEY };
56
- },
57
- streetLevelRequired: (value) => {
58
- if (value.trim().length > 0) return void 0;
59
- return STREET_LEVEL_REQUIRED_ERROR;
60
- },
61
- cpf: (value) => {
62
- if (value.trim().length === 0) return void 0;
63
- return validateCPF(value) ? void 0 : { key: "verification.errors.invalidTaxId" };
64
- },
65
- ssnFormat: (value) => {
66
- if (value.trim().length === 0) return void 0;
67
- return SSN_FORMAT_REGEX.test(value) ? void 0 : { key: "verification.errors.ssnFormat" };
68
- },
69
- noPoBox: (value) => {
70
- if (value.trim().length === 0) return void 0;
71
- return isPoBox(value) ? { key: "verification.errors.poBox" } : void 0;
72
- },
73
- postalCodeFormat: (value, rule) => {
74
- if (rule.type !== "postalCodeFormat") return void 0;
75
- if (value.trim().length === 0) return void 0;
76
- if (validatePostalCode(value, rule.country)) return void 0;
77
- return {
78
- key: getPostalCodeErrorKey(rule.country),
79
- params: buildPostalCodeParams(rule.country)
80
- };
81
- },
82
- phoneFormat: (value, rule) => {
83
- if (rule.type !== "phoneFormat") return void 0;
84
- const trimmed = value.trim();
85
- if (rule.optional && trimmed.length === 0) return void 0;
86
- return validatePhone(trimmed, rule.country) ? void 0 : { key: "verification.errors.phoneInvalid" };
87
- },
88
- emailFormat: (value) => {
89
- if (value.trim().length === 0) return void 0;
90
- return EMAIL_FORMAT_REGEX.test(value) ? void 0 : { key: "verification.errors.emailInvalid" };
91
- },
92
- exactLength: (value, rule) => {
93
- if (rule.type !== "exactLength") return void 0;
94
- if (value.trim().length === 0) return void 0;
95
- return value.length === rule.length ? void 0 : { key: "verification.errors.exactly10Characters" };
96
- },
97
- oneOfRequired: (_value, rule, _field, values) => {
98
- if (rule.type !== "oneOfRequired") return void 0;
99
- return rule.fields.some((name) => normalizeFieldValue(values[name]).trim().length > 0) ? void 0 : { key: ONE_OF_REQUIRED_ERROR_KEY };
100
- }
101
- });
102
- const evaluateRules = (value, rules, field, values, validators) => {
103
- if (!rules) return void 0;
104
- for (const rule of rules) {
105
- const error = validators[rule.type](value, rule, field, values);
106
- if (error) return error;
107
- }
108
- };
109
- function validateEkycForm(values, fields) {
110
- const validators = createValidators();
111
- return fields.reduce((errors, field) => {
112
- const value = normalizeFieldValue(values[field.name]);
113
- const error = evaluateRules(value, field.validation, field, values, validators);
114
- if (error) errors[field.name] = error;
115
- return errors;
116
- }, {});
117
- }
118
- function validateEkycField(values, fieldName, fields) {
119
- const field = fields.find((f) => f.name === fieldName);
120
- if (!field) return void 0;
121
- const validators = createValidators();
122
- const value = normalizeFieldValue(values[field.name]);
123
- return evaluateRules(value, field.validation, field, values, validators);
124
- }
125
- //#endregion
126
- //#region ../form-definitions/generated/ekyc.ts
127
- const EKYC_DEFINITIONS = {
128
- "ekyc/BR/BR_GOVT_1": {
129
- schemaVersion: 1,
130
- vocabulary: "1.0",
131
- id: "ekyc/BR/BR_GOVT_1",
132
- module: "ekyc",
133
- country: "BR",
134
- source: "BR_GOVT_1",
135
- sections: [{ id: "address" }, { id: "driverLicense" }],
136
- fields: [
137
- {
138
- name: "firstName",
139
- kind: "text",
140
- group: "name",
141
- required: true,
142
- label: { key: "verification.labels.firstName" },
143
- placeholder: { key: "verification.placeholder.firstName" },
144
- input: {
145
- maxLength: 100,
146
- autofill: "givenName"
147
- }
148
- },
149
- {
150
- name: "surName",
151
- kind: "text",
152
- group: "name",
153
- required: true,
154
- label: { key: "verification.labels.surName" },
155
- placeholder: { key: "verification.placeholder.surname" },
156
- input: {
157
- maxLength: 100,
158
- autofill: "familyName"
159
- }
160
- },
161
- {
162
- name: "dateOfBirth",
163
- kind: "date",
164
- group: "dateOfBirth",
165
- required: true,
166
- label: { key: "verification.labels.dateOfBirth" },
167
- input: { autofill: "birthday" }
168
- },
169
- {
170
- name: "email",
171
- kind: "text",
172
- group: "email",
173
- required: true,
174
- label: { key: "verification.labels.email" },
175
- placeholder: { key: "verification.placeholder.email" },
176
- input: {
177
- keyboard: "email",
178
- autofill: "email"
179
- },
180
- rules: [{ id: "emailFormat" }]
181
- },
182
- {
183
- name: "phone",
184
- kind: "phone",
185
- group: "phone",
186
- required: true,
187
- label: { key: "verification.labels.phone" },
188
- input: { autofill: "phone" },
189
- phone: { lockCountry: "whenPhoneRisk" },
190
- rules: [{ id: "phoneFormat" }],
191
- payload: { transforms: [{ id: "e164" }] }
192
- },
193
- {
194
- name: "taxId",
195
- kind: "text",
196
- group: "ssn",
197
- required: true,
198
- label: { key: "verification.labels.taxId" },
199
- displayLabel: {
200
- key: "verification.labels.cpf",
201
- text: "CPF"
202
- },
203
- rules: [{ id: "cpf" }]
204
- },
205
- {
206
- name: "nationality",
207
- kind: "choice",
208
- group: "nationality",
209
- required: true,
210
- widget: "select",
211
- label: { key: "verification.labels.nationality" },
212
- options: [
213
- {
214
- value: "brazilian",
215
- label: { key: "verification.labels.brazilian" }
216
- },
217
- {
218
- value: "naturalizedBrazilian",
219
- label: { key: "verification.labels.naturalizedBrazilian" }
220
- },
221
- {
222
- value: "foreigner",
223
- label: { key: "verification.labels.foreigner" }
224
- },
225
- {
226
- value: "brazilianBornAbroad",
227
- label: { key: "verification.labels.brazilianBornAbroad" }
228
- }
229
- ],
230
- payload: { transforms: [{ id: "uppercase" }] }
231
- },
232
- {
233
- name: "last4SSN",
234
- kind: "text",
235
- group: "last4SSN",
236
- required: true,
237
- label: { key: "verification.labels.last4SSN" },
238
- input: {
239
- maxLength: 4,
240
- keyboard: "numeric"
241
- }
242
- },
243
- {
244
- name: "idNum",
245
- kind: "text",
246
- group: "idNumber",
247
- required: true,
248
- label: { key: "verification.labels.idNum" },
249
- input: { maxLength: 13 }
250
- },
251
- {
252
- name: "idNum1",
253
- kind: "text",
254
- group: "idNumber1",
255
- required: true,
256
- label: { key: "verification.labels.idNum1" }
257
- },
258
- {
259
- name: "gender",
260
- kind: "choice",
261
- group: "gender",
262
- required: true,
263
- widget: "radio",
264
- label: { key: "verification.labels.gender" },
265
- options: [{
266
- value: "F",
267
- label: { key: "common.female" }
268
- }, {
269
- value: "M",
270
- label: { key: "common.male" }
271
- }]
272
- },
273
- {
274
- name: "panNumber",
275
- kind: "text",
276
- group: "panNumber",
277
- required: true,
278
- label: { key: "verification.labels.panNumber" },
279
- input: { maxLength: 10 },
280
- rules: [{
281
- id: "exactLength",
282
- params: { length: 10 }
283
- }]
284
- },
285
- {
286
- name: "houseNo",
287
- kind: "text",
288
- group: "address",
289
- section: "address",
290
- required: true,
291
- label: { key: "verification.labels.houseNo" }
292
- },
293
- {
294
- name: "street",
295
- kind: "text",
296
- group: "address",
297
- section: "address",
298
- required: true,
299
- widget: "addressSearch",
300
- label: { key: "verification.labels.street" },
301
- input: { autofill: "addressLine1" },
302
- rules: [{ id: "noPoBox" }]
303
- },
304
- {
305
- name: "city",
306
- kind: "text",
307
- group: "address",
308
- section: "address",
309
- required: true,
310
- label: { key: "verification.labels.city" },
311
- input: { autofill: "addressLevel2" }
312
- },
313
- {
314
- name: "state",
315
- kind: "text",
316
- group: "address",
317
- section: "address",
318
- required: true,
319
- label: { key: "verification.labels.state" },
320
- placeholder: {
321
- key: "verification.placeholder.stateCode",
322
- params: { states: "RJ, SP" }
323
- },
324
- input: { autofill: "addressLevel1" },
325
- payload: { transforms: [{ id: "uppercase" }] }
326
- },
327
- {
328
- name: "postalCode",
329
- kind: "text",
330
- group: "address",
331
- section: "address",
332
- required: true,
333
- label: { key: "verification.labels.postalCode" },
334
- input: {
335
- maxLength: 9,
336
- autofill: "postalCode"
337
- },
338
- rules: [{ id: "postalCodeFormat" }],
339
- payload: { transforms: [{
340
- id: "stripSeparators",
341
- params: { chars: "- " }
342
- }] }
343
- },
344
- {
345
- name: "dlNumber",
346
- kind: "text",
347
- group: "dlNumber",
348
- section: "driverLicense",
349
- required: true,
350
- label: { key: "verification.labels.dlNumber" }
351
- },
352
- {
353
- name: "dlState",
354
- kind: "choice",
355
- group: "dlState",
356
- section: "driverLicense",
357
- required: true,
358
- widget: "select",
359
- label: { key: "verification.labels.dlState" },
360
- placeholder: { key: "verification.placeholder.state" },
361
- optionsRef: "US_STATES"
362
- },
363
- {
364
- name: "dlExpireAt",
365
- kind: "date",
366
- group: "dlExpireAt",
367
- section: "driverLicense",
368
- required: true,
369
- label: { key: "verification.labels.dlExpireAt" }
370
- }
371
- ],
372
- submit: {
373
- static: { plugins: ["kyc"] },
374
- context: {
375
- source: "source",
376
- countryCode: "country"
377
- }
378
- }
379
- },
380
- "ekyc/US/US_CREDIT_TELCO": {
381
- schemaVersion: 1,
382
- vocabulary: "1.0",
383
- id: "ekyc/US/US_CREDIT_TELCO",
384
- module: "ekyc",
385
- country: "US",
386
- source: "US_CREDIT_TELCO",
387
- sections: [{ id: "address" }, { id: "driverLicense" }],
388
- groups: [{
389
- group: "name",
390
- whenDisabled: "forceShow"
391
- }],
392
- fields: [
393
- {
394
- name: "firstName",
395
- kind: "text",
396
- group: "name",
397
- required: true,
398
- label: { key: "verification.labels.firstName" },
399
- placeholder: { key: "verification.placeholder.firstName" },
400
- input: {
401
- maxLength: 100,
402
- autofill: "givenName"
403
- }
404
- },
405
- {
406
- name: "surName",
407
- kind: "text",
408
- group: "name",
409
- required: true,
410
- label: { key: "verification.labels.lastName" },
411
- placeholder: { key: "verification.placeholder.lastName" },
412
- input: {
413
- maxLength: 100,
414
- autofill: "familyName"
415
- }
416
- },
417
- {
418
- name: "dateOfBirth",
419
- kind: "date",
420
- group: "dateOfBirth",
421
- label: { key: "verification.labels.dateOfBirth" },
422
- input: { autofill: "birthday" }
423
- },
424
- {
425
- name: "email",
426
- kind: "text",
427
- group: "email",
428
- required: true,
429
- label: { key: "verification.labels.email" },
430
- placeholder: { key: "verification.placeholder.email" },
431
- input: {
432
- keyboard: "email",
433
- autofill: "email"
434
- },
435
- rules: [{ id: "emailFormat" }]
436
- },
437
- {
438
- name: "phone",
439
- kind: "phone",
440
- group: "phone",
441
- label: { key: "verification.labels.phone" },
442
- input: { autofill: "phone" },
443
- phone: { lockCountry: true },
444
- rules: [{ id: "phoneFormat" }],
445
- payload: { transforms: [{ id: "e164" }] }
446
- },
447
- {
448
- name: "ssn",
449
- kind: "text",
450
- group: "ssn",
451
- widget: "masked",
452
- label: { key: "verification.labels.ssn" },
453
- input: {
454
- maxLength: 11,
455
- keyboard: "numeric"
456
- },
457
- rules: [{ id: "ssnFormat" }],
458
- payload: { transforms: [{
459
- id: "stripSeparators",
460
- params: { chars: "-" }
461
- }] }
462
- },
463
- {
464
- name: "nationality",
465
- kind: "text",
466
- group: "nationality",
467
- required: true,
468
- label: { key: "verification.labels.nationality" },
469
- payload: { transforms: [{ id: "uppercase" }] }
470
- },
471
- {
472
- name: "last4SSN",
473
- kind: "text",
474
- group: "last4SSN",
475
- required: true,
476
- label: { key: "verification.labels.last4SSN" },
477
- input: {
478
- maxLength: 4,
479
- keyboard: "numeric"
480
- }
481
- },
482
- {
483
- name: "idNum",
484
- kind: "text",
485
- group: "idNumber",
486
- required: true,
487
- label: { key: "verification.labels.idNum" },
488
- input: { maxLength: 13 }
489
- },
490
- {
491
- name: "idNum1",
492
- kind: "text",
493
- group: "idNumber1",
494
- required: true,
495
- label: { key: "verification.labels.idNum1" }
496
- },
497
- {
498
- name: "gender",
499
- kind: "choice",
500
- group: "gender",
501
- required: true,
502
- widget: "radio",
503
- label: { key: "verification.labels.gender" },
504
- options: [{
505
- value: "F",
506
- label: { key: "common.female" }
507
- }, {
508
- value: "M",
509
- label: { key: "common.male" }
510
- }]
511
- },
512
- {
513
- name: "panNumber",
514
- kind: "text",
515
- group: "panNumber",
516
- required: true,
517
- label: { key: "verification.labels.panNumber" },
518
- input: { maxLength: 10 },
519
- rules: [{
520
- id: "exactLength",
521
- params: { length: 10 }
522
- }]
523
- },
524
- {
525
- name: "street",
526
- kind: "text",
527
- group: "address",
528
- section: "address",
529
- widget: "addressSearch",
530
- label: { key: "verification.labels.street" },
531
- input: { autofill: "addressLine1" },
532
- rules: [{ id: "noPoBox" }]
533
- },
534
- {
535
- name: "apartment",
536
- kind: "text",
537
- group: "address",
538
- section: "address",
539
- label: { key: "verification.labels.apartment" },
540
- placeholder: { key: "verification.placeholder.apartment" },
541
- input: { autofill: "addressLine2" }
542
- },
543
- {
544
- name: "city",
545
- kind: "text",
546
- group: "address",
547
- section: "address",
548
- label: { key: "verification.labels.city" },
549
- input: { autofill: "addressLevel2" }
550
- },
551
- {
552
- name: "state",
553
- kind: "choice",
554
- group: "address",
555
- section: "address",
556
- widget: "select",
557
- label: { key: "verification.labels.chooseState" },
558
- placeholder: { key: "verification.placeholder.state" },
559
- input: { autofill: "addressLevel1" },
560
- optionsRef: "US_STATES",
561
- payload: { transforms: [{ id: "uppercase" }] }
562
- },
563
- {
564
- name: "postalCode",
565
- kind: "text",
566
- group: "address",
567
- section: "address",
568
- label: { key: "verification.labels.zipCode" },
569
- input: {
570
- maxLength: 10,
571
- autofill: "postalCode"
572
- },
573
- rules: [{ id: "postalCodeFormat" }],
574
- payload: { transforms: [{
575
- id: "stripSeparators",
576
- params: { chars: "- " }
577
- }] }
578
- },
579
- {
580
- name: "dlNumber",
581
- kind: "text",
582
- group: "dlNumber",
583
- section: "driverLicense",
584
- required: true,
585
- label: { key: "verification.labels.dlNumber" }
586
- },
587
- {
588
- name: "dlState",
589
- kind: "choice",
590
- group: "dlState",
591
- section: "driverLicense",
592
- required: true,
593
- widget: "select",
594
- label: { key: "verification.labels.dlState" },
595
- placeholder: { key: "verification.placeholder.state" },
596
- optionsRef: "US_STATES"
597
- },
598
- {
599
- name: "dlExpireAt",
600
- kind: "date",
601
- group: "dlExpireAt",
602
- section: "driverLicense",
603
- required: true,
604
- label: { key: "verification.labels.dlExpireAt" }
605
- }
606
- ],
607
- groupRules: [{
608
- id: "oneOfRequired",
609
- fields: ["dateOfBirth", "ssn"],
610
- message: { key: "verification.errors.dobOrSsnRequired" }
611
- }],
612
- submit: {
613
- static: { plugins: ["kyc"] },
614
- context: {
615
- source: "source",
616
- countryCode: "country"
617
- }
618
- }
619
- }
620
- };
621
- //#endregion
622
- //#region src/modules/ekyc/ekycForm.ts
623
- /**
624
- * eKYC adapter for form definitions.
625
- *
626
- * Selects the bundled definition for a source and country, resolves it against
627
- * the verification fields from module configuration, and projects the result
628
- * to today's public `EkycFieldDef[]` shape, including the `validation` arrays
629
- * today's validators run. A pair without a definition this projection can
630
- * express keeps the current builder.
631
- */
632
- /** eKYC group id → the key `getEKYCFields` sets in `EkycVerificationFields`. */
633
- const EKYC_GROUP_KEYS = {
634
- name: "name",
635
- dateOfBirth: "date of birth",
636
- email: "email",
637
- phone: "phone",
638
- address: "address",
639
- ssn: "SSN",
640
- last4SSN: "last4SSN",
641
- idNumber: "idNum",
642
- idNumber1: "idNum1",
643
- nationality: "nationality",
644
- gender: "gender",
645
- panNumber: "panNumber",
646
- dlNumber: "dlNumber",
647
- dlState: "dlState",
648
- dlExpireAt: "dlExpireAt"
649
- };
650
- const OPTION_LISTS = { US_STATES: usStateOptions };
651
- /** Vocabulary rules expressed as today's `EkycValidationRule` objects. */
652
- const RULES = {
653
- cpf: () => ({ type: "cpf" }),
654
- ssnFormat: () => ({ type: "ssnFormat" }),
655
- noPoBox: () => ({ type: "noPoBox" }),
656
- emailFormat: () => ({ type: "emailFormat" }),
657
- postalCodeFormat: ({ country }) => ({
658
- type: "postalCodeFormat",
659
- country
660
- }),
661
- phoneFormat: ({ country, required }) => ({
662
- type: "phoneFormat",
663
- country,
664
- optional: !required
665
- }),
666
- exactLength: ({ params }) => ({
667
- type: "exactLength",
668
- length: params.length
669
- })
670
- };
671
- /**
672
- * Params a projected rule reads. The compiler checks params against the
673
- * vocabulary too; this keeps a definition that skipped it, such as a served
674
- * one later, from projecting a broken rule.
675
- */
676
- const RULE_PARAMS = { exactLength: ({ length }) => typeof length === "number" && Number.isInteger(length) && length > 0 };
677
- /**
678
- * What the projection can express today. Request-body transforms are listed
679
- * because `buildSubmitPayload` already applies them, on the fields
680
- * `legacyPayloadTransforms` names; `requiredWhen` waits for decision B20, so
681
- * no condition is supported yet.
682
- */
683
- const EKYC_SUPPORTED_IDS = {
684
- schemaVersions: [1],
685
- vocabulary: "1.0",
686
- kinds: /* @__PURE__ */ new Set([
687
- "text",
688
- "date",
689
- "choice",
690
- "phone"
691
- ]),
692
- groups: new Set(Object.keys(EKYC_GROUP_KEYS)),
693
- rules: new Set(Object.keys(RULES)),
694
- transforms: /* @__PURE__ */ new Set([
695
- "stripSeparators",
696
- "e164",
697
- "uppercase"
698
- ]),
699
- groupRules: /* @__PURE__ */ new Set(["oneOfRequired"]),
700
- optionLists: new Set(Object.keys(OPTION_LISTS)),
701
- conditions: /* @__PURE__ */ new Set()
702
- };
703
- /** Today's field shape only flags `middleName` as optional. */
704
- const LEGACY_OPTIONAL_FLAG = /* @__PURE__ */ new Set(["middleName"]);
705
- /** The sections the eKYC UI has headers for. */
706
- const UI_SECTIONS = /* @__PURE__ */ new Set(["address", "driverLicense"]);
707
- /** The fields today's DOB-or-SSN group rule and its message are for. */
708
- const ONE_OF_REQUIRED_FIELDS = ["dateOfBirth", "ssn"];
709
- /** A Text today's field shape can carry: a key only, or `text` where shown. */
710
- const plainKey = (text) => !text?.params;
711
- /**
712
- * The request-body transforms `buildSubmitPayload` applies to a field. It
713
- * reads values by field name and transforms them in fixed branches, not from
714
- * the definition, so until the kernel builds request bodies (P2) a definition
715
- * must declare exactly these. Otherwise a transform it declares on another
716
- * field would pass `checkSupport` and then not be applied. Mirrors those
717
- * branches by hand: change both together.
718
- */
719
- function legacyPayloadTransforms(name, country) {
720
- switch (name) {
721
- case "phone": return [{ id: "e164" }];
722
- case "nationality":
723
- case "state": return [{ id: "uppercase" }];
724
- case "postalCode": return [{
725
- id: "stripSeparators",
726
- params: { chars: "- " }
727
- }];
728
- case "ssn": return country === "US" || country === "CA" ? [{
729
- id: "stripSeparators",
730
- params: { chars: "-" }
731
- }] : [];
732
- default: return [];
733
- }
734
- }
735
- function sameTransforms(declared, expected) {
736
- return declared.length === expected.length && declared.every((transform, i) => {
737
- const params = transform.params ?? {};
738
- const want = expected[i].params ?? {};
739
- return transform.id === expected[i].id && Object.keys(params).length === Object.keys(want).length && Object.entries(want).every(([key, value]) => params[key] === value);
740
- });
741
- }
742
- /**
743
- * Whether today's code handles a field the way its definition says. Today's
744
- * validators show their own message, so a rule can't carry one. The field
745
- * shape has no hint or suggestions, and only placeholders take params. Input
746
- * formatting (`processFieldValue`) and the request body (`buildSubmitPayload`)
747
- * stay keyed by field name until P2.
748
- */
749
- function isProjectableField(field, country) {
750
- return !field.hint && !field.suggestionsRef && plainKey(field.label) && plainKey(field.displayLabel) && (field.options ?? []).every((option) => plainKey(option.label)) && (!field.section || UI_SECTIONS.has(field.section)) && (field.rules ?? []).every((rule) => !rule.message && (RULE_PARAMS[rule.id]?.(rule.params ?? {}) ?? true)) && !field.input?.format?.length && (field.payload?.key ?? field.name) === field.name && !field.payload?.omit && sameTransforms(field.payload?.transforms ?? [], legacyPayloadTransforms(field.name, country));
751
- }
752
- /**
753
- * Caches the check per definition object. Bundled definitions are singletons
754
- * created once at module load, so each is checked once. A served source (P4)
755
- * that builds new objects per call would still be correct, but would miss
756
- * this cache; key it by definition id and version then.
757
- */
758
- const projectable = /* @__PURE__ */ new WeakMap();
759
- /** Whether every part of a definition maps onto today's `EkycFieldDef`. */
760
- function isProjectableEkycDefinition(definition) {
761
- let result = projectable.get(definition);
762
- if (result === void 0) {
763
- result = definition.module === "ekyc" && checkSupport(definition, EKYC_SUPPORTED_IDS).supported && definition.fields.every((field) => isProjectableField(field, definition.country ?? "")) && (definition.sections ?? []).every((section) => !section.title && UI_SECTIONS.has(section.id)) && (definition.groupRules ?? []).every((rule) => rule.fields.length === ONE_OF_REQUIRED_FIELDS.length && ONE_OF_REQUIRED_FIELDS.every((name) => rule.fields.includes(name)) && (!rule.message || rule.message.key === "verification.errors.dobOrSsnRequired" && !rule.message.params));
764
- projectable.set(definition, result);
765
- }
766
- return result;
767
- }
768
- const bundled = createBundledDefinitionSource(EKYC_DEFINITIONS);
769
- /** The bundled definition for exactly this source and country, if it is projectable. */
770
- function selectEkycDefinition(source, country) {
771
- const definition = bundled.select({
772
- module: "ekyc",
773
- source,
774
- country
775
- });
776
- return definition && isProjectableEkycDefinition(definition) ? definition : void 0;
777
- }
778
- function toEkycResolveContext(verificationFields, enablePhoneRisk) {
779
- return {
780
- groups: Object.fromEntries(Object.entries(EKYC_GROUP_KEYS).map(([group, key]) => [group, Boolean(verificationFields[key])])),
781
- phoneRisk: enablePhoneRisk
782
- };
783
- }
784
- function fieldType(field) {
785
- if (field.kind === "choice") return field.widget === "radio" ? "radio" : "dropdown";
786
- return field.kind === "date" || field.kind === "phone" ? field.kind : "text";
787
- }
788
- function fieldOptions(field) {
789
- if (field.optionsRef) return OPTION_LISTS[field.optionsRef];
790
- return field.options?.map((option) => ({
791
- value: option.value,
792
- label: option.label.key
793
- }));
794
- }
795
- function projectField(resolved, verificationFields, country) {
796
- const { field, required } = resolved;
797
- const groupKey = EKYC_GROUP_KEYS[field.group];
798
- const source = groupKey && verificationFields[groupKey] || "user_input";
799
- const def = {
800
- name: field.name,
801
- type: fieldType(field),
802
- label: field.label.key,
803
- source,
804
- required
805
- };
806
- if (field.placeholder) {
807
- def.placeholder = field.placeholder.key;
808
- if (field.placeholder.params) def.placeholderParams = { ...field.placeholder.params };
809
- }
810
- if (field.displayLabel) def.displayLabel = field.displayLabel.text ?? field.displayLabel.key;
811
- if (field.input?.maxLength !== void 0) def.maxLength = field.input.maxLength;
812
- const options = fieldOptions(field);
813
- if (options) def.options = options;
814
- if (field.section) def.section = field.section;
815
- if (field.kind === "phone") def.disableCountrySelector = resolved.phoneLocked;
816
- if (LEGACY_OPTIONAL_FLAG.has(field.name)) def.optional = true;
817
- const validation = required ? [{ type: "required" }] : [];
818
- for (const rule of field.rules ?? []) {
819
- const project = RULES[rule.id];
820
- if (project) validation.push(project({
821
- country,
822
- required,
823
- params: rule.params ?? {}
824
- }));
825
- }
826
- if (validation.length > 0) def.validation = validation;
827
- return def;
828
- }
829
- /**
830
- * Projects a resolved definition to today's `EkycFieldDef[]`, identical to
831
- * what `legacyBuildFieldDefs` returns for the same source and country.
832
- */
833
- function projectEkycFields(form, verificationFields, country) {
834
- const defs = form.fields.map((resolved) => projectField(resolved, verificationFields, country));
835
- for (const { fields } of form.groupRules) for (const def of defs) if (fields.includes(def.name)) def.validation = [{
836
- type: "oneOfRequired",
837
- fields: [...fields]
838
- }, ...def.validation ?? []];
839
- return defs;
840
- }
841
- //#endregion
842
- //#region src/modules/ekyc/ekycActions.ts
843
- const dateFormattingInstance = new DateFormattingProvider();
844
- function buildValidationRules(field, country, configSource) {
845
- const rules = [];
846
- if (field.required) rules.push({ type: "required" });
847
- if (field.name === "taxId" && country === "BR") rules.push({ type: "cpf" });
848
- if (field.name === "ssn" && (country === "US" || country === "CA")) rules.push({ type: "ssnFormat" });
849
- if (field.name === "street") rules.push({ type: "noPoBox" });
850
- if (field.name === "postalCode") rules.push({
851
- type: "postalCodeFormat",
852
- country
853
- });
854
- if (field.name === "phone") rules.push({
855
- type: "phoneFormat",
856
- country,
857
- optional: isFieldOptional("phone", configSource)
858
- });
859
- if (field.name === "email") rules.push({ type: "emailFormat" });
860
- if (field.name === "panNumber") rules.push({
861
- type: "exactLength",
862
- length: 10
863
- });
864
- return rules;
865
- }
866
- function applyOneOfRequiredGroups(defs, configSource) {
867
- for (const group of ONE_OF_REQUIRED_GROUPS[configSource] ?? []) {
868
- const members = defs.filter((def) => group.includes(def.name));
869
- const fields = members.map((def) => def.name);
870
- for (const def of members) def.validation = [{
871
- type: "oneOfRequired",
872
- fields
873
- }, ...def.validation ?? []];
874
- }
875
- }
876
- /**
877
- * Builds the form's field defs. A source with a form definition for exactly
878
- * this country reads it (`packages/form-definitions/catalog/ekyc`); any other
879
- * pair keeps the current builder.
880
- */
881
- function buildFieldDefs(fields, configSource, country, enablePhoneRisk = false) {
882
- const definition = selectEkycDefinition(configSource, country);
883
- if (definition) return projectEkycFields(resolveForm(definition, toEkycResolveContext(fields, enablePhoneRisk)), fields, country);
884
- return legacyBuildFieldDefs(fields, configSource, country, enablePhoneRisk);
885
- }
886
- /** The per-source builder for sources without a form definition yet. */
887
- function legacyBuildFieldDefs(fields, configSource, country, enablePhoneRisk = false) {
888
- const defs = [];
889
- const add = (name, type, label, source, opts) => {
890
- if (source === false) return;
891
- const def = {
892
- name,
893
- type,
894
- label,
895
- source,
896
- required: !isFieldOptional(name, configSource),
897
- ...opts
898
- };
899
- const validation = buildValidationRules(def, country, configSource);
900
- if (validation.length > 0) def.validation = validation;
901
- defs.push(def);
902
- };
903
- const nameSource = fields.name || (NAME_SOURCES.includes(configSource) ? "user_input" : false);
904
- if (nameSource) {
905
- add("firstName", "text", "verification.labels.firstName", nameSource, {
906
- maxLength: 100,
907
- placeholder: "verification.placeholder.firstName"
908
- });
909
- if (MIDDLE_NAME_SOURCES.includes(configSource)) add("middleName", "text", "verification.labels.middleName", nameSource, {
910
- maxLength: 100,
911
- placeholder: "verification.placeholder.middleName",
912
- optional: true
913
- });
914
- add("surName", "text", country === "US" ? "verification.labels.lastName" : "verification.labels.surName", nameSource, {
915
- maxLength: 100,
916
- placeholder: country === "US" ? "verification.placeholder.lastName" : "verification.placeholder.surname"
917
- });
918
- if (country === "MX") add("maternalSurname", "text", "verification.labels.maternalSurname", nameSource, {
919
- maxLength: 100,
920
- placeholder: "verification.placeholder.maternalSurname"
921
- });
922
- }
923
- if (fields["date of birth"]) add("dateOfBirth", "date", "verification.labels.dateOfBirth", fields["date of birth"]);
924
- const emailSource = fields.email || (EMAIL_SOURCES.includes(configSource) ? "user_input" : false);
925
- if (emailSource) add("email", "text", "verification.labels.email", emailSource, { placeholder: "verification.placeholder.email" });
926
- if (fields.phone) {
927
- const phoneCountrySelectorDisabled = enablePhoneRisk && configSource !== "PHONE_RISK_1" || COUNTRY_SELECTOR_DISABLED_SOURCES.includes(configSource);
928
- add("phone", "phone", "verification.labels.phone", fields.phone, { disableCountrySelector: phoneCountrySelectorDisabled });
929
- }
930
- if (fields.SSN) if (country === "BR" || TAX_ID_SOURCES.includes(configSource)) add("taxId", "text", "verification.labels.taxId", fields.SSN, { ...country === "BR" && { displayLabel: "CPF" } });
931
- else if (country === "CN") add("ssn", "text", "verification.labels.prcId", fields.SSN);
932
- else add("ssn", "text", "verification.labels.ssn", fields.SSN, { maxLength: 11 });
933
- if (fields.nationality) if (country === "BR") add("nationality", "dropdown", "verification.labels.nationality", fields.nationality, { options: [
934
- {
935
- value: "brazilian",
936
- label: "verification.labels.brazilian"
937
- },
938
- {
939
- value: "naturalizedBrazilian",
940
- label: "verification.labels.naturalizedBrazilian"
941
- },
942
- {
943
- value: "foreigner",
944
- label: "verification.labels.foreigner"
945
- },
946
- {
947
- value: "brazilianBornAbroad",
948
- label: "verification.labels.brazilianBornAbroad"
949
- }
950
- ] });
951
- else add("nationality", "text", "verification.labels.nationality", fields.nationality);
952
- if (fields.last4SSN) add("last4SSN", "text", "verification.labels.last4SSN", fields.last4SSN, { maxLength: 4 });
953
- if (fields.idNum) add("idNum", "text", "verification.labels.idNum", fields.idNum, { maxLength: 13 });
954
- if (fields.idNum1) add("idNum1", "text", "verification.labels.idNum1", fields.idNum1);
955
- if (fields.gender) add("gender", "radio", "verification.labels.gender", fields.gender, { options: [{
956
- value: "F",
957
- label: "common.female"
958
- }, {
959
- value: "M",
960
- label: "common.male"
961
- }] });
962
- if (fields.panNumber) add("panNumber", "text", "verification.labels.panNumber", fields.panNumber, { maxLength: 10 });
963
- const addAddressFields = () => {
964
- const addrSource = fields.address;
965
- if (!addrSource) return;
966
- if (HOUSE_NO_SOURCES.includes(configSource)) add("houseNo", "text", "verification.labels.houseNo", addrSource, { section: "address" });
967
- if (STREET_SOURCES.includes(configSource)) add("street", "text", "verification.labels.street", addrSource, { section: "address" });
968
- if (APARTMENT_SOURCES.includes(configSource)) add("apartment", "text", "verification.labels.apartment", addrSource, {
969
- section: "address",
970
- placeholder: "verification.placeholder.apartment"
971
- });
972
- if (CITY_SOURCES.includes(configSource)) add("city", "text", "verification.labels.city", addrSource, { section: "address" });
973
- if (ADDRESS_STATE_SOURCES.includes(configSource)) add("state", country === "US" ? "dropdown" : "text", country === "US" ? "verification.labels.chooseState" : "verification.labels.state", addrSource, {
974
- section: "address",
975
- ...country === "US" ? {
976
- options: usStateOptions,
977
- placeholder: "verification.placeholder.state"
978
- } : {
979
- placeholder: "verification.placeholder.stateCode",
980
- placeholderParams: { states: STATE_CODE_HINTS[country] ?? "" }
981
- }
982
- });
983
- if (POSTAL_CODE_SOURCES.includes(configSource)) add("postalCode", "text", country === "US" ? "verification.labels.zipCode" : "verification.labels.postalCode", addrSource, {
984
- section: "address",
985
- maxLength: getPostalCodeMaxLength(country)
986
- });
987
- };
988
- const addDriversLicenseFields = () => {
989
- if (fields.dlNumber) add("dlNumber", "text", "verification.labels.dlNumber", fields.dlNumber, { section: "driverLicense" });
990
- if (fields.dlState) add("dlState", "dropdown", "verification.labels.dlState", fields.dlState, {
991
- section: "driverLicense",
992
- options: usStateOptions,
993
- placeholder: "verification.placeholder.state"
994
- });
995
- if (fields.dlExpireAt) add("dlExpireAt", "date", "verification.labels.dlExpireAt", fields.dlExpireAt, { section: "driverLicense" });
996
- };
997
- if (configSource === "US_TELCO_1") {
998
- addDriversLicenseFields();
999
- addAddressFields();
1000
- } else {
1001
- addAddressFields();
1002
- addDriversLicenseFields();
1003
- }
1004
- applyOneOfRequiredGroups(defs, configSource);
1005
- return defs;
1006
- }
1007
- function applyPrefill(fields, ocrData, otpStatus, _country) {
1008
- const values = {};
1009
- const prefilled = {};
1010
- const readonlyFields = [];
1011
- let hideEmail = false;
1012
- if (fields.name === "document_scan" && ocrData?.name) {
1013
- if (ocrData.name.firstName) {
1014
- values.firstName = ocrData.name.firstName;
1015
- prefilled.firstName = true;
1016
- }
1017
- if (ocrData.name.paternalLastName) {
1018
- values.surName = ocrData.name.paternalLastName;
1019
- prefilled.surName = true;
1020
- }
1021
- if (ocrData.name.middleName) {
1022
- values.middleName = ocrData.name.middleName;
1023
- prefilled.middleName = true;
1024
- }
1025
- if (ocrData.name.maternalLastName) {
1026
- values.maternalSurname = ocrData.name.maternalLastName;
1027
- prefilled.maternalSurname = true;
1028
- }
1029
- }
1030
- const ocrBirthDate = dateFormattingInstance.utcToIsoDateString(ocrData?.birthDate);
1031
- if (fields["date of birth"] === "document_scan" && ocrBirthDate) {
1032
- values.dateOfBirth = ocrBirthDate;
1033
- prefilled.dateOfBirth = true;
1034
- }
1035
- const addressSource = fields.address;
1036
- if (addressSource === "document_scan" || addressSource === "poa_document") {
1037
- const addrData = addressSource === "poa_document" ? ocrData?.addressFieldsFromStatement ?? void 0 : ocrData?.addressFields ?? ocrData?.checkedAddressBean ?? void 0;
1038
- if (addrData) {
1039
- if (addrData.street) {
1040
- values.street = addrData.street;
1041
- prefilled.street = true;
1042
- }
1043
- if (addrData.city) {
1044
- values.city = addrData.city;
1045
- prefilled.city = true;
1046
- }
1047
- if (addrData.state) {
1048
- values.state = addrData.state;
1049
- prefilled.state = true;
1050
- }
1051
- if (addrData.postalCode) {
1052
- values.postalCode = addrData.postalCode;
1053
- prefilled.postalCode = true;
1054
- }
1055
- if (addrData.houseNumber) {
1056
- values.houseNo = addrData.houseNumber;
1057
- prefilled.houseNo = true;
1058
- }
1059
- }
1060
- }
1061
- if (fields.phone === "phone_module_input" && otpStatus?.phone) {
1062
- values.phone = otpStatus.phone;
1063
- prefilled.phone = true;
1064
- readonlyFields.push("phone");
1065
- }
1066
- if (fields.email === "email_module_input" && otpStatus?.email) {
1067
- values.email = otpStatus.email;
1068
- prefilled.email = true;
1069
- hideEmail = true;
1070
- }
1071
- return {
1072
- values,
1073
- prefilled,
1074
- hideEmail,
1075
- readonlyFields
1076
- };
1077
- }
1078
- /**
1079
- * Builds the request body. Keep the per-field transforms below in sync with
1080
- * `legacyPayloadTransforms` in `ekycForm.ts`: definitions are projectable only
1081
- * when they declare exactly these, until P2 builds request bodies from them.
1082
- */
1083
- function buildSubmitPayload(ctx) {
1084
- const payload = {};
1085
- for (const field of ctx.fields) {
1086
- const val = ctx.values[field.name];
1087
- if (val !== void 0 && val !== "") payload[field.name] = val;
1088
- }
1089
- if (payload.nationality) payload.nationality = payload.nationality.toUpperCase();
1090
- if (ctx.fieldsCountry && !COUNTRY_CODE_OMITTED_SOURCES.includes(ctx.configSource)) payload.countryCode = ctx.fieldsCountry;
1091
- if (ctx.hideEmail && ctx.values.email) payload.email = ctx.values.email;
1092
- if (payload.ssn && (ctx.fieldsCountry === "US" || ctx.fieldsCountry === "CA")) payload.ssn = payload.ssn.replace(/-/g, "");
1093
- if (payload.postalCode) payload.postalCode = payload.postalCode.replace(/[-\s]/g, "");
1094
- if (payload.phone) payload.phone = formatPhoneE164(payload.phone, ctx.fieldsCountry);
1095
- if (payload.state) payload.state = payload.state.toUpperCase();
1096
- if (ctx.configSource === "UK_CREDIT_BUREAU_1" && payload.countryCode) payload.country = payload.countryCode;
1097
- if (ctx.configSource === "US_DRIVERS_LICENSE_1" && payload.dlState) payload.state = payload.dlState;
1098
- return {
1099
- ...payload,
1100
- plugins: ["kyc"],
1101
- source: ctx.configSource
1102
- };
1103
- }
1104
- function processFieldValue(name, value, fieldsCountry) {
1105
- if ((name === "firstName" || name === "surName" || name === "middleName" || name === "maternalSurname") && value) return cleanName(value);
1106
- if (name === "ssn" && (fieldsCountry === "US" || fieldsCountry === "CA")) return formatSSN(value);
1107
- if (name === "postalCode") return formatPostalCode(value, fieldsCountry);
1108
- if (name === "panNumber") return value.replace(/[^a-zA-Z0-9]/g, "").toUpperCase();
1109
- return value;
1110
- }
1111
- //#endregion
1112
- //#region src/modules/ekyc/ekycServices.ts
1113
- /** Fetches module configuration for EXTERNAL_VERIFICATION */
1114
- async function fetchModuleConfig(flowId, signal) {
1115
- const url = `${endpoints.moduleConfig}?id=${encodeURIComponent(flowId)}&moduleKey=EXTERNAL_VERIFICATION`;
1116
- const res = await api.get(url, { signal });
1117
- if (!res.ok) throw new Error(`GET ${url} failed: ${res.status} ${res.statusText}`);
1118
- return res.data;
1119
- }
1120
- /** Fetches OCR data for pre-fill */
1121
- async function fetchOcrData(signal) {
1122
- const res = await api.get(endpoints.ocrData, { signal });
1123
- if (!res.ok) throw new Error(`GET ${endpoints.ocrData} failed: ${res.status} ${res.statusText}`);
1124
- return res.data;
1125
- }
1126
- /** Fetches phone/email from prior OTP modules */
1127
- async function fetchOtpStatus(signal) {
1128
- const res = await api.get(endpoints.otpStatus, { signal });
1129
- if (!res.ok) throw new Error(`GET ${endpoints.otpStatus} failed: ${res.status} ${res.statusText}`);
1130
- return res.data;
1131
- }
1132
- var EkycSubmitError = class extends Error {
1133
- constructor(status, apiError) {
1134
- super(`POST ${endpoints.ekycSubmit} failed: ${status} – ${apiError}`);
1135
- this.name = "EkycSubmitError";
1136
- this.status = status;
1137
- this.apiError = apiError;
1138
- }
1139
- };
1140
- /** Submits eKYC verification */
1141
- async function submitEkyc(data, signal) {
1142
- try {
1143
- return (await api.post(endpoints.ekycSubmit, data, { signal })).data;
1144
- } catch (err) {
1145
- const httpErr = err;
1146
- if (typeof httpErr.status === "number") {
1147
- const body = httpErr.data;
1148
- const apiError = body?.error ?? body?.message ?? String(err);
1149
- throw new EkycSubmitError(httpErr.status, apiError);
1150
- }
1151
- throw err;
1152
- }
1153
- }
1154
- //#endregion
1155
- //#region src/modules/ekyc/ekycGuards.ts
1156
- const hasNoValidationErrorsGuard = ({ context }) => Object.keys(context.validationErrors ?? {}).length === 0;
1157
- const hasFlowIdGuard = ({ context }) => !!context.config.flowId;
1158
- const hasVerificationFieldsGuard = ({ context }) => !!context.config.verificationFields;
1159
- const COUNTRY_NOT_SUPPORTED_MSG = "Request unsuccessful. Country not supported for EKYC.";
1160
- const isCountryNotSupportedGuard = ({ event }) => {
1161
- const err = event.error;
1162
- return err instanceof EkycSubmitError && err.status === 400 && err.apiError === COUNTRY_NOT_SUPPORTED_MSG;
1163
- };
1164
- //#endregion
1165
- //#region src/modules/ekyc/ekycActors.ts
1166
- const fetchModuleConfigActor = fromPromise(async ({ input, signal }) => {
1167
- const phoneRules = loadPhoneValidator();
1168
- phoneRules.catch(() => void 0);
1169
- const config = await fetchModuleConfig(input.flowId, signal);
1170
- if (getEKYCFields(config).phone !== false) await phoneRules;
1171
- return config;
1172
- });
1173
- const fetchPrefillDataActor = fromPromise(async ({ signal }) => {
1174
- const [ocrData, otpStatus] = await Promise.all([fetchOcrData(signal).catch(() => void 0), fetchOtpStatus(signal).catch(() => void 0)]);
1175
- return {
1176
- ocrData,
1177
- otpStatus
1178
- };
1179
- });
1180
- const submitEkycActor = fromPromise(async ({ input, signal }) => submitEkyc(input, signal));
1181
- //#endregion
1182
- //#region src/modules/ekyc/ekycStateMachine.ts
1183
- const ADDRESS_AUTOCOMPLETE_KEYS = [
1184
- "street",
1185
- "city",
1186
- "state",
1187
- "postalCode",
1188
- "houseNo"
1189
- ];
1190
- const omitKeys = (errors, keys) => {
1191
- if (!errors) return void 0;
1192
- const next = { ...errors };
1193
- for (const key of keys) delete next[key];
1194
- return Object.keys(next).length > 0 ? next : void 0;
1195
- };
1196
- const ekycMachine = setup({
1197
- types: {
1198
- context: {},
1199
- events: {},
1200
- input: {}
1201
- },
1202
- actors: {
1203
- fetchModuleConfig: fetchModuleConfigActor,
1204
- fetchPrefillData: fetchPrefillDataActor,
1205
- submitEkyc: submitEkycActor,
1206
- debounceSearch: debounceSearchActor
1207
- },
1208
- actions: {
1209
- setModuleConfig: assign(({ context, event }) => {
1210
- const config = event.output;
1211
- const source = resolveEkycSource(config.source ?? context.config.source ?? "", config.riskAddons);
1212
- const country = context.config.fieldsCountry ?? getEKYCCountry(source);
1213
- const vFields = getEKYCFields(config);
1214
- return {
1215
- moduleConfig: config,
1216
- verificationFields: vFields,
1217
- configSource: source,
1218
- fieldsCountry: country,
1219
- fields: buildFieldDefs(vFields, source, country, config.enablePhoneRisk)
1220
- };
1221
- }),
1222
- applyPrefillData: assign(({ context, event }) => {
1223
- const { ocrData, otpStatus } = event.output;
1224
- const { values, prefilled, hideEmail, readonlyFields } = applyPrefill(context.verificationFields, ocrData, otpStatus, context.fieldsCountry);
1225
- return {
1226
- values,
1227
- prefilled,
1228
- hideEmail,
1229
- fields: context.fields.map((f) => ({
1230
- ...f,
1231
- readonly: readonlyFields.includes(f.name) ? true : f.readonly
1232
- }))
1233
- };
1234
- }),
1235
- updateField: assign(({ context, event }) => {
1236
- if (event.type !== "DATA_CHANGED") return {};
1237
- const processedValue = processFieldValue(event.name, event.value, context.fieldsCountry);
1238
- return {
1239
- values: {
1240
- ...context.values,
1241
- [event.name]: processedValue
1242
- },
1243
- submitError: ""
1244
- };
1245
- }),
1246
- clearFieldValidationError: assign(({ context, event }) => {
1247
- if (event.type !== "DATA_CHANGED") return {};
1248
- const errs = context.validationErrors;
1249
- if (!errs) return {};
1250
- const next = { ...errs };
1251
- delete next[event.name];
1252
- const oneOfRule = context.fields.find((f) => f.name === event.name)?.validation?.find((rule) => rule.type === "oneOfRequired");
1253
- if (oneOfRule?.type === "oneOfRequired") {
1254
- for (const sibling of oneOfRule.fields) if (next[sibling]?.key === "verification.errors.dobOrSsnRequired") delete next[sibling];
1255
- }
1256
- if (Object.keys(next).length === Object.keys(errs).length) return {};
1257
- return { validationErrors: Object.keys(next).length > 0 ? next : void 0 };
1258
- }),
1259
- validateFormField: assign(({ context, event }) => {
1260
- if (event.type !== "VALIDATE_FIELD") return {};
1261
- const message = validateEkycField(context.values, event.name, context.fields);
1262
- const next = { ...context.validationErrors ?? {} };
1263
- if (message) next[event.name] = message;
1264
- else delete next[event.name];
1265
- return { validationErrors: Object.keys(next).length > 0 ? next : void 0 };
1266
- }),
1267
- computeValidationResult: assign(({ context }) => {
1268
- const errors = validateEkycForm(context.values, context.fields);
1269
- return { validationErrors: Object.keys(errors).length > 0 ? errors : void 0 };
1270
- }),
1271
- fillAddressFields: assign(({ context, event }) => {
1272
- const { suggestion } = event;
1273
- const activeFields = new Set(context.fields.map((f) => f.name));
1274
- const { values: newValues } = fillFromSuggestion(context.values, {}, suggestion, activeFields);
1275
- const clearedErrors = omitKeys(context.validationErrors, ADDRESS_AUTOCOMPLETE_KEYS);
1276
- const streetError = getStreetLevelErrorForSuggestion(suggestion, activeFields);
1277
- const validationErrors = {
1278
- ...clearedErrors ?? {},
1279
- ...streetError !== void 0 ? { street: streetError } : {}
1280
- };
1281
- return {
1282
- values: newValues,
1283
- addressSuggestions: [],
1284
- _searchQuery: "",
1285
- validationErrors: Object.keys(validationErrors).length > 0 ? validationErrors : void 0,
1286
- submitError: ""
1287
- };
1288
- }),
1289
- setAddressSuggestions: assign(({ event }) => ({ addressSuggestions: event.suggestions })),
1290
- setErrorMessage: assign(({ event }) => ({ errorMessage: String(event.error ?? "verification.error") })),
1291
- clearErrorMessage: assign({ errorMessage: () => "" }),
1292
- setSubmitError: assign(() => ({ submitError: "verification.errors.countryNotSupported" })),
1293
- clearSubmitError: assign({ submitError: () => "" })
1294
- },
1295
- guards: {
1296
- hasNoValidationErrors: hasNoValidationErrorsGuard,
1297
- hasFlowId: hasFlowIdGuard,
1298
- hasVerificationFields: hasVerificationFieldsGuard,
1299
- isCountryNotSupported: isCountryNotSupportedGuard
1300
- }
1301
- }).createMachine({
1302
- id: "ekyc",
1303
- initial: "idle",
1304
- context: ({ input }) => {
1305
- const config = toEkycConfig(input.config);
1306
- return {
1307
- config,
1308
- moduleConfig: void 0,
1309
- verificationFields: {},
1310
- configSource: config.source ?? "",
1311
- fieldsCountry: config.fieldsCountry ?? "",
1312
- fields: [],
1313
- values: {},
1314
- addressSuggestions: [],
1315
- prefilled: {},
1316
- hideEmail: false,
1317
- errorMessage: "",
1318
- submitError: "",
1319
- _searchQuery: ""
1320
- };
1321
- },
1322
- states: {
1323
- idle: { on: { LOAD: [
1324
- {
1325
- target: "loading",
1326
- guard: "hasFlowId"
1327
- },
1328
- {
1329
- target: "prefilling",
1330
- guard: "hasVerificationFields",
1331
- actions: assign(({ context }) => {
1332
- const vFields = context.config.verificationFields;
1333
- const source = context.config.source ?? "";
1334
- const country = context.config.fieldsCountry ?? getEKYCCountry(source);
1335
- return {
1336
- verificationFields: vFields,
1337
- configSource: source,
1338
- fieldsCountry: country,
1339
- fields: buildFieldDefs(vFields, source, country, context.config.enablePhoneRisk)
1340
- };
1341
- })
1342
- },
1343
- { target: "misconfigured" }
1344
- ] } },
1345
- loading: { invoke: {
1346
- id: "fetchModuleConfig",
1347
- src: "fetchModuleConfig",
1348
- input: ({ context }) => ({ flowId: context.config.flowId }),
1349
- onDone: {
1350
- target: "prefilling",
1351
- actions: "setModuleConfig"
1352
- },
1353
- onError: {
1354
- target: "error",
1355
- actions: "setErrorMessage"
1356
- }
1357
- } },
1358
- prefilling: { invoke: {
1359
- id: "fetchPrefillData",
1360
- src: "fetchPrefillData",
1361
- onDone: {
1362
- target: "form",
1363
- actions: "applyPrefillData"
1364
- },
1365
- onError: { target: "form" }
1366
- } },
1367
- form: {
1368
- initial: "inputting",
1369
- states: {
1370
- inputting: { on: {
1371
- DATA_CHANGED: { actions: ["updateField", "clearFieldValidationError"] },
1372
- VALIDATE_FIELD: { actions: "validateFormField" },
1373
- SUBMIT: { target: "validatingSubmit" }
1374
- } },
1375
- searching: {
1376
- invoke: {
1377
- id: "debounceSearch",
1378
- src: "debounceSearch",
1379
- input: ({ context }) => ({ query: context._searchQuery })
1380
- },
1381
- on: {
1382
- DATA_CHANGED: { actions: ["updateField", "clearFieldValidationError"] },
1383
- VALIDATE_FIELD: { actions: "validateFormField" },
1384
- RESULTS: {
1385
- target: "inputting",
1386
- actions: "setAddressSuggestions"
1387
- }
1388
- }
1389
- },
1390
- validatingSubmit: {
1391
- entry: "computeValidationResult",
1392
- always: [{
1393
- guard: "hasNoValidationErrors",
1394
- target: "#ekyc.submitting"
1395
- }, { target: "inputting" }]
1396
- }
1397
- },
1398
- on: {
1399
- SEARCH_ADDRESS: {
1400
- target: ".searching",
1401
- actions: assign(({ event }) => ({
1402
- _searchQuery: event.query,
1403
- addressSuggestions: []
1404
- }))
1405
- },
1406
- SELECT_ADDRESS: {
1407
- target: ".inputting",
1408
- actions: "fillAddressFields"
1409
- },
1410
- SKIP: { target: "#ekyc.finished" },
1411
- CLOSE: { target: "#ekyc.closed" }
1412
- }
1413
- },
1414
- submitting: { invoke: {
1415
- id: "submitEkyc",
1416
- src: "submitEkyc",
1417
- input: ({ context }) => buildSubmitPayload(context),
1418
- onDone: { target: "success" },
1419
- onError: [{
1420
- target: "form",
1421
- guard: "isCountryNotSupported",
1422
- actions: "setSubmitError"
1423
- }, {
1424
- target: "error",
1425
- actions: "setErrorMessage"
1426
- }]
1427
- } },
1428
- success: { after: { 3e3: "finished" } },
1429
- error: { on: {
1430
- RETRY: {
1431
- target: "form",
1432
- actions: "clearErrorMessage"
1433
- },
1434
- SKIP: { target: "finished" },
1435
- CLOSE: { target: "closed" }
1436
- } },
1437
- misconfigured: { on: { CLOSE: { target: "closed" } } },
1438
- finished: { type: "final" },
1439
- closed: { type: "final" }
1440
- }
1441
- });
1442
- //#endregion
1443
- export { ekycMachine as t };