@richard.fadiora/liveness-detection 1.0.4 → 2.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/dist/index.es.js +279 -203
- package/dist/index.umd.js +4 -4
- package/package.json +2 -1
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import se, { useRef as q, useState as _, useEffect as H } from "react";
|
|
2
2
|
import ae from "react-webcam";
|
|
3
|
-
var
|
|
3
|
+
var X = { exports: {} }, N = {};
|
|
4
4
|
/**
|
|
5
5
|
* @license React
|
|
6
6
|
* react-jsx-runtime.production.js
|
|
@@ -10,29 +10,29 @@ var G = { exports: {} }, O = {};
|
|
|
10
10
|
* This source code is licensed under the MIT license found in the
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
12
|
*/
|
|
13
|
-
var
|
|
13
|
+
var re;
|
|
14
14
|
function ie() {
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
var d = Symbol.for("react.transitional.element"),
|
|
18
|
-
function
|
|
19
|
-
var
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
for (var
|
|
23
|
-
|
|
24
|
-
} else
|
|
25
|
-
return
|
|
15
|
+
if (re) return N;
|
|
16
|
+
re = 1;
|
|
17
|
+
var d = Symbol.for("react.transitional.element"), p = Symbol.for("react.fragment");
|
|
18
|
+
function f(s, n, c) {
|
|
19
|
+
var v = null;
|
|
20
|
+
if (c !== void 0 && (v = "" + c), n.key !== void 0 && (v = "" + n.key), "key" in n) {
|
|
21
|
+
c = {};
|
|
22
|
+
for (var g in n)
|
|
23
|
+
g !== "key" && (c[g] = n[g]);
|
|
24
|
+
} else c = n;
|
|
25
|
+
return n = c.ref, {
|
|
26
26
|
$$typeof: d,
|
|
27
|
-
type:
|
|
28
|
-
key:
|
|
29
|
-
ref:
|
|
30
|
-
props:
|
|
27
|
+
type: s,
|
|
28
|
+
key: v,
|
|
29
|
+
ref: n !== void 0 ? n : null,
|
|
30
|
+
props: c
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
return N.Fragment = p, N.jsx = f, N.jsxs = f, N;
|
|
34
34
|
}
|
|
35
|
-
var
|
|
35
|
+
var I = {};
|
|
36
36
|
/**
|
|
37
37
|
* @license React
|
|
38
38
|
* react-jsx-runtime.development.js
|
|
@@ -42,44 +42,44 @@ var P = {};
|
|
|
42
42
|
* This source code is licensed under the MIT license found in the
|
|
43
43
|
* LICENSE file in the root directory of this source tree.
|
|
44
44
|
*/
|
|
45
|
-
var
|
|
45
|
+
var te;
|
|
46
46
|
function le() {
|
|
47
|
-
return
|
|
47
|
+
return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
|
|
48
48
|
function d(e) {
|
|
49
49
|
if (e == null) return null;
|
|
50
50
|
if (typeof e == "function")
|
|
51
|
-
return e.$$typeof ===
|
|
51
|
+
return e.$$typeof === u ? null : e.displayName || e.name || null;
|
|
52
52
|
if (typeof e == "string") return e;
|
|
53
53
|
switch (e) {
|
|
54
|
-
case
|
|
54
|
+
case x:
|
|
55
55
|
return "Fragment";
|
|
56
|
-
case
|
|
56
|
+
case S:
|
|
57
57
|
return "Profiler";
|
|
58
|
-
case
|
|
58
|
+
case w:
|
|
59
59
|
return "StrictMode";
|
|
60
|
-
case
|
|
60
|
+
case W:
|
|
61
61
|
return "Suspense";
|
|
62
|
-
case
|
|
62
|
+
case $:
|
|
63
63
|
return "SuspenseList";
|
|
64
|
-
case
|
|
64
|
+
case V:
|
|
65
65
|
return "Activity";
|
|
66
66
|
}
|
|
67
67
|
if (typeof e == "object")
|
|
68
68
|
switch (typeof e.tag == "number" && console.error(
|
|
69
69
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
70
70
|
), e.$$typeof) {
|
|
71
|
-
case
|
|
71
|
+
case k:
|
|
72
72
|
return "Portal";
|
|
73
|
-
case
|
|
73
|
+
case M:
|
|
74
74
|
return e.displayName || "Context";
|
|
75
|
-
case
|
|
75
|
+
case Y:
|
|
76
76
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
77
|
-
case
|
|
77
|
+
case P:
|
|
78
78
|
var r = e.render;
|
|
79
79
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
80
|
-
case
|
|
80
|
+
case z:
|
|
81
81
|
return r = e.displayName || null, r !== null ? r : d(e.type) || "Memo";
|
|
82
|
-
case
|
|
82
|
+
case C:
|
|
83
83
|
r = e._payload, e = e._init;
|
|
84
84
|
try {
|
|
85
85
|
return d(e(r));
|
|
@@ -88,29 +88,29 @@ function le() {
|
|
|
88
88
|
}
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function p(e) {
|
|
92
92
|
return "" + e;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function f(e) {
|
|
95
95
|
try {
|
|
96
|
-
|
|
96
|
+
p(e);
|
|
97
97
|
var r = !1;
|
|
98
98
|
} catch {
|
|
99
99
|
r = !0;
|
|
100
100
|
}
|
|
101
101
|
if (r) {
|
|
102
102
|
r = console;
|
|
103
|
-
var
|
|
104
|
-
return
|
|
103
|
+
var o = r.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
104
|
+
return o.call(
|
|
105
105
|
r,
|
|
106
106
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
107
|
-
|
|
108
|
-
),
|
|
107
|
+
i
|
|
108
|
+
), p(e);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
if (e ===
|
|
113
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
111
|
+
function s(e) {
|
|
112
|
+
if (e === x) return "<>";
|
|
113
|
+
if (typeof e == "object" && e !== null && e.$$typeof === C)
|
|
114
114
|
return "<...>";
|
|
115
115
|
try {
|
|
116
116
|
var r = d(e);
|
|
@@ -119,49 +119,49 @@ function le() {
|
|
|
119
119
|
return "<...>";
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
var e =
|
|
122
|
+
function n() {
|
|
123
|
+
var e = R.A;
|
|
124
124
|
return e === null ? null : e.getOwner();
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function c() {
|
|
127
127
|
return Error("react-stack-top-frame");
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
if (
|
|
129
|
+
function v(e) {
|
|
130
|
+
if (E.call(e, "key")) {
|
|
131
131
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
132
132
|
if (r && r.isReactWarning) return !1;
|
|
133
133
|
}
|
|
134
134
|
return e.key !== void 0;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
function
|
|
138
|
-
|
|
136
|
+
function g(e, r) {
|
|
137
|
+
function o() {
|
|
138
|
+
y || (y = !0, console.error(
|
|
139
139
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
140
140
|
r
|
|
141
141
|
));
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
get:
|
|
143
|
+
o.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
144
|
+
get: o,
|
|
145
145
|
configurable: !0
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function L() {
|
|
149
149
|
var e = d(this.type);
|
|
150
|
-
return
|
|
150
|
+
return Z[e] || (Z[e] = !0, console.error(
|
|
151
151
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
152
152
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
var
|
|
154
|
+
function a(e, r, o, i, D, B) {
|
|
155
|
+
var l = o.ref;
|
|
156
156
|
return e = {
|
|
157
|
-
$$typeof:
|
|
157
|
+
$$typeof: O,
|
|
158
158
|
type: e,
|
|
159
159
|
key: r,
|
|
160
|
-
props:
|
|
161
|
-
_owner:
|
|
162
|
-
}, (
|
|
160
|
+
props: o,
|
|
161
|
+
_owner: i
|
|
162
|
+
}, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
|
|
163
163
|
enumerable: !1,
|
|
164
|
-
get:
|
|
164
|
+
get: L
|
|
165
165
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
166
166
|
configurable: !1,
|
|
167
167
|
enumerable: !1,
|
|
@@ -176,213 +176,265 @@ function le() {
|
|
|
176
176
|
configurable: !1,
|
|
177
177
|
enumerable: !1,
|
|
178
178
|
writable: !0,
|
|
179
|
-
value:
|
|
179
|
+
value: D
|
|
180
180
|
}), Object.defineProperty(e, "_debugTask", {
|
|
181
181
|
configurable: !1,
|
|
182
182
|
enumerable: !1,
|
|
183
183
|
writable: !0,
|
|
184
|
-
value:
|
|
184
|
+
value: B
|
|
185
185
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
186
186
|
}
|
|
187
|
-
function
|
|
188
|
-
var
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
if (
|
|
192
|
-
for (
|
|
193
|
-
|
|
194
|
-
Object.freeze && Object.freeze(
|
|
187
|
+
function m(e, r, o, i, D, B) {
|
|
188
|
+
var l = r.children;
|
|
189
|
+
if (l !== void 0)
|
|
190
|
+
if (i)
|
|
191
|
+
if (h(l)) {
|
|
192
|
+
for (i = 0; i < l.length; i++)
|
|
193
|
+
F(l[i]);
|
|
194
|
+
Object.freeze && Object.freeze(l);
|
|
195
195
|
} else
|
|
196
196
|
console.error(
|
|
197
197
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
198
198
|
);
|
|
199
|
-
else
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
var
|
|
203
|
-
return
|
|
199
|
+
else F(l);
|
|
200
|
+
if (E.call(r, "key")) {
|
|
201
|
+
l = d(e);
|
|
202
|
+
var A = Object.keys(r).filter(function(oe) {
|
|
203
|
+
return oe !== "key";
|
|
204
204
|
});
|
|
205
|
-
|
|
205
|
+
i = 0 < A.length ? "{key: someKey, " + A.join(": ..., ") + ": ...}" : "{key: someKey}", ee[l + i] || (A = 0 < A.length ? "{" + A.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
206
206
|
`A props object containing a "key" prop is being spread into JSX:
|
|
207
207
|
let props = %s;
|
|
208
208
|
<%s {...props} />
|
|
209
209
|
React keys must be passed directly to JSX without using spread:
|
|
210
210
|
let props = %s;
|
|
211
211
|
<%s key={someKey} {...props} />`,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
),
|
|
212
|
+
i,
|
|
213
|
+
l,
|
|
214
|
+
A,
|
|
215
|
+
l
|
|
216
|
+
), ee[l + i] = !0);
|
|
217
217
|
}
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
for (var
|
|
221
|
-
|
|
222
|
-
} else
|
|
223
|
-
return
|
|
224
|
-
|
|
218
|
+
if (l = null, o !== void 0 && (f(o), l = "" + o), v(r) && (f(r.key), l = "" + r.key), "key" in r) {
|
|
219
|
+
o = {};
|
|
220
|
+
for (var G in r)
|
|
221
|
+
G !== "key" && (o[G] = r[G]);
|
|
222
|
+
} else o = r;
|
|
223
|
+
return l && g(
|
|
224
|
+
o,
|
|
225
225
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
226
|
-
),
|
|
226
|
+
), a(
|
|
227
227
|
e,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
228
|
+
l,
|
|
229
|
+
o,
|
|
230
|
+
n(),
|
|
231
|
+
D,
|
|
232
|
+
B
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
|
|
235
|
+
function F(e) {
|
|
236
|
+
T(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === C && (e._payload.status === "fulfilled" ? T(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
237
237
|
}
|
|
238
|
-
function
|
|
239
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
238
|
+
function T(e) {
|
|
239
|
+
return typeof e == "object" && e !== null && e.$$typeof === O;
|
|
240
240
|
}
|
|
241
|
-
var
|
|
241
|
+
var b = se, O = Symbol.for("react.transitional.element"), k = Symbol.for("react.portal"), x = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), Y = Symbol.for("react.consumer"), M = Symbol.for("react.context"), P = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), $ = Symbol.for("react.suspense_list"), z = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), V = Symbol.for("react.activity"), u = Symbol.for("react.client.reference"), R = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, E = Object.prototype.hasOwnProperty, h = Array.isArray, j = console.createTask ? console.createTask : function() {
|
|
242
242
|
return null;
|
|
243
243
|
};
|
|
244
|
-
|
|
244
|
+
b = {
|
|
245
245
|
react_stack_bottom_frame: function(e) {
|
|
246
246
|
return e();
|
|
247
247
|
}
|
|
248
248
|
};
|
|
249
|
-
var
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
)(),
|
|
253
|
-
|
|
254
|
-
var
|
|
255
|
-
return
|
|
249
|
+
var y, Z = {}, Q = b.react_stack_bottom_frame.bind(
|
|
250
|
+
b,
|
|
251
|
+
c
|
|
252
|
+
)(), K = j(s(c)), ee = {};
|
|
253
|
+
I.Fragment = x, I.jsx = function(e, r, o) {
|
|
254
|
+
var i = 1e4 > R.recentlyCreatedOwnerStacks++;
|
|
255
|
+
return m(
|
|
256
256
|
e,
|
|
257
257
|
r,
|
|
258
|
-
|
|
258
|
+
o,
|
|
259
259
|
!1,
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
i ? Error("react-stack-top-frame") : Q,
|
|
261
|
+
i ? j(s(e)) : K
|
|
262
262
|
);
|
|
263
|
-
},
|
|
264
|
-
var
|
|
265
|
-
return
|
|
263
|
+
}, I.jsxs = function(e, r, o) {
|
|
264
|
+
var i = 1e4 > R.recentlyCreatedOwnerStacks++;
|
|
265
|
+
return m(
|
|
266
266
|
e,
|
|
267
267
|
r,
|
|
268
|
-
|
|
268
|
+
o,
|
|
269
269
|
!0,
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
i ? Error("react-stack-top-frame") : Q,
|
|
271
|
+
i ? j(s(e)) : K
|
|
272
272
|
);
|
|
273
273
|
};
|
|
274
|
-
}()),
|
|
274
|
+
}()), I;
|
|
275
275
|
}
|
|
276
|
-
process.env.NODE_ENV === "production" ?
|
|
277
|
-
var t =
|
|
278
|
-
const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"],
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
276
|
+
process.env.NODE_ENV === "production" ? X.exports = ie() : X.exports = le();
|
|
277
|
+
var t = X.exports;
|
|
278
|
+
const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"], ne = 60, ue = (d) => {
|
|
279
|
+
if (!d) return null;
|
|
280
|
+
const p = d.split(","), f = p[0].match(/:(.*?);/)[1], s = atob(p[1]);
|
|
281
|
+
let n = s.length;
|
|
282
|
+
const c = new Uint8Array(n);
|
|
283
|
+
for (; n--; ) c[n] = s.charCodeAt(n);
|
|
284
|
+
return new Blob([c], { type: f });
|
|
285
|
+
}, ye = ({ apiUrl: d, onComplete: p }) => {
|
|
286
|
+
const f = q(null), s = q(null), n = q(null), [c, v] = _([]), [g, L] = _(0), [a, m] = _("idle"), [F, T] = _(3), [b, O] = _(ne), [k, x] = _(!1), [w, S] = _(!1), [Y, M] = _(null), P = () => {
|
|
287
|
+
const u = [...ce].sort(() => 0.5 - Math.random()).slice(0, 3);
|
|
288
|
+
v(u), L(0), m("idle"), T(3), O(ne), x(!1), S(!1);
|
|
282
289
|
};
|
|
283
|
-
|
|
284
|
-
|
|
290
|
+
H(() => {
|
|
291
|
+
P();
|
|
285
292
|
}, []);
|
|
286
|
-
const
|
|
287
|
-
|
|
293
|
+
const W = () => {
|
|
294
|
+
P();
|
|
288
295
|
};
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
296
|
+
H(() => () => {
|
|
297
|
+
n.current && clearInterval(n.current), s.current && s.current.abort();
|
|
298
|
+
}, []), H(() => {
|
|
299
|
+
let u;
|
|
300
|
+
return k && b > 0 ? u = setInterval(() => {
|
|
301
|
+
O((R) => R - 1);
|
|
302
|
+
}, 1e3) : b === 0 && a !== "success" && (n.current && (clearInterval(n.current), n.current = null), s.current && s.current.abort(), m("timeout"), x(!1), S(!1), p && p(!1)), () => clearInterval(u);
|
|
303
|
+
}, [k, b, a]);
|
|
304
|
+
const $ = async () => {
|
|
305
|
+
if (a === "capturing" || a === "verifying") return;
|
|
306
|
+
n.current && clearInterval(n.current), k || x(!0), m("counting");
|
|
307
|
+
let u = 3;
|
|
308
|
+
n.current = setInterval(() => {
|
|
309
|
+
u -= 1, T(u), u === 0 && (clearInterval(n.current), n.current = null, z());
|
|
300
310
|
}, 1e3);
|
|
301
|
-
},
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
h.append("files", j, `frame_${u}.jpg`);
|
|
311
|
+
}, z = async () => {
|
|
312
|
+
if (!f.current)
|
|
313
|
+
return;
|
|
314
|
+
m("capturing");
|
|
315
|
+
const u = [], R = 20;
|
|
316
|
+
for (let E = 0; E < R; E++) {
|
|
317
|
+
if (!f.current || b <= 0) return;
|
|
318
|
+
try {
|
|
319
|
+
const h = f.current.getScreenshot();
|
|
320
|
+
h && u.push(h);
|
|
321
|
+
} catch {
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
await new Promise((h) => setTimeout(h, 100));
|
|
316
325
|
}
|
|
317
|
-
|
|
326
|
+
u.length > 0 && a !== "timeout" && C(u);
|
|
327
|
+
}, C = async (u) => {
|
|
328
|
+
if (a === "verifying" || a === "timeout") return;
|
|
329
|
+
m("verifying"), s.current = new AbortController();
|
|
330
|
+
const { signal: R } = s.current, E = new FormData();
|
|
331
|
+
u.forEach((h, j) => {
|
|
332
|
+
const y = ue(h);
|
|
333
|
+
y && E.append("files", y, `frame_${j}.jpg`);
|
|
334
|
+
}), E.append("challenge", c[g]);
|
|
318
335
|
try {
|
|
319
|
-
|
|
336
|
+
const h = await fetch(`${d}/v1/verify`, {
|
|
320
337
|
method: "POST",
|
|
321
|
-
body:
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
338
|
+
body: E,
|
|
339
|
+
signal: R
|
|
340
|
+
});
|
|
341
|
+
u = [];
|
|
342
|
+
const j = await h.json();
|
|
343
|
+
if (a === "timeout") return;
|
|
344
|
+
if (j.is_live)
|
|
345
|
+
if (g < 2)
|
|
346
|
+
L((y) => y + 1), T(3), m("idle");
|
|
347
|
+
else {
|
|
348
|
+
const y = f.current.getScreenshot();
|
|
349
|
+
y && M(y), m("success"), x(!1), p && p({
|
|
350
|
+
success: !0,
|
|
351
|
+
image: y
|
|
352
|
+
// This is the base64 string
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
else
|
|
356
|
+
x(!1), S(!0), m("idle"), T(3);
|
|
357
|
+
} catch {
|
|
358
|
+
S(!0), m("idle");
|
|
359
|
+
} finally {
|
|
360
|
+
s.current = null;
|
|
325
361
|
}
|
|
326
|
-
},
|
|
362
|
+
}, V = {
|
|
327
363
|
Smile: "Show us a big SMILE! 😁",
|
|
328
364
|
Blink: "BLINK your eyes rapidly! 👁️",
|
|
329
|
-
Turn_Head: "Slowly TURN your head left
|
|
365
|
+
Turn_Head: "Slowly TURN your head left or right! ↔️",
|
|
330
366
|
Thumbs_Up: "Give a THUMBS UP! 👍"
|
|
331
367
|
};
|
|
332
368
|
return /* @__PURE__ */ t.jsxs("div", { style: { textAlign: "center", padding: "20px", fontFamily: "sans-serif" }, children: [
|
|
333
|
-
|
|
369
|
+
k && a !== "success" && /* @__PURE__ */ t.jsxs("div", { style: { fontSize: "20px", fontWeight: "bold", color: b < 10 ? "red" : "black" }, children: [
|
|
334
370
|
"Time Remaining: ",
|
|
335
|
-
|
|
371
|
+
b,
|
|
336
372
|
"s"
|
|
337
373
|
] }),
|
|
338
|
-
|
|
374
|
+
w && /* @__PURE__ */ t.jsx("div", { style: fe, children: /* @__PURE__ */ t.jsxs("div", { style: de, children: [
|
|
339
375
|
/* @__PURE__ */ t.jsx("h3", { style: { color: "#dc3545" }, children: "Action Not Detected" }),
|
|
340
376
|
/* @__PURE__ */ t.jsx("p", { children: "We couldn't verify that move. Please try again before time runs out!" }),
|
|
341
377
|
/* @__PURE__ */ t.jsx("button", { onClick: () => {
|
|
342
|
-
|
|
343
|
-
}, style:
|
|
378
|
+
S(!1), $();
|
|
379
|
+
}, style: U, children: "Try Again" })
|
|
344
380
|
] }) }),
|
|
345
|
-
|
|
381
|
+
a === "success" && /* @__PURE__ */ t.jsxs("div", { children: [
|
|
346
382
|
/* @__PURE__ */ t.jsx("h2", { children: "✅ Verification Passed!" }),
|
|
347
|
-
/* @__PURE__ */ t.
|
|
383
|
+
Y && /* @__PURE__ */ t.jsxs("div", { style: { margin: "20px auto", width: "200px" }, children: [
|
|
384
|
+
/* @__PURE__ */ t.jsx("p", { children: "Verified Photo:" }),
|
|
385
|
+
/* @__PURE__ */ t.jsx(
|
|
386
|
+
"img",
|
|
387
|
+
{
|
|
388
|
+
src: Y,
|
|
389
|
+
alt: "Verified",
|
|
390
|
+
style: { width: "100%", borderRadius: "10px", border: "3px solid #28a745" }
|
|
391
|
+
}
|
|
392
|
+
)
|
|
393
|
+
] }),
|
|
394
|
+
/* @__PURE__ */ t.jsx("button", { onClick: W, style: { ...U, backgroundColor: "#6c757d" }, children: "Verify Again" })
|
|
348
395
|
] }),
|
|
349
|
-
|
|
396
|
+
a === "timeout" && /* @__PURE__ */ t.jsxs("div", { children: [
|
|
350
397
|
/* @__PURE__ */ t.jsx("h2", { style: { color: "#dc3545" }, children: "⏰ Session Expired" }),
|
|
351
398
|
/* @__PURE__ */ t.jsx("p", { children: "You didn't complete the challenges in time." }),
|
|
352
|
-
/* @__PURE__ */ t.jsx("p", { children: "Please ensure you follow the instructions and perform the tasks within the time limit. (60
|
|
353
|
-
/* @__PURE__ */ t.jsx("button", { onClick:
|
|
399
|
+
/* @__PURE__ */ t.jsx("p", { children: "Please ensure you follow the instructions and perform the tasks within the time limit. (60 seconds)" }),
|
|
400
|
+
/* @__PURE__ */ t.jsx("button", { onClick: P, style: U, children: "🔄 Try Again" })
|
|
354
401
|
] }),
|
|
355
|
-
["idle", "counting", "capturing", "verifying"].includes(
|
|
402
|
+
["idle", "counting", "capturing", "verifying"].includes(a) && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
356
403
|
/* @__PURE__ */ t.jsx("h2", { children: "Please be in a well-lit room where your face can be well seen." }),
|
|
357
404
|
/* @__PURE__ */ t.jsxs("h3", { children: [
|
|
358
405
|
"Challenge ",
|
|
359
|
-
|
|
406
|
+
g + 1,
|
|
360
407
|
" of 3"
|
|
361
408
|
] }),
|
|
362
|
-
/* @__PURE__ */ t.jsx("h2", { style: { color: "#007bff" }, children:
|
|
363
|
-
/* @__PURE__ */ t.jsxs("div", { style: { position: "relative", width: "fit-content", margin: "auto" }, children: [
|
|
409
|
+
/* @__PURE__ */ t.jsx("h2", { style: { color: "#007bff" }, children: V[c[g]] }),
|
|
410
|
+
/* @__PURE__ */ t.jsxs("div", { style: { position: "relative", width: "fit-content", margin: "auto", overflow: "hidden", borderRadius: "10px" }, children: [
|
|
364
411
|
/* @__PURE__ */ t.jsx(
|
|
365
412
|
ae,
|
|
366
413
|
{
|
|
367
414
|
audio: !1,
|
|
368
|
-
ref:
|
|
415
|
+
ref: f,
|
|
369
416
|
screenshotFormat: "image/jpeg",
|
|
370
417
|
style: { borderRadius: "10px", width: "100%", maxWidth: "400px", transform: "scaleX(-1)" }
|
|
371
418
|
}
|
|
372
419
|
),
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
420
|
+
/* @__PURE__ */ t.jsx("div", { style: {
|
|
421
|
+
...pe,
|
|
422
|
+
borderColor: a === "capturing" ? "#28a745" : "rgba(255, 255, 255, 0.6)",
|
|
423
|
+
borderStyle: a === "capturing" ? "solid" : "dashed"
|
|
424
|
+
}, children: /* @__PURE__ */ t.jsx("div", { style: me }) }),
|
|
425
|
+
a === "counting" && /* @__PURE__ */ t.jsx("div", { style: J, children: F }),
|
|
426
|
+
a === "verifying" && /* @__PURE__ */ t.jsx("div", { style: J, children: "Analyzing..." }),
|
|
427
|
+
a === "capturing" && /* @__PURE__ */ t.jsx("div", { style: { ...J, background: "rgba(40, 167, 69, 0.3)" }, children: "Recording..." })
|
|
376
428
|
] }),
|
|
377
|
-
/* @__PURE__ */ t.jsx("div", { style: { marginTop: "20px" }, children:
|
|
378
|
-
...
|
|
379
|
-
filter:
|
|
380
|
-
cursor:
|
|
381
|
-
opacity:
|
|
429
|
+
/* @__PURE__ */ t.jsx("div", { style: { marginTop: "20px" }, children: a === "idle" && /* @__PURE__ */ t.jsx("button", { onClick: $, disabled: w, style: {
|
|
430
|
+
...U,
|
|
431
|
+
filter: w ? "grayscale(1)" : "none",
|
|
432
|
+
cursor: w ? "not-allowed" : "pointer",
|
|
433
|
+
opacity: w ? 0.6 : 1
|
|
382
434
|
}, children: "I'm Ready" }) })
|
|
383
435
|
] })
|
|
384
436
|
] });
|
|
385
|
-
},
|
|
437
|
+
}, J = {
|
|
386
438
|
position: "absolute",
|
|
387
439
|
top: 0,
|
|
388
440
|
left: 0,
|
|
@@ -395,7 +447,7 @@ const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"], re = 60, pe = ({ apiUrl
|
|
|
395
447
|
justifyContent: "center",
|
|
396
448
|
fontSize: "48px",
|
|
397
449
|
borderRadius: "10px"
|
|
398
|
-
},
|
|
450
|
+
}, U = {
|
|
399
451
|
padding: "10px 30px",
|
|
400
452
|
fontSize: "18px",
|
|
401
453
|
cursor: "pointer",
|
|
@@ -403,7 +455,7 @@ const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"], re = 60, pe = ({ apiUrl
|
|
|
403
455
|
color: "white",
|
|
404
456
|
border: "none",
|
|
405
457
|
borderRadius: "5px"
|
|
406
|
-
},
|
|
458
|
+
}, fe = {
|
|
407
459
|
position: "absolute",
|
|
408
460
|
top: 0,
|
|
409
461
|
left: 0,
|
|
@@ -415,26 +467,50 @@ const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"], re = 60, pe = ({ apiUrl
|
|
|
415
467
|
justifyContent: "center",
|
|
416
468
|
zIndex: 100,
|
|
417
469
|
borderRadius: "10px"
|
|
418
|
-
},
|
|
470
|
+
}, de = {
|
|
419
471
|
backgroundColor: "white",
|
|
420
472
|
padding: "30px",
|
|
421
473
|
borderRadius: "15px",
|
|
422
474
|
maxWidth: "300px",
|
|
423
475
|
boxShadow: "0 4px 15px rgba(0,0,0,0.3)",
|
|
424
476
|
color: "#000"
|
|
425
|
-
},
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
477
|
+
}, pe = {
|
|
478
|
+
position: "absolute",
|
|
479
|
+
top: "50%",
|
|
480
|
+
left: "50%",
|
|
481
|
+
transform: "translate(-50%, -50%)",
|
|
482
|
+
width: "260px",
|
|
483
|
+
// Adjust width based on your model's preference
|
|
484
|
+
height: "240px",
|
|
485
|
+
// Adjust height
|
|
486
|
+
borderRadius: "50%",
|
|
487
|
+
border: "2px dashed rgba(255, 255, 255, 0.6)",
|
|
488
|
+
boxShadow: "0 0 0 9999px rgba(0, 0, 0, 0.5)",
|
|
489
|
+
// This creates the dark "vignette"
|
|
490
|
+
pointerEvents: "none",
|
|
491
|
+
// Critical: clicks pass through to the webcam/buttons
|
|
492
|
+
zIndex: 10
|
|
493
|
+
}, me = {
|
|
494
|
+
position: "absolute",
|
|
495
|
+
top: 0,
|
|
496
|
+
left: 0,
|
|
497
|
+
right: 0,
|
|
498
|
+
bottom: 0,
|
|
499
|
+
borderRadius: "50%",
|
|
500
|
+
boxShadow: "inset 0 0 30px rgba(255, 255, 255, 0.2)"
|
|
501
|
+
}, ge = async (d, p, f) => {
|
|
502
|
+
const s = new FormData();
|
|
503
|
+
p.forEach((c, v) => {
|
|
504
|
+
s.append("files", c, `frame_${v}.jpg`);
|
|
505
|
+
}), s.append("challenge", f);
|
|
506
|
+
const n = await fetch(`${d}/v1/verify`, {
|
|
431
507
|
method: "POST",
|
|
432
|
-
body:
|
|
508
|
+
body: s
|
|
433
509
|
});
|
|
434
|
-
if (!
|
|
435
|
-
return await
|
|
510
|
+
if (!n.ok) throw new Error("Network response was not ok");
|
|
511
|
+
return await n.json();
|
|
436
512
|
};
|
|
437
513
|
export {
|
|
438
|
-
|
|
439
|
-
|
|
514
|
+
ye as LivenessSDK,
|
|
515
|
+
ge as verifyLiveness
|
|
440
516
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(x,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("react-webcam")):typeof define=="function"&&define.amd?define(["exports","react","react-webcam"],i):(x=typeof globalThis<"u"?globalThis:x||self,i(x.LivenessSDK={},x.React,x.Webcam))})(this,function(x,i,ne){"use strict";var z={exports:{}},P={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Z;function oe(){if(Z)return P;Z=1;var p=Symbol.for("react.transitional.element"),m=Symbol.for("react.fragment");function d(s,n,u){var R=null;if(u!==void 0&&(R=""+u),n.key!==void 0&&(R=""+n.key),"key"in n){u={};for(var g in n)g!=="key"&&(u[g]=n[g])}else u=n;return n=u.ref,{$$typeof:p,type:s,key:R,ref:n!==void 0?n:null,props:u}}return P.Fragment=m,P.jsx=d,P.jsxs=d,P}var C={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var Q;function se(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&function(){function p(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===f?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case j:return"Profiler";case w:return"StrictMode";case G:return"Suspense";case U:return"SuspenseList";case J:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case A:return"Portal";case B:return e.displayName||"Context";case M:return(e._context.displayName||"Context")+".Consumer";case I:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return t=e.displayName||null,t!==null?t:p(e.type)||"Memo";case L:t=e._payload,e=e._init;try{return p(e(t))}catch{}}return null}function m(e){return""+e}function d(e){try{m(e);var t=!1}catch{t=!0}if(t){t=console;var o=t.error,l=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",l),m(e)}}function s(e){if(e===E)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===L)return"<...>";try{var t=p(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function n(){var e=S.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function R(e){if(_.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function g(e,t){function o(){v||(v=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}o.isReactWarning=!0,Object.defineProperty(e,"key",{get:o,configurable:!0})}function F(){var e=p(this.type);return $[e]||($[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function a(e,t,o,l,W,X){var c=o.ref;return e={$$typeof:N,type:e,key:t,props:o,_owner:l},(c!==void 0?c:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:F}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function h(e,t,o,l,W,X){var c=t.children;if(c!==void 0)if(l)if(b(c)){for(l=0;l<c.length;l++)Y(c[l]);Object.freeze&&Object.freeze(c)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Y(c);if(_.call(t,"key")){c=p(e);var O=Object.keys(t).filter(function(me){return me!=="key"});l=0<O.length?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}",re[c+l]||(O=0<O.length?"{"+O.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,l,c,O,c),re[c+l]=!0)}if(c=null,o!==void 0&&(d(o),c=""+o),R(t)&&(d(t.key),c=""+t.key),"key"in t){o={};for(var K in t)K!=="key"&&(o[K]=t[K])}else o=t;return c&&g(o,typeof e=="function"?e.displayName||e.name||"Unknown":e),a(e,c,o,n(),W,X)}function Y(e){T(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===L&&(e._payload.status==="fulfilled"?T(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function T(e){return typeof e=="object"&&e!==null&&e.$$typeof===N}var y=i,N=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),B=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),f=Symbol.for("react.client.reference"),S=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=Object.prototype.hasOwnProperty,b=Array.isArray,k=console.createTask?console.createTask:function(){return null};y={react_stack_bottom_frame:function(e){return e()}};var v,$={},ee=y.react_stack_bottom_frame.bind(y,u)(),te=k(s(u)),re={};C.Fragment=E,C.jsx=function(e,t,o){var l=1e4>S.recentlyCreatedOwnerStacks++;return h(e,t,o,!1,l?Error("react-stack-top-frame"):ee,l?k(s(e)):te)},C.jsxs=function(e,t,o){var l=1e4>S.recentlyCreatedOwnerStacks++;return h(e,t,o,!0,l?Error("react-stack-top-frame"):ee,l?k(s(e)):te)}}()),C}process.env.NODE_ENV==="production"?z.exports=oe():z.exports=se();var r=z.exports;const ae=["Smile","Blink","Turn_Head","Thumbs_Up"],q=60,ie=p=>{if(!p)return null;const m=p.split(","),d=m[0].match(/:(.*?);/)[1],s=atob(m[1]);let n=s.length;const u=new Uint8Array(n);for(;n--;)u[n]=s.charCodeAt(n);return new Blob([u],{type:d})},le=({apiUrl:p,onComplete:m})=>{const d=i.useRef(null),s=i.useRef(null),n=i.useRef(null),[u,R]=i.useState([]),[g,F]=i.useState(0),[a,h]=i.useState("idle"),[Y,T]=i.useState(3),[y,N]=i.useState(q),[A,E]=i.useState(!1),[w,j]=i.useState(!1),[M,B]=i.useState(null),I=()=>{const f=[...ae].sort(()=>.5-Math.random()).slice(0,3);R(f),F(0),h("idle"),T(3),N(q),E(!1),j(!1)};i.useEffect(()=>{I()},[]);const G=()=>{I()};i.useEffect(()=>()=>{n.current&&clearInterval(n.current),s.current&&s.current.abort()},[]),i.useEffect(()=>{let f;return A&&y>0?f=setInterval(()=>{N(S=>S-1)},1e3):y===0&&a!=="success"&&(n.current&&(clearInterval(n.current),n.current=null),s.current&&s.current.abort(),h("timeout"),E(!1),j(!1),m&&m(!1)),()=>clearInterval(f)},[A,y,a]);const U=async()=>{if(a==="capturing"||a==="verifying")return;n.current&&clearInterval(n.current),A||E(!0),h("counting");let f=3;n.current=setInterval(()=>{f-=1,T(f),f===0&&(clearInterval(n.current),n.current=null,H())},1e3)},H=async()=>{if(!d.current)return;h("capturing");const f=[],S=20;for(let _=0;_<S;_++){if(!d.current||y<=0)return;try{const b=d.current.getScreenshot();b&&f.push(b)}catch{break}await new Promise(b=>setTimeout(b,100))}f.length>0&&a!=="timeout"&&L(f)},L=async f=>{if(a==="verifying"||a==="timeout")return;h("verifying"),s.current=new AbortController;const{signal:S}=s.current,_=new FormData;f.forEach((b,k)=>{const v=ie(b);v&&_.append("files",v,`frame_${k}.jpg`)}),_.append("challenge",u[g]);try{const b=await fetch(`${p}/v1/verify`,{method:"POST",body:_,signal:S});f=[];const k=await b.json();if(a==="timeout")return;if(k.is_live)if(g<2)F(v=>v+1),T(3),h("idle");else{const v=d.current.getScreenshot();v&&B(v),h("success"),E(!1),m&&m({success:!0,image:v})}else E(!1),j(!0),h("idle"),T(3)}catch{j(!0),h("idle")}finally{s.current=null}},J={Smile:"Show us a big SMILE! 😁",Blink:"BLINK your eyes rapidly! 👁️",Turn_Head:"Slowly TURN your head left or right! ↔️",Thumbs_Up:"Give a THUMBS UP! 👍"};return r.jsxs("div",{style:{textAlign:"center",padding:"20px",fontFamily:"sans-serif"},children:[A&&a!=="success"&&r.jsxs("div",{style:{fontSize:"20px",fontWeight:"bold",color:y<10?"red":"black"},children:["Time Remaining: ",y,"s"]}),w&&r.jsx("div",{style:ce,children:r.jsxs("div",{style:ue,children:[r.jsx("h3",{style:{color:"#dc3545"},children:"Action Not Detected"}),r.jsx("p",{children:"We couldn't verify that move. Please try again before time runs out!"}),r.jsx("button",{onClick:()=>{j(!1),U()},style:D,children:"Try Again"})]})}),a==="success"&&r.jsxs("div",{children:[r.jsx("h2",{children:"✅ Verification Passed!"}),M&&r.jsxs("div",{style:{margin:"20px auto",width:"200px"},children:[r.jsx("p",{children:"Verified Photo:"}),r.jsx("img",{src:M,alt:"Verified",style:{width:"100%",borderRadius:"10px",border:"3px solid #28a745"}})]}),r.jsx("button",{onClick:G,style:{...D,backgroundColor:"#6c757d"},children:"Verify Again"})]}),a==="timeout"&&r.jsxs("div",{children:[r.jsx("h2",{style:{color:"#dc3545"},children:"⏰ Session Expired"}),r.jsx("p",{children:"You didn't complete the challenges in time."}),r.jsx("p",{children:"Please ensure you follow the instructions and perform the tasks within the time limit. (60 seconds)"}),r.jsx("button",{onClick:I,style:D,children:"🔄 Try Again"})]}),["idle","counting","capturing","verifying"].includes(a)&&r.jsxs(r.Fragment,{children:[r.jsx("h2",{children:"Please be in a well-lit room where your face can be well seen."}),r.jsxs("h3",{children:["Challenge ",g+1," of 3"]}),r.jsx("h2",{style:{color:"#007bff"},children:J[u[g]]}),r.jsxs("div",{style:{position:"relative",width:"fit-content",margin:"auto",overflow:"hidden",borderRadius:"10px"},children:[r.jsx(ne,{audio:!1,ref:d,screenshotFormat:"image/jpeg",style:{borderRadius:"10px",width:"100%",maxWidth:"400px",transform:"scaleX(-1)"}}),r.jsx("div",{style:{...fe,borderColor:a==="capturing"?"#28a745":"rgba(255, 255, 255, 0.6)",borderStyle:a==="capturing"?"solid":"dashed"},children:r.jsx("div",{style:de})}),a==="counting"&&r.jsx("div",{style:V,children:Y}),a==="verifying"&&r.jsx("div",{style:V,children:"Analyzing..."}),a==="capturing"&&r.jsx("div",{style:{...V,background:"rgba(40, 167, 69, 0.3)"},children:"Recording..."})]}),r.jsx("div",{style:{marginTop:"20px"},children:a==="idle"&&r.jsx("button",{onClick:U,disabled:w,style:{...D,filter:w?"grayscale(1)":"none",cursor:w?"not-allowed":"pointer",opacity:w?.6:1},children:"I'm Ready"})})]})]})},V={position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"48px",borderRadius:"10px"},D={padding:"10px 30px",fontSize:"18px",cursor:"pointer",backgroundColor:"#28a745",color:"white",border:"none",borderRadius:"5px"},ce={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100,borderRadius:"10px"},ue={backgroundColor:"white",padding:"30px",borderRadius:"15px",maxWidth:"300px",boxShadow:"0 4px 15px rgba(0,0,0,0.3)",color:"#000"},fe={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"260px",height:"240px",borderRadius:"50%",border:"2px dashed rgba(255, 255, 255, 0.6)",boxShadow:"0 0 0 9999px rgba(0, 0, 0, 0.5)",pointerEvents:"none",zIndex:10},de={position:"absolute",top:0,left:0,right:0,bottom:0,borderRadius:"50%",boxShadow:"inset 0 0 30px rgba(255, 255, 255, 0.2)"},pe=async(p,m,d)=>{const s=new FormData;m.forEach((u,R)=>{s.append("files",u,`frame_${R}.jpg`)}),s.append("challenge",d);const n=await fetch(`${p}/v1/verify`,{method:"POST",body:s});if(!n.ok)throw new Error("Network response was not ok");return await n.json()};x.LivenessSDK=le,x.verifyLiveness=pe,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@richard.fadiora/liveness-detection",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"react-webcam": "^7.2.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@mediapipe/tasks-vision": "^0.10.32",
|
|
28
29
|
"react-webcam": "^7.2.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|