@trustchex/react-native-sdk 1.355.1 → 1.357.0

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 (254) hide show
  1. package/README.md +2 -9
  2. package/TrustchexSDK.podspec +5 -4
  3. package/android/build.gradle +6 -4
  4. package/android/src/main/AndroidManifest.xml +1 -1
  5. package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +45 -25
  6. package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraManager.kt +168 -0
  7. package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +871 -0
  8. package/android/src/main/java/com/trustchex/reactnativesdk/mlkit/MLKitModule.kt +245 -0
  9. package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidationModule.kt +785 -0
  10. package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidator.kt +419 -0
  11. package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +818 -0
  12. package/ios/Camera/TrustchexCameraManager.m +37 -0
  13. package/ios/Camera/TrustchexCameraManager.swift +125 -0
  14. package/ios/Camera/TrustchexCameraView.swift +1176 -0
  15. package/ios/MLKit/MLKitModule.m +23 -0
  16. package/ios/MLKit/MLKitModule.swift +250 -0
  17. package/ios/MRZValidation.m +39 -0
  18. package/ios/MRZValidation.swift +802 -0
  19. package/ios/MRZValidator.swift +466 -0
  20. package/ios/OpenCV/OpenCVModule.h +4 -0
  21. package/ios/OpenCV/OpenCVModule.mm +810 -0
  22. package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +2 -3
  23. package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +1 -2
  24. package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +418 -193
  25. package/lib/module/Screens/Static/OTPVerificationScreen.js +11 -11
  26. package/lib/module/Screens/Static/QrCodeScanningScreen.js +5 -1
  27. package/lib/module/Screens/Static/ResultScreen.js +25 -2
  28. package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +25 -7
  29. package/lib/module/Shared/Components/DebugNavigationPanel.js +234 -24
  30. package/lib/module/Shared/Components/EIDScanner.js +99 -9
  31. package/lib/module/Shared/Components/FaceCamera.js +170 -179
  32. package/lib/module/Shared/Components/IdentityDocumentCamera.js +2151 -771
  33. package/lib/module/Shared/Components/QrCodeScannerCamera.js +109 -107
  34. package/lib/module/Shared/Components/TrustchexCamera.js +122 -0
  35. package/lib/module/Shared/EIDReader/tlv/tlv.helpers.js +91 -0
  36. package/lib/module/Shared/EIDReader/tlv/tlv.utils.js +2 -124
  37. package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
  38. package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
  39. package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +4 -4
  40. package/lib/module/Shared/Libs/analytics.utils.js +2 -2
  41. package/lib/module/Shared/Libs/debug.utils.js +132 -0
  42. package/lib/module/Shared/Libs/deeplink.utils.js +6 -5
  43. package/lib/module/Shared/Libs/demo.utils.js +13 -3
  44. package/lib/module/Shared/Libs/mrz.utils.js +1 -175
  45. package/lib/module/Shared/Libs/native-device-info.utils.js +12 -6
  46. package/lib/module/Shared/Libs/tts.utils.js +40 -6
  47. package/lib/module/Shared/Services/AnalyticsService.js +9 -8
  48. package/lib/module/Shared/Types/mrzFields.js +1 -0
  49. package/lib/module/Translation/Resources/en.js +87 -88
  50. package/lib/module/Translation/Resources/tr.js +84 -85
  51. package/lib/module/Trustchex.js +9 -2
  52. package/lib/module/index.js +1 -0
  53. package/lib/module/version.js +1 -1
  54. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
  55. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
  56. package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
  57. package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts.map +1 -1
  58. package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
  59. package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
  60. package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
  61. package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts.map +1 -1
  62. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts +2 -2
  63. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
  64. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +18 -4
  65. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
  66. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -4
  67. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
  68. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts +2 -1
  69. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
  70. package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts +124 -0
  71. package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts.map +1 -0
  72. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts +11 -0
  73. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts.map +1 -0
  74. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts +2 -39
  75. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts.map +1 -1
  76. package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -1
  77. package/lib/typescript/src/Shared/Libs/debug.utils.d.ts +42 -0
  78. package/lib/typescript/src/Shared/Libs/debug.utils.d.ts.map +1 -0
  79. package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
  80. package/lib/typescript/src/Shared/Libs/demo.utils.d.ts.map +1 -1
  81. package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
  82. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +0 -4
  83. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
  84. package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts.map +1 -1
  85. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts +4 -3
  86. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts.map +1 -1
  87. package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -1
  88. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts +2 -2
  89. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts.map +1 -1
  90. package/lib/typescript/src/Shared/Types/mrzFields.d.ts +11 -0
  91. package/lib/typescript/src/Shared/Types/mrzFields.d.ts.map +1 -0
  92. package/lib/typescript/src/Translation/Resources/en.d.ts +4 -5
  93. package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
  94. package/lib/typescript/src/Translation/Resources/tr.d.ts +4 -5
  95. package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
  96. package/lib/typescript/src/Trustchex.d.ts +2 -0
  97. package/lib/typescript/src/Trustchex.d.ts.map +1 -1
  98. package/lib/typescript/src/index.d.ts +1 -0
  99. package/lib/typescript/src/index.d.ts.map +1 -1
  100. package/lib/typescript/src/version.d.ts +1 -1
  101. package/package.json +4 -35
  102. package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +1 -1
  103. package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +7 -5
  104. package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +2 -3
  105. package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +498 -216
  106. package/src/Screens/Static/OTPVerificationScreen.tsx +37 -31
  107. package/src/Screens/Static/QrCodeScanningScreen.tsx +8 -1
  108. package/src/Screens/Static/ResultScreen.tsx +136 -88
  109. package/src/Screens/Static/VerificationSessionCheckScreen.tsx +46 -13
  110. package/src/Shared/Components/DebugNavigationPanel.tsx +290 -34
  111. package/src/Shared/Components/EIDScanner.tsx +94 -16
  112. package/src/Shared/Components/FaceCamera.tsx +236 -203
  113. package/src/Shared/Components/IdentityDocumentCamera.tsx +3073 -1030
  114. package/src/Shared/Components/QrCodeScannerCamera.tsx +133 -127
  115. package/src/Shared/Components/TrustchexCamera.tsx +289 -0
  116. package/src/Shared/Config/camera-enhancement.config.ts +2 -2
  117. package/src/Shared/EIDReader/tlv/tlv.helpers.ts +96 -0
  118. package/src/Shared/EIDReader/tlv/tlv.utils.ts +2 -125
  119. package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
  120. package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
  121. package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +4 -4
  122. package/src/Shared/Libs/analytics.utils.ts +48 -20
  123. package/src/Shared/Libs/debug.utils.ts +149 -0
  124. package/src/Shared/Libs/deeplink.utils.ts +7 -5
  125. package/src/Shared/Libs/demo.utils.ts +4 -0
  126. package/src/Shared/Libs/http-client.ts +12 -8
  127. package/src/Shared/Libs/mrz.utils.ts +1 -163
  128. package/src/Shared/Libs/native-device-info.utils.ts +12 -6
  129. package/src/Shared/Libs/tts.utils.ts +48 -6
  130. package/src/Shared/Services/AnalyticsService.ts +69 -24
  131. package/src/Shared/Types/identificationInfo.ts +2 -2
  132. package/src/Shared/Types/mrzFields.ts +29 -0
  133. package/src/Translation/Resources/en.ts +90 -100
  134. package/src/Translation/Resources/tr.ts +89 -97
  135. package/src/Translation/index.ts +1 -1
  136. package/src/Trustchex.tsx +21 -4
  137. package/src/index.tsx +14 -0
  138. package/src/version.ts +1 -1
  139. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/barcodescanner/BarcodeScannerFrameProcessorPlugin.kt +0 -301
  140. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/BitmapUtils.kt +0 -205
  141. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/CropperPlugin.kt +0 -72
  142. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/FrameMetadata.kt +0 -4
  143. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/facedetector/FaceDetectorFrameProcessorPlugin.kt +0 -303
  144. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/textrecognition/TextRecognitionFrameProcessorPlugin.kt +0 -115
  145. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +0 -9
  146. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.mm +0 -22
  147. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +0 -188
  148. package/ios/VisionCameraPlugins/Cropper/Cropper-Bridging-Header.h +0 -13
  149. package/ios/VisionCameraPlugins/Cropper/Cropper.h +0 -20
  150. package/ios/VisionCameraPlugins/Cropper/Cropper.mm +0 -22
  151. package/ios/VisionCameraPlugins/Cropper/Cropper.swift +0 -145
  152. package/ios/VisionCameraPlugins/Cropper/CropperUtils.swift +0 -49
  153. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin-Bridging-Header.h +0 -4
  154. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.mm +0 -22
  155. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.swift +0 -320
  156. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin-Bridging-Header.h +0 -4
  157. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.mm +0 -27
  158. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.swift +0 -144
  159. package/lib/module/Shared/Libs/camera.utils.js +0 -308
  160. package/lib/module/Shared/Libs/frame-enhancement.utils.js +0 -133
  161. package/lib/module/Shared/Libs/opencv.utils.js +0 -21
  162. package/lib/module/Shared/Libs/worklet.utils.js +0 -68
  163. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.js +0 -46
  164. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +0 -35
  165. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -19
  166. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +0 -26
  167. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/types.js +0 -3
  168. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.js +0 -197
  169. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.js +0 -101
  170. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.js +0 -60
  171. package/lib/module/Shared/VisionCameraPlugins/Cropper/index.js +0 -47
  172. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/Camera.js +0 -42
  173. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/detectFaces.js +0 -35
  174. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/index.js +0 -4
  175. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/types.js +0 -3
  176. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/Camera.js +0 -56
  177. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.js +0 -20
  178. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.js +0 -9
  179. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/index.js +0 -6
  180. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/scanText.js +0 -20
  181. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/translateText.js +0 -19
  182. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/types.js +0 -3
  183. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +0 -87
  184. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +0 -1
  185. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts +0 -25
  186. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts.map +0 -1
  187. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts +0 -3
  188. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts.map +0 -1
  189. package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts +0 -9
  190. package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts.map +0 -1
  191. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts +0 -13
  192. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts.map +0 -1
  193. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts +0 -6
  194. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +0 -1
  195. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -12
  196. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +0 -1
  197. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts +0 -3
  198. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +0 -1
  199. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts +0 -52
  200. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts.map +0 -1
  201. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts +0 -62
  202. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts.map +0 -1
  203. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts +0 -34
  204. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts.map +0 -1
  205. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts +0 -32
  206. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts.map +0 -1
  207. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts +0 -23
  208. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts.map +0 -1
  209. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts +0 -9
  210. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts.map +0 -1
  211. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts +0 -3
  212. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts.map +0 -1
  213. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts +0 -3
  214. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts.map +0 -1
  215. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts +0 -79
  216. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts.map +0 -1
  217. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts +0 -6
  218. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts.map +0 -1
  219. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts +0 -3
  220. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map +0 -1
  221. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts +0 -3
  222. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map +0 -1
  223. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts +0 -5
  224. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts.map +0 -1
  225. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts +0 -3
  226. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts.map +0 -1
  227. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts +0 -3
  228. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map +0 -1
  229. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts +0 -67
  230. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts.map +0 -1
  231. package/src/Shared/Libs/camera.utils.ts +0 -345
  232. package/src/Shared/Libs/frame-enhancement.utils.ts +0 -217
  233. package/src/Shared/Libs/opencv.utils.ts +0 -40
  234. package/src/Shared/Libs/worklet.utils.ts +0 -72
  235. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.ts +0 -79
  236. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +0 -46
  237. package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -60
  238. package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +0 -32
  239. package/src/Shared/VisionCameraPlugins/BarcodeScanner/types.ts +0 -82
  240. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.ts +0 -195
  241. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.ts +0 -135
  242. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.ts +0 -84
  243. package/src/Shared/VisionCameraPlugins/Cropper/index.ts +0 -78
  244. package/src/Shared/VisionCameraPlugins/FaceDetector/Camera.tsx +0 -63
  245. package/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.ts +0 -44
  246. package/src/Shared/VisionCameraPlugins/FaceDetector/index.ts +0 -3
  247. package/src/Shared/VisionCameraPlugins/FaceDetector/types.ts +0 -99
  248. package/src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx +0 -76
  249. package/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts +0 -18
  250. package/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts +0 -7
  251. package/src/Shared/VisionCameraPlugins/TextRecognition/index.ts +0 -7
  252. package/src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts +0 -27
  253. package/src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts +0 -21
  254. package/src/Shared/VisionCameraPlugins/TextRecognition/types.ts +0 -141
@@ -1,46 +1,60 @@
1
1
  import { useIsFocused } from '@react-navigation/native';
2
2
  import { useKeepAwake } from '../Libs/native-keep-awake.utils';
3
- import React, { useEffect, useState, useMemo } from 'react';
3
+ import { debugLog, debugWarn, debugError, logError } from '../Libs/debug.utils';
4
+ import React, { useEffect, useState, useRef, useCallback } from 'react';
4
5
  import {
5
6
  StyleSheet,
6
7
  Text,
7
8
  View,
8
9
  Platform,
9
10
  Linking,
10
- Dimensions,
11
11
  ActivityIndicator,
12
12
  NativeModules,
13
+ PermissionsAndroid,
14
+ type NativeSyntheticEvent,
13
15
  } from 'react-native';
14
16
  import {
15
- useCameraDevice,
16
- useCameraPermission,
17
- Camera,
18
- useFrameProcessor,
19
- useCameraFormat,
20
- runAtTargetFps,
21
- useMicrophonePermission,
22
- } from 'react-native-vision-camera';
23
- import type { Frame } from 'react-native-vision-camera';
24
- import { runAsync } from '../Libs/worklet.utils';
25
- import {
26
- type Face,
27
- useFaceDetector,
28
- } from '../VisionCameraPlugins/FaceDetector';
29
- import { Worklets, useSharedValue } from 'react-native-worklets-core';
30
- import { crop } from '../VisionCameraPlugins/Cropper';
31
- import { isCircularRegionBright, isBlurry } from '../Libs/camera.utils';
17
+ TrustchexCamera,
18
+ type TrustchexCameraHandle,
19
+ type Frame,
20
+ } from './TrustchexCamera';
32
21
  import { useTranslation } from 'react-i18next';
33
22
  import StyledButton from './StyledButton';
34
23
  import { useTheme } from '../Contexts/ThemeContext';
35
24
  import { SafeAreaView } from 'react-native-safe-area-context';
25
+ import { Dimensions } from 'react-native';
26
+
27
+ const { width: windowWidth, height: windowHeight } = Dimensions.get('window');
28
+ const { OpenCVModule } = NativeModules;
29
+ const MIN_BRIGHTNESS_THRESHOLD = 80;
30
+ const BLUR_VARIANCE_THRESHOLD = 60;
31
+ const REGION_BRIGHTNESS_THRESHOLD = 70;
32
+
33
+ export type Face = {
34
+ bounds: {
35
+ x: number;
36
+ y: number;
37
+ width: number;
38
+ height: number;
39
+ };
40
+ yawAngle: number;
41
+ pitchAngle: number;
42
+ rollAngle: number;
43
+ trackingId?: number;
44
+ smilingProbability: number;
45
+ leftEyeOpenProbability: number;
46
+ rightEyeOpenProbability: number;
47
+ };
36
48
 
37
49
  export type FaceCameraProps = {
38
50
  onFacesDetected: (
39
51
  faces: Face[],
40
52
  image: string,
41
- isImageBright: boolean
53
+ isImageBright: boolean,
54
+ frameWidth: number,
55
+ frameHeight: number
42
56
  ) => void;
43
- onCameraInitialized: (camera: Camera) => void;
57
+ onCameraInitialized: (camera: TrustchexCameraHandle) => void;
44
58
  previewRect?: {
45
59
  minX: number;
46
60
  minY: number;
@@ -49,12 +63,6 @@ export type FaceCameraProps = {
49
63
  };
50
64
  };
51
65
 
52
- const VIDEO_WIDTH = 1280;
53
- const VIDEO_HEIGHT = 720;
54
-
55
- const windowWidth = Dimensions.get('window').width;
56
- const windowHeight = Dimensions.get('window').height;
57
-
58
66
  const FaceCamera = ({
59
67
  onFacesDetected,
60
68
  onCameraInitialized,
@@ -62,65 +70,38 @@ const FaceCamera = ({
62
70
  }: FaceCameraProps) => {
63
71
  useKeepAwake();
64
72
  const theme = useTheme();
65
- const cameraPermission = useCameraPermission();
66
- const microphonePermission = useMicrophonePermission();
73
+ const [hasPermission, setHasPermission] = useState(false);
67
74
  const [permissionsRequested, setPermissionsRequested] = useState(false);
68
- const cameraRef = React.useRef<Camera | null>(null);
75
+ const cameraRef = useRef<TrustchexCameraHandle>(null);
69
76
  const isFocused = useIsFocused();
70
77
  const [isActive, setIsActive] = useState(false);
71
- const device = useCameraDevice('front');
72
- const format = useCameraFormat(device, [
73
- {
74
- videoResolution: { width: VIDEO_WIDTH, height: VIDEO_HEIGHT },
75
- iso: 'max',
76
- photoHdr: false,
77
- videoHdr: false,
78
- fps: 30,
79
- },
80
- ]);
81
- const isCameraInitialized = useSharedValue(false);
82
-
83
- const faceDetectorOptions = useMemo(
84
- () => ({
85
- contourMode: 'none' as const,
86
- landmarkMode: 'none' as const,
87
- classificationMode: 'all' as const,
88
- performanceMode: 'accurate' as const,
89
- trackingEnabled: false,
90
- autoScale: true,
91
- windowWidth: windowWidth,
92
- windowHeight: windowHeight,
93
- }),
94
- [windowWidth, windowHeight]
95
- );
96
-
97
- const { detectFaces } = useFaceDetector(faceDetectorOptions);
78
+ const isCameraInitializedRef = useRef(false);
79
+ const lastFrameTimeRef = useRef(0);
98
80
  const { t } = useTranslation();
99
81
 
100
82
  useEffect(() => {
101
83
  const requestPermissions = async () => {
102
- if (!cameraPermission.hasPermission) {
103
- await cameraPermission.requestPermission();
104
- }
105
- if (!microphonePermission.hasPermission) {
106
- await microphonePermission.requestPermission();
84
+ if (Platform.OS === 'android') {
85
+ const granted = await PermissionsAndroid.request(
86
+ PermissionsAndroid.PERMISSIONS.CAMERA
87
+ );
88
+ setHasPermission(granted === PermissionsAndroid.RESULTS.GRANTED);
89
+ } else {
90
+ // iOS permissions handled by native camera
91
+ setHasPermission(true);
107
92
  }
108
93
  setPermissionsRequested(true);
109
94
  };
110
95
  requestPermissions();
111
- }, [cameraPermission, microphonePermission]);
112
-
113
- const handleFaces = Worklets.createRunOnJS(
114
- (faces: Face[], image: string, isBright: boolean) => {
115
- if (faces.length > 0) {
116
- console.log('[FaceCamera] handleFaces called - faces:', faces.length, 'bright:', isBright);
117
- onFacesDetected(faces, image, isBright);
118
- }
119
- }
120
- );
96
+ }, []);
121
97
 
122
98
  useEffect(() => {
123
- if (!!device && !!format && isFocused) {
99
+ debugLog('FaceCamera', 'isActive state changed:', {
100
+ isFocused,
101
+ hasPermission,
102
+ isActive: isFocused && hasPermission,
103
+ });
104
+ if (isFocused && hasPermission) {
124
105
  setIsActive(true);
125
106
  } else {
126
107
  setIsActive(false);
@@ -129,7 +110,7 @@ const FaceCamera = ({
129
110
  return () => {
130
111
  setIsActive(false);
131
112
  };
132
- }, [device, format, isFocused]);
113
+ }, [isFocused, hasPermission]);
133
114
 
134
115
  // Set screen brightness to maximum when camera is active
135
116
  useEffect(() => {
@@ -142,9 +123,13 @@ const FaceCamera = ({
142
123
  if (isActive) {
143
124
  try {
144
125
  originalBrightness = await DeviceBrightness.getBrightness();
145
- await DeviceBrightness.setBrightness(1.0);
126
+ await DeviceBrightness.setBrightness(1);
146
127
  } catch (error) {
147
- console.log('Failed to set brightness:', error);
128
+ debugLog(
129
+ 'FaceCamera',
130
+ '[FaceCamera] Failed to set brightness:',
131
+ error
132
+ );
148
133
  }
149
134
  }
150
135
  };
@@ -153,103 +138,178 @@ const FaceCamera = ({
153
138
 
154
139
  return () => {
155
140
  if (originalBrightness >= 0) {
156
- DeviceBrightness.setBrightness(originalBrightness).catch(() => { });
141
+ DeviceBrightness.setBrightness(originalBrightness).catch(() => {});
157
142
  }
158
143
  };
159
144
  }, [isActive]);
160
145
 
161
- const handleWorklet = (frame: Frame) => {
162
- 'worklet';
163
- try {
164
- // Calculate brightness based on the circular preview area if provided
165
- // Otherwise fall back to entire frame brightness
166
- let isBright = false;
167
- if (previewRect) {
168
- // Convert preview rect from screen coordinates to frame coordinates
169
- const scaleX = frame.width / windowWidth;
170
- const scaleY = frame.height / windowHeight;
171
- const frameCircleRect = {
172
- minX: Math.floor(previewRect.minX * scaleX),
173
- minY: Math.floor(previewRect.minY * scaleY),
174
- width: Math.floor(previewRect.width * scaleX),
175
- height: Math.floor(previewRect.height * scaleY),
176
- };
177
- isBright = isCircularRegionBright(frame, frameCircleRect, 60);
178
- } else {
179
- // Fallback: check entire frame brightness (use legacy method)
180
- const buffer = frame.toArrayBuffer();
181
- const data = new Uint8Array(buffer);
182
- const width = frame.width;
183
- const height = frame.height;
184
- let luminanceSum = 0;
185
- let pixelCount = 0;
186
- const centerX = Math.floor(width / 2);
187
- const centerY = Math.floor(height / 2);
188
- const halfSizeX = Math.floor(width / 2);
189
- const halfSizeY = Math.floor(height / 2);
190
-
191
- for (let y = centerY - halfSizeY; y < centerY + halfSizeY; y++) {
192
- for (let x = centerX - halfSizeX; x < centerX + halfSizeX; x++) {
193
- const index = y * width + x;
194
- if (data[index] !== undefined) {
195
- luminanceSum += data[index];
196
- pixelCount++;
197
- }
198
- }
199
- }
200
- isBright = (luminanceSum / pixelCount) > 60;
201
- }
146
+ const isProcessingFrame = useRef(false);
202
147
 
203
- // Skip blurry frames to ensure sharp face captures
204
- // Lower threshold (10) for better frame acceptance
205
- if (isBlurry(frame, 10)) {
148
+ const handleFrame = useCallback(
149
+ async (event: NativeSyntheticEvent<{ frame: Frame }>) => {
150
+ debugLog('FaceCamera', '*** FRAME CALLBACK INVOKED ***', {
151
+ isProcessing: isProcessingFrame.current,
152
+ timestamp: Date.now(),
153
+ });
154
+
155
+ if (isProcessingFrame.current) {
156
+ debugLog('FaceCamera', 'Frame dropped - already processing');
206
157
  return;
207
158
  }
208
159
 
209
- const image = crop(frame, {
210
- cropRegion: {
211
- top: 0,
212
- left: 0,
213
- width: 100,
214
- height: 100,
215
- },
216
- includeImageBase64: true,
217
- saveAsFile: false,
218
- });
160
+ const now = Date.now();
161
+ const timeSinceLastFrame = now - lastFrameTimeRef.current;
162
+ // Throttle to ~6.7 FPS for face scanning (150ms interval matches Flutter SDK for responsive detection)
163
+ if (timeSinceLastFrame < 150) {
164
+ debugLog(
165
+ 'FaceCamera',
166
+ `Frame dropped - throttling (${timeSinceLastFrame}ms < 150ms)`
167
+ );
168
+ return;
169
+ }
170
+ lastFrameTimeRef.current = now;
219
171
 
220
- if (image && image.base64) {
221
- const faces = detectFaces(frame);
222
- if (faces.length > 0) {
223
- console.log('[FaceCamera] Faces detected:', faces.length);
224
- }
225
- handleFaces(faces, image.base64, isBright);
172
+ if (!isCameraInitializedRef.current) {
173
+ debugLog('FaceCamera', 'Camera not initialized yet');
174
+ return;
226
175
  }
227
- } catch (error) {
228
- console.error('[FaceCamera] Face detection error:', error);
229
- }
230
- };
231
176
 
232
- const frameProcessor = useFrameProcessor(
233
- (frame) => {
234
- 'worklet';
235
- if (!isCameraInitialized.value) {
177
+ if (!isActive) {
178
+ debugLog('FaceCamera', 'Camera not active');
236
179
  return;
237
180
  }
238
- // iOS: Run at target 6 FPS using runAtTargetFps
239
- if (Platform.OS === 'ios') {
240
- runAtTargetFps(6, () => {
241
- 'worklet';
242
- handleWorklet(frame);
243
- });
244
- } else {
245
- // Android: Run async without throttling
246
- runAsync(frame, () => {
247
- 'worklet';
248
- handleWorklet(frame);
249
- });
181
+
182
+ isProcessingFrame.current = true;
183
+ const { frame } = event.nativeEvent;
184
+
185
+ try {
186
+ if (
187
+ !frame.width ||
188
+ !frame.height ||
189
+ frame.width <= 0 ||
190
+ frame.height <= 0
191
+ ) {
192
+ debugLog('FaceCamera', 'Invalid frame dimensions');
193
+ return;
194
+ }
195
+
196
+ const base64Image = frame.base64Image ?? '';
197
+
198
+ // Read faces directly from native ML Kit results
199
+ const nativeFaces = frame.faces ?? [];
200
+ debugLog('FaceCamera', 'Native faces:', nativeFaces.length);
201
+
202
+ // Map NativeFace to FaceCamera's Face type first
203
+ // ML Kit classification probabilities may be undefined if detection fails
204
+ // Default to 0 so comparisons don't fail with undefined
205
+ const faces: Face[] = nativeFaces.map((f) => ({
206
+ bounds: {
207
+ x: f.bounds.x,
208
+ y: f.bounds.y,
209
+ width: f.bounds.width,
210
+ height: f.bounds.height,
211
+ },
212
+ yawAngle: f.yawAngle ?? 0,
213
+ pitchAngle: f.pitchAngle ?? 0,
214
+ rollAngle: f.rollAngle ?? 0,
215
+ smilingProbability: f.smilingProbability ?? 0,
216
+ leftEyeOpenProbability: f.leftEyeOpenProbability ?? 0,
217
+ rightEyeOpenProbability: f.rightEyeOpenProbability ?? 0,
218
+ }));
219
+
220
+ // Check overall brightness - computed natively on the Y plane
221
+ const avgBrightness = frame.brightness ?? 128;
222
+ const isBright = avgBrightness >= MIN_BRIGHTNESS_THRESHOLD;
223
+
224
+ // Check brightness in the region of interest (circular preview area)
225
+ let isRegionBright = isBright; // Default to overall brightness
226
+ if (previewRect && base64Image && OpenCVModule) {
227
+ try {
228
+ // Scale preview rect from screen coordinates to frame coordinates
229
+ const scaleX = frame.width / windowWidth;
230
+ const scaleY = frame.height / windowHeight;
231
+ const regionMinX = Math.round(previewRect.minX * scaleX);
232
+ const regionMinY = Math.round(previewRect.minY * scaleY);
233
+ const regionWidth = Math.round(previewRect.width * scaleX);
234
+ const regionHeight = Math.round(previewRect.height * scaleY);
235
+
236
+ isRegionBright = await OpenCVModule.isCircularRegionBright(
237
+ base64Image,
238
+ regionMinX,
239
+ regionMinY,
240
+ regionWidth,
241
+ regionHeight,
242
+ REGION_BRIGHTNESS_THRESHOLD
243
+ );
244
+ } catch (error) {
245
+ debugWarn('FaceCamera', 'Region brightness check failed:', error);
246
+ }
247
+ }
248
+
249
+ // Check for blur using OpenCV Laplacian variance
250
+ let isNotBlurry = true;
251
+ try {
252
+ if (base64Image && OpenCVModule) {
253
+ const isBlurryResult = await OpenCVModule.checkBlurry(
254
+ base64Image,
255
+ BLUR_VARIANCE_THRESHOLD
256
+ );
257
+ isNotBlurry = !isBlurryResult;
258
+ }
259
+ } catch (error) {
260
+ debugWarn('FaceCamera', 'Blur check failed:', error);
261
+ // If check fails, assume not blurry to continue
262
+ }
263
+
264
+ // Check quality but still pass detected faces
265
+ // Let liveness detection logic decide whether to accept poor quality frames
266
+ const hasGoodQuality = isRegionBright && isNotBlurry;
267
+ if (!hasGoodQuality) {
268
+ debugLog('FaceCamera', 'Frame quality insufficient:', {
269
+ avgBrightness,
270
+ isBright,
271
+ isRegionBright,
272
+ isNotBlurry,
273
+ faceCount: faces.length,
274
+ });
275
+ }
276
+
277
+ debugLog(
278
+ 'FaceCamera',
279
+ `Calling onFacesDetected with ${faces.length} faces`
280
+ );
281
+ // Always call onFacesDetected with detected faces
282
+ // isRegionBright indicates whether the region of interest has acceptable brightness
283
+ // This allows the UI to show warnings while still detecting faces
284
+ onFacesDetected(
285
+ faces,
286
+ base64Image,
287
+ isRegionBright,
288
+ frame.width,
289
+ frame.height
290
+ );
291
+ } catch (error: any) {
292
+ debugError('FaceCamera', 'Face detection error:', error);
293
+ } finally {
294
+ isProcessingFrame.current = false;
250
295
  }
251
296
  },
252
- [handleFaces, isCameraInitialized]
297
+ [isActive, previewRect, onFacesDetected]
298
+ );
299
+
300
+ const handleCameraReady = useCallback(() => {
301
+ debugLog('FaceCamera', 'Camera ready, initializing...');
302
+ isCameraInitializedRef.current = true;
303
+ if (cameraRef.current) {
304
+ onCameraInitialized(cameraRef.current);
305
+ }
306
+ }, [onCameraInitialized]);
307
+
308
+ const handleCameraError = useCallback(
309
+ (event: NativeSyntheticEvent<{ error: string }>) => {
310
+ logError('[FaceCamera] Camera error:', event.nativeEvent.error);
311
+ },
312
+ []
253
313
  );
254
314
 
255
315
  if (!permissionsRequested) {
@@ -260,8 +320,7 @@ const FaceCamera = ({
260
320
  );
261
321
  }
262
322
 
263
- if (!cameraPermission.hasPermission) {
264
- // Camera permission denied by user - their choice, not actionable
323
+ if (!hasPermission) {
265
324
  return (
266
325
  <SafeAreaView style={styles.permissionContainer}>
267
326
  <Text style={styles.permissionText}>
@@ -279,54 +338,28 @@ const FaceCamera = ({
279
338
  );
280
339
  }
281
340
 
282
- if (!microphonePermission.hasPermission) {
283
- // Microphone permission denied by user - their choice, not actionable
284
- return (
285
- <SafeAreaView style={styles.permissionContainer}>
286
- <Text style={styles.permissionText}>
287
- {t('general.noMicrophonePermissionGiven')}
288
- </Text>
289
- <StyledButton
290
- mode="contained"
291
- onPress={() => {
292
- Linking.openSettings();
293
- }}
294
- >
295
- {t('general.openSettings')}
296
- </StyledButton>
297
- </SafeAreaView>
298
- );
299
- }
300
-
301
- if (device == null) {
302
- // No camera device - device limitation, not actionable
303
- return (
304
- <SafeAreaView style={styles.permissionContainer}>
305
- <Text style={styles.permissionText}>
306
- {t('general.noCameraDetected')}
307
- </Text>
308
- </SafeAreaView>
309
- );
310
- }
341
+ debugLog('FaceCamera', 'Rendering TrustchexCamera with props:', {
342
+ isActive,
343
+ enableFrameProcessing: isActive,
344
+ enableFaceDetection: isActive,
345
+ includeBase64: true,
346
+ targetFps: 10,
347
+ });
311
348
 
312
349
  return (
313
350
  <View style={StyleSheet.absoluteFill}>
314
- <Camera
351
+ <TrustchexCamera
315
352
  ref={cameraRef}
316
- frameProcessor={frameProcessor}
317
353
  style={StyleSheet.absoluteFill}
318
- device={device}
319
- format={format}
320
- isActive={isActive}
321
- video={true}
322
- photo={false}
323
- audio={true}
324
- videoBitRate={'extra-low'}
325
- fps={Math.max(format?.minFps ?? 0, 30)}
326
- onInitialized={() => {
327
- isCameraInitialized.value = true;
328
- onCameraInitialized(cameraRef.current!);
329
- }}
354
+ cameraType="front"
355
+ torchEnabled={false}
356
+ enableFrameProcessing={isActive}
357
+ enableFaceDetection={isActive}
358
+ includeBase64={true} // Enabled to capture photos for liveness steps
359
+ targetFps={5}
360
+ onFrameAvailable={handleFrame}
361
+ onCameraReady={handleCameraReady}
362
+ onCameraError={handleCameraError}
330
363
  />
331
364
  </View>
332
365
  );