@incodetech/core 2.5.0-agentic → 2.5.0-agentic.2

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 (224) hide show
  1. package/dist/{FaceDetectionProvider-Dv9iXub0.esm.js → FaceDetectionProvider-ClZEDaLF.esm.js} +9 -9
  2. package/dist/{IIdCaptureCapability-CAxToGns.d.ts → IIdCaptureCapability-BRAZQtkM.d.ts} +1 -0
  3. package/dist/{MotionSensorProvider-X4_2eBGd.esm.js → MotionSensorProvider-BAGydZPH.esm.js} +5 -0
  4. package/dist/{WasmUtilProvider-DVFDFlIL.esm.js → WasmUtilProvider-C4x5gc1c.esm.js} +2 -2
  5. package/dist/{definitionSource-B-Z2EgJJ.esm.js → addressSearch-DBJeg_g3.esm.js} +76 -9
  6. package/dist/ae-signature.esm.js +1 -1
  7. package/dist/{phoneFormat-C3q0Ukh4.esm.js → allowedCharacters-Bnir--CN.esm.js} +1 -11
  8. package/dist/antifraud.esm.js +2 -2
  9. package/dist/{antifraudManager-BI2zr7YX.esm.js → antifraudManager-DRMBLSh7.esm.js} +3 -3
  10. package/dist/{antifraudStateMachine-TWUu8wLN.esm.js → antifraudStateMachine-Bi0m60oV.esm.js} +1 -1
  11. package/dist/{api-BNxrW8xK.esm.js → api-B58edv6M.esm.js} +0 -1
  12. package/dist/{apiError-BAfdBGxH.esm.js → apiError-CWjo9dzH.esm.js} +1 -1
  13. package/dist/{attemptCarry-DWM8lV9V.esm.js → attemptCarry-CxiYlUAO.esm.js} +1 -1
  14. package/dist/authentication.d.ts +3 -3
  15. package/dist/authentication.esm.js +2 -2
  16. package/dist/{authenticationManager-BJElkTsj.d.ts → authenticationManager-CkD0JR7Q.d.ts} +1 -1
  17. package/dist/{authenticationManager-DFzByAYo.esm.js → authenticationManager-D_qFuB3y.esm.js} +6 -6
  18. package/dist/{authenticationStateMachine-CKTOhwwc.esm.js → authenticationStateMachine-DJJWTDZS.esm.js} +3 -3
  19. package/dist/{browser-pQZA35G2-CG3C-xGt.esm.js → browser-pQZA35G2-B4Dwja1e.esm.js} +1 -1
  20. package/dist/{calendarDate-DcqGuEht.esm.js → calendarDate-D2zWfUlA.esm.js} +1 -1
  21. package/dist/camera.esm.js +1 -1
  22. package/dist/certificate-issuance.esm.js +2 -2
  23. package/dist/{certificateIssuanceManager-P44yBRop.esm.js → certificateIssuanceManager-Ctj6AJC7.esm.js} +3 -3
  24. package/dist/{certificateIssuanceStateMachine-BPBrILt6.esm.js → certificateIssuanceStateMachine-DDqN9kvL.esm.js} +1 -1
  25. package/dist/{cnpj-Bl_olpdX.esm.js → cnpj-CVq3vL39.esm.js} +1 -9
  26. package/dist/cnpj-D5cxwIe-.esm.js +9 -0
  27. package/dist/consent.d.ts +1 -1
  28. package/dist/consent.esm.js +2 -2
  29. package/dist/{consentManager-Duzd8paN.d.ts → consentManager-B0YKqYtZ.d.ts} +5 -5
  30. package/dist/{consentManager-D43w2ms-.esm.js → consentManager-CyoeiABc.esm.js} +3 -3
  31. package/dist/{consentStateMachine-CLK8PfM4.esm.js → consentStateMachine-BTUrAslr.esm.js} +1 -1
  32. package/dist/cross-document-data-match.esm.js +1 -1
  33. package/dist/{crossDocumentDataMatchManager-Cag_bcyW.esm.js → crossDocumentDataMatchManager-cmQmp7Bi.esm.js} +3 -3
  34. package/dist/curp-validation.d.ts +1 -1
  35. package/dist/curp-validation.esm.js +2 -2
  36. package/dist/{curpValidationManager-C6WmQToS.esm.js → curpValidationManager-EW44fVpH.esm.js} +3 -3
  37. package/dist/{curpValidationManager-CmL52FU8.d.ts → curpValidationManager-HOidAKvT.d.ts} +1 -1
  38. package/dist/{curpValidationStateMachine-BbJ4YAzE.esm.js → curpValidationStateMachine-BFkt90Zs.esm.js} +3 -3
  39. package/dist/custom-fields.esm.js +1 -1
  40. package/dist/custom-watchlist.esm.js +2 -2
  41. package/dist/{customFieldsManager-BBy6X9nh.esm.js → customFieldsManager-DPMBJrcH.esm.js} +4 -4
  42. package/dist/{customWatchlistManager-CtBMy2EF.esm.js → customWatchlistManager-DiYpPjZx.esm.js} +3 -3
  43. package/dist/{customWatchlistStateMachine-SS2ssNCg.esm.js → customWatchlistStateMachine-D7VxQggF.esm.js} +1 -1
  44. package/dist/{deepsightCaptureConfig-Nm_K8twx.esm.js → deepsightCaptureConfig-XPx0BN30.esm.js} +2 -2
  45. package/dist/{deepsightLoader-BInnND1H.esm.js → deepsightLoader-Bvs8HYaK.esm.js} +7 -7
  46. package/dist/definitionSource-B9WTvQb9.esm.js +30 -0
  47. package/dist/{desktopCameraElection-JNBOXqvK.esm.js → desktopCameraElection-CdrLiJTn.esm.js} +8 -8
  48. package/dist/document-capture.esm.js +2 -2
  49. package/dist/document-signature.esm.js +3 -3
  50. package/dist/{documentCaptureManager-CGDtkfWj.esm.js → documentCaptureManager-SRG6YEMh.esm.js} +3 -3
  51. package/dist/{documentCaptureStateMachine-flAt9D4q.esm.js → documentCaptureStateMachine-Bh0uyfGq.esm.js} +4 -4
  52. package/dist/{documentSignatureStateMachine-DrRyICFT.esm.js → documentSignatureStateMachine-oqU3EPca.esm.js} +4 -4
  53. package/dist/dynamic-forms.esm.js +2 -2
  54. package/dist/{dynamicFormsManager-CxLq2KzT.esm.js → dynamicFormsManager-YGL7Avp-.esm.js} +3 -3
  55. package/dist/{dynamicFormsStateMachine-By-maT_4.esm.js → dynamicFormsStateMachine-BE_WfmVE.esm.js} +3 -3
  56. package/dist/ekyb.d.ts +4 -4
  57. package/dist/ekyb.esm.js +3 -3
  58. package/dist/{ekybManager-CE19Pcdb.esm.js → ekybManager-35NxvxZK.esm.js} +3 -3
  59. package/dist/{ekybManager-BflWuTe4.d.ts → ekybManager-Cjk8pQX0.d.ts} +2 -2
  60. package/dist/{ekybStateMachine-q7JQ-x9l.esm.js → ekybStateMachine-BD4zpC3O.esm.js} +141 -10
  61. package/dist/{ekybUtils-Z9MhFAer.esm.js → ekybUtils-Dl0MU-ib.esm.js} +23 -1
  62. package/dist/ekyc-prefill.d.ts +5 -5
  63. package/dist/ekyc-prefill.esm.js +2 -2
  64. package/dist/ekyc.d.ts +3 -3
  65. package/dist/ekyc.esm.js +3 -3
  66. package/dist/{ekycManager-p3uenUEi.esm.js → ekycManager-D2K8AaMV.esm.js} +3 -3
  67. package/dist/{ekycManager-BKVQazAb.d.ts → ekycManager-DusmB-4j.d.ts} +2 -2
  68. package/dist/{ekycPrefillManager-BcLhkpp8.d.ts → ekycPrefillManager-BwmPXfhY.d.ts} +12 -12
  69. package/dist/{ekycPrefillManager-gPX3XE7u.esm.js → ekycPrefillManager-CxzjSch2.esm.js} +6 -7
  70. package/dist/ekycPrefillStateMachine-x6skDqhq.esm.js +1289 -0
  71. package/dist/{ekycStateMachine-D0NAHzS7.esm.js → ekycStateMachine-6EKndBd7.esm.js} +740 -230
  72. package/dist/{ekycUtils-DEvtEyBI.esm.js → ekycUtils-C6HZB46m.esm.js} +37 -6
  73. package/dist/electronic-signature.esm.js +1 -1
  74. package/dist/{electronicSignatureManager-C1M-Yxf2.esm.js → electronicSignatureManager-BYJHywZK.esm.js} +4 -4
  75. package/dist/email.esm.js +2 -2
  76. package/dist/{emailManager-DWnhEsUf.esm.js → emailManager-BBdRYLtH.esm.js} +3 -3
  77. package/dist/{emailStateMachine--T9PHflK.esm.js → emailStateMachine-DO7lWYvn.esm.js} +2 -2
  78. package/dist/{events-ChMS-UzR.esm.js → events-PUWyizJn.esm.js} +2 -2
  79. package/dist/events.d.ts +0 -3
  80. package/dist/events.esm.js +2 -2
  81. package/dist/extensibility.d.ts +15 -15
  82. package/dist/extensibility.esm.js +36 -36
  83. package/dist/face-match.esm.js +2 -2
  84. package/dist/{faceCaptureManagerFactory-18QW0lmV.esm.js → faceCaptureManagerFactory-CYr2rVEj.esm.js} +6 -6
  85. package/dist/{faceCaptureManagerFactory-CHqmyOjM.d.ts → faceCaptureManagerFactory-D1EJw36F.d.ts} +3 -3
  86. package/dist/{faceCaptureSetup-CFToXwHy.esm.js → faceCaptureSetup-DadLKnMf.esm.js} +20 -12
  87. package/dist/{faceMatchManager-DIStK4qi.esm.js → faceMatchManager-nBvS9z0o.esm.js} +3 -3
  88. package/dist/{faceMatchStateMachine-DagrRdo2.esm.js → faceMatchStateMachine-48O8j_Lx.esm.js} +2 -2
  89. package/dist/{feature-management-BlscKbeV.esm.js → feature-management-CUzbPq54.esm.js} +1 -1
  90. package/dist/feature-management.esm.js +1 -1
  91. package/dist/field-comparison.esm.js +1 -1
  92. package/dist/{fieldComparisonManager-BnWBtMN7.esm.js → fieldComparisonManager-B1ipvtnp.esm.js} +3 -3
  93. package/dist/fiscal-qr.esm.js +1 -1
  94. package/dist/{fiscalQrManager-BxXaLhin.esm.js → fiscalQrManager-yecjuXV4.esm.js} +3 -3
  95. package/dist/flow-events.d.ts +1 -1
  96. package/dist/flow.d.ts +7 -7
  97. package/dist/flow.esm.js +5 -5
  98. package/dist/{flowCompletionService-DNLssMAg.esm.js → flowCompletionService-BSiUcHmU.esm.js} +2 -2
  99. package/dist/{flowServices-Bzq3piUR.esm.js → flowServices-BIMnpB8Q.esm.js} +9 -9
  100. package/dist/formErrors-lSfh7Y8J.esm.js +512 -0
  101. package/dist/geolocation.esm.js +2 -2
  102. package/dist/{geolocationManager-DoLbpx5e.esm.js → geolocationManager-D7J-rLJp.esm.js} +3 -3
  103. package/dist/{geolocationStateMachine-d5_E7gAm.esm.js → geolocationStateMachine-5g2Quxbz.esm.js} +3 -3
  104. package/dist/government-validation.esm.js +2 -2
  105. package/dist/{governmentValidationManager-CaZxyEOO.esm.js → governmentValidationManager-0-L21hu6.esm.js} +3 -3
  106. package/dist/{governmentValidationStateMachine-DeHHhlcf.esm.js → governmentValidationStateMachine-BFIcq3UB.esm.js} +1 -1
  107. package/dist/home.d.ts +1 -1
  108. package/dist/home.esm.js +2 -2
  109. package/dist/http.esm.js +1 -1
  110. package/dist/id-ocr.d.ts +1 -1
  111. package/dist/id-ocr.esm.js +19 -3
  112. package/dist/id-selfie-flow.d.ts +2 -2
  113. package/dist/id-selfie-flow.esm.js +8 -8
  114. package/dist/id-verification.esm.js +2 -2
  115. package/dist/id.d.ts +3 -3
  116. package/dist/id.esm.js +3 -3
  117. package/dist/{idCaptureDefaults-R3rHuTOE.esm.js → idCaptureDefaults-CNopPetU.esm.js} +16 -6
  118. package/dist/{idCaptureManager-CgkQW3Xc.d.ts → idCaptureManager-CNFBeYgV.d.ts} +20 -5
  119. package/dist/{idCaptureManager-D_YGMeCW.esm.js → idCaptureManager-Du5jr3gJ.esm.js} +24 -18
  120. package/dist/{idCaptureServices-CP6AxsFW.esm.js → idCaptureServices-N0sn1AOF.esm.js} +5 -5
  121. package/dist/{idCaptureStateMachine-BdBtGQZP.esm.js → idCaptureStateMachine-CHk0uv1U.esm.js} +191 -44
  122. package/dist/{idOcrManager-C0C7lFGd.d.ts → idOcrManager-DflRx-_u.d.ts} +1 -1
  123. package/dist/{idOcrManager-XTbpfHoF.esm.js → idOcrManager-bjBLjrEE.esm.js} +3 -3
  124. package/dist/{idOcrStateMachine-B-00PgPh.esm.js → idOcrStateMachine-D5ifJ1B8.esm.js} +2 -2
  125. package/dist/{idVerificationManager-B4NYLlUl.esm.js → idVerificationManager-C8Ja-vKq.esm.js} +3 -3
  126. package/dist/{idVerificationStateMachine-B48Ikl-7.esm.js → idVerificationStateMachine-BMnfZZli.esm.js} +1 -1
  127. package/dist/identity-reuse.esm.js +2 -2
  128. package/dist/identity-search.esm.js +2 -2
  129. package/dist/{identityReuseManager-tFeYm_So.esm.js → identityReuseManager-B5BWAleT.esm.js} +3 -3
  130. package/dist/{identityReuseStateMachine-Ckf39qFu.esm.js → identityReuseStateMachine-Cuggm1UP.esm.js} +1 -1
  131. package/dist/{index-CoePktWH.d.ts → index-BoGlwLGK.d.ts} +1 -1
  132. package/dist/{index-CNck5TLp.d.ts → index-bsGvWr9-.d.ts} +21 -2
  133. package/dist/index.d.ts +1 -1
  134. package/dist/index.esm.js +1 -1
  135. package/dist/{invokeOnCaptureCallback-DNQX9k5e.esm.js → invokeOnCaptureCallback-D2FOfi4O.esm.js} +1 -1
  136. package/dist/kyb-checks.d.ts +3 -3
  137. package/dist/kyb-checks.esm.js +2 -2
  138. package/dist/{kybChecksManager-DP76y-Qz.esm.js → kybChecksManager-CDxP2pYP.esm.js} +2 -2
  139. package/dist/{kybChecksManager-B7Di9auB.d.ts → kybChecksManager-CKDy1mel.d.ts} +1 -1
  140. package/dist/{kybChecksStateMachine-OKLT8Zoc.esm.js → kybChecksStateMachine-ZOKNXTUx.esm.js} +176 -179
  141. package/dist/mandatory-consent.d.ts +2 -2
  142. package/dist/mandatory-consent.esm.js +2 -2
  143. package/dist/{mandatoryConsentManager-kzr5kdc_.d.ts → mandatoryConsentManager-BcxCesP5.d.ts} +6 -6
  144. package/dist/{mandatoryConsentManager-NX1lz6nk.esm.js → mandatoryConsentManager-FfgHdPYw.esm.js} +3 -3
  145. package/dist/{mandatoryConsentStateMachine-D1J2NQSI.esm.js → mandatoryConsentStateMachine-CXuYC3qR.esm.js} +1 -1
  146. package/dist/{multipartRecordingService-Cz-cWrpV.esm.js → multipartRecordingService-CFmOUGQt.esm.js} +1 -1
  147. package/dist/numericRange-2e1vw1W0.esm.js +256 -0
  148. package/dist/{permissionGuards-Cyh71hOt.esm.js → permissionGuards-CZTCRHT-.esm.js} +1 -1
  149. package/dist/{permissionServices-BrtDMB0Z.esm.js → permissionServices-Vd86JiW9.esm.js} +19 -7
  150. package/dist/phone.d.ts +1 -1
  151. package/dist/phone.esm.js +2 -2
  152. package/dist/{phoneManager-VO1HEoUZ.d.ts → phoneManager-bA-xw2TP.d.ts} +0 -8
  153. package/dist/{phoneManager-D1QPNbu0.esm.js → phoneManager-oIMdbeLG.esm.js} +5 -6
  154. package/dist/{phoneServices-DC7AuUed.esm.js → phoneServices-Dk4j3NhI.esm.js} +2 -12
  155. package/dist/{phoneStateMachine-CxCPxTIy.esm.js → phoneStateMachine-Cu3y7ewi.esm.js} +3 -8
  156. package/dist/{processFaceMatch-BQoiqLVh.esm.js → processFaceMatch-CHeI0DEt.esm.js} +1 -1
  157. package/dist/qe-signature.esm.js +1 -1
  158. package/dist/{recordingService-CSCvD2tB.esm.js → recordingService-Cg-DwTxA.esm.js} +3 -3
  159. package/dist/redirect-to-mobile.esm.js +2 -2
  160. package/dist/{redirectToMobileManager-Dcpg5GfP.esm.js → redirectToMobileManager-yYJGE47m.esm.js} +3 -3
  161. package/dist/{redirectToMobileStateMachine-BMehrtVP.esm.js → redirectToMobileStateMachine-g_NbyHrL.esm.js} +1 -1
  162. package/dist/{runChildModule-DNEmc7of.esm.js → runChildModule-Dd-tXDh2.esm.js} +2 -2
  163. package/dist/{sdkVersion-etdZfyCR.esm.js → sdkVersion-DDHH3E2F.esm.js} +1 -1
  164. package/dist/selfie.d.ts +3 -3
  165. package/dist/selfie.esm.js +11 -11
  166. package/dist/{selfieErrorUtils-DT-uhK20.esm.js → selfieErrorUtils-Dtm9bDS7.esm.js} +1 -1
  167. package/dist/{selfieManager-CdS6a7Q8.esm.js → selfieManager-BYJPzJW1.esm.js} +6 -6
  168. package/dist/{selfieManager-DrBYj5kA.d.ts → selfieManager-CqDlUy6B.d.ts} +1 -1
  169. package/dist/{selfieStateMachine-ChCl3nyf.esm.js → selfieStateMachine-DGg7S9O6.esm.js} +3 -3
  170. package/dist/{session-VXYuRYzb.esm.js → session-B49EJzZg.esm.js} +5 -5
  171. package/dist/session.d.ts +1 -1
  172. package/dist/session.esm.js +5 -5
  173. package/dist/{sessionInitializer-BT_CmYcX.esm.js → sessionInitializer-CaY5gnUl.esm.js} +11 -11
  174. package/dist/{setup-BXrgDdfx.esm.js → setup-B7SDCbtu.esm.js} +13 -13
  175. package/dist/{setup-rcXgYUcY.d.ts → setup-CTnxQSQW.d.ts} +1 -1
  176. package/dist/signature.esm.js +2 -2
  177. package/dist/{signatureManager-B737Gkvk.esm.js → signatureManager-DRUflksL.esm.js} +3 -3
  178. package/dist/{signatureStateMachine-B-QG7fk0.esm.js → signatureStateMachine-BQZenxel.esm.js} +1 -1
  179. package/dist/{stats-CrqhpKkP.esm.js → stats-DHu3li6G.esm.js} +1 -1
  180. package/dist/stats.esm.js +1 -1
  181. package/dist/{tri-BD9z6z0w.esm.js → tri-DBB-iiN3.esm.js} +8 -25
  182. package/dist/tri.d.ts +1 -1
  183. package/dist/{tri.esm-DYdFtcDH.esm.js → tri.esm-CftnGf9w.esm.js} +187 -177
  184. package/dist/tri.esm.js +1 -1
  185. package/dist/trueSight-Dg3TSVN7.esm.js +1 -0
  186. package/dist/{trueSightService-BwyLhIAo.esm.js → trueSightService-BWDGk571.esm.js} +5 -7
  187. package/dist/trust-graph.esm.js +3 -3
  188. package/dist/{trustGraphStateMachine-BxvReuo1.esm.js → trustGraphStateMachine-0Ehwried.esm.js} +1 -1
  189. package/dist/{types-4Re9FSOw.d.ts → types-BZsmNYom.d.ts} +3 -4
  190. package/dist/types-BinnzVrL.d.ts +6 -0
  191. package/dist/{types-BgRHw-dR.d.ts → types-BwMpWCVG.d.ts} +6 -2
  192. package/dist/{types-b0l9b83G.d.ts → types-D-FEM1rT.d.ts} +26 -10
  193. package/dist/{textRules-D4NRinKY.d.ts → types-D6Q1D1kx.d.ts} +1 -9
  194. package/dist/{types-CBQN04Rh.esm.js → types-DLsivQsu.esm.js} +0 -3
  195. package/dist/{types-CTaL0XJz.d.ts → types-DWqO7owj.d.ts} +2 -24
  196. package/dist/{types-CEGG70FK.d.ts → types-HHgsFhZn.d.ts} +1 -1
  197. package/dist/{types-C1056-J1.d.ts → types-LbccjQYX.d.ts} +1 -1
  198. package/dist/{types-DHpz4Y37.d.ts → types-PnJXvTkV.d.ts} +1 -1
  199. package/dist/{types-B-PIc0en.d.ts → types-g3NuVCT9.d.ts} +40 -37
  200. package/dist/{types-DEa3taWc.d.ts → types-tOSLpcSa.d.ts} +16 -2
  201. package/dist/video-selfie.d.ts +14 -6
  202. package/dist/video-selfie.esm.js +12 -9
  203. package/dist/{videoSelfieCameraWarmer-DgRlU_8q.esm.js → videoSelfieCameraWarmer-DFhlGeRd.esm.js} +27 -8
  204. package/dist/{videoSelfieStepDetector-DC_Qh7qI.d.ts → videoSelfieStepDetector-CxOc3kSI.d.ts} +3 -3
  205. package/dist/{warmup-BN8dG2KX.esm.js → warmup-ClZxXOkg.esm.js} +1 -1
  206. package/dist/wasm.d.ts +2 -2
  207. package/dist/wasm.esm.js +3 -3
  208. package/dist/{wasmDsFlagSync-DwBfTlgB.esm.js → wasmDsFlagSync-Bw-P5OG1.esm.js} +1 -1
  209. package/dist/{wasmWebClient-B2P6Vlvv.esm.js → wasmWebClient-BLtlzQhv.esm.js} +9 -9
  210. package/dist/watchlist-for-business.esm.js +2 -2
  211. package/dist/watchlist.esm.js +2 -2
  212. package/dist/{watchlistForBusinessManager-DxeSH80T.esm.js → watchlistForBusinessManager-d8kdf35n.esm.js} +3 -3
  213. package/dist/{watchlistForBusinessStateMachine-BC9UWLuZ.esm.js → watchlistForBusinessStateMachine-Y9wFmuMH.esm.js} +4 -3
  214. package/dist/{watchlistManager-BHzmC9OC.esm.js → watchlistManager-D1BVrd3H.esm.js} +3 -3
  215. package/dist/{watchlistStateMachine-Bxzn16iJ.esm.js → watchlistStateMachine-Da4p0sTE.esm.js} +1 -1
  216. package/dist/workflow.d.ts +1 -1
  217. package/dist/workflow.esm.js +42 -42
  218. package/package.json +3 -3
  219. package/dist/addressSearch-BKlynuBr.esm.js +0 -71
  220. package/dist/ekycPrefillStateMachine-SBnBKPGA.esm.js +0 -685
  221. package/dist/ekycRules-BH_Ll_0A.esm.js +0 -482
  222. package/dist/idOcrCpfUtils-D5Gwskxu.esm.js +0 -18
  223. package/dist/trueSight-BymJD5cW.esm.js +0 -1
  224. package/dist/types-BtrJ5fkm.d.ts +0 -6
@@ -1,96 +1,19 @@
1
- import { t as api, u as endpoints } from "./api-BNxrW8xK.esm.js";
2
- import { t as getPhoneValidation } from "./phoneValidation-OggtfjRt.esm.js";
1
+ import { t as getLocalIsoDate } from "./IBrowserEnvironmentCapability-D7JG7ML3.esm.js";
2
+ import { t as api, u as endpoints } from "./api-B58edv6M.esm.js";
3
+ import { n as loadPhoneValidation, t as getPhoneValidation } from "./phoneValidation-OggtfjRt.esm.js";
3
4
  import { i as assign, t as setup } from "./xstate.esm-CIqUf_i6.esm.js";
4
5
  import { n as fromPromise } from "./xstate-actors.esm-BCcwgosu.esm.js";
5
- import { a as formatPhoneNational, c as oneOfRequiredErrorKey, i as cleanName, l as validateEkycField, n as projectRules, o as formatSSN, s as loadPhoneValidator, t as RULES, u as validateEkycForm } from "./ekycRules-BH_Ll_0A.esm.js";
6
+ import { t as isValidCurp } from "./curp-DZGvefg3.esm.js";
7
+ import { a as isPoBox, c as hasDigitCount, d as isValidInDrivingLicenseNumber, f as isValidFiPersonalIdentityCode, i as isWithinMaxAge, l as resolvePrefill, n as isNotFuture, o as isEmailFormat, p as isValidEsDni, r as hasNameCharacters, s as digitCountError, t as isInNumericRange, u as isValidRut } from "./numericRange-2e1vw1W0.esm.js";
8
+ import { n as calendarDateError } from "./calendarDate-D2zWfUlA.esm.js";
6
9
  import { n as usStates, t as usStateOptions } from "./usStates-CwOQ2kAx.esm.js";
7
- import { a as getPostalCodeMaxLength, c as fillFromSuggestion, l as getStreetLevelErrorForSuggestion, n as formatPostalCode, t as createBundledDefinitionSource, u as keepSuggestionInOptions } from "./definitionSource-B-Z2EgJJ.esm.js";
8
- import { n as checkSupport, t as resolveForm } from "./resolveForm-DaaQSVWp.esm.js";
9
- import { n as searchAddress, r as isFormDefinitionsEnabled, t as debounceSearchActor } from "./addressSearch-BKlynuBr.esm.js";
10
- import { C as TAX_ID_SOURCES, S as STREET_SOURCES, _ as MIDDLE_NAME_SOURCES, a as getEKYCFields, b as POSTAL_CODE_SOURCES, c as resolveEkycSource, d as APARTMENT_SOURCES, f as CITY_SOURCES, g as HOUSE_NO_SOURCES, h as EMAIL_SOURCES, i as getEKYCDisplayModes, l as toEkycConfig, m as COUNTRY_SELECTOR_DISABLED_SOURCES, o as isFieldOptional, p as COUNTRY_CODE_OMITTED_SOURCES, r as getEKYCCountry, s as mapToEKYCvalue, t as EKYC_GROUP_KEYS, u as ADDRESS_STATE_SOURCES, v as NAME_SOURCES, w as VOCABULARY, x as STATE_CODE_HINTS, y as ONE_OF_REQUIRED_GROUPS } from "./ekycUtils-DEvtEyBI.esm.js";
10
+ import { a as getPostalCodeErrorKey, c as validatePostalCode, d as getStreetLevelErrorForSuggestion, f as keepSuggestionInOptions, i as formatPostalCode, l as STREET_LEVEL_REQUIRED_ERROR, n as searchAddress, o as getPostalCodeErrorParams, r as isFormDefinitionsEnabled, s as getPostalCodeMaxLength, t as debounceSearchActor, u as fillFromSuggestion } from "./addressSearch-DBJeg_g3.esm.js";
11
+ import { n as checkSupport, r as DYNAMIC_REQUIRED_KEY, t as resolveForm } from "./resolveForm-DaaQSVWp.esm.js";
12
+ import { n as matchesCharTemplate, t as createBundledDefinitionSource } from "./definitionSource-B9WTvQb9.esm.js";
13
+ import { C as POSTAL_CODE_SOURCES, D as VOCABULARY, E as TAX_ID_SOURCES, S as ONE_OF_REQUIRED_GROUPS, T as STREET_SOURCES, _ as COUNTRY_SELECTOR_DISABLED_SOURCES, a as getEKYCFields, b as MIDDLE_NAME_SOURCES, c as isFieldOptional, d as toEkycConfig, f as withRiskAddonFields, g as COUNTRY_CODE_OMITTED_SOURCES, h as CITY_SOURCES, i as getEKYCDisplayModes, l as mapToEKYCvalue, m as APARTMENT_SOURCES, o as getEkycRiskAddons, p as ADDRESS_STATE_SOURCES, r as getEKYCCountry, s as getRiskAddonFields, t as EKYC_GROUP_KEYS, u as resolveEkycSource, v as EMAIL_SOURCES, w as STATE_CODE_HINTS, x as NAME_SOURCES, y as HOUSE_NO_SOURCES } from "./ekycUtils-C6HZB46m.esm.js";
11
14
  import { t as DateFormattingProvider } from "./DateFormattingProvider-DPq9zco-.esm.js";
12
- import { t as formatPhoneE164 } from "./phoneFormat-C3q0Ukh4.esm.js";
13
- //#region src/internal/forms/resolvePrefill.ts
14
- const DISPLAY_MODES = /* @__PURE__ */ new Set([
15
- "editable",
16
- "readOnly",
17
- "hidden"
18
- ]);
19
- const ONE_OF_REQUIRED = "oneOfRequired";
20
- const filled = (value) => value !== void 0 && value.trim() !== "";
21
- function configuredMode(context, group) {
22
- const mode = context.displayModes?.[group];
23
- return mode !== void 0 && DISPLAY_MODES.has(mode) ? mode : "editable";
24
- }
25
- /** The field's prefill source for its group's origin, if it lists one. */
26
- function sourceFor(field, context) {
27
- const origin = context.origins?.[field.group];
28
- if (!origin) return void 0;
29
- return field.prefill?.find((id) => id.startsWith(`${origin}.`));
30
- }
31
- /**
32
- * Decides each shown field's prefilled value and display mode, from the
33
- * resolved form, module configuration's origins and display modes, and the
34
- * values the module read. Pure and synchronous.
35
- *
36
- * A value that fails its field's checks is dropped. A group configured
37
- * `hidden` or `readOnly` becomes `editable` as a whole when one of its
38
- * required fields has no value, or when a `oneOfRequired` rule over it has
39
- * none, so the user can always complete the form. An optional field without
40
- * a value keeps its mode and sends nothing. An editable field filled from one
41
- * of the context's `lockingOrigins` shows read-only.
42
- */
43
- function resolvePrefill(form, context, data, checks) {
44
- const candidates = {};
45
- for (const { field } of form.fields) {
46
- const source = sourceFor(field, context);
47
- const raw = source ? data[source] : void 0;
48
- if (filled(raw)) candidates[field.name] = checks.format(field, raw);
49
- }
50
- const values = {};
51
- for (const { field } of form.fields) {
52
- const value = candidates[field.name];
53
- if (filled(value) && checks.isValid(field, value, candidates)) values[field.name] = value;
54
- }
55
- const isRequired = (resolved) => resolved.required || resolved.requiredIfFilled.some((name) => filled(values[name]));
56
- const promoted = /* @__PURE__ */ new Set();
57
- const promote = (group) => {
58
- if (configuredMode(context, group) !== "editable") promoted.add(group);
59
- };
60
- for (const resolved of form.fields) if (isRequired(resolved) && !filled(values[resolved.field.name])) promote(resolved.field.group);
61
- const groupOf = new Map(form.fields.map(({ field }) => [field.name, field.group]));
62
- for (const { rule, fields } of form.groupRules) {
63
- if (rule.id !== ONE_OF_REQUIRED) continue;
64
- if (fields.some((name) => filled(values[name]))) continue;
65
- for (const name of fields) {
66
- const group = groupOf.get(name);
67
- if (group) promote(group);
68
- }
69
- }
70
- return {
71
- fields: form.fields.map((resolved) => {
72
- const { group, name } = resolved.field;
73
- if (promoted.has(group)) return {
74
- ...resolved,
75
- displayMode: "editable",
76
- displayReason: "promoted"
77
- };
78
- const configured = configuredMode(context, group);
79
- const origin = context.origins?.[group];
80
- if (configured === "editable" && filled(values[name]) && origin !== void 0 && context.lockingOrigins?.includes(origin)) return {
81
- ...resolved,
82
- displayMode: "readOnly",
83
- displayReason: "locked"
84
- };
85
- return {
86
- ...resolved,
87
- displayMode: configured,
88
- displayReason: "configured"
89
- };
90
- }),
91
- values
92
- };
93
- }
15
+ import { t as validateCPF } from "./cpf-DDXMTLYr.esm.js";
16
+ import { n as hasAllowedCharacters } from "./allowedCharacters-Bnir--CN.esm.js";
94
17
  const brStateOptions = Object.values({
95
18
  AC: {
96
19
  code: "AC",
@@ -212,6 +135,336 @@ const CHARACTER_CLASSES = [
212
135
  "space"
213
136
  ];
214
137
  //#endregion
138
+ //#region src/shared/phoneFormat.ts
139
+ /**
140
+ * The phone in E.164, or the value as typed when the rules are not loaded
141
+ * (`loadPhoneValidation()`) or the number is not valid.
142
+ */
143
+ function formatPhoneE164(phone, country) {
144
+ return getPhoneValidation()?.formatE164(phone, country) ?? phone;
145
+ }
146
+ //#endregion
147
+ //#region src/modules/ekyc/ekycValidators.ts
148
+ async function loadPhoneValidator() {
149
+ if (!await loadPhoneValidation()) throw new Error("Failed to load the phone validation rules");
150
+ }
151
+ /** Progressively formats an SSN as XXX-XX-XXXX */
152
+ function formatSSN(value) {
153
+ const ssn = value?.replace(/\D/g, "") ?? "";
154
+ if (ssn.length < 4) return ssn;
155
+ if (ssn.length < 6) return `${ssn.slice(0, 3)}-${ssn.slice(3)}`;
156
+ return `${ssn.slice(0, 3)}-${ssn.slice(3, 5)}-${ssn.slice(5, 9)}`;
157
+ }
158
+ /**
159
+ * Strips characters a name can't contain, as the user types. Keeps everything
160
+ * `nameCharacters` allows (letters from any script with their combining marks,
161
+ * spaces, hyphens, and straight or typographic apostrophes), plus the commas
162
+ * and acute accents (´) SDKv1 kept, so it never strips a valid name.
163
+ */
164
+ function cleanName(name) {
165
+ return (name ?? "").replace(/[^\p{L}\p{M}\s,'’´-]/gu, "").slice(0, 100);
166
+ }
167
+ function validatePhone(phone, country) {
168
+ return getPhoneValidation()?.isValid(phone, country) ?? false;
169
+ }
170
+ /** The phone's national significant number, or the value as typed. */
171
+ function formatPhoneNational(phone, country) {
172
+ return getPhoneValidation()?.nationalNumber(phone, country) ?? phone;
173
+ }
174
+ /** The error key a `oneOfRequired` group shows: its own message, or DOB-or-SSN. */
175
+ const oneOfRequiredErrorKey = (rule) => rule.message ?? "verification.errors.dobOrSsnRequired";
176
+ const PHONE_INVALID_KEY = "verification.errors.phoneInvalid";
177
+ const INVALID_ID_NUMBER_KEY = "verification.errors.invalidIdNumber";
178
+ /**
179
+ * A national ID check: blank passes, anything else must satisfy `isValid`.
180
+ * The error is the vocabulary's message for these rules; a definition names
181
+ * its own with the rule's `message`.
182
+ */
183
+ const idNumberValidator = (isValid) => (value) => {
184
+ if (value.trim().length === 0) return void 0;
185
+ if (isValid(value)) return void 0;
186
+ return { key: INVALID_ID_NUMBER_KEY };
187
+ };
188
+ const normalizeFieldValue = (value) => typeof value === "string" ? value : String(value ?? "");
189
+ const SSN_FORMAT_REGEX = /^\d{3}-\d{2}-\d{4}$/;
190
+ const requiredError = (field) => {
191
+ const fieldName = field.displayLabel ?? field.label;
192
+ return fieldName ? {
193
+ key: DYNAMIC_REQUIRED_KEY,
194
+ params: { fieldName }
195
+ } : { key: DYNAMIC_REQUIRED_KEY };
196
+ };
197
+ const isFilled = (values, name) => normalizeFieldValue(values[name]).trim().length > 0;
198
+ const createValidators = () => {
199
+ const validators = {
200
+ required: (value, _rule, field) => {
201
+ if (value.trim().length > 0) return void 0;
202
+ return requiredError(field);
203
+ },
204
+ requiredIfFilled: (value, rule, field, values) => {
205
+ if (rule.type !== "requiredIfFilled") return void 0;
206
+ if (value.trim().length > 0) return void 0;
207
+ return rule.fields.some((name) => isFilled(values, name)) ? requiredError(field) : void 0;
208
+ },
209
+ rulesByOption: (value, rule, field, values) => {
210
+ if (rule.type !== "rulesByOption") return void 0;
211
+ if (value.trim().length === 0) return void 0;
212
+ const option = normalizeFieldValue(values[rule.selector]).trim();
213
+ const rules = Object.prototype.hasOwnProperty.call(rule.cases, option) ? rule.cases[option] : void 0;
214
+ return evaluateRules(value, rules, field, values, validators);
215
+ },
216
+ streetLevelRequired: (value) => {
217
+ if (value.trim().length > 0) return void 0;
218
+ return STREET_LEVEL_REQUIRED_ERROR;
219
+ },
220
+ cpf: (value) => {
221
+ if (value.trim().length === 0) return void 0;
222
+ return validateCPF(value) ? void 0 : { key: "verification.errors.invalidTaxId" };
223
+ },
224
+ ssnFormat: (value) => {
225
+ if (value.trim().length === 0) return void 0;
226
+ return SSN_FORMAT_REGEX.test(value) ? void 0 : { key: "verification.errors.ssnFormat" };
227
+ },
228
+ noPoBox: (value) => {
229
+ if (value.trim().length === 0) return void 0;
230
+ return isPoBox(value) ? { key: "verification.errors.poBox" } : void 0;
231
+ },
232
+ postalCodeFormat: (value, rule) => {
233
+ if (rule.type !== "postalCodeFormat") return void 0;
234
+ if (value.trim().length === 0) return void 0;
235
+ if (validatePostalCode(value, rule.country)) return void 0;
236
+ return {
237
+ key: getPostalCodeErrorKey(rule.country),
238
+ params: getPostalCodeErrorParams(rule.country)
239
+ };
240
+ },
241
+ phoneFormat: (value, rule) => {
242
+ if (rule.type !== "phoneFormat") return void 0;
243
+ const trimmed = value.trim();
244
+ if (rule.optional && trimmed.length === 0) return void 0;
245
+ return validatePhone(trimmed, rule.country) ? void 0 : { key: "verification.errors.phoneInvalid" };
246
+ },
247
+ emailFormat: (value) => {
248
+ if (value.trim().length === 0) return void 0;
249
+ return isEmailFormat(value) ? void 0 : { key: "verification.errors.emailInvalid" };
250
+ },
251
+ exactLength: (value, rule) => {
252
+ if (rule.type !== "exactLength") return void 0;
253
+ if (value.trim().length === 0) return void 0;
254
+ return value.length === rule.length ? void 0 : { key: "verification.errors.exactly10Characters" };
255
+ },
256
+ nameCharacters: (value) => {
257
+ if (value.trim().length === 0) return void 0;
258
+ return hasNameCharacters(value.trim()) ? void 0 : { key: "verification.errors.nameCharacters" };
259
+ },
260
+ notFuture: (value) => {
261
+ if (value.trim().length === 0) return void 0;
262
+ return isNotFuture(value.trim(), getLocalIsoDate()) ? void 0 : { key: "verification.errors.futureDate" };
263
+ },
264
+ maxAge: (value, rule) => {
265
+ if (rule.type !== "maxAge") return void 0;
266
+ if (value.trim().length === 0) return void 0;
267
+ return isWithinMaxAge(value.trim(), getLocalIsoDate(), rule.years) ? void 0 : { key: "verification.errors.dateOfBirthMaxAge" };
268
+ },
269
+ phoneDigits: (value, rule) => {
270
+ if (rule.type !== "phoneDigits") return void 0;
271
+ const trimmed = value.trim();
272
+ if (trimmed.length === 0) return void 0;
273
+ const national = getPhoneValidation()?.nationalNumber(trimmed, rule.country);
274
+ if (!national) return { key: PHONE_INVALID_KEY };
275
+ return national.length >= rule.min && national.length <= rule.max ? void 0 : { key: PHONE_INVALID_KEY };
276
+ },
277
+ digitCount: (value, rule) => {
278
+ if (rule.type !== "digitCount") return void 0;
279
+ if (value.trim().length === 0) return void 0;
280
+ return hasDigitCount(value.trim(), rule) ? void 0 : digitCountError(rule);
281
+ },
282
+ allowedCharacters: (value, rule) => {
283
+ if (rule.type !== "allowedCharacters") return void 0;
284
+ if (value.trim().length === 0) return void 0;
285
+ return hasAllowedCharacters(value.trim(), rule.classes, rule.extra) ? void 0 : { key: "verification.errors.invalidCharacters" };
286
+ },
287
+ charTemplate: (value, rule) => {
288
+ if (rule.type !== "charTemplate") return void 0;
289
+ if (value.trim().length === 0) return void 0;
290
+ return matchesCharTemplate(value.trim(), rule.templates, rule.ignoreCase) ? void 0 : { key: "verification.errors.invalidFormat" };
291
+ },
292
+ numericRange: (value, rule) => {
293
+ if (rule.type !== "numericRange") return void 0;
294
+ if (value.trim().length === 0) return void 0;
295
+ return isInNumericRange(value.trim(), rule.min, rule.max) ? void 0 : {
296
+ key: "verification.errors.numberBetween",
297
+ params: {
298
+ min: rule.min,
299
+ max: rule.max
300
+ }
301
+ };
302
+ },
303
+ rut: idNumberValidator(isValidRut),
304
+ esDni: idNumberValidator(isValidEsDni),
305
+ fiPersonalIdentityCode: idNumberValidator(isValidFiPersonalIdentityCode),
306
+ inDrivingLicenseNumber: idNumberValidator(isValidInDrivingLicenseNumber),
307
+ curp: idNumberValidator((value) => isValidCurp(value.trim())),
308
+ oneOfRequired: (_value, rule, _field, values) => {
309
+ if (rule.type !== "oneOfRequired") return void 0;
310
+ return rule.fields.some((name) => isFilled(values, name)) ? void 0 : { key: oneOfRequiredErrorKey(rule) };
311
+ }
312
+ };
313
+ return validators;
314
+ };
315
+ /**
316
+ * A rule's own message key shows instead of the validator's, keeping its
317
+ * params. `oneOfRequired` already shows its message.
318
+ */
319
+ const withRuleMessage = (error, rule) => !rule.message || error.key === rule.message ? error : {
320
+ ...error,
321
+ key: rule.message
322
+ };
323
+ const evaluateRules = (value, rules, field, values, validators) => {
324
+ const dateError = field.type === "date" ? calendarDateError(value.trim()) : void 0;
325
+ if (dateError) return { key: dateError };
326
+ if (!rules) return void 0;
327
+ for (const rule of rules) {
328
+ const error = validators[rule.type](value, rule, field, values);
329
+ if (error) return withRuleMessage(error, rule);
330
+ }
331
+ };
332
+ function validateEkycForm(values, fields) {
333
+ const validators = createValidators();
334
+ return fields.reduce((errors, field) => {
335
+ const value = normalizeFieldValue(values[field.name]);
336
+ const error = evaluateRules(value, field.validation, field, values, validators);
337
+ if (error) errors[field.name] = error;
338
+ return errors;
339
+ }, {});
340
+ }
341
+ function validateEkycField(values, fieldName, fields) {
342
+ const field = fields.find((f) => f.name === fieldName);
343
+ if (!field) return void 0;
344
+ const validators = createValidators();
345
+ const value = normalizeFieldValue(values[field.name]);
346
+ return evaluateRules(value, field.validation, field, values, validators);
347
+ }
348
+ //#endregion
349
+ //#region src/modules/ekyc/ekycPrefill.ts
350
+ /**
351
+ * eKYC prefill data for form definitions: turns the `ocr-data` and
352
+ * `otp-status` responses into values keyed by the vocabulary's prefill source
353
+ * ids (`document.firstName`, `phoneModule.phone`, …). The forms kernel then
354
+ * decides which of them a field uses and how it shows (`resolvePrefill`).
355
+ */
356
+ const dateFormatting = new DateFormattingProvider();
357
+ const fromSuggestion = (suggestion) => ({
358
+ street: suggestion.street,
359
+ houseNumber: suggestion.houseNumber,
360
+ city: suggestion.city,
361
+ state: suggestion.stateCode,
362
+ postalCode: suggestion.postalCode
363
+ });
364
+ const DRIVERS_LICENSE = "DriversLicense";
365
+ /** OCR sends some dates as epoch milliseconds in a string, such as `issuedAt`. */
366
+ const epochMs = (value) => typeof value === "string" && /^\d+$/.test(value) ? Number(value) : value;
367
+ const US_STATE_CODES = Object.fromEntries(Object.values(usStates).flatMap(({ code, name }) => [[code, code], [name.toUpperCase(), code]]));
368
+ /** A US state code or name as its code, such as `California` → `CA`. */
369
+ function usStateCode(value) {
370
+ return value ? US_STATE_CODES[value.trim().toUpperCase()] : void 0;
371
+ }
372
+ /**
373
+ * The first name and surname of a scanned document. Uses the OCR's
374
+ * `firstName` / `paternalLastName`. Only when OCR sent no name part at all does
375
+ * it split `fullName`, which is all some documents send (the Indian PAN card):
376
+ * the last word is the surname and the words before it the first name, so a
377
+ * middle name is kept. Any name part blocks the split, because the other
378
+ * sources still fill `middleName` / `maternalLastName` from those parts and a
379
+ * split would repeat them or replace a part OCR did send. A one-word
380
+ * `fullName` gives no surname.
381
+ */
382
+ function resolveOcrName(name) {
383
+ const firstName = name?.firstName?.trim() ?? "";
384
+ const surName = name?.paternalLastName?.trim() ?? "";
385
+ const hasNameParts = Boolean(firstName || surName || name?.middleName?.trim() || name?.maternalLastName?.trim());
386
+ const words = name?.fullName?.trim().split(/\s+/).filter(Boolean) ?? [];
387
+ if (hasNameParts || words.length < 2) return {
388
+ firstName,
389
+ surName
390
+ };
391
+ return {
392
+ firstName: words.slice(0, -1).join(" "),
393
+ surName: words[words.length - 1]
394
+ };
395
+ }
396
+ /** The proof-of-address statement address, whichever shape it came in. */
397
+ function statementAddress(ocr) {
398
+ const fromStatement = ocr.addressFromStatement;
399
+ const parsed = typeof fromStatement === "object" ? fromStatement : void 0;
400
+ const fields = ocr.addressFieldsFromStatement;
401
+ return {
402
+ label: parsed?.address ?? (typeof fromStatement === "string" ? fromStatement : void 0) ?? fields?.label,
403
+ street: parsed?.street ?? fields?.street,
404
+ houseNumber: parsed?.houseNumber ?? fields?.houseNumber,
405
+ city: parsed?.city ?? fields?.city,
406
+ state: parsed?.state ?? fields?.state,
407
+ postalCode: parsed?.postalCode ?? fields?.postalCode
408
+ };
409
+ }
410
+ /** The address search queries to try for each origin, in order. */
411
+ function prefillAddressQueries(ocr) {
412
+ if (!ocr) return {
413
+ document: [],
414
+ poa: []
415
+ };
416
+ const documentQueries = ocr.addressFields || ocr.checkedAddressBean ? [ocr.address, ocr.checkedAddress] : [];
417
+ return {
418
+ document: [...new Set(documentQueries.filter((q) => Boolean(q)))],
419
+ poa: [statementAddress(ocr).label].filter((q) => Boolean(q))
420
+ };
421
+ }
422
+ function addressEntries(origin, parts) {
423
+ return [
424
+ [`${origin}.street`, parts.street],
425
+ [`${origin}.houseNumber`, parts.houseNumber],
426
+ [`${origin}.city`, parts.city],
427
+ [`${origin}.state`, parts.state],
428
+ [`${origin}.postalCode`, parts.postalCode]
429
+ ];
430
+ }
431
+ /** Each prefill source id this module can fill, and how. */
432
+ const SOURCES = {
433
+ "document.firstName": (ocr) => resolveOcrName(ocr.name).firstName,
434
+ "document.middleName": (ocr) => ocr.name?.middleName,
435
+ "document.paternalLastName": (ocr) => resolveOcrName(ocr.name).surName,
436
+ "document.maternalLastName": (ocr) => ocr.name?.maternalLastName,
437
+ "document.birthDate": (ocr) => dateFormatting.utcToIsoDateString(ocr.birthDate),
438
+ "document.issueDate": (ocr) => dateFormatting.utcToIsoDateString(epochMs(ocr.issuedAt)),
439
+ "document.documentNumber": (ocr) => ocr.documentNumber,
440
+ "document.personalNumber": (ocr) => ocr.personalNumber,
441
+ "document.driversLicenseNumber": (ocr) => ocr.typeOfId === DRIVERS_LICENSE ? ocr.documentNumber : void 0,
442
+ "document.driversLicenseState": (ocr) => ocr.typeOfId === DRIVERS_LICENSE ? usStateCode(ocr.issuingState) : void 0,
443
+ "poa.firstName": (ocr) => ocr.poaName?.trim().split(/\s+/)[0],
444
+ "poa.lastName": (ocr) => ocr.poaName?.trim().split(/\s+/).slice(1).join(" ") || void 0,
445
+ "phoneModule.phone": (_ocr, otp) => otp.phone,
446
+ "emailModule.email": (_ocr, otp) => otp.email
447
+ };
448
+ const ADDRESS_SOURCES = [...addressEntries("document", {}), ...addressEntries("poa", {})].map(([id]) => id);
449
+ /** Every prefill source id eKYC can fill, for `EKYC_SUPPORTED_IDS`. */
450
+ const EKYC_PREFILL_SOURCES = [...Object.keys(SOURCES), ...ADDRESS_SOURCES];
451
+ /**
452
+ * The session's prefill values by source id. An address comes from its
453
+ * suggestion when one was found, otherwise from the OCR address fields.
454
+ */
455
+ function buildPrefillData(ocr, otp, matches = {}) {
456
+ const ocrData = ocr ?? {};
457
+ const otpData = otp ?? {};
458
+ const documentAddress = matches.document ? fromSuggestion(matches.document) : ocrData.addressFields ?? ocrData.checkedAddressBean ?? {};
459
+ const poaAddress = matches.poa ? fromSuggestion(matches.poa) : statementAddress(ocrData);
460
+ const entries = [
461
+ ...Object.entries(SOURCES).map(([id, read]) => [id, read(ocrData, otpData, matches)]),
462
+ ...addressEntries("document", documentAddress),
463
+ ...addressEntries("poa", poaAddress)
464
+ ];
465
+ return Object.fromEntries(entries.filter(([, value]) => Boolean(value)));
466
+ }
467
+ //#endregion
215
468
  //#region ../form-definitions/generated/ekyc.ts
216
469
  const EKYC_DEFINITIONS = {
217
470
  "ekyc/AR/AR_CREDIT_BUR_1": {
@@ -282,6 +535,7 @@ const EKYC_DEFINITIONS = {
282
535
  kind: "text",
283
536
  group: "email",
284
537
  required: true,
538
+ requiredWhen: [{ riskAddon: "emailCheck" }],
285
539
  label: { key: "verification.labels.email" },
286
540
  placeholder: { key: "verification.placeholder.email" },
287
541
  input: {
@@ -295,6 +549,11 @@ const EKYC_DEFINITIONS = {
295
549
  name: "phone",
296
550
  kind: "phone",
297
551
  group: "phone",
552
+ requiredWhen: [
553
+ { riskAddon: "phoneCheck" },
554
+ { riskAddon: "advancedPhoneCheck" },
555
+ { riskAddon: "phoneProfile" }
556
+ ],
298
557
  label: { key: "verification.labels.phone" },
299
558
  input: { autofill: "phone" },
300
559
  phone: { lockCountry: true },
@@ -489,6 +748,7 @@ const EKYC_DEFINITIONS = {
489
748
  kind: "text",
490
749
  group: "email",
491
750
  required: true,
751
+ requiredWhen: [{ riskAddon: "emailCheck" }],
492
752
  label: { key: "verification.labels.email" },
493
753
  placeholder: { key: "verification.placeholder.email" },
494
754
  input: {
@@ -503,6 +763,11 @@ const EKYC_DEFINITIONS = {
503
763
  kind: "phone",
504
764
  group: "phone",
505
765
  required: true,
766
+ requiredWhen: [
767
+ { riskAddon: "phoneCheck" },
768
+ { riskAddon: "advancedPhoneCheck" },
769
+ { riskAddon: "phoneProfile" }
770
+ ],
506
771
  label: { key: "verification.labels.phone" },
507
772
  input: { autofill: "phone" },
508
773
  phone: { lockCountry: "whenPhoneRisk" },
@@ -541,6 +806,7 @@ const EKYC_DEFINITIONS = {
541
806
  group: "address",
542
807
  section: "address",
543
808
  label: { key: "verification.labels.houseNo" },
809
+ payload: { key: "streetNo" },
544
810
  prefill: ["document.houseNumber", "poa.houseNumber"]
545
811
  },
546
812
  {
@@ -647,6 +913,7 @@ const EKYC_DEFINITIONS = {
647
913
  kind: "text",
648
914
  group: "email",
649
915
  required: true,
916
+ requiredWhen: [{ riskAddon: "emailCheck" }],
650
917
  label: { key: "verification.labels.email" },
651
918
  placeholder: { key: "verification.placeholder.email" },
652
919
  input: {
@@ -661,6 +928,11 @@ const EKYC_DEFINITIONS = {
661
928
  kind: "phone",
662
929
  group: "phone",
663
930
  required: true,
931
+ requiredWhen: [
932
+ { riskAddon: "phoneCheck" },
933
+ { riskAddon: "advancedPhoneCheck" },
934
+ { riskAddon: "phoneProfile" }
935
+ ],
664
936
  label: { key: "verification.labels.phone" },
665
937
  input: { autofill: "phone" },
666
938
  phone: { lockCountry: true },
@@ -811,6 +1083,7 @@ const EKYC_DEFINITIONS = {
811
1083
  kind: "text",
812
1084
  group: "email",
813
1085
  required: true,
1086
+ requiredWhen: [{ riskAddon: "emailCheck" }],
814
1087
  label: { key: "verification.labels.email" },
815
1088
  placeholder: { key: "verification.placeholder.email" },
816
1089
  input: {
@@ -825,6 +1098,11 @@ const EKYC_DEFINITIONS = {
825
1098
  kind: "phone",
826
1099
  group: "phone",
827
1100
  required: true,
1101
+ requiredWhen: [
1102
+ { riskAddon: "phoneCheck" },
1103
+ { riskAddon: "advancedPhoneCheck" },
1104
+ { riskAddon: "phoneProfile" }
1105
+ ],
828
1106
  label: { key: "verification.labels.phone" },
829
1107
  input: { autofill: "phone" },
830
1108
  phone: { lockCountry: "whenPhoneRisk" },
@@ -1003,6 +1281,7 @@ const EKYC_DEFINITIONS = {
1003
1281
  name: "email",
1004
1282
  kind: "text",
1005
1283
  group: "email",
1284
+ requiredWhen: [{ riskAddon: "emailCheck" }],
1006
1285
  label: { key: "verification.labels.email" },
1007
1286
  placeholder: { key: "verification.placeholder.email" },
1008
1287
  input: {
@@ -1016,6 +1295,11 @@ const EKYC_DEFINITIONS = {
1016
1295
  name: "phone",
1017
1296
  kind: "phone",
1018
1297
  group: "phone",
1298
+ requiredWhen: [
1299
+ { riskAddon: "phoneCheck" },
1300
+ { riskAddon: "advancedPhoneCheck" },
1301
+ { riskAddon: "phoneProfile" }
1302
+ ],
1019
1303
  label: { key: "verification.labels.phone" },
1020
1304
  input: { autofill: "phone" },
1021
1305
  phone: { lockCountry: true },
@@ -1038,7 +1322,8 @@ const EKYC_DEFINITIONS = {
1038
1322
  key: "verification.labels.cpf",
1039
1323
  text: "CPF"
1040
1324
  },
1041
- rules: [{ id: "cpf" }]
1325
+ rules: [{ id: "cpf" }],
1326
+ payload: { key: "idNum" }
1042
1327
  },
1043
1328
  {
1044
1329
  name: "gender",
@@ -1190,6 +1475,7 @@ const EKYC_DEFINITIONS = {
1190
1475
  kind: "text",
1191
1476
  group: "email",
1192
1477
  required: true,
1478
+ requiredWhen: [{ riskAddon: "emailCheck" }],
1193
1479
  label: { key: "verification.labels.email" },
1194
1480
  placeholder: { key: "verification.placeholder.email" },
1195
1481
  input: {
@@ -1204,6 +1490,11 @@ const EKYC_DEFINITIONS = {
1204
1490
  kind: "phone",
1205
1491
  group: "phone",
1206
1492
  required: true,
1493
+ requiredWhen: [
1494
+ { riskAddon: "phoneCheck" },
1495
+ { riskAddon: "advancedPhoneCheck" },
1496
+ { riskAddon: "phoneProfile" }
1497
+ ],
1207
1498
  label: { key: "verification.labels.phone" },
1208
1499
  input: { autofill: "phone" },
1209
1500
  phone: { lockCountry: "whenPhoneRisk" },
@@ -1352,6 +1643,7 @@ const EKYC_DEFINITIONS = {
1352
1643
  kind: "text",
1353
1644
  group: "email",
1354
1645
  required: true,
1646
+ requiredWhen: [{ riskAddon: "emailCheck" }],
1355
1647
  label: { key: "verification.labels.email" },
1356
1648
  placeholder: { key: "verification.placeholder.email" },
1357
1649
  input: {
@@ -1365,6 +1657,11 @@ const EKYC_DEFINITIONS = {
1365
1657
  name: "phone",
1366
1658
  kind: "phone",
1367
1659
  group: "phone",
1660
+ requiredWhen: [
1661
+ { riskAddon: "phoneCheck" },
1662
+ { riskAddon: "advancedPhoneCheck" },
1663
+ { riskAddon: "phoneProfile" }
1664
+ ],
1368
1665
  label: { key: "verification.labels.phone" },
1369
1666
  input: { autofill: "phone" },
1370
1667
  phone: { lockCountry: true },
@@ -1520,6 +1817,7 @@ const EKYC_DEFINITIONS = {
1520
1817
  kind: "text",
1521
1818
  group: "email",
1522
1819
  required: true,
1820
+ requiredWhen: [{ riskAddon: "emailCheck" }],
1523
1821
  label: { key: "verification.labels.email" },
1524
1822
  placeholder: { key: "verification.placeholder.email" },
1525
1823
  input: {
@@ -1534,6 +1832,11 @@ const EKYC_DEFINITIONS = {
1534
1832
  kind: "phone",
1535
1833
  group: "phone",
1536
1834
  required: true,
1835
+ requiredWhen: [
1836
+ { riskAddon: "phoneCheck" },
1837
+ { riskAddon: "advancedPhoneCheck" },
1838
+ { riskAddon: "phoneProfile" }
1839
+ ],
1537
1840
  label: { key: "verification.labels.phone" },
1538
1841
  input: { autofill: "phone" },
1539
1842
  phone: { lockCountry: true },
@@ -1647,6 +1950,7 @@ const EKYC_DEFINITIONS = {
1647
1950
  kind: "text",
1648
1951
  group: "email",
1649
1952
  required: true,
1953
+ requiredWhen: [{ riskAddon: "emailCheck" }],
1650
1954
  label: { key: "verification.labels.email" },
1651
1955
  placeholder: { key: "verification.placeholder.email" },
1652
1956
  input: {
@@ -1661,6 +1965,11 @@ const EKYC_DEFINITIONS = {
1661
1965
  kind: "phone",
1662
1966
  group: "phone",
1663
1967
  required: true,
1968
+ requiredWhen: [
1969
+ { riskAddon: "phoneCheck" },
1970
+ { riskAddon: "advancedPhoneCheck" },
1971
+ { riskAddon: "phoneProfile" }
1972
+ ],
1664
1973
  label: { key: "verification.labels.phone" },
1665
1974
  input: { autofill: "phone" },
1666
1975
  phone: { lockCountry: "whenPhoneRisk" },
@@ -1761,6 +2070,7 @@ const EKYC_DEFINITIONS = {
1761
2070
  kind: "text",
1762
2071
  group: "email",
1763
2072
  required: true,
2073
+ requiredWhen: [{ riskAddon: "emailCheck" }],
1764
2074
  label: { key: "verification.labels.email" },
1765
2075
  placeholder: { key: "verification.placeholder.email" },
1766
2076
  input: {
@@ -1775,6 +2085,11 @@ const EKYC_DEFINITIONS = {
1775
2085
  kind: "phone",
1776
2086
  group: "phone",
1777
2087
  required: true,
2088
+ requiredWhen: [
2089
+ { riskAddon: "phoneCheck" },
2090
+ { riskAddon: "advancedPhoneCheck" },
2091
+ { riskAddon: "phoneProfile" }
2092
+ ],
1778
2093
  label: { key: "verification.labels.phone" },
1779
2094
  input: { autofill: "phone" },
1780
2095
  phone: { lockCountry: "whenPhoneRisk" },
@@ -1898,6 +2213,7 @@ const EKYC_DEFINITIONS = {
1898
2213
  kind: "text",
1899
2214
  group: "email",
1900
2215
  required: true,
2216
+ requiredWhen: [{ riskAddon: "emailCheck" }],
1901
2217
  label: { key: "verification.labels.email" },
1902
2218
  placeholder: { key: "verification.placeholder.email" },
1903
2219
  input: {
@@ -1911,6 +2227,11 @@ const EKYC_DEFINITIONS = {
1911
2227
  name: "phone",
1912
2228
  kind: "phone",
1913
2229
  group: "phone",
2230
+ requiredWhen: [
2231
+ { riskAddon: "phoneCheck" },
2232
+ { riskAddon: "advancedPhoneCheck" },
2233
+ { riskAddon: "phoneProfile" }
2234
+ ],
1914
2235
  label: { key: "verification.labels.phone" },
1915
2236
  input: { autofill: "phone" },
1916
2237
  phone: { lockCountry: true },
@@ -2032,6 +2353,7 @@ const EKYC_DEFINITIONS = {
2032
2353
  kind: "text",
2033
2354
  group: "email",
2034
2355
  required: true,
2356
+ requiredWhen: [{ riskAddon: "emailCheck" }],
2035
2357
  label: { key: "verification.labels.email" },
2036
2358
  placeholder: { key: "verification.placeholder.email" },
2037
2359
  input: {
@@ -2046,6 +2368,11 @@ const EKYC_DEFINITIONS = {
2046
2368
  kind: "phone",
2047
2369
  group: "phone",
2048
2370
  required: true,
2371
+ requiredWhen: [
2372
+ { riskAddon: "phoneCheck" },
2373
+ { riskAddon: "advancedPhoneCheck" },
2374
+ { riskAddon: "phoneProfile" }
2375
+ ],
2049
2376
  label: { key: "verification.labels.phone" },
2050
2377
  input: { autofill: "phone" },
2051
2378
  phone: { lockCountry: true },
@@ -2172,6 +2499,7 @@ const EKYC_DEFINITIONS = {
2172
2499
  kind: "text",
2173
2500
  group: "email",
2174
2501
  required: true,
2502
+ requiredWhen: [{ riskAddon: "emailCheck" }],
2175
2503
  label: { key: "verification.labels.email" },
2176
2504
  placeholder: { key: "verification.placeholder.email" },
2177
2505
  input: {
@@ -2185,6 +2513,11 @@ const EKYC_DEFINITIONS = {
2185
2513
  name: "phone",
2186
2514
  kind: "phone",
2187
2515
  group: "phone",
2516
+ requiredWhen: [
2517
+ { riskAddon: "phoneCheck" },
2518
+ { riskAddon: "advancedPhoneCheck" },
2519
+ { riskAddon: "phoneProfile" }
2520
+ ],
2188
2521
  label: { key: "verification.labels.phone" },
2189
2522
  input: { autofill: "phone" },
2190
2523
  phone: { lockCountry: true },
@@ -2337,6 +2670,7 @@ const EKYC_DEFINITIONS = {
2337
2670
  name: "email",
2338
2671
  kind: "text",
2339
2672
  group: "email",
2673
+ requiredWhen: [{ riskAddon: "emailCheck" }],
2340
2674
  label: { key: "verification.labels.email" },
2341
2675
  placeholder: { key: "verification.placeholder.email" },
2342
2676
  input: {
@@ -2351,6 +2685,11 @@ const EKYC_DEFINITIONS = {
2351
2685
  kind: "phone",
2352
2686
  group: "phone",
2353
2687
  required: true,
2688
+ requiredWhen: [
2689
+ { riskAddon: "phoneCheck" },
2690
+ { riskAddon: "advancedPhoneCheck" },
2691
+ { riskAddon: "phoneProfile" }
2692
+ ],
2354
2693
  label: { key: "verification.labels.phone" },
2355
2694
  input: { autofill: "phone" },
2356
2695
  phone: { lockCountry: true },
@@ -2491,6 +2830,7 @@ const EKYC_DEFINITIONS = {
2491
2830
  kind: "text",
2492
2831
  group: "email",
2493
2832
  required: true,
2833
+ requiredWhen: [{ riskAddon: "emailCheck" }],
2494
2834
  label: { key: "verification.labels.email" },
2495
2835
  placeholder: { key: "verification.placeholder.email" },
2496
2836
  input: {
@@ -2505,6 +2845,11 @@ const EKYC_DEFINITIONS = {
2505
2845
  kind: "phone",
2506
2846
  group: "phone",
2507
2847
  required: true,
2848
+ requiredWhen: [
2849
+ { riskAddon: "phoneCheck" },
2850
+ { riskAddon: "advancedPhoneCheck" },
2851
+ { riskAddon: "phoneProfile" }
2852
+ ],
2508
2853
  label: { key: "verification.labels.phone" },
2509
2854
  input: { autofill: "phone" },
2510
2855
  phone: { lockCountry: "whenPhoneRisk" },
@@ -2642,6 +2987,7 @@ const EKYC_DEFINITIONS = {
2642
2987
  kind: "text",
2643
2988
  group: "email",
2644
2989
  required: true,
2990
+ requiredWhen: [{ riskAddon: "emailCheck" }],
2645
2991
  label: { key: "verification.labels.email" },
2646
2992
  placeholder: { key: "verification.placeholder.email" },
2647
2993
  input: {
@@ -2656,6 +3002,11 @@ const EKYC_DEFINITIONS = {
2656
3002
  kind: "phone",
2657
3003
  group: "phone",
2658
3004
  required: true,
3005
+ requiredWhen: [
3006
+ { riskAddon: "phoneCheck" },
3007
+ { riskAddon: "advancedPhoneCheck" },
3008
+ { riskAddon: "phoneProfile" }
3009
+ ],
2659
3010
  label: { key: "verification.labels.phone" },
2660
3011
  input: { autofill: "phone" },
2661
3012
  phone: { lockCountry: "whenPhoneRisk" },
@@ -2809,6 +3160,7 @@ const EKYC_DEFINITIONS = {
2809
3160
  kind: "text",
2810
3161
  group: "email",
2811
3162
  required: true,
3163
+ requiredWhen: [{ riskAddon: "emailCheck" }],
2812
3164
  label: { key: "verification.labels.email" },
2813
3165
  placeholder: { key: "verification.placeholder.email" },
2814
3166
  input: {
@@ -2822,6 +3174,11 @@ const EKYC_DEFINITIONS = {
2822
3174
  name: "phone",
2823
3175
  kind: "phone",
2824
3176
  group: "phone",
3177
+ requiredWhen: [
3178
+ { riskAddon: "phoneCheck" },
3179
+ { riskAddon: "advancedPhoneCheck" },
3180
+ { riskAddon: "phoneProfile" }
3181
+ ],
2825
3182
  label: { key: "verification.labels.phone" },
2826
3183
  input: { autofill: "phone" },
2827
3184
  phone: { lockCountry: true },
@@ -2866,6 +3223,7 @@ const EKYC_DEFINITIONS = {
2866
3223
  group: "address",
2867
3224
  section: "address",
2868
3225
  label: { key: "verification.labels.houseNo" },
3226
+ payload: { key: "streetNo" },
2869
3227
  prefill: ["document.houseNumber", "poa.houseNumber"]
2870
3228
  },
2871
3229
  {
@@ -2970,6 +3328,7 @@ const EKYC_DEFINITIONS = {
2970
3328
  kind: "text",
2971
3329
  group: "email",
2972
3330
  required: true,
3331
+ requiredWhen: [{ riskAddon: "emailCheck" }],
2973
3332
  label: { key: "verification.labels.email" },
2974
3333
  placeholder: { key: "verification.placeholder.email" },
2975
3334
  input: {
@@ -2983,6 +3342,11 @@ const EKYC_DEFINITIONS = {
2983
3342
  name: "phone",
2984
3343
  kind: "phone",
2985
3344
  group: "phone",
3345
+ requiredWhen: [
3346
+ { riskAddon: "phoneCheck" },
3347
+ { riskAddon: "advancedPhoneCheck" },
3348
+ { riskAddon: "phoneProfile" }
3349
+ ],
2986
3350
  label: { key: "verification.labels.phone" },
2987
3351
  input: { autofill: "phone" },
2988
3352
  phone: { lockCountry: true },
@@ -3152,6 +3516,7 @@ const EKYC_DEFINITIONS = {
3152
3516
  kind: "text",
3153
3517
  group: "email",
3154
3518
  required: true,
3519
+ requiredWhen: [{ riskAddon: "emailCheck" }],
3155
3520
  label: { key: "verification.labels.email" },
3156
3521
  placeholder: { key: "verification.placeholder.email" },
3157
3522
  input: {
@@ -3166,6 +3531,11 @@ const EKYC_DEFINITIONS = {
3166
3531
  kind: "phone",
3167
3532
  group: "phone",
3168
3533
  required: true,
3534
+ requiredWhen: [
3535
+ { riskAddon: "phoneCheck" },
3536
+ { riskAddon: "advancedPhoneCheck" },
3537
+ { riskAddon: "phoneProfile" }
3538
+ ],
3169
3539
  label: { key: "verification.labels.phone" },
3170
3540
  input: { autofill: "phone" },
3171
3541
  phone: { lockCountry: "whenPhoneRisk" },
@@ -3267,6 +3637,7 @@ const EKYC_DEFINITIONS = {
3267
3637
  kind: "text",
3268
3638
  group: "email",
3269
3639
  required: true,
3640
+ requiredWhen: [{ riskAddon: "emailCheck" }],
3270
3641
  label: { key: "verification.labels.email" },
3271
3642
  placeholder: { key: "verification.placeholder.email" },
3272
3643
  input: {
@@ -3281,6 +3652,11 @@ const EKYC_DEFINITIONS = {
3281
3652
  kind: "phone",
3282
3653
  group: "phone",
3283
3654
  required: true,
3655
+ requiredWhen: [
3656
+ { riskAddon: "phoneCheck" },
3657
+ { riskAddon: "advancedPhoneCheck" },
3658
+ { riskAddon: "phoneProfile" }
3659
+ ],
3284
3660
  label: { key: "verification.labels.phone" },
3285
3661
  input: { autofill: "phone" },
3286
3662
  phone: { lockCountry: "whenPhoneRisk" },
@@ -3436,6 +3812,7 @@ const EKYC_DEFINITIONS = {
3436
3812
  kind: "text",
3437
3813
  group: "email",
3438
3814
  required: true,
3815
+ requiredWhen: [{ riskAddon: "emailCheck" }],
3439
3816
  label: { key: "verification.labels.email" },
3440
3817
  placeholder: { key: "verification.placeholder.email" },
3441
3818
  input: {
@@ -3450,6 +3827,11 @@ const EKYC_DEFINITIONS = {
3450
3827
  kind: "phone",
3451
3828
  group: "phone",
3452
3829
  required: true,
3830
+ requiredWhen: [
3831
+ { riskAddon: "phoneCheck" },
3832
+ { riskAddon: "advancedPhoneCheck" },
3833
+ { riskAddon: "phoneProfile" }
3834
+ ],
3453
3835
  label: { key: "verification.labels.phone" },
3454
3836
  input: { autofill: "phone" },
3455
3837
  phone: { lockCountry: "whenPhoneRisk" },
@@ -3794,6 +4176,7 @@ const EKYC_DEFINITIONS = {
3794
4176
  kind: "text",
3795
4177
  group: "email",
3796
4178
  required: true,
4179
+ requiredWhen: [{ riskAddon: "emailCheck" }],
3797
4180
  label: { key: "verification.labels.email" },
3798
4181
  placeholder: { key: "verification.placeholder.email" },
3799
4182
  input: {
@@ -3808,6 +4191,11 @@ const EKYC_DEFINITIONS = {
3808
4191
  kind: "phone",
3809
4192
  group: "phone",
3810
4193
  required: true,
4194
+ requiredWhen: [
4195
+ { riskAddon: "phoneCheck" },
4196
+ { riskAddon: "advancedPhoneCheck" },
4197
+ { riskAddon: "phoneProfile" }
4198
+ ],
3811
4199
  label: { key: "verification.labels.phone" },
3812
4200
  input: { autofill: "phone" },
3813
4201
  phone: { lockCountry: true },
@@ -3926,6 +4314,7 @@ const EKYC_DEFINITIONS = {
3926
4314
  kind: "text",
3927
4315
  group: "email",
3928
4316
  required: true,
4317
+ requiredWhen: [{ riskAddon: "emailCheck" }],
3929
4318
  label: { key: "verification.labels.email" },
3930
4319
  placeholder: { key: "verification.placeholder.email" },
3931
4320
  input: {
@@ -3940,6 +4329,11 @@ const EKYC_DEFINITIONS = {
3940
4329
  kind: "phone",
3941
4330
  group: "phone",
3942
4331
  required: true,
4332
+ requiredWhen: [
4333
+ { riskAddon: "phoneCheck" },
4334
+ { riskAddon: "advancedPhoneCheck" },
4335
+ { riskAddon: "phoneProfile" }
4336
+ ],
3943
4337
  label: { key: "verification.labels.phone" },
3944
4338
  input: { autofill: "phone" },
3945
4339
  phone: { lockCountry: "whenPhoneRisk" },
@@ -3960,7 +4354,7 @@ const EKYC_DEFINITIONS = {
3960
4354
  id: "digitCount",
3961
4355
  params: { lengths: [14] }
3962
4356
  }],
3963
- payload: { key: "idNumber" },
4357
+ payload: { key: "idNum" },
3964
4358
  prefill: ["document.documentNumber"]
3965
4359
  },
3966
4360
  {
@@ -4073,6 +4467,7 @@ const EKYC_DEFINITIONS = {
4073
4467
  kind: "text",
4074
4468
  group: "email",
4075
4469
  required: true,
4470
+ requiredWhen: [{ riskAddon: "emailCheck" }],
4076
4471
  label: { key: "verification.labels.email" },
4077
4472
  placeholder: { key: "verification.placeholder.email" },
4078
4473
  input: {
@@ -4087,6 +4482,11 @@ const EKYC_DEFINITIONS = {
4087
4482
  kind: "phone",
4088
4483
  group: "phone",
4089
4484
  required: true,
4485
+ requiredWhen: [
4486
+ { riskAddon: "phoneCheck" },
4487
+ { riskAddon: "advancedPhoneCheck" },
4488
+ { riskAddon: "phoneProfile" }
4489
+ ],
4090
4490
  label: { key: "verification.labels.phone" },
4091
4491
  input: { autofill: "phone" },
4092
4492
  phone: { lockCountry: "whenPhoneRisk" },
@@ -4192,6 +4592,7 @@ const EKYC_DEFINITIONS = {
4192
4592
  kind: "text",
4193
4593
  group: "email",
4194
4594
  required: true,
4595
+ requiredWhen: [{ riskAddon: "emailCheck" }],
4195
4596
  label: { key: "verification.labels.email" },
4196
4597
  placeholder: { key: "verification.placeholder.email" },
4197
4598
  input: {
@@ -4206,6 +4607,11 @@ const EKYC_DEFINITIONS = {
4206
4607
  kind: "phone",
4207
4608
  group: "phone",
4208
4609
  required: true,
4610
+ requiredWhen: [
4611
+ { riskAddon: "phoneCheck" },
4612
+ { riskAddon: "advancedPhoneCheck" },
4613
+ { riskAddon: "phoneProfile" }
4614
+ ],
4209
4615
  label: { key: "verification.labels.phone" },
4210
4616
  input: { autofill: "phone" },
4211
4617
  phone: { lockCountry: true },
@@ -4318,6 +4724,7 @@ const EKYC_DEFINITIONS = {
4318
4724
  name: "email",
4319
4725
  kind: "text",
4320
4726
  group: "email",
4727
+ requiredWhen: [{ riskAddon: "emailCheck" }],
4321
4728
  label: { key: "verification.labels.email" },
4322
4729
  placeholder: { key: "verification.placeholder.email" },
4323
4730
  input: {
@@ -4332,6 +4739,11 @@ const EKYC_DEFINITIONS = {
4332
4739
  kind: "phone",
4333
4740
  group: "phone",
4334
4741
  required: true,
4742
+ requiredWhen: [
4743
+ { riskAddon: "phoneCheck" },
4744
+ { riskAddon: "advancedPhoneCheck" },
4745
+ { riskAddon: "phoneProfile" }
4746
+ ],
4335
4747
  label: { key: "verification.labels.phone" },
4336
4748
  input: { autofill: "phone" },
4337
4749
  phone: { lockCountry: true },
@@ -4467,6 +4879,7 @@ const EKYC_DEFINITIONS = {
4467
4879
  name: "email",
4468
4880
  kind: "text",
4469
4881
  group: "email",
4882
+ requiredWhen: [{ riskAddon: "emailCheck" }],
4470
4883
  label: { key: "verification.labels.email" },
4471
4884
  placeholder: { key: "verification.placeholder.email" },
4472
4885
  input: {
@@ -4480,6 +4893,11 @@ const EKYC_DEFINITIONS = {
4480
4893
  name: "phone",
4481
4894
  kind: "phone",
4482
4895
  group: "phone",
4896
+ requiredWhen: [
4897
+ { riskAddon: "phoneCheck" },
4898
+ { riskAddon: "advancedPhoneCheck" },
4899
+ { riskAddon: "phoneProfile" }
4900
+ ],
4483
4901
  label: { key: "verification.labels.phone" },
4484
4902
  input: { autofill: "phone" },
4485
4903
  phone: { lockCountry: true },
@@ -4628,6 +5046,7 @@ const EKYC_DEFINITIONS = {
4628
5046
  kind: "text",
4629
5047
  group: "email",
4630
5048
  required: true,
5049
+ requiredWhen: [{ riskAddon: "emailCheck" }],
4631
5050
  label: { key: "verification.labels.email" },
4632
5051
  placeholder: { key: "verification.placeholder.email" },
4633
5052
  input: {
@@ -4642,6 +5061,11 @@ const EKYC_DEFINITIONS = {
4642
5061
  kind: "phone",
4643
5062
  group: "phone",
4644
5063
  required: true,
5064
+ requiredWhen: [
5065
+ { riskAddon: "phoneCheck" },
5066
+ { riskAddon: "advancedPhoneCheck" },
5067
+ { riskAddon: "phoneProfile" }
5068
+ ],
4645
5069
  label: { key: "verification.labels.phone" },
4646
5070
  input: { autofill: "phone" },
4647
5071
  phone: { lockCountry: "whenPhoneRisk" },
@@ -4772,6 +5196,7 @@ const EKYC_DEFINITIONS = {
4772
5196
  kind: "text",
4773
5197
  group: "email",
4774
5198
  required: true,
5199
+ requiredWhen: [{ riskAddon: "emailCheck" }],
4775
5200
  label: { key: "verification.labels.email" },
4776
5201
  placeholder: { key: "verification.placeholder.email" },
4777
5202
  input: {
@@ -4786,6 +5211,11 @@ const EKYC_DEFINITIONS = {
4786
5211
  kind: "phone",
4787
5212
  group: "phone",
4788
5213
  required: true,
5214
+ requiredWhen: [
5215
+ { riskAddon: "phoneCheck" },
5216
+ { riskAddon: "advancedPhoneCheck" },
5217
+ { riskAddon: "phoneProfile" }
5218
+ ],
4789
5219
  label: { key: "verification.labels.phone" },
4790
5220
  input: { autofill: "phone" },
4791
5221
  phone: { lockCountry: "whenPhoneRisk" },
@@ -4971,6 +5401,7 @@ const EKYC_DEFINITIONS = {
4971
5401
  kind: "text",
4972
5402
  group: "email",
4973
5403
  required: true,
5404
+ requiredWhen: [{ riskAddon: "emailCheck" }],
4974
5405
  label: { key: "verification.labels.email" },
4975
5406
  placeholder: { key: "verification.placeholder.email" },
4976
5407
  input: {
@@ -4985,6 +5416,11 @@ const EKYC_DEFINITIONS = {
4985
5416
  kind: "phone",
4986
5417
  group: "phone",
4987
5418
  required: true,
5419
+ requiredWhen: [
5420
+ { riskAddon: "phoneCheck" },
5421
+ { riskAddon: "advancedPhoneCheck" },
5422
+ { riskAddon: "phoneProfile" }
5423
+ ],
4988
5424
  label: { key: "verification.labels.phone" },
4989
5425
  input: { autofill: "phone" },
4990
5426
  phone: { lockCountry: true },
@@ -5100,6 +5536,7 @@ const EKYC_DEFINITIONS = {
5100
5536
  kind: "text",
5101
5537
  group: "email",
5102
5538
  required: true,
5539
+ requiredWhen: [{ riskAddon: "emailCheck" }],
5103
5540
  label: { key: "verification.labels.email" },
5104
5541
  placeholder: { key: "verification.placeholder.email" },
5105
5542
  input: {
@@ -5113,6 +5550,11 @@ const EKYC_DEFINITIONS = {
5113
5550
  name: "phone",
5114
5551
  kind: "phone",
5115
5552
  group: "phone",
5553
+ requiredWhen: [
5554
+ { riskAddon: "phoneCheck" },
5555
+ { riskAddon: "advancedPhoneCheck" },
5556
+ { riskAddon: "phoneProfile" }
5557
+ ],
5116
5558
  label: { key: "verification.labels.phone" },
5117
5559
  input: { autofill: "phone" },
5118
5560
  phone: { lockCountry: true },
@@ -5254,6 +5696,7 @@ const EKYC_DEFINITIONS = {
5254
5696
  kind: "text",
5255
5697
  group: "email",
5256
5698
  required: true,
5699
+ requiredWhen: [{ riskAddon: "emailCheck" }],
5257
5700
  label: { key: "verification.labels.email" },
5258
5701
  placeholder: { key: "verification.placeholder.email" },
5259
5702
  input: {
@@ -5268,6 +5711,11 @@ const EKYC_DEFINITIONS = {
5268
5711
  kind: "phone",
5269
5712
  group: "phone",
5270
5713
  required: true,
5714
+ requiredWhen: [
5715
+ { riskAddon: "phoneCheck" },
5716
+ { riskAddon: "advancedPhoneCheck" },
5717
+ { riskAddon: "phoneProfile" }
5718
+ ],
5271
5719
  label: { key: "verification.labels.phone" },
5272
5720
  input: { autofill: "phone" },
5273
5721
  phone: { lockCountry: "whenPhoneRisk" },
@@ -5405,6 +5853,7 @@ const EKYC_DEFINITIONS = {
5405
5853
  name: "email",
5406
5854
  kind: "text",
5407
5855
  group: "email",
5856
+ requiredWhen: [{ riskAddon: "emailCheck" }],
5408
5857
  label: { key: "verification.labels.email" },
5409
5858
  placeholder: { key: "verification.placeholder.email" },
5410
5859
  input: {
@@ -5419,6 +5868,11 @@ const EKYC_DEFINITIONS = {
5419
5868
  kind: "phone",
5420
5869
  group: "phone",
5421
5870
  required: true,
5871
+ requiredWhen: [
5872
+ { riskAddon: "phoneCheck" },
5873
+ { riskAddon: "advancedPhoneCheck" },
5874
+ { riskAddon: "phoneProfile" }
5875
+ ],
5422
5876
  label: { key: "verification.labels.phone" },
5423
5877
  input: { autofill: "phone" },
5424
5878
  phone: { lockCountry: true },
@@ -5567,6 +6021,7 @@ const EKYC_DEFINITIONS = {
5567
6021
  kind: "text",
5568
6022
  group: "email",
5569
6023
  required: true,
6024
+ requiredWhen: [{ riskAddon: "emailCheck" }],
5570
6025
  label: { key: "verification.labels.email" },
5571
6026
  placeholder: { key: "verification.placeholder.email" },
5572
6027
  input: {
@@ -5581,6 +6036,11 @@ const EKYC_DEFINITIONS = {
5581
6036
  kind: "phone",
5582
6037
  group: "phone",
5583
6038
  required: true,
6039
+ requiredWhen: [
6040
+ { riskAddon: "phoneCheck" },
6041
+ { riskAddon: "advancedPhoneCheck" },
6042
+ { riskAddon: "phoneProfile" }
6043
+ ],
5584
6044
  label: { key: "verification.labels.phone" },
5585
6045
  input: { autofill: "phone" },
5586
6046
  phone: { lockCountry: "whenPhoneRisk" },
@@ -6047,6 +6507,7 @@ const EKYC_DEFINITIONS = {
6047
6507
  name: "email",
6048
6508
  kind: "text",
6049
6509
  group: "email",
6510
+ requiredWhen: [{ riskAddon: "emailCheck" }],
6050
6511
  label: { key: "verification.labels.email" },
6051
6512
  placeholder: { key: "verification.placeholder.email" },
6052
6513
  input: {
@@ -6060,6 +6521,11 @@ const EKYC_DEFINITIONS = {
6060
6521
  name: "phone",
6061
6522
  kind: "phone",
6062
6523
  group: "phone",
6524
+ requiredWhen: [
6525
+ { riskAddon: "phoneCheck" },
6526
+ { riskAddon: "advancedPhoneCheck" },
6527
+ { riskAddon: "phoneProfile" }
6528
+ ],
6063
6529
  label: { key: "verification.labels.phone" },
6064
6530
  input: { autofill: "phone" },
6065
6531
  phone: { lockCountry: true },
@@ -6219,6 +6685,7 @@ const EKYC_DEFINITIONS = {
6219
6685
  name: "email",
6220
6686
  kind: "text",
6221
6687
  group: "email",
6688
+ requiredWhen: [{ riskAddon: "emailCheck" }],
6222
6689
  label: { key: "verification.labels.email" },
6223
6690
  placeholder: { key: "verification.placeholder.email" },
6224
6691
  input: {
@@ -6232,6 +6699,11 @@ const EKYC_DEFINITIONS = {
6232
6699
  name: "phone",
6233
6700
  kind: "phone",
6234
6701
  group: "phone",
6702
+ requiredWhen: [
6703
+ { riskAddon: "phoneCheck" },
6704
+ { riskAddon: "advancedPhoneCheck" },
6705
+ { riskAddon: "phoneProfile" }
6706
+ ],
6235
6707
  label: { key: "verification.labels.phone" },
6236
6708
  input: { autofill: "phone" },
6237
6709
  phone: { lockCountry: true },
@@ -6256,10 +6728,13 @@ const EKYC_DEFINITIONS = {
6256
6728
  keyboard: "numeric"
6257
6729
  },
6258
6730
  rules: [{ id: "ssnFormat" }],
6259
- payload: { transforms: [{
6260
- id: "stripSeparators",
6261
- params: { chars: "-" }
6262
- }] }
6731
+ payload: {
6732
+ transforms: [{
6733
+ id: "stripSeparators",
6734
+ params: { chars: "-" }
6735
+ }],
6736
+ key: "idNumber"
6737
+ }
6263
6738
  },
6264
6739
  {
6265
6740
  name: "street",
@@ -6394,6 +6869,7 @@ const EKYC_DEFINITIONS = {
6394
6869
  kind: "text",
6395
6870
  group: "email",
6396
6871
  required: true,
6872
+ requiredWhen: [{ riskAddon: "emailCheck" }],
6397
6873
  label: { key: "verification.labels.email" },
6398
6874
  placeholder: { key: "verification.placeholder.email" },
6399
6875
  input: {
@@ -6407,6 +6883,11 @@ const EKYC_DEFINITIONS = {
6407
6883
  name: "phone",
6408
6884
  kind: "phone",
6409
6885
  group: "phone",
6886
+ requiredWhen: [
6887
+ { riskAddon: "phoneCheck" },
6888
+ { riskAddon: "advancedPhoneCheck" },
6889
+ { riskAddon: "phoneProfile" }
6890
+ ],
6410
6891
  label: { key: "verification.labels.phone" },
6411
6892
  input: { autofill: "phone" },
6412
6893
  phone: { lockCountry: true },
@@ -6454,7 +6935,10 @@ const EKYC_DEFINITIONS = {
6454
6935
  section: "address",
6455
6936
  label: { key: "verification.labels.apartment" },
6456
6937
  placeholder: { key: "verification.placeholder.apartment" },
6457
- input: { autofill: "addressLine2" }
6938
+ input: {
6939
+ autofill: "addressLine2",
6940
+ maxLength: 20
6941
+ }
6458
6942
  },
6459
6943
  {
6460
6944
  name: "city",
@@ -6562,6 +7046,7 @@ const EKYC_DEFINITIONS = {
6562
7046
  name: "email",
6563
7047
  kind: "text",
6564
7048
  group: "email",
7049
+ requiredWhen: [{ riskAddon: "emailCheck" }],
6565
7050
  label: { key: "verification.labels.email" },
6566
7051
  placeholder: { key: "verification.placeholder.email" },
6567
7052
  input: {
@@ -6576,6 +7061,11 @@ const EKYC_DEFINITIONS = {
6576
7061
  kind: "phone",
6577
7062
  group: "phone",
6578
7063
  required: true,
7064
+ requiredWhen: [
7065
+ { riskAddon: "phoneCheck" },
7066
+ { riskAddon: "advancedPhoneCheck" },
7067
+ { riskAddon: "phoneProfile" }
7068
+ ],
6579
7069
  label: { key: "verification.labels.phone" },
6580
7070
  input: { autofill: "phone" },
6581
7071
  phone: { lockCountry: true },
@@ -6733,6 +7223,7 @@ const EKYC_DEFINITIONS = {
6733
7223
  kind: "text",
6734
7224
  group: "email",
6735
7225
  required: true,
7226
+ requiredWhen: [{ riskAddon: "emailCheck" }],
6736
7227
  label: { key: "verification.labels.email" },
6737
7228
  placeholder: { key: "verification.placeholder.email" },
6738
7229
  input: {
@@ -6747,6 +7238,11 @@ const EKYC_DEFINITIONS = {
6747
7238
  kind: "phone",
6748
7239
  group: "phone",
6749
7240
  required: true,
7241
+ requiredWhen: [
7242
+ { riskAddon: "phoneCheck" },
7243
+ { riskAddon: "advancedPhoneCheck" },
7244
+ { riskAddon: "phoneProfile" }
7245
+ ],
6750
7246
  label: { key: "verification.labels.phone" },
6751
7247
  input: { autofill: "phone" },
6752
7248
  phone: { lockCountry: true },
@@ -6885,6 +7381,7 @@ const EKYC_DEFINITIONS = {
6885
7381
  kind: "text",
6886
7382
  group: "email",
6887
7383
  required: true,
7384
+ requiredWhen: [{ riskAddon: "emailCheck" }],
6888
7385
  label: { key: "verification.labels.email" },
6889
7386
  placeholder: { key: "verification.placeholder.email" },
6890
7387
  input: {
@@ -6899,6 +7396,11 @@ const EKYC_DEFINITIONS = {
6899
7396
  kind: "phone",
6900
7397
  group: "phone",
6901
7398
  required: true,
7399
+ requiredWhen: [
7400
+ { riskAddon: "phoneCheck" },
7401
+ { riskAddon: "advancedPhoneCheck" },
7402
+ { riskAddon: "phoneProfile" }
7403
+ ],
6902
7404
  label: { key: "verification.labels.phone" },
6903
7405
  input: { autofill: "phone" },
6904
7406
  phone: { lockCountry: "whenPhoneRisk" },
@@ -7143,99 +7645,109 @@ const inStateOptions = Object.values({
7143
7645
  label: state.name
7144
7646
  }));
7145
7647
  //#endregion
7146
- //#region src/modules/ekyc/ekycPrefill.ts
7648
+ //#region src/modules/ekyc/ekycRules.ts
7649
+ /** Vocabulary rules expressed as today's `EkycValidationRule` objects. */
7650
+ const RULES = {
7651
+ cpf: () => ({ type: "cpf" }),
7652
+ ssnFormat: () => ({ type: "ssnFormat" }),
7653
+ noPoBox: () => ({ type: "noPoBox" }),
7654
+ emailFormat: () => ({ type: "emailFormat" }),
7655
+ postalCodeFormat: ({ country }) => ({
7656
+ type: "postalCodeFormat",
7657
+ country
7658
+ }),
7659
+ phoneFormat: ({ country, required }) => ({
7660
+ type: "phoneFormat",
7661
+ country,
7662
+ optional: !required
7663
+ }),
7664
+ exactLength: ({ params }) => ({
7665
+ type: "exactLength",
7666
+ length: params.length
7667
+ }),
7668
+ nameCharacters: () => ({ type: "nameCharacters" }),
7669
+ notFuture: () => ({ type: "notFuture" }),
7670
+ maxAge: ({ params }) => ({
7671
+ type: "maxAge",
7672
+ years: params.years
7673
+ }),
7674
+ phoneDigits: ({ country, params }) => ({
7675
+ type: "phoneDigits",
7676
+ country,
7677
+ min: params.min,
7678
+ max: params.max
7679
+ }),
7680
+ digitCount: ({ params }) => ({
7681
+ type: "digitCount",
7682
+ ...params.lengths !== void 0 && { lengths: [...params.lengths] },
7683
+ ...params.min !== void 0 && { min: params.min },
7684
+ ...params.max !== void 0 && { max: params.max }
7685
+ }),
7686
+ allowedCharacters: ({ params }) => ({
7687
+ type: "allowedCharacters",
7688
+ classes: [...params.classes],
7689
+ ...params.extra !== void 0 && { extra: params.extra }
7690
+ }),
7691
+ charTemplate: ({ params }) => ({
7692
+ type: "charTemplate",
7693
+ templates: [...params.templates],
7694
+ ...params.ignoreCase !== void 0 && { ignoreCase: params.ignoreCase }
7695
+ }),
7696
+ numericRange: ({ params }) => ({
7697
+ type: "numericRange",
7698
+ min: params.min,
7699
+ max: params.max
7700
+ }),
7701
+ rut: () => ({ type: "rut" }),
7702
+ esDni: () => ({ type: "esDni" }),
7703
+ fiPersonalIdentityCode: () => ({ type: "fiPersonalIdentityCode" }),
7704
+ inDrivingLicenseNumber: () => ({ type: "inDrivingLicenseNumber" }),
7705
+ curp: () => ({ type: "curp" })
7706
+ };
7707
+ const isCount = (value) => typeof value === "number" && Number.isInteger(value) && value > 0;
7708
+ const isInteger = (value) => typeof value === "number" && Number.isInteger(value);
7709
+ const isNonEmptyArrayOf = (value, item) => Array.isArray(value) && value.length > 0 && value.every(item);
7710
+ const isString = (value) => typeof value === "string";
7711
+ const isCharacterClass = (value) => CHARACTER_CLASSES.includes(value);
7147
7712
  /**
7148
- * eKYC prefill data for form definitions: turns the `ocr-data` and
7149
- * `otp-status` responses into values keyed by the vocabulary's prefill source
7150
- * ids (`document.firstName`, `phoneModule.phone`, …). The forms kernel then
7151
- * decides which of them a field uses and how it shows (`resolvePrefill`).
7713
+ * Params a projected rule reads. The compiler checks params against the
7714
+ * vocabulary too; this keeps a definition that skipped it, such as a served
7715
+ * one later, from projecting a broken rule.
7152
7716
  */
7153
- const dateFormatting = new DateFormattingProvider();
7154
- const fromSuggestion = (suggestion) => ({
7155
- street: suggestion.street,
7156
- houseNumber: suggestion.houseNumber,
7157
- city: suggestion.city,
7158
- state: suggestion.stateCode,
7159
- postalCode: suggestion.postalCode
7160
- });
7161
- const DRIVERS_LICENSE = "DriversLicense";
7162
- /** OCR sends some dates as epoch milliseconds in a string, such as `issuedAt`. */
7163
- const epochMs = (value) => typeof value === "string" && /^\d+$/.test(value) ? Number(value) : value;
7164
- const US_STATE_CODES = Object.fromEntries(Object.values(usStates).flatMap(({ code, name }) => [[code, code], [name.toUpperCase(), code]]));
7165
- /** A US state code or name as its code, such as `California` → `CA`. */
7166
- function usStateCode(value) {
7167
- return value ? US_STATE_CODES[value.trim().toUpperCase()] : void 0;
7168
- }
7169
- /** The proof-of-address statement address, whichever shape it came in. */
7170
- function statementAddress(ocr) {
7171
- const fromStatement = ocr.addressFromStatement;
7172
- const parsed = typeof fromStatement === "object" ? fromStatement : void 0;
7173
- const fields = ocr.addressFieldsFromStatement;
7174
- return {
7175
- label: parsed?.address ?? (typeof fromStatement === "string" ? fromStatement : void 0) ?? fields?.label,
7176
- street: parsed?.street ?? fields?.street,
7177
- houseNumber: parsed?.houseNumber ?? fields?.houseNumber,
7178
- city: parsed?.city ?? fields?.city,
7179
- state: parsed?.state ?? fields?.state,
7180
- postalCode: parsed?.postalCode ?? fields?.postalCode
7181
- };
7182
- }
7183
- /** The address search queries to try for each origin, in order. */
7184
- function prefillAddressQueries(ocr) {
7185
- if (!ocr) return {
7186
- document: [],
7187
- poa: []
7188
- };
7189
- const documentQueries = ocr.addressFields || ocr.checkedAddressBean ? [ocr.address, ocr.checkedAddress] : [];
7190
- return {
7191
- document: [...new Set(documentQueries.filter((q) => Boolean(q)))],
7192
- poa: [statementAddress(ocr).label].filter((q) => Boolean(q))
7193
- };
7194
- }
7195
- function addressEntries(origin, parts) {
7196
- return [
7197
- [`${origin}.street`, parts.street],
7198
- [`${origin}.houseNumber`, parts.houseNumber],
7199
- [`${origin}.city`, parts.city],
7200
- [`${origin}.state`, parts.state],
7201
- [`${origin}.postalCode`, parts.postalCode]
7202
- ];
7203
- }
7204
- /** Each prefill source id this module can fill, and how. */
7205
- const SOURCES = {
7206
- "document.firstName": (ocr) => ocr.name?.firstName,
7207
- "document.middleName": (ocr) => ocr.name?.middleName,
7208
- "document.paternalLastName": (ocr) => ocr.name?.paternalLastName,
7209
- "document.maternalLastName": (ocr) => ocr.name?.maternalLastName,
7210
- "document.birthDate": (ocr) => dateFormatting.utcToIsoDateString(ocr.birthDate),
7211
- "document.issueDate": (ocr) => dateFormatting.utcToIsoDateString(epochMs(ocr.issuedAt)),
7212
- "document.documentNumber": (ocr) => ocr.documentNumber,
7213
- "document.personalNumber": (ocr) => ocr.personalNumber,
7214
- "document.driversLicenseNumber": (ocr) => ocr.typeOfId === DRIVERS_LICENSE ? ocr.documentNumber : void 0,
7215
- "document.driversLicenseState": (ocr) => ocr.typeOfId === DRIVERS_LICENSE ? usStateCode(ocr.issuingState) : void 0,
7216
- "poa.firstName": (ocr) => ocr.poaName?.trim().split(/\s+/)[0],
7217
- "poa.lastName": (ocr) => ocr.poaName?.trim().split(/\s+/).slice(1).join(" ") || void 0,
7218
- "phoneModule.phone": (_ocr, otp) => otp.phone,
7219
- "emailModule.email": (_ocr, otp) => otp.email
7717
+ const RULE_PARAMS = {
7718
+ exactLength: ({ length }) => isCount(length),
7719
+ phoneDigits: ({ min, max }) => isCount(min) && isCount(max) && min <= max,
7720
+ digitCount: ({ lengths, min, max }) => lengths !== void 0 ? isNonEmptyArrayOf(lengths, isCount) && min === void 0 && max === void 0 : isCount(min) && isCount(max) && min <= max,
7721
+ allowedCharacters: ({ classes, extra }) => isNonEmptyArrayOf(classes, isCharacterClass) && (extra === void 0 || isString(extra)),
7722
+ charTemplate: ({ templates, ignoreCase }) => isNonEmptyArrayOf(templates, (t) => isString(t) && t !== "") && (ignoreCase === void 0 || typeof ignoreCase === "boolean"),
7723
+ numericRange: ({ min, max }) => isInteger(min) && isInteger(max) && min <= max,
7724
+ maxAge: ({ years }) => isCount(years)
7220
7725
  };
7221
- const ADDRESS_SOURCES = [...addressEntries("document", {}), ...addressEntries("poa", {})].map(([id]) => id);
7222
- /** Every prefill source id eKYC can fill, for `EKYC_SUPPORTED_IDS`. */
7223
- const EKYC_PREFILL_SOURCES = [...Object.keys(SOURCES), ...ADDRESS_SOURCES];
7224
7726
  /**
7225
- * The session's prefill values by source id. An address comes from its
7226
- * suggestion when one was found, otherwise from the OCR address fields.
7727
+ * Whether a field rule maps onto a validator: a known id, valid params, and
7728
+ * a message without params. eKYC's adapter checks its definitions with it.
7227
7729
  */
7228
- function buildPrefillData(ocr, otp, matches = {}) {
7229
- const ocrData = ocr ?? {};
7230
- const otpData = otp ?? {};
7231
- const documentAddress = matches.document ? fromSuggestion(matches.document) : ocrData.addressFields ?? ocrData.checkedAddressBean ?? {};
7232
- const poaAddress = matches.poa ? fromSuggestion(matches.poa) : statementAddress(ocrData);
7233
- const entries = [
7234
- ...Object.entries(SOURCES).map(([id, read]) => [id, read(ocrData, otpData, matches)]),
7235
- ...addressEntries("document", documentAddress),
7236
- ...addressEntries("poa", poaAddress)
7237
- ];
7238
- return Object.fromEntries(entries.filter(([, value]) => Boolean(value)));
7730
+ function isProjectableRule(rule) {
7731
+ return Object.prototype.hasOwnProperty.call(RULES, rule.id) && !rule.message?.params && (RULE_PARAMS[rule.id]?.(rule.params ?? {}) ?? true);
7732
+ }
7733
+ /**
7734
+ * A field's vocabulary rules as today's `EkycValidationRule`s, which
7735
+ * `validateEkycField` runs.
7736
+ */
7737
+ function projectRules(rules, country, required) {
7738
+ return rules.flatMap((rule) => {
7739
+ const project = RULES[rule.id];
7740
+ if (!project) return [];
7741
+ const projected = project({
7742
+ country,
7743
+ required,
7744
+ params: rule.params ?? {}
7745
+ });
7746
+ return [rule.message ? {
7747
+ ...projected,
7748
+ message: rule.message.key
7749
+ } : projected];
7750
+ });
7239
7751
  }
7240
7752
  //#endregion
7241
7753
  //#region src/modules/ekyc/ekycForm.ts
@@ -7274,30 +7786,10 @@ const OPTION_LISTS = {
7274
7786
  }
7275
7787
  ]
7276
7788
  };
7277
- const isCount = (value) => typeof value === "number" && Number.isInteger(value) && value > 0;
7278
- const isInteger = (value) => typeof value === "number" && Number.isInteger(value);
7279
- const isNonEmptyArrayOf = (value, item) => Array.isArray(value) && value.length > 0 && value.every(item);
7280
- const isString = (value) => typeof value === "string";
7281
- const isCharacterClass = (value) => CHARACTER_CLASSES.includes(value);
7282
- /**
7283
- * Params a projected rule reads. The compiler checks params against the
7284
- * vocabulary too; this keeps a definition that skipped it, such as a served
7285
- * one later, from projecting a broken rule.
7286
- */
7287
- const RULE_PARAMS = {
7288
- exactLength: ({ length }) => isCount(length),
7289
- phoneDigits: ({ min, max }) => isCount(min) && isCount(max) && min <= max,
7290
- digitCount: ({ lengths, min, max }) => lengths !== void 0 ? isNonEmptyArrayOf(lengths, isCount) && min === void 0 && max === void 0 : isCount(min) && isCount(max) && min <= max,
7291
- allowedCharacters: ({ classes, extra }) => isNonEmptyArrayOf(classes, isCharacterClass) && (extra === void 0 || isString(extra)),
7292
- charTemplate: ({ templates, ignoreCase }) => isNonEmptyArrayOf(templates, (t) => isString(t) && t !== "") && (ignoreCase === void 0 || typeof ignoreCase === "boolean"),
7293
- numericRange: ({ min, max }) => isInteger(min) && isInteger(max) && min <= max,
7294
- maxAge: ({ years }) => isCount(years)
7295
- };
7296
7789
  /**
7297
7790
  * What the projection can express today. Request-body transforms are listed
7298
7791
  * because `buildSubmitPayload` already applies them, on the fields
7299
- * `legacyPayloadTransforms` names; `requiredWhen` waits for decision B20, so
7300
- * no condition is supported yet.
7792
+ * `legacyPayloadTransforms` names.
7301
7793
  */
7302
7794
  const EKYC_SUPPORTED_IDS = {
7303
7795
  schemaVersions: [1],
@@ -7319,7 +7811,7 @@ const EKYC_SUPPORTED_IDS = {
7319
7811
  ]),
7320
7812
  groupRules: /* @__PURE__ */ new Set(["oneOfRequired", "rulesByOption"]),
7321
7813
  optionLists: new Set(Object.keys(OPTION_LISTS)),
7322
- conditions: /* @__PURE__ */ new Set(["fieldFilled"]),
7814
+ conditions: /* @__PURE__ */ new Set(["fieldFilled", "riskAddon"]),
7323
7815
  prefillSources: new Set(EKYC_PREFILL_SOURCES),
7324
7816
  flags: /* @__PURE__ */ new Set()
7325
7817
  };
@@ -7403,10 +7895,6 @@ function phoneFormatOf(field) {
7403
7895
  * this cache; key it by definition id and version then.
7404
7896
  */
7405
7897
  const projectable = /* @__PURE__ */ new WeakMap();
7406
- /** Whether a field rule maps onto a validator: known, valid params, no message. */
7407
- function isProjectableRule(rule) {
7408
- return Object.prototype.hasOwnProperty.call(RULES, rule.id) && plainKey(rule.message) && (RULE_PARAMS[rule.id]?.(rule.params ?? {}) ?? true);
7409
- }
7410
7898
  /**
7411
7899
  * `oneOfRequired` shows its own message key, or today's DOB-or-SSN message
7412
7900
  * when it has none, which only fits date of birth and SSN.
@@ -7510,6 +7998,7 @@ function toEkycResolveContext(verificationFields, enablePhoneRisk, displayModes
7510
7998
  return {
7511
7999
  groups: Object.fromEntries(groups.map(([group, key]) => [group, Boolean(verificationFields[key])])),
7512
8000
  phoneRisk: enablePhoneRisk,
8001
+ riskAddons: [...riskAddons],
7513
8002
  origins,
7514
8003
  displayModes: modes,
7515
8004
  lockingOrigins: LOCKING_ORIGINS
@@ -7567,6 +8056,16 @@ function projectField(resolved, verificationFields, country) {
7567
8056
  return def;
7568
8057
  }
7569
8058
  /**
8059
+ * Adds a "one of" group rule to a member, first so it answers for a blank
8060
+ * field before any format rule. A member required on its own (a risk add-on's,
8061
+ * B20) answers with its own required error, so the group rule goes last
8062
+ * there. It stays so that filling that member clears its siblings' group error.
8063
+ */
8064
+ function withOneOfRequired(def, oneOf) {
8065
+ const rules = def.validation ?? [];
8066
+ return def.required ? [...rules, oneOf] : [oneOf, ...rules];
8067
+ }
8068
+ /**
7570
8069
  * Projects a resolved definition to today's `EkycFieldDef[]`, identical to
7571
8070
  * what `legacyBuildFieldDefs` returns for the same source and country.
7572
8071
  */
@@ -7591,7 +8090,7 @@ function projectEkycFields(form, verificationFields, country) {
7591
8090
  fields: [...fields],
7592
8091
  ...message && message !== "verification.errors.dobOrSsnRequired" && { message }
7593
8092
  };
7594
- for (const def of defs) if (fields.includes(def.name)) def.validation = [oneOf, ...def.validation ?? []];
8093
+ for (const def of defs) if (fields.includes(def.name)) def.validation = withOneOfRequired(def, oneOf);
7595
8094
  }
7596
8095
  return defs;
7597
8096
  }
@@ -7603,7 +8102,7 @@ const STATE_OPTIONS_BY_COUNTRY = {
7603
8102
  US: usStateOptions,
7604
8103
  BR: brStateOptions
7605
8104
  };
7606
- function buildValidationRules(field, country, configSource) {
8105
+ function buildValidationRules(field, country) {
7607
8106
  const rules = [];
7608
8107
  if (field.required) rules.push({ type: "required" });
7609
8108
  if (field.name === "taxId" && country === "BR") rules.push({ type: "cpf" });
@@ -7616,7 +8115,7 @@ function buildValidationRules(field, country, configSource) {
7616
8115
  if (field.name === "phone") rules.push({
7617
8116
  type: "phoneFormat",
7618
8117
  country,
7619
- optional: isFieldOptional("phone", configSource)
8118
+ optional: !field.required
7620
8119
  });
7621
8120
  if (field.name === "email") rules.push({ type: "emailFormat" });
7622
8121
  if (field.name === "panNumber") rules.push({
@@ -7633,10 +8132,10 @@ function applyOneOfRequiredGroups(defs, configSource) {
7633
8132
  for (const group of ONE_OF_REQUIRED_GROUPS[configSource] ?? []) {
7634
8133
  const members = defs.filter((def) => group.includes(def.name));
7635
8134
  const fields = members.map((def) => def.name);
7636
- for (const def of members) def.validation = [{
8135
+ for (const def of members) def.validation = withOneOfRequired(def, {
7637
8136
  type: "oneOfRequired",
7638
8137
  fields
7639
- }, ...def.validation ?? []];
8138
+ });
7640
8139
  }
7641
8140
  }
7642
8141
  /**
@@ -7647,14 +8146,15 @@ function applyOneOfRequiredGroups(defs, configSource) {
7647
8146
  * it was created, so it can't change mid-session. The options are named so a
7648
8147
  * caller can't swap the two booleans.
7649
8148
  */
7650
- function buildFieldDefs(fields, configSource, country, { useDefinitions, enablePhoneRisk = false }) {
8149
+ function buildFieldDefs(fields, configSource, country, { useDefinitions, enablePhoneRisk = false, riskAddons = [] }) {
7651
8150
  const definition = selectEkycDefinition(configSource, country, useDefinitions);
7652
- if (definition) return projectEkycFields(resolveForm(definition, toEkycResolveContext(fields, enablePhoneRisk)), fields, country);
7653
- return legacyBuildFieldDefs(fields, configSource, country, enablePhoneRisk);
8151
+ if (definition) return projectEkycFields(resolveForm(definition, toEkycResolveContext(fields, enablePhoneRisk, {}, riskAddons)), fields, country);
8152
+ return legacyBuildFieldDefs(fields, configSource, country, enablePhoneRisk, riskAddons);
7654
8153
  }
7655
8154
  /** The per-source builder for sources without a form definition yet. */
7656
- function legacyBuildFieldDefs(fields, configSource, country, enablePhoneRisk = false) {
8155
+ function legacyBuildFieldDefs(fields, configSource, country, enablePhoneRisk = false, riskAddons = []) {
7657
8156
  const defs = [];
8157
+ const addonFields = getRiskAddonFields(riskAddons);
7658
8158
  const add = (name, type, label, source, opts) => {
7659
8159
  if (source === false) return;
7660
8160
  const def = {
@@ -7662,10 +8162,10 @@ function legacyBuildFieldDefs(fields, configSource, country, enablePhoneRisk = f
7662
8162
  type,
7663
8163
  label,
7664
8164
  source,
7665
- required: !isFieldOptional(name, configSource),
8165
+ required: addonFields.has(name) || !isFieldOptional(name, configSource),
7666
8166
  ...opts
7667
8167
  };
7668
- const validation = buildValidationRules(def, country, configSource);
8168
+ const validation = buildValidationRules(def, country);
7669
8169
  if (validation.length > 0) def.validation = validation;
7670
8170
  defs.push(def);
7671
8171
  };
@@ -7785,12 +8285,13 @@ function applyPrefill(fields, ocrData, otpStatus, _country) {
7785
8285
  const readonlyFields = [];
7786
8286
  let hideEmail = false;
7787
8287
  if (fields.name === "document_scan" && ocrData?.name) {
7788
- if (ocrData.name.firstName) {
7789
- values.firstName = ocrData.name.firstName;
8288
+ const { firstName, surName } = resolveOcrName(ocrData.name);
8289
+ if (firstName) {
8290
+ values.firstName = firstName;
7790
8291
  prefilled.firstName = true;
7791
8292
  }
7792
- if (ocrData.name.paternalLastName) {
7793
- values.surName = ocrData.name.paternalLastName;
8293
+ if (surName) {
8294
+ values.surName = surName;
7794
8295
  prefilled.surName = true;
7795
8296
  }
7796
8297
  if (ocrData.name.middleName) {
@@ -7913,6 +8414,13 @@ const PHONE_FORMATTERS = {
7913
8414
  e164NoPlus: (phone, country) => formatPhoneE164(phone, country).replace(/^\+/, "")
7914
8415
  };
7915
8416
  /**
8417
+ * Whether a field's value is left out of the request body: absent, `null`, or
8418
+ * text that is blank once trimmed (CK1 decision K1, as the kernel's
8419
+ * `buildPayload` does). A host can pass anything to `setField`, so any other
8420
+ * value is sent as it is.
8421
+ */
8422
+ const isLeftOut = (value) => value === void 0 || value === null || typeof value === "string" && value.trim() === "";
8423
+ /**
7916
8424
  * Builds the request body. Keep the per-field transforms below in sync with
7917
8425
  * `legacyPayloadTransforms` in `ekycForm.ts`: definitions are projectable only
7918
8426
  * when they declare exactly these, until P2 builds request bodies from them.
@@ -7921,7 +8429,7 @@ function buildSubmitPayload(ctx) {
7921
8429
  const payload = {};
7922
8430
  for (const field of ctx.fields) {
7923
8431
  const val = ctx.values[field.name];
7924
- if (val !== void 0 && val !== "") payload[field.name] = val;
8432
+ if (!isLeftOut(val)) payload[field.name] = val;
7925
8433
  }
7926
8434
  if (payload.nationality) payload.nationality = payload.nationality.toUpperCase();
7927
8435
  if (ctx.fieldsCountry && !COUNTRY_CODE_OMITTED_SOURCES.includes(ctx.configSource)) payload.countryCode = ctx.fieldsCountry;
@@ -8106,7 +8614,7 @@ const prefillConfig = (context) => ({
8106
8614
  configSource: context.configSource,
8107
8615
  country: context.fieldsCountry,
8108
8616
  enablePhoneRisk: context.moduleConfig?.enablePhoneRisk ?? context.config.enablePhoneRisk,
8109
- riskAddons: context.moduleConfig?.riskAddons,
8617
+ riskAddons: getEkycRiskAddons(context),
8110
8618
  useDefinitions: context._formDefinitions
8111
8619
  });
8112
8620
  const stepsOf = (context) => buildEkycSteps(context.fields, context.hideEmail);
@@ -8147,7 +8655,8 @@ const ekycMachine = setup({
8147
8655
  fieldsCountry: country,
8148
8656
  fields: buildFieldDefs(vFields, source, country, {
8149
8657
  useDefinitions: context._formDefinitions,
8150
- enablePhoneRisk: config.enablePhoneRisk
8658
+ enablePhoneRisk: config.enablePhoneRisk,
8659
+ riskAddons: config.riskAddons
8151
8660
  }),
8152
8661
  displayModes: getEKYCDisplayModes(config)
8153
8662
  };
@@ -8325,7 +8834,7 @@ const ekycMachine = setup({
8325
8834
  target: "loading.phoneRules",
8326
8835
  guard: "hasVerificationFields",
8327
8836
  actions: assign(({ context }) => {
8328
- const vFields = context.config.verificationFields;
8837
+ const vFields = withRiskAddonFields(context.config.verificationFields, context.config.riskAddons);
8329
8838
  const source = context.config.source ?? "";
8330
8839
  const country = context.config.fieldsCountry ?? getEKYCCountry(source);
8331
8840
  return {
@@ -8334,7 +8843,8 @@ const ekycMachine = setup({
8334
8843
  fieldsCountry: country,
8335
8844
  fields: buildFieldDefs(vFields, source, country, {
8336
8845
  useDefinitions: context._formDefinitions,
8337
- enablePhoneRisk: context.config.enablePhoneRisk
8846
+ enablePhoneRisk: context.config.enablePhoneRisk,
8847
+ riskAddons: context.config.riskAddons
8338
8848
  })
8339
8849
  };
8340
8850
  })