@richard.fadiora/liveness-detection 4.3.7 → 4.3.8

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.js CHANGED
@@ -1,645 +1,8 @@
1
- import { verifyLiveness as mt } from "./api-BpiDoGOd.js";
2
- import { L as k } from "./LivenessCheck-DxxnvHvi.js";
3
- import { a as St, u as gt } from "./LivenessCheck-DxxnvHvi.js";
4
- import { Injectable as W, ViewChild as K, Input as l, Output as H, Component as q, ViewEncapsulation as G, EventEmitter as A } from "@angular/core";
5
- import { CommonModule as J } from "@angular/common";
6
- var w = function(e, r) {
7
- return w = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
8
- t.__proto__ = n;
9
- } || function(t, n) {
10
- for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
11
- }, w(e, r);
12
- };
13
- function d(e, r) {
14
- if (typeof r != "function" && r !== null)
15
- throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
16
- w(e, r);
17
- function t() {
18
- this.constructor = e;
19
- }
20
- e.prototype = r === null ? Object.create(r) : (t.prototype = r.prototype, new t());
21
- }
22
- function E(e) {
23
- var r = typeof Symbol == "function" && Symbol.iterator, t = r && e[r], n = 0;
24
- if (t) return t.call(e);
25
- if (e && typeof e.length == "number") return {
26
- next: function() {
27
- return e && n >= e.length && (e = void 0), { value: e && e[n++], done: !e };
28
- }
29
- };
30
- throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
31
- }
32
- function O(e, r) {
33
- var t = typeof Symbol == "function" && e[Symbol.iterator];
34
- if (!t) return e;
35
- var n = t.call(e), o, i = [], s;
36
- try {
37
- for (; (r === void 0 || r-- > 0) && !(o = n.next()).done; ) i.push(o.value);
38
- } catch (c) {
39
- s = { error: c };
40
- } finally {
41
- try {
42
- o && !o.done && (t = n.return) && t.call(n);
43
- } finally {
44
- if (s) throw s.error;
45
- }
46
- }
47
- return i;
48
- }
49
- function C(e, r, t) {
50
- if (t || arguments.length === 2) for (var n = 0, o = r.length, i; n < o; n++)
51
- (i || !(n in r)) && (i || (i = Array.prototype.slice.call(r, 0, n)), i[n] = r[n]);
52
- return e.concat(i || Array.prototype.slice.call(r));
53
- }
54
- function f(e) {
55
- return typeof e == "function";
56
- }
57
- function R(e) {
58
- var r = function(n) {
59
- Error.call(n), n.stack = new Error().stack;
60
- }, t = e(r);
61
- return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
62
- }
63
- var g = R(function(e) {
64
- return function(t) {
65
- e(this), this.message = t ? t.length + ` errors occurred during unsubscription:
66
- ` + t.map(function(n, o) {
67
- return o + 1 + ") " + n.toString();
68
- }).join(`
69
- `) : "", this.name = "UnsubscriptionError", this.errors = t;
70
- };
71
- });
72
- function x(e, r) {
73
- if (e) {
74
- var t = e.indexOf(r);
75
- 0 <= t && e.splice(t, 1);
76
- }
77
- }
78
- var _ = function() {
79
- function e(r) {
80
- this.initialTeardown = r, this.closed = !1, this._parentage = null, this._finalizers = null;
81
- }
82
- return e.prototype.unsubscribe = function() {
83
- var r, t, n, o, i;
84
- if (!this.closed) {
85
- this.closed = !0;
86
- var s = this._parentage;
87
- if (s)
88
- if (this._parentage = null, Array.isArray(s))
89
- try {
90
- for (var c = E(s), p = c.next(); !p.done; p = c.next()) {
91
- var S = p.value;
92
- S.remove(this);
93
- }
94
- } catch (h) {
95
- r = { error: h };
96
- } finally {
97
- try {
98
- p && !p.done && (t = c.return) && t.call(c);
99
- } finally {
100
- if (r) throw r.error;
101
- }
102
- }
103
- else
104
- s.remove(this);
105
- var j = this.initialTeardown;
106
- if (f(j))
107
- try {
108
- j();
109
- } catch (h) {
110
- i = h instanceof g ? h.errors : [h];
111
- }
112
- var P = this._finalizers;
113
- if (P) {
114
- this._finalizers = null;
115
- try {
116
- for (var y = E(P), v = y.next(); !v.done; v = y.next()) {
117
- var $ = v.value;
118
- try {
119
- I($);
120
- } catch (h) {
121
- i = i ?? [], h instanceof g ? i = C(C([], O(i)), O(h.errors)) : i.push(h);
122
- }
123
- }
124
- } catch (h) {
125
- n = { error: h };
126
- } finally {
127
- try {
128
- v && !v.done && (o = y.return) && o.call(y);
129
- } finally {
130
- if (n) throw n.error;
131
- }
132
- }
133
- }
134
- if (i)
135
- throw new g(i);
136
- }
137
- }, e.prototype.add = function(r) {
138
- var t;
139
- if (r && r !== this)
140
- if (this.closed)
141
- I(r);
142
- else {
143
- if (r instanceof e) {
144
- if (r.closed || r._hasParent(this))
145
- return;
146
- r._addParent(this);
147
- }
148
- (this._finalizers = (t = this._finalizers) !== null && t !== void 0 ? t : []).push(r);
149
- }
150
- }, e.prototype._hasParent = function(r) {
151
- var t = this._parentage;
152
- return t === r || Array.isArray(t) && t.includes(r);
153
- }, e.prototype._addParent = function(r) {
154
- var t = this._parentage;
155
- this._parentage = Array.isArray(t) ? (t.push(r), t) : t ? [t, r] : r;
156
- }, e.prototype._removeParent = function(r) {
157
- var t = this._parentage;
158
- t === r ? this._parentage = null : Array.isArray(t) && x(t, r);
159
- }, e.prototype.remove = function(r) {
160
- var t = this._finalizers;
161
- t && x(t, r), r instanceof e && r._removeParent(this);
162
- }, e.EMPTY = function() {
163
- var r = new e();
164
- return r.closed = !0, r;
165
- }(), e;
166
- }(), V = _.EMPTY;
167
- function F(e) {
168
- return e instanceof _ || e && "closed" in e && f(e.remove) && f(e.add) && f(e.unsubscribe);
169
- }
170
- function I(e) {
171
- f(e) ? e() : e.unsubscribe();
172
- }
173
- var Q = {
174
- Promise: void 0
175
- }, X = {
176
- setTimeout: function(e, r) {
177
- for (var t = [], n = 2; n < arguments.length; n++)
178
- t[n - 2] = arguments[n];
179
- return setTimeout.apply(void 0, C([e, r], O(t)));
180
- },
181
- clearTimeout: function(e) {
182
- return clearTimeout(e);
183
- },
184
- delegate: void 0
185
- };
186
- function z(e) {
187
- X.setTimeout(function() {
188
- throw e;
189
- });
190
- }
191
- function U() {
192
- }
193
- function m(e) {
194
- e();
195
- }
196
- var Y = function(e) {
197
- d(r, e);
198
- function r(t) {
199
- var n = e.call(this) || this;
200
- return n.isStopped = !1, t ? (n.destination = t, F(t) && t.add(n)) : n.destination = rt, n;
201
- }
202
- return r.create = function(t, n, o) {
203
- return new T(t, n, o);
204
- }, r.prototype.next = function(t) {
205
- this.isStopped || this._next(t);
206
- }, r.prototype.error = function(t) {
207
- this.isStopped || (this.isStopped = !0, this._error(t));
208
- }, r.prototype.complete = function() {
209
- this.isStopped || (this.isStopped = !0, this._complete());
210
- }, r.prototype.unsubscribe = function() {
211
- this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
212
- }, r.prototype._next = function(t) {
213
- this.destination.next(t);
214
- }, r.prototype._error = function(t) {
215
- try {
216
- this.destination.error(t);
217
- } finally {
218
- this.unsubscribe();
219
- }
220
- }, r.prototype._complete = function() {
221
- try {
222
- this.destination.complete();
223
- } finally {
224
- this.unsubscribe();
225
- }
226
- }, r;
227
- }(_), N = function() {
228
- function e(r) {
229
- this.partialObserver = r;
230
- }
231
- return e.prototype.next = function(r) {
232
- var t = this.partialObserver;
233
- if (t.next)
234
- try {
235
- t.next(r);
236
- } catch (n) {
237
- b(n);
238
- }
239
- }, e.prototype.error = function(r) {
240
- var t = this.partialObserver;
241
- if (t.error)
242
- try {
243
- t.error(r);
244
- } catch (n) {
245
- b(n);
246
- }
247
- else
248
- b(r);
249
- }, e.prototype.complete = function() {
250
- var r = this.partialObserver;
251
- if (r.complete)
252
- try {
253
- r.complete();
254
- } catch (t) {
255
- b(t);
256
- }
257
- }, e;
258
- }(), T = function(e) {
259
- d(r, e);
260
- function r(t, n, o) {
261
- var i = e.call(this) || this, s;
262
- return f(t) || !t ? s = {
263
- next: t ?? void 0,
264
- error: n ?? void 0,
265
- complete: o ?? void 0
266
- } : s = t, i.destination = new N(s), i;
267
- }
268
- return r;
269
- }(Y);
270
- function b(e) {
271
- z(e);
272
- }
273
- function tt(e) {
274
- throw e;
275
- }
276
- var rt = {
277
- closed: !0,
278
- next: U,
279
- error: tt,
280
- complete: U
281
- }, et = function() {
282
- return typeof Symbol == "function" && Symbol.observable || "@@observable";
283
- }();
284
- function nt(e) {
285
- return e;
286
- }
287
- function ot(e) {
288
- return e.length === 0 ? nt : e.length === 1 ? e[0] : function(t) {
289
- return e.reduce(function(n, o) {
290
- return o(n);
291
- }, t);
292
- };
293
- }
294
- var M = function() {
295
- function e(r) {
296
- r && (this._subscribe = r);
297
- }
298
- return e.prototype.lift = function(r) {
299
- var t = new e();
300
- return t.source = this, t.operator = r, t;
301
- }, e.prototype.subscribe = function(r, t, n) {
302
- var o = this, i = st(r) ? r : new T(r, t, n);
303
- return m(function() {
304
- var s = o, c = s.operator, p = s.source;
305
- i.add(c ? c.call(i, p) : p ? o._subscribe(i) : o._trySubscribe(i));
306
- }), i;
307
- }, e.prototype._trySubscribe = function(r) {
308
- try {
309
- return this._subscribe(r);
310
- } catch (t) {
311
- r.error(t);
312
- }
313
- }, e.prototype.forEach = function(r, t) {
314
- var n = this;
315
- return t = B(t), new t(function(o, i) {
316
- var s = new T({
317
- next: function(c) {
318
- try {
319
- r(c);
320
- } catch (p) {
321
- i(p), s.unsubscribe();
322
- }
323
- },
324
- error: i,
325
- complete: o
326
- });
327
- n.subscribe(s);
328
- });
329
- }, e.prototype._subscribe = function(r) {
330
- var t;
331
- return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(r);
332
- }, e.prototype[et] = function() {
333
- return this;
334
- }, e.prototype.pipe = function() {
335
- for (var r = [], t = 0; t < arguments.length; t++)
336
- r[t] = arguments[t];
337
- return ot(r)(this);
338
- }, e.prototype.toPromise = function(r) {
339
- var t = this;
340
- return r = B(r), new r(function(n, o) {
341
- var i;
342
- t.subscribe(function(s) {
343
- return i = s;
344
- }, function(s) {
345
- return o(s);
346
- }, function() {
347
- return n(i);
348
- });
349
- });
350
- }, e.create = function(r) {
351
- return new e(r);
352
- }, e;
353
- }();
354
- function B(e) {
355
- var r;
356
- return (r = e ?? Q.Promise) !== null && r !== void 0 ? r : Promise;
357
- }
358
- function it(e) {
359
- return e && f(e.next) && f(e.error) && f(e.complete);
360
- }
361
- function st(e) {
362
- return e && e instanceof Y || it(e) && F(e);
363
- }
364
- var ut = R(function(e) {
365
- return function() {
366
- e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
367
- };
368
- }), Z = function(e) {
369
- d(r, e);
370
- function r() {
371
- var t = e.call(this) || this;
372
- return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
373
- }
374
- return r.prototype.lift = function(t) {
375
- var n = new D(this, this);
376
- return n.operator = t, n;
377
- }, r.prototype._throwIfClosed = function() {
378
- if (this.closed)
379
- throw new ut();
380
- }, r.prototype.next = function(t) {
381
- var n = this;
382
- m(function() {
383
- var o, i;
384
- if (n._throwIfClosed(), !n.isStopped) {
385
- n.currentObservers || (n.currentObservers = Array.from(n.observers));
386
- try {
387
- for (var s = E(n.currentObservers), c = s.next(); !c.done; c = s.next()) {
388
- var p = c.value;
389
- p.next(t);
390
- }
391
- } catch (S) {
392
- o = { error: S };
393
- } finally {
394
- try {
395
- c && !c.done && (i = s.return) && i.call(s);
396
- } finally {
397
- if (o) throw o.error;
398
- }
399
- }
400
- }
401
- });
402
- }, r.prototype.error = function(t) {
403
- var n = this;
404
- m(function() {
405
- if (n._throwIfClosed(), !n.isStopped) {
406
- n.hasError = n.isStopped = !0, n.thrownError = t;
407
- for (var o = n.observers; o.length; )
408
- o.shift().error(t);
409
- }
410
- });
411
- }, r.prototype.complete = function() {
412
- var t = this;
413
- m(function() {
414
- if (t._throwIfClosed(), !t.isStopped) {
415
- t.isStopped = !0;
416
- for (var n = t.observers; n.length; )
417
- n.shift().complete();
418
- }
419
- });
420
- }, r.prototype.unsubscribe = function() {
421
- this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
422
- }, Object.defineProperty(r.prototype, "observed", {
423
- get: function() {
424
- var t;
425
- return ((t = this.observers) === null || t === void 0 ? void 0 : t.length) > 0;
426
- },
427
- enumerable: !1,
428
- configurable: !0
429
- }), r.prototype._trySubscribe = function(t) {
430
- return this._throwIfClosed(), e.prototype._trySubscribe.call(this, t);
431
- }, r.prototype._subscribe = function(t) {
432
- return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
433
- }, r.prototype._innerSubscribe = function(t) {
434
- var n = this, o = this, i = o.hasError, s = o.isStopped, c = o.observers;
435
- return i || s ? V : (this.currentObservers = null, c.push(t), new _(function() {
436
- n.currentObservers = null, x(c, t);
437
- }));
438
- }, r.prototype._checkFinalizedStatuses = function(t) {
439
- var n = this, o = n.hasError, i = n.thrownError, s = n.isStopped;
440
- o ? t.error(i) : s && t.complete();
441
- }, r.prototype.asObservable = function() {
442
- var t = new M();
443
- return t.source = this, t;
444
- }, r.create = function(t, n) {
445
- return new D(t, n);
446
- }, r;
447
- }(M), D = function(e) {
448
- d(r, e);
449
- function r(t, n) {
450
- var o = e.call(this) || this;
451
- return o.destination = t, o.source = n, o;
452
- }
453
- return r.prototype.next = function(t) {
454
- var n, o;
455
- (o = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || o === void 0 || o.call(n, t);
456
- }, r.prototype.error = function(t) {
457
- var n, o;
458
- (o = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || o === void 0 || o.call(n, t);
459
- }, r.prototype.complete = function() {
460
- var t, n;
461
- (n = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || n === void 0 || n.call(t);
462
- }, r.prototype._subscribe = function(t) {
463
- var n, o;
464
- return (o = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(t)) !== null && o !== void 0 ? o : V;
465
- }, r;
466
- }(Z), at = function(e) {
467
- d(r, e);
468
- function r(t) {
469
- var n = e.call(this) || this;
470
- return n._value = t, n;
471
- }
472
- return Object.defineProperty(r.prototype, "value", {
473
- get: function() {
474
- return this.getValue();
475
- },
476
- enumerable: !1,
477
- configurable: !0
478
- }), r.prototype._subscribe = function(t) {
479
- var n = e.prototype._subscribe.call(this, t);
480
- return !n.closed && t.next(this._value), n;
481
- }, r.prototype.getValue = function() {
482
- var t = this, n = t.hasError, o = t.thrownError, i = t._value;
483
- if (n)
484
- throw o;
485
- return this._throwIfClosed(), i;
486
- }, r.prototype.next = function(t) {
487
- e.prototype.next.call(this, this._value = t);
488
- }, r;
489
- }(Z), ct = Object.getOwnPropertyDescriptor, lt = (e, r, t, n) => {
490
- for (var o = n > 1 ? void 0 : n ? ct(r, t) : r, i = e.length - 1, s; i >= 0; i--)
491
- (s = e[i]) && (o = s(o) || o);
492
- return o;
493
- };
494
- let L = class {
495
- constructor(e) {
496
- this.ngZone = e, this.stateSubject = new at(null), this.state$ = this.stateSubject.asObservable();
497
- }
498
- init(e) {
499
- this.ngZone.runOutsideAngular(() => {
500
- this.engine = new k({
501
- ...e,
502
- onStateChange: (r) => {
503
- this.ngZone.run(() => this.stateSubject.next(r));
504
- }
505
- }), this.engine.loadModels();
506
- });
507
- }
508
- attach(e) {
509
- var r;
510
- (r = this.engine) == null || r.attachVideo(e);
511
- }
512
- start() {
513
- var e;
514
- (e = this.engine) == null || e.start();
515
- }
516
- reset() {
517
- var e;
518
- (e = this.engine) == null || e.reset();
519
- }
520
- ngOnDestroy() {
521
- var e;
522
- (e = this.engine) == null || e.stop();
523
- }
524
- };
525
- L = lt([
526
- W({ providedIn: "root" })
527
- ], L);
528
- var pt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, a = (e, r, t, n) => {
529
- for (var o = n > 1 ? void 0 : n ? ht(r, t) : r, i = e.length - 1, s; i >= 0; i--)
530
- (s = e[i]) && (o = (n ? s(r, t, o) : s(o)) || o);
531
- return n && o && pt(r, t, o), o;
532
- };
533
- let u = class {
534
- constructor(e) {
535
- this.liveness = e, this.duration = 60, this.containerClass = "", this.videoWrapperClass = "", this.videoClass = "", this.timerClass = "", this.challengeTextClass = "", this.buttonClass = "", this.retryButtonClass = "", this.statusOverlayClass = "", this.successMessageClass = "", this.errorMessageClass = "", this.instructionBoxClass = "", this.onComplete = new A(), this.onError = new A();
536
- }
537
- ngOnInit() {
538
- this.liveness.init({
539
- apiUrl: this.apiUrl,
540
- duration: this.duration,
541
- smileThreshold: this.smileThreshold,
542
- blinkThreshold: this.blinkThreshold,
543
- minturnHeadThreshold: this.minturnHeadThreshold,
544
- maxturnHeadThreshold: this.maxturnHeadThreshold,
545
- onComplete: (e) => this.onComplete.emit(e),
546
- onError: (e) => this.onError.emit(e)
547
- });
548
- }
549
- async ngAfterViewInit() {
550
- try {
551
- const e = await navigator.mediaDevices.getUserMedia({
552
- video: { width: 640, height: 480, facingMode: "user" }
553
- }), r = this.webcamRef.nativeElement;
554
- r.srcObject = e, r.onloadedmetadata = () => {
555
- r.play(), this.liveness.attach(r);
556
- };
557
- } catch {
558
- this.onError.emit({ success: !1, reason: "Camera access denied" });
559
- }
560
- }
561
- ngOnDestroy() {
562
- var r, t;
563
- const e = (t = (r = this.webcamRef) == null ? void 0 : r.nativeElement) == null ? void 0 : t.srcObject;
564
- e == null || e.getTracks().forEach((n) => n.stop());
565
- }
566
- };
567
- a([
568
- K("webcam")
569
- ], u.prototype, "webcamRef", 2);
570
- a([
571
- l()
572
- ], u.prototype, "apiUrl", 2);
573
- a([
574
- l()
575
- ], u.prototype, "duration", 2);
576
- a([
577
- l()
578
- ], u.prototype, "smileThreshold", 2);
579
- a([
580
- l()
581
- ], u.prototype, "blinkThreshold", 2);
582
- a([
583
- l()
584
- ], u.prototype, "minturnHeadThreshold", 2);
585
- a([
586
- l()
587
- ], u.prototype, "maxturnHeadThreshold", 2);
588
- a([
589
- l()
590
- ], u.prototype, "containerClass", 2);
591
- a([
592
- l()
593
- ], u.prototype, "videoWrapperClass", 2);
594
- a([
595
- l()
596
- ], u.prototype, "videoClass", 2);
597
- a([
598
- l()
599
- ], u.prototype, "timerClass", 2);
600
- a([
601
- l()
602
- ], u.prototype, "challengeTextClass", 2);
603
- a([
604
- l()
605
- ], u.prototype, "buttonClass", 2);
606
- a([
607
- l()
608
- ], u.prototype, "retryButtonClass", 2);
609
- a([
610
- l()
611
- ], u.prototype, "statusOverlayClass", 2);
612
- a([
613
- l()
614
- ], u.prototype, "successMessageClass", 2);
615
- a([
616
- l()
617
- ], u.prototype, "errorMessageClass", 2);
618
- a([
619
- l()
620
- ], u.prototype, "instructionBoxClass", 2);
621
- a([
622
- H()
623
- ], u.prototype, "onComplete", 2);
624
- a([
625
- H()
626
- ], u.prototype, "onError", 2);
627
- u = a([
628
- q({
629
- selector: "LivenessCheck",
630
- standalone: !0,
631
- // Make it standalone
632
- imports: [J],
633
- // Add CommonModule here to fix NG8002
634
- templateUrl: "./liveness.component.html",
635
- encapsulation: G.None
636
- })
637
- ], u);
1
+ import { verifyLiveness as i } from "./api-BpiDoGOd.js";
2
+ import { L as r, a as v, u as L } from "./LivenessCheck-DxxnvHvi.js";
638
3
  export {
639
- u as LivenessComponent,
640
- k as LivenessEngine,
641
- St as LivenessSDK,
642
- L as LivenessService,
643
- gt as useLiveness,
644
- mt as verifyLiveness
4
+ r as LivenessEngine,
5
+ v as LivenessSDK,
6
+ L as useLiveness,
7
+ i as verifyLiveness
645
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@richard.fadiora/liveness-detection",
3
- "version": "4.3.7",
3
+ "version": "4.3.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [