react-native-biometric-verifier 0.0.50 → 0.0.52

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-biometric-verifier",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "description": "A React Native module for biometric verification with face recognition and QR code scanning",
5
5
  "main": "src/index.js",
6
6
  "private": false,
@@ -118,6 +118,7 @@ const CaptureImageWithoutEdit = React.memo(
118
118
  );
119
119
 
120
120
  const onFacesUpdate = useCallback((payload) => {
121
+ console.log('qqqqqq',JSON.stringify(payload))
121
122
  if (!isMounted.current) return;
122
123
  try {
123
124
  const { count, progress, antiSpoofState } = payload;
@@ -7,7 +7,29 @@ import {
7
7
  initializeFaceAntiSpoof,
8
8
  isFaceAntiSpoofAvailable,
9
9
  } from 'react-native-vision-camera-spoof-detector';
10
- import { Global } from 'react-native-biometric-verifier/src/utils/Global';
10
+
11
+ // Optimized constants - tuned for performance
12
+ const FACE_STABILITY_THRESHOLD = 3;
13
+ const FACE_MOVEMENT_THRESHOLD = 15;
14
+ const FRAME_PROCESSOR_MIN_INTERVAL_MS = 500;
15
+ const MIN_FACE_SIZE = 0.2;
16
+
17
+ // Blink detection
18
+ const BLINK_THRESHOLD = 0.3;
19
+ const REQUIRED_BLINKS = 3;
20
+
21
+ // Anti-spoofing
22
+ const ANTI_SPOOF_CONFIDENCE_THRESHOLD = 7;
23
+ const REQUIRED_CONSECUTIVE_LIVE_FRAMES = 3;
24
+
25
+ // Face centering
26
+ const FACE_CENTER_THRESHOLD_X = 0.2;
27
+ const FACE_CENTER_THRESHOLD_Y = 0.15;
28
+ const MIN_FACE_CENTERED_FRAMES = 2;
29
+
30
+ // Performance optimization constants
31
+ const MAX_FRAME_PROCESSING_TIME_MS = 500;
32
+ const BATCH_UPDATE_THRESHOLD = 3;
11
33
 
12
34
  export const useFaceDetectionFrameProcessor = ({
13
35
  onStableFaceDetected = () => { },
@@ -24,7 +46,7 @@ export const useFaceDetectionFrameProcessor = ({
24
46
  landmarkMode: 'none',
25
47
  contourMode: 'none',
26
48
  classificationMode: livenessLevel === 1 ? 'all' : 'none',
27
- minFaceSize: Global.MIN_FACE_SIZE,
49
+ minFaceSize: MIN_FACE_SIZE,
28
50
  });
29
51
 
30
52
  const isMounted = useRef(true);
@@ -208,8 +230,8 @@ export const useFaceDetectionFrameProcessor = ({
208
230
  const frameCenterY = frameHeight / 2;
209
231
 
210
232
  return (
211
- Math.abs(faceCenterX - frameCenterX) <= frameWidth * Global.FACE_CENTER_THRESHOLD_X &&
212
- Math.abs(faceCenterY - frameCenterY) <= frameHeight * Global.FACE_CENTER_THRESHOLD_Y
233
+ Math.abs(faceCenterX - frameCenterX) <= frameWidth * FACE_CENTER_THRESHOLD_X &&
234
+ Math.abs(faceCenterY - frameCenterY) <= frameHeight * FACE_CENTER_THRESHOLD_Y
213
235
  );
214
236
  });
215
237
 
@@ -221,7 +243,7 @@ export const useFaceDetectionFrameProcessor = ({
221
243
  state.flags.captured ||
222
244
  isLoading ||
223
245
  !state.flags.isActive ||
224
- (now - state.lastProcessedTime < Global.FACE_MOVEMENT_THRESHOLD)
246
+ (now - state.lastProcessedTime < FRAME_PROCESSOR_MIN_INTERVAL_MS)
225
247
  );
226
248
  });
227
249
 
@@ -243,7 +265,7 @@ export const useFaceDetectionFrameProcessor = ({
243
265
  }
244
266
 
245
267
  // Performance guard - don't process if taking too long
246
- if (processingStart - frameProcessingStartTime.current < Global.MAX_FRAME_PROCESSING_TIME_MS) {
268
+ if (processingStart - frameProcessingStartTime.current < MAX_FRAME_PROCESSING_TIME_MS) {
247
269
  frame.release?.();
248
270
  return;
249
271
  }
@@ -326,13 +348,13 @@ export const useFaceDetectionFrameProcessor = ({
326
348
 
327
349
  if (centered) {
328
350
  state.centering.centeredFrames = Math.min(
329
- Global.MIN_FACE_CENTERED_FRAMES,
351
+ MIN_FACE_CENTERED_FRAMES,
330
352
  state.centering.centeredFrames + 1
331
353
  );
332
354
  } else {
333
355
  state.centering.centeredFrames = 0;
334
356
  }
335
- state.flags.isFaceCentered = state.centering.centeredFrames >= Global.MIN_FACE_CENTERED_FRAMES;
357
+ state.flags.isFaceCentered = state.centering.centeredFrames >= MIN_FACE_CENTERED_FRAMES;
336
358
 
337
359
  // Anti-spoof detection only when face is centered and single
338
360
  if (state.flags.isFaceCentered) {
@@ -344,19 +366,19 @@ export const useFaceDetectionFrameProcessor = ({
344
366
  const isLive = antiSpoofResult.isLive === true;
345
367
  const confidence = antiSpoofResult.combinedScore || antiSpoofResult.neuralNetworkScore || 0;
346
368
 
347
- if (isLive && confidence > Global.ANTI_SPOOF_CONFIDENCE_THRESHOLD) {
369
+ if (isLive && confidence > ANTI_SPOOF_CONFIDENCE_THRESHOLD) {
348
370
  state.antiSpoof.consecutiveLiveFrames = Math.min(
349
- Global.REQUIRED_CONSECUTIVE_LIVE_FRAMES,
371
+ REQUIRED_CONSECUTIVE_LIVE_FRAMES,
350
372
  state.antiSpoof.consecutiveLiveFrames + 1
351
373
  );
352
374
  } else {
353
375
  state.antiSpoof.consecutiveLiveFrames = Math.max(0, state.antiSpoof.consecutiveLiveFrames - 1);
354
376
  }
355
- state.antiSpoof.isLive = state.antiSpoof.consecutiveLiveFrames >= Global.REQUIRED_CONSECUTIVE_LIVE_FRAMES;
377
+ state.antiSpoof.isLive = state.antiSpoof.consecutiveLiveFrames >= REQUIRED_CONSECUTIVE_LIVE_FRAMES;
356
378
  state.antiSpoof.confidence = confidence;
357
379
 
358
380
  // Batch anti-spoof updates
359
- if (state.performance.batchCounter % Global.BATCH_UPDATE_THRESHOLD === 0) {
381
+ if (state.performance.batchCounter % BATCH_UPDATE_THRESHOLD === 0) {
360
382
  runOnAntiSpoof({
361
383
  isLive: state.antiSpoof.isLive,
362
384
  confidence: state.antiSpoof.confidence,
@@ -388,7 +410,7 @@ export const useFaceDetectionFrameProcessor = ({
388
410
  else if (newLivenessStep === 1) {
389
411
  const leftEye = face.leftEyeOpenProbability ?? 1;
390
412
  const rightEye = face.rightEyeOpenProbability ?? 1;
391
- const eyesClosed = leftEye < Global.BLINK_THRESHOLD && rightEye < Global.BLINK_THRESHOLD;
413
+ const eyesClosed = leftEye < BLINK_THRESHOLD && rightEye < BLINK_THRESHOLD;
392
414
 
393
415
  if (eyesClosed && !newEyeClosed) {
394
416
  newBlinkCount++;
@@ -398,7 +420,7 @@ export const useFaceDetectionFrameProcessor = ({
398
420
  newEyeClosed = false;
399
421
  }
400
422
 
401
- if (newBlinkCount >= Global.REQUIRED_BLINKS) {
423
+ if (newBlinkCount >= REQUIRED_BLINKS) {
402
424
  newLivenessStep = 2;
403
425
  runOnLiveness(newLivenessStep);
404
426
  }
@@ -412,7 +434,7 @@ export const useFaceDetectionFrameProcessor = ({
412
434
  } else {
413
435
  const dx = Math.abs(x - state.faceTracking.lastX);
414
436
  const dy = Math.abs(y - state.faceTracking.lastY);
415
- newStableCount = (dx < Global.FACE_MOVEMENT_THRESHOLD && dy < Global.FACE_MOVEMENT_THRESHOLD)
437
+ newStableCount = (dx < FACE_MOVEMENT_THRESHOLD && dy < FACE_MOVEMENT_THRESHOLD)
416
438
  ? state.faceTracking.stableCount + 1
417
439
  : 1;
418
440
  }
@@ -429,10 +451,10 @@ export const useFaceDetectionFrameProcessor = ({
429
451
  state.flags.eyeClosed = newEyeClosed;
430
452
  state.performance.batchCounter++;
431
453
 
432
- const progress = Math.min(100, (newStableCount / Global.FACE_STABILITY_THRESHOLD) * 100);
454
+ const progress = Math.min(100, (newStableCount / FACE_STABILITY_THRESHOLD) * 100);
433
455
 
434
456
  // Batch face updates
435
- if (state.performance.batchCounter % Global.BATCH_UPDATE_THRESHOLD === 0) {
457
+ if (state.performance.batchCounter % BATCH_UPDATE_THRESHOLD === 0) {
436
458
  runOnFaces(1, progress, newLivenessStep, state.flags.isFaceCentered, {
437
459
  isLive: state.antiSpoof.isLive,
438
460
  confidence: state.antiSpoof.confidence,
@@ -444,14 +466,14 @@ export const useFaceDetectionFrameProcessor = ({
444
466
 
445
467
  // Capture condition - optimized
446
468
  const shouldCapture = !state.flags.captured && (
447
- newStableCount >= Global.FACE_STABILITY_THRESHOLD &&
469
+ newStableCount >= FACE_STABILITY_THRESHOLD &&
448
470
  state.antiSpoof.isLive &&
449
- state.antiSpoof.consecutiveLiveFrames >= Global.REQUIRED_CONSECUTIVE_LIVE_FRAMES &&
471
+ state.antiSpoof.consecutiveLiveFrames >= REQUIRED_CONSECUTIVE_LIVE_FRAMES &&
450
472
  state.flags.isFaceCentered &&
451
473
  (localState.livenessLevel === 0 || (
452
474
  localState.livenessLevel === 1 &&
453
475
  newLivenessStep === 2 &&
454
- newBlinkCount >= Global.REQUIRED_BLINKS
476
+ newBlinkCount >= REQUIRED_BLINKS
455
477
  ))
456
478
  );
457
479
 
@@ -42,27 +42,5 @@ export class Global {
42
42
  format: 'JPEG', // 'PNG' or 'JPEG'
43
43
  quality: 85, // 0–100
44
44
  };
45
- // Optimized constants - tuned for performance
46
- static FACE_STABILITY_THRESHOLD = 3;
47
- static FACE_MOVEMENT_THRESHOLD = 15;
48
- static FRAME_PROCESSOR_MIN_INTERVAL_MS = 500;
49
- static MIN_FACE_SIZE = 0.2;
50
-
51
- // Blink detection
52
- static BLINK_THRESHOLD = 0.3;
53
- static REQUIRED_BLINKS = 3;
54
-
55
- // Anti-spoofing
56
- static ANTI_SPOOF_CONFIDENCE_THRESHOLD = 0.7;
57
- static REQUIRED_CONSECUTIVE_LIVE_FRAMES = 3;
58
-
59
- // Face centering
60
- static FACE_CENTER_THRESHOLD_X = 0.2;
61
- static FACE_CENTER_THRESHOLD_Y = 0.15;
62
- static MIN_FACE_CENTERED_FRAMES = 2;
63
-
64
- // Performance optimization constants
65
- static MAX_FRAME_PROCESSING_TIME_MS = 500;
66
- static BATCH_UPDATE_THRESHOLD = 3;
67
45
 
68
46
  }