@velion-la/onboarding-sdk-react-native 1.0.0-beta.10

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 (614) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/LICENSE +12 -0
  3. package/README.md +888 -0
  4. package/app.plugin.js +101 -0
  5. package/lib/commonjs/camera/AddressSearchBar.js +304 -0
  6. package/lib/commonjs/camera/AddressSearchBar.js.map +1 -0
  7. package/lib/commonjs/camera/DocumentCapture.js +513 -0
  8. package/lib/commonjs/camera/DocumentCapture.js.map +1 -0
  9. package/lib/commonjs/camera/LivenessCamera.js +628 -0
  10. package/lib/commonjs/camera/LivenessCamera.js.map +1 -0
  11. package/lib/commonjs/camera/MapAddressPicker.js +331 -0
  12. package/lib/commonjs/camera/MapAddressPicker.js.map +1 -0
  13. package/lib/commonjs/core/VelionOnboarding.js +1113 -0
  14. package/lib/commonjs/core/VelionOnboarding.js.map +1 -0
  15. package/lib/commonjs/core/retryStepCopy.js +43 -0
  16. package/lib/commonjs/core/retryStepCopy.js.map +1 -0
  17. package/lib/commonjs/core/routingCommands.js +62 -0
  18. package/lib/commonjs/core/routingCommands.js.map +1 -0
  19. package/lib/commonjs/core/sessionDeclinedCopy.js +56 -0
  20. package/lib/commonjs/core/sessionDeclinedCopy.js.map +1 -0
  21. package/lib/commonjs/core/sessionStateMapper.js +200 -0
  22. package/lib/commonjs/core/sessionStateMapper.js.map +1 -0
  23. package/lib/commonjs/core/sseReasonMessages.js +450 -0
  24. package/lib/commonjs/core/sseReasonMessages.js.map +1 -0
  25. package/lib/commonjs/data/iso3166Alpha2Codes.json +1 -0
  26. package/lib/commonjs/data/iso3166CountryNames.json +251 -0
  27. package/lib/commonjs/i18n/index.js +30 -0
  28. package/lib/commonjs/i18n/index.js.map +1 -0
  29. package/lib/commonjs/i18n/strings/en.js +301 -0
  30. package/lib/commonjs/i18n/strings/en.js.map +1 -0
  31. package/lib/commonjs/i18n/strings/es.js +306 -0
  32. package/lib/commonjs/i18n/strings/es.js.map +1 -0
  33. package/lib/commonjs/index.js +225 -0
  34. package/lib/commonjs/index.js.map +1 -0
  35. package/lib/commonjs/package.json +1 -0
  36. package/lib/commonjs/steps/AddressInfoStep.js +662 -0
  37. package/lib/commonjs/steps/AddressInfoStep.js.map +1 -0
  38. package/lib/commonjs/steps/DocumentsOcrStep.js +405 -0
  39. package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -0
  40. package/lib/commonjs/steps/EconomicActivityStep.js +214 -0
  41. package/lib/commonjs/steps/EconomicActivityStep.js.map +1 -0
  42. package/lib/commonjs/steps/EmailContactStep.js +150 -0
  43. package/lib/commonjs/steps/EmailContactStep.js.map +1 -0
  44. package/lib/commonjs/steps/EmailOtpStep.js +225 -0
  45. package/lib/commonjs/steps/EmailOtpStep.js.map +1 -0
  46. package/lib/commonjs/steps/FaceMatchStep.js +169 -0
  47. package/lib/commonjs/steps/FaceMatchStep.js.map +1 -0
  48. package/lib/commonjs/steps/FingerprintStep.js +92 -0
  49. package/lib/commonjs/steps/FingerprintStep.js.map +1 -0
  50. package/lib/commonjs/steps/HumanBasicInfoStep.js +251 -0
  51. package/lib/commonjs/steps/HumanBasicInfoStep.js.map +1 -0
  52. package/lib/commonjs/steps/HumanExtendedInfoStep.js +275 -0
  53. package/lib/commonjs/steps/HumanExtendedInfoStep.js.map +1 -0
  54. package/lib/commonjs/steps/LegalBasicInfoStep.js +195 -0
  55. package/lib/commonjs/steps/LegalBasicInfoStep.js.map +1 -0
  56. package/lib/commonjs/steps/LegalExtendedInfoStep.js +173 -0
  57. package/lib/commonjs/steps/LegalExtendedInfoStep.js.map +1 -0
  58. package/lib/commonjs/steps/LivenessMatchStep.js +1184 -0
  59. package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -0
  60. package/lib/commonjs/steps/PhoneContactStep.js +151 -0
  61. package/lib/commonjs/steps/PhoneContactStep.js.map +1 -0
  62. package/lib/commonjs/steps/PhoneOtpStep.js +224 -0
  63. package/lib/commonjs/steps/PhoneOtpStep.js.map +1 -0
  64. package/lib/commonjs/steps/SwornDeclarationStep.js +206 -0
  65. package/lib/commonjs/steps/SwornDeclarationStep.js.map +1 -0
  66. package/lib/commonjs/steps/TaxInfoStep.js +251 -0
  67. package/lib/commonjs/steps/TaxInfoStep.js.map +1 -0
  68. package/lib/commonjs/steps/TermsAndConditionsStep.js +245 -0
  69. package/lib/commonjs/steps/TermsAndConditionsStep.js.map +1 -0
  70. package/lib/commonjs/steps/_shared.js +61 -0
  71. package/lib/commonjs/steps/_shared.js.map +1 -0
  72. package/lib/commonjs/steps/types.js +6 -0
  73. package/lib/commonjs/steps/types.js.map +1 -0
  74. package/lib/commonjs/transport/api.js +176 -0
  75. package/lib/commonjs/transport/api.js.map +1 -0
  76. package/lib/commonjs/transport/irisWebSocket.js +121 -0
  77. package/lib/commonjs/transport/irisWebSocket.js.map +1 -0
  78. package/lib/commonjs/transport/secureUrl.js +50 -0
  79. package/lib/commonjs/transport/secureUrl.js.map +1 -0
  80. package/lib/commonjs/transport/sse.js +248 -0
  81. package/lib/commonjs/transport/sse.js.map +1 -0
  82. package/lib/commonjs/types/index.js +458 -0
  83. package/lib/commonjs/types/index.js.map +1 -0
  84. package/lib/commonjs/ui/MapFallbackBoundary.js +42 -0
  85. package/lib/commonjs/ui/MapFallbackBoundary.js.map +1 -0
  86. package/lib/commonjs/ui/StepShell.js +251 -0
  87. package/lib/commonjs/ui/StepShell.js.map +1 -0
  88. package/lib/commonjs/ui/VelionOnboardingScreen.js +276 -0
  89. package/lib/commonjs/ui/VelionOnboardingScreen.js.map +1 -0
  90. package/lib/commonjs/ui/forms/index.js +38 -0
  91. package/lib/commonjs/ui/forms/index.js.map +1 -0
  92. package/lib/commonjs/ui/forms/useInlineValidation.js +88 -0
  93. package/lib/commonjs/ui/forms/useInlineValidation.js.map +1 -0
  94. package/lib/commonjs/ui/forms/validators.js +34 -0
  95. package/lib/commonjs/ui/forms/validators.js.map +1 -0
  96. package/lib/commonjs/ui/icons/HomeHeartIcon.js +38 -0
  97. package/lib/commonjs/ui/icons/HomeHeartIcon.js.map +1 -0
  98. package/lib/commonjs/ui/icons/StepIcon.js +59 -0
  99. package/lib/commonjs/ui/icons/StepIcon.js.map +1 -0
  100. package/lib/commonjs/ui/overlays/AnalyzingOverlay.js +284 -0
  101. package/lib/commonjs/ui/overlays/AnalyzingOverlay.js.map +1 -0
  102. package/lib/commonjs/ui/overlays/LoadingOverlay.js +108 -0
  103. package/lib/commonjs/ui/overlays/LoadingOverlay.js.map +1 -0
  104. package/lib/commonjs/ui/overlays/ProgressBar.js +101 -0
  105. package/lib/commonjs/ui/overlays/ProgressBar.js.map +1 -0
  106. package/lib/commonjs/ui/overlays/RetryDialog.js +125 -0
  107. package/lib/commonjs/ui/overlays/RetryDialog.js.map +1 -0
  108. package/lib/commonjs/ui/overlays/index.js +33 -0
  109. package/lib/commonjs/ui/overlays/index.js.map +1 -0
  110. package/lib/commonjs/ui/primitives/BackButton.js +75 -0
  111. package/lib/commonjs/ui/primitives/BackButton.js.map +1 -0
  112. package/lib/commonjs/ui/primitives/Banner.js +81 -0
  113. package/lib/commonjs/ui/primitives/Banner.js.map +1 -0
  114. package/lib/commonjs/ui/primitives/Button.js +142 -0
  115. package/lib/commonjs/ui/primitives/Button.js.map +1 -0
  116. package/lib/commonjs/ui/primitives/Card.js +50 -0
  117. package/lib/commonjs/ui/primitives/Card.js.map +1 -0
  118. package/lib/commonjs/ui/primitives/Checkbox.js +139 -0
  119. package/lib/commonjs/ui/primitives/Checkbox.js.map +1 -0
  120. package/lib/commonjs/ui/primitives/CountrySelect.js +288 -0
  121. package/lib/commonjs/ui/primitives/CountrySelect.js.map +1 -0
  122. package/lib/commonjs/ui/primitives/DatePicker.js +245 -0
  123. package/lib/commonjs/ui/primitives/DatePicker.js.map +1 -0
  124. package/lib/commonjs/ui/primitives/Input.js +101 -0
  125. package/lib/commonjs/ui/primitives/Input.js.map +1 -0
  126. package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js +162 -0
  127. package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js.map +1 -0
  128. package/lib/commonjs/ui/primitives/Select.js +209 -0
  129. package/lib/commonjs/ui/primitives/Select.js.map +1 -0
  130. package/lib/commonjs/ui/primitives/Spinner.js +25 -0
  131. package/lib/commonjs/ui/primitives/Spinner.js.map +1 -0
  132. package/lib/commonjs/ui/primitives/index.js +89 -0
  133. package/lib/commonjs/ui/primitives/index.js.map +1 -0
  134. package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js +31 -0
  135. package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
  136. package/lib/commonjs/ui/theme/ThemeProvider.js +74 -0
  137. package/lib/commonjs/ui/theme/ThemeProvider.js.map +1 -0
  138. package/lib/commonjs/ui/theme/index.js +68 -0
  139. package/lib/commonjs/ui/theme/index.js.map +1 -0
  140. package/lib/commonjs/ui/theme/tokens.js +154 -0
  141. package/lib/commonjs/ui/theme/tokens.js.map +1 -0
  142. package/lib/commonjs/utils/EventEmitter.js +144 -0
  143. package/lib/commonjs/utils/EventEmitter.js.map +1 -0
  144. package/lib/commonjs/utils/base64.js +53 -0
  145. package/lib/commonjs/utils/base64.js.map +1 -0
  146. package/lib/commonjs/utils/deviceFingerprint.js +132 -0
  147. package/lib/commonjs/utils/deviceFingerprint.js.map +1 -0
  148. package/lib/commonjs/utils/documentTypeOptions.js +35 -0
  149. package/lib/commonjs/utils/documentTypeOptions.js.map +1 -0
  150. package/lib/commonjs/utils/googleMapsPreflight.js +88 -0
  151. package/lib/commonjs/utils/googleMapsPreflight.js.map +1 -0
  152. package/lib/commonjs/utils/hmac.js +58 -0
  153. package/lib/commonjs/utils/hmac.js.map +1 -0
  154. package/lib/commonjs/utils/iso3166Countries.js +98 -0
  155. package/lib/commonjs/utils/iso3166Countries.js.map +1 -0
  156. package/lib/commonjs/utils/jpegFromUri.js +44 -0
  157. package/lib/commonjs/utils/jpegFromUri.js.map +1 -0
  158. package/lib/commonjs/utils/keepAwake.js +58 -0
  159. package/lib/commonjs/utils/keepAwake.js.map +1 -0
  160. package/lib/commonjs/utils/log.js +42 -0
  161. package/lib/commonjs/utils/log.js.map +1 -0
  162. package/lib/commonjs/utils/osGeocoder.js +70 -0
  163. package/lib/commonjs/utils/osGeocoder.js.map +1 -0
  164. package/lib/commonjs/utils/parseGoogleAddressComponents.js +74 -0
  165. package/lib/commonjs/utils/parseGoogleAddressComponents.js.map +1 -0
  166. package/lib/commonjs/utils/personNameNormalize.js +24 -0
  167. package/lib/commonjs/utils/personNameNormalize.js.map +1 -0
  168. package/lib/commonjs/utils/sdkError.js +34 -0
  169. package/lib/commonjs/utils/sdkError.js.map +1 -0
  170. package/lib/commonjs/utils/sdkVersion.js +13 -0
  171. package/lib/commonjs/utils/sdkVersion.js.map +1 -0
  172. package/lib/commonjs/utils/stepConfig.js +65 -0
  173. package/lib/commonjs/utils/stepConfig.js.map +1 -0
  174. package/lib/commonjs/utils/taxInfoConfig.js +19 -0
  175. package/lib/commonjs/utils/taxInfoConfig.js.map +1 -0
  176. package/lib/commonjs/utils/useSafeAreaInsets.js +41 -0
  177. package/lib/commonjs/utils/useSafeAreaInsets.js.map +1 -0
  178. package/lib/commonjs/utils/velionExtra.js +48 -0
  179. package/lib/commonjs/utils/velionExtra.js.map +1 -0
  180. package/lib/module/camera/AddressSearchBar.js +299 -0
  181. package/lib/module/camera/AddressSearchBar.js.map +1 -0
  182. package/lib/module/camera/DocumentCapture.js +508 -0
  183. package/lib/module/camera/DocumentCapture.js.map +1 -0
  184. package/lib/module/camera/LivenessCamera.js +623 -0
  185. package/lib/module/camera/LivenessCamera.js.map +1 -0
  186. package/lib/module/camera/MapAddressPicker.js +326 -0
  187. package/lib/module/camera/MapAddressPicker.js.map +1 -0
  188. package/lib/module/core/VelionOnboarding.js +1109 -0
  189. package/lib/module/core/VelionOnboarding.js.map +1 -0
  190. package/lib/module/core/retryStepCopy.js +39 -0
  191. package/lib/module/core/retryStepCopy.js.map +1 -0
  192. package/lib/module/core/routingCommands.js +57 -0
  193. package/lib/module/core/routingCommands.js.map +1 -0
  194. package/lib/module/core/sessionDeclinedCopy.js +52 -0
  195. package/lib/module/core/sessionDeclinedCopy.js.map +1 -0
  196. package/lib/module/core/sessionStateMapper.js +189 -0
  197. package/lib/module/core/sessionStateMapper.js.map +1 -0
  198. package/lib/module/core/sseReasonMessages.js +446 -0
  199. package/lib/module/core/sseReasonMessages.js.map +1 -0
  200. package/lib/module/data/iso3166Alpha2Codes.json +1 -0
  201. package/lib/module/data/iso3166CountryNames.json +251 -0
  202. package/lib/module/i18n/index.js +25 -0
  203. package/lib/module/i18n/index.js.map +1 -0
  204. package/lib/module/i18n/strings/en.js +297 -0
  205. package/lib/module/i18n/strings/en.js.map +1 -0
  206. package/lib/module/i18n/strings/es.js +302 -0
  207. package/lib/module/i18n/strings/es.js.map +1 -0
  208. package/lib/module/index.js +36 -0
  209. package/lib/module/index.js.map +1 -0
  210. package/lib/module/steps/AddressInfoStep.js +658 -0
  211. package/lib/module/steps/AddressInfoStep.js.map +1 -0
  212. package/lib/module/steps/DocumentsOcrStep.js +399 -0
  213. package/lib/module/steps/DocumentsOcrStep.js.map +1 -0
  214. package/lib/module/steps/EconomicActivityStep.js +209 -0
  215. package/lib/module/steps/EconomicActivityStep.js.map +1 -0
  216. package/lib/module/steps/EmailContactStep.js +145 -0
  217. package/lib/module/steps/EmailContactStep.js.map +1 -0
  218. package/lib/module/steps/EmailOtpStep.js +220 -0
  219. package/lib/module/steps/EmailOtpStep.js.map +1 -0
  220. package/lib/module/steps/FaceMatchStep.js +164 -0
  221. package/lib/module/steps/FaceMatchStep.js.map +1 -0
  222. package/lib/module/steps/FingerprintStep.js +87 -0
  223. package/lib/module/steps/FingerprintStep.js.map +1 -0
  224. package/lib/module/steps/HumanBasicInfoStep.js +246 -0
  225. package/lib/module/steps/HumanBasicInfoStep.js.map +1 -0
  226. package/lib/module/steps/HumanExtendedInfoStep.js +270 -0
  227. package/lib/module/steps/HumanExtendedInfoStep.js.map +1 -0
  228. package/lib/module/steps/LegalBasicInfoStep.js +190 -0
  229. package/lib/module/steps/LegalBasicInfoStep.js.map +1 -0
  230. package/lib/module/steps/LegalExtendedInfoStep.js +168 -0
  231. package/lib/module/steps/LegalExtendedInfoStep.js.map +1 -0
  232. package/lib/module/steps/LivenessMatchStep.js +1177 -0
  233. package/lib/module/steps/LivenessMatchStep.js.map +1 -0
  234. package/lib/module/steps/PhoneContactStep.js +146 -0
  235. package/lib/module/steps/PhoneContactStep.js.map +1 -0
  236. package/lib/module/steps/PhoneOtpStep.js +219 -0
  237. package/lib/module/steps/PhoneOtpStep.js.map +1 -0
  238. package/lib/module/steps/SwornDeclarationStep.js +203 -0
  239. package/lib/module/steps/SwornDeclarationStep.js.map +1 -0
  240. package/lib/module/steps/TaxInfoStep.js +246 -0
  241. package/lib/module/steps/TaxInfoStep.js.map +1 -0
  242. package/lib/module/steps/TermsAndConditionsStep.js +240 -0
  243. package/lib/module/steps/TermsAndConditionsStep.js.map +1 -0
  244. package/lib/module/steps/_shared.js +52 -0
  245. package/lib/module/steps/_shared.js.map +1 -0
  246. package/lib/module/steps/types.js +4 -0
  247. package/lib/module/steps/types.js.map +1 -0
  248. package/lib/module/transport/api.js +173 -0
  249. package/lib/module/transport/api.js.map +1 -0
  250. package/lib/module/transport/irisWebSocket.js +115 -0
  251. package/lib/module/transport/irisWebSocket.js.map +1 -0
  252. package/lib/module/transport/secureUrl.js +45 -0
  253. package/lib/module/transport/secureUrl.js.map +1 -0
  254. package/lib/module/transport/sse.js +242 -0
  255. package/lib/module/transport/sse.js.map +1 -0
  256. package/lib/module/types/index.js +532 -0
  257. package/lib/module/types/index.js.map +1 -0
  258. package/lib/module/ui/MapFallbackBoundary.js +37 -0
  259. package/lib/module/ui/MapFallbackBoundary.js.map +1 -0
  260. package/lib/module/ui/StepShell.js +246 -0
  261. package/lib/module/ui/StepShell.js.map +1 -0
  262. package/lib/module/ui/VelionOnboardingScreen.js +273 -0
  263. package/lib/module/ui/VelionOnboardingScreen.js.map +1 -0
  264. package/lib/module/ui/forms/index.js +5 -0
  265. package/lib/module/ui/forms/index.js.map +1 -0
  266. package/lib/module/ui/forms/useInlineValidation.js +84 -0
  267. package/lib/module/ui/forms/useInlineValidation.js.map +1 -0
  268. package/lib/module/ui/forms/validators.js +27 -0
  269. package/lib/module/ui/forms/validators.js.map +1 -0
  270. package/lib/module/ui/icons/HomeHeartIcon.js +33 -0
  271. package/lib/module/ui/icons/HomeHeartIcon.js.map +1 -0
  272. package/lib/module/ui/icons/StepIcon.js +55 -0
  273. package/lib/module/ui/icons/StepIcon.js.map +1 -0
  274. package/lib/module/ui/overlays/AnalyzingOverlay.js +279 -0
  275. package/lib/module/ui/overlays/AnalyzingOverlay.js.map +1 -0
  276. package/lib/module/ui/overlays/LoadingOverlay.js +104 -0
  277. package/lib/module/ui/overlays/LoadingOverlay.js.map +1 -0
  278. package/lib/module/ui/overlays/ProgressBar.js +97 -0
  279. package/lib/module/ui/overlays/ProgressBar.js.map +1 -0
  280. package/lib/module/ui/overlays/RetryDialog.js +121 -0
  281. package/lib/module/ui/overlays/RetryDialog.js.map +1 -0
  282. package/lib/module/ui/overlays/index.js +6 -0
  283. package/lib/module/ui/overlays/index.js.map +1 -0
  284. package/lib/module/ui/primitives/BackButton.js +71 -0
  285. package/lib/module/ui/primitives/BackButton.js.map +1 -0
  286. package/lib/module/ui/primitives/Banner.js +77 -0
  287. package/lib/module/ui/primitives/Banner.js.map +1 -0
  288. package/lib/module/ui/primitives/Button.js +138 -0
  289. package/lib/module/ui/primitives/Button.js.map +1 -0
  290. package/lib/module/ui/primitives/Card.js +46 -0
  291. package/lib/module/ui/primitives/Card.js.map +1 -0
  292. package/lib/module/ui/primitives/Checkbox.js +136 -0
  293. package/lib/module/ui/primitives/Checkbox.js.map +1 -0
  294. package/lib/module/ui/primitives/CountrySelect.js +284 -0
  295. package/lib/module/ui/primitives/CountrySelect.js.map +1 -0
  296. package/lib/module/ui/primitives/DatePicker.js +241 -0
  297. package/lib/module/ui/primitives/DatePicker.js.map +1 -0
  298. package/lib/module/ui/primitives/Input.js +97 -0
  299. package/lib/module/ui/primitives/Input.js.map +1 -0
  300. package/lib/module/ui/primitives/SearchableSingleSelectList.js +153 -0
  301. package/lib/module/ui/primitives/SearchableSingleSelectList.js.map +1 -0
  302. package/lib/module/ui/primitives/Select.js +205 -0
  303. package/lib/module/ui/primitives/Select.js.map +1 -0
  304. package/lib/module/ui/primitives/Spinner.js +21 -0
  305. package/lib/module/ui/primitives/Spinner.js.map +1 -0
  306. package/lib/module/ui/primitives/index.js +14 -0
  307. package/lib/module/ui/primitives/index.js.map +1 -0
  308. package/lib/module/ui/primitives/searchableSingleSelectFilter.js +27 -0
  309. package/lib/module/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
  310. package/lib/module/ui/theme/ThemeProvider.js +67 -0
  311. package/lib/module/ui/theme/ThemeProvider.js.map +1 -0
  312. package/lib/module/ui/theme/index.js +5 -0
  313. package/lib/module/ui/theme/index.js.map +1 -0
  314. package/lib/module/ui/theme/tokens.js +145 -0
  315. package/lib/module/ui/theme/tokens.js.map +1 -0
  316. package/lib/module/utils/EventEmitter.js +139 -0
  317. package/lib/module/utils/EventEmitter.js.map +1 -0
  318. package/lib/module/utils/base64.js +47 -0
  319. package/lib/module/utils/base64.js.map +1 -0
  320. package/lib/module/utils/deviceFingerprint.js +129 -0
  321. package/lib/module/utils/deviceFingerprint.js.map +1 -0
  322. package/lib/module/utils/documentTypeOptions.js +31 -0
  323. package/lib/module/utils/documentTypeOptions.js.map +1 -0
  324. package/lib/module/utils/googleMapsPreflight.js +84 -0
  325. package/lib/module/utils/googleMapsPreflight.js.map +1 -0
  326. package/lib/module/utils/hmac.js +53 -0
  327. package/lib/module/utils/hmac.js.map +1 -0
  328. package/lib/module/utils/iso3166Countries.js +92 -0
  329. package/lib/module/utils/iso3166Countries.js.map +1 -0
  330. package/lib/module/utils/jpegFromUri.js +40 -0
  331. package/lib/module/utils/jpegFromUri.js.map +1 -0
  332. package/lib/module/utils/keepAwake.js +53 -0
  333. package/lib/module/utils/keepAwake.js.map +1 -0
  334. package/lib/module/utils/log.js +37 -0
  335. package/lib/module/utils/log.js.map +1 -0
  336. package/lib/module/utils/osGeocoder.js +65 -0
  337. package/lib/module/utils/osGeocoder.js.map +1 -0
  338. package/lib/module/utils/parseGoogleAddressComponents.js +69 -0
  339. package/lib/module/utils/parseGoogleAddressComponents.js.map +1 -0
  340. package/lib/module/utils/personNameNormalize.js +20 -0
  341. package/lib/module/utils/personNameNormalize.js.map +1 -0
  342. package/lib/module/utils/sdkError.js +29 -0
  343. package/lib/module/utils/sdkError.js.map +1 -0
  344. package/lib/module/utils/sdkVersion.js +9 -0
  345. package/lib/module/utils/sdkVersion.js.map +1 -0
  346. package/lib/module/utils/stepConfig.js +59 -0
  347. package/lib/module/utils/stepConfig.js.map +1 -0
  348. package/lib/module/utils/taxInfoConfig.js +15 -0
  349. package/lib/module/utils/taxInfoConfig.js.map +1 -0
  350. package/lib/module/utils/useSafeAreaInsets.js +37 -0
  351. package/lib/module/utils/useSafeAreaInsets.js.map +1 -0
  352. package/lib/module/utils/velionExtra.js +44 -0
  353. package/lib/module/utils/velionExtra.js.map +1 -0
  354. package/lib/typescript/camera/AddressSearchBar.d.ts +37 -0
  355. package/lib/typescript/camera/AddressSearchBar.d.ts.map +1 -0
  356. package/lib/typescript/camera/DocumentCapture.d.ts +34 -0
  357. package/lib/typescript/camera/DocumentCapture.d.ts.map +1 -0
  358. package/lib/typescript/camera/LivenessCamera.d.ts +67 -0
  359. package/lib/typescript/camera/LivenessCamera.d.ts.map +1 -0
  360. package/lib/typescript/camera/MapAddressPicker.d.ts +57 -0
  361. package/lib/typescript/camera/MapAddressPicker.d.ts.map +1 -0
  362. package/lib/typescript/core/VelionOnboarding.d.ts +169 -0
  363. package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -0
  364. package/lib/typescript/core/retryStepCopy.d.ts +27 -0
  365. package/lib/typescript/core/retryStepCopy.d.ts.map +1 -0
  366. package/lib/typescript/core/routingCommands.d.ts +39 -0
  367. package/lib/typescript/core/routingCommands.d.ts.map +1 -0
  368. package/lib/typescript/core/sessionDeclinedCopy.d.ts +16 -0
  369. package/lib/typescript/core/sessionDeclinedCopy.d.ts.map +1 -0
  370. package/lib/typescript/core/sessionStateMapper.d.ts +52 -0
  371. package/lib/typescript/core/sessionStateMapper.d.ts.map +1 -0
  372. package/lib/typescript/core/sseReasonMessages.d.ts +20 -0
  373. package/lib/typescript/core/sseReasonMessages.d.ts.map +1 -0
  374. package/lib/typescript/i18n/index.d.ts +13 -0
  375. package/lib/typescript/i18n/index.d.ts.map +1 -0
  376. package/lib/typescript/i18n/strings/en.d.ts +3 -0
  377. package/lib/typescript/i18n/strings/en.d.ts.map +1 -0
  378. package/lib/typescript/i18n/strings/es.d.ts +297 -0
  379. package/lib/typescript/i18n/strings/es.d.ts.map +1 -0
  380. package/lib/typescript/index.d.ts +26 -0
  381. package/lib/typescript/index.d.ts.map +1 -0
  382. package/lib/typescript/steps/AddressInfoStep.d.ts +26 -0
  383. package/lib/typescript/steps/AddressInfoStep.d.ts.map +1 -0
  384. package/lib/typescript/steps/DocumentsOcrStep.d.ts +26 -0
  385. package/lib/typescript/steps/DocumentsOcrStep.d.ts.map +1 -0
  386. package/lib/typescript/steps/EconomicActivityStep.d.ts +29 -0
  387. package/lib/typescript/steps/EconomicActivityStep.d.ts.map +1 -0
  388. package/lib/typescript/steps/EmailContactStep.d.ts +15 -0
  389. package/lib/typescript/steps/EmailContactStep.d.ts.map +1 -0
  390. package/lib/typescript/steps/EmailOtpStep.d.ts +21 -0
  391. package/lib/typescript/steps/EmailOtpStep.d.ts.map +1 -0
  392. package/lib/typescript/steps/FaceMatchStep.d.ts +27 -0
  393. package/lib/typescript/steps/FaceMatchStep.d.ts.map +1 -0
  394. package/lib/typescript/steps/FingerprintStep.d.ts +25 -0
  395. package/lib/typescript/steps/FingerprintStep.d.ts.map +1 -0
  396. package/lib/typescript/steps/HumanBasicInfoStep.d.ts +25 -0
  397. package/lib/typescript/steps/HumanBasicInfoStep.d.ts.map +1 -0
  398. package/lib/typescript/steps/HumanExtendedInfoStep.d.ts +23 -0
  399. package/lib/typescript/steps/HumanExtendedInfoStep.d.ts.map +1 -0
  400. package/lib/typescript/steps/LegalBasicInfoStep.d.ts +17 -0
  401. package/lib/typescript/steps/LegalBasicInfoStep.d.ts.map +1 -0
  402. package/lib/typescript/steps/LegalExtendedInfoStep.d.ts +17 -0
  403. package/lib/typescript/steps/LegalExtendedInfoStep.d.ts.map +1 -0
  404. package/lib/typescript/steps/LivenessMatchStep.d.ts +26 -0
  405. package/lib/typescript/steps/LivenessMatchStep.d.ts.map +1 -0
  406. package/lib/typescript/steps/PhoneContactStep.d.ts +15 -0
  407. package/lib/typescript/steps/PhoneContactStep.d.ts.map +1 -0
  408. package/lib/typescript/steps/PhoneOtpStep.d.ts +19 -0
  409. package/lib/typescript/steps/PhoneOtpStep.d.ts.map +1 -0
  410. package/lib/typescript/steps/SwornDeclarationStep.d.ts +20 -0
  411. package/lib/typescript/steps/SwornDeclarationStep.d.ts.map +1 -0
  412. package/lib/typescript/steps/TaxInfoStep.d.ts +19 -0
  413. package/lib/typescript/steps/TaxInfoStep.d.ts.map +1 -0
  414. package/lib/typescript/steps/TermsAndConditionsStep.d.ts +21 -0
  415. package/lib/typescript/steps/TermsAndConditionsStep.d.ts.map +1 -0
  416. package/lib/typescript/steps/_shared.d.ts +22 -0
  417. package/lib/typescript/steps/_shared.d.ts.map +1 -0
  418. package/lib/typescript/steps/types.d.ts +89 -0
  419. package/lib/typescript/steps/types.d.ts.map +1 -0
  420. package/lib/typescript/transport/api.d.ts +35 -0
  421. package/lib/typescript/transport/api.d.ts.map +1 -0
  422. package/lib/typescript/transport/irisWebSocket.d.ts +72 -0
  423. package/lib/typescript/transport/irisWebSocket.d.ts.map +1 -0
  424. package/lib/typescript/transport/secureUrl.d.ts +14 -0
  425. package/lib/typescript/transport/secureUrl.d.ts.map +1 -0
  426. package/lib/typescript/transport/sse.d.ts +54 -0
  427. package/lib/typescript/transport/sse.d.ts.map +1 -0
  428. package/lib/typescript/types/index.d.ts +1219 -0
  429. package/lib/typescript/types/index.d.ts.map +1 -0
  430. package/lib/typescript/ui/MapFallbackBoundary.d.ts +28 -0
  431. package/lib/typescript/ui/MapFallbackBoundary.d.ts.map +1 -0
  432. package/lib/typescript/ui/StepShell.d.ts +29 -0
  433. package/lib/typescript/ui/StepShell.d.ts.map +1 -0
  434. package/lib/typescript/ui/VelionOnboardingScreen.d.ts +26 -0
  435. package/lib/typescript/ui/VelionOnboardingScreen.d.ts.map +1 -0
  436. package/lib/typescript/ui/forms/index.d.ts +3 -0
  437. package/lib/typescript/ui/forms/index.d.ts.map +1 -0
  438. package/lib/typescript/ui/forms/useInlineValidation.d.ts +30 -0
  439. package/lib/typescript/ui/forms/useInlineValidation.d.ts.map +1 -0
  440. package/lib/typescript/ui/forms/validators.d.ts +11 -0
  441. package/lib/typescript/ui/forms/validators.d.ts.map +1 -0
  442. package/lib/typescript/ui/icons/HomeHeartIcon.d.ts +14 -0
  443. package/lib/typescript/ui/icons/HomeHeartIcon.d.ts.map +1 -0
  444. package/lib/typescript/ui/icons/StepIcon.d.ts +26 -0
  445. package/lib/typescript/ui/icons/StepIcon.d.ts.map +1 -0
  446. package/lib/typescript/ui/overlays/AnalyzingOverlay.d.ts +24 -0
  447. package/lib/typescript/ui/overlays/AnalyzingOverlay.d.ts.map +1 -0
  448. package/lib/typescript/ui/overlays/LoadingOverlay.d.ts +19 -0
  449. package/lib/typescript/ui/overlays/LoadingOverlay.d.ts.map +1 -0
  450. package/lib/typescript/ui/overlays/ProgressBar.d.ts +32 -0
  451. package/lib/typescript/ui/overlays/ProgressBar.d.ts.map +1 -0
  452. package/lib/typescript/ui/overlays/RetryDialog.d.ts +17 -0
  453. package/lib/typescript/ui/overlays/RetryDialog.d.ts.map +1 -0
  454. package/lib/typescript/ui/overlays/index.d.ts +4 -0
  455. package/lib/typescript/ui/overlays/index.d.ts.map +1 -0
  456. package/lib/typescript/ui/primitives/BackButton.d.ts +20 -0
  457. package/lib/typescript/ui/primitives/BackButton.d.ts.map +1 -0
  458. package/lib/typescript/ui/primitives/Banner.d.ts +11 -0
  459. package/lib/typescript/ui/primitives/Banner.d.ts.map +1 -0
  460. package/lib/typescript/ui/primitives/Button.d.ts +27 -0
  461. package/lib/typescript/ui/primitives/Button.d.ts.map +1 -0
  462. package/lib/typescript/ui/primitives/Card.d.ts +10 -0
  463. package/lib/typescript/ui/primitives/Card.d.ts.map +1 -0
  464. package/lib/typescript/ui/primitives/Checkbox.d.ts +25 -0
  465. package/lib/typescript/ui/primitives/Checkbox.d.ts.map +1 -0
  466. package/lib/typescript/ui/primitives/CountrySelect.d.ts +31 -0
  467. package/lib/typescript/ui/primitives/CountrySelect.d.ts.map +1 -0
  468. package/lib/typescript/ui/primitives/DatePicker.d.ts +42 -0
  469. package/lib/typescript/ui/primitives/DatePicker.d.ts.map +1 -0
  470. package/lib/typescript/ui/primitives/Input.d.ts +17 -0
  471. package/lib/typescript/ui/primitives/Input.d.ts.map +1 -0
  472. package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts +33 -0
  473. package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts.map +1 -0
  474. package/lib/typescript/ui/primitives/Select.d.ts +26 -0
  475. package/lib/typescript/ui/primitives/Select.d.ts.map +1 -0
  476. package/lib/typescript/ui/primitives/Spinner.d.ts +10 -0
  477. package/lib/typescript/ui/primitives/Spinner.d.ts.map +1 -0
  478. package/lib/typescript/ui/primitives/index.d.ts +12 -0
  479. package/lib/typescript/ui/primitives/index.d.ts.map +1 -0
  480. package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts +25 -0
  481. package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts.map +1 -0
  482. package/lib/typescript/ui/theme/ThemeProvider.d.ts +23 -0
  483. package/lib/typescript/ui/theme/ThemeProvider.d.ts.map +1 -0
  484. package/lib/typescript/ui/theme/index.d.ts +3 -0
  485. package/lib/typescript/ui/theme/index.d.ts.map +1 -0
  486. package/lib/typescript/ui/theme/tokens.d.ts +42 -0
  487. package/lib/typescript/ui/theme/tokens.d.ts.map +1 -0
  488. package/lib/typescript/utils/EventEmitter.d.ts +98 -0
  489. package/lib/typescript/utils/EventEmitter.d.ts.map +1 -0
  490. package/lib/typescript/utils/base64.d.ts +19 -0
  491. package/lib/typescript/utils/base64.d.ts.map +1 -0
  492. package/lib/typescript/utils/deviceFingerprint.d.ts +42 -0
  493. package/lib/typescript/utils/deviceFingerprint.d.ts.map +1 -0
  494. package/lib/typescript/utils/documentTypeOptions.d.ts +13 -0
  495. package/lib/typescript/utils/documentTypeOptions.d.ts.map +1 -0
  496. package/lib/typescript/utils/googleMapsPreflight.d.ts +52 -0
  497. package/lib/typescript/utils/googleMapsPreflight.d.ts.map +1 -0
  498. package/lib/typescript/utils/hmac.d.ts +39 -0
  499. package/lib/typescript/utils/hmac.d.ts.map +1 -0
  500. package/lib/typescript/utils/iso3166Countries.d.ts +27 -0
  501. package/lib/typescript/utils/iso3166Countries.d.ts.map +1 -0
  502. package/lib/typescript/utils/jpegFromUri.d.ts +29 -0
  503. package/lib/typescript/utils/jpegFromUri.d.ts.map +1 -0
  504. package/lib/typescript/utils/keepAwake.d.ts +16 -0
  505. package/lib/typescript/utils/keepAwake.d.ts.map +1 -0
  506. package/lib/typescript/utils/log.d.ts +18 -0
  507. package/lib/typescript/utils/log.d.ts.map +1 -0
  508. package/lib/typescript/utils/osGeocoder.d.ts +38 -0
  509. package/lib/typescript/utils/osGeocoder.d.ts.map +1 -0
  510. package/lib/typescript/utils/parseGoogleAddressComponents.d.ts +43 -0
  511. package/lib/typescript/utils/parseGoogleAddressComponents.d.ts.map +1 -0
  512. package/lib/typescript/utils/personNameNormalize.d.ts +10 -0
  513. package/lib/typescript/utils/personNameNormalize.d.ts.map +1 -0
  514. package/lib/typescript/utils/sdkError.d.ts +14 -0
  515. package/lib/typescript/utils/sdkError.d.ts.map +1 -0
  516. package/lib/typescript/utils/sdkVersion.d.ts +7 -0
  517. package/lib/typescript/utils/sdkVersion.d.ts.map +1 -0
  518. package/lib/typescript/utils/stepConfig.d.ts +8 -0
  519. package/lib/typescript/utils/stepConfig.d.ts.map +1 -0
  520. package/lib/typescript/utils/taxInfoConfig.d.ts +7 -0
  521. package/lib/typescript/utils/taxInfoConfig.d.ts.map +1 -0
  522. package/lib/typescript/utils/useSafeAreaInsets.d.ts +26 -0
  523. package/lib/typescript/utils/useSafeAreaInsets.d.ts.map +1 -0
  524. package/lib/typescript/utils/velionExtra.d.ts +24 -0
  525. package/lib/typescript/utils/velionExtra.d.ts.map +1 -0
  526. package/package.json +107 -0
  527. package/src/camera/AddressSearchBar.tsx +363 -0
  528. package/src/camera/DocumentCapture.tsx +514 -0
  529. package/src/camera/LivenessCamera.tsx +706 -0
  530. package/src/camera/MapAddressPicker.tsx +391 -0
  531. package/src/core/VelionOnboarding.ts +1291 -0
  532. package/src/core/retryStepCopy.ts +54 -0
  533. package/src/core/routingCommands.ts +63 -0
  534. package/src/core/sessionDeclinedCopy.ts +76 -0
  535. package/src/core/sessionStateMapper.ts +232 -0
  536. package/src/core/sseReasonMessages.ts +531 -0
  537. package/src/data/iso3166Alpha2Codes.json +1 -0
  538. package/src/data/iso3166CountryNames.json +251 -0
  539. package/src/i18n/index.ts +26 -0
  540. package/src/i18n/strings/en.ts +335 -0
  541. package/src/i18n/strings/es.ts +337 -0
  542. package/src/index.ts +146 -0
  543. package/src/steps/AddressInfoStep.tsx +744 -0
  544. package/src/steps/DocumentsOcrStep.tsx +481 -0
  545. package/src/steps/EconomicActivityStep.tsx +230 -0
  546. package/src/steps/EmailContactStep.tsx +165 -0
  547. package/src/steps/EmailOtpStep.tsx +256 -0
  548. package/src/steps/FaceMatchStep.tsx +176 -0
  549. package/src/steps/FingerprintStep.tsx +99 -0
  550. package/src/steps/HumanBasicInfoStep.tsx +286 -0
  551. package/src/steps/HumanExtendedInfoStep.tsx +362 -0
  552. package/src/steps/LegalBasicInfoStep.tsx +214 -0
  553. package/src/steps/LegalExtendedInfoStep.tsx +184 -0
  554. package/src/steps/LivenessMatchStep.tsx +1351 -0
  555. package/src/steps/PhoneContactStep.tsx +166 -0
  556. package/src/steps/PhoneOtpStep.tsx +255 -0
  557. package/src/steps/SwornDeclarationStep.tsx +237 -0
  558. package/src/steps/TaxInfoStep.tsx +288 -0
  559. package/src/steps/TermsAndConditionsStep.tsx +269 -0
  560. package/src/steps/_shared.ts +69 -0
  561. package/src/steps/types.ts +93 -0
  562. package/src/transport/api.ts +257 -0
  563. package/src/transport/irisWebSocket.ts +186 -0
  564. package/src/transport/secureUrl.ts +47 -0
  565. package/src/transport/sse.ts +310 -0
  566. package/src/types/index.ts +1421 -0
  567. package/src/ui/MapFallbackBoundary.tsx +46 -0
  568. package/src/ui/StepShell.tsx +273 -0
  569. package/src/ui/VelionOnboardingScreen.tsx +297 -0
  570. package/src/ui/forms/index.ts +12 -0
  571. package/src/ui/forms/useInlineValidation.ts +115 -0
  572. package/src/ui/forms/validators.ts +29 -0
  573. package/src/ui/icons/HomeHeartIcon.tsx +34 -0
  574. package/src/ui/icons/StepIcon.tsx +78 -0
  575. package/src/ui/overlays/AnalyzingOverlay.tsx +323 -0
  576. package/src/ui/overlays/LoadingOverlay.tsx +115 -0
  577. package/src/ui/overlays/ProgressBar.tsx +106 -0
  578. package/src/ui/overlays/RetryDialog.tsx +128 -0
  579. package/src/ui/overlays/index.ts +3 -0
  580. package/src/ui/primitives/BackButton.tsx +65 -0
  581. package/src/ui/primitives/Banner.tsx +81 -0
  582. package/src/ui/primitives/Button.tsx +164 -0
  583. package/src/ui/primitives/Card.tsx +55 -0
  584. package/src/ui/primitives/Checkbox.tsx +153 -0
  585. package/src/ui/primitives/CountrySelect.tsx +356 -0
  586. package/src/ui/primitives/DatePicker.tsx +266 -0
  587. package/src/ui/primitives/Input.tsx +110 -0
  588. package/src/ui/primitives/SearchableSingleSelectList.tsx +195 -0
  589. package/src/ui/primitives/Select.tsx +259 -0
  590. package/src/ui/primitives/Spinner.tsx +17 -0
  591. package/src/ui/primitives/index.ts +16 -0
  592. package/src/ui/primitives/searchableSingleSelectFilter.ts +38 -0
  593. package/src/ui/theme/ThemeProvider.tsx +102 -0
  594. package/src/ui/theme/index.ts +17 -0
  595. package/src/ui/theme/tokens.ts +159 -0
  596. package/src/utils/EventEmitter.ts +155 -0
  597. package/src/utils/base64.ts +44 -0
  598. package/src/utils/deviceFingerprint.ts +184 -0
  599. package/src/utils/documentTypeOptions.ts +31 -0
  600. package/src/utils/googleMapsPreflight.ts +89 -0
  601. package/src/utils/hmac.ts +61 -0
  602. package/src/utils/iso3166Countries.ts +111 -0
  603. package/src/utils/jpegFromUri.ts +42 -0
  604. package/src/utils/keepAwake.ts +62 -0
  605. package/src/utils/log.ts +37 -0
  606. package/src/utils/osGeocoder.ts +75 -0
  607. package/src/utils/parseGoogleAddressComponents.ts +123 -0
  608. package/src/utils/personNameNormalize.ts +17 -0
  609. package/src/utils/sdkError.ts +40 -0
  610. package/src/utils/sdkVersion.ts +6 -0
  611. package/src/utils/stepConfig.ts +75 -0
  612. package/src/utils/taxInfoConfig.ts +14 -0
  613. package/src/utils/useSafeAreaInsets.ts +37 -0
  614. package/src/utils/velionExtra.ts +46 -0
@@ -0,0 +1,1113 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VelionOnboarding = void 0;
7
+ var _EventEmitter = require("../utils/EventEmitter");
8
+ var _api = require("../transport/api");
9
+ var _log = require("../utils/log");
10
+ var _velionExtra = require("../utils/velionExtra");
11
+ var _sessionStateMapper = require("./sessionStateMapper");
12
+ var _sse = require("../transport/sse");
13
+ var _sessionDeclinedCopy = require("./sessionDeclinedCopy");
14
+ var _retryStepCopy = require("./retryStepCopy");
15
+ var _routingCommands = require("./routingCommands");
16
+ var _FingerprintStep = require("../steps/FingerprintStep");
17
+ var _HumanBasicInfoStep = require("../steps/HumanBasicInfoStep");
18
+ var _EmailContactStep = require("../steps/EmailContactStep");
19
+ var _PhoneContactStep = require("../steps/PhoneContactStep");
20
+ var _EmailOtpStep = require("../steps/EmailOtpStep");
21
+ var _PhoneOtpStep = require("../steps/PhoneOtpStep");
22
+ var _TaxInfoStep = require("../steps/TaxInfoStep");
23
+ var _SwornDeclarationStep = require("../steps/SwornDeclarationStep");
24
+ var _EconomicActivityStep = require("../steps/EconomicActivityStep");
25
+ var _TermsAndConditionsStep = require("../steps/TermsAndConditionsStep");
26
+ var _LegalBasicInfoStep = require("../steps/LegalBasicInfoStep");
27
+ var _HumanExtendedInfoStep = require("../steps/HumanExtendedInfoStep");
28
+ var _LegalExtendedInfoStep = require("../steps/LegalExtendedInfoStep");
29
+ var _AddressInfoStep = require("../steps/AddressInfoStep");
30
+ var _DocumentsOcrStep = require("../steps/DocumentsOcrStep");
31
+ var _LivenessMatchStep = require("../steps/LivenessMatchStep");
32
+ var _FaceMatchStep = require("../steps/FaceMatchStep");
33
+ var _types = require("../types");
34
+ var _react = require("react");
35
+ var _RetryDialog = require("../ui/overlays/RetryDialog");
36
+ /**
37
+ * @fileoverview VelionOnboarding — orchestrator for the React Native SDK.
38
+ *
39
+ * Platform-agnostic dynamic state machine: deals with HTTP, SSE, dedupe and
40
+ * step-module orchestration. UI mounting is delegated to a React component
41
+ * (`VelionOnboardingScreen`) instead of direct DOM manipulation.
42
+ *
43
+ * Invariants:
44
+ * - SSE dedupe by `event_id` (monotonic)
45
+ * - Suppress duplicate `NEXT_STEP` for the just-completed step
46
+ * - `RETRY_STEP` shows a retry dialog (Retry re-mounts the step, Cancel exits);
47
+ * once the retry quota is exhausted the backend emits SESSION_DECLINED instead
48
+ * - 45 s watchdog for terminal SSE event after final step → fallback GET
49
+ * - SESSION_DECLINED handling races with module.run()
50
+ */
51
+
52
+ // ─────────────────────────────────────────────────────────────────────────────
53
+ // PUBLIC CONFIG (RN flavor)
54
+ // ─────────────────────────────────────────────────────────────────────────────
55
+
56
+ /**
57
+ * RN-specific config. Drops web-only fields (`containerId`, `allowEmbedded`,
58
+ * `iframeParentOrigin`) and keeps everything else identical to
59
+ * `WebVelionConfig`, including `fingerprintEndpoint` and `fingerprintApiKey`
60
+ * — both are honoured by the native Fingerprint Pro SDK on mobile too.
61
+ */
62
+
63
+ // ─────────────────────────────────────────────────────────────────────────────
64
+ // INTERNAL CONTRACTS
65
+ // ─────────────────────────────────────────────────────────────────────────────
66
+
67
+ /** Result of awaiting an active step module (see {@link VelionOnboarding.awaitModuleOutcome}). */
68
+
69
+ const BACKEND_ONLY_ORCHESTRATED_STEPS = new Set(['FACE_MATCH', 'AML_SCREENING']);
70
+ const DEFAULT_API_URL = 'https://sdk.velion.la/onboarding';
71
+ function isBackendOnlyOrchestratedStep(step) {
72
+ if (typeof step !== 'string' || step.trim() === '') return false;
73
+ return BACKEND_ONLY_ORCHESTRATED_STEPS.has(step.trim().toUpperCase());
74
+ }
75
+ function isTerminalSessionEvent(event) {
76
+ const t = event.event_type;
77
+ return t === 'SESSION_APPROVED' || t === 'SESSION_MANUAL_REVIEW' || t === 'SESSION_DECLINED' || t === 'SESSION_TERMINATED';
78
+ }
79
+ function terminalEventTypeToStatus(eventType) {
80
+ switch (eventType) {
81
+ case 'SESSION_APPROVED':
82
+ return 'APPROVED';
83
+ case 'SESSION_MANUAL_REVIEW':
84
+ return 'MANUAL_REVIEW';
85
+ case 'SESSION_DECLINED':
86
+ return 'DECLINED';
87
+ case 'SESSION_TERMINATED':
88
+ return 'REJECTED';
89
+ default:
90
+ return undefined;
91
+ }
92
+ }
93
+ function isSessionTokenAuthSdkError(err) {
94
+ return err != null && typeof err === 'object' && err.code === _types.SdkErrorCode.SESSION_EXPIRED;
95
+ }
96
+
97
+ // ─────────────────────────────────────────────────────────────────────────────
98
+ // PUBLIC: ORCHESTRATOR
99
+ // ─────────────────────────────────────────────────────────────────────────────
100
+
101
+ /**
102
+ * Optional view bridge given to the orchestrator by `VelionOnboardingScreen`.
103
+ *
104
+ * The orchestrator never reads from this — it only writes:
105
+ * - `setLoading(text)` to display a status message between steps
106
+ * - `setStepNode(node)` to mount the active step's UI
107
+ * - `setError(err)` to surface a fatal error
108
+ * - `setResult(result)` on flow completion (host may show their own result)
109
+ */
110
+
111
+ /**
112
+ * Top-level entry point. Instantiate once per session, call `start()`, and
113
+ * `destroy()` from the host's unmount path.
114
+ */
115
+ class VelionOnboarding {
116
+ emitter = new _EventEmitter.TypedEventEmitter();
117
+ status = 'IDLE';
118
+ activeModule = null;
119
+ view = {};
120
+ uiHandle = {
121
+ setNode: node => this.view.setStepNode?.(node)
122
+ };
123
+ initAbortController = new AbortController();
124
+ sseAbortController = new AbortController();
125
+ sseCleanup = null;
126
+ sseTerminalResolve = null;
127
+ sseNextStepResolve = null;
128
+ queuedNextStepCommand = null;
129
+ lastSseEventId = '0';
130
+ previousStepResolve = null;
131
+ queuedPreviousStepCommand = null;
132
+ backExitResolve = null;
133
+ queuedBackExitStep = null;
134
+ backRequestInFlight = false;
135
+
136
+ /** Resolver for the in-flight retry dialog (RETRY_STEP), cleared on destroy. */
137
+ retryDialogResolve = null;
138
+
139
+ /** Per-step reversibility (workflow order) cached from the initial GET, used to
140
+ * derive `can_go_back` for steps reached via SSE (which doesn't carry it). */
141
+ stepReversibility = [];
142
+ sessionDeclineHandler = null;
143
+ pendingSessionDeclined = null;
144
+ pendingTerminalEvent = null;
145
+ sessionEnded = false;
146
+ constructor(config) {
147
+ const apiUrl = config.apiUrl ?? DEFAULT_API_URL;
148
+ this.config = Object.freeze({
149
+ ...config,
150
+ apiUrl
151
+ });
152
+ if (this.config.debug === true) (0, _log.setDebugEnabled)(true);
153
+ let api;
154
+ let constructionError = null;
155
+ try {
156
+ api = (0, _api.createApiCaller)(apiUrl, config.sessionToken, config.expiresAt);
157
+ } catch (err) {
158
+ constructionError = err;
159
+ // Provide a safe-but-unused caller so typed code paths don't crash.
160
+ api = (0, _api.createApiCaller)('https://invalid.velion.invalid', config.sessionToken, config.expiresAt);
161
+ }
162
+ this.api = api;
163
+ this.constructionError = constructionError;
164
+ this.wireExternalCallbacks();
165
+ }
166
+
167
+ /** Connects an `OrchestratorView` (typically `VelionOnboardingScreen`). */
168
+ attachView(view) {
169
+ this.view = view;
170
+ }
171
+
172
+ /** Detaches the active view (called from screen unmount). */
173
+ detachView() {
174
+ this.view = {};
175
+ }
176
+ on(event, listener) {
177
+ return this.emitter.on(event, listener);
178
+ }
179
+ getStatus() {
180
+ return this.status;
181
+ }
182
+
183
+ /**
184
+ * Hot-rotate the bearer token used by every subsequent backend call. The SSE
185
+ * stream is also reopened so the new token reaches the server-side authenticator.
186
+ */
187
+ refreshSessionToken(token, expiresAt) {
188
+ if (this.status === 'DESTROYED') return;
189
+ this.api.setSessionToken(token, expiresAt);
190
+ if (this.sseCleanup) {
191
+ _log.log.info('[Flow] Reopening SSE after session token rotation');
192
+ this.sseCleanup();
193
+ this.sseAbortController.abort();
194
+ this.sseAbortController = new AbortController();
195
+ this.openSseStream(token);
196
+ }
197
+ }
198
+ async start() {
199
+ if (this.status === 'DESTROYED') {
200
+ this.emitError({
201
+ code: _types.SdkErrorCode.INSTANCE_DESTROYED,
202
+ message: 'This VelionOnboarding instance has been destroyed. Create a new instance to retry.'
203
+ });
204
+ return;
205
+ }
206
+ if (this.status !== 'IDLE') {
207
+ this.emitError({
208
+ code: _types.SdkErrorCode.ALREADY_STARTED,
209
+ message: 'start() was called on an already-running SDK instance. Call destroy() before re-starting.'
210
+ });
211
+ return;
212
+ }
213
+ if (this.constructionError) {
214
+ this.emitError(this.constructionError);
215
+ return;
216
+ }
217
+ try {
218
+ await this.initialize();
219
+ } catch (err) {
220
+ this.emitError(err);
221
+ }
222
+ }
223
+ destroy() {
224
+ if (this.status === 'DESTROYED') return;
225
+ this.setStatus('DESTROYED');
226
+ this.initAbortController.abort();
227
+ this.sseCleanup?.();
228
+ this.sseAbortController.abort();
229
+ this.activeModule?.destroy();
230
+ this.activeModule = null;
231
+ this.view.setStepNode?.(null);
232
+ this.view.setLoading?.(null);
233
+ this.emitter.removeAllListeners();
234
+ this.sessionDeclineHandler = null;
235
+ this.pendingSessionDeclined = null;
236
+ this.previousStepResolve = null;
237
+ this.queuedPreviousStepCommand = null;
238
+ this.backExitResolve = null;
239
+ this.queuedBackExitStep = null;
240
+ this.retryDialogResolve = null;
241
+ }
242
+
243
+ // ── Initialization ────────────────────────────────────────────────────────
244
+
245
+ async initialize() {
246
+ this.setStatus('INITIALIZING');
247
+ this.showLoading(this.localizedLoadingMsg());
248
+ let dto;
249
+ try {
250
+ dto = await this.api.get(`/sessions/${this.config.sessionId}`, {
251
+ signal: this.initAbortController.signal,
252
+ extraHeaders: {
253
+ 'Cache-Control': 'no-cache, no-store, must-revalidate',
254
+ Pragma: 'no-cache'
255
+ }
256
+ });
257
+ } catch (err) {
258
+ this.showLoading(null);
259
+ if (isSessionTokenAuthSdkError(err)) {
260
+ throw err;
261
+ }
262
+ throw {
263
+ code: _types.SdkErrorCode.SESSION_FETCH_FAILED,
264
+ message: `Failed to fetch session for sessionId="${this.config.sessionId}". Verify the apiUrl and sessionToken are correct.`,
265
+ cause: err
266
+ };
267
+ }
268
+ const sessionState = (0, _sessionStateMapper.mapOnboardingDtoToSessionState)(dto);
269
+ // Cache the workflow reversibility map so the "back" control can be resolved
270
+ // for steps reached via SSE (which doesn't carry `can_go_back`).
271
+ this.stepReversibility = sessionState.stepReversibility ?? [];
272
+ this.emitter.emit('session:loaded', sessionState);
273
+ if ((0, _sessionStateMapper.isTerminalSessionStatusFromDto)(dto.status)) {
274
+ const result = (0, _sessionStateMapper.mapOnboardingDtoToResult)(dto, this.config.sessionId);
275
+ this.completeFlow(result);
276
+ return;
277
+ }
278
+ this.validateSessionState(dto, sessionState);
279
+ this.sseAbortController = new AbortController();
280
+ this.openSseStream(this.config.sessionToken);
281
+ this.setStatus('RUNNING');
282
+ await this.runStepMachine(sessionState);
283
+ }
284
+ validateSessionState(dto, state) {
285
+ if ((0, _sessionStateMapper.requiresCurrentStepForSessionStatus)(dto.status) && !state.currentStep) {
286
+ throw {
287
+ code: _types.SdkErrorCode.SESSION_FETCH_FAILED,
288
+ message: `Session ${this.config.sessionId} reports status="${dto.status}" but no current_step. Backend payload is incomplete.`
289
+ };
290
+ }
291
+ }
292
+
293
+ // ── Step Machine ──────────────────────────────────────────────────────────
294
+
295
+ async runStepMachine(sessionState) {
296
+ if (await this.consumePendingTerminalEvent()) return;
297
+ if (this.pendingSessionDeclined) {
298
+ const ev = this.pendingSessionDeclined;
299
+ this.pendingSessionDeclined = null;
300
+ this.endFlowWithSessionDeclined(ev);
301
+ return;
302
+ }
303
+ let index = 0;
304
+ let currentStep = sessionState.currentStep;
305
+ let currentStepConfig = sessionState.currentStepConfig;
306
+ let currentStepResult = sessionState.currentStepResult;
307
+ let currentCanGoBack = currentStep ? this.resolveCanGoBack(sessionState.canGoBack, currentStep) : false;
308
+ const knownStepConfigs = {
309
+ ...(sessionState.stepConfigs ?? {})
310
+ };
311
+ if (currentStep && isBackendOnlyOrchestratedStep(currentStep)) {
312
+ this.showLoading(this.localizedProcessingMsg());
313
+ try {
314
+ const outcome = await this.withSessionDeclineRace(this.waitForRoutingAfterBackendOnlyStep());
315
+ if (await this.consumePendingTerminalEvent()) return;
316
+ if (outcome.declined) {
317
+ this.endFlowWithSessionDeclined(outcome.event);
318
+ return;
319
+ }
320
+ const routed = outcome.value;
321
+ if (!routed?.step) {
322
+ throw {
323
+ code: _types.SdkErrorCode.SESSION_FETCH_FAILED,
324
+ message: `Timed out waiting for ROUTING_COMMAND while the session was on a backend-only step (${String(currentStep)}).`
325
+ };
326
+ }
327
+ currentStep = routed.step;
328
+ currentStepConfig = routed.stepConfig;
329
+ currentStepResult = undefined;
330
+ currentCanGoBack = this.resolveCanGoBack(routed.canGoBack, routed.step);
331
+ } finally {
332
+ this.showLoading(null);
333
+ }
334
+ }
335
+ while (currentStep) {
336
+ if (await this.consumePendingTerminalEvent()) return;
337
+ if (this.pendingSessionDeclined) {
338
+ const ev = this.pendingSessionDeclined;
339
+ this.pendingSessionDeclined = null;
340
+ this.endFlowWithSessionDeclined(ev);
341
+ return;
342
+ }
343
+ this.setStatus('STEP_PROCESSING');
344
+ this.emitter.emit('step:change', {
345
+ step: currentStep,
346
+ index
347
+ });
348
+ if (currentStepConfig) {
349
+ knownStepConfigs[currentStep] = currentStepConfig;
350
+ }
351
+ const module = this.createModule(currentStep, currentStepConfig, currentStepResult, currentCanGoBack);
352
+ this.activeModule = module;
353
+ let outcome;
354
+ try {
355
+ outcome = await this.awaitModuleOutcome(module.run());
356
+ } catch (err) {
357
+ module.destroy();
358
+ this.activeModule = null;
359
+ throw err;
360
+ }
361
+ if (await this.consumePendingTerminalEvent()) {
362
+ module.destroy();
363
+ this.activeModule = null;
364
+ return;
365
+ }
366
+ if (outcome.kind === 'declined') {
367
+ module.destroy();
368
+ this.activeModule = null;
369
+ this.endFlowWithSessionDeclined(outcome.event);
370
+ return;
371
+ }
372
+ if (outcome.kind === 'back') {
373
+ // Reverse navigation: tear down the active form and re-enter the loop on
374
+ // the re-opened step with its previous data as prefill. Do NOT advance
375
+ // the index nor emit step:complete — the step was not completed.
376
+ module.destroy();
377
+ this.activeModule = null;
378
+ this.view.setStepNode?.(null);
379
+ const command = outcome.command;
380
+ currentStep = command.step;
381
+ currentStepConfig = command.stepConfig ?? knownStepConfigs[command.step];
382
+ currentStepResult = command.stepResult;
383
+ currentCanGoBack = this.resolveCanGoBack(command.canGoBack, command.step);
384
+ this.showLoading(this.localizedLoadingMsg());
385
+ continue;
386
+ }
387
+ if (outcome.kind === 'exit') {
388
+ // Back on the first reversible step: there is no earlier step, so the
389
+ // backend told us to leave. Tear down and hand control back to the host.
390
+ module.destroy();
391
+ this.activeModule = null;
392
+ this.exitFlow(outcome.step);
393
+ return;
394
+ }
395
+ module.destroy();
396
+ this.activeModule = null;
397
+ this.view.setStepNode?.(null);
398
+ this.emitter.emit('step:complete', {
399
+ step: currentStep
400
+ });
401
+ this.setStatus('RUNNING');
402
+ index += 1;
403
+ this.showLoading('');
404
+ let next;
405
+ try {
406
+ const nextOutcome = await this.withSessionDeclineRace(this.resolveNextStepAfterCompletion());
407
+ if (await this.consumePendingTerminalEvent()) {
408
+ this.showLoading(null);
409
+ return;
410
+ }
411
+ if (nextOutcome.declined) {
412
+ this.endFlowWithSessionDeclined(nextOutcome.event);
413
+ return;
414
+ }
415
+ next = nextOutcome.value;
416
+ } catch (err) {
417
+ this.showLoading(null);
418
+ throw err;
419
+ }
420
+ while (next?.step && next.action === 'NEXT_STEP' && next.step === currentStep) {
421
+ _log.log.warn('[Flow] Dropping duplicate NEXT_STEP for just-completed step', {
422
+ step: currentStep
423
+ });
424
+ const retryOutcome = await this.withSessionDeclineRace(this.resolveNextStepAfterCompletion());
425
+ if (await this.consumePendingTerminalEvent()) {
426
+ this.showLoading(null);
427
+ return;
428
+ }
429
+ if (retryOutcome.declined) {
430
+ this.endFlowWithSessionDeclined(retryOutcome.event);
431
+ return;
432
+ }
433
+ next = retryOutcome.value;
434
+ }
435
+ if (next?.step) {
436
+ this.showLoading(null);
437
+ }
438
+ if (!next?.step) break;
439
+
440
+ // RETRY_STEP: the step failed but the retry quota is not exhausted. Show a
441
+ // retry dialog before re-presenting the step. "Retry" re-mounts the same
442
+ // step for a fresh submit; "Cancel" exits the flow cleanly (no verdict).
443
+ // When the quota IS exhausted the backend emits SESSION_DECLINED instead,
444
+ // so this dialog never shows for the final attempt.
445
+ if (next.action === 'RETRY_STEP') {
446
+ const choice = await this.presentRetryStepDialog(next.step);
447
+ if (this.sessionEnded || this.status === 'DESTROYED') return;
448
+ if (await this.consumePendingTerminalEvent()) return;
449
+ if (this.pendingSessionDeclined) {
450
+ const ev = this.pendingSessionDeclined;
451
+ this.pendingSessionDeclined = null;
452
+ this.endFlowWithSessionDeclined(ev);
453
+ return;
454
+ }
455
+ if (choice === 'cancel') {
456
+ this.exitFlow(next.step, 'RETRY_CANCELLED');
457
+ return;
458
+ }
459
+ this.showLoading(this.localizedLoadingMsg());
460
+ }
461
+ currentStep = next.step;
462
+ currentStepConfig = next.stepConfig ?? knownStepConfigs[next.step];
463
+ // Forward navigation: no prefill. `can_go_back` comes from the command
464
+ // when the backend sends it, else derived from the reversibility map.
465
+ currentStepResult = undefined;
466
+ currentCanGoBack = this.resolveCanGoBack(next.canGoBack, next.step);
467
+ }
468
+ this.showLoading(this.localizedFinalizingMsg());
469
+ try {
470
+ if (this.pendingSessionDeclined) {
471
+ const ev = this.pendingSessionDeclined;
472
+ this.pendingSessionDeclined = null;
473
+ this.endFlowWithSessionDeclined(ev);
474
+ return;
475
+ }
476
+ if (await this.consumePendingTerminalEvent()) return;
477
+ const terminalOutcome = await this.withSessionDeclineRace(this.waitForTerminalSseEvent(45_000));
478
+ if (terminalOutcome.declined) {
479
+ this.endFlowWithSessionDeclined(terminalOutcome.event);
480
+ return;
481
+ }
482
+ const terminalEvent = terminalOutcome.value;
483
+ if (terminalEvent) {
484
+ await this.finalizeSessionWithTerminalEvent(terminalEvent);
485
+ return;
486
+ }
487
+ await this.finalizeSessionSingleGet();
488
+ } finally {
489
+ this.showLoading(null);
490
+ }
491
+ }
492
+ createModule(step, stepConfig, stepResult, canGoBack) {
493
+ const deps = {
494
+ api: this.api,
495
+ sessionId: this.config.sessionId,
496
+ locale: this.config.locale ?? 'es',
497
+ colorMode: this.config.colorMode ?? 'light',
498
+ ui: this.uiHandle,
499
+ step,
500
+ ...(stepConfig !== undefined && {
501
+ stepConfig
502
+ }),
503
+ ...(stepResult !== undefined && {
504
+ stepResult
505
+ }),
506
+ // Reverse navigation: wire the "back" control only when the backend says
507
+ // the user can go back from this step (`can_go_back`). The orchestrator
508
+ // owns the POST + SSE handshake; the step only triggers it.
509
+ ...(canGoBack === true && {
510
+ onBack: () => this.requestBackNavigation(step)
511
+ }),
512
+ // Map key fallback chain:
513
+ // 1. `VelionConfig.googleMapsApiKey` (runtime override; takes precedence
514
+ // so hosts that already inject it via JS keep working).
515
+ // 2. `expoConfig.extra.velionGoogleMapsApiKey`, written by the SDK's
516
+ // Expo config plugin (`app.plugin.js`) during prebuild. This is the
517
+ // one-place-to-set-it path documented in the README.
518
+ ...(() => {
519
+ const fromConfig = this.config.googleMapsApiKey;
520
+ const resolved = typeof fromConfig === 'string' && fromConfig.trim().length > 0 ? fromConfig : (0, _velionExtra.getGoogleMapsApiKeyFromExpoExtra)();
521
+ return resolved !== undefined ? {
522
+ googleMapsApiKey: resolved
523
+ } : {};
524
+ })(),
525
+ ...(this.config.fingerprintEndpoint !== undefined && {
526
+ fingerprintEndpoint: this.config.fingerprintEndpoint
527
+ }),
528
+ ...(this.config.fingerprintApiKey !== undefined && {
529
+ fingerprintApiKey: this.config.fingerprintApiKey
530
+ }),
531
+ ...(this.config.fingerprintTimeoutMs !== undefined && {
532
+ fingerprintTimeoutMs: this.config.fingerprintTimeoutMs
533
+ }),
534
+ ...(this.config.livenessCalibrationLabel !== undefined && {
535
+ livenessCalibrationLabel: this.config.livenessCalibrationLabel
536
+ }),
537
+ ...(this.config.onLivenessVideoUploaded !== undefined && {
538
+ onLivenessVideoUploaded: this.config.onLivenessVideoUploaded
539
+ })
540
+ };
541
+ switch (step) {
542
+ case 'DEVICE_FINGERPRINT':
543
+ return new _FingerprintStep.FingerprintStep(deps);
544
+ case 'HUMAN_BASIC_INFO':
545
+ return new _HumanBasicInfoStep.HumanBasicInfoStep(deps);
546
+ case 'EMAIL_CONTACT':
547
+ return new _EmailContactStep.EmailContactStep(deps);
548
+ case 'PHONE_CONTACT':
549
+ return new _PhoneContactStep.PhoneContactStep(deps);
550
+ case 'EMAIL_OTP':
551
+ return new _EmailOtpStep.EmailOtpStep(deps);
552
+ case 'PHONE_OTP':
553
+ return new _PhoneOtpStep.PhoneOtpStep(deps);
554
+ case 'TAX_INFO':
555
+ return new _TaxInfoStep.TaxInfoStep(deps);
556
+ case 'SWORN_DECLARATION':
557
+ return new _SwornDeclarationStep.SwornDeclarationStep(deps);
558
+ case 'ECONOMIC_ACTIVITY_DECLARATION':
559
+ return new _EconomicActivityStep.EconomicActivityStep(deps);
560
+ case 'TERMS_AND_CONDITIONS':
561
+ return new _TermsAndConditionsStep.TermsAndConditionsStep(deps);
562
+ case 'LEGAL_BASIC_INFO':
563
+ return new _LegalBasicInfoStep.LegalBasicInfoStep(deps);
564
+ case 'HUMAN_EXTENDED_INFO':
565
+ return new _HumanExtendedInfoStep.HumanExtendedInfoStep(deps);
566
+ case 'LEGAL_EXTENDED_INFO':
567
+ return new _LegalExtendedInfoStep.LegalExtendedInfoStep(deps);
568
+ case 'ADDRESS_INFO':
569
+ return new _AddressInfoStep.AddressInfoStep(deps);
570
+ case 'DOCUMENTS_OCR':
571
+ return new _DocumentsOcrStep.DocumentsOcrStep(deps);
572
+ case 'LIVENESS_MATCH':
573
+ return new _LivenessMatchStep.LivenessMatchStep(deps);
574
+ case 'FACE_MATCH':
575
+ return new _FaceMatchStep.FaceMatchStep(deps);
576
+ default:
577
+ throw {
578
+ code: _types.SdkErrorCode.UNKNOWN,
579
+ message: `Step "${String(step)}" is not implemented yet in the React Native SDK. ` + 'See the port roadmap in the repo README.'
580
+ };
581
+ }
582
+ }
583
+
584
+ // ── Finalization ──────────────────────────────────────────────────────────
585
+
586
+ async finalizeSessionWithTerminalEvent(event) {
587
+ const status = terminalEventTypeToStatus(event.event_type);
588
+ if (!status) {
589
+ await this.finalizeSessionSingleGet();
590
+ return;
591
+ }
592
+ let dto;
593
+ try {
594
+ dto = await this.api.get(`/sessions/${this.config.sessionId}`);
595
+ } catch (err) {
596
+ throw {
597
+ code: _types.SdkErrorCode.API_ERROR,
598
+ message: 'All steps completed but failed to retrieve the final session result.',
599
+ cause: err
600
+ };
601
+ }
602
+ const result = (0, _sessionStateMapper.mapOnboardingDtoToResultWithStatus)(dto, this.config.sessionId, status, event.reason);
603
+ this.completeFlow(result);
604
+ }
605
+ async finalizeSessionSingleGet() {
606
+ let dto;
607
+ try {
608
+ dto = await this.api.get(`/sessions/${this.config.sessionId}`);
609
+ } catch (err) {
610
+ throw {
611
+ code: _types.SdkErrorCode.API_ERROR,
612
+ message: 'All steps completed but no terminal SSE event was received within the timeout, and the session fetch failed.',
613
+ cause: err
614
+ };
615
+ }
616
+ const result = (0, _sessionStateMapper.mapOnboardingDtoToResult)(dto, this.config.sessionId);
617
+ this.completeFlow(result);
618
+ }
619
+ completeFlow(result) {
620
+ this.sessionEnded = true;
621
+ this.setStatus('COMPLETED');
622
+ _log.log.info('[Flow] Session finalized', {
623
+ sessionId: result.sessionId,
624
+ status: result.status,
625
+ terminalReason: result.terminalReason,
626
+ referenceId: result.referenceId,
627
+ completedAt: result.completedAt
628
+ });
629
+ this.view.setResult?.(result);
630
+ this.emitter.emit('flow:complete', result);
631
+ }
632
+
633
+ /**
634
+ * Ends the flow without a verdict and notifies the host via `onExit`. Not an
635
+ * error: the UI is cleared so the host can dismiss the SDK. Triggered by
636
+ * backing out of the first reversible step (`BACK_EXIT`) or cancelling the
637
+ * retry dialog (`RETRY_CANCELLED`).
638
+ */
639
+ exitFlow(step, reason = 'BACK_EXIT') {
640
+ if (this.sessionEnded) return;
641
+ this.sessionEnded = true;
642
+ this.view.setStepNode?.(null);
643
+ this.setStatus('EXITED');
644
+ _log.log.info('[Flow] Session exited', {
645
+ sessionId: this.config.sessionId,
646
+ reason,
647
+ step
648
+ });
649
+ const exit = {
650
+ reason,
651
+ ...(step !== undefined && {
652
+ step
653
+ })
654
+ };
655
+ this.view.setExit?.(exit);
656
+ this.emitter.emit('flow:exit', exit);
657
+ }
658
+
659
+ /**
660
+ * Mounts the retry dialog for a `RETRY_STEP` and resolves with the user's
661
+ * choice. Copy is derived from the step (not the backend `reason`, which is a
662
+ * diagnostic string) and can be overridden per-step via `retryStepTexts`.
663
+ */
664
+ presentRetryStepDialog(step) {
665
+ const copy = (0, _retryStepCopy.resolveRetryStepCopy)(this.config.locale, this.config.retryStepTexts, step);
666
+ _log.log.info('[Flow] Presenting RETRY_STEP dialog', {
667
+ step
668
+ });
669
+ return new Promise(resolve => {
670
+ const settle = choice => {
671
+ if (this.retryDialogResolve === null) return;
672
+ this.retryDialogResolve = null;
673
+ this.view.setStepNode?.(null);
674
+ resolve(choice);
675
+ };
676
+ this.retryDialogResolve = resolve;
677
+ this.view.setStepNode?.(/*#__PURE__*/(0, _react.createElement)(_RetryDialog.RetryDialog, {
678
+ title: copy.title,
679
+ message: copy.message,
680
+ retryLabel: copy.retryLabel,
681
+ cancelLabel: copy.cancelLabel,
682
+ onRetry: () => settle('retry'),
683
+ onCancel: () => settle('cancel')
684
+ }));
685
+ });
686
+ }
687
+ endFlowWithSessionDeclined(event) {
688
+ if (this.sessionEnded) return;
689
+ this.sessionEnded = true;
690
+ _log.log.info('[Flow] Session finalized', {
691
+ sessionId: this.config.sessionId,
692
+ status: 'DECLINED',
693
+ terminalReason: event.reason,
694
+ stepCode: event.step_code
695
+ });
696
+ const copy = (0, _sessionDeclinedCopy.resolveSessionDeclinedCopy)(this.config.locale, this.config.sessionDeclinedReasonTexts, event.reason, this.config.finalResultScreenTexts?.dismissLabel);
697
+ const err = {
698
+ code: _types.SdkErrorCode.SESSION_DECLINED,
699
+ message: copy.message,
700
+ ...(event.reason !== undefined && {
701
+ declineReason: event.reason
702
+ }),
703
+ ...(event.step_code !== undefined && {
704
+ stepCode: event.step_code
705
+ }),
706
+ declineTitle: copy.title,
707
+ declineMessage: copy.message
708
+ };
709
+ this.emitError(err);
710
+ }
711
+
712
+ // ── SSE plumbing ──────────────────────────────────────────────────────────
713
+
714
+ openSseStream(sessionToken) {
715
+ this.sseCleanup = (0, _sse.createSessionEventSource)({
716
+ baseUrl: this.config.apiUrl,
717
+ sessionId: this.config.sessionId,
718
+ sessionToken,
719
+ lastEventId: this.lastSseEventId,
720
+ signal: this.sseAbortController.signal,
721
+ onEvent: event => this.handleSseEvent(event),
722
+ onError: err => {
723
+ _log.log.warn('[Flow] SSE onError callback invoked', err);
724
+ }
725
+ });
726
+ }
727
+ handleSseEvent(event) {
728
+ if (this.sessionEnded) return;
729
+ if (event.event_id !== undefined) {
730
+ const incoming = Number(event.event_id);
731
+ const lastSeen = Number(this.lastSseEventId);
732
+ if (Number.isFinite(incoming) && Number.isFinite(lastSeen) && incoming <= lastSeen) {
733
+ _log.log.info('[SSE] Skipping replayed event', {
734
+ eventId: event.event_id,
735
+ lastSeen: this.lastSseEventId,
736
+ eventType: event.event_type,
737
+ action: event.action
738
+ });
739
+ return;
740
+ }
741
+ if (Number.isFinite(incoming)) {
742
+ this.lastSseEventId = String(event.event_id);
743
+ }
744
+ }
745
+ this.config.onSessionEvent?.(event);
746
+ const isTerminal = isTerminalSessionEvent(event);
747
+ if (event.event_type === 'SESSION_DECLINED') {
748
+ this.pendingTerminalEvent = event;
749
+ if (this.sessionDeclineHandler) {
750
+ this.sessionDeclineHandler(event);
751
+ } else {
752
+ this.pendingSessionDeclined = event;
753
+ }
754
+ return;
755
+ }
756
+ if (isTerminal) {
757
+ this.pendingTerminalEvent = event;
758
+ if (this.sseNextStepResolve) {
759
+ _log.log.info('[Flow] Terminal event interrupted ROUTING_COMMAND wait', {
760
+ eventType: event.event_type
761
+ });
762
+ const resolveNext = this.sseNextStepResolve;
763
+ this.sseNextStepResolve = null;
764
+ resolveNext(null);
765
+ }
766
+ }
767
+ const maybePrevious = (0, _routingCommands.parsePreviousStepCommand)(event);
768
+ if (maybePrevious) {
769
+ _log.log.info('[Flow] PREVIOUS_STEP received from SSE', {
770
+ step: maybePrevious.step,
771
+ hasStepConfig: maybePrevious.stepConfig !== undefined,
772
+ hasStepResult: maybePrevious.stepResult !== undefined
773
+ });
774
+ if (this.previousStepResolve) {
775
+ const resolve = this.previousStepResolve;
776
+ this.previousStepResolve = null;
777
+ resolve(maybePrevious);
778
+ } else {
779
+ // Defensive: a PREVIOUS_STEP arrived while no step was waiting for it
780
+ // (e.g. between transitions). Queue it so the next module entry honors it.
781
+ this.queuedPreviousStepCommand = maybePrevious;
782
+ }
783
+ return;
784
+ }
785
+ const maybeBackExit = (0, _routingCommands.parseBackExitCommand)(event);
786
+ if (maybeBackExit) {
787
+ _log.log.info('[Flow] BACK_EXIT received from SSE', {
788
+ step: maybeBackExit.step
789
+ });
790
+ if (this.backExitResolve) {
791
+ const resolve = this.backExitResolve;
792
+ this.backExitResolve = null;
793
+ resolve(maybeBackExit.step);
794
+ } else {
795
+ this.queuedBackExitStep = {
796
+ step: maybeBackExit.step
797
+ };
798
+ }
799
+ return;
800
+ }
801
+ const maybeNext = this.extractNextStepCommand(event);
802
+ if (maybeNext) {
803
+ _log.log.info('[Flow] ROUTING_COMMAND received from SSE', {
804
+ step: maybeNext.step,
805
+ hasStepConfig: maybeNext.stepConfig !== undefined,
806
+ eventType: event.event_type,
807
+ action: event.action
808
+ });
809
+ if (this.sseNextStepResolve) {
810
+ const resolve = this.sseNextStepResolve;
811
+ this.sseNextStepResolve = null;
812
+ resolve(maybeNext);
813
+ } else {
814
+ this.queuedNextStepCommand = maybeNext;
815
+ }
816
+ }
817
+ if (this.sseTerminalResolve && isTerminal) {
818
+ _log.log.info('[Flow] Terminal event received from SSE', {
819
+ eventType: event.event_type
820
+ });
821
+ const resolve = this.sseTerminalResolve;
822
+ this.sseTerminalResolve = null;
823
+ resolve(event);
824
+ }
825
+ }
826
+ extractNextStepCommand(event) {
827
+ if (event.event_type !== 'ROUTING_COMMAND') return null;
828
+ const action = event.action;
829
+ if (action !== 'NEXT_STEP' && action !== 'RETRY_STEP') return null;
830
+ const step = event.step_code;
831
+ if (!step) return null;
832
+ return {
833
+ step,
834
+ action,
835
+ ...(event.step_config !== undefined && {
836
+ stepConfig: event.step_config
837
+ }),
838
+ ...(typeof event.can_go_back === 'boolean' && {
839
+ canGoBack: event.can_go_back
840
+ })
841
+ };
842
+ }
843
+
844
+ /**
845
+ * Fire-and-forget reverse navigation. POSTs `/sessions/:id/back`; the actual
846
+ * step transition arrives via SSE (`PREVIOUS_STEP`). A `400` (session not
847
+ * IN_PROGRESS) or any other failure is swallowed — the user keeps editing the
848
+ * current step. De-duplicated so rapid taps don't stack requests.
849
+ */
850
+ requestBackNavigation(fromStep) {
851
+ if (this.status === 'DESTROYED' || this.sessionEnded) return;
852
+ if (this.backRequestInFlight) return;
853
+ this.backRequestInFlight = true;
854
+ _log.log.info('[Flow] Requesting reverse navigation', {
855
+ fromStep
856
+ });
857
+ void this.api.post(`/sessions/${this.config.sessionId}/back`, {
858
+ from_step: fromStep
859
+ }).catch(err => {
860
+ _log.log.warn('[Flow] Back navigation request failed (ignored)', err);
861
+ }).finally(() => {
862
+ this.backRequestInFlight = false;
863
+ });
864
+ }
865
+
866
+ /**
867
+ * Derives `can_go_back` for a step from the cached workflow reversibility map.
868
+ * Matches the backend's barrier model: a step can go back when any earlier
869
+ * step is reversible (navigate) or the step itself is the first reversible one
870
+ * (back exits). Fallback only — an explicit `can_go_back` from the backend
871
+ * (GET, or a ROUTING_COMMAND that carries it) always wins.
872
+ */
873
+ resolveCanGoBack(explicit, step) {
874
+ return typeof explicit === 'boolean' ? explicit : (0, _sessionStateMapper.deriveCanGoBack)(step, this.stepReversibility);
875
+ }
876
+
877
+ // ── Wait helpers ──────────────────────────────────────────────────────────
878
+
879
+ /**
880
+ * Wait for the next ROUTING_COMMAND. The orchestrator races this with a 30 s
881
+ * timeout that, on fire, falls back to a fresh GET /sessions/:id to recover
882
+ * if SSE was missed.
883
+ */
884
+ resolveNextStepAfterCompletion() {
885
+ if (this.queuedNextStepCommand) {
886
+ const next = this.queuedNextStepCommand;
887
+ this.queuedNextStepCommand = null;
888
+ return Promise.resolve(next);
889
+ }
890
+ return new Promise(resolve => {
891
+ const timeout = setTimeout(async () => {
892
+ if (this.sseNextStepResolve) {
893
+ this.sseNextStepResolve = null;
894
+ }
895
+ _log.log.warn('[Flow] No ROUTING_COMMAND within 30 s — falling back to GET /sessions for next step');
896
+ try {
897
+ const dto = await this.api.get(`/sessions/${this.config.sessionId}`, {
898
+ extraHeaders: {
899
+ 'Cache-Control': 'no-cache, no-store, must-revalidate'
900
+ }
901
+ });
902
+ if ((0, _sessionStateMapper.isTerminalSessionStatusFromDto)(dto.status)) {
903
+ resolve(null);
904
+ return;
905
+ }
906
+ const state = (0, _sessionStateMapper.mapOnboardingDtoToSessionState)(dto);
907
+ if (state.currentStep) {
908
+ resolve({
909
+ step: state.currentStep,
910
+ action: 'NEXT_STEP',
911
+ ...(state.currentStepConfig !== undefined && {
912
+ stepConfig: state.currentStepConfig
913
+ }),
914
+ ...(state.canGoBack !== undefined && {
915
+ canGoBack: state.canGoBack
916
+ })
917
+ });
918
+ return;
919
+ }
920
+ resolve(null);
921
+ } catch (err) {
922
+ _log.log.error('[Flow] Fallback GET /sessions failed', err);
923
+ resolve(null);
924
+ }
925
+ }, 30_000);
926
+ this.sseNextStepResolve = cmd => {
927
+ clearTimeout(timeout);
928
+ resolve(cmd);
929
+ };
930
+ });
931
+ }
932
+ waitForRoutingAfterBackendOnlyStep() {
933
+ return this.resolveNextStepAfterCompletion();
934
+ }
935
+ waitForTerminalSseEvent(timeoutMs) {
936
+ if (this.pendingTerminalEvent) {
937
+ const ev = this.pendingTerminalEvent;
938
+ return Promise.resolve(ev);
939
+ }
940
+ return new Promise(resolve => {
941
+ const timeout = setTimeout(() => {
942
+ if (this.sseTerminalResolve) {
943
+ this.sseTerminalResolve = null;
944
+ resolve(null);
945
+ }
946
+ }, timeoutMs);
947
+ this.sseTerminalResolve = event => {
948
+ clearTimeout(timeout);
949
+ resolve(event);
950
+ };
951
+ });
952
+ }
953
+
954
+ /**
955
+ * Drain a pending terminal event (e.g. SESSION_APPROVED arrived while the
956
+ * orchestrator was busy mid-step). Returns true when the flow has been ended
957
+ * by the consumed event.
958
+ */
959
+ async consumePendingTerminalEvent() {
960
+ const event = this.pendingTerminalEvent;
961
+ if (!event) return false;
962
+ this.pendingTerminalEvent = null;
963
+ if (event.event_type === 'SESSION_DECLINED') {
964
+ this.endFlowWithSessionDeclined(event);
965
+ return true;
966
+ }
967
+ await this.finalizeSessionWithTerminalEvent(event);
968
+ return true;
969
+ }
970
+
971
+ /**
972
+ * Runs the active step, resolving on the first of:
973
+ * - `completed` — the module's `run()` resolved (user advanced),
974
+ * - `declined` — SESSION_DECLINED arrived mid-step,
975
+ * - `back` — a PREVIOUS_STEP routing command arrived (user tapped back),
976
+ * - `exit` — a BACK_EXIT routing command arrived (back on the first
977
+ * reversible step → leave the flow).
978
+ *
979
+ * Rejects only if `run()` itself throws. Used in place of the plain decline
980
+ * race for the step loop so reverse navigation can interrupt an active form.
981
+ */
982
+ awaitModuleOutcome(run) {
983
+ if (this.queuedPreviousStepCommand) {
984
+ const command = this.queuedPreviousStepCommand;
985
+ this.queuedPreviousStepCommand = null;
986
+ return Promise.resolve({
987
+ kind: 'back',
988
+ command
989
+ });
990
+ }
991
+ if (this.queuedBackExitStep) {
992
+ const {
993
+ step
994
+ } = this.queuedBackExitStep;
995
+ this.queuedBackExitStep = null;
996
+ return Promise.resolve({
997
+ kind: 'exit',
998
+ step
999
+ });
1000
+ }
1001
+ return new Promise((resolve, reject) => {
1002
+ let settled = false;
1003
+ const cleanup = () => {
1004
+ this.sessionDeclineHandler = null;
1005
+ this.previousStepResolve = null;
1006
+ this.backExitResolve = null;
1007
+ };
1008
+ const settle = run2 => {
1009
+ if (settled) return;
1010
+ settled = true;
1011
+ cleanup();
1012
+ run2();
1013
+ };
1014
+ this.sessionDeclineHandler = event => settle(() => resolve({
1015
+ kind: 'declined',
1016
+ event
1017
+ }));
1018
+ this.previousStepResolve = command => settle(() => resolve({
1019
+ kind: 'back',
1020
+ command
1021
+ }));
1022
+ this.backExitResolve = step => settle(() => resolve({
1023
+ kind: 'exit',
1024
+ step
1025
+ }));
1026
+ run.then(() => settle(() => resolve({
1027
+ kind: 'completed'
1028
+ }))).catch(err => settle(() => reject(err)));
1029
+ });
1030
+ }
1031
+
1032
+ /**
1033
+ * Race a step's promise against SESSION_DECLINED. If decline arrives first,
1034
+ * `declined` is true so the caller can short-circuit cleanup.
1035
+ */
1036
+ withSessionDeclineRace(promise) {
1037
+ return new Promise((resolve, reject) => {
1038
+ let settled = false;
1039
+ const declineHandler = event => {
1040
+ if (settled) return;
1041
+ settled = true;
1042
+ this.sessionDeclineHandler = null;
1043
+ resolve({
1044
+ declined: true,
1045
+ event
1046
+ });
1047
+ };
1048
+ this.sessionDeclineHandler = declineHandler;
1049
+ promise.then(value => {
1050
+ if (settled) return;
1051
+ settled = true;
1052
+ this.sessionDeclineHandler = null;
1053
+ resolve({
1054
+ declined: false,
1055
+ value
1056
+ });
1057
+ }).catch(err => {
1058
+ if (settled) return;
1059
+ settled = true;
1060
+ this.sessionDeclineHandler = null;
1061
+ reject(err);
1062
+ });
1063
+ });
1064
+ }
1065
+
1066
+ // ── Helpers ───────────────────────────────────────────────────────────────
1067
+
1068
+ wireExternalCallbacks() {
1069
+ const cb = this.config;
1070
+ if (cb.onError) this.emitter.on('error', cb.onError);
1071
+ if (cb.onSuccess) this.emitter.on('flow:complete', cb.onSuccess);
1072
+ if (cb.onExit) this.emitter.on('flow:exit', cb.onExit);
1073
+ if (cb.onStepChange) {
1074
+ this.emitter.on('step:change', ({
1075
+ step,
1076
+ index
1077
+ }) => cb.onStepChange?.(step, index));
1078
+ }
1079
+ if (cb.onStepComplete) {
1080
+ this.emitter.on('step:complete', ({
1081
+ step
1082
+ }) => cb.onStepComplete?.(step));
1083
+ }
1084
+ // session:loaded has no public callback — internal only.
1085
+ }
1086
+ setStatus(next) {
1087
+ this.status = next;
1088
+ this.emitter.emit('status:change', next);
1089
+ }
1090
+ emitError(err) {
1091
+ if (this.status === 'DESTROYED') return;
1092
+ this.setStatus('ERROR');
1093
+ this.view.setError?.(err);
1094
+ this.emitter.emit('error', err);
1095
+ }
1096
+ isEnglish() {
1097
+ return (this.config.locale ?? 'es').toLowerCase().startsWith('en');
1098
+ }
1099
+ localizedLoadingMsg() {
1100
+ return this.isEnglish() ? 'Loading…' : 'Cargando…';
1101
+ }
1102
+ localizedProcessingMsg() {
1103
+ return this.isEnglish() ? 'Processing your verification…' : 'Procesando tu verificación…';
1104
+ }
1105
+ localizedFinalizingMsg() {
1106
+ return this.isEnglish() ? 'Processing your information…' : 'Procesando tu información…';
1107
+ }
1108
+ showLoading(text) {
1109
+ this.view.setLoading?.(text);
1110
+ }
1111
+ }
1112
+ exports.VelionOnboarding = VelionOnboarding;
1113
+ //# sourceMappingURL=VelionOnboarding.js.map