@velion-la/onboarding-sdk-react-native 1.0.0-beta.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 (557) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/LICENSE +12 -0
  3. package/README.md +803 -0
  4. package/lib/commonjs/camera/AddressSearchBar.js +304 -0
  5. package/lib/commonjs/camera/AddressSearchBar.js.map +1 -0
  6. package/lib/commonjs/camera/DocumentCapture.js +505 -0
  7. package/lib/commonjs/camera/DocumentCapture.js.map +1 -0
  8. package/lib/commonjs/camera/LivenessCamera.js +534 -0
  9. package/lib/commonjs/camera/LivenessCamera.js.map +1 -0
  10. package/lib/commonjs/camera/MapAddressPicker.js +341 -0
  11. package/lib/commonjs/camera/MapAddressPicker.js.map +1 -0
  12. package/lib/commonjs/core/VelionOnboarding.js +815 -0
  13. package/lib/commonjs/core/VelionOnboarding.js.map +1 -0
  14. package/lib/commonjs/core/sessionDeclinedCopy.js +56 -0
  15. package/lib/commonjs/core/sessionDeclinedCopy.js.map +1 -0
  16. package/lib/commonjs/core/sessionStateMapper.js +137 -0
  17. package/lib/commonjs/core/sessionStateMapper.js.map +1 -0
  18. package/lib/commonjs/core/sseReasonMessages.js +450 -0
  19. package/lib/commonjs/core/sseReasonMessages.js.map +1 -0
  20. package/lib/commonjs/data/iso3166Alpha2Codes.json +1 -0
  21. package/lib/commonjs/data/iso3166CountryNames.json +251 -0
  22. package/lib/commonjs/i18n/index.js +30 -0
  23. package/lib/commonjs/i18n/index.js.map +1 -0
  24. package/lib/commonjs/i18n/strings/en.js +261 -0
  25. package/lib/commonjs/i18n/strings/en.js.map +1 -0
  26. package/lib/commonjs/i18n/strings/es.js +266 -0
  27. package/lib/commonjs/i18n/strings/es.js.map +1 -0
  28. package/lib/commonjs/index.js +213 -0
  29. package/lib/commonjs/index.js.map +1 -0
  30. package/lib/commonjs/package.json +1 -0
  31. package/lib/commonjs/steps/AddressInfoStep.js +650 -0
  32. package/lib/commonjs/steps/AddressInfoStep.js.map +1 -0
  33. package/lib/commonjs/steps/DocumentsOcrStep.js +397 -0
  34. package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -0
  35. package/lib/commonjs/steps/EmailContactStep.js +145 -0
  36. package/lib/commonjs/steps/EmailContactStep.js.map +1 -0
  37. package/lib/commonjs/steps/EmailOtpStep.js +220 -0
  38. package/lib/commonjs/steps/EmailOtpStep.js.map +1 -0
  39. package/lib/commonjs/steps/FaceMatchStep.js +166 -0
  40. package/lib/commonjs/steps/FaceMatchStep.js.map +1 -0
  41. package/lib/commonjs/steps/FingerprintStep.js +92 -0
  42. package/lib/commonjs/steps/FingerprintStep.js.map +1 -0
  43. package/lib/commonjs/steps/HumanBasicInfoStep.js +243 -0
  44. package/lib/commonjs/steps/HumanBasicInfoStep.js.map +1 -0
  45. package/lib/commonjs/steps/HumanExtendedInfoStep.js +268 -0
  46. package/lib/commonjs/steps/HumanExtendedInfoStep.js.map +1 -0
  47. package/lib/commonjs/steps/LegalBasicInfoStep.js +188 -0
  48. package/lib/commonjs/steps/LegalBasicInfoStep.js.map +1 -0
  49. package/lib/commonjs/steps/LegalExtendedInfoStep.js +166 -0
  50. package/lib/commonjs/steps/LegalExtendedInfoStep.js.map +1 -0
  51. package/lib/commonjs/steps/LivenessMatchStep.js +707 -0
  52. package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -0
  53. package/lib/commonjs/steps/PhoneContactStep.js +146 -0
  54. package/lib/commonjs/steps/PhoneContactStep.js.map +1 -0
  55. package/lib/commonjs/steps/PhoneOtpStep.js +219 -0
  56. package/lib/commonjs/steps/PhoneOtpStep.js.map +1 -0
  57. package/lib/commonjs/steps/SwornDeclarationStep.js +196 -0
  58. package/lib/commonjs/steps/SwornDeclarationStep.js.map +1 -0
  59. package/lib/commonjs/steps/TaxInfoStep.js +244 -0
  60. package/lib/commonjs/steps/TaxInfoStep.js.map +1 -0
  61. package/lib/commonjs/steps/TermsAndConditionsStep.js +238 -0
  62. package/lib/commonjs/steps/TermsAndConditionsStep.js.map +1 -0
  63. package/lib/commonjs/steps/_shared.js +40 -0
  64. package/lib/commonjs/steps/_shared.js.map +1 -0
  65. package/lib/commonjs/steps/types.js +6 -0
  66. package/lib/commonjs/steps/types.js.map +1 -0
  67. package/lib/commonjs/transport/api.js +176 -0
  68. package/lib/commonjs/transport/api.js.map +1 -0
  69. package/lib/commonjs/transport/irisWebSocket.js +121 -0
  70. package/lib/commonjs/transport/irisWebSocket.js.map +1 -0
  71. package/lib/commonjs/transport/secureUrl.js +50 -0
  72. package/lib/commonjs/transport/secureUrl.js.map +1 -0
  73. package/lib/commonjs/transport/sse.js +248 -0
  74. package/lib/commonjs/transport/sse.js.map +1 -0
  75. package/lib/commonjs/types/index.js +391 -0
  76. package/lib/commonjs/types/index.js.map +1 -0
  77. package/lib/commonjs/ui/MapFallbackBoundary.js +42 -0
  78. package/lib/commonjs/ui/MapFallbackBoundary.js.map +1 -0
  79. package/lib/commonjs/ui/StepShell.js +118 -0
  80. package/lib/commonjs/ui/StepShell.js.map +1 -0
  81. package/lib/commonjs/ui/VelionOnboardingScreen.js +217 -0
  82. package/lib/commonjs/ui/VelionOnboardingScreen.js.map +1 -0
  83. package/lib/commonjs/ui/forms/index.js +38 -0
  84. package/lib/commonjs/ui/forms/index.js.map +1 -0
  85. package/lib/commonjs/ui/forms/useInlineValidation.js +88 -0
  86. package/lib/commonjs/ui/forms/useInlineValidation.js.map +1 -0
  87. package/lib/commonjs/ui/forms/validators.js +34 -0
  88. package/lib/commonjs/ui/forms/validators.js.map +1 -0
  89. package/lib/commonjs/ui/icons/HomeHeartIcon.js +38 -0
  90. package/lib/commonjs/ui/icons/HomeHeartIcon.js.map +1 -0
  91. package/lib/commonjs/ui/icons/StepIcon.js +59 -0
  92. package/lib/commonjs/ui/icons/StepIcon.js.map +1 -0
  93. package/lib/commonjs/ui/overlays/AnalyzingOverlay.js +284 -0
  94. package/lib/commonjs/ui/overlays/AnalyzingOverlay.js.map +1 -0
  95. package/lib/commonjs/ui/overlays/LoadingOverlay.js +108 -0
  96. package/lib/commonjs/ui/overlays/LoadingOverlay.js.map +1 -0
  97. package/lib/commonjs/ui/overlays/ProgressBar.js +95 -0
  98. package/lib/commonjs/ui/overlays/ProgressBar.js.map +1 -0
  99. package/lib/commonjs/ui/overlays/RetryDialog.js +125 -0
  100. package/lib/commonjs/ui/overlays/RetryDialog.js.map +1 -0
  101. package/lib/commonjs/ui/overlays/index.js +33 -0
  102. package/lib/commonjs/ui/overlays/index.js.map +1 -0
  103. package/lib/commonjs/ui/primitives/Banner.js +81 -0
  104. package/lib/commonjs/ui/primitives/Banner.js.map +1 -0
  105. package/lib/commonjs/ui/primitives/Button.js +142 -0
  106. package/lib/commonjs/ui/primitives/Button.js.map +1 -0
  107. package/lib/commonjs/ui/primitives/Card.js +50 -0
  108. package/lib/commonjs/ui/primitives/Card.js.map +1 -0
  109. package/lib/commonjs/ui/primitives/Checkbox.js +139 -0
  110. package/lib/commonjs/ui/primitives/Checkbox.js.map +1 -0
  111. package/lib/commonjs/ui/primitives/CountrySelect.js +288 -0
  112. package/lib/commonjs/ui/primitives/CountrySelect.js.map +1 -0
  113. package/lib/commonjs/ui/primitives/DatePicker.js +245 -0
  114. package/lib/commonjs/ui/primitives/DatePicker.js.map +1 -0
  115. package/lib/commonjs/ui/primitives/Input.js +101 -0
  116. package/lib/commonjs/ui/primitives/Input.js.map +1 -0
  117. package/lib/commonjs/ui/primitives/Select.js +209 -0
  118. package/lib/commonjs/ui/primitives/Select.js.map +1 -0
  119. package/lib/commonjs/ui/primitives/Spinner.js +25 -0
  120. package/lib/commonjs/ui/primitives/Spinner.js.map +1 -0
  121. package/lib/commonjs/ui/primitives/index.js +69 -0
  122. package/lib/commonjs/ui/primitives/index.js.map +1 -0
  123. package/lib/commonjs/ui/theme/ThemeProvider.js +74 -0
  124. package/lib/commonjs/ui/theme/ThemeProvider.js.map +1 -0
  125. package/lib/commonjs/ui/theme/index.js +68 -0
  126. package/lib/commonjs/ui/theme/index.js.map +1 -0
  127. package/lib/commonjs/ui/theme/tokens.js +154 -0
  128. package/lib/commonjs/ui/theme/tokens.js.map +1 -0
  129. package/lib/commonjs/utils/EventEmitter.js +144 -0
  130. package/lib/commonjs/utils/EventEmitter.js.map +1 -0
  131. package/lib/commonjs/utils/base64.js +53 -0
  132. package/lib/commonjs/utils/base64.js.map +1 -0
  133. package/lib/commonjs/utils/deviceFingerprint.js +132 -0
  134. package/lib/commonjs/utils/deviceFingerprint.js.map +1 -0
  135. package/lib/commonjs/utils/documentTypeOptions.js +35 -0
  136. package/lib/commonjs/utils/documentTypeOptions.js.map +1 -0
  137. package/lib/commonjs/utils/googleMapsPreflight.js +77 -0
  138. package/lib/commonjs/utils/googleMapsPreflight.js.map +1 -0
  139. package/lib/commonjs/utils/hmac.js +58 -0
  140. package/lib/commonjs/utils/hmac.js.map +1 -0
  141. package/lib/commonjs/utils/iso3166Countries.js +98 -0
  142. package/lib/commonjs/utils/iso3166Countries.js.map +1 -0
  143. package/lib/commonjs/utils/jpegFromUri.js +44 -0
  144. package/lib/commonjs/utils/jpegFromUri.js.map +1 -0
  145. package/lib/commonjs/utils/keepAwake.js +58 -0
  146. package/lib/commonjs/utils/keepAwake.js.map +1 -0
  147. package/lib/commonjs/utils/log.js +42 -0
  148. package/lib/commonjs/utils/log.js.map +1 -0
  149. package/lib/commonjs/utils/osGeocoder.js +70 -0
  150. package/lib/commonjs/utils/osGeocoder.js.map +1 -0
  151. package/lib/commonjs/utils/parseGoogleAddressComponents.js +74 -0
  152. package/lib/commonjs/utils/parseGoogleAddressComponents.js.map +1 -0
  153. package/lib/commonjs/utils/personNameNormalize.js +24 -0
  154. package/lib/commonjs/utils/personNameNormalize.js.map +1 -0
  155. package/lib/commonjs/utils/sdkError.js +34 -0
  156. package/lib/commonjs/utils/sdkError.js.map +1 -0
  157. package/lib/commonjs/utils/sdkVersion.js +13 -0
  158. package/lib/commonjs/utils/sdkVersion.js.map +1 -0
  159. package/lib/commonjs/utils/stepConfig.js +65 -0
  160. package/lib/commonjs/utils/stepConfig.js.map +1 -0
  161. package/lib/commonjs/utils/taxInfoConfig.js +19 -0
  162. package/lib/commonjs/utils/taxInfoConfig.js.map +1 -0
  163. package/lib/module/camera/AddressSearchBar.js +299 -0
  164. package/lib/module/camera/AddressSearchBar.js.map +1 -0
  165. package/lib/module/camera/DocumentCapture.js +500 -0
  166. package/lib/module/camera/DocumentCapture.js.map +1 -0
  167. package/lib/module/camera/LivenessCamera.js +529 -0
  168. package/lib/module/camera/LivenessCamera.js.map +1 -0
  169. package/lib/module/camera/MapAddressPicker.js +337 -0
  170. package/lib/module/camera/MapAddressPicker.js.map +1 -0
  171. package/lib/module/core/VelionOnboarding.js +811 -0
  172. package/lib/module/core/VelionOnboarding.js.map +1 -0
  173. package/lib/module/core/sessionDeclinedCopy.js +52 -0
  174. package/lib/module/core/sessionDeclinedCopy.js.map +1 -0
  175. package/lib/module/core/sessionStateMapper.js +128 -0
  176. package/lib/module/core/sessionStateMapper.js.map +1 -0
  177. package/lib/module/core/sseReasonMessages.js +446 -0
  178. package/lib/module/core/sseReasonMessages.js.map +1 -0
  179. package/lib/module/data/iso3166Alpha2Codes.json +1 -0
  180. package/lib/module/data/iso3166CountryNames.json +251 -0
  181. package/lib/module/i18n/index.js +25 -0
  182. package/lib/module/i18n/index.js.map +1 -0
  183. package/lib/module/i18n/strings/en.js +257 -0
  184. package/lib/module/i18n/strings/en.js.map +1 -0
  185. package/lib/module/i18n/strings/es.js +262 -0
  186. package/lib/module/i18n/strings/es.js.map +1 -0
  187. package/lib/module/index.js +36 -0
  188. package/lib/module/index.js.map +1 -0
  189. package/lib/module/steps/AddressInfoStep.js +646 -0
  190. package/lib/module/steps/AddressInfoStep.js.map +1 -0
  191. package/lib/module/steps/DocumentsOcrStep.js +391 -0
  192. package/lib/module/steps/DocumentsOcrStep.js.map +1 -0
  193. package/lib/module/steps/EmailContactStep.js +140 -0
  194. package/lib/module/steps/EmailContactStep.js.map +1 -0
  195. package/lib/module/steps/EmailOtpStep.js +215 -0
  196. package/lib/module/steps/EmailOtpStep.js.map +1 -0
  197. package/lib/module/steps/FaceMatchStep.js +161 -0
  198. package/lib/module/steps/FaceMatchStep.js.map +1 -0
  199. package/lib/module/steps/FingerprintStep.js +87 -0
  200. package/lib/module/steps/FingerprintStep.js.map +1 -0
  201. package/lib/module/steps/HumanBasicInfoStep.js +238 -0
  202. package/lib/module/steps/HumanBasicInfoStep.js.map +1 -0
  203. package/lib/module/steps/HumanExtendedInfoStep.js +263 -0
  204. package/lib/module/steps/HumanExtendedInfoStep.js.map +1 -0
  205. package/lib/module/steps/LegalBasicInfoStep.js +183 -0
  206. package/lib/module/steps/LegalBasicInfoStep.js.map +1 -0
  207. package/lib/module/steps/LegalExtendedInfoStep.js +161 -0
  208. package/lib/module/steps/LegalExtendedInfoStep.js.map +1 -0
  209. package/lib/module/steps/LivenessMatchStep.js +701 -0
  210. package/lib/module/steps/LivenessMatchStep.js.map +1 -0
  211. package/lib/module/steps/PhoneContactStep.js +141 -0
  212. package/lib/module/steps/PhoneContactStep.js.map +1 -0
  213. package/lib/module/steps/PhoneOtpStep.js +214 -0
  214. package/lib/module/steps/PhoneOtpStep.js.map +1 -0
  215. package/lib/module/steps/SwornDeclarationStep.js +191 -0
  216. package/lib/module/steps/SwornDeclarationStep.js.map +1 -0
  217. package/lib/module/steps/TaxInfoStep.js +239 -0
  218. package/lib/module/steps/TaxInfoStep.js.map +1 -0
  219. package/lib/module/steps/TermsAndConditionsStep.js +233 -0
  220. package/lib/module/steps/TermsAndConditionsStep.js.map +1 -0
  221. package/lib/module/steps/_shared.js +33 -0
  222. package/lib/module/steps/_shared.js.map +1 -0
  223. package/lib/module/steps/types.js +4 -0
  224. package/lib/module/steps/types.js.map +1 -0
  225. package/lib/module/transport/api.js +173 -0
  226. package/lib/module/transport/api.js.map +1 -0
  227. package/lib/module/transport/irisWebSocket.js +115 -0
  228. package/lib/module/transport/irisWebSocket.js.map +1 -0
  229. package/lib/module/transport/secureUrl.js +45 -0
  230. package/lib/module/transport/secureUrl.js.map +1 -0
  231. package/lib/module/transport/sse.js +242 -0
  232. package/lib/module/transport/sse.js.map +1 -0
  233. package/lib/module/types/index.js +457 -0
  234. package/lib/module/types/index.js.map +1 -0
  235. package/lib/module/ui/MapFallbackBoundary.js +37 -0
  236. package/lib/module/ui/MapFallbackBoundary.js.map +1 -0
  237. package/lib/module/ui/StepShell.js +114 -0
  238. package/lib/module/ui/StepShell.js.map +1 -0
  239. package/lib/module/ui/VelionOnboardingScreen.js +212 -0
  240. package/lib/module/ui/VelionOnboardingScreen.js.map +1 -0
  241. package/lib/module/ui/forms/index.js +5 -0
  242. package/lib/module/ui/forms/index.js.map +1 -0
  243. package/lib/module/ui/forms/useInlineValidation.js +84 -0
  244. package/lib/module/ui/forms/useInlineValidation.js.map +1 -0
  245. package/lib/module/ui/forms/validators.js +27 -0
  246. package/lib/module/ui/forms/validators.js.map +1 -0
  247. package/lib/module/ui/icons/HomeHeartIcon.js +33 -0
  248. package/lib/module/ui/icons/HomeHeartIcon.js.map +1 -0
  249. package/lib/module/ui/icons/StepIcon.js +55 -0
  250. package/lib/module/ui/icons/StepIcon.js.map +1 -0
  251. package/lib/module/ui/overlays/AnalyzingOverlay.js +279 -0
  252. package/lib/module/ui/overlays/AnalyzingOverlay.js.map +1 -0
  253. package/lib/module/ui/overlays/LoadingOverlay.js +104 -0
  254. package/lib/module/ui/overlays/LoadingOverlay.js.map +1 -0
  255. package/lib/module/ui/overlays/ProgressBar.js +90 -0
  256. package/lib/module/ui/overlays/ProgressBar.js.map +1 -0
  257. package/lib/module/ui/overlays/RetryDialog.js +121 -0
  258. package/lib/module/ui/overlays/RetryDialog.js.map +1 -0
  259. package/lib/module/ui/overlays/index.js +6 -0
  260. package/lib/module/ui/overlays/index.js.map +1 -0
  261. package/lib/module/ui/primitives/Banner.js +77 -0
  262. package/lib/module/ui/primitives/Banner.js.map +1 -0
  263. package/lib/module/ui/primitives/Button.js +138 -0
  264. package/lib/module/ui/primitives/Button.js.map +1 -0
  265. package/lib/module/ui/primitives/Card.js +46 -0
  266. package/lib/module/ui/primitives/Card.js.map +1 -0
  267. package/lib/module/ui/primitives/Checkbox.js +136 -0
  268. package/lib/module/ui/primitives/Checkbox.js.map +1 -0
  269. package/lib/module/ui/primitives/CountrySelect.js +284 -0
  270. package/lib/module/ui/primitives/CountrySelect.js.map +1 -0
  271. package/lib/module/ui/primitives/DatePicker.js +241 -0
  272. package/lib/module/ui/primitives/DatePicker.js.map +1 -0
  273. package/lib/module/ui/primitives/Input.js +97 -0
  274. package/lib/module/ui/primitives/Input.js.map +1 -0
  275. package/lib/module/ui/primitives/Select.js +205 -0
  276. package/lib/module/ui/primitives/Select.js.map +1 -0
  277. package/lib/module/ui/primitives/Spinner.js +21 -0
  278. package/lib/module/ui/primitives/Spinner.js.map +1 -0
  279. package/lib/module/ui/primitives/index.js +12 -0
  280. package/lib/module/ui/primitives/index.js.map +1 -0
  281. package/lib/module/ui/theme/ThemeProvider.js +67 -0
  282. package/lib/module/ui/theme/ThemeProvider.js.map +1 -0
  283. package/lib/module/ui/theme/index.js +5 -0
  284. package/lib/module/ui/theme/index.js.map +1 -0
  285. package/lib/module/ui/theme/tokens.js +145 -0
  286. package/lib/module/ui/theme/tokens.js.map +1 -0
  287. package/lib/module/utils/EventEmitter.js +139 -0
  288. package/lib/module/utils/EventEmitter.js.map +1 -0
  289. package/lib/module/utils/base64.js +47 -0
  290. package/lib/module/utils/base64.js.map +1 -0
  291. package/lib/module/utils/deviceFingerprint.js +129 -0
  292. package/lib/module/utils/deviceFingerprint.js.map +1 -0
  293. package/lib/module/utils/documentTypeOptions.js +31 -0
  294. package/lib/module/utils/documentTypeOptions.js.map +1 -0
  295. package/lib/module/utils/googleMapsPreflight.js +73 -0
  296. package/lib/module/utils/googleMapsPreflight.js.map +1 -0
  297. package/lib/module/utils/hmac.js +53 -0
  298. package/lib/module/utils/hmac.js.map +1 -0
  299. package/lib/module/utils/iso3166Countries.js +92 -0
  300. package/lib/module/utils/iso3166Countries.js.map +1 -0
  301. package/lib/module/utils/jpegFromUri.js +40 -0
  302. package/lib/module/utils/jpegFromUri.js.map +1 -0
  303. package/lib/module/utils/keepAwake.js +53 -0
  304. package/lib/module/utils/keepAwake.js.map +1 -0
  305. package/lib/module/utils/log.js +37 -0
  306. package/lib/module/utils/log.js.map +1 -0
  307. package/lib/module/utils/osGeocoder.js +65 -0
  308. package/lib/module/utils/osGeocoder.js.map +1 -0
  309. package/lib/module/utils/parseGoogleAddressComponents.js +69 -0
  310. package/lib/module/utils/parseGoogleAddressComponents.js.map +1 -0
  311. package/lib/module/utils/personNameNormalize.js +20 -0
  312. package/lib/module/utils/personNameNormalize.js.map +1 -0
  313. package/lib/module/utils/sdkError.js +29 -0
  314. package/lib/module/utils/sdkError.js.map +1 -0
  315. package/lib/module/utils/sdkVersion.js +9 -0
  316. package/lib/module/utils/sdkVersion.js.map +1 -0
  317. package/lib/module/utils/stepConfig.js +59 -0
  318. package/lib/module/utils/stepConfig.js.map +1 -0
  319. package/lib/module/utils/taxInfoConfig.js +15 -0
  320. package/lib/module/utils/taxInfoConfig.js.map +1 -0
  321. package/lib/typescript/camera/AddressSearchBar.d.ts +37 -0
  322. package/lib/typescript/camera/AddressSearchBar.d.ts.map +1 -0
  323. package/lib/typescript/camera/DocumentCapture.d.ts +34 -0
  324. package/lib/typescript/camera/DocumentCapture.d.ts.map +1 -0
  325. package/lib/typescript/camera/LivenessCamera.d.ts +50 -0
  326. package/lib/typescript/camera/LivenessCamera.d.ts.map +1 -0
  327. package/lib/typescript/camera/MapAddressPicker.d.ts +57 -0
  328. package/lib/typescript/camera/MapAddressPicker.d.ts.map +1 -0
  329. package/lib/typescript/core/VelionOnboarding.d.ts +115 -0
  330. package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -0
  331. package/lib/typescript/core/sessionDeclinedCopy.d.ts +16 -0
  332. package/lib/typescript/core/sessionDeclinedCopy.d.ts.map +1 -0
  333. package/lib/typescript/core/sessionStateMapper.d.ts +33 -0
  334. package/lib/typescript/core/sessionStateMapper.d.ts.map +1 -0
  335. package/lib/typescript/core/sseReasonMessages.d.ts +20 -0
  336. package/lib/typescript/core/sseReasonMessages.d.ts.map +1 -0
  337. package/lib/typescript/i18n/index.d.ts +13 -0
  338. package/lib/typescript/i18n/index.d.ts.map +1 -0
  339. package/lib/typescript/i18n/strings/en.d.ts +3 -0
  340. package/lib/typescript/i18n/strings/en.d.ts.map +1 -0
  341. package/lib/typescript/i18n/strings/es.d.ts +260 -0
  342. package/lib/typescript/i18n/strings/es.d.ts.map +1 -0
  343. package/lib/typescript/index.d.ts +26 -0
  344. package/lib/typescript/index.d.ts.map +1 -0
  345. package/lib/typescript/steps/AddressInfoStep.d.ts +26 -0
  346. package/lib/typescript/steps/AddressInfoStep.d.ts.map +1 -0
  347. package/lib/typescript/steps/DocumentsOcrStep.d.ts +26 -0
  348. package/lib/typescript/steps/DocumentsOcrStep.d.ts.map +1 -0
  349. package/lib/typescript/steps/EmailContactStep.d.ts +15 -0
  350. package/lib/typescript/steps/EmailContactStep.d.ts.map +1 -0
  351. package/lib/typescript/steps/EmailOtpStep.d.ts +21 -0
  352. package/lib/typescript/steps/EmailOtpStep.d.ts.map +1 -0
  353. package/lib/typescript/steps/FaceMatchStep.d.ts +27 -0
  354. package/lib/typescript/steps/FaceMatchStep.d.ts.map +1 -0
  355. package/lib/typescript/steps/FingerprintStep.d.ts +25 -0
  356. package/lib/typescript/steps/FingerprintStep.d.ts.map +1 -0
  357. package/lib/typescript/steps/HumanBasicInfoStep.d.ts +25 -0
  358. package/lib/typescript/steps/HumanBasicInfoStep.d.ts.map +1 -0
  359. package/lib/typescript/steps/HumanExtendedInfoStep.d.ts +23 -0
  360. package/lib/typescript/steps/HumanExtendedInfoStep.d.ts.map +1 -0
  361. package/lib/typescript/steps/LegalBasicInfoStep.d.ts +17 -0
  362. package/lib/typescript/steps/LegalBasicInfoStep.d.ts.map +1 -0
  363. package/lib/typescript/steps/LegalExtendedInfoStep.d.ts +17 -0
  364. package/lib/typescript/steps/LegalExtendedInfoStep.d.ts.map +1 -0
  365. package/lib/typescript/steps/LivenessMatchStep.d.ts +26 -0
  366. package/lib/typescript/steps/LivenessMatchStep.d.ts.map +1 -0
  367. package/lib/typescript/steps/PhoneContactStep.d.ts +15 -0
  368. package/lib/typescript/steps/PhoneContactStep.d.ts.map +1 -0
  369. package/lib/typescript/steps/PhoneOtpStep.d.ts +19 -0
  370. package/lib/typescript/steps/PhoneOtpStep.d.ts.map +1 -0
  371. package/lib/typescript/steps/SwornDeclarationStep.d.ts +20 -0
  372. package/lib/typescript/steps/SwornDeclarationStep.d.ts.map +1 -0
  373. package/lib/typescript/steps/TaxInfoStep.d.ts +19 -0
  374. package/lib/typescript/steps/TaxInfoStep.d.ts.map +1 -0
  375. package/lib/typescript/steps/TermsAndConditionsStep.d.ts +21 -0
  376. package/lib/typescript/steps/TermsAndConditionsStep.d.ts.map +1 -0
  377. package/lib/typescript/steps/_shared.d.ts +11 -0
  378. package/lib/typescript/steps/_shared.d.ts.map +1 -0
  379. package/lib/typescript/steps/types.d.ts +68 -0
  380. package/lib/typescript/steps/types.d.ts.map +1 -0
  381. package/lib/typescript/transport/api.d.ts +35 -0
  382. package/lib/typescript/transport/api.d.ts.map +1 -0
  383. package/lib/typescript/transport/irisWebSocket.d.ts +72 -0
  384. package/lib/typescript/transport/irisWebSocket.d.ts.map +1 -0
  385. package/lib/typescript/transport/secureUrl.d.ts +14 -0
  386. package/lib/typescript/transport/secureUrl.d.ts.map +1 -0
  387. package/lib/typescript/transport/sse.d.ts +54 -0
  388. package/lib/typescript/transport/sse.d.ts.map +1 -0
  389. package/lib/typescript/types/index.d.ts +1010 -0
  390. package/lib/typescript/types/index.d.ts.map +1 -0
  391. package/lib/typescript/ui/MapFallbackBoundary.d.ts +28 -0
  392. package/lib/typescript/ui/MapFallbackBoundary.d.ts.map +1 -0
  393. package/lib/typescript/ui/StepShell.d.ts +19 -0
  394. package/lib/typescript/ui/StepShell.d.ts.map +1 -0
  395. package/lib/typescript/ui/VelionOnboardingScreen.d.ts +19 -0
  396. package/lib/typescript/ui/VelionOnboardingScreen.d.ts.map +1 -0
  397. package/lib/typescript/ui/forms/index.d.ts +3 -0
  398. package/lib/typescript/ui/forms/index.d.ts.map +1 -0
  399. package/lib/typescript/ui/forms/useInlineValidation.d.ts +30 -0
  400. package/lib/typescript/ui/forms/useInlineValidation.d.ts.map +1 -0
  401. package/lib/typescript/ui/forms/validators.d.ts +11 -0
  402. package/lib/typescript/ui/forms/validators.d.ts.map +1 -0
  403. package/lib/typescript/ui/icons/HomeHeartIcon.d.ts +14 -0
  404. package/lib/typescript/ui/icons/HomeHeartIcon.d.ts.map +1 -0
  405. package/lib/typescript/ui/icons/StepIcon.d.ts +26 -0
  406. package/lib/typescript/ui/icons/StepIcon.d.ts.map +1 -0
  407. package/lib/typescript/ui/overlays/AnalyzingOverlay.d.ts +24 -0
  408. package/lib/typescript/ui/overlays/AnalyzingOverlay.d.ts.map +1 -0
  409. package/lib/typescript/ui/overlays/LoadingOverlay.d.ts +19 -0
  410. package/lib/typescript/ui/overlays/LoadingOverlay.d.ts.map +1 -0
  411. package/lib/typescript/ui/overlays/ProgressBar.d.ts +26 -0
  412. package/lib/typescript/ui/overlays/ProgressBar.d.ts.map +1 -0
  413. package/lib/typescript/ui/overlays/RetryDialog.d.ts +17 -0
  414. package/lib/typescript/ui/overlays/RetryDialog.d.ts.map +1 -0
  415. package/lib/typescript/ui/overlays/index.d.ts +4 -0
  416. package/lib/typescript/ui/overlays/index.d.ts.map +1 -0
  417. package/lib/typescript/ui/primitives/Banner.d.ts +11 -0
  418. package/lib/typescript/ui/primitives/Banner.d.ts.map +1 -0
  419. package/lib/typescript/ui/primitives/Button.d.ts +27 -0
  420. package/lib/typescript/ui/primitives/Button.d.ts.map +1 -0
  421. package/lib/typescript/ui/primitives/Card.d.ts +10 -0
  422. package/lib/typescript/ui/primitives/Card.d.ts.map +1 -0
  423. package/lib/typescript/ui/primitives/Checkbox.d.ts +25 -0
  424. package/lib/typescript/ui/primitives/Checkbox.d.ts.map +1 -0
  425. package/lib/typescript/ui/primitives/CountrySelect.d.ts +31 -0
  426. package/lib/typescript/ui/primitives/CountrySelect.d.ts.map +1 -0
  427. package/lib/typescript/ui/primitives/DatePicker.d.ts +42 -0
  428. package/lib/typescript/ui/primitives/DatePicker.d.ts.map +1 -0
  429. package/lib/typescript/ui/primitives/Input.d.ts +17 -0
  430. package/lib/typescript/ui/primitives/Input.d.ts.map +1 -0
  431. package/lib/typescript/ui/primitives/Select.d.ts +26 -0
  432. package/lib/typescript/ui/primitives/Select.d.ts.map +1 -0
  433. package/lib/typescript/ui/primitives/Spinner.d.ts +10 -0
  434. package/lib/typescript/ui/primitives/Spinner.d.ts.map +1 -0
  435. package/lib/typescript/ui/primitives/index.d.ts +10 -0
  436. package/lib/typescript/ui/primitives/index.d.ts.map +1 -0
  437. package/lib/typescript/ui/theme/ThemeProvider.d.ts +23 -0
  438. package/lib/typescript/ui/theme/ThemeProvider.d.ts.map +1 -0
  439. package/lib/typescript/ui/theme/index.d.ts +3 -0
  440. package/lib/typescript/ui/theme/index.d.ts.map +1 -0
  441. package/lib/typescript/ui/theme/tokens.d.ts +42 -0
  442. package/lib/typescript/ui/theme/tokens.d.ts.map +1 -0
  443. package/lib/typescript/utils/EventEmitter.d.ts +98 -0
  444. package/lib/typescript/utils/EventEmitter.d.ts.map +1 -0
  445. package/lib/typescript/utils/base64.d.ts +19 -0
  446. package/lib/typescript/utils/base64.d.ts.map +1 -0
  447. package/lib/typescript/utils/deviceFingerprint.d.ts +42 -0
  448. package/lib/typescript/utils/deviceFingerprint.d.ts.map +1 -0
  449. package/lib/typescript/utils/documentTypeOptions.d.ts +13 -0
  450. package/lib/typescript/utils/documentTypeOptions.d.ts.map +1 -0
  451. package/lib/typescript/utils/googleMapsPreflight.d.ts +44 -0
  452. package/lib/typescript/utils/googleMapsPreflight.d.ts.map +1 -0
  453. package/lib/typescript/utils/hmac.d.ts +39 -0
  454. package/lib/typescript/utils/hmac.d.ts.map +1 -0
  455. package/lib/typescript/utils/iso3166Countries.d.ts +27 -0
  456. package/lib/typescript/utils/iso3166Countries.d.ts.map +1 -0
  457. package/lib/typescript/utils/jpegFromUri.d.ts +29 -0
  458. package/lib/typescript/utils/jpegFromUri.d.ts.map +1 -0
  459. package/lib/typescript/utils/keepAwake.d.ts +16 -0
  460. package/lib/typescript/utils/keepAwake.d.ts.map +1 -0
  461. package/lib/typescript/utils/log.d.ts +18 -0
  462. package/lib/typescript/utils/log.d.ts.map +1 -0
  463. package/lib/typescript/utils/osGeocoder.d.ts +38 -0
  464. package/lib/typescript/utils/osGeocoder.d.ts.map +1 -0
  465. package/lib/typescript/utils/parseGoogleAddressComponents.d.ts +43 -0
  466. package/lib/typescript/utils/parseGoogleAddressComponents.d.ts.map +1 -0
  467. package/lib/typescript/utils/personNameNormalize.d.ts +10 -0
  468. package/lib/typescript/utils/personNameNormalize.d.ts.map +1 -0
  469. package/lib/typescript/utils/sdkError.d.ts +14 -0
  470. package/lib/typescript/utils/sdkError.d.ts.map +1 -0
  471. package/lib/typescript/utils/sdkVersion.d.ts +7 -0
  472. package/lib/typescript/utils/sdkVersion.d.ts.map +1 -0
  473. package/lib/typescript/utils/stepConfig.d.ts +8 -0
  474. package/lib/typescript/utils/stepConfig.d.ts.map +1 -0
  475. package/lib/typescript/utils/taxInfoConfig.d.ts +7 -0
  476. package/lib/typescript/utils/taxInfoConfig.d.ts.map +1 -0
  477. package/package.json +99 -0
  478. package/src/camera/AddressSearchBar.tsx +363 -0
  479. package/src/camera/DocumentCapture.tsx +505 -0
  480. package/src/camera/LivenessCamera.tsx +602 -0
  481. package/src/camera/MapAddressPicker.tsx +397 -0
  482. package/src/core/VelionOnboarding.ts +974 -0
  483. package/src/core/sessionDeclinedCopy.ts +76 -0
  484. package/src/core/sessionStateMapper.ts +167 -0
  485. package/src/core/sseReasonMessages.ts +531 -0
  486. package/src/data/iso3166Alpha2Codes.json +1 -0
  487. package/src/data/iso3166CountryNames.json +251 -0
  488. package/src/i18n/index.ts +26 -0
  489. package/src/i18n/strings/en.ts +289 -0
  490. package/src/i18n/strings/es.ts +291 -0
  491. package/src/index.ts +137 -0
  492. package/src/steps/AddressInfoStep.tsx +726 -0
  493. package/src/steps/DocumentsOcrStep.tsx +472 -0
  494. package/src/steps/EmailContactStep.tsx +159 -0
  495. package/src/steps/EmailOtpStep.tsx +250 -0
  496. package/src/steps/FaceMatchStep.tsx +177 -0
  497. package/src/steps/FingerprintStep.tsx +99 -0
  498. package/src/steps/HumanBasicInfoStep.tsx +274 -0
  499. package/src/steps/HumanExtendedInfoStep.tsx +353 -0
  500. package/src/steps/LegalBasicInfoStep.tsx +205 -0
  501. package/src/steps/LegalExtendedInfoStep.tsx +171 -0
  502. package/src/steps/LivenessMatchStep.tsx +846 -0
  503. package/src/steps/PhoneContactStep.tsx +160 -0
  504. package/src/steps/PhoneOtpStep.tsx +249 -0
  505. package/src/steps/SwornDeclarationStep.tsx +220 -0
  506. package/src/steps/TaxInfoStep.tsx +277 -0
  507. package/src/steps/TermsAndConditionsStep.tsx +261 -0
  508. package/src/steps/_shared.ts +44 -0
  509. package/src/steps/types.ts +72 -0
  510. package/src/transport/api.ts +257 -0
  511. package/src/transport/irisWebSocket.ts +186 -0
  512. package/src/transport/secureUrl.ts +47 -0
  513. package/src/transport/sse.ts +310 -0
  514. package/src/types/index.ts +1198 -0
  515. package/src/ui/MapFallbackBoundary.tsx +46 -0
  516. package/src/ui/StepShell.tsx +137 -0
  517. package/src/ui/VelionOnboardingScreen.tsx +223 -0
  518. package/src/ui/forms/index.ts +12 -0
  519. package/src/ui/forms/useInlineValidation.ts +115 -0
  520. package/src/ui/forms/validators.ts +29 -0
  521. package/src/ui/icons/HomeHeartIcon.tsx +34 -0
  522. package/src/ui/icons/StepIcon.tsx +77 -0
  523. package/src/ui/overlays/AnalyzingOverlay.tsx +323 -0
  524. package/src/ui/overlays/LoadingOverlay.tsx +115 -0
  525. package/src/ui/overlays/ProgressBar.tsx +99 -0
  526. package/src/ui/overlays/RetryDialog.tsx +128 -0
  527. package/src/ui/overlays/index.ts +3 -0
  528. package/src/ui/primitives/Banner.tsx +81 -0
  529. package/src/ui/primitives/Button.tsx +164 -0
  530. package/src/ui/primitives/Card.tsx +55 -0
  531. package/src/ui/primitives/Checkbox.tsx +153 -0
  532. package/src/ui/primitives/CountrySelect.tsx +356 -0
  533. package/src/ui/primitives/DatePicker.tsx +266 -0
  534. package/src/ui/primitives/Input.tsx +110 -0
  535. package/src/ui/primitives/Select.tsx +259 -0
  536. package/src/ui/primitives/Spinner.tsx +17 -0
  537. package/src/ui/primitives/index.ts +9 -0
  538. package/src/ui/theme/ThemeProvider.tsx +102 -0
  539. package/src/ui/theme/index.ts +17 -0
  540. package/src/ui/theme/tokens.ts +159 -0
  541. package/src/utils/EventEmitter.ts +155 -0
  542. package/src/utils/base64.ts +44 -0
  543. package/src/utils/deviceFingerprint.ts +184 -0
  544. package/src/utils/documentTypeOptions.ts +31 -0
  545. package/src/utils/googleMapsPreflight.ts +72 -0
  546. package/src/utils/hmac.ts +61 -0
  547. package/src/utils/iso3166Countries.ts +111 -0
  548. package/src/utils/jpegFromUri.ts +42 -0
  549. package/src/utils/keepAwake.ts +62 -0
  550. package/src/utils/log.ts +37 -0
  551. package/src/utils/osGeocoder.ts +75 -0
  552. package/src/utils/parseGoogleAddressComponents.ts +123 -0
  553. package/src/utils/personNameNormalize.ts +17 -0
  554. package/src/utils/sdkError.ts +40 -0
  555. package/src/utils/sdkVersion.ts +6 -0
  556. package/src/utils/stepConfig.ts +75 -0
  557. package/src/utils/taxInfoConfig.ts +14 -0
@@ -0,0 +1,701 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * LIVENESS_MATCH — Iris-driven active liveness over WebSocket.
5
+ *
6
+ * Flow:
7
+ * 1. POST /liveness-init → { liveness_session_id, websocket_url, expires_at,
8
+ * challenges, connection_token, frame_integrity_key_base64 }.
9
+ * 2. Optionally import the HMAC key for frame integrity.
10
+ * 3. Open vision-camera (front), connect WS with ?token & ?lang.
11
+ * 4. SESSION_READY → start frame capture loop (interval-driven), watchdog 25s.
12
+ * 5. Process CHALLENGE / CHALLENGE_PROGRESS / CHALLENGE_COMPLETE / WARNING /
13
+ * ERROR / SESSION_COMPLETE.
14
+ * 6. Terminal WARNING (SPOOF_RISK_HIGH, …) → in-flow retry dialog (re-init
15
+ * + fresh WS) without bailing the whole flow.
16
+ * 7. SESSION_COMPLETE → POST /liveness-verify → resolve the step.
17
+ */
18
+
19
+ import { useCallback, useEffect, useRef, useState } from 'react';
20
+ import { ScrollView, StyleSheet, Text, View } from 'react-native';
21
+ import * as ImageManipulator from 'expo-image-manipulator';
22
+ import { SdkErrorCode } from '../types';
23
+ import { Banner } from '../ui/primitives/Banner';
24
+ import { Button } from '../ui/primitives/Button';
25
+ import { AnalyzingOverlay } from '../ui/overlays/AnalyzingOverlay';
26
+ import { RetryDialog } from '../ui/overlays/RetryDialog';
27
+ import { StepShell } from '../ui/StepShell';
28
+ import { StepIcon } from '../ui/icons/StepIcon';
29
+ import { mixHex, useTheme } from '../ui/theme';
30
+ import { getStrings } from '../i18n';
31
+ import { log } from '../utils/log';
32
+ import { readJpegFromUri } from '../utils/jpegFromUri';
33
+ import { buildSignedFrameEnvelope, importHmacKey } from '../utils/hmac';
34
+ import { TERMINAL_WARNING_CODES, openIrisWebSocket } from '../transport/irisWebSocket';
35
+ import { LivenessCamera } from '../camera/LivenessCamera';
36
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
37
+ // Capture loop defaults tuned for the Iris orchestrator's frame cadence.
38
+ const FRAME_MS_DEFAULT = 350;
39
+ const FRAME_MS_TURN = 220;
40
+ const PROGRESS_WATCHDOG_MS = 25_000;
41
+ const FRAME_MAX_LONG_EDGE = 720;
42
+ const FRAME_QUALITY = 0.55;
43
+ export class LivenessMatchStep {
44
+ destroyed = false;
45
+ constructor(deps) {
46
+ this.deps = deps;
47
+ }
48
+ run() {
49
+ return new Promise((resolve, reject) => {
50
+ this.resolveStep = resolve;
51
+ this.rejectStep = reject;
52
+ this.deps.ui.setNode(/*#__PURE__*/_jsx(LivenessMatchView, {
53
+ api: this.deps.api,
54
+ sessionId: this.deps.sessionId,
55
+ locale: this.deps.locale,
56
+ calibrationLabel: this.deps.livenessCalibrationLabel,
57
+ showIntro: true,
58
+ showBackButton: true,
59
+ onComplete: () => {
60
+ if (this.destroyed) return;
61
+ this.deps.ui.setNode(null);
62
+ this.resolveStep();
63
+ },
64
+ onCancel: err => {
65
+ if (this.destroyed) return;
66
+ this.deps.ui.setNode(null);
67
+ this.rejectStep(err);
68
+ }
69
+ }));
70
+ });
71
+ }
72
+ destroy() {
73
+ this.destroyed = true;
74
+ this.deps.ui.setNode(null);
75
+ }
76
+ }
77
+ function LivenessMatchView({
78
+ api,
79
+ sessionId,
80
+ locale,
81
+ calibrationLabel,
82
+ showIntro,
83
+ showBackButton,
84
+ onComplete,
85
+ onCancel
86
+ }) {
87
+ const t = getStrings(locale);
88
+ const theme = useTheme();
89
+ const cameraRef = useRef(null);
90
+ const [phase, setPhase] = useState(showIntro ? 'intro' : 'capturing');
91
+ const [statusText, setStatusText] = useState(null);
92
+ const [challengeText, setChallengeText] = useState(null);
93
+ const [ovalCue, setOvalCue] = useState('NEUTRAL');
94
+ const [toast, setToast] = useState(null);
95
+ const [progress, setProgress] = useState(null);
96
+ const [retry, setRetry] = useState(null);
97
+ const [bannerError, setBannerError] = useState(null);
98
+
99
+ // Long-lived state that the capture loop / WS handlers need without
100
+ // triggering re-renders: kept in refs.
101
+ const wsRef = useRef(null);
102
+ const hmacRef = useRef(null);
103
+ const livenessSessionIdRef = useRef(null);
104
+ const currentChallengeRef = useRef(null);
105
+ // Tracks the position of the active challenge inside the session sequence
106
+ // so we can recognise the LAST challenge completing and switch to the
107
+ // "Analyzing" overlay immediately, instead of letting the user stare at
108
+ // the camera with the last instruction frozen on screen for the seconds
109
+ // it takes the worker to drain its queue and the orchestrator to emit
110
+ // SESSION_COMPLETE.
111
+ const lastChallengeMetaRef = useRef(null);
112
+ const frameMsRef = useRef(FRAME_MS_DEFAULT);
113
+ const captureTimerRef = useRef(null);
114
+ const inFlightRef = useRef(false);
115
+ const framesSentRef = useRef(0);
116
+ const watchdogRef = useRef(null);
117
+ const finalizingRef = useRef(false);
118
+ const toastTimerRef = useRef(null);
119
+ // Tracks the toast currently on screen so we can extend its visibility when
120
+ // the same message arrives again (instead of dismount/remount, which made
121
+ // warnings flash in <2s and the user couldn't read them).
122
+ const activeToastRef = useRef(null);
123
+
124
+ // Each toast stays on screen at least this long. The orchestrator can spam
125
+ // WARNINGs (POSITIONING_REQUIRED, SPOOF_RISK_HIGH, …) several times per
126
+ // second; without a floor the user literally cannot read them.
127
+ const TOAST_MIN_DURATION_MS = 3200;
128
+ const showToast = useCallback((kind, message) => {
129
+ const active = activeToastRef.current;
130
+ if (active && active.kind === kind && active.message === message) {
131
+ // Identical toast already visible — just refresh the timer so it
132
+ // stays up while warnings keep arriving. Do NOT touch `setToast`:
133
+ // a new object would re-trigger the entry animation and flicker.
134
+ if (toastTimerRef.current) clearTimeout(toastTimerRef.current);
135
+ toastTimerRef.current = setTimeout(() => {
136
+ setToast(null);
137
+ activeToastRef.current = null;
138
+ }, TOAST_MIN_DURATION_MS);
139
+ return;
140
+ }
141
+ // Different content: replace and guarantee the new toast its own
142
+ // minimum window.
143
+ activeToastRef.current = {
144
+ kind,
145
+ message
146
+ };
147
+ setToast({
148
+ kind,
149
+ message
150
+ });
151
+ if (toastTimerRef.current) clearTimeout(toastTimerRef.current);
152
+ toastTimerRef.current = setTimeout(() => {
153
+ setToast(null);
154
+ activeToastRef.current = null;
155
+ }, TOAST_MIN_DURATION_MS);
156
+ }, []);
157
+ const stopWatchdog = useCallback(() => {
158
+ if (watchdogRef.current) {
159
+ clearTimeout(watchdogRef.current);
160
+ watchdogRef.current = null;
161
+ }
162
+ }, []);
163
+ const stopCapture = useCallback(() => {
164
+ if (captureTimerRef.current) {
165
+ clearInterval(captureTimerRef.current);
166
+ captureTimerRef.current = null;
167
+ }
168
+ inFlightRef.current = false;
169
+ }, []);
170
+ const failWith = useCallback(err => {
171
+ stopWatchdog();
172
+ stopCapture();
173
+ try {
174
+ wsRef.current?.close(1000, 'fail');
175
+ } catch {
176
+ /* ignore */
177
+ }
178
+ wsRef.current = null;
179
+ onCancel(err);
180
+ }, [onCancel, stopCapture, stopWatchdog]);
181
+ const captureAndSend = useCallback(async () => {
182
+ if (inFlightRef.current) return;
183
+ const ws = wsRef.current;
184
+ if (!ws || !ws.isOpen()) return;
185
+ inFlightRef.current = true;
186
+ try {
187
+ const photo = await cameraRef.current?.takeFrame();
188
+ if (!photo || !ws.isOpen()) return;
189
+ const compressed = await ImageManipulator.manipulateAsync(photo.path.startsWith('file://') ? photo.path : `file://${photo.path}`, [{
190
+ resize: {
191
+ width: FRAME_MAX_LONG_EDGE
192
+ }
193
+ }], {
194
+ compress: FRAME_QUALITY,
195
+ format: ImageManipulator.SaveFormat.JPEG
196
+ });
197
+ if (!ws.isOpen()) return;
198
+ const jpeg = await readJpegFromUri(compressed.uri);
199
+ const key = hmacRef.current;
200
+ if (key) {
201
+ const envelope = buildSignedFrameEnvelope({
202
+ key,
203
+ sessionId: livenessSessionIdRef.current ?? sessionId,
204
+ frameId: framesSentRef.current,
205
+ jpegBytes: jpeg.bytes,
206
+ jpegBase64: jpeg.base64
207
+ });
208
+ ws.sendJson(envelope.json);
209
+ } else {
210
+ // Vision-camera + RN's WebSocket need an ArrayBuffer for binary frames.
211
+ // `Uint8Array.buffer` is a `SharedArrayBuffer` on some Hermes versions
212
+ // — slice into a fresh ArrayBuffer to be safe.
213
+ const ab = jpeg.bytes.buffer.slice(jpeg.bytes.byteOffset, jpeg.bytes.byteOffset + jpeg.bytes.byteLength);
214
+ ws.sendBinary(ab);
215
+ }
216
+ framesSentRef.current += 1;
217
+ } catch (err) {
218
+ log.warn('[Liveness] frame send failed', err);
219
+ } finally {
220
+ inFlightRef.current = false;
221
+ }
222
+ }, [sessionId]);
223
+ const startCaptureLoop = useCallback(ms => {
224
+ stopCapture();
225
+ frameMsRef.current = ms;
226
+ captureTimerRef.current = setInterval(() => {
227
+ void captureAndSend();
228
+ }, ms);
229
+ }, [captureAndSend, stopCapture]);
230
+ const adjustFps = useCallback(ms => {
231
+ if (frameMsRef.current === ms) return;
232
+ if (captureTimerRef.current) {
233
+ startCaptureLoop(ms);
234
+ } else {
235
+ frameMsRef.current = ms;
236
+ }
237
+ }, [startCaptureLoop]);
238
+ const challengeLabel = useCallback(id => {
239
+ if (!id) return '';
240
+ return t.liveness.challenge[id] ?? '';
241
+ }, [t.liveness.challenge]);
242
+ const presentTerminalRetry = useCallback((code, message) => {
243
+ stopCapture();
244
+ stopWatchdog();
245
+ try {
246
+ wsRef.current?.close(4001, 'terminal_warning_retry_pending');
247
+ } catch {
248
+ /* ignore */
249
+ }
250
+ wsRef.current = null;
251
+ setRetry({
252
+ code,
253
+ message: message?.trim() || t.liveness.terminalRetryFallback
254
+ });
255
+ }, [stopCapture, stopWatchdog, t.liveness.terminalRetryFallback]);
256
+ const resetWatchdog = useCallback(() => {
257
+ stopWatchdog();
258
+ watchdogRef.current = setTimeout(() => {
259
+ log.warn('[Liveness] progress watchdog fired');
260
+ // The watchdog used to be a hard fail — onCancel → step rejects →
261
+ // orchestrator surfaces the error and exits the whole liveness step.
262
+ // That left the user with no in-flow recovery: they had to restart
263
+ // the entire onboarding. The Iris-side "no progress in N seconds" is
264
+ // usually a recoverable user-side issue (lighting, framing, not
265
+ // looking at the camera), so we treat it the same way as a terminal
266
+ // WARNING: tear down the WS, show the retry dialog, and let the user
267
+ // restart the verification without leaving the step.
268
+ presentTerminalRetry('NO_PROGRESS', t.liveness.noProgressMessage);
269
+ }, PROGRESS_WATCHDOG_MS);
270
+ }, [presentTerminalRetry, stopWatchdog, t.liveness.noProgressMessage]);
271
+ const handleWsMessage = useCallback(msg => {
272
+ switch (msg.type) {
273
+ case 'SESSION_READY':
274
+ {
275
+ setStatusText(null);
276
+ // The ~1-2 s gap between SESSION_READY and the first CHALLENGE is
277
+ // where users decide their posture for the whole session. We use
278
+ // it for two pieces of guidance, layered:
279
+ // - A short "Heads up — starting now" toast above the oval so
280
+ // they're not caught looking away when (e.g.) the BLINK window
281
+ // opens.
282
+ // - A persistent `challengeText` ("Center your face in the oval")
283
+ // anchored above the oval so they keep adjusting until the
284
+ // first real challenge arrives and overwrites it. Without
285
+ // this, every Android calibration session started with the
286
+ // face at ~25 % of the frame width and SMILE / MOVE_FARTHER
287
+ // failed before the user understood what was being asked.
288
+ setChallengeText(t.liveness.centerFace);
289
+ showToast('success', t.liveness.getReady);
290
+ startCaptureLoop(FRAME_MS_DEFAULT);
291
+ resetWatchdog();
292
+ return;
293
+ }
294
+ case 'CHALLENGE':
295
+ {
296
+ const ch = msg.challenge ?? null;
297
+ currentChallengeRef.current = ch;
298
+ // Stash the sequence position so CHALLENGE_COMPLETE can tell
299
+ // whether this was the LAST challenge and switch to the analyzing
300
+ // overlay immediately instead of waiting for SESSION_COMPLETE.
301
+ if (typeof msg.sequenceIndex === 'number' && typeof msg.totalChallenges === 'number') {
302
+ lastChallengeMetaRef.current = {
303
+ index: msg.sequenceIndex,
304
+ total: msg.totalChallenges
305
+ };
306
+ }
307
+ adjustFps(ch === 'TURN_LEFT' || ch === 'TURN_RIGHT' ? FRAME_MS_TURN : FRAME_MS_DEFAULT);
308
+ setChallengeText(challengeLabel(ch));
309
+ // Map distance challenges to an oval-size cue so the viewfinder
310
+ // shape reinforces the instruction (grows for closer, returns to
311
+ // neutral for farther). All other challenges keep the neutral
312
+ // oval — the dim mask shouldn't move under a turn / smile / blink.
313
+ setOvalCue(ch === 'MOVE_CLOSER' ? 'MOVE_CLOSER' : ch === 'MOVE_FARTHER' ? 'MOVE_FARTHER' : 'NEUTRAL');
314
+ setProgress(0);
315
+ resetWatchdog();
316
+ return;
317
+ }
318
+ case 'CHALLENGE_PROGRESS':
319
+ {
320
+ if (typeof msg.confidence === 'number') {
321
+ setProgress(msg.confidence);
322
+ }
323
+ resetWatchdog();
324
+ return;
325
+ }
326
+ case 'CHALLENGE_COMPLETE':
327
+ {
328
+ setProgress(1);
329
+ currentChallengeRef.current = null;
330
+ adjustFps(FRAME_MS_DEFAULT);
331
+ // Reset the oval back to neutral after each challenge so the
332
+ // next CHALLENGE (or finalize) doesn't inherit a "zoomed" oval.
333
+ setOvalCue('NEUTRAL');
334
+ // Last challenge of the sequence completed → switch to the
335
+ // "Analyzing your video" overlay right away. SESSION_COMPLETE
336
+ // can take several seconds to land while the worker drains
337
+ // its queue; without this the user would stare at the camera
338
+ // and the stale instruction the whole time.
339
+ const meta = lastChallengeMetaRef.current;
340
+ if (meta && meta.index >= meta.total - 1) {
341
+ stopCapture();
342
+ setPhase('finalizing');
343
+ }
344
+ resetWatchdog();
345
+ return;
346
+ }
347
+ case 'WARNING':
348
+ {
349
+ if (msg.code && TERMINAL_WARNING_CODES.has(msg.code)) {
350
+ presentTerminalRetry(msg.code, msg.message);
351
+ return;
352
+ }
353
+ const isPositioningReady = msg.code === 'POSITIONING_READY';
354
+ // Per-code SDK-side fallback used when the orchestrator forwarded a
355
+ // code but no localised text (e.g. older orchestrator versions, or
356
+ // the rare WS message that drops the body). The orchestrator's own
357
+ // text is preferred — it always wins when present — so the user sees
358
+ // the server's exact wording in the session's locale.
359
+ const FALLBACK_BY_CODE = {
360
+ TOO_FAR: t.liveness.warningTooFar,
361
+ TOO_CLOSE: t.liveness.warningTooClose,
362
+ MOVE_CLOSER_HINT: t.liveness.warningMoveCloserHint,
363
+ MOVE_FARTHER_HINT: t.liveness.warningMoveFartherHint
364
+ };
365
+ // Timeout fallback is dynamic: the orchestrator now sends a
366
+ // challenge-specific message ("No pudimos reconocer el giro hacia
367
+ // la izquierda"), but if it ever drops it the SDK rebuilds the
368
+ // same text from the locally tracked active challenge.
369
+ let timeoutFallback;
370
+ if (msg.code === 'CHALLENGE_TIMEOUT') {
371
+ const ch = currentChallengeRef.current;
372
+ switch (ch) {
373
+ case 'TURN_LEFT':
374
+ timeoutFallback = t.liveness.timeoutTurnLeft;
375
+ break;
376
+ case 'TURN_RIGHT':
377
+ timeoutFallback = t.liveness.timeoutTurnRight;
378
+ break;
379
+ case 'BLINK':
380
+ timeoutFallback = t.liveness.timeoutBlink;
381
+ break;
382
+ case 'SMILE':
383
+ timeoutFallback = t.liveness.timeoutSmile;
384
+ break;
385
+ case 'MOVE_CLOSER':
386
+ timeoutFallback = t.liveness.timeoutMoveCloser;
387
+ break;
388
+ case 'MOVE_FARTHER':
389
+ timeoutFallback = t.liveness.timeoutMoveFarther;
390
+ break;
391
+ default:
392
+ timeoutFallback = t.liveness.timeoutGeneric;
393
+ }
394
+ }
395
+ const codedFallback = timeoutFallback ?? (msg.code ? FALLBACK_BY_CODE[msg.code] : undefined) ?? t.liveness.warningGeneric;
396
+ // Prefer the server-localised message — it's situationally
397
+ // accurate ("El fondo tiene mucho movimiento o reflejos. Pasá a
398
+ // un fondo neutro y plano"). Drop to the SDK fallback only when
399
+ // the orchestrator did not provide one.
400
+ const baseText = msg.message ?? codedFallback;
401
+ const text = isPositioningReady ? t.liveness.positioningReady : typeof msg.consecutiveMisses === 'number' && msg.consecutiveMisses >= 3 ? t.liveness.warningConsecutiveMisses.replace('{n}', String(msg.consecutiveMisses)).concat(' — ', baseText) : baseText;
402
+ showToast(isPositioningReady ? 'success' : 'warning', text);
403
+ resetWatchdog();
404
+ return;
405
+ }
406
+ case 'ERROR':
407
+ {
408
+ failWith({
409
+ code: SdkErrorCode.LIVENESS_FAILED,
410
+ message: msg.message ?? msg.code ?? 'Iris reported an error during liveness.'
411
+ });
412
+ return;
413
+ }
414
+ case 'SESSION_COMPLETE':
415
+ {
416
+ stopWatchdog();
417
+ if (finalizingRef.current) return;
418
+ finalizingRef.current = true;
419
+ stopCapture();
420
+ try {
421
+ wsRef.current?.close(1000, 'session_complete');
422
+ } catch {
423
+ /* ignore */
424
+ }
425
+ wsRef.current = null;
426
+ setPhase('finalizing');
427
+ (async () => {
428
+ try {
429
+ await api.post(`/sessions/${sessionId}/liveness-verify`, {});
430
+ onComplete();
431
+ } catch (err) {
432
+ const message = err && typeof err === 'object' && 'message' in err ? String(err.message) : 'Failed to notify the backend that liveness completed.';
433
+ failWith({
434
+ code: SdkErrorCode.LIVENESS_FAILED,
435
+ message,
436
+ cause: err
437
+ });
438
+ }
439
+ })();
440
+ return;
441
+ }
442
+ default:
443
+ return;
444
+ }
445
+ }, [adjustFps, api, challengeLabel, failWith, onComplete, presentTerminalRetry, resetWatchdog, sessionId, showToast, startCaptureLoop, stopCapture, stopWatchdog, t.liveness.getReady, t.liveness.positioningReady, t.liveness.warningConsecutiveMisses, t.liveness.warningGeneric]);
446
+ const startVerification = useCallback(async () => {
447
+ setBannerError(null);
448
+ setRetry(null);
449
+ setStatusText(t.liveness.connecting);
450
+ finalizingRef.current = false;
451
+ framesSentRef.current = 0;
452
+ currentChallengeRef.current = null;
453
+ lastChallengeMetaRef.current = null;
454
+ frameMsRef.current = FRAME_MS_DEFAULT;
455
+ hmacRef.current = null;
456
+ let init;
457
+ try {
458
+ // `calibration_label` is the wire name expected by the backend
459
+ // (snake_case mirroring iris-test's `/sessions` POST). Only sent when
460
+ // the host explicitly enables calibration via VelionConfig.
461
+ const body = {};
462
+ if (calibrationLabel && calibrationLabel.length > 0) {
463
+ body.calibration_label = calibrationLabel;
464
+ }
465
+ init = await api.post(`/sessions/${sessionId}/liveness-init`, body);
466
+ } catch (err) {
467
+ failWith({
468
+ code: SdkErrorCode.LIVENESS_INIT_FAILED,
469
+ message: (err && typeof err === 'object' && 'message' in err ? String(err.message) : '') || 'Failed to create the Iris liveness session.',
470
+ cause: err
471
+ });
472
+ return;
473
+ }
474
+ if (!init.liveness_session_id || !init.websocket_url) {
475
+ failWith({
476
+ code: SdkErrorCode.LIVENESS_INIT_FAILED,
477
+ message: 'liveness-init response missing required fields.'
478
+ });
479
+ return;
480
+ }
481
+ livenessSessionIdRef.current = init.liveness_session_id;
482
+ if (init.frame_integrity_key_base64) {
483
+ try {
484
+ hmacRef.current = importHmacKey(init.frame_integrity_key_base64);
485
+ } catch (err) {
486
+ log.warn('[Liveness] failed to import HMAC key', err);
487
+ hmacRef.current = null;
488
+ }
489
+ }
490
+ setStatusText(t.liveness.preparingCamera);
491
+ let connection;
492
+ try {
493
+ connection = openIrisWebSocket({
494
+ websocketUrl: init.websocket_url,
495
+ connectionToken: init.connection_token,
496
+ locale,
497
+ onOpen: () => setStatusText(t.liveness.connecting),
498
+ onMessage: handleWsMessage,
499
+ onClose: (code, reason) => {
500
+ if (finalizingRef.current) return;
501
+ // Code 4001 is the close we send ourselves from
502
+ // `presentTerminalRetry` to tear down the WS before showing the
503
+ // retry dialog. Checking the React state `retry` here is unsafe
504
+ // — this handler is registered via closure on a stale render,
505
+ // so `retry` reads `null` even when we just called `setRetry`.
506
+ // The close code is reliable: we always pair 4001 with the
507
+ // retry-dialog mount.
508
+ if (code === 4001) return;
509
+ stopCapture();
510
+ stopWatchdog();
511
+ if (code === 1000) return;
512
+ failWith({
513
+ code: SdkErrorCode.LIVENESS_FAILED,
514
+ message: `Iris WebSocket closed before completion (code=${code}${reason ? `, reason=${reason}` : ''}).`
515
+ });
516
+ }
517
+ });
518
+ } catch (err) {
519
+ failWith({
520
+ code: SdkErrorCode.LIVENESS_FAILED,
521
+ message: err instanceof Error ? err.message : 'Failed to open the Iris WebSocket.',
522
+ cause: err
523
+ });
524
+ return;
525
+ }
526
+ wsRef.current = connection;
527
+ }, [api, calibrationLabel, failWith, handleWsMessage, locale, retry, sessionId, stopCapture, stopWatchdog, t.liveness.connecting, t.liveness.preparingCamera]);
528
+
529
+ // Re-run after a terminal retry — same cleanup as start, but reuses the
530
+ // mounted camera (no DOM teardown).
531
+ const restartVerification = useCallback(async () => {
532
+ setRetry(null);
533
+ setProgress(null);
534
+ setChallengeText(null);
535
+ setOvalCue('NEUTRAL');
536
+ await startVerification();
537
+ }, [startVerification]);
538
+
539
+ // Effect: when the user enters the capture phase (intro skipped or
540
+ // confirmed), run the start sequence.
541
+ useEffect(() => {
542
+ if (phase !== 'capturing') return;
543
+ void startVerification();
544
+ return () => {
545
+ stopCapture();
546
+ stopWatchdog();
547
+ if (toastTimerRef.current) clearTimeout(toastTimerRef.current);
548
+ try {
549
+ wsRef.current?.close(1000, 'unmount');
550
+ } catch {
551
+ /* ignore */
552
+ }
553
+ wsRef.current = null;
554
+ };
555
+ // We intentionally only re-run when phase flips into capturing — the
556
+ // first start; the retry path is handled by `restartVerification`.
557
+ // eslint-disable-next-line react-hooks/exhaustive-deps
558
+ }, [phase]);
559
+ if (retry) {
560
+ return /*#__PURE__*/_jsx(RetryDialog, {
561
+ title: t.liveness.terminalRetryTitle,
562
+ message: retry.message,
563
+ retryLabel: t.liveness.terminalRetryButton,
564
+ cancelLabel: t.liveness.terminalCancelButton,
565
+ onRetry: () => {
566
+ void restartVerification();
567
+ },
568
+ onCancel: () => {
569
+ setRetry(null);
570
+ onCancel({
571
+ code: SdkErrorCode.LIVENESS_FAILED,
572
+ message: retry.message
573
+ });
574
+ }
575
+ });
576
+ }
577
+ if (phase === 'intro') {
578
+ return /*#__PURE__*/_jsx(View, {
579
+ style: {
580
+ flex: 1
581
+ },
582
+ children: /*#__PURE__*/_jsxs(StepShell, {
583
+ title: t.liveness.introTitle,
584
+ subtitle: t.liveness.introSubtitle,
585
+ iconNode: /*#__PURE__*/_jsx(StepIcon, {
586
+ name: "face"
587
+ }),
588
+ children: [/*#__PURE__*/_jsx(ScrollView, {
589
+ contentContainerStyle: styles.tipsList,
590
+ children: t.liveness.introTips.map((tip, idx) => /*#__PURE__*/_jsxs(View, {
591
+ style: [styles.tipRow, {
592
+ borderColor: theme.borderColor,
593
+ backgroundColor: mixHex(theme.primaryColor, theme.backgroundColor, 6),
594
+ borderRadius: theme.borderRadiusPx
595
+ }],
596
+ children: [/*#__PURE__*/_jsx(View, {
597
+ style: [styles.tipIcon, {
598
+ backgroundColor: mixHex(theme.primaryColor, theme.backgroundColor, 18)
599
+ }],
600
+ children: /*#__PURE__*/_jsx(Text, {
601
+ style: [styles.tipIconText, {
602
+ color: theme.primaryColor
603
+ }],
604
+ children: idx + 1
605
+ })
606
+ }), /*#__PURE__*/_jsx(Text, {
607
+ style: [styles.tipText, {
608
+ color: theme.textColor
609
+ }],
610
+ children: tip
611
+ })]
612
+ }, idx))
613
+ }), bannerError ? /*#__PURE__*/_jsx(Banner, {
614
+ message: bannerError
615
+ }) : null, /*#__PURE__*/_jsxs(View, {
616
+ style: styles.introActions,
617
+ children: [showBackButton ? /*#__PURE__*/_jsx(Button, {
618
+ variant: "ghost",
619
+ label: t.liveness.introBack,
620
+ onPress: () => onCancel({
621
+ code: SdkErrorCode.LIVENESS_FAILED,
622
+ message: 'User exited the liveness intro.'
623
+ }),
624
+ fullWidth: false,
625
+ style: styles.introBtn
626
+ }) : null, /*#__PURE__*/_jsx(Button, {
627
+ label: t.liveness.introStart,
628
+ onPress: () => setPhase('capturing'),
629
+ fullWidth: !showBackButton,
630
+ style: showBackButton ? styles.introBtn : undefined
631
+ })]
632
+ })]
633
+ })
634
+ });
635
+ }
636
+ if (phase === 'finalizing') {
637
+ return /*#__PURE__*/_jsx(AnalyzingOverlay, {
638
+ headline: t.liveness.analyzingHeadline,
639
+ caption: t.liveness.analyzingCaption
640
+ });
641
+ }
642
+ return /*#__PURE__*/_jsx(View, {
643
+ style: {
644
+ flex: 1
645
+ },
646
+ children: /*#__PURE__*/_jsx(LivenessCamera, {
647
+ ref: cameraRef,
648
+ statusText: statusText,
649
+ challengeText: challengeText,
650
+ ovalCue: ovalCue,
651
+ toast: toast,
652
+ progress: progress,
653
+ permissionDeniedLabel: t.liveness.cameraPermissionDenied,
654
+ retryLabel: t.liveness.cameraTryAgain,
655
+ cancelLabel: t.common.cancel
656
+ // Intentionally no onCancel during capture. The capture screen is
657
+ // meant to be fullscreen and uninterruptible — if the user wants
658
+ // out, the 25 s progress watchdog catches stalled sessions and
659
+ // routes them through the RetryDialog (with its own Cancel option).
660
+ // The intro screen keeps the explicit "Atrás" button.
661
+ })
662
+ });
663
+ }
664
+ const styles = StyleSheet.create({
665
+ tipsList: {
666
+ paddingVertical: 4,
667
+ gap: 10
668
+ },
669
+ tipRow: {
670
+ flexDirection: 'row',
671
+ alignItems: 'center',
672
+ gap: 12,
673
+ padding: 12,
674
+ borderWidth: 1
675
+ },
676
+ tipIcon: {
677
+ width: 32,
678
+ height: 32,
679
+ borderRadius: 16,
680
+ alignItems: 'center',
681
+ justifyContent: 'center'
682
+ },
683
+ tipIconText: {
684
+ fontSize: 14,
685
+ fontWeight: '700'
686
+ },
687
+ tipText: {
688
+ flex: 1,
689
+ fontSize: 14,
690
+ lineHeight: 20
691
+ },
692
+ introActions: {
693
+ flexDirection: 'row',
694
+ gap: 10,
695
+ marginTop: 6
696
+ },
697
+ introBtn: {
698
+ flex: 1
699
+ }
700
+ });
701
+ //# sourceMappingURL=LivenessMatchStep.js.map