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