@seontechnologies/seon-id-verification
Version:
An advanced SDK featuring web components for natural person identification through document scanning, facial recognition, hand gesture, and face turning detection, designed for secure and efficient user verification.
79 lines (78 loc) • 3.74 kB
JavaScript
import { a as B, l as F, j as i } from "./index-oGnhSncZ.mjs";
import { useState as m, useRef as D, useMemo as L, useCallback as a } from "react";
import { C as G, a as $ } from "./CameraCard-DCtEAYmX.mjs";
import { E as H, X as J, s as k, S as K, L as Q, a as Y } from "./UploadLivenessVideo-ia7J-Ak0.mjs";
import { M as Z } from "./MediaPipeVideo-BLVUgMdB.mjs";
let T = 0;
const et = (E) => {
const { onNext: M, onBack: O } = E, [c, S] = m(0), r = D(null), s = D(null), [l, U] = m(!1), [C, I] = m(!1), [V, b] = m(!1), z = L(() => B.config.promptLength, []), o = L(() => H.mediaPipe.CFaceDetectionConfig, []), N = 10, f = a((t) => {
S(t);
}, []), p = a((t) => {
U(t);
}, []), W = a((t) => {
I(t);
}, []), X = a(({ isRecordingStopped: t }) => {
!l && !t ? f(0) : (l && !t || t) && f(1);
}, [f, l]), q = a(async () => {
var e;
(e = s.current) == null || e.close(), s.current = null;
const t = await J.forVisionTasks(o.forVisionTasks);
s.current = await k.createFromOptions(t, {
baseOptions: {
modelAssetPath: o.modelAssetPath,
delegate: "GPU"
},
minDetectionConfidence: o.minDetectionConfidence,
runningMode: "VIDEO"
});
}, [
o.forVisionTasks,
o.minDetectionConfidence,
o.modelAssetPath
]), g = a(async ({ capturedInRow: t, videoDetectedChunkStartingTime: e, isDurationCompleted: h, mediaRecorder: n, capturedVideo: w, minFaceCapturedInRow: _, videoDurationS: j, setIsRecordingStopped: A, uploadVideo: P }) => {
var y;
if (!((y = r.current) != null && y.srcObject) || !s.current || !(s.current instanceof k))
return;
const x = performance.now();
let v = [];
r.current && s.current && (v = s.current.detectForVideo(r.current, x).detections), v.length > 0 ? (p(!0), t.current = t.current + 1) : (p(!1), t.current = 0, e.current = null, (n == null ? void 0 : n.state) === "recording" && n.stop()), t.current === _ && (e.current = x, (n == null ? void 0 : n.state) !== "recording" && n.start()), h.current = e.current ? x - e.current > j * 1e3 : !1, h.current && (n == null ? void 0 : n.state) === "recording" && (A(!0), b(!0), n.stop(), setTimeout(() => {
cancelAnimationFrame(T), P(w.current, []);
}, 1400)), T = window.requestAnimationFrame(() => g({
capturedInRow: t,
videoDetectedChunkStartingTime: e,
isDurationCompleted: h,
mediaRecorder: n,
capturedVideo: w,
minFaceCapturedInRow: _,
videoDurationS: j,
setIsRecordingStopped: A,
uploadVideo: P
}));
}, [s, p, r]), u = [
{
instruction: {
icon: i.jsx(K, { width: 48, hanging: 48 }),
text: F.liveness_check_action_position_face
},
animateTo: {
startAnimationTo: l,
strokeDasharray: "0",
strokeWidth: "4"
},
outline: "idle",
dimension: "face-only"
},
{
instruction: {
text: F.liveness_check_action_hold
},
outline: "countdown",
dimension: "face-only",
startAnimation: l
}
];
return i.jsxs(i.Fragment, { children: [i.jsx(G, { className: `tw-w-full tw-h-full sm:tw-h-auto ${C && "tw-opacity-0"}`, children: i.jsx($, { idPrefix: "selfie-liveness-camera", onBack: O, title: F.liveness_check_selfie_flow_title, instructions: u[c].instruction, children: i.jsx(Q, { dimension: u[c].dimension, outline: u[c].outline, startAnimation: u[c].startAnimation, animateTo: u[c].animateTo, isSuccessful: V, children: i.jsx(Z, { initializeDetector: q, videoRef: r, videoDurationS: z, minFaceCapturedInRow: N, detectorRef: s, onNext: M, handleIsUploading: W, detectionLoop: g, handleAnimationSteps: X }) }) }) }), i.jsx(Y, { isUploading: C })] });
};
export {
et as default
};