react-native-biometric-verifier 0.0.65 → 0.0.67
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 +212 -75
- package/package.json +1 -1
- package/src/components/CaptureImageWithoutEdit.js +186 -100
- package/src/hooks/useFaceDetectionFrameProcessor.js +207 -620
package/README.md
CHANGED
|
@@ -1,116 +1,253 @@
|
|
|
1
1
|
# React Native Biometric Verifier
|
|
2
|
-
|
|
3
|
-
A
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
|
|
3
|
+
A beginner-friendly React Native package for biometric verification with camera-based face recognition, optional QR-based location validation, and liveness checks.
|
|
4
|
+
|
|
5
|
+
This component is built so any React Native app can securely verify a user by combining:
|
|
6
|
+
- Face scan
|
|
7
|
+
- GPS location check
|
|
8
|
+
- QR metadata validation
|
|
9
|
+
- Liveness / anti-spoof detection
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## ✅ What this package does
|
|
14
|
+
|
|
15
|
+
- Opens a verification modal with camera preview.
|
|
16
|
+
- Detects and captures a single face using the front camera.
|
|
17
|
+
- Optionally scans a QR code first to validate location.
|
|
18
|
+
- Uses GPS to confirm the user is within a valid radius.
|
|
19
|
+
- Sends face image data to a backend API for recognition.
|
|
20
|
+
- Displays status messages, countdown timer, and success/error feedback.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🔧 Features
|
|
25
|
+
|
|
26
|
+
- Face recognition workflow
|
|
27
|
+
- QR-based location verification
|
|
28
|
+
- Distance check using GPS coordinates
|
|
29
|
+
- Liveness and anti-spoof checks
|
|
30
|
+
- Countdown timer for verification sessions
|
|
31
|
+
- Animated notifications and progress state
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🚀 Installation
|
|
36
|
+
|
|
16
37
|
```bash
|
|
17
38
|
npm install react-native-biometric-verifier
|
|
18
39
|
```
|
|
19
|
-
|
|
20
|
-
###
|
|
21
|
-
|
|
22
|
-
This library relies on several peer dependencies that you must install in your project:
|
|
23
|
-
|
|
40
|
+
|
|
41
|
+
### Required peer dependencies
|
|
42
|
+
|
|
24
43
|
```bash
|
|
25
44
|
npm install react-native-vector-icons react-native-geolocation-service react-native-image-resizer react-native-fs prop-types
|
|
26
45
|
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
|
|
47
|
+
> The package also depends on native camera and vision packages internally. Make sure your app is configured for camera access.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 📱 Platform setup
|
|
52
|
+
|
|
53
|
+
### iOS
|
|
54
|
+
Add these keys to `Info.plist`:
|
|
55
|
+
|
|
33
56
|
```xml
|
|
34
57
|
<key>NSCameraUsageDescription</key>
|
|
35
|
-
<string>We need access to your camera for biometric verification
|
|
58
|
+
<string>We need access to your camera for biometric verification.</string>
|
|
36
59
|
<key>NSLocationWhenInUseUsageDescription</key>
|
|
37
|
-
<string>We need your location to verify your presence at the designated area
|
|
60
|
+
<string>We need your location to verify your presence at the designated area.</string>
|
|
38
61
|
```
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Add
|
|
42
|
-
|
|
62
|
+
|
|
63
|
+
### Android
|
|
64
|
+
Add these permissions to `AndroidManifest.xml`:
|
|
65
|
+
|
|
43
66
|
```xml
|
|
44
67
|
<uses-permission android:name="android.permission.CAMERA" />
|
|
45
68
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
46
69
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
47
70
|
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 📘 Basic Usage
|
|
75
|
+
|
|
53
76
|
```javascript
|
|
54
77
|
import React, { useState } from 'react';
|
|
55
78
|
import { View, Button } from 'react-native';
|
|
56
79
|
import BiometricModal from 'react-native-biometric-verifier';
|
|
57
|
-
|
|
58
|
-
const App = () => {
|
|
80
|
+
|
|
81
|
+
const App = ({ navigation }) => {
|
|
59
82
|
const [isVerifierOpen, setIsVerifierOpen] = useState(false);
|
|
60
|
-
|
|
61
|
-
const handleVerificationComplete = (
|
|
62
|
-
console.log('Verification
|
|
63
|
-
// Handle success (e.g., navigate to next screen, show success message)
|
|
83
|
+
|
|
84
|
+
const handleVerificationComplete = (result) => {
|
|
85
|
+
console.log('Verification successful:', result);
|
|
64
86
|
setIsVerifierOpen(false);
|
|
65
87
|
};
|
|
66
|
-
|
|
88
|
+
|
|
67
89
|
return (
|
|
68
90
|
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
69
91
|
<Button title="Start Verification" onPress={() => setIsVerifierOpen(true)} />
|
|
70
|
-
|
|
92
|
+
|
|
71
93
|
{isVerifierOpen && (
|
|
72
94
|
<BiometricModal
|
|
73
|
-
data="USER_UNIQUE_ID"
|
|
74
|
-
depKey="DEPARTMENT_KEY" // Optional: for QR location validation
|
|
95
|
+
data="USER_UNIQUE_ID"
|
|
75
96
|
apiurl="https://your-api-endpoint.com/"
|
|
76
|
-
|
|
97
|
+
navigation={navigation}
|
|
98
|
+
onclose={(open) => setIsVerifierOpen(open)}
|
|
77
99
|
callback={handleVerificationComplete}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
MaxDistanceMeters={30} // Allowed radius for location verification
|
|
100
|
+
qrscan={false}
|
|
101
|
+
duration={100}
|
|
102
|
+
MaxDistanceMeters={30}
|
|
82
103
|
frameProcessorFps={5}
|
|
83
|
-
livenessLevel=
|
|
84
|
-
antispooflevel=
|
|
104
|
+
livenessLevel={1}
|
|
105
|
+
antispooflevel={0.35}
|
|
85
106
|
/>
|
|
86
107
|
)}
|
|
87
108
|
</View>
|
|
88
109
|
);
|
|
89
110
|
};
|
|
90
|
-
|
|
111
|
+
|
|
91
112
|
export default App;
|
|
92
113
|
```
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
114
|
+
|
|
115
|
+
> `navigation` is required because the component may call `navigation.goBack()` when the verification timer expires.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🧠 How the verification flow works
|
|
120
|
+
|
|
121
|
+
The component supports two main flows:
|
|
122
|
+
|
|
123
|
+
1. **Face verification only** (`qrscan={false}`)
|
|
124
|
+
- Open the front camera.
|
|
125
|
+
- Detect a single centered face.
|
|
126
|
+
- Optionally perform liveness checks.
|
|
127
|
+
- Capture the face image.
|
|
128
|
+
- Send the image to the backend API.
|
|
129
|
+
|
|
130
|
+
2. **QR + face verification** (`qrscan={true}`)
|
|
131
|
+
- Open the back camera.
|
|
132
|
+
- Scan a QR code containing `latitude,longitude,depKey`.
|
|
133
|
+
- Request current device GPS location.
|
|
134
|
+
- Verify the device is within `MaxDistanceMeters`.
|
|
135
|
+
- Verify the QR `depKey` matches the `depKey` prop.
|
|
136
|
+
- Continue to face verification after location validation.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 🌐 Workflow diagram
|
|
141
|
+
|
|
142
|
+
```mermaid
|
|
143
|
+
flowchart TD
|
|
144
|
+
A[Start Verification] --> B{qrscan === true?}
|
|
145
|
+
B -- Yes --> C[Scan QR Code]
|
|
146
|
+
B -- No --> F[Start Face Scan]
|
|
147
|
+
C --> D[Request Device Location]
|
|
148
|
+
D --> E[Compare distance and depKey]
|
|
149
|
+
E -- Valid --> F
|
|
150
|
+
E -- Invalid --> G[Show location error]
|
|
151
|
+
F --> H[Detect stable face & liveness]
|
|
152
|
+
H --> I[Capture photo]
|
|
153
|
+
I --> J[Upload to API]
|
|
154
|
+
J --> K{API response}
|
|
155
|
+
K -- Success --> L[Show success and callback]
|
|
156
|
+
K -- Fail --> M[Show failure message]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 📌 Props reference
|
|
162
|
+
|
|
96
163
|
| Prop | Type | Required | Description | Default |
|
|
97
164
|
|------|------|----------|-------------|---------|
|
|
98
|
-
| `apiurl` | string | Yes | Base URL for the verification backend
|
|
99
|
-
| `data` | string | Yes | Unique identifier
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
165
|
+
| `apiurl` | string | Yes | Base URL for the verification backend request. | - |
|
|
166
|
+
| `data` | string | Yes | Unique user identifier (employee ID, face ID, etc.). | - |
|
|
167
|
+
| `navigation` | object | Yes | React Navigation prop used for timeout navigation. | - |
|
|
168
|
+
| `onclose` | function | Yes | Called when the modal closes. Receives `false`. | - |
|
|
169
|
+
| `callback` | function | Yes | Called after successful verification with result data. | - |
|
|
170
|
+
| `qrscan` | boolean | No | Start with QR scan mode. | `false` |
|
|
171
|
+
| `depKey` | string | No | Expected key inside the scanned QR payload. | - |
|
|
172
|
+
| `duration` | number | No | Countdown length in seconds. | `100` |
|
|
173
|
+
| `MaxDistanceMeters` | number | No | Allowed GPS distance radius in meters. | `30` |
|
|
174
|
+
| `frameProcessorFps` | number | No | Camera frame processor FPS. | `5` |
|
|
175
|
+
| `livenessLevel` | number | No | Liveness check mode: `0` or `1`. | `0` |
|
|
176
|
+
| `antispooflevel` | number | No | Anti-spoof threshold used internally. | `0.35` |
|
|
177
|
+
| `fileurl` | string | No | Optional file URL for displaying employee data. | - |
|
|
178
|
+
| `imageurl` | string | No | Optional image URL for display. | - |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 🧩 Example: face-only verification
|
|
183
|
+
|
|
184
|
+
```javascript
|
|
185
|
+
<BiometricModal
|
|
186
|
+
data="EMPLOYEE_123"
|
|
187
|
+
apiurl="https://your-api-endpoint.com/"
|
|
188
|
+
navigation={navigation}
|
|
189
|
+
onclose={(open) => setIsVerifierOpen(open)}
|
|
190
|
+
callback={handleVerificationComplete}
|
|
191
|
+
qrscan={false}
|
|
192
|
+
duration={90}
|
|
193
|
+
frameProcessorFps={4}
|
|
194
|
+
livenessLevel={0}
|
|
195
|
+
/>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## 🧭 Example: QR + face verification
|
|
199
|
+
|
|
200
|
+
```javascript
|
|
201
|
+
<BiometricModal
|
|
202
|
+
data="EMPLOYEE_123"
|
|
203
|
+
depKey="OFFICE_A"
|
|
204
|
+
apiurl="https://your-api-endpoint.com/"
|
|
205
|
+
navigation={navigation}
|
|
206
|
+
onclose={(open) => setIsVerifierOpen(open)}
|
|
207
|
+
callback={handleVerificationComplete}
|
|
208
|
+
qrscan={true}
|
|
209
|
+
duration={120}
|
|
210
|
+
MaxDistanceMeters={50}
|
|
211
|
+
frameProcessorFps={3}
|
|
212
|
+
livenessLevel={1}
|
|
213
|
+
antispooflevel={0.35}
|
|
214
|
+
/>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 🧱 Internal architecture
|
|
220
|
+
|
|
221
|
+
- `src/index.js` – Main `BiometricModal` component and verification flow.
|
|
222
|
+
- `src/components/CaptureImageWithoutEdit.js` – Camera capture, face detection, and QR scanning.
|
|
223
|
+
- `src/hooks/useFaceDetectionFrameProcessor.js` – Face liveness and anti-spoof frame processor.
|
|
224
|
+
- `src/hooks/useGeolocation.js` – Location permission and GPS fetch.
|
|
225
|
+
- `src/hooks/useImageProcessing.js` – Image resize and Base64 conversion.
|
|
226
|
+
- `src/hooks/useCountdown.js` – Countdown timer logic.
|
|
227
|
+
- `src/hooks/useNotifyMessage.js` – Animated notification messages.
|
|
228
|
+
- `src/utils/NetworkServiceCall.js` – API request helper.
|
|
229
|
+
- `src/utils/distanceCalculator.js` – Geolocation distance calculation.
|
|
230
|
+
- `src/utils/Global.js` – Shared constants and theme values.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## 💡 Interview talking points
|
|
235
|
+
|
|
236
|
+
- Explain the dual modes: face-only and QR-first.
|
|
237
|
+
- Describe how location validation prevents spoofing of presence.
|
|
238
|
+
- Mention the use of `use*` hooks for clean and reusable code.
|
|
239
|
+
- Highlight the flow from camera capture → Base64 conversion → API request → callback.
|
|
240
|
+
- Note the user-friendly UI with timer, notifications, and step indicator.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 🤝 Contribution
|
|
245
|
+
|
|
246
|
+
Contributions are welcome. Open an issue or submit a pull request for bug fixes and improvements.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 📄 License
|
|
251
|
+
|
|
116
252
|
JESCON TECHNOLOGIES PVT LTD
|
|
253
|
+
|
package/package.json
CHANGED