@richard.fadiora/liveness-detection 1.0.2 → 1.0.3
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 +185 -159
- package/dist/index.umd.js +4 -4
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import oe, { useRef as se, useState as w, useEffect as
|
|
1
|
+
import oe, { useRef as se, useState as w, useEffect as Q } from "react";
|
|
2
2
|
import ae from "react-webcam";
|
|
3
|
-
var
|
|
3
|
+
var B = { exports: {} }, A = {};
|
|
4
4
|
/**
|
|
5
5
|
* @license React
|
|
6
6
|
* react-jsx-runtime.production.js
|
|
@@ -10,29 +10,29 @@ var z = { exports: {} }, P = {};
|
|
|
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
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
|
|
13
|
+
var K;
|
|
14
|
+
function le() {
|
|
15
|
+
if (K) return A;
|
|
16
|
+
K = 1;
|
|
17
17
|
var d = Symbol.for("react.transitional.element"), m = Symbol.for("react.fragment");
|
|
18
|
-
function b(
|
|
18
|
+
function b(f, l, a) {
|
|
19
19
|
var v = null;
|
|
20
|
-
if (a !== void 0 && (v = "" + a),
|
|
20
|
+
if (a !== void 0 && (v = "" + a), l.key !== void 0 && (v = "" + l.key), "key" in l) {
|
|
21
21
|
a = {};
|
|
22
|
-
for (var
|
|
23
|
-
|
|
24
|
-
} else a =
|
|
25
|
-
return
|
|
22
|
+
for (var i in l)
|
|
23
|
+
i !== "key" && (a[i] = l[i]);
|
|
24
|
+
} else a = l;
|
|
25
|
+
return l = a.ref, {
|
|
26
26
|
$$typeof: d,
|
|
27
|
-
type:
|
|
27
|
+
type: f,
|
|
28
28
|
key: v,
|
|
29
|
-
ref:
|
|
29
|
+
ref: l !== void 0 ? l : null,
|
|
30
30
|
props: a
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
return A.Fragment = m, A.jsx = b, A.jsxs = b, A;
|
|
34
34
|
}
|
|
35
|
-
var
|
|
35
|
+
var O = {};
|
|
36
36
|
/**
|
|
37
37
|
* @license React
|
|
38
38
|
* react-jsx-runtime.development.js
|
|
@@ -42,44 +42,44 @@ var A = {};
|
|
|
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
|
|
46
|
-
function
|
|
47
|
-
return
|
|
45
|
+
var ee;
|
|
46
|
+
function ie() {
|
|
47
|
+
return ee || (ee = 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 === T ? null : e.displayName || e.name || null;
|
|
52
52
|
if (typeof e == "string") return e;
|
|
53
53
|
switch (e) {
|
|
54
|
-
case
|
|
54
|
+
case g:
|
|
55
55
|
return "Fragment";
|
|
56
|
-
case
|
|
56
|
+
case D:
|
|
57
57
|
return "Profiler";
|
|
58
|
-
case
|
|
58
|
+
case k:
|
|
59
59
|
return "StrictMode";
|
|
60
|
-
case
|
|
60
|
+
case F:
|
|
61
61
|
return "Suspense";
|
|
62
|
-
case
|
|
62
|
+
case c:
|
|
63
63
|
return "SuspenseList";
|
|
64
|
-
case
|
|
64
|
+
case x:
|
|
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 L:
|
|
72
72
|
return "Portal";
|
|
73
73
|
case Y:
|
|
74
74
|
return e.displayName || "Context";
|
|
75
|
-
case
|
|
75
|
+
case P:
|
|
76
76
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
77
|
-
case
|
|
77
|
+
case $:
|
|
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 h:
|
|
81
81
|
return r = e.displayName || null, r !== null ? r : d(e.type) || "Memo";
|
|
82
|
-
case
|
|
82
|
+
case u:
|
|
83
83
|
r = e._payload, e = e._init;
|
|
84
84
|
try {
|
|
85
85
|
return d(e(r));
|
|
@@ -100,17 +100,17 @@ function le() {
|
|
|
100
100
|
}
|
|
101
101
|
if (r) {
|
|
102
102
|
r = console;
|
|
103
|
-
var
|
|
104
|
-
return
|
|
103
|
+
var n = r.error, o = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
104
|
+
return n.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
107
|
o
|
|
108
108
|
), m(e);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
if (e ===
|
|
113
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
111
|
+
function f(e) {
|
|
112
|
+
if (e === g) return "<>";
|
|
113
|
+
if (typeof e == "object" && e !== null && e.$$typeof === u)
|
|
114
114
|
return "<...>";
|
|
115
115
|
try {
|
|
116
116
|
var r = d(e);
|
|
@@ -119,45 +119,45 @@ function le() {
|
|
|
119
119
|
return "<...>";
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
var e =
|
|
122
|
+
function l() {
|
|
123
|
+
var e = M.A;
|
|
124
124
|
return e === null ? null : e.getOwner();
|
|
125
125
|
}
|
|
126
126
|
function a() {
|
|
127
127
|
return Error("react-stack-top-frame");
|
|
128
128
|
}
|
|
129
129
|
function v(e) {
|
|
130
|
-
if (
|
|
130
|
+
if (G.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 i(e, r) {
|
|
137
|
+
function n() {
|
|
138
|
+
q || (q = !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
|
+
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
144
|
+
get: n,
|
|
145
145
|
configurable: !0
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
function p() {
|
|
149
149
|
var e = d(this.type);
|
|
150
|
-
return
|
|
150
|
+
return H[e] || (H[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 s =
|
|
154
|
+
function I(e, r, n, o, C, W) {
|
|
155
|
+
var s = n.ref;
|
|
156
156
|
return e = {
|
|
157
|
-
$$typeof:
|
|
157
|
+
$$typeof: _,
|
|
158
158
|
type: e,
|
|
159
159
|
key: r,
|
|
160
|
-
props:
|
|
160
|
+
props: n,
|
|
161
161
|
_owner: o
|
|
162
162
|
}, (s !== void 0 ? s : null) !== null ? Object.defineProperty(e, "ref", {
|
|
163
163
|
enumerable: !1,
|
|
@@ -176,33 +176,33 @@ function le() {
|
|
|
176
176
|
configurable: !1,
|
|
177
177
|
enumerable: !1,
|
|
178
178
|
writable: !0,
|
|
179
|
-
value:
|
|
179
|
+
value: C
|
|
180
180
|
}), Object.defineProperty(e, "_debugTask", {
|
|
181
181
|
configurable: !1,
|
|
182
182
|
enumerable: !1,
|
|
183
183
|
writable: !0,
|
|
184
|
-
value:
|
|
184
|
+
value: W
|
|
185
185
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function R(e, r, n, o, C, W) {
|
|
188
188
|
var s = r.children;
|
|
189
189
|
if (s !== void 0)
|
|
190
190
|
if (o)
|
|
191
191
|
if (te(s)) {
|
|
192
192
|
for (o = 0; o < s.length; o++)
|
|
193
|
-
|
|
193
|
+
E(s[o]);
|
|
194
194
|
Object.freeze && Object.freeze(s);
|
|
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 (
|
|
199
|
+
else E(s);
|
|
200
|
+
if (G.call(r, "key")) {
|
|
201
201
|
s = d(e);
|
|
202
|
-
var
|
|
202
|
+
var j = Object.keys(r).filter(function(ne) {
|
|
203
203
|
return ne !== "key";
|
|
204
204
|
});
|
|
205
|
-
o = 0 <
|
|
205
|
+
o = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", Z[s + o] || (j = 0 < j.length ? "{" + j.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} />
|
|
@@ -211,150 +211,157 @@ React keys must be passed directly to JSX without using spread:
|
|
|
211
211
|
<%s key={someKey} {...props} />`,
|
|
212
212
|
o,
|
|
213
213
|
s,
|
|
214
|
-
|
|
214
|
+
j,
|
|
215
215
|
s
|
|
216
|
-
),
|
|
216
|
+
), Z[s + o] = !0);
|
|
217
217
|
}
|
|
218
|
-
if (s = null,
|
|
219
|
-
|
|
220
|
-
for (var
|
|
221
|
-
|
|
222
|
-
} else
|
|
223
|
-
return s &&
|
|
224
|
-
|
|
218
|
+
if (s = null, n !== void 0 && (b(n), s = "" + n), v(r) && (b(r.key), s = "" + r.key), "key" in r) {
|
|
219
|
+
n = {};
|
|
220
|
+
for (var z in r)
|
|
221
|
+
z !== "key" && (n[z] = r[z]);
|
|
222
|
+
} else n = r;
|
|
223
|
+
return s && i(
|
|
224
|
+
n,
|
|
225
225
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
226
|
-
),
|
|
226
|
+
), I(
|
|
227
227
|
e,
|
|
228
228
|
s,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
n,
|
|
230
|
+
l(),
|
|
231
|
+
C,
|
|
232
|
+
W
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
|
|
235
|
+
function E(e) {
|
|
236
|
+
S(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === u && (e._payload.status === "fulfilled" ? S(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 S(e) {
|
|
239
|
+
return typeof e == "object" && e !== null && e.$$typeof === _;
|
|
240
240
|
}
|
|
241
|
-
var
|
|
241
|
+
var y = oe, _ = Symbol.for("react.transitional.element"), L = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), D = Symbol.for("react.profiler"), P = Symbol.for("react.consumer"), Y = Symbol.for("react.context"), $ = Symbol.for("react.forward_ref"), F = Symbol.for("react.suspense"), c = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), u = Symbol.for("react.lazy"), x = Symbol.for("react.activity"), T = Symbol.for("react.client.reference"), M = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, G = Object.prototype.hasOwnProperty, te = Array.isArray, U = console.createTask ? console.createTask : function() {
|
|
242
242
|
return null;
|
|
243
243
|
};
|
|
244
|
-
|
|
244
|
+
y = {
|
|
245
245
|
react_stack_bottom_frame: function(e) {
|
|
246
246
|
return e();
|
|
247
247
|
}
|
|
248
248
|
};
|
|
249
|
-
var
|
|
250
|
-
|
|
249
|
+
var q, H = {}, J = y.react_stack_bottom_frame.bind(
|
|
250
|
+
y,
|
|
251
251
|
a
|
|
252
|
-
)(),
|
|
253
|
-
|
|
254
|
-
var o = 1e4 >
|
|
255
|
-
return
|
|
252
|
+
)(), X = U(f(a)), Z = {};
|
|
253
|
+
O.Fragment = g, O.jsx = function(e, r, n) {
|
|
254
|
+
var o = 1e4 > M.recentlyCreatedOwnerStacks++;
|
|
255
|
+
return R(
|
|
256
256
|
e,
|
|
257
257
|
r,
|
|
258
|
-
|
|
258
|
+
n,
|
|
259
259
|
!1,
|
|
260
|
-
o ? Error("react-stack-top-frame") :
|
|
261
|
-
o ?
|
|
260
|
+
o ? Error("react-stack-top-frame") : J,
|
|
261
|
+
o ? U(f(e)) : X
|
|
262
262
|
);
|
|
263
|
-
},
|
|
264
|
-
var o = 1e4 >
|
|
265
|
-
return
|
|
263
|
+
}, O.jsxs = function(e, r, n) {
|
|
264
|
+
var o = 1e4 > M.recentlyCreatedOwnerStacks++;
|
|
265
|
+
return R(
|
|
266
266
|
e,
|
|
267
267
|
r,
|
|
268
|
-
|
|
268
|
+
n,
|
|
269
269
|
!0,
|
|
270
|
-
o ? Error("react-stack-top-frame") :
|
|
271
|
-
o ?
|
|
270
|
+
o ? Error("react-stack-top-frame") : J,
|
|
271
|
+
o ? U(f(e)) : X
|
|
272
272
|
);
|
|
273
273
|
};
|
|
274
|
-
}()),
|
|
274
|
+
}()), O;
|
|
275
275
|
}
|
|
276
|
-
process.env.NODE_ENV === "production" ?
|
|
277
|
-
var
|
|
278
|
-
const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"],
|
|
279
|
-
const b = se(null), [
|
|
276
|
+
process.env.NODE_ENV === "production" ? B.exports = le() : B.exports = ie();
|
|
277
|
+
var t = B.exports;
|
|
278
|
+
const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"], re = 60, pe = ({ apiUrl: d, onComplete: m }) => {
|
|
279
|
+
const b = se(null), [f, l] = w([]), [a, v] = w(0), [i, p] = w("idle"), [I, R] = w(3), [E, S] = w(re), [y, _] = w(!1), [L, g] = w(!1), k = () => {
|
|
280
280
|
const c = [...ce].sort(() => 0.5 - Math.random()).slice(0, 3);
|
|
281
|
-
|
|
281
|
+
l(c), v(0), p("idle"), R(3), S(re), _(!1), g(!1);
|
|
282
282
|
};
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
Q(() => {
|
|
284
|
+
k();
|
|
285
285
|
}, []);
|
|
286
|
-
const
|
|
287
|
-
|
|
286
|
+
const D = () => {
|
|
287
|
+
k();
|
|
288
288
|
};
|
|
289
|
-
|
|
289
|
+
Q(() => {
|
|
290
290
|
let c;
|
|
291
|
-
return
|
|
292
|
-
|
|
293
|
-
}, 1e3) :
|
|
294
|
-
}, [
|
|
295
|
-
const
|
|
296
|
-
|
|
291
|
+
return y && E > 0 ? c = setInterval(() => {
|
|
292
|
+
S((h) => h - 1);
|
|
293
|
+
}, 1e3) : E === 0 && i !== "success" && (p("timeout"), _(!1), g(!1), m && m(!1)), () => clearInterval(c);
|
|
294
|
+
}, [y, E, i]);
|
|
295
|
+
const P = async () => {
|
|
296
|
+
y || _(!0), p("counting");
|
|
297
297
|
let c = 3;
|
|
298
298
|
const h = setInterval(() => {
|
|
299
|
-
c -= 1,
|
|
299
|
+
c -= 1, R(c), c === 0 && (clearInterval(h), Y());
|
|
300
300
|
}, 1e3);
|
|
301
|
-
},
|
|
301
|
+
}, Y = async () => {
|
|
302
302
|
p("capturing");
|
|
303
303
|
const c = [], h = 20;
|
|
304
|
-
for (let
|
|
305
|
-
const
|
|
306
|
-
c.push(
|
|
304
|
+
for (let u = 0; u < h; u++) {
|
|
305
|
+
const x = b.current.getScreenshot();
|
|
306
|
+
c.push(x), await new Promise((T) => setTimeout(T, 100));
|
|
307
307
|
}
|
|
308
|
-
|
|
309
|
-
},
|
|
310
|
-
p("verifying");
|
|
308
|
+
$(c);
|
|
309
|
+
}, $ = async (c) => {
|
|
310
|
+
window.dummyTest = "I am working!", console.log("SEND TO BRAIN CALLED"), p("verifying");
|
|
311
311
|
const h = new FormData();
|
|
312
|
-
for (let
|
|
313
|
-
const
|
|
314
|
-
h.append("files",
|
|
312
|
+
for (let u = 0; u < c.length; u++) {
|
|
313
|
+
const x = await fetch(c[u]).then((T) => T.blob());
|
|
314
|
+
h.append("files", x, `frame_${u}.jpg`);
|
|
315
315
|
}
|
|
316
|
-
h.append("challenge",
|
|
316
|
+
h.append("challenge", f[a]);
|
|
317
317
|
try {
|
|
318
|
-
const
|
|
318
|
+
const x = await (await fetch(`${d}/v1/verify`, {
|
|
319
319
|
method: "POST",
|
|
320
320
|
body: h
|
|
321
321
|
})).json();
|
|
322
|
-
console.log("API Response:",
|
|
323
|
-
} catch (
|
|
324
|
-
console.error("API Error:",
|
|
322
|
+
console.log("API Response:", x.status), x.is_live ? a < 2 ? (v((T) => T + 1), R(3), p("idle")) : (p("success"), _(!1), m && m(!0)) : (console.log("Not live - Opening Modal"), _(!1), g(!0), p("idle"), R(3));
|
|
323
|
+
} catch (u) {
|
|
324
|
+
console.error("API Error:", u), g(!0), p("idle");
|
|
325
325
|
}
|
|
326
|
-
},
|
|
326
|
+
}, F = {
|
|
327
327
|
Smile: "Show us a big SMILE! 😁",
|
|
328
328
|
Blink: "BLINK your eyes rapidly! 👁️",
|
|
329
329
|
Turn_Head: "Slowly TURN your head left and right! ↔️",
|
|
330
330
|
Thumbs_Up: "Give a THUMBS UP! 👍"
|
|
331
331
|
};
|
|
332
|
-
return /* @__PURE__ */
|
|
333
|
-
|
|
332
|
+
return /* @__PURE__ */ t.jsxs("div", { style: { textAlign: "center", padding: "20px", fontFamily: "sans-serif" }, children: [
|
|
333
|
+
y && i !== "success" && /* @__PURE__ */ t.jsxs("div", { style: { fontSize: "20px", fontWeight: "bold", color: E < 10 ? "red" : "black" }, children: [
|
|
334
334
|
"Time Remaining: ",
|
|
335
|
-
|
|
335
|
+
E,
|
|
336
336
|
"s"
|
|
337
337
|
] }),
|
|
338
|
-
|
|
339
|
-
/* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
338
|
+
L && /* @__PURE__ */ t.jsx("div", { style: ue, children: /* @__PURE__ */ t.jsxs("div", { style: fe, children: [
|
|
339
|
+
/* @__PURE__ */ t.jsx("h3", { style: { color: "#dc3545" }, children: "Action Not Detected" }),
|
|
340
|
+
/* @__PURE__ */ t.jsx("p", { children: "We couldn't verify that move. Please try again before time runs out!" }),
|
|
341
|
+
/* @__PURE__ */ t.jsx("button", { onClick: () => {
|
|
342
|
+
g(!1), P();
|
|
343
|
+
}, style: N, children: "Try Again" })
|
|
344
|
+
] }) }),
|
|
345
|
+
i === "success" && /* @__PURE__ */ t.jsxs("div", { children: [
|
|
346
|
+
/* @__PURE__ */ t.jsx("h2", { children: "✅ Verification Passed!" }),
|
|
347
|
+
/* @__PURE__ */ t.jsx("button", { onClick: D, style: { ...N, backgroundColor: "#6c757d" }, children: "Verify Again" })
|
|
341
348
|
] }),
|
|
342
|
-
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */
|
|
349
|
+
i === "timeout" && /* @__PURE__ */ t.jsxs("div", { children: [
|
|
350
|
+
/* @__PURE__ */ t.jsx("h2", { style: { color: "#dc3545" }, children: "⏰ Session Expired" }),
|
|
351
|
+
/* @__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 secsonds)" }),
|
|
353
|
+
/* @__PURE__ */ t.jsx("button", { onClick: k, style: N, children: "🔄 Try Again" })
|
|
347
354
|
] }),
|
|
348
|
-
["idle", "counting", "capturing", "verifying"].includes(
|
|
349
|
-
/* @__PURE__ */
|
|
350
|
-
/* @__PURE__ */
|
|
355
|
+
["idle", "counting", "capturing", "verifying"].includes(i) && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
356
|
+
/* @__PURE__ */ t.jsx("h2", { children: "Please be in a well-lit room where your face can be well seen." }),
|
|
357
|
+
/* @__PURE__ */ t.jsxs("h3", { children: [
|
|
351
358
|
"Challenge ",
|
|
352
359
|
a + 1,
|
|
353
360
|
" of 3"
|
|
354
361
|
] }),
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
/* @__PURE__ */
|
|
357
|
-
/* @__PURE__ */
|
|
362
|
+
/* @__PURE__ */ t.jsx("h2", { style: { color: "#007bff" }, children: F[f[a]] }),
|
|
363
|
+
/* @__PURE__ */ t.jsxs("div", { style: { position: "relative", width: "fit-content", margin: "auto" }, children: [
|
|
364
|
+
/* @__PURE__ */ t.jsx(
|
|
358
365
|
ae,
|
|
359
366
|
{
|
|
360
367
|
audio: !1,
|
|
@@ -363,14 +370,14 @@ const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"], K = 90, de = ({ apiUrl:
|
|
|
363
370
|
style: { borderRadius: "10px", width: "100%", maxWidth: "400px", transform: "scaleX(-1)" }
|
|
364
371
|
}
|
|
365
372
|
),
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
373
|
+
i === "counting" && /* @__PURE__ */ t.jsx("div", { style: V, children: I }),
|
|
374
|
+
i === "verifying" && /* @__PURE__ */ t.jsx("div", { style: V, children: "Analyzing..." }),
|
|
375
|
+
i === "capturing" && /* @__PURE__ */ t.jsx("div", { style: { ...V, background: "rgba(40, 167, 69, 0.3)" }, children: "Recording..." })
|
|
369
376
|
] }),
|
|
370
|
-
/* @__PURE__ */
|
|
377
|
+
/* @__PURE__ */ t.jsx("div", { style: { marginTop: "20px" }, children: i === "idle" && /* @__PURE__ */ t.jsx("button", { onClick: P, style: N, children: "I'm Ready" }) })
|
|
371
378
|
] })
|
|
372
379
|
] });
|
|
373
|
-
},
|
|
380
|
+
}, V = {
|
|
374
381
|
position: "absolute",
|
|
375
382
|
top: 0,
|
|
376
383
|
left: 0,
|
|
@@ -383,7 +390,7 @@ const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"], K = 90, de = ({ apiUrl:
|
|
|
383
390
|
justifyContent: "center",
|
|
384
391
|
fontSize: "48px",
|
|
385
392
|
borderRadius: "10px"
|
|
386
|
-
},
|
|
393
|
+
}, N = {
|
|
387
394
|
padding: "10px 30px",
|
|
388
395
|
fontSize: "18px",
|
|
389
396
|
cursor: "pointer",
|
|
@@ -391,19 +398,38 @@ const ce = ["Smile", "Blink", "Turn_Head", "Thumbs_Up"], K = 90, de = ({ apiUrl:
|
|
|
391
398
|
color: "white",
|
|
392
399
|
border: "none",
|
|
393
400
|
borderRadius: "5px"
|
|
394
|
-
},
|
|
395
|
-
|
|
401
|
+
}, ue = {
|
|
402
|
+
position: "absolute",
|
|
403
|
+
top: 0,
|
|
404
|
+
left: 0,
|
|
405
|
+
right: 0,
|
|
406
|
+
bottom: 0,
|
|
407
|
+
backgroundColor: "rgba(0,0,0,0.7)",
|
|
408
|
+
display: "flex",
|
|
409
|
+
alignItems: "center",
|
|
410
|
+
justifyContent: "center",
|
|
411
|
+
zIndex: 100,
|
|
412
|
+
borderRadius: "10px"
|
|
413
|
+
}, fe = {
|
|
414
|
+
backgroundColor: "white",
|
|
415
|
+
padding: "30px",
|
|
416
|
+
borderRadius: "15px",
|
|
417
|
+
maxWidth: "300px",
|
|
418
|
+
boxShadow: "0 4px 15px rgba(0,0,0,0.3)",
|
|
419
|
+
color: "#000"
|
|
420
|
+
}, he = async (d, m, b) => {
|
|
421
|
+
const f = new FormData();
|
|
396
422
|
m.forEach((a, v) => {
|
|
397
|
-
|
|
398
|
-
}),
|
|
399
|
-
const
|
|
423
|
+
f.append("files", a, `frame_${v}.jpg`);
|
|
424
|
+
}), f.append("challenge", b);
|
|
425
|
+
const l = await fetch(`${d}/v1/verify`, {
|
|
400
426
|
method: "POST",
|
|
401
|
-
body:
|
|
427
|
+
body: f
|
|
402
428
|
});
|
|
403
|
-
if (!
|
|
404
|
-
return await
|
|
429
|
+
if (!l.ok) throw new Error("Network response was not ok");
|
|
430
|
+
return await l.json();
|
|
405
431
|
};
|
|
406
432
|
export {
|
|
407
|
-
|
|
408
|
-
|
|
433
|
+
pe as LivenessSDK,
|
|
434
|
+
he as verifyLiveness
|
|
409
435
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(g,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react"),require("react-webcam")):typeof define=="function"&&define.amd?define(["exports","react","react-webcam"],u):(g=typeof globalThis<"u"?globalThis:g||self,u(g.LivenessSDK={},g.React,g.Webcam))})(this,function(g,u,re){"use strict";var L={exports:{}},k={};/**
|
|
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 J;function ne(){if(J)return k;J=1;var m=Symbol.for("react.transitional.element"),p=Symbol.for("react.fragment");function v(d,i,a){var y=null;if(a!==void 0&&(y=""+a),i.key!==void 0&&(y=""+i.key),"key"in i){a={};for(var l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:m,type:d,key:y,ref:i!==void 0?i:null,props:a}}return k.Fragment=p,k.jsx=v,k.jsxs=v,k}var A={};/**
|
|
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 X;function oe(){return X||(X=1,process.env.NODE_ENV!=="production"&&function(){function m(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===w?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case _:return"Fragment";case M:return"Profiler";case P:return"StrictMode";case z:return"Suspense";case c:return"SuspenseList";case R: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 F:return"Portal";case U:return e.displayName||"Context";case N:return(e._context.displayName||"Context")+".Consumer";case W:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case b:return t=e.displayName||null,t!==null?t:m(e.type)||"Memo";case f:t=e._payload,e=e._init;try{return m(e(t))}catch{}}return null}function p(e){return""+e}function v(e){try{p(e);var t=!1}catch{t=!0}if(t){t=console;var n=t.error,o=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),p(e)}}function d(e){if(e===_)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===f)return"<...>";try{var t=m(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function i(){var e=V.A;return e===null?null:e.getOwner()}function a(){return Error("react-stack-top-frame")}function y(e){if(Z.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function l(e,t){function n(){Q||(Q=!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))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function h(){var e=m(this.type);return q[e]||(q[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 Y(e,t,n,o,I,G){var s=n.ref;return e={$$typeof:T,type:e,key:t,props:n,_owner:o},(s!==void 0?s:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:h}):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:I}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function S(e,t,n,o,I,G){var s=t.children;if(s!==void 0)if(o)if(ue(s)){for(o=0;o<s.length;o++)x(s[o]);Object.freeze&&Object.freeze(s)}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 x(s);if(Z.call(t,"key")){s=m(e);var j=Object.keys(t).filter(function(fe){return fe!=="key"});o=0<j.length?"{key: someKey, "+j.join(": ..., ")+": ...}":"{key: someKey}",te[s+o]||(j=0<j.length?"{"+j.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} />`,s,
|
|
22
|
+
<%s key={someKey} {...props} />`,o,s,j,s),te[s+o]=!0)}if(s=null,n!==void 0&&(v(n),s=""+n),y(t)&&(v(t.key),s=""+t.key),"key"in t){n={};for(var H in t)H!=="key"&&(n[H]=t[H])}else n=t;return s&&l(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),Y(e,s,n,i(),I,G)}function x(e){O(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===f&&(e._payload.status==="fulfilled"?O(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function O(e){return typeof e=="object"&&e!==null&&e.$$typeof===T}var E=u,T=Symbol.for("react.transitional.element"),F=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),U=Symbol.for("react.context"),W=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),w=Symbol.for("react.client.reference"),V=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=Object.prototype.hasOwnProperty,ue=Array.isArray,B=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var Q,q={},$=E.react_stack_bottom_frame.bind(E,a)(),ee=B(d(a)),te={};A.Fragment=_,A.jsx=function(e,t,n){var o=1e4>V.recentlyCreatedOwnerStacks++;return S(e,t,n,!1,o?Error("react-stack-top-frame"):$,o?B(d(e)):ee)},A.jsxs=function(e,t,n){var o=1e4>V.recentlyCreatedOwnerStacks++;return S(e,t,n,!0,o?Error("react-stack-top-frame"):$,o?B(d(e)):ee)}}()),A}process.env.NODE_ENV==="production"?L.exports=ne():L.exports=oe();var r=L.exports;const se=["Smile","Blink","Turn_Head","Thumbs_Up"],K=60,ae=({apiUrl:m,onComplete:p})=>{const v=u.useRef(null),[d,i]=u.useState([]),[a,y]=u.useState(0),[l,h]=u.useState("idle"),[Y,S]=u.useState(3),[x,O]=u.useState(K),[E,T]=u.useState(!1),[F,_]=u.useState(!1),P=()=>{const c=[...se].sort(()=>.5-Math.random()).slice(0,3);i(c),y(0),h("idle"),S(3),O(K),T(!1),_(!1)};u.useEffect(()=>{P()},[]);const M=()=>{P()};u.useEffect(()=>{let c;return E&&x>0?c=setInterval(()=>{O(b=>b-1)},1e3):x===0&&l!=="success"&&(h("timeout"),T(!1),_(!1),p&&p(!1)),()=>clearInterval(c)},[E,x,l]);const N=async()=>{E||T(!0),h("counting");let c=3;const b=setInterval(()=>{c-=1,S(c),c===0&&(clearInterval(b),U())},1e3)},U=async()=>{h("capturing");const c=[],b=20;for(let f=0;f<b;f++){const R=v.current.getScreenshot();c.push(R),await new Promise(w=>setTimeout(w,100))}W(c)},W=async c=>{window.dummyTest="I am working!",console.log("SEND TO BRAIN CALLED"),h("verifying");const b=new FormData;for(let f=0;f<c.length;f++){const R=await fetch(c[f]).then(w=>w.blob());b.append("files",R,`frame_${f}.jpg`)}b.append("challenge",d[a]);try{const R=await(await fetch(`${m}/v1/verify`,{method:"POST",body:b})).json();console.log("API Response:",R.status),R.is_live?a<2?(y(w=>w+1),S(3),h("idle")):(h("success"),T(!1),p&&p(!0)):(console.log("Not live - Opening Modal"),T(!1),_(!0),h("idle"),S(3))}catch(f){console.error("API Error:",f),_(!0),h("idle")}},z={Smile:"Show us a big SMILE! 😁",Blink:"BLINK your eyes rapidly! 👁️",Turn_Head:"Slowly TURN your head left and right! ↔️",Thumbs_Up:"Give a THUMBS UP! 👍"};return r.jsxs("div",{style:{textAlign:"center",padding:"20px",fontFamily:"sans-serif"},children:[E&&l!=="success"&&r.jsxs("div",{style:{fontSize:"20px",fontWeight:"bold",color:x<10?"red":"black"},children:["Time Remaining: ",x,"s"]}),F&&r.jsx("div",{style:ie,children:r.jsxs("div",{style:le,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:()=>{_(!1),N()},style:C,children:"Try Again"})]})}),l==="success"&&r.jsxs("div",{children:[r.jsx("h2",{children:"✅ Verification Passed!"}),r.jsx("button",{onClick:M,style:{...C,backgroundColor:"#6c757d"},children:"Verify Again"})]}),l==="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 secsonds)"}),r.jsx("button",{onClick:P,style:C,children:"🔄 Try Again"})]}),["idle","counting","capturing","verifying"].includes(l)&&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 ",a+1," of 3"]}),r.jsx("h2",{style:{color:"#007bff"},children:z[d[a]]}),r.jsxs("div",{style:{position:"relative",width:"fit-content",margin:"auto"},children:[r.jsx(re,{audio:!1,ref:v,screenshotFormat:"image/jpeg",style:{borderRadius:"10px",width:"100%",maxWidth:"400px",transform:"scaleX(-1)"}}),l==="counting"&&r.jsx("div",{style:D,children:Y}),l==="verifying"&&r.jsx("div",{style:D,children:"Analyzing..."}),l==="capturing"&&r.jsx("div",{style:{...D,background:"rgba(40, 167, 69, 0.3)"},children:"Recording..."})]}),r.jsx("div",{style:{marginTop:"20px"},children:l==="idle"&&r.jsx("button",{onClick:N,style:C,children:"I'm Ready"})})]})]})},D={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"},C={padding:"10px 30px",fontSize:"18px",cursor:"pointer",backgroundColor:"#28a745",color:"white",border:"none",borderRadius:"5px"},ie={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"},le={backgroundColor:"white",padding:"30px",borderRadius:"15px",maxWidth:"300px",boxShadow:"0 4px 15px rgba(0,0,0,0.3)",color:"#000"},ce=async(m,p,v)=>{const d=new FormData;p.forEach((a,y)=>{d.append("files",a,`frame_${y}.jpg`)}),d.append("challenge",v);const i=await fetch(`${m}/v1/verify`,{method:"POST",body:d});if(!i.ok)throw new Error("Network response was not ok");return await i.json()};g.LivenessSDK=ae,g.verifyLiveness=ce,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|