react-native-biometric-verifier 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +26 -6
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -30,7 +30,7 @@ import { styles } from './components/styles';
|
|
|
30
30
|
import { useNavigation } from '@react-navigation/native';
|
|
31
31
|
import networkServiceCall from './utils/NetworkServiceCall';
|
|
32
32
|
|
|
33
|
-
const BiometricVerificationModal = React.memo(({ data, callback }) => {
|
|
33
|
+
const BiometricVerificationModal = React.memo(({ data, qrscan = false, callback }) => {
|
|
34
34
|
const navigation = useNavigation();
|
|
35
35
|
|
|
36
36
|
const { countdown, startCountdown, resetCountdown } = useCountdown();
|
|
@@ -48,6 +48,7 @@ const BiometricVerificationModal = React.memo(({ data, callback }) => {
|
|
|
48
48
|
|
|
49
49
|
const dataRef = useRef(data);
|
|
50
50
|
const mountedRef = useRef(true);
|
|
51
|
+
const qrscanRef = useRef(qrscan);
|
|
51
52
|
|
|
52
53
|
useEffect(() => {
|
|
53
54
|
return () => {
|
|
@@ -57,7 +58,8 @@ const BiometricVerificationModal = React.memo(({ data, callback }) => {
|
|
|
57
58
|
|
|
58
59
|
useEffect(() => {
|
|
59
60
|
dataRef.current = data;
|
|
60
|
-
|
|
61
|
+
qrscanRef.current = qrscan;
|
|
62
|
+
}, [data, qrscan]);
|
|
61
63
|
|
|
62
64
|
const updateState = useCallback((newState) => {
|
|
63
65
|
if (mountedRef.current) {
|
|
@@ -107,14 +109,25 @@ const BiometricVerificationModal = React.memo(({ data, callback }) => {
|
|
|
107
109
|
try {
|
|
108
110
|
const body = { image: base64 }
|
|
109
111
|
const header = { hrenemp: currentData }
|
|
110
|
-
const response = await networkServiceCall("POST",RECOGNIZE_URL,header,body);
|
|
112
|
+
const response = await networkServiceCall("POST", RECOGNIZE_URL, header, body);
|
|
111
113
|
if (response.httpstatus === 200) {
|
|
112
114
|
notifyMessage('Identity verified successfully!', 'success');
|
|
113
115
|
updateState({
|
|
114
116
|
employeeData: response.data?.data,
|
|
115
117
|
animationState: ANIMATION_STATES.SUCCESS,
|
|
116
118
|
});
|
|
117
|
-
|
|
119
|
+
|
|
120
|
+
// If QR scanning is enabled, proceed to QR scan
|
|
121
|
+
if (qrscanRef.current) {
|
|
122
|
+
setTimeout(() => startQRCodeScan(), 1500);
|
|
123
|
+
} else {
|
|
124
|
+
// If only face recognition, complete the process
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
callback?.(dataRef.current);
|
|
127
|
+
updateState({ modalVisible: false });
|
|
128
|
+
resetState();
|
|
129
|
+
}, 1500);
|
|
130
|
+
}
|
|
118
131
|
} else {
|
|
119
132
|
updateState({ animationState: ANIMATION_STATES.ERROR });
|
|
120
133
|
notifyMessage(response.data?.error?.message || 'Face not recognized. Please try again.', 'error');
|
|
@@ -125,7 +138,7 @@ const BiometricVerificationModal = React.memo(({ data, callback }) => {
|
|
|
125
138
|
} finally {
|
|
126
139
|
updateState({ isLoading: false });
|
|
127
140
|
}
|
|
128
|
-
}, [convertImageToBase64, notifyMessage, startQRCodeScan, updateState]);
|
|
141
|
+
}, [convertImageToBase64, notifyMessage, startQRCodeScan, updateState, callback]);
|
|
129
142
|
|
|
130
143
|
const handleStartFaceScan = useCallback(() => {
|
|
131
144
|
updateState({
|
|
@@ -219,7 +232,14 @@ const BiometricVerificationModal = React.memo(({ data, callback }) => {
|
|
|
219
232
|
|
|
220
233
|
const startProcess = useCallback(() => {
|
|
221
234
|
startCountdown(COUNTDOWN_DURATION, handleCountdownFinish);
|
|
222
|
-
|
|
235
|
+
|
|
236
|
+
if (qrscanRef.current) {
|
|
237
|
+
// Start with face scan if QR scanning is enabled
|
|
238
|
+
handleStartFaceScan();
|
|
239
|
+
} else {
|
|
240
|
+
// If only face recognition is needed, start directly with face scan
|
|
241
|
+
handleStartFaceScan();
|
|
242
|
+
}
|
|
223
243
|
}, [handleCountdownFinish, handleStartFaceScan, startCountdown]);
|
|
224
244
|
|
|
225
245
|
useEffect(() => {
|