@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.
- package/README.md +2 -9
- package/TrustchexSDK.podspec +5 -4
- package/android/build.gradle +6 -4
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +45 -25
- package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraManager.kt +168 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +871 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mlkit/MLKitModule.kt +245 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidationModule.kt +785 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidator.kt +419 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +818 -0
- package/ios/Camera/TrustchexCameraManager.m +37 -0
- package/ios/Camera/TrustchexCameraManager.swift +125 -0
- package/ios/Camera/TrustchexCameraView.swift +1176 -0
- package/ios/MLKit/MLKitModule.m +23 -0
- package/ios/MLKit/MLKitModule.swift +250 -0
- package/ios/MRZValidation.m +39 -0
- package/ios/MRZValidation.swift +802 -0
- package/ios/MRZValidator.swift +466 -0
- package/ios/OpenCV/OpenCVModule.h +4 -0
- package/ios/OpenCV/OpenCVModule.mm +810 -0
- package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +2 -3
- package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +1 -2
- package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +418 -193
- package/lib/module/Screens/Static/OTPVerificationScreen.js +11 -11
- package/lib/module/Screens/Static/QrCodeScanningScreen.js +5 -1
- package/lib/module/Screens/Static/ResultScreen.js +25 -2
- package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +25 -7
- package/lib/module/Shared/Components/DebugNavigationPanel.js +234 -24
- package/lib/module/Shared/Components/EIDScanner.js +99 -9
- package/lib/module/Shared/Components/FaceCamera.js +170 -179
- package/lib/module/Shared/Components/IdentityDocumentCamera.js +2151 -771
- package/lib/module/Shared/Components/QrCodeScannerCamera.js +109 -107
- package/lib/module/Shared/Components/TrustchexCamera.js +122 -0
- package/lib/module/Shared/EIDReader/tlv/tlv.helpers.js +91 -0
- package/lib/module/Shared/EIDReader/tlv/tlv.utils.js +2 -124
- package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +4 -4
- package/lib/module/Shared/Libs/analytics.utils.js +2 -2
- package/lib/module/Shared/Libs/debug.utils.js +132 -0
- package/lib/module/Shared/Libs/deeplink.utils.js +6 -5
- package/lib/module/Shared/Libs/demo.utils.js +13 -3
- package/lib/module/Shared/Libs/mrz.utils.js +1 -175
- package/lib/module/Shared/Libs/native-device-info.utils.js +12 -6
- package/lib/module/Shared/Libs/tts.utils.js +40 -6
- package/lib/module/Shared/Services/AnalyticsService.js +9 -8
- package/lib/module/Shared/Types/mrzFields.js +1 -0
- package/lib/module/Translation/Resources/en.js +87 -88
- package/lib/module/Translation/Resources/tr.js +84 -85
- package/lib/module/Trustchex.js +9 -2
- package/lib/module/index.js +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/EIDScanner.d.ts +2 -2
- package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +18 -4
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -4
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts +2 -1
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts +124 -0
- package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts +11 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts +2 -39
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/debug.utils.d.ts +42 -0
- package/lib/typescript/src/Shared/Libs/debug.utils.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/demo.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +0 -4
- package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/tts.utils.d.ts +4 -3
- package/lib/typescript/src/Shared/Libs/tts.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Types/identificationInfo.d.ts +2 -2
- package/lib/typescript/src/Shared/Types/identificationInfo.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Types/mrzFields.d.ts +11 -0
- package/lib/typescript/src/Shared/Types/mrzFields.d.ts.map +1 -0
- package/lib/typescript/src/Translation/Resources/en.d.ts +4 -5
- package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
- package/lib/typescript/src/Translation/Resources/tr.d.ts +4 -5
- package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
- package/lib/typescript/src/Trustchex.d.ts +2 -0
- package/lib/typescript/src/Trustchex.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +4 -35
- package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +1 -1
- package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +7 -5
- package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +2 -3
- package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +498 -216
- package/src/Screens/Static/OTPVerificationScreen.tsx +37 -31
- package/src/Screens/Static/QrCodeScanningScreen.tsx +8 -1
- package/src/Screens/Static/ResultScreen.tsx +136 -88
- package/src/Screens/Static/VerificationSessionCheckScreen.tsx +46 -13
- package/src/Shared/Components/DebugNavigationPanel.tsx +290 -34
- package/src/Shared/Components/EIDScanner.tsx +94 -16
- package/src/Shared/Components/FaceCamera.tsx +236 -203
- package/src/Shared/Components/IdentityDocumentCamera.tsx +3073 -1030
- package/src/Shared/Components/QrCodeScannerCamera.tsx +133 -127
- package/src/Shared/Components/TrustchexCamera.tsx +289 -0
- package/src/Shared/Config/camera-enhancement.config.ts +2 -2
- package/src/Shared/EIDReader/tlv/tlv.helpers.ts +96 -0
- package/src/Shared/EIDReader/tlv/tlv.utils.ts +2 -125
- package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +4 -4
- package/src/Shared/Libs/analytics.utils.ts +48 -20
- package/src/Shared/Libs/debug.utils.ts +149 -0
- package/src/Shared/Libs/deeplink.utils.ts +7 -5
- package/src/Shared/Libs/demo.utils.ts +4 -0
- package/src/Shared/Libs/http-client.ts +12 -8
- package/src/Shared/Libs/mrz.utils.ts +1 -163
- package/src/Shared/Libs/native-device-info.utils.ts +12 -6
- package/src/Shared/Libs/tts.utils.ts +48 -6
- package/src/Shared/Services/AnalyticsService.ts +69 -24
- package/src/Shared/Types/identificationInfo.ts +2 -2
- package/src/Shared/Types/mrzFields.ts +29 -0
- package/src/Translation/Resources/en.ts +90 -100
- package/src/Translation/Resources/tr.ts +89 -97
- package/src/Translation/index.ts +1 -1
- package/src/Trustchex.tsx +21 -4
- package/src/index.tsx +14 -0
- package/src/version.ts +1 -1
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/barcodescanner/BarcodeScannerFrameProcessorPlugin.kt +0 -301
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/BitmapUtils.kt +0 -205
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/CropperPlugin.kt +0 -72
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/FrameMetadata.kt +0 -4
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/facedetector/FaceDetectorFrameProcessorPlugin.kt +0 -303
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/textrecognition/TextRecognitionFrameProcessorPlugin.kt +0 -115
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +0 -9
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.mm +0 -22
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +0 -188
- package/ios/VisionCameraPlugins/Cropper/Cropper-Bridging-Header.h +0 -13
- package/ios/VisionCameraPlugins/Cropper/Cropper.h +0 -20
- package/ios/VisionCameraPlugins/Cropper/Cropper.mm +0 -22
- package/ios/VisionCameraPlugins/Cropper/Cropper.swift +0 -145
- package/ios/VisionCameraPlugins/Cropper/CropperUtils.swift +0 -49
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin-Bridging-Header.h +0 -4
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.mm +0 -22
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.swift +0 -320
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin-Bridging-Header.h +0 -4
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.mm +0 -27
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.swift +0 -144
- package/lib/module/Shared/Libs/camera.utils.js +0 -308
- package/lib/module/Shared/Libs/frame-enhancement.utils.js +0 -133
- package/lib/module/Shared/Libs/opencv.utils.js +0 -21
- package/lib/module/Shared/Libs/worklet.utils.js +0 -68
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.js +0 -46
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +0 -35
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -19
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +0 -26
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/types.js +0 -3
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.js +0 -197
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.js +0 -101
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.js +0 -60
- package/lib/module/Shared/VisionCameraPlugins/Cropper/index.js +0 -47
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/Camera.js +0 -42
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/detectFaces.js +0 -35
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/index.js +0 -4
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/types.js +0 -3
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/Camera.js +0 -56
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.js +0 -20
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.js +0 -9
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/index.js +0 -6
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/scanText.js +0 -20
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/translateText.js +0 -19
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/types.js +0 -3
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +0 -87
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts +0 -25
- package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts +0 -3
- package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts +0 -9
- package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts +0 -13
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts +0 -6
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -12
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts +0 -52
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts +0 -62
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts +0 -34
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts +0 -32
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts +0 -23
- package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts +0 -9
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts +0 -79
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts +0 -6
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts +0 -5
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts +0 -67
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts.map +0 -1
- package/src/Shared/Libs/camera.utils.ts +0 -345
- package/src/Shared/Libs/frame-enhancement.utils.ts +0 -217
- package/src/Shared/Libs/opencv.utils.ts +0 -40
- package/src/Shared/Libs/worklet.utils.ts +0 -72
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.ts +0 -79
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +0 -46
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -60
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +0 -32
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/types.ts +0 -82
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.ts +0 -195
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.ts +0 -135
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.ts +0 -84
- package/src/Shared/VisionCameraPlugins/Cropper/index.ts +0 -78
- package/src/Shared/VisionCameraPlugins/FaceDetector/Camera.tsx +0 -63
- package/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.ts +0 -44
- package/src/Shared/VisionCameraPlugins/FaceDetector/index.ts +0 -3
- package/src/Shared/VisionCameraPlugins/FaceDetector/types.ts +0 -99
- package/src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx +0 -76
- package/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts +0 -18
- package/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts +0 -7
- package/src/Shared/VisionCameraPlugins/TextRecognition/index.ts +0 -7
- package/src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts +0 -27
- package/src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts +0 -21
- package/src/Shared/VisionCameraPlugins/TextRecognition/types.ts +0 -141
|
@@ -12,7 +12,8 @@ import AppContext from "../Contexts/AppContext.js";
|
|
|
12
12
|
import StyledButton from "./StyledButton.js";
|
|
13
13
|
import LottieView from 'lottie-react-native';
|
|
14
14
|
import { useKeepAwake } from "../Libs/native-keep-awake.utils.js";
|
|
15
|
-
import {
|
|
15
|
+
import { speak, resetLastMessage } from "../Libs/tts.utils.js";
|
|
16
|
+
import { isDebugEnabled } from "../Libs/debug.utils.js";
|
|
16
17
|
import { trackEIDScanStart, trackEIDScanComplete, trackEIDScanFailed } from "../Libs/analytics.utils.js";
|
|
17
18
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
19
|
const EIDScanner = ({
|
|
@@ -48,7 +49,7 @@ const EIDScanner = ({
|
|
|
48
49
|
const dd = dateStr.substring(4, 6);
|
|
49
50
|
|
|
50
51
|
// Assume 19xx if YY >= 50, else 20xx
|
|
51
|
-
const year = parseInt(yy) >= 50 ? `19${yy}` : `20${yy}`;
|
|
52
|
+
const year = parseInt(yy, 10) >= 50 ? `19${yy}` : `20${yy}`;
|
|
52
53
|
return `${dd}/${mm}/${year}`;
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -73,6 +74,7 @@ const EIDScanner = ({
|
|
|
73
74
|
const appContext = React.useContext(AppContext);
|
|
74
75
|
const [voiceGuidanceMessage, setVoiceGuidanceMessage] = useState();
|
|
75
76
|
const [attemptNumber, setAttemptNumber] = useState(0);
|
|
77
|
+
const lastVoiceGuidanceMessage = useRef('');
|
|
76
78
|
const readNFC = useCallback(async () => {
|
|
77
79
|
const startTime = Date.now();
|
|
78
80
|
const currentAttempt = attemptNumber + 1;
|
|
@@ -81,6 +83,8 @@ const EIDScanner = ({
|
|
|
81
83
|
setIsScanned(false);
|
|
82
84
|
setProgress(0);
|
|
83
85
|
setProgressStage('');
|
|
86
|
+
lastVoiceGuidanceMessage.current = '';
|
|
87
|
+
resetLastMessage();
|
|
84
88
|
|
|
85
89
|
// Track EID scan start using analytics helper
|
|
86
90
|
const docType = documentType || 'UNKNOWN';
|
|
@@ -124,8 +128,6 @@ const EIDScanner = ({
|
|
|
124
128
|
setDocumentMRZInfo(passportData.mrz);
|
|
125
129
|
setDocumentFaceImageMimeType(passportData.mimeType);
|
|
126
130
|
setIsScanned(true);
|
|
127
|
-
|
|
128
|
-
// Track successful EID scan
|
|
129
131
|
await trackEIDScanComplete(docType, scanDuration, currentAttempt).catch(() => {});
|
|
130
132
|
}
|
|
131
133
|
} else {
|
|
@@ -240,8 +242,9 @@ const EIDScanner = ({
|
|
|
240
242
|
}
|
|
241
243
|
}, [isScanning, progress, pulseAnim]);
|
|
242
244
|
useEffect(() => {
|
|
243
|
-
if (voiceGuidanceMessage && appContext.currentWorkflowStep?.data?.voiceGuidanceActive) {
|
|
244
|
-
|
|
245
|
+
if (voiceGuidanceMessage && appContext.currentWorkflowStep?.data?.voiceGuidanceActive && voiceGuidanceMessage !== lastVoiceGuidanceMessage.current) {
|
|
246
|
+
lastVoiceGuidanceMessage.current = voiceGuidanceMessage;
|
|
247
|
+
speak(voiceGuidanceMessage, true);
|
|
245
248
|
}
|
|
246
249
|
}, [voiceGuidanceMessage, appContext.currentWorkflowStep?.data?.voiceGuidanceActive]);
|
|
247
250
|
return /*#__PURE__*/_jsxs(View, {
|
|
@@ -250,11 +253,14 @@ const EIDScanner = ({
|
|
|
250
253
|
style: [styles.topProgressContainer, {
|
|
251
254
|
paddingTop: insets.top + 16
|
|
252
255
|
}],
|
|
253
|
-
children: [/*#__PURE__*/
|
|
256
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
257
|
+
style: styles.holdSteadyText,
|
|
258
|
+
children: t('eidScannerScreen.readingDocument')
|
|
259
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
254
260
|
style: styles.progressTextContainer,
|
|
255
261
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
256
262
|
style: styles.topScanningText,
|
|
257
|
-
children: progressStage || t('eidScannerScreen.
|
|
263
|
+
children: progressStage || t('eidScannerScreen.connecting')
|
|
258
264
|
}), /*#__PURE__*/_jsxs(Text, {
|
|
259
265
|
style: [styles.progressPercentage, {
|
|
260
266
|
color: appContext.branding.primaryColor
|
|
@@ -433,6 +439,83 @@ const EIDScanner = ({
|
|
|
433
439
|
},
|
|
434
440
|
children: t('eidScannerScreen.approveAndContinue')
|
|
435
441
|
})
|
|
442
|
+
}), isDebugEnabled() && /*#__PURE__*/_jsxs(View, {
|
|
443
|
+
style: {
|
|
444
|
+
position: 'absolute',
|
|
445
|
+
top: insets.top + 10,
|
|
446
|
+
right: 10,
|
|
447
|
+
backgroundColor: 'rgba(0, 0, 0, 0.85)',
|
|
448
|
+
padding: 10,
|
|
449
|
+
borderRadius: 8,
|
|
450
|
+
borderWidth: 1,
|
|
451
|
+
borderColor: '#FF6B6B',
|
|
452
|
+
maxWidth: 200,
|
|
453
|
+
zIndex: 1001
|
|
454
|
+
},
|
|
455
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
456
|
+
style: {
|
|
457
|
+
color: '#FF6B6B',
|
|
458
|
+
fontSize: 11,
|
|
459
|
+
fontWeight: 'bold',
|
|
460
|
+
marginBottom: 6
|
|
461
|
+
},
|
|
462
|
+
children: "\uD83D\uDC1B DEBUG MODE"
|
|
463
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
464
|
+
style: {
|
|
465
|
+
color: '#88D8B0',
|
|
466
|
+
fontSize: 9,
|
|
467
|
+
marginBottom: 2
|
|
468
|
+
},
|
|
469
|
+
children: `NFC: ${hasNfc ? '✓' : '✗'}`
|
|
470
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
471
|
+
style: {
|
|
472
|
+
color: '#88D8B0',
|
|
473
|
+
fontSize: 9,
|
|
474
|
+
marginBottom: 2
|
|
475
|
+
},
|
|
476
|
+
children: `Enabled: ${isEnabled ? '✓' : '✗'}`
|
|
477
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
478
|
+
style: {
|
|
479
|
+
color: '#88D8B0',
|
|
480
|
+
fontSize: 9,
|
|
481
|
+
marginBottom: 2
|
|
482
|
+
},
|
|
483
|
+
children: `Scanning: ${isScanning ? '✓' : '○'}`
|
|
484
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
485
|
+
style: {
|
|
486
|
+
color: '#88D8B0',
|
|
487
|
+
fontSize: 9,
|
|
488
|
+
marginBottom: 2
|
|
489
|
+
},
|
|
490
|
+
children: `Scanned: ${isScanned ? '✓' : '○'}`
|
|
491
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
492
|
+
style: {
|
|
493
|
+
color: '#88D8B0',
|
|
494
|
+
fontSize: 9,
|
|
495
|
+
marginBottom: 2
|
|
496
|
+
},
|
|
497
|
+
children: `Progress: ${Math.round(progress)}%`
|
|
498
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
499
|
+
style: {
|
|
500
|
+
color: '#88D8B0',
|
|
501
|
+
fontSize: 9,
|
|
502
|
+
marginBottom: 2
|
|
503
|
+
},
|
|
504
|
+
children: `Face Image: ${documentFaceImage ? '✓' : '✗'}`
|
|
505
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
506
|
+
style: {
|
|
507
|
+
color: '#88D8B0',
|
|
508
|
+
fontSize: 9,
|
|
509
|
+
marginBottom: 2
|
|
510
|
+
},
|
|
511
|
+
children: `MRZ Info: ${documentMRZInfo ? '✓' : '✗'}`
|
|
512
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
513
|
+
style: {
|
|
514
|
+
color: '#88D8B0',
|
|
515
|
+
fontSize: 9
|
|
516
|
+
},
|
|
517
|
+
children: `Doc Type: ${documentType}`
|
|
518
|
+
})]
|
|
436
519
|
})]
|
|
437
520
|
})]
|
|
438
521
|
});
|
|
@@ -455,6 +538,13 @@ const styles = StyleSheet.create({
|
|
|
455
538
|
backgroundColor: 'rgba(255, 255, 255, 0.95)',
|
|
456
539
|
gap: 8
|
|
457
540
|
},
|
|
541
|
+
holdSteadyText: {
|
|
542
|
+
fontSize: 20,
|
|
543
|
+
fontWeight: '700',
|
|
544
|
+
color: '#000',
|
|
545
|
+
textAlign: 'center',
|
|
546
|
+
marginBottom: 8
|
|
547
|
+
},
|
|
458
548
|
progressTextContainer: {
|
|
459
549
|
flexDirection: 'row',
|
|
460
550
|
justifyContent: 'space-between',
|
|
@@ -462,7 +552,7 @@ const styles = StyleSheet.create({
|
|
|
462
552
|
width: '100%'
|
|
463
553
|
},
|
|
464
554
|
topScanningText: {
|
|
465
|
-
fontSize:
|
|
555
|
+
fontSize: 14,
|
|
466
556
|
fontWeight: 'bold',
|
|
467
557
|
color: '#000',
|
|
468
558
|
flex: 1
|
|
@@ -2,23 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
import { useIsFocused } from '@react-navigation/native';
|
|
4
4
|
import { useKeepAwake } from "../Libs/native-keep-awake.utils.js";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useFaceDetector } from "../VisionCameraPlugins/FaceDetector/index.js";
|
|
10
|
-
import { Worklets, useSharedValue } from 'react-native-worklets-core';
|
|
11
|
-
import { crop } from "../VisionCameraPlugins/Cropper/index.js";
|
|
12
|
-
import { isCircularRegionBright, isBlurry } from "../Libs/camera.utils.js";
|
|
5
|
+
import { debugLog, debugWarn, debugError, logError } from "../Libs/debug.utils.js";
|
|
6
|
+
import React, { useEffect, useState, useRef, useCallback } from 'react';
|
|
7
|
+
import { StyleSheet, Text, View, Platform, Linking, ActivityIndicator, NativeModules, PermissionsAndroid } from 'react-native';
|
|
8
|
+
import { TrustchexCamera } from "./TrustchexCamera.js";
|
|
13
9
|
import { useTranslation } from 'react-i18next';
|
|
14
10
|
import StyledButton from "./StyledButton.js";
|
|
15
11
|
import { useTheme } from "../Contexts/ThemeContext.js";
|
|
16
12
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
13
|
+
import { Dimensions } from 'react-native';
|
|
17
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const {
|
|
16
|
+
width: windowWidth,
|
|
17
|
+
height: windowHeight
|
|
18
|
+
} = Dimensions.get('window');
|
|
19
|
+
const {
|
|
20
|
+
OpenCVModule
|
|
21
|
+
} = NativeModules;
|
|
22
|
+
const MIN_BRIGHTNESS_THRESHOLD = 80;
|
|
23
|
+
const BLUR_VARIANCE_THRESHOLD = 60;
|
|
24
|
+
const REGION_BRIGHTNESS_THRESHOLD = 70;
|
|
22
25
|
const FaceCamera = ({
|
|
23
26
|
onFacesDetected,
|
|
24
27
|
onCameraInitialized,
|
|
@@ -26,60 +29,36 @@ const FaceCamera = ({
|
|
|
26
29
|
}) => {
|
|
27
30
|
useKeepAwake();
|
|
28
31
|
const theme = useTheme();
|
|
29
|
-
const
|
|
30
|
-
const microphonePermission = useMicrophonePermission();
|
|
32
|
+
const [hasPermission, setHasPermission] = useState(false);
|
|
31
33
|
const [permissionsRequested, setPermissionsRequested] = useState(false);
|
|
32
|
-
const cameraRef =
|
|
34
|
+
const cameraRef = useRef(null);
|
|
33
35
|
const isFocused = useIsFocused();
|
|
34
36
|
const [isActive, setIsActive] = useState(false);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
videoResolution: {
|
|
38
|
-
width: VIDEO_WIDTH,
|
|
39
|
-
height: VIDEO_HEIGHT
|
|
40
|
-
},
|
|
41
|
-
iso: 'max',
|
|
42
|
-
photoHdr: false,
|
|
43
|
-
videoHdr: false,
|
|
44
|
-
fps: 30
|
|
45
|
-
}]);
|
|
46
|
-
const isCameraInitialized = useSharedValue(false);
|
|
47
|
-
const faceDetectorOptions = useMemo(() => ({
|
|
48
|
-
contourMode: 'none',
|
|
49
|
-
landmarkMode: 'none',
|
|
50
|
-
classificationMode: 'all',
|
|
51
|
-
performanceMode: 'accurate',
|
|
52
|
-
trackingEnabled: false,
|
|
53
|
-
autoScale: true,
|
|
54
|
-
windowWidth: windowWidth,
|
|
55
|
-
windowHeight: windowHeight
|
|
56
|
-
}), [windowWidth, windowHeight]);
|
|
57
|
-
const {
|
|
58
|
-
detectFaces
|
|
59
|
-
} = useFaceDetector(faceDetectorOptions);
|
|
37
|
+
const isCameraInitializedRef = useRef(false);
|
|
38
|
+
const lastFrameTimeRef = useRef(0);
|
|
60
39
|
const {
|
|
61
40
|
t
|
|
62
41
|
} = useTranslation();
|
|
63
42
|
useEffect(() => {
|
|
64
43
|
const requestPermissions = async () => {
|
|
65
|
-
if (
|
|
66
|
-
await
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
44
|
+
if (Platform.OS === 'android') {
|
|
45
|
+
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA);
|
|
46
|
+
setHasPermission(granted === PermissionsAndroid.RESULTS.GRANTED);
|
|
47
|
+
} else {
|
|
48
|
+
// iOS permissions handled by native camera
|
|
49
|
+
setHasPermission(true);
|
|
70
50
|
}
|
|
71
51
|
setPermissionsRequested(true);
|
|
72
52
|
};
|
|
73
53
|
requestPermissions();
|
|
74
|
-
}, [
|
|
75
|
-
const handleFaces = Worklets.createRunOnJS((faces, image, isBright) => {
|
|
76
|
-
if (faces.length > 0) {
|
|
77
|
-
console.log('[FaceCamera] handleFaces called - faces:', faces.length, 'bright:', isBright);
|
|
78
|
-
onFacesDetected(faces, image, isBright);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
54
|
+
}, []);
|
|
81
55
|
useEffect(() => {
|
|
82
|
-
|
|
56
|
+
debugLog('FaceCamera', 'isActive state changed:', {
|
|
57
|
+
isFocused,
|
|
58
|
+
hasPermission,
|
|
59
|
+
isActive: isFocused && hasPermission
|
|
60
|
+
});
|
|
61
|
+
if (isFocused && hasPermission) {
|
|
83
62
|
setIsActive(true);
|
|
84
63
|
} else {
|
|
85
64
|
setIsActive(false);
|
|
@@ -87,7 +66,7 @@ const FaceCamera = ({
|
|
|
87
66
|
return () => {
|
|
88
67
|
setIsActive(false);
|
|
89
68
|
};
|
|
90
|
-
}, [
|
|
69
|
+
}, [isFocused, hasPermission]);
|
|
91
70
|
|
|
92
71
|
// Set screen brightness to maximum when camera is active
|
|
93
72
|
useEffect(() => {
|
|
@@ -100,9 +79,9 @@ const FaceCamera = ({
|
|
|
100
79
|
if (isActive) {
|
|
101
80
|
try {
|
|
102
81
|
originalBrightness = await DeviceBrightness.getBrightness();
|
|
103
|
-
await DeviceBrightness.setBrightness(1
|
|
82
|
+
await DeviceBrightness.setBrightness(1);
|
|
104
83
|
} catch (error) {
|
|
105
|
-
|
|
84
|
+
debugLog('FaceCamera', '[FaceCamera] Failed to set brightness:', error);
|
|
106
85
|
}
|
|
107
86
|
}
|
|
108
87
|
};
|
|
@@ -113,96 +92,131 @@ const FaceCamera = ({
|
|
|
113
92
|
}
|
|
114
93
|
};
|
|
115
94
|
}, [isActive]);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
95
|
+
const isProcessingFrame = useRef(false);
|
|
96
|
+
const handleFrame = useCallback(async event => {
|
|
97
|
+
debugLog('FaceCamera', '*** FRAME CALLBACK INVOKED ***', {
|
|
98
|
+
isProcessing: isProcessingFrame.current,
|
|
99
|
+
timestamp: Date.now()
|
|
100
|
+
});
|
|
101
|
+
if (isProcessingFrame.current) {
|
|
102
|
+
debugLog('FaceCamera', 'Frame dropped - already processing');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const now = Date.now();
|
|
106
|
+
const timeSinceLastFrame = now - lastFrameTimeRef.current;
|
|
107
|
+
// Throttle to ~6.7 FPS for face scanning (150ms interval matches Flutter SDK for responsive detection)
|
|
108
|
+
if (timeSinceLastFrame < 150) {
|
|
109
|
+
debugLog('FaceCamera', `Frame dropped - throttling (${timeSinceLastFrame}ms < 150ms)`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
lastFrameTimeRef.current = now;
|
|
113
|
+
if (!isCameraInitializedRef.current) {
|
|
114
|
+
debugLog('FaceCamera', 'Camera not initialized yet');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (!isActive) {
|
|
118
|
+
debugLog('FaceCamera', 'Camera not active');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
isProcessingFrame.current = true;
|
|
122
|
+
const {
|
|
123
|
+
frame
|
|
124
|
+
} = event.nativeEvent;
|
|
119
125
|
try {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
let isBright = false;
|
|
123
|
-
if (previewRect) {
|
|
124
|
-
// Convert preview rect from screen coordinates to frame coordinates
|
|
125
|
-
const scaleX = frame.width / windowWidth;
|
|
126
|
-
const scaleY = frame.height / windowHeight;
|
|
127
|
-
const frameCircleRect = {
|
|
128
|
-
minX: Math.floor(previewRect.minX * scaleX),
|
|
129
|
-
minY: Math.floor(previewRect.minY * scaleY),
|
|
130
|
-
width: Math.floor(previewRect.width * scaleX),
|
|
131
|
-
height: Math.floor(previewRect.height * scaleY)
|
|
132
|
-
};
|
|
133
|
-
isBright = isCircularRegionBright(frame, frameCircleRect, 60);
|
|
134
|
-
} else {
|
|
135
|
-
// Fallback: check entire frame brightness (use legacy method)
|
|
136
|
-
const buffer = frame.toArrayBuffer();
|
|
137
|
-
const data = new Uint8Array(buffer);
|
|
138
|
-
const width = frame.width;
|
|
139
|
-
const height = frame.height;
|
|
140
|
-
let luminanceSum = 0;
|
|
141
|
-
let pixelCount = 0;
|
|
142
|
-
const centerX = Math.floor(width / 2);
|
|
143
|
-
const centerY = Math.floor(height / 2);
|
|
144
|
-
const halfSizeX = Math.floor(width / 2);
|
|
145
|
-
const halfSizeY = Math.floor(height / 2);
|
|
146
|
-
for (let y = centerY - halfSizeY; y < centerY + halfSizeY; y++) {
|
|
147
|
-
for (let x = centerX - halfSizeX; x < centerX + halfSizeX; x++) {
|
|
148
|
-
const index = y * width + x;
|
|
149
|
-
if (data[index] !== undefined) {
|
|
150
|
-
luminanceSum += data[index];
|
|
151
|
-
pixelCount++;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
isBright = luminanceSum / pixelCount > 60;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Skip blurry frames to ensure sharp face captures
|
|
159
|
-
// Lower threshold (10) for better frame acceptance
|
|
160
|
-
if (isBlurry(frame, 10)) {
|
|
126
|
+
if (!frame.width || !frame.height || frame.width <= 0 || frame.height <= 0) {
|
|
127
|
+
debugLog('FaceCamera', 'Invalid frame dimensions');
|
|
161
128
|
return;
|
|
162
129
|
}
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
130
|
+
const base64Image = frame.base64Image ?? '';
|
|
131
|
+
|
|
132
|
+
// Read faces directly from native ML Kit results
|
|
133
|
+
const nativeFaces = frame.faces ?? [];
|
|
134
|
+
debugLog('FaceCamera', 'Native faces:', nativeFaces.length);
|
|
135
|
+
|
|
136
|
+
// Map NativeFace to FaceCamera's Face type first
|
|
137
|
+
// ML Kit classification probabilities may be undefined if detection fails
|
|
138
|
+
// Default to 0 so comparisons don't fail with undefined
|
|
139
|
+
const faces = nativeFaces.map(f => ({
|
|
140
|
+
bounds: {
|
|
141
|
+
x: f.bounds.x,
|
|
142
|
+
y: f.bounds.y,
|
|
143
|
+
width: f.bounds.width,
|
|
144
|
+
height: f.bounds.height
|
|
169
145
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
146
|
+
yawAngle: f.yawAngle ?? 0,
|
|
147
|
+
pitchAngle: f.pitchAngle ?? 0,
|
|
148
|
+
rollAngle: f.rollAngle ?? 0,
|
|
149
|
+
smilingProbability: f.smilingProbability ?? 0,
|
|
150
|
+
leftEyeOpenProbability: f.leftEyeOpenProbability ?? 0,
|
|
151
|
+
rightEyeOpenProbability: f.rightEyeOpenProbability ?? 0
|
|
152
|
+
}));
|
|
153
|
+
|
|
154
|
+
// Check overall brightness - computed natively on the Y plane
|
|
155
|
+
const avgBrightness = frame.brightness ?? 128;
|
|
156
|
+
const isBright = avgBrightness >= MIN_BRIGHTNESS_THRESHOLD;
|
|
157
|
+
|
|
158
|
+
// Check brightness in the region of interest (circular preview area)
|
|
159
|
+
let isRegionBright = isBright; // Default to overall brightness
|
|
160
|
+
if (previewRect && base64Image && OpenCVModule) {
|
|
161
|
+
try {
|
|
162
|
+
// Scale preview rect from screen coordinates to frame coordinates
|
|
163
|
+
const scaleX = frame.width / windowWidth;
|
|
164
|
+
const scaleY = frame.height / windowHeight;
|
|
165
|
+
const regionMinX = Math.round(previewRect.minX * scaleX);
|
|
166
|
+
const regionMinY = Math.round(previewRect.minY * scaleY);
|
|
167
|
+
const regionWidth = Math.round(previewRect.width * scaleX);
|
|
168
|
+
const regionHeight = Math.round(previewRect.height * scaleY);
|
|
169
|
+
isRegionBright = await OpenCVModule.isCircularRegionBright(base64Image, regionMinX, regionMinY, regionWidth, regionHeight, REGION_BRIGHTNESS_THRESHOLD);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
debugWarn('FaceCamera', 'Region brightness check failed:', error);
|
|
177
172
|
}
|
|
178
|
-
handleFaces(faces, image.base64, isBright);
|
|
179
173
|
}
|
|
180
|
-
} catch (error) {
|
|
181
|
-
console.error('[FaceCamera] Face detection error:', error);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
const frameProcessor = useFrameProcessor(frame => {
|
|
185
|
-
'worklet';
|
|
186
174
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// Android: Run async without throttling
|
|
199
|
-
runAsync(frame, () => {
|
|
200
|
-
'worklet';
|
|
175
|
+
// Check for blur using OpenCV Laplacian variance
|
|
176
|
+
let isNotBlurry = true;
|
|
177
|
+
try {
|
|
178
|
+
if (base64Image && OpenCVModule) {
|
|
179
|
+
const isBlurryResult = await OpenCVModule.checkBlurry(base64Image, BLUR_VARIANCE_THRESHOLD);
|
|
180
|
+
isNotBlurry = !isBlurryResult;
|
|
181
|
+
}
|
|
182
|
+
} catch (error) {
|
|
183
|
+
debugWarn('FaceCamera', 'Blur check failed:', error);
|
|
184
|
+
// If check fails, assume not blurry to continue
|
|
185
|
+
}
|
|
201
186
|
|
|
202
|
-
|
|
203
|
-
|
|
187
|
+
// Check quality but still pass detected faces
|
|
188
|
+
// Let liveness detection logic decide whether to accept poor quality frames
|
|
189
|
+
const hasGoodQuality = isRegionBright && isNotBlurry;
|
|
190
|
+
if (!hasGoodQuality) {
|
|
191
|
+
debugLog('FaceCamera', 'Frame quality insufficient:', {
|
|
192
|
+
avgBrightness,
|
|
193
|
+
isBright,
|
|
194
|
+
isRegionBright,
|
|
195
|
+
isNotBlurry,
|
|
196
|
+
faceCount: faces.length
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
debugLog('FaceCamera', `Calling onFacesDetected with ${faces.length} faces`);
|
|
200
|
+
// Always call onFacesDetected with detected faces
|
|
201
|
+
// isRegionBright indicates whether the region of interest has acceptable brightness
|
|
202
|
+
// This allows the UI to show warnings while still detecting faces
|
|
203
|
+
onFacesDetected(faces, base64Image, isRegionBright, frame.width, frame.height);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
debugError('FaceCamera', 'Face detection error:', error);
|
|
206
|
+
} finally {
|
|
207
|
+
isProcessingFrame.current = false;
|
|
208
|
+
}
|
|
209
|
+
}, [isActive, previewRect, onFacesDetected]);
|
|
210
|
+
const handleCameraReady = useCallback(() => {
|
|
211
|
+
debugLog('FaceCamera', 'Camera ready, initializing...');
|
|
212
|
+
isCameraInitializedRef.current = true;
|
|
213
|
+
if (cameraRef.current) {
|
|
214
|
+
onCameraInitialized(cameraRef.current);
|
|
204
215
|
}
|
|
205
|
-
}, [
|
|
216
|
+
}, [onCameraInitialized]);
|
|
217
|
+
const handleCameraError = useCallback(event => {
|
|
218
|
+
logError('[FaceCamera] Camera error:', event.nativeEvent.error);
|
|
219
|
+
}, []);
|
|
206
220
|
if (!permissionsRequested) {
|
|
207
221
|
return /*#__PURE__*/_jsx(SafeAreaView, {
|
|
208
222
|
style: styles.permissionContainer,
|
|
@@ -212,8 +226,7 @@ const FaceCamera = ({
|
|
|
212
226
|
})
|
|
213
227
|
});
|
|
214
228
|
}
|
|
215
|
-
if (!
|
|
216
|
-
// Camera permission denied by user - their choice, not actionable
|
|
229
|
+
if (!hasPermission) {
|
|
217
230
|
return /*#__PURE__*/_jsxs(SafeAreaView, {
|
|
218
231
|
style: styles.permissionContainer,
|
|
219
232
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
@@ -228,50 +241,28 @@ const FaceCamera = ({
|
|
|
228
241
|
})]
|
|
229
242
|
});
|
|
230
243
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}), /*#__PURE__*/_jsx(StyledButton, {
|
|
239
|
-
mode: "contained",
|
|
240
|
-
onPress: () => {
|
|
241
|
-
Linking.openSettings();
|
|
242
|
-
},
|
|
243
|
-
children: t('general.openSettings')
|
|
244
|
-
})]
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
if (device == null) {
|
|
248
|
-
// No camera device - device limitation, not actionable
|
|
249
|
-
return /*#__PURE__*/_jsx(SafeAreaView, {
|
|
250
|
-
style: styles.permissionContainer,
|
|
251
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
252
|
-
style: styles.permissionText,
|
|
253
|
-
children: t('general.noCameraDetected')
|
|
254
|
-
})
|
|
255
|
-
});
|
|
256
|
-
}
|
|
244
|
+
debugLog('FaceCamera', 'Rendering TrustchexCamera with props:', {
|
|
245
|
+
isActive,
|
|
246
|
+
enableFrameProcessing: isActive,
|
|
247
|
+
enableFaceDetection: isActive,
|
|
248
|
+
includeBase64: true,
|
|
249
|
+
targetFps: 10
|
|
250
|
+
});
|
|
257
251
|
return /*#__PURE__*/_jsx(View, {
|
|
258
252
|
style: StyleSheet.absoluteFill,
|
|
259
|
-
children: /*#__PURE__*/_jsx(
|
|
253
|
+
children: /*#__PURE__*/_jsx(TrustchexCamera, {
|
|
260
254
|
ref: cameraRef,
|
|
261
|
-
frameProcessor: frameProcessor,
|
|
262
255
|
style: StyleSheet.absoluteFill,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
onCameraInitialized(cameraRef.current);
|
|
274
|
-
}
|
|
256
|
+
cameraType: "front",
|
|
257
|
+
torchEnabled: false,
|
|
258
|
+
enableFrameProcessing: isActive,
|
|
259
|
+
enableFaceDetection: isActive,
|
|
260
|
+
includeBase64: true // Enabled to capture photos for liveness steps
|
|
261
|
+
,
|
|
262
|
+
targetFps: 5,
|
|
263
|
+
onFrameAvailable: handleFrame,
|
|
264
|
+
onCameraReady: handleCameraReady,
|
|
265
|
+
onCameraError: handleCameraError
|
|
275
266
|
})
|
|
276
267
|
});
|
|
277
268
|
};
|