@daboss2003/liveness-web 1.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 ADDED
@@ -0,0 +1,72 @@
1
+ # @daboss2003/liveness-web
2
+
3
+ Lightweight web liveness detection using MediaPipe Face Landmarker (CDN). The SDK provides the full UI: oval face frame, camera, and step progress. You only supply callbacks.
4
+
5
+ ## Install
6
+
7
+ ```
8
+ npm install @daboss2003/liveness-web
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { startLiveness } from "@daboss2003/liveness-web";
15
+
16
+ startLiveness({
17
+ container: document.getElementById("root"), // optional; defaults to document.body
18
+ callbacks: {
19
+ onSuccess(imageBase64) {
20
+ console.log("Verified", imageBase64.length);
21
+ },
22
+ onFailure(reason) {
23
+ console.error(reason);
24
+ },
25
+ onChallengeChanged(stepIndex, stepLabel) {
26
+ console.log(`Step ${stepIndex + 1}: ${stepLabel}`);
27
+ },
28
+ },
29
+ });
30
+ ```
31
+
32
+ - **Auto-start:** Verification starts as soon as `startLiveness` is called (no Start button).
33
+ - **Runs until complete:** The flow continues until the user passes all steps or a hard error occurs. Wrong poses do not stop the session; the user can keep trying until they get each step right.
34
+ - **No timeouts:** Steps are not timed out.
35
+ - **Progress:** The oval border fills by segment as each step is completed (5 steps total).
36
+
37
+ To cancel and release the camera:
38
+
39
+ ```ts
40
+ import { stop } from "@daboss2003/liveness-web";
41
+ stop();
42
+ ```
43
+
44
+ ## Errors (CDN / connectivity)
45
+
46
+ When CDN or connectivity fails, `onFailure` is called with a string you can compare to exported constants:
47
+
48
+ - **`LIVENESS_ERROR_CDN_NOT_AVAILABLE`** (`"cdnNotAvailable"`) — CDN/assets unavailable after retries; internet was confirmed. Your app can fall back to a normal camera flow (e.g. capture without liveness).
49
+ - **`LIVENESS_ERROR_OFFLINE`** (`"offline"`) — No internet connection (e.g. user is offline).
50
+
51
+ Example:
52
+
53
+ ```ts
54
+ import { startLiveness, LIVENESS_ERROR_CDN_NOT_AVAILABLE, isCdnNotAvailableError } from "@daboss2003/liveness-web";
55
+
56
+ startLiveness({
57
+ callbacks: {
58
+ onFailure(reason) {
59
+ if (isCdnNotAvailableError(reason)) {
60
+ // Fall back to normal camera flow
61
+ return;
62
+ }
63
+ console.error(reason);
64
+ },
65
+ },
66
+ });
67
+ ```
68
+
69
+ ## Notes
70
+
71
+ - Uses MediaPipe Tasks Vision Web from CDN.
72
+ - Camera permission is required in the browser.
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_SOUND_DATA_URLS: Record<string, string>;