@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,1177 @@
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
+ // `expo-file-system` v19's `File` class wraps a `file://` path with a Blob-
22
+ // compatible API (`arrayBuffer`, `size`, `delete`). We read the recorded mp4
23
+ // to bytes in JS and PUT them with the global `fetch`. For the typical
24
+ // 1–5 MB session video this is well within the bridge budget; if the
25
+ // recorded files grow significantly we can switch to a streaming uploader
26
+ // without changing the call sites.
27
+ import { File as FsFile } from 'expo-file-system';
28
+ import * as ImageManipulator from 'expo-image-manipulator';
29
+ import { SdkErrorCode } from '../types';
30
+ import { Banner } from '../ui/primitives/Banner';
31
+ import { Button } from '../ui/primitives/Button';
32
+ import { AnalyzingOverlay } from '../ui/overlays/AnalyzingOverlay';
33
+ import { RetryDialog } from '../ui/overlays/RetryDialog';
34
+ import { StepShell } from '../ui/StepShell';
35
+ import { StepIcon } from '../ui/icons/StepIcon';
36
+ import { mixHex, useTheme } from '../ui/theme';
37
+ import { getStrings } from '../i18n';
38
+ import { log } from '../utils/log';
39
+ import { readJpegFromUri } from '../utils/jpegFromUri';
40
+ import { buildSignedFrameEnvelope, importHmacKey } from '../utils/hmac';
41
+ import { TERMINAL_WARNING_CODES, openIrisWebSocket } from '../transport/irisWebSocket';
42
+ import { LivenessCamera } from '../camera/LivenessCamera';
43
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
44
+ // Capture loop defaults tuned for the Iris orchestrator's frame cadence.
45
+ const FRAME_MS_DEFAULT = 350;
46
+ const FRAME_MS_TURN = 220;
47
+ const PROGRESS_WATCHDOG_MS = 25_000;
48
+ /**
49
+ * Hard ceiling for the POST /liveness-verify call that runs after
50
+ * SESSION_COMPLETE. The progress watchdog is already off by then, so an
51
+ * unbounded fetch (the dev network shows recurring HTTP/2 stream resets)
52
+ * would strand the user on the analyzing overlay forever.
53
+ */
54
+ const LIVENESS_VERIFY_TIMEOUT_MS = 20_000;
55
+ const FRAME_MAX_LONG_EDGE = 720;
56
+ const FRAME_QUALITY = 0.55;
57
+ /**
58
+ * Hard ceiling for the video upload PUT to GCS that runs between SESSION_COMPLETE
59
+ * and POST /liveness-verify. Long enough for a 5 MB upload on a slow mobile link
60
+ * but short enough that a stalled connection can't keep the user on the
61
+ * analyzing overlay indefinitely. On timeout we fall back to verify-without-body.
62
+ */
63
+ /**
64
+ * Hard ceiling for the video upload PUT to GCS that runs between
65
+ * SESSION_COMPLETE and POST /liveness-verify. The signed URL TTL is 10 min,
66
+ * so 60 s leaves comfortable headroom for a typical 1–5 MB session video
67
+ * over a slow mobile uplink. On timeout we fall back to verify-without-body.
68
+ */
69
+ const VIDEO_UPLOAD_TIMEOUT_MS = 60_000;
70
+ // Upper bound for vision-camera to deliver `onRecordingFinished` after
71
+ // `stopRecording()` resolves. Observed ~50–200 ms in practice; we set the
72
+ // cap generously so a slow flush on older Androids doesn't strand the
73
+ // failure path waiting for a signal that's just running late.
74
+ const RECORDING_FINISH_TIMEOUT_MS = 3_000;
75
+ const VIDEO_CONTENT_TYPE = 'video/mp4';
76
+
77
+ /** Returns the first 80 chars of a URL — enough to spot the bucket without dumping the V4 signature. */
78
+ function truncateUrl(url) {
79
+ return url.length <= 80 ? url : `${url.slice(0, 80)}…`;
80
+ }
81
+ export class LivenessMatchStep {
82
+ destroyed = false;
83
+ constructor(deps) {
84
+ this.deps = deps;
85
+ }
86
+ run() {
87
+ return new Promise((resolve, reject) => {
88
+ this.resolveStep = resolve;
89
+ this.rejectStep = reject;
90
+ this.deps.ui.setNode(/*#__PURE__*/_jsx(LivenessMatchView, {
91
+ api: this.deps.api,
92
+ sessionId: this.deps.sessionId,
93
+ locale: this.deps.locale,
94
+ calibrationLabel: this.deps.livenessCalibrationLabel,
95
+ showIntro: true,
96
+ showBackButton: true,
97
+ onVideoUploaded: this.deps.onLivenessVideoUploaded,
98
+ onComplete: () => {
99
+ if (this.destroyed) return;
100
+ this.deps.ui.setNode(null);
101
+ this.resolveStep();
102
+ },
103
+ onCancel: err => {
104
+ if (this.destroyed) return;
105
+ this.deps.ui.setNode(null);
106
+ this.rejectStep(err);
107
+ }
108
+ }));
109
+ });
110
+ }
111
+ destroy() {
112
+ this.destroyed = true;
113
+ this.deps.ui.setNode(null);
114
+ }
115
+ }
116
+ function LivenessMatchView({
117
+ api,
118
+ sessionId,
119
+ locale,
120
+ calibrationLabel,
121
+ showIntro,
122
+ showBackButton,
123
+ onVideoUploaded,
124
+ onComplete,
125
+ onCancel
126
+ }) {
127
+ const t = getStrings(locale);
128
+ const theme = useTheme();
129
+ const cameraRef = useRef(null);
130
+ const [phase, setPhase] = useState(showIntro ? 'intro' : 'capturing');
131
+ const [statusText, setStatusText] = useState(null);
132
+ const [challengeText, setChallengeText] = useState(null);
133
+ const [ovalCue, setOvalCue] = useState('NEUTRAL');
134
+ const [toast, setToast] = useState(null);
135
+ const [progress, setProgress] = useState(null);
136
+ const [retry, setRetry] = useState(null);
137
+ const [bannerError, setBannerError] = useState(null);
138
+
139
+ // Long-lived state that the capture loop / WS handlers need without
140
+ // triggering re-renders: kept in refs.
141
+ const wsRef = useRef(null);
142
+ const hmacRef = useRef(null);
143
+ const livenessSessionIdRef = useRef(null);
144
+ const currentChallengeRef = useRef(null);
145
+ // Tracks the position of the active challenge inside the session sequence
146
+ // so we can recognise the LAST challenge completing and switch to the
147
+ // "Analyzing" overlay immediately, instead of letting the user stare at
148
+ // the camera with the last instruction frozen on screen for the seconds
149
+ // it takes the worker to drain its queue and the orchestrator to emit
150
+ // SESSION_COMPLETE.
151
+ const lastChallengeMetaRef = useRef(null);
152
+ const frameMsRef = useRef(FRAME_MS_DEFAULT);
153
+ const captureTimerRef = useRef(null);
154
+ const inFlightRef = useRef(false);
155
+ const framesSentRef = useRef(0);
156
+ const watchdogRef = useRef(null);
157
+ const finalizingRef = useRef(false);
158
+ const toastTimerRef = useRef(null);
159
+ // Tracks the toast currently on screen so we can extend its visibility when
160
+ // the same message arrives again (instead of dismount/remount, which made
161
+ // warnings flash in <2s and the user couldn't read them).
162
+ const activeToastRef = useRef(null);
163
+
164
+ // ── Video recording state (OSDKR-4) ─────────────────────────────────────
165
+ // `videoUploadRef` holds the signed URL returned by /liveness-init when the
166
+ // backend enabled video capture for this session. `null` → skip recording.
167
+ const videoUploadRef = useRef(null);
168
+ // Current state of the video pipeline. Best-effort: any value other than
169
+ // `'uploaded'` ends up calling /liveness-verify WITHOUT a body — liveness
170
+ // still completes normally.
171
+
172
+ const videoOutcomeRef = useRef('none');
173
+ // Filled in when the GCS PUT returns 200; consumed by the verify call.
174
+ const videoMetaRef = useRef(null);
175
+ // Resolves when the upload (success or failure path) is fully settled. The
176
+ // SESSION_COMPLETE handler awaits this with a bounded timeout before calling
177
+ // /liveness-verify so the metadata, if any, makes it into the body.
178
+ const videoUploadPromiseRef = useRef(null);
179
+ // Resolves as soon as vision-camera fires `onRecordingFinished` (i.e. when
180
+ // the mp4 file is fully written and `uploadRecordedVideo` has been kicked
181
+ // off — fetch is in flight but not yet complete). `failWith` awaits this with
182
+ // a short timeout so the upload's underlying fetch is *started* before the
183
+ // step is torn down. After the unmount the fetch closure keeps its own refs
184
+ // alive and the PUT to GCS completes in the background.
185
+ const videoRecordingFinishedPromiseRef = useRef(null);
186
+ // Local file system path of the temp mp4. Tracked so the unmount cleanup
187
+ // can delete it if the user backs out before the upload finished.
188
+ const videoTempPathRef = useRef(null);
189
+ // Cached so `failWith` / unmount can invoke the callback with the prop
190
+ // captured at start, even if the host re-renders.
191
+ const onVideoUploadedRef = useRef(onVideoUploaded);
192
+ useEffect(() => {
193
+ onVideoUploadedRef.current = onVideoUploaded;
194
+ }, [onVideoUploaded]);
195
+
196
+ // Each toast stays on screen at least this long. The orchestrator can spam
197
+ // WARNINGs (POSITIONING_REQUIRED, SPOOF_RISK_HIGH, …) several times per
198
+ // second; without a floor the user literally cannot read them.
199
+ const TOAST_MIN_DURATION_MS = 3200;
200
+ const showToast = useCallback((kind, message) => {
201
+ const active = activeToastRef.current;
202
+ if (active && active.kind === kind && active.message === message) {
203
+ // Identical toast already visible — just refresh the timer so it
204
+ // stays up while warnings keep arriving. Do NOT touch `setToast`:
205
+ // a new object would re-trigger the entry animation and flicker.
206
+ if (toastTimerRef.current) clearTimeout(toastTimerRef.current);
207
+ toastTimerRef.current = setTimeout(() => {
208
+ setToast(null);
209
+ activeToastRef.current = null;
210
+ }, TOAST_MIN_DURATION_MS);
211
+ return;
212
+ }
213
+ // Different content: replace and guarantee the new toast its own
214
+ // minimum window.
215
+ activeToastRef.current = {
216
+ kind,
217
+ message
218
+ };
219
+ setToast({
220
+ kind,
221
+ message
222
+ });
223
+ if (toastTimerRef.current) clearTimeout(toastTimerRef.current);
224
+ toastTimerRef.current = setTimeout(() => {
225
+ setToast(null);
226
+ activeToastRef.current = null;
227
+ }, TOAST_MIN_DURATION_MS);
228
+ }, []);
229
+ const stopWatchdog = useCallback(() => {
230
+ if (watchdogRef.current) {
231
+ clearTimeout(watchdogRef.current);
232
+ watchdogRef.current = null;
233
+ }
234
+ }, []);
235
+ const stopCapture = useCallback(() => {
236
+ if (captureTimerRef.current) {
237
+ clearInterval(captureTimerRef.current);
238
+ captureTimerRef.current = null;
239
+ }
240
+ inFlightRef.current = false;
241
+ }, []);
242
+
243
+ // ── Video upload pipeline (OSDKR-4) ─────────────────────────────────────
244
+ // Everything below is best-effort: never throws into the caller; never
245
+ // blocks liveness completion. The worst case is `videoOutcomeRef = 'failed'`
246
+ // and verify being called without a body.
247
+ const deleteVideoTemp = useCallback(path => {
248
+ if (!path) return;
249
+ try {
250
+ // `File.delete()` is synchronous in expo-file-system v19.
251
+ new FsFile(path).delete();
252
+ } catch {
253
+ // Best-effort cleanup; we can't do much if rm fails.
254
+ }
255
+ }, []);
256
+ const uploadRecordedVideo = useCallback(async video => {
257
+ const target = videoUploadRef.current;
258
+ videoTempPathRef.current = video.path;
259
+ if (!target) {
260
+ log.warn('[Liveness] video upload skipped: no signed URL in init response');
261
+ videoOutcomeRef.current = 'failed';
262
+ deleteVideoTemp(video.path);
263
+ videoTempPathRef.current = null;
264
+ return;
265
+ }
266
+ const durationMs = typeof video.duration === 'number' && isFinite(video.duration) ? Math.round(video.duration * 1000) : null;
267
+ let sizeBytes = null;
268
+ let file = null;
269
+ try {
270
+ file = new FsFile(video.path);
271
+ sizeBytes = typeof file.size === 'number' ? file.size : null;
272
+ } catch (err) {
273
+ log.warn('[Liveness] could not stat video file before upload', err);
274
+ }
275
+ log.info('[Liveness] video upload starting', {
276
+ url: truncateUrl(target.upload_url),
277
+ method: target.method,
278
+ contentType: VIDEO_CONTENT_TYPE,
279
+ path: video.path,
280
+ sizeBytes,
281
+ durationMs
282
+ });
283
+ const t0 = Date.now();
284
+ try {
285
+ // Build a NATIVE React Native Blob from the `file://` URI: fetching
286
+ // the local path returns a Response whose `.blob()` is the BlobModule
287
+ // implementation that the bridge actually knows how to upload. Using
288
+ // the expo-file-system `File` directly silently sends an empty body
289
+ // (GCS responds 200 with a 0-byte object — exactly what we hit
290
+ // before). Reading the bytes through the native Blob keeps the data
291
+ // on the native side and uploads streamed from disk.
292
+ const fileUri = video.path.startsWith('file://') ? video.path : `file://${video.path}`;
293
+ const nativeBlob = await (await fetch(fileUri)).blob();
294
+ log.info('[Liveness] video upload body prepared', {
295
+ blobSize: nativeBlob.size,
296
+ blobType: nativeBlob.type
297
+ });
298
+ const result = await fetch(target.upload_url, {
299
+ method: 'PUT',
300
+ headers: {
301
+ 'Content-Type': VIDEO_CONTENT_TYPE
302
+ },
303
+ body: nativeBlob
304
+ });
305
+ const elapsedMs = Date.now() - t0;
306
+ if (result.ok) {
307
+ log.info('[Liveness] video upload ok', {
308
+ status: result.status,
309
+ elapsedMs,
310
+ sizeBytes
311
+ });
312
+ videoOutcomeRef.current = 'uploaded';
313
+ videoMetaRef.current = {
314
+ content_type: VIDEO_CONTENT_TYPE,
315
+ duration_ms: durationMs
316
+ };
317
+ // Invoke the host callback BEFORE cleanup so the path stays valid
318
+ // for any synchronous host work (rare, but cheap to guarantee).
319
+ try {
320
+ onVideoUploadedRef.current?.({
321
+ upload_url: target.upload_url,
322
+ content_type: VIDEO_CONTENT_TYPE,
323
+ duration_ms: durationMs,
324
+ size_bytes: sizeBytes
325
+ });
326
+ } catch (err) {
327
+ log.warn('[Liveness] onLivenessVideoUploaded threw', err);
328
+ }
329
+ } else {
330
+ // Try to extract the GCS error XML — its body tells us exactly which
331
+ // permission / signature param failed (otherwise we are blind).
332
+ let responseSnippet = '';
333
+ try {
334
+ responseSnippet = (await result.text()).slice(0, 400);
335
+ } catch {
336
+ /* body not readable; status alone is the signal */
337
+ }
338
+ log.warn('[Liveness] video upload non-200', {
339
+ status: result.status,
340
+ elapsedMs,
341
+ sizeBytes,
342
+ body: responseSnippet
343
+ });
344
+ videoOutcomeRef.current = 'failed';
345
+ }
346
+ } catch (err) {
347
+ log.warn('[Liveness] video upload error', {
348
+ elapsedMs: Date.now() - t0,
349
+ sizeBytes,
350
+ err
351
+ });
352
+ videoOutcomeRef.current = 'failed';
353
+ } finally {
354
+ deleteVideoTemp(video.path);
355
+ videoTempPathRef.current = null;
356
+ }
357
+ }, [deleteVideoTemp]);
358
+ const startVideoRecordingIfEnabled = useCallback(() => {
359
+ if (!videoUploadRef.current) {
360
+ log.info('[Liveness] video skipped: no video_upload in liveness-init');
361
+ return;
362
+ }
363
+ const camera = cameraRef.current;
364
+ if (!camera) {
365
+ log.warn('[Liveness] video skipped: LivenessCamera ref not ready at SESSION_READY');
366
+ return;
367
+ }
368
+ log.info('[Liveness] video recording starting', {
369
+ uploadUrl: truncateUrl(videoUploadRef.current.upload_url),
370
+ expiresAt: videoUploadRef.current.expires_at
371
+ });
372
+ // Pre-assign the upload promise BEFORE calling startRecording. vision-camera
373
+ // dispatches `onRecordingFinished` on a separate microtask from the
374
+ // `stopRecording()` resolution, so a "set the promise inside the callback"
375
+ // pattern races SESSION_COMPLETE — the verify POST fires before
376
+ // `uploadRecordedVideo` is even invoked, and the body ends up empty.
377
+ // The Deferred resolves once the recording's success/error path is fully
378
+ // settled (including the upload PUT and the cleanup).
379
+ let settle = () => {};
380
+ let settled = false;
381
+ videoUploadPromiseRef.current = new Promise(resolve => {
382
+ settle = () => {
383
+ if (settled) return;
384
+ settled = true;
385
+ resolve();
386
+ };
387
+ });
388
+ let signalRecordingFinished = () => {};
389
+ let recordingFinishedSettled = false;
390
+ videoRecordingFinishedPromiseRef.current = new Promise(resolve => {
391
+ signalRecordingFinished = () => {
392
+ if (recordingFinishedSettled) return;
393
+ recordingFinishedSettled = true;
394
+ resolve();
395
+ };
396
+ });
397
+ try {
398
+ camera.startVideoRecording({
399
+ onRecordingFinished: video => {
400
+ log.info('[Liveness] video recording finished', {
401
+ path: video.path,
402
+ durationSec: video.duration
403
+ });
404
+ // Signal `failWith` (and anyone else waiting for the file to be
405
+ // ready) BEFORE awaiting the upload. The fetch closure keeps the
406
+ // upload alive past any unmount, so it's safe to let the component
407
+ // tear down once the recording-finished signal has fired.
408
+ uploadRecordedVideo(video).finally(() => {
409
+ settle();
410
+ });
411
+ signalRecordingFinished();
412
+ },
413
+ onRecordingError: err => {
414
+ log.warn('[Liveness] video recording error', err);
415
+ videoOutcomeRef.current = 'failed';
416
+ signalRecordingFinished();
417
+ settle();
418
+ }
419
+ });
420
+ log.info('[Liveness] video recording started');
421
+ videoOutcomeRef.current = 'recording';
422
+ } catch (err) {
423
+ log.warn('[Liveness] failed to start video recording', err);
424
+ videoOutcomeRef.current = 'failed';
425
+ // No callback will ever fire → unblock anyone awaiting either Deferred.
426
+ signalRecordingFinished();
427
+ settle();
428
+ }
429
+ }, [uploadRecordedVideo]);
430
+ const stopVideoRecordingIfActive = useCallback(async () => {
431
+ if (videoOutcomeRef.current !== 'recording') {
432
+ log.info('[Liveness] video stop skipped', {
433
+ outcome: videoOutcomeRef.current
434
+ });
435
+ return;
436
+ }
437
+ const camera = cameraRef.current;
438
+ if (!camera) {
439
+ log.warn('[Liveness] video stop skipped: LivenessCamera ref gone');
440
+ return;
441
+ }
442
+ log.info('[Liveness] video recording stopping');
443
+ try {
444
+ // Returns when vision-camera flushed the file; the upload Deferred
445
+ // (set in startVideoRecordingIfEnabled) is what actually tells us when
446
+ // the PUT + cleanup are done — the SESSION_COMPLETE handler awaits it.
447
+ await camera.stopVideoRecording();
448
+ log.info('[Liveness] video recording stop resolved (onRecordingFinished will follow)');
449
+ } catch (err) {
450
+ log.warn('[Liveness] failed to stop video recording', err);
451
+ videoOutcomeRef.current = 'failed';
452
+ }
453
+ }, []);
454
+ const failWith = useCallback(err => {
455
+ stopWatchdog();
456
+ stopCapture();
457
+ // OSDKR-4 requirement: the video must upload on EVERY outcome,
458
+ // including LIVENESS_FAILED, so back-office reviewers can audit
459
+ // what happened in declined sessions. To make that work we need
460
+ // `onRecordingFinished` to fire *before* the component unmounts —
461
+ // once the file is flushed and `uploadRecordedVideo` has kicked
462
+ // off, the fetch closure carries the upload through to completion
463
+ // on its own, no matter how quickly the UI is torn down.
464
+ //
465
+ // We don't wait for the GCS PUT to complete (that can take
466
+ // seconds and the user shouldn't sit on the error screen for it),
467
+ // just for the recording-finished signal.
468
+ const recordingWasActive = videoOutcomeRef.current === 'recording';
469
+ const finish = () => {
470
+ if (videoTempPathRef.current && !recordingWasActive) {
471
+ // Only delete the temp file when there was no recording in
472
+ // flight; otherwise `uploadRecordedVideo` is responsible for
473
+ // deleting it after the PUT settles.
474
+ const path = videoTempPathRef.current;
475
+ videoTempPathRef.current = null;
476
+ void deleteVideoTemp(path);
477
+ }
478
+ try {
479
+ wsRef.current?.close(1000, 'fail');
480
+ } catch {
481
+ /* ignore */
482
+ }
483
+ wsRef.current = null;
484
+ onCancel(err);
485
+ };
486
+ if (!recordingWasActive) {
487
+ finish();
488
+ return;
489
+ }
490
+ const finishedPromise = videoRecordingFinishedPromiseRef.current;
491
+ void (async () => {
492
+ await stopVideoRecordingIfActive();
493
+ if (finishedPromise) {
494
+ // Bound the wait so a misbehaving recorder can't strand the
495
+ // user on the camera screen forever. `RECORDING_FINISH_TIMEOUT_MS`
496
+ // is conservative — vision-camera typically lands the callback
497
+ // tens of milliseconds after stopRecording resolves.
498
+ let finishTimer = null;
499
+ const timeoutPromise = new Promise(resolve => {
500
+ finishTimer = setTimeout(() => {
501
+ log.warn('[Liveness] recording-finished signal timed out — proceeding to fail without ensuring the upload kicked off');
502
+ resolve();
503
+ }, RECORDING_FINISH_TIMEOUT_MS);
504
+ });
505
+ await Promise.race([finishedPromise, timeoutPromise]);
506
+ if (finishTimer) clearTimeout(finishTimer);
507
+ }
508
+ finish();
509
+ })();
510
+ }, [deleteVideoTemp, onCancel, stopCapture, stopVideoRecordingIfActive, stopWatchdog]);
511
+ const captureAndSend = useCallback(async () => {
512
+ if (inFlightRef.current) return;
513
+ const ws = wsRef.current;
514
+ if (!ws || !ws.isOpen()) return;
515
+ inFlightRef.current = true;
516
+ try {
517
+ const photo = await cameraRef.current?.takeFrame();
518
+ if (!photo || !ws.isOpen()) return;
519
+ // Front-camera frames come back mirrored (vision-camera's default for
520
+ // front cam, which we keep so the recorded mp4 has a correct rotation
521
+ // matrix — see the `isMirrored` comment in LivenessCamera). For Iris,
522
+ // we want the un-mirrored yaw so TURN_LEFT/RIGHT challenges map to
523
+ // real-world directions, so we flip the JPEG horizontally here before
524
+ // signing and sending.
525
+ const compressed = await ImageManipulator.manipulateAsync(photo.path.startsWith('file://') ? photo.path : `file://${photo.path}`, [{
526
+ resize: {
527
+ width: FRAME_MAX_LONG_EDGE
528
+ }
529
+ }, {
530
+ flip: ImageManipulator.FlipType.Horizontal
531
+ }], {
532
+ compress: FRAME_QUALITY,
533
+ format: ImageManipulator.SaveFormat.JPEG
534
+ });
535
+ if (!ws.isOpen()) return;
536
+ const jpeg = await readJpegFromUri(compressed.uri);
537
+ const key = hmacRef.current;
538
+ if (key) {
539
+ const envelope = buildSignedFrameEnvelope({
540
+ key,
541
+ sessionId: livenessSessionIdRef.current ?? sessionId,
542
+ frameId: framesSentRef.current,
543
+ jpegBytes: jpeg.bytes,
544
+ jpegBase64: jpeg.base64
545
+ });
546
+ ws.sendJson(envelope.json);
547
+ } else {
548
+ // Vision-camera + RN's WebSocket need an ArrayBuffer for binary frames.
549
+ // `Uint8Array.buffer` is a `SharedArrayBuffer` on some Hermes versions
550
+ // — slice into a fresh ArrayBuffer to be safe.
551
+ const ab = jpeg.bytes.buffer.slice(jpeg.bytes.byteOffset, jpeg.bytes.byteOffset + jpeg.bytes.byteLength);
552
+ ws.sendBinary(ab);
553
+ }
554
+ framesSentRef.current += 1;
555
+ } catch (err) {
556
+ log.warn('[Liveness] frame send failed', err);
557
+ } finally {
558
+ inFlightRef.current = false;
559
+ }
560
+ }, [sessionId]);
561
+ const startCaptureLoop = useCallback(ms => {
562
+ stopCapture();
563
+ frameMsRef.current = ms;
564
+ captureTimerRef.current = setInterval(() => {
565
+ void captureAndSend();
566
+ }, ms);
567
+ }, [captureAndSend, stopCapture]);
568
+ const adjustFps = useCallback(ms => {
569
+ if (frameMsRef.current === ms) return;
570
+ if (captureTimerRef.current) {
571
+ startCaptureLoop(ms);
572
+ } else {
573
+ frameMsRef.current = ms;
574
+ }
575
+ }, [startCaptureLoop]);
576
+ const challengeLabel = useCallback(id => {
577
+ if (!id) return '';
578
+ return t.liveness.challenge[id] ?? '';
579
+ }, [t.liveness.challenge]);
580
+ const presentTerminalRetry = useCallback((code, message) => {
581
+ stopCapture();
582
+ stopWatchdog();
583
+ try {
584
+ wsRef.current?.close(4001, 'terminal_warning_retry_pending');
585
+ } catch {
586
+ /* ignore */
587
+ }
588
+ wsRef.current = null;
589
+ setRetry({
590
+ code,
591
+ message: message?.trim() || t.liveness.terminalRetryFallback
592
+ });
593
+ }, [stopCapture, stopWatchdog, t.liveness.terminalRetryFallback]);
594
+ const resetWatchdog = useCallback(() => {
595
+ stopWatchdog();
596
+ watchdogRef.current = setTimeout(() => {
597
+ log.warn('[Liveness] progress watchdog fired');
598
+ // The watchdog used to be a hard fail — onCancel → step rejects →
599
+ // orchestrator surfaces the error and exits the whole liveness step.
600
+ // That left the user with no in-flow recovery: they had to restart
601
+ // the entire onboarding. The Iris-side "no progress in N seconds" is
602
+ // usually a recoverable user-side issue (lighting, framing, not
603
+ // looking at the camera), so we treat it the same way as a terminal
604
+ // WARNING: tear down the WS, show the retry dialog, and let the user
605
+ // restart the verification without leaving the step.
606
+ presentTerminalRetry('NO_PROGRESS', t.liveness.noProgressMessage);
607
+ }, PROGRESS_WATCHDOG_MS);
608
+ }, [presentTerminalRetry, stopWatchdog, t.liveness.noProgressMessage]);
609
+ const handleWsMessage = useCallback(msg => {
610
+ switch (msg.type) {
611
+ case 'SESSION_READY':
612
+ {
613
+ setStatusText(null);
614
+ // The ~1-2 s gap between SESSION_READY and the first CHALLENGE is
615
+ // where users decide their posture for the whole session. We use
616
+ // it for two pieces of guidance, layered:
617
+ // - A short "Heads up — starting now" toast above the oval so
618
+ // they're not caught looking away when (e.g.) the BLINK window
619
+ // opens.
620
+ // - A persistent `challengeText` ("Center your face in the oval")
621
+ // anchored above the oval so they keep adjusting until the
622
+ // first real challenge arrives and overwrites it. Without
623
+ // this, every Android calibration session started with the
624
+ // face at ~25 % of the frame width and SMILE / MOVE_FARTHER
625
+ // failed before the user understood what was being asked.
626
+ setChallengeText(t.liveness.centerFace);
627
+ showToast('success', t.liveness.getReady);
628
+ startCaptureLoop(FRAME_MS_DEFAULT);
629
+ // Start the local mp4 recording in parallel with the frame loop, if
630
+ // the backend opted in via `video_upload` in /liveness-init. Pure
631
+ // best-effort: any failure here is logged and never blocks liveness.
632
+ startVideoRecordingIfEnabled();
633
+ resetWatchdog();
634
+ return;
635
+ }
636
+ case 'CHALLENGE':
637
+ {
638
+ const ch = msg.challenge ?? null;
639
+ currentChallengeRef.current = ch;
640
+ // Stash the sequence position so CHALLENGE_COMPLETE can tell
641
+ // whether this was the LAST challenge and switch to the analyzing
642
+ // overlay immediately instead of waiting for SESSION_COMPLETE.
643
+ if (typeof msg.sequenceIndex === 'number' && typeof msg.totalChallenges === 'number') {
644
+ lastChallengeMetaRef.current = {
645
+ index: msg.sequenceIndex,
646
+ total: msg.totalChallenges
647
+ };
648
+ }
649
+ adjustFps(ch === 'TURN_LEFT' || ch === 'TURN_RIGHT' ? FRAME_MS_TURN : FRAME_MS_DEFAULT);
650
+ setChallengeText(challengeLabel(ch));
651
+ // Map distance challenges to an oval-size cue so the viewfinder
652
+ // shape reinforces the instruction (grows for closer, returns to
653
+ // neutral for farther). All other challenges keep the neutral
654
+ // oval — the dim mask shouldn't move under a turn / smile / blink.
655
+ setOvalCue(ch === 'MOVE_CLOSER' ? 'MOVE_CLOSER' : ch === 'MOVE_FARTHER' ? 'MOVE_FARTHER' : 'NEUTRAL');
656
+ setProgress(0);
657
+ resetWatchdog();
658
+ return;
659
+ }
660
+ case 'CHALLENGE_PROGRESS':
661
+ {
662
+ if (typeof msg.confidence === 'number') {
663
+ setProgress(msg.confidence);
664
+ }
665
+ resetWatchdog();
666
+ return;
667
+ }
668
+ case 'CHALLENGE_COMPLETE':
669
+ {
670
+ setProgress(1);
671
+ currentChallengeRef.current = null;
672
+ adjustFps(FRAME_MS_DEFAULT);
673
+ // Reset the oval back to neutral after each challenge so the
674
+ // next CHALLENGE (or finalize) doesn't inherit a "zoomed" oval.
675
+ setOvalCue('NEUTRAL');
676
+ // Last challenge of the sequence completed → switch to the
677
+ // "Analyzing your video" overlay right away. SESSION_COMPLETE
678
+ // can take several seconds to land while the worker drains
679
+ // its queue; without this the user would stare at the camera
680
+ // and the stale instruction the whole time.
681
+ //
682
+ // CRITICAL: the video recording MUST be stopped before the phase
683
+ // change. Switching phase unmounts <LivenessCamera>, which makes
684
+ // vision-camera tear down the recording mid-flush — the
685
+ // `onRecordingFinished` callback never fires and the upload
686
+ // promise stays pending until the 60 s timeout. We stop first,
687
+ // then unmount.
688
+ const meta = lastChallengeMetaRef.current;
689
+ if (meta && meta.index >= meta.total - 1) {
690
+ log.info('[Liveness] last challenge complete — preparing to finalize', {
691
+ index: meta.index,
692
+ total: meta.total,
693
+ videoOutcome: videoOutcomeRef.current
694
+ });
695
+ stopCapture();
696
+ (async () => {
697
+ await stopVideoRecordingIfActive();
698
+ log.info('[Liveness] last challenge: switching phase to finalizing');
699
+ setPhase('finalizing');
700
+ })();
701
+ }
702
+ resetWatchdog();
703
+ return;
704
+ }
705
+ case 'WARNING':
706
+ {
707
+ if (msg.code && TERMINAL_WARNING_CODES.has(msg.code)) {
708
+ presentTerminalRetry(msg.code, msg.message);
709
+ return;
710
+ }
711
+ // The orchestrator aborted the running challenge because capture
712
+ // quality dropped mid-gesture (face drifted too far, lighting
713
+ // fell). Drop back to positioning-style guidance — no progress
714
+ // bar, neutral oval, persistent hint — and let the SAME challenge
715
+ // re-arrive on its own once the user is well positioned again.
716
+ if (msg.code === 'CHALLENGE_REPOSITION') {
717
+ currentChallengeRef.current = null;
718
+ adjustFps(FRAME_MS_DEFAULT);
719
+ setProgress(null);
720
+ setOvalCue('NEUTRAL');
721
+ const repositionText = msg.message ?? t.liveness.repositioning;
722
+ setChallengeText(repositionText);
723
+ showToast('warning', repositionText);
724
+ resetWatchdog();
725
+ return;
726
+ }
727
+ const isPositioningReady = msg.code === 'POSITIONING_READY';
728
+ // Per-code SDK-side fallback used when the orchestrator forwarded a
729
+ // code but no localised text (e.g. older orchestrator versions, or
730
+ // the rare WS message that drops the body). The orchestrator's own
731
+ // text is preferred — it always wins when present — so the user sees
732
+ // the server's exact wording in the session's locale.
733
+ const FALLBACK_BY_CODE = {
734
+ TOO_FAR: t.liveness.warningTooFar,
735
+ TOO_CLOSE: t.liveness.warningTooClose,
736
+ MOVE_CLOSER_HINT: t.liveness.warningMoveCloserHint,
737
+ MOVE_FARTHER_HINT: t.liveness.warningMoveFartherHint
738
+ };
739
+ // Timeout fallback is dynamic: the orchestrator now sends a
740
+ // challenge-specific message ("No pudimos reconocer el giro hacia
741
+ // la izquierda"), but if it ever drops it the SDK rebuilds the
742
+ // same text from the locally tracked active challenge.
743
+ let timeoutFallback;
744
+ if (msg.code === 'CHALLENGE_TIMEOUT') {
745
+ const ch = currentChallengeRef.current;
746
+ switch (ch) {
747
+ case 'TURN_LEFT':
748
+ timeoutFallback = t.liveness.timeoutTurnLeft;
749
+ break;
750
+ case 'TURN_RIGHT':
751
+ timeoutFallback = t.liveness.timeoutTurnRight;
752
+ break;
753
+ case 'BLINK':
754
+ timeoutFallback = t.liveness.timeoutBlink;
755
+ break;
756
+ case 'SMILE':
757
+ timeoutFallback = t.liveness.timeoutSmile;
758
+ break;
759
+ case 'MOVE_CLOSER':
760
+ timeoutFallback = t.liveness.timeoutMoveCloser;
761
+ break;
762
+ case 'MOVE_FARTHER':
763
+ timeoutFallback = t.liveness.timeoutMoveFarther;
764
+ break;
765
+ default:
766
+ timeoutFallback = t.liveness.timeoutGeneric;
767
+ }
768
+ }
769
+ const codedFallback = timeoutFallback ?? (msg.code ? FALLBACK_BY_CODE[msg.code] : undefined) ?? t.liveness.warningGeneric;
770
+ // Prefer the server-localised message — it's situationally
771
+ // accurate ("El fondo tiene mucho movimiento o reflejos. Pasá a
772
+ // un fondo neutro y plano"). Drop to the SDK fallback only when
773
+ // the orchestrator did not provide one.
774
+ const baseText = msg.message ?? codedFallback;
775
+ const text = isPositioningReady ? t.liveness.positioningReady : typeof msg.consecutiveMisses === 'number' && msg.consecutiveMisses >= 3 ? t.liveness.warningConsecutiveMisses.replace('{n}', String(msg.consecutiveMisses)).concat(' — ', baseText) : baseText;
776
+ showToast(isPositioningReady ? 'success' : 'warning', text);
777
+ resetWatchdog();
778
+ return;
779
+ }
780
+ case 'ERROR':
781
+ {
782
+ failWith({
783
+ code: SdkErrorCode.LIVENESS_FAILED,
784
+ message: msg.message ?? msg.code ?? 'Iris reported an error during liveness.'
785
+ });
786
+ return;
787
+ }
788
+ case 'SESSION_COMPLETE':
789
+ {
790
+ stopWatchdog();
791
+ if (finalizingRef.current) return;
792
+ finalizingRef.current = true;
793
+ stopCapture();
794
+ try {
795
+ wsRef.current?.close(1000, 'session_complete');
796
+ } catch {
797
+ /* ignore */
798
+ }
799
+ wsRef.current = null;
800
+ // IMPORTANT: do NOT setPhase('finalizing') yet. Switching phase
801
+ // unmounts LivenessCamera, which cancels the in-flight video
802
+ // recording mid-flush and prevents `onRecordingFinished` from
803
+ // firing — the upload would never start. We stop the recording
804
+ // first (camera still mounted, ref valid), then transition phase
805
+ // and run the verify pipeline.
806
+ (async () => {
807
+ // ── Settle the video pipeline before /liveness-verify ─────────
808
+ // Best-effort: stop the recording (if still running), then await
809
+ // the upload promise with a hard timeout. Whatever the outcome
810
+ // (uploaded / failed / timeout), we proceed to verify — the body
811
+ // is only attached when the upload actually succeeded.
812
+ await stopVideoRecordingIfActive();
813
+ // Safe to unmount LivenessCamera now: the recording has been
814
+ // flushed and `onRecordingFinished` has been scheduled.
815
+ setPhase('finalizing');
816
+ if (videoUploadPromiseRef.current) {
817
+ log.info('[Liveness] awaiting video upload settle', {
818
+ timeoutMs: VIDEO_UPLOAD_TIMEOUT_MS
819
+ });
820
+ const uploadPromise = videoUploadPromiseRef.current;
821
+ let uploadTimer = null;
822
+ const timeoutPromise = new Promise(resolve => {
823
+ uploadTimer = setTimeout(() => {
824
+ log.warn('[Liveness] video upload timed out — verify will go without body');
825
+ videoOutcomeRef.current = 'failed';
826
+ resolve();
827
+ }, VIDEO_UPLOAD_TIMEOUT_MS);
828
+ });
829
+ await Promise.race([uploadPromise, timeoutPromise]);
830
+ if (uploadTimer) clearTimeout(uploadTimer);
831
+ }
832
+ const verifyBody = videoOutcomeRef.current === 'uploaded' && videoMetaRef.current ? {
833
+ video: videoMetaRef.current
834
+ } : {};
835
+ log.info('[Liveness] POST /liveness-verify', {
836
+ outcome: videoOutcomeRef.current,
837
+ hasBody: 'video' in verifyBody
838
+ });
839
+
840
+ // Bound the verify call with an explicit timeout. SESSION_COMPLETE
841
+ // already turned the progress watchdog off, so if this POST hangs
842
+ // (the dev network shows recurring HTTP/2 INTERNAL_ERROR resets)
843
+ // nothing else would rescue the user — the app would sit on the
844
+ // analyzing overlay forever. On timeout we abort and route through
845
+ // failWith so the retry dialog is shown.
846
+ const verifyController = new AbortController();
847
+ const verifyTimeout = setTimeout(() => verifyController.abort(), LIVENESS_VERIFY_TIMEOUT_MS);
848
+ try {
849
+ await api.post(`/sessions/${sessionId}/liveness-verify`, verifyBody, {
850
+ signal: verifyController.signal
851
+ });
852
+ clearTimeout(verifyTimeout);
853
+ onComplete();
854
+ } catch (err) {
855
+ clearTimeout(verifyTimeout);
856
+ const aborted = verifyController.signal.aborted || err != null && typeof err === 'object' && 'name' in err && err.name === 'AbortError';
857
+ const message = aborted ? 'The verification request timed out. Check your connection and try again.' : err && typeof err === 'object' && 'message' in err ? String(err.message) : 'Failed to notify the backend that liveness completed.';
858
+ failWith({
859
+ code: aborted ? SdkErrorCode.NETWORK_ERROR : SdkErrorCode.LIVENESS_FAILED,
860
+ message,
861
+ cause: err
862
+ });
863
+ }
864
+ })();
865
+ return;
866
+ }
867
+ default:
868
+ return;
869
+ }
870
+ }, [adjustFps, api, challengeLabel, failWith, onComplete, presentTerminalRetry, resetWatchdog, sessionId, showToast, startCaptureLoop, startVideoRecordingIfEnabled, stopCapture, stopVideoRecordingIfActive, stopWatchdog, t.liveness.getReady, t.liveness.positioningReady, t.liveness.repositioning, t.liveness.warningConsecutiveMisses, t.liveness.warningGeneric]);
871
+ const startVerification = useCallback(async () => {
872
+ setBannerError(null);
873
+ setRetry(null);
874
+ setStatusText(t.liveness.connecting);
875
+ finalizingRef.current = false;
876
+ framesSentRef.current = 0;
877
+ currentChallengeRef.current = null;
878
+ lastChallengeMetaRef.current = null;
879
+ frameMsRef.current = FRAME_MS_DEFAULT;
880
+ hmacRef.current = null;
881
+ let init;
882
+ try {
883
+ // `calibration_label` is the wire name expected by the backend
884
+ // (snake_case mirroring iris-test's `/sessions` POST). Only sent when
885
+ // the host explicitly enables calibration via VelionConfig.
886
+ const body = {};
887
+ if (calibrationLabel && calibrationLabel.length > 0) {
888
+ body.calibration_label = calibrationLabel;
889
+ }
890
+ init = await api.post(`/sessions/${sessionId}/liveness-init`, body);
891
+ } catch (err) {
892
+ failWith({
893
+ code: SdkErrorCode.LIVENESS_INIT_FAILED,
894
+ message: (err && typeof err === 'object' && 'message' in err ? String(err.message) : '') || 'Failed to create the Iris liveness session.',
895
+ cause: err
896
+ });
897
+ return;
898
+ }
899
+ if (!init.liveness_session_id || !init.websocket_url) {
900
+ failWith({
901
+ code: SdkErrorCode.LIVENESS_INIT_FAILED,
902
+ message: 'liveness-init response missing required fields.'
903
+ });
904
+ return;
905
+ }
906
+ livenessSessionIdRef.current = init.liveness_session_id;
907
+ if (init.frame_integrity_key_base64) {
908
+ try {
909
+ hmacRef.current = importHmacKey(init.frame_integrity_key_base64);
910
+ } catch (err) {
911
+ log.warn('[Liveness] failed to import HMAC key', err);
912
+ hmacRef.current = null;
913
+ }
914
+ }
915
+ // Reset the video pipeline state for this attempt (the host may retry).
916
+ // We honour `video_upload` even when the host did not register the
917
+ // `onLivenessVideoUploaded` callback — the upload still happens, only
918
+ // the host notification is skipped. `outcome` stays `'none'` until
919
+ // `startVideoRecordingIfEnabled` confirms the recording actually started;
920
+ // see that callback for why we cannot trust `init.video_upload` alone.
921
+ videoUploadRef.current = init.video_upload ?? null;
922
+ videoOutcomeRef.current = 'none';
923
+ videoMetaRef.current = null;
924
+ videoUploadPromiseRef.current = null;
925
+ videoRecordingFinishedPromiseRef.current = null;
926
+ videoTempPathRef.current = null;
927
+ if (init.video_upload) {
928
+ log.info('[Liveness] init.video_upload received', {
929
+ url: truncateUrl(init.video_upload.upload_url),
930
+ expiresAt: init.video_upload.expires_at,
931
+ method: init.video_upload.method
932
+ });
933
+ } else {
934
+ log.info('[Liveness] init.video_upload absent — recording disabled for this session');
935
+ }
936
+ setStatusText(t.liveness.preparingCamera);
937
+ let connection;
938
+ try {
939
+ connection = openIrisWebSocket({
940
+ websocketUrl: init.websocket_url,
941
+ connectionToken: init.connection_token,
942
+ locale,
943
+ onOpen: () => setStatusText(t.liveness.connecting),
944
+ onMessage: handleWsMessage,
945
+ onClose: (code, reason) => {
946
+ if (finalizingRef.current) return;
947
+ // Code 4001 is the close we send ourselves from
948
+ // `presentTerminalRetry` to tear down the WS before showing the
949
+ // retry dialog. Checking the React state `retry` here is unsafe
950
+ // — this handler is registered via closure on a stale render,
951
+ // so `retry` reads `null` even when we just called `setRetry`.
952
+ // The close code is reliable: we always pair 4001 with the
953
+ // retry-dialog mount.
954
+ if (code === 4001) return;
955
+ stopCapture();
956
+ stopWatchdog();
957
+ if (code === 1000) return;
958
+ failWith({
959
+ code: SdkErrorCode.LIVENESS_FAILED,
960
+ message: `Iris WebSocket closed before completion (code=${code}${reason ? `, reason=${reason}` : ''}).`
961
+ });
962
+ }
963
+ });
964
+ } catch (err) {
965
+ failWith({
966
+ code: SdkErrorCode.LIVENESS_FAILED,
967
+ message: err instanceof Error ? err.message : 'Failed to open the Iris WebSocket.',
968
+ cause: err
969
+ });
970
+ return;
971
+ }
972
+ wsRef.current = connection;
973
+ }, [api, calibrationLabel, failWith, handleWsMessage, locale, retry, sessionId, stopCapture, stopWatchdog, t.liveness.connecting, t.liveness.preparingCamera]);
974
+
975
+ // Re-run after a terminal retry — same cleanup as start, but reuses the
976
+ // mounted camera (no DOM teardown).
977
+ const restartVerification = useCallback(async () => {
978
+ setRetry(null);
979
+ setProgress(null);
980
+ setChallengeText(null);
981
+ setOvalCue('NEUTRAL');
982
+ await startVerification();
983
+ }, [startVerification]);
984
+
985
+ // Effect: when the user enters the capture phase (intro skipped or
986
+ // confirmed), run the start sequence.
987
+ //
988
+ // NOTE: this effect must NOT tear down the WebSocket in its cleanup.
989
+ // Its dependency is `[phase]`, so the cleanup runs on every phase change
990
+ // — including capturing → finalizing. Closing the WS there killed it
991
+ // ~250 ms after the last CHALLENGE_COMPLETE, i.e. *before* Iris emitted
992
+ // SESSION_COMPLETE (~440 ms later), so the SDK never received it and
993
+ // never sent /liveness-verify. Session teardown lives in the unmount-only
994
+ // effect below.
995
+ useEffect(() => {
996
+ if (phase !== 'capturing') return;
997
+ void startVerification();
998
+ // We intentionally only re-run when phase flips into capturing — the
999
+ // first start; the retry path is handled by `restartVerification`.
1000
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1001
+ }, [phase]);
1002
+
1003
+ // Effect: real component teardown. Runs once, on unmount only — so the
1004
+ // WebSocket survives in-flow phase changes (capturing → finalizing) and
1005
+ // stays open long enough to receive SESSION_COMPLETE. The SESSION_COMPLETE
1006
+ // / fail / terminal-retry handlers already close the WS explicitly when
1007
+ // the flow ends normally; this is the safety net for an actual unmount.
1008
+ useEffect(() => {
1009
+ return () => {
1010
+ stopCapture();
1011
+ stopWatchdog();
1012
+ if (toastTimerRef.current) clearTimeout(toastTimerRef.current);
1013
+ // Best-effort video pipeline shutdown on unmount. Stop the recording
1014
+ // if it's still running (vision-camera deletes its temp file when the
1015
+ // <Camera> tears down anyway, but we explicitly stop to flush). Then
1016
+ // delete any temp file we own, so a backed-out user doesn't leak
1017
+ // storage.
1018
+ if (videoOutcomeRef.current === 'recording') {
1019
+ void stopVideoRecordingIfActive();
1020
+ }
1021
+ const leftoverPath = videoTempPathRef.current;
1022
+ videoTempPathRef.current = null;
1023
+ if (leftoverPath) {
1024
+ void deleteVideoTemp(leftoverPath);
1025
+ }
1026
+ try {
1027
+ wsRef.current?.close(1000, 'unmount');
1028
+ } catch {
1029
+ /* ignore */
1030
+ }
1031
+ wsRef.current = null;
1032
+ };
1033
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1034
+ }, []);
1035
+ if (retry) {
1036
+ return /*#__PURE__*/_jsx(RetryDialog, {
1037
+ title: t.liveness.terminalRetryTitle,
1038
+ message: retry.message,
1039
+ retryLabel: t.liveness.terminalRetryButton,
1040
+ cancelLabel: t.liveness.terminalCancelButton,
1041
+ onRetry: () => {
1042
+ void restartVerification();
1043
+ },
1044
+ onCancel: () => {
1045
+ setRetry(null);
1046
+ onCancel({
1047
+ code: SdkErrorCode.LIVENESS_FAILED,
1048
+ message: retry.message
1049
+ });
1050
+ }
1051
+ });
1052
+ }
1053
+ if (phase === 'intro') {
1054
+ return /*#__PURE__*/_jsx(View, {
1055
+ style: {
1056
+ flex: 1
1057
+ },
1058
+ children: /*#__PURE__*/_jsxs(StepShell, {
1059
+ title: t.liveness.introTitle,
1060
+ subtitle: t.liveness.introSubtitle,
1061
+ iconNode: /*#__PURE__*/_jsx(StepIcon, {
1062
+ name: "face"
1063
+ }),
1064
+ children: [/*#__PURE__*/_jsx(ScrollView, {
1065
+ contentContainerStyle: styles.tipsList,
1066
+ children: t.liveness.introTips.map((tip, idx) => /*#__PURE__*/_jsxs(View, {
1067
+ style: [styles.tipRow, {
1068
+ borderColor: theme.borderColor,
1069
+ backgroundColor: mixHex(theme.primaryColor, theme.backgroundColor, 6),
1070
+ borderRadius: theme.borderRadiusPx
1071
+ }],
1072
+ children: [/*#__PURE__*/_jsx(View, {
1073
+ style: [styles.tipIcon, {
1074
+ backgroundColor: mixHex(theme.primaryColor, theme.backgroundColor, 18)
1075
+ }],
1076
+ children: /*#__PURE__*/_jsx(Text, {
1077
+ style: [styles.tipIconText, {
1078
+ color: theme.primaryColor
1079
+ }],
1080
+ children: idx + 1
1081
+ })
1082
+ }), /*#__PURE__*/_jsx(Text, {
1083
+ style: [styles.tipText, {
1084
+ color: theme.textColor
1085
+ }],
1086
+ children: tip
1087
+ })]
1088
+ }, idx))
1089
+ }), bannerError ? /*#__PURE__*/_jsx(Banner, {
1090
+ message: bannerError
1091
+ }) : null, /*#__PURE__*/_jsxs(View, {
1092
+ style: styles.introActions,
1093
+ children: [showBackButton ? /*#__PURE__*/_jsx(Button, {
1094
+ variant: "ghost",
1095
+ label: t.liveness.introBack,
1096
+ onPress: () => onCancel({
1097
+ code: SdkErrorCode.LIVENESS_FAILED,
1098
+ message: 'User exited the liveness intro.'
1099
+ }),
1100
+ fullWidth: false,
1101
+ style: styles.introBtn
1102
+ }) : null, /*#__PURE__*/_jsx(Button, {
1103
+ label: t.liveness.introStart,
1104
+ onPress: () => setPhase('capturing'),
1105
+ fullWidth: !showBackButton,
1106
+ style: showBackButton ? styles.introBtn : undefined
1107
+ })]
1108
+ })]
1109
+ })
1110
+ });
1111
+ }
1112
+ if (phase === 'finalizing') {
1113
+ return /*#__PURE__*/_jsx(AnalyzingOverlay, {
1114
+ headline: t.liveness.analyzingHeadline,
1115
+ caption: t.liveness.analyzingCaption
1116
+ });
1117
+ }
1118
+ return /*#__PURE__*/_jsx(View, {
1119
+ style: {
1120
+ flex: 1
1121
+ },
1122
+ children: /*#__PURE__*/_jsx(LivenessCamera, {
1123
+ ref: cameraRef,
1124
+ statusText: statusText,
1125
+ challengeText: challengeText,
1126
+ ovalCue: ovalCue,
1127
+ toast: toast,
1128
+ progress: progress,
1129
+ permissionDeniedLabel: t.liveness.cameraPermissionDenied,
1130
+ retryLabel: t.liveness.cameraTryAgain,
1131
+ cancelLabel: t.common.cancel
1132
+ // Intentionally no onCancel during capture. The capture screen is
1133
+ // meant to be fullscreen and uninterruptible — if the user wants
1134
+ // out, the 25 s progress watchdog catches stalled sessions and
1135
+ // routes them through the RetryDialog (with its own Cancel option).
1136
+ // The intro screen keeps the explicit "Atrás" button.
1137
+ })
1138
+ });
1139
+ }
1140
+ const styles = StyleSheet.create({
1141
+ tipsList: {
1142
+ paddingVertical: 4,
1143
+ gap: 10
1144
+ },
1145
+ tipRow: {
1146
+ flexDirection: 'row',
1147
+ alignItems: 'center',
1148
+ gap: 12,
1149
+ padding: 12,
1150
+ borderWidth: 1
1151
+ },
1152
+ tipIcon: {
1153
+ width: 32,
1154
+ height: 32,
1155
+ borderRadius: 16,
1156
+ alignItems: 'center',
1157
+ justifyContent: 'center'
1158
+ },
1159
+ tipIconText: {
1160
+ fontSize: 14,
1161
+ fontWeight: '700'
1162
+ },
1163
+ tipText: {
1164
+ flex: 1,
1165
+ fontSize: 14,
1166
+ lineHeight: 20
1167
+ },
1168
+ introActions: {
1169
+ flexDirection: 'row',
1170
+ gap: 10,
1171
+ marginTop: 6
1172
+ },
1173
+ introBtn: {
1174
+ flex: 1
1175
+ }
1176
+ });
1177
+ //# sourceMappingURL=LivenessMatchStep.js.map