@richard.fadiora/liveness-detection 3.1.0 → 4.0.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 CHANGED
@@ -1,27 +1,31 @@
1
- # Liveness Detection Component
1
+ # Liveness Detection SDK
2
2
 
3
- A React-based liveness detection component that performs randomized user challenges and verifies real-user presence via a backend anti-spoofing API.
3
+ A cross-framework **liveness detection SDK** that performs randomized user challenges and verifies real-user presence via a backend anti-spoofing API. Works with **React** and **Angular** via framework-specific wrappers while the **core engine is framework-agnostic**.
4
4
 
5
- This version introduces **headless mode**, **render-prop customization**, and robust **challenge sequencing**, **configurable thresholds** for `Smile`, `Blink`, and `Turn_Head` challenges
5
+ This version introduces:
6
6
 
7
- Pause between steps for user feedback
8
-
9
- Sequential challenge execution with strict timeout handling allowing you to fully control the UI while keeping the verification logic encapsulated.
7
+ - **Headless mode** for fully custom UI
8
+ - Robust **challenge sequencing**
9
+ - **Configurable thresholds** for `Smile`, `Blink`, and `Turn_Head` challenges
10
+ - Sequential challenge execution with **strict timeout handling**
11
+ - Pause between steps for user feedback
12
+ - Cross-framework integration (React hook & Angular service)
10
13
 
11
14
  ---
12
15
 
13
16
  ## 📌 Overview
14
17
 
15
- This component strengthens identity verification by combining:
18
+ This SDK strengthens identity verification by combining:
16
19
 
17
20
  - Randomized challenge-response validation
21
+ - Sequential challenge execution
18
22
  - Strict timeout enforcement
19
23
  - Backend spoof detection
20
24
  - Callback-based integration for easy usage
21
- - Headless / fully customizable UI via render props
22
- - Configurable challenge thresholds to adapt difficulty
25
+ - Headless / fully customizable UI via render props (React)
26
+ - Configurable challenge thresholds
23
27
 
24
- It protects against:
28
+ Protects against:
25
29
 
26
30
  - Presentation (photo) attacks
27
31
  - Screen glare attacks
@@ -29,6 +33,29 @@ It protects against:
29
33
 
30
34
  ---
31
35
 
36
+ ## ⚙️ Architecture
37
+
38
+ ### Core Engine
39
+
40
+ - `LivenessEngine` (framework-agnostic)
41
+ - Handles:
42
+ - Challenge sequence generation
43
+ - MediaPipe face & hand model detection
44
+ - Challenge validation (`Smile`, `Blink`, `Turn_Head`, `Thumbs_Up`)
45
+ - Face cropping
46
+ - Detection loop
47
+ - Final frame capture and backend verification
48
+ - Can be used directly or via React/Angular wrappers
49
+
50
+ ### Framework Wrappers
51
+
52
+ | Framework | Wrapper | Notes |
53
+ |-----------|--------|------|
54
+ | React | `useLiveness` hook | Uses `webcamRef` and React state, supports render-prop customization |
55
+ | Angular | `LivenessService` | Injectable service, exposes engine state and control methods |
56
+
57
+ ---
58
+
32
59
  ## ⚙️ How It Works
33
60
 
34
61
  ### 1️⃣ Challenge Initialization
@@ -133,6 +160,25 @@ export default App;
133
160
  )}
134
161
  />
135
162
  ```
163
+ ## 📤 Hook Return Values
164
+
165
+ The `useLiveness` hook exposes the following values and control functions for managing the liveness detection session.
166
+
167
+ | Name | Type | Description |
168
+ |-----|------|-------------|
169
+ | `webcamRef` | `ref` | React ref attached to the webcam component. Provides access to the live video stream used for face and hand detection as well as frame capture for verification. |
170
+ | `status` | `string` | Represents the current state of the liveness session. Possible values include `loading`, `ready`, `capturing`, `verifying`, `success`, `error`, and `expired`. |
171
+ | `errorMsg` | `string` | Contains the error message displayed when the liveness verification fails or when the system encounters an issue. |
172
+ | `sequence` | `string[]` | The randomized sequence of liveness challenges selected for the current session. Three challenges are chosen from the challenge pool. |
173
+ | `currentStep` | `number` | The index of the current challenge being performed within the challenge sequence. |
174
+ | `timeLeft` | `number` | Remaining time (in seconds) before the session expires. The timer runs while the system is in the `capturing` state. |
175
+ | `isStepTransitioning` | `boolean` | Indicates whether the system is currently transitioning between challenges. Used to briefly pause detection and provide UI feedback after a challenge is completed. |
176
+ | `start` | `function` | Starts the liveness challenge session and begins the detection loop. |
177
+ | `reset` | `function` | Resets the entire session, including the timer, challenge sequence, step index, and error state. |
178
+ | `sendFinalProof` | `function` | Sends captured face frames to the backend verification API to perform the final liveness check. Normally triggered automatically after the last challenge is completed. |
179
+
180
+
181
+
136
182
 
137
183
  ---
138
184