react-native-biometric-verifier 0.0.62 → 0.0.64
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/.gitattributes +2 -0
- package/LICENSE +21 -0
- package/README.md +106 -18
- package/package.json +10 -2
- package/src/components/CaptureImageWithoutEdit.js +4 -4
- package/src/hooks/useFaceDetectionFrameProcessor.js +7 -3
package/.gitattributes
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
JESCON TECHNOLOGIES PVT LTD License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 PRAFULDAS M M
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,28 +1,116 @@
|
|
|
1
1
|
# React Native Biometric Verifier
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A powerful and easy-to-use React Native module for biometric verification, featuring face recognition and QR code scanning capabilities with location validation.
|
|
4
|
+
|
|
4
5
|
|
|
5
6
|
## Features
|
|
6
7
|
|
|
7
|
-
- Face
|
|
8
|
-
- QR
|
|
9
|
-
- Location
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
- Customizable notification system
|
|
13
|
-
- Comprehensive error handling
|
|
8
|
+
- **Face Recognition**: Capture and verify user identity via face scan.
|
|
9
|
+
- **QR Code Scanning**: specialized mode for location verification using QR codes.
|
|
10
|
+
- **Location Validation**: Verify user presence within a specific geofence.
|
|
11
|
+
- **Liveness Detection**: Configurable liveness and anti-spoofing checks.
|
|
12
|
+
- **Customizable UI**: Animations, countdown timers, and feedback notifications.
|
|
14
13
|
|
|
15
14
|
## Installation
|
|
16
15
|
|
|
17
16
|
```bash
|
|
18
17
|
npm install react-native-biometric-verifier
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Peer Dependencies
|
|
21
|
+
|
|
22
|
+
This library relies on several peer dependencies that you must install in your project:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install react-native-vector-icons react-native-geolocation-service react-native-image-resizer react-native-fs prop-types
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Platform Configuration
|
|
29
|
+
|
|
30
|
+
#### iOS
|
|
31
|
+
Add the following keys to your `Info.plist` file to request camera and location permissions:
|
|
32
|
+
|
|
33
|
+
```xml
|
|
34
|
+
<key>NSCameraUsageDescription</key>
|
|
35
|
+
<string>We need access to your camera for biometric verification</string>
|
|
36
|
+
<key>NSLocationWhenInUseUsageDescription</key>
|
|
37
|
+
<string>We need your location to verify your presence at the designated area</string>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Android
|
|
41
|
+
Add the following permissions to your `AndroidManifest.xml`:
|
|
42
|
+
|
|
43
|
+
```xml
|
|
44
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
45
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
46
|
+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
Import the `BiometricModal` component and standard React hooks.
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
import React, { useState } from 'react';
|
|
55
|
+
import { View, Button } from 'react-native';
|
|
56
|
+
import BiometricModal from 'react-native-biometric-verifier';
|
|
57
|
+
|
|
58
|
+
const App = () => {
|
|
59
|
+
const [isVerifierOpen, setIsVerifierOpen] = useState(false);
|
|
60
|
+
|
|
61
|
+
const handleVerificationComplete = (data) => {
|
|
62
|
+
console.log('Verification Success:', data);
|
|
63
|
+
// Handle success (e.g., navigate to next screen, show success message)
|
|
64
|
+
setIsVerifierOpen(false);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
69
|
+
<Button title="Start Verification" onPress={() => setIsVerifierOpen(true)} />
|
|
70
|
+
|
|
71
|
+
{isVerifierOpen && (
|
|
72
|
+
<BiometricModal
|
|
73
|
+
data="USER_UNIQUE_ID" // e.g., Employee ID or Face ID
|
|
74
|
+
depKey="DEPARTMENT_KEY" // Optional: for QR location validation
|
|
75
|
+
apiurl="https://your-api-endpoint.com/"
|
|
76
|
+
onclose={(val) => setIsVerifierOpen(val)}
|
|
77
|
+
callback={handleVerificationComplete}
|
|
78
|
+
// Optional Props
|
|
79
|
+
qrscan={false} // Set to true to enable QR scan mode first
|
|
80
|
+
duration={100} // Countdown duration in seconds
|
|
81
|
+
MaxDistanceMeters={30} // Allowed radius for location verification
|
|
82
|
+
frameProcessorFps={5}
|
|
83
|
+
livenessLevel="high"
|
|
84
|
+
antispooflevel="high"
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
</View>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default App;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Props
|
|
95
|
+
|
|
96
|
+
| Prop | Type | Required | Description | Default |
|
|
97
|
+
|------|------|----------|-------------|---------|
|
|
98
|
+
| `apiurl` | string | Yes | Base URL for the verification backend API. | - |
|
|
99
|
+
| `data` | string | Yes | Unique identifier for the user (e.g., Face ID, User ID). | - |
|
|
100
|
+
| `onclose` | function | Yes | Callback function to close the modal. | - |
|
|
101
|
+
| `callback` | function | Yes | Callback function returning successful verification data. | - |
|
|
102
|
+
| `qrscan` | boolean | No | If `true`, starts with QR code scanning mode. | `false` |
|
|
103
|
+
| `depKey` | string | No | Key used to validate the QR code content. | - |
|
|
104
|
+
| `duration` | number | No | Timeout duration for the session in seconds. | `100` |
|
|
105
|
+
| `MaxDistanceMeters` | number | No | Maximum allowed distance (meters) for location check. | `30` |
|
|
106
|
+
| `frameProcessorFps` | number | No | Frames per second for image processing. | - |
|
|
107
|
+
| `livenessLevel` | string | No | Liveness detection strictness. | - |
|
|
108
|
+
| `antispooflevel` | string | No | Anti-spoofing strictness. | - |
|
|
109
|
+
|
|
110
|
+
## Contributing
|
|
111
|
+
|
|
112
|
+
Contributions are welcome! Please open an issue or submit a pull request for any bugs or improvements.
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
JESCON TECHNOLOGIES PVT LTD
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-biometric-verifier",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.64",
|
|
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
|
"scripts": {
|
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
],
|
|
16
16
|
"author": "PRAFULDAS M M",
|
|
17
17
|
"license": "JESCON TECHNOLOGIES PVT LTD",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/dpraful/react-native-biometric-verifier.git"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/dpraful/react-native-biometric-verifier#readme",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/dpraful/react-native-biometric-verifier/issues"
|
|
25
|
+
},
|
|
18
26
|
"peerDependencies": {
|
|
19
27
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
20
28
|
"react-native": ">=0.60.0",
|
|
@@ -29,4 +37,4 @@
|
|
|
29
37
|
"react": "^18.0.0",
|
|
30
38
|
"react-native": "^0.69.0"
|
|
31
39
|
}
|
|
32
|
-
}
|
|
40
|
+
}
|
|
@@ -545,17 +545,17 @@ const CaptureImageWithoutEdit = React.memo(
|
|
|
545
545
|
{isFaceCentered && (
|
|
546
546
|
<View style={styles.confidenceContainer}>
|
|
547
547
|
<Text style={styles.confidenceText}>
|
|
548
|
-
Confidence: {Math.round(antiSpoofConfidence *
|
|
548
|
+
Confidence: {Math.round(antiSpoofConfidence * 100)}%
|
|
549
549
|
</Text>
|
|
550
550
|
<View style={styles.confidenceBar}>
|
|
551
551
|
<View
|
|
552
552
|
style={[
|
|
553
553
|
styles.confidenceProgress,
|
|
554
554
|
{
|
|
555
|
-
width: `${antiSpoofConfidence *
|
|
556
|
-
backgroundColor: antiSpoofConfidence >
|
|
555
|
+
width: `${antiSpoofConfidence * 100}%`,
|
|
556
|
+
backgroundColor: antiSpoofConfidence * 100 > 40
|
|
557
557
|
? Global.AppTheme.success
|
|
558
|
-
: antiSpoofConfidence >
|
|
558
|
+
: antiSpoofConfidence * 100 > 20
|
|
559
559
|
? Global.AppTheme.warning
|
|
560
560
|
: Global.AppTheme.error
|
|
561
561
|
}
|
|
@@ -29,6 +29,7 @@ const MIN_FACE_CENTERED_FRAMES = 2;
|
|
|
29
29
|
// Performance optimization constants
|
|
30
30
|
const MAX_FRAME_PROCESSING_TIME_MS = 500;
|
|
31
31
|
const BATCH_UPDATE_THRESHOLD = 3;
|
|
32
|
+
const REAL_LAPLACIAN_THRESHOLD = 3500;
|
|
32
33
|
|
|
33
34
|
export const useFaceDetectionFrameProcessor = ({
|
|
34
35
|
onStableFaceDetected = () => { },
|
|
@@ -39,7 +40,7 @@ export const useFaceDetectionFrameProcessor = ({
|
|
|
39
40
|
isLoading = false,
|
|
40
41
|
isActive = true,
|
|
41
42
|
livenessLevel,
|
|
42
|
-
antispooflevel =
|
|
43
|
+
antispooflevel = 0.35,
|
|
43
44
|
}) => {
|
|
44
45
|
const { detectFaces } = useFaceDetector({
|
|
45
46
|
performanceMode: 'fast',
|
|
@@ -247,6 +248,7 @@ export const useFaceDetectionFrameProcessor = ({
|
|
|
247
248
|
);
|
|
248
249
|
});
|
|
249
250
|
|
|
251
|
+
|
|
250
252
|
// Optimized frame processor
|
|
251
253
|
const frameProcessor = useFrameProcessor(
|
|
252
254
|
(frame) => {
|
|
@@ -363,9 +365,11 @@ export const useFaceDetectionFrameProcessor = ({
|
|
|
363
365
|
if (antiSpoofResult != null) {
|
|
364
366
|
state.antiSpoof.lastResult = antiSpoofResult;
|
|
365
367
|
|
|
366
|
-
const confidence =
|
|
368
|
+
const { laplacianScore = 0, confidence = 0, combinedScore = 0 } = antiSpoofResult;
|
|
367
369
|
|
|
368
|
-
if (
|
|
370
|
+
if (laplacianScore > REAL_LAPLACIAN_THRESHOLD &&
|
|
371
|
+
confidence > antispooflevel &&
|
|
372
|
+
combinedScore > antispooflevel) {
|
|
369
373
|
state.antiSpoof.consecutiveLiveFrames = Math.min(
|
|
370
374
|
REQUIRED_CONSECUTIVE_LIVE_FRAMES,
|
|
371
375
|
state.antiSpoof.consecutiveLiveFrames + 1
|