@richard.fadiora/liveness-detection 5.0.3 → 5.0.4
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/LivenessCheck-CjVP-81C.cjs +36 -0
- package/dist/LivenessCheck-uEzmlOY8.js +4178 -0
- package/dist/angular/fesm2022/richard.fadiora-liveness-detection.mjs +25 -6
- package/dist/angular/fesm2022/richard.fadiora-liveness-detection.mjs.map +1 -1
- package/dist/core/LivenessEngine.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +10 -7
- package/dist/react.cjs +1 -22
- package/dist/react.js +3 -365
- package/package.json +1 -1
- package/dist/LivenessEngine-B1aNyAdi.js +0 -3815
- package/dist/LivenessEngine-BqatmbVS.cjs +0 -15
|
@@ -88,6 +88,7 @@ class LivenessEngine {
|
|
|
88
88
|
* Phase 2: Attach Video (Call this once the Webcam is in the DOM)
|
|
89
89
|
*/
|
|
90
90
|
attachVideo = (video) => {
|
|
91
|
+
video.setAttribute('crossorigin', 'anonymous');
|
|
91
92
|
this.webcam = video;
|
|
92
93
|
console.log("[LivenessEngine] Video stream attached.");
|
|
93
94
|
};
|
|
@@ -243,12 +244,12 @@ class LivenessEngine {
|
|
|
243
244
|
this.requestId = requestAnimationFrame(this.detectLoop);
|
|
244
245
|
}
|
|
245
246
|
};
|
|
246
|
-
handleStepSuccess(landmarks) {
|
|
247
|
+
async handleStepSuccess(landmarks) {
|
|
247
248
|
if (this.isStepTransitioningRef)
|
|
248
249
|
return;
|
|
249
250
|
this.isStepTransitioningRef = true;
|
|
250
251
|
// Capture Snapshot
|
|
251
|
-
const canvas = this.getFaceCrop(this.webcam, landmarks);
|
|
252
|
+
const canvas = await this.getFaceCrop(this.webcam, landmarks);
|
|
252
253
|
const snapshot = {
|
|
253
254
|
challenge: this.state.sequence[this.currentStepRef],
|
|
254
255
|
image: canvas.toDataURL("image/jpeg", 0.7),
|
|
@@ -311,7 +312,7 @@ class LivenessEngine {
|
|
|
311
312
|
break;
|
|
312
313
|
const faceRes = this.models.face?.detectForVideo(this.webcam, performance.now());
|
|
313
314
|
if (faceRes?.faceLandmarks?.[0]) {
|
|
314
|
-
const canvas = this.getFaceCrop(this.webcam, faceRes.faceLandmarks[0]);
|
|
315
|
+
const canvas = await this.getFaceCrop(this.webcam, faceRes.faceLandmarks[0]);
|
|
315
316
|
const blob = await new Promise(res => canvas.toBlob(res, "image/jpeg", 0.9));
|
|
316
317
|
if (blob)
|
|
317
318
|
blobs.push(blob);
|
|
@@ -337,7 +338,7 @@ class LivenessEngine {
|
|
|
337
338
|
this.config.onError({ success: false, reason: "Network error" });
|
|
338
339
|
}
|
|
339
340
|
}
|
|
340
|
-
getFaceCrop(video, landmarks) {
|
|
341
|
+
async getFaceCrop(video, landmarks) {
|
|
341
342
|
const ctx = this.offscreenCanvas.getContext("2d");
|
|
342
343
|
const xs = landmarks.map(l => l.x * video.videoWidth);
|
|
343
344
|
const ys = landmarks.map(l => l.y * video.videoHeight);
|
|
@@ -348,8 +349,26 @@ class LivenessEngine {
|
|
|
348
349
|
const width = maxX - minX;
|
|
349
350
|
const height = maxY - minY;
|
|
350
351
|
const margin = width * 0.3;
|
|
351
|
-
|
|
352
|
-
|
|
352
|
+
const sourceX = Math.max(0, minX - margin);
|
|
353
|
+
const sourceY = Math.max(0, minY - margin);
|
|
354
|
+
const sourceW = Math.min(video.videoWidth - sourceX, width + margin * 2);
|
|
355
|
+
const sourceH = Math.min(video.videoHeight - sourceY, height + margin * 2);
|
|
356
|
+
try {
|
|
357
|
+
// 2. Extract the bitmap (This bypasses many canvas-tainting triggers)
|
|
358
|
+
const bitmap = await createImageBitmap(video, sourceX, sourceY, sourceW, sourceH);
|
|
359
|
+
const ctx = this.offscreenCanvas.getContext("2d");
|
|
360
|
+
ctx.clearRect(0, 0, 224, 224);
|
|
361
|
+
// 3. Draw the clean bitmap to the offscreen canvas
|
|
362
|
+
ctx.drawImage(bitmap, 0, 0, 224, 224);
|
|
363
|
+
// 4. Important: close the bitmap to free memory
|
|
364
|
+
bitmap.close();
|
|
365
|
+
}
|
|
366
|
+
catch (e) {
|
|
367
|
+
console.error("[LivenessEngine] Bitmap extraction failed, falling back to direct draw", e);
|
|
368
|
+
// Fallback if createImageBitmap is not supported or fails
|
|
369
|
+
const ctx = this.offscreenCanvas.getContext("2d");
|
|
370
|
+
ctx.drawImage(video, sourceX, sourceY, sourceW, sourceH, 0, 0, 224, 224);
|
|
371
|
+
}
|
|
353
372
|
return this.offscreenCanvas;
|
|
354
373
|
}
|
|
355
374
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"richard.fadiora-liveness-detection.mjs","sources":["../../../src/core/LivenessEngine.ts","../../../src/angular/liveness.service.ts","../../../src/angular/liveness.component.ts","../../../src/angular/liveness.component.html","../../../src/api.ts","../../../src/richard.fadiora-liveness-detection.ts"],"sourcesContent":["// src/core/LivenessEngine.ts\r\nimport { FaceLandmarker, HandLandmarker, FilesetResolver, NormalizedLandmark } from \"@mediapipe/tasks-vision\";\r\n\r\nexport type Challenge = \"Smile\" | \"Blink\" | \"Turn_Head\" | \"Thumbs_Up\";\r\n\r\nexport interface ChallengeSnapshot {\r\n challenge: Challenge;\r\n image: string; // Base64 data URL\r\n timestamp: number;\r\n}\r\n\r\nexport interface LivenessSDKResult {\r\n success: boolean;\r\n image?: string;\r\n reason?: string;\r\n skinConfidence?: number;\r\n snapshots?: ChallengeSnapshot[];\r\n}\r\n\r\nexport interface LivenessState {\r\n status: \"loading\" | \"ready\" | \"capturing\" | \"verifying\" | \"success\" | \"error\" | \"expired\";\r\n sequence: Challenge[];\r\n currentStep: number;\r\n timeLeft: number;\r\n isStepTransitioning: boolean;\r\n errorMsg: string;\r\n snapshots: ChallengeSnapshot[];\r\n}\r\n\r\nexport interface LivenessEngineConfig {\r\n apiUrl: string;\r\n duration?: number;\r\n smileThreshold?: number;\r\n blinkThreshold?: number;\r\n minturnHeadThreshold?: number;\r\n maxturnHeadThreshold?: number;\r\n onStateChange?: (state: LivenessState) => void;\r\n onComplete?: (result: LivenessSDKResult) => void;\r\n onError?: (error: LivenessSDKResult) => void;\r\n}\r\n\r\nexport class LivenessEngine {\r\n private config: Required<LivenessEngineConfig>;\r\n private models: { face: FaceLandmarker | null; hand: HandLandmarker | null } = { face: null, hand: null };\r\n private webcam: HTMLVideoElement | null = null;\r\n private state: LivenessState;\r\n \r\n private currentStepRef = 0;\r\n private isStepTransitioningRef = false;\r\n private timerId: ReturnType<typeof setInterval> | null = null;\r\n private requestId: number | null = null;\r\n private heartbeatId: ReturnType<typeof setInterval> | null = null;\r\n \r\n // --- NEW SECURITY TRACKERS ---\r\n private anchorRatios: number | null = null;\r\n private lastNosePos: { x: number; y: number } | null = null;\r\n private consecutiveMissingFrames = 0;\r\n private readonly MAX_GAP = 15; // ~250ms buffer\r\n private readonly LIVENESS_LOCK_KEY = \"liveness_active_session\";\r\n private stabilityFrames = 0;\r\n private readonly REQUIRED_STABILITY = 10; // Wait for ~10 clear frames before locking\r\n \r\n private offscreenCanvas = document.createElement(\"canvas\");\r\n private CHALLENGE_POOL: Challenge[] = [\"Smile\", \"Blink\", \"Turn_Head\", \"Thumbs_Up\"];\r\n\r\n constructor(config: LivenessEngineConfig) {\r\n this.config = {\r\n apiUrl: config.apiUrl,\r\n duration: config.duration ?? 60,\r\n smileThreshold: config.smileThreshold ?? 0.2,\r\n blinkThreshold: config.blinkThreshold ?? 0.012,\r\n minturnHeadThreshold: config.minturnHeadThreshold ?? 0.15,\r\n maxturnHeadThreshold: config.maxturnHeadThreshold ?? 0.85,\r\n onStateChange: config.onStateChange || (() => {}),\r\n onComplete: config.onComplete || (() => {}),\r\n onError: config.onError || (() => {}),\r\n };\r\n\r\n this.state = {\r\n status: \"loading\",\r\n sequence: [],\r\n currentStep: 0,\r\n timeLeft: this.config.duration,\r\n isStepTransitioning: false,\r\n errorMsg: \"\",\r\n snapshots: [],\r\n };\r\n \r\n this.offscreenCanvas.width = 224;\r\n this.offscreenCanvas.height = 224;\r\n }\r\n\r\n /**\r\n * Phase 1: Load AI Assets (Call this immediately on mount)\r\n */\r\n public async loadModels() {\r\n console.log(\"[LivenessEngine] Loading AI Models...\");\r\n try {\r\n const vision = await FilesetResolver.forVisionTasks(\r\n \"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.3/wasm\"\r\n );\r\n\r\n this.models.face = await FaceLandmarker.createFromOptions(vision, {\r\n baseOptions: {\r\n modelAssetPath: \"https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task\",\r\n delegate: \"GPU\",\r\n },\r\n outputFaceBlendshapes: true,\r\n runningMode: \"VIDEO\",\r\n });\r\n\r\n this.models.hand = await HandLandmarker.createFromOptions(vision, {\r\n baseOptions: {\r\n modelAssetPath: \"https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task\",\r\n delegate: \"GPU\",\r\n },\r\n runningMode: \"VIDEO\",\r\n numHands: 1,\r\n });\r\n\r\n this.generateSequence();\r\n // Stay in 'loading' or move to a 'ready_to_mount' status if you prefer\r\n // For now, we move to ready to signal the UI can show the camera\r\n this.updateState({ status: \"ready\" });\r\n console.log(\"[LivenessEngine] Models Loaded.\");\r\n } catch (err) {\r\n console.error(\"[LivenessEngine] Init Error:\", err);\r\n this.updateState({ status: \"error\", errorMsg: \"Failed to load security assets.\" });\r\n }\r\n }\r\n\r\n /**\r\n * Phase 2: Attach Video (Call this once the Webcam is in the DOM)\r\n */\r\n public attachVideo = (video: HTMLVideoElement) => {\r\n this.webcam = video;\r\n console.log(\"[LivenessEngine] Video stream attached.\");\r\n };\r\n\r\n // --- NEW SECURITY METHODS ---\r\n\r\n private verifyIdentity(landmarks: NormalizedLandmark[]): boolean {\r\n const eyeDist = Math.sqrt(\r\n Math.pow(landmarks[33].x - landmarks[263].x, 2) + \r\n Math.pow(landmarks[33].y - landmarks[263].y, 2)\r\n );\r\n const noseToMouth = Math.abs(landmarks[1].y - landmarks[13].y);\r\n const currentRatio = eyeDist / (noseToMouth || 1);\r\n\r\n if (this.anchorRatios === null) {\r\n this.anchorRatios = currentRatio;\r\n return true;\r\n }\r\n\r\n const diff = Math.abs(this.anchorRatios - currentRatio) / this.anchorRatios;\r\n return diff < 0.50; // 50% tolerance for head tilt\r\n }\r\n\r\n private checkMovement(landmarks: NormalizedLandmark[]): boolean {\r\n const nose = { x: landmarks[1].x, y: landmarks[1].y };\r\n if (this.lastNosePos) {\r\n const dist = Math.sqrt(\r\n Math.pow(nose.x - this.lastNosePos.x, 2) + \r\n Math.pow(nose.y - this.lastNosePos.y, 2)\r\n );\r\n if (dist > 0.3) return false; // Sudden teleportation\r\n }\r\n this.lastNosePos = nose;\r\n return true;\r\n }\r\n\r\n private failInstantly(reason: string) {\r\n this.stop();\r\n this.updateState({ status: \"error\", errorMsg: reason, isStepTransitioning: false });\r\n this.config.onError({ success: false, reason });\r\n }\r\n\r\n public start = () => {\r\n // Multi-tab Prevention\r\n const active = localStorage.getItem(this.LIVENESS_LOCK_KEY);\r\n if (active && Date.now() - parseInt(active) < 5000) {\r\n this.failInstantly(\"Another session is active.\");\r\n return;\r\n }\r\n\r\n this.heartbeatId = setInterval(() => {\r\n localStorage.setItem(this.LIVENESS_LOCK_KEY, Date.now().toString());\r\n }, 1000);\r\n\r\n if (this.state.status !== \"ready\" || !this.webcam) {\r\n console.warn(\"[LivenessEngine] Engine not ready or video missing.\");\r\n return;\r\n }\r\n\r\n console.log(\"[LivenessEngine] Session Starting...\");\r\n this.state.status = \"capturing\"; // Sync internal status immediately\r\n this.updateState({ status: \"capturing\" });\r\n this.startTimer();\r\n this.detectLoop();\r\n };\r\n\r\n public stop = () => {\r\n if (this.timerId) clearInterval(this.timerId);\r\n if (this.heartbeatId) clearInterval(this.heartbeatId);\r\n if (this.requestId) cancelAnimationFrame(this.requestId);\r\n localStorage.removeItem(this.LIVENESS_LOCK_KEY);\r\n\r\n this.timerId = null;\r\n this.heartbeatId = null;\r\n this.requestId = null;\r\n };\r\n\r\n public reset = () => {\r\n this.stop();\r\n this.currentStepRef = 0;\r\n this.isStepTransitioningRef = false;\r\n this.anchorRatios = null;\r\n this.lastNosePos = null;\r\n this.consecutiveMissingFrames = 0;\r\n this.stabilityFrames = 0;\r\n this.generateSequence();\r\n this.updateState({\r\n status: \"ready\",\r\n currentStep: 0,\r\n timeLeft: this.config.duration,\r\n isStepTransitioning: false,\r\n errorMsg: \"\",\r\n snapshots: [],\r\n });\r\n};\r\n\r\n private updateState(newState: Partial<LivenessState>) {\r\n this.state = { ...this.state, ...newState };\r\n this.config.onStateChange(this.state);\r\n }\r\n\r\n private generateSequence(): Challenge[] {\r\n const seq = [...this.CHALLENGE_POOL].sort(() => 0.5 - Math.random()).slice(0, 3);\r\n this.state.sequence = seq;\r\n return seq;\r\n }\r\n\r\n private startTimer() {\r\n if (this.timerId) clearInterval(this.timerId);\r\n this.timerId = setInterval(() => {\r\n if (this.state.timeLeft > 0) {\r\n this.updateState({ timeLeft: this.state.timeLeft - 1 });\r\n } else {\r\n this.stop();\r\n this.updateState({ status: \"expired\" });\r\n }\r\n }, 1000);\r\n }\r\n\r\n private detectLoop = () => {\r\n if (this.state.status !== \"capturing\" || !this.webcam || !this.models.face) return;\r\n\r\n const now = performance.now();\r\n try {\r\n const faceRes = this.models.face.detectForVideo(this.webcam, now);\r\n \r\n // --- NEW SECURITY CHECKS ---\r\n // 1. Multi-Face Security\r\n if (faceRes.faceLandmarks && faceRes.faceLandmarks.length > 1) {\r\n console.warn(\"[LivenessEngine] Security Alert: Multiple faces detected!\");\r\n this.failInstantly(\"Multiple faces detected. Please ensure only one person is in frame.\");\r\n return; // CRITICAL: Stop execution here\r\n }\r\n \r\n const landmarks = faceRes.faceLandmarks?.[0];\r\n\r\n // 2. Continuity & Identity Security\r\n if (!landmarks) {\r\n this.consecutiveMissingFrames++;\r\n if (this.consecutiveMissingFrames > this.MAX_GAP) {\r\n return this.failInstantly(\"Face lost. Session reset.\");\r\n }\r\n } else {\r\n this.consecutiveMissingFrames = 0;\r\n\r\n if (this.anchorRatios === null) {\r\n this.stabilityFrames++;\r\n if (this.stabilityFrames >= this.REQUIRED_STABILITY) {\r\n this.verifyIdentity(landmarks); // This sets the anchor for the first time\r\n }\r\n } else {\r\n // Only perform the security check AFTER the anchor is established\r\n if (!this.verifyIdentity(landmarks) || !this.checkMovement(landmarks)) {\r\n this.failInstantly(\"Security violation: Identity mismatch.\");\r\n return;\r\n }\r\n }\r\n\r\n // 3. Challenge Logic\r\n const currentChallenge = this.state.sequence[this.currentStepRef];\r\n const handRes = this.models.hand?.detectForVideo(this.webcam, now);\r\n\r\n if (this.checkAction(faceRes, handRes, currentChallenge)) {\r\n this.handleStepSuccess(landmarks); // Pass landmarks to capture\r\n return; \r\n }\r\n }\r\n\r\n this.requestId = requestAnimationFrame(this.detectLoop);\r\n\r\n } catch (err) {\r\n console.error(\"[LivenessEngine] Loop detection error:\", err);\r\n this.requestId = requestAnimationFrame(this.detectLoop);\r\n }\r\n\r\n };\r\n\r\n private handleStepSuccess(landmarks: NormalizedLandmark[]) {\r\n if (this.isStepTransitioningRef) return;\r\n \r\n this.isStepTransitioningRef = true;\r\n\r\n // Capture Snapshot\r\n const canvas = this.getFaceCrop(this.webcam!, landmarks);\r\n const snapshot: ChallengeSnapshot = {\r\n challenge: this.state.sequence[this.currentStepRef],\r\n image: canvas.toDataURL(\"image/jpeg\", 0.7),\r\n timestamp: Date.now()\r\n };\r\n\r\n const updatedSnapshots = [...this.state.snapshots, snapshot];\r\n\r\n this.updateState({ isStepTransitioning: true, snapshots: updatedSnapshots });\r\n\r\n setTimeout(() => {\r\n // Check if engine was stopped during the timeout\r\n if (this.state.status !== \"capturing\") return;\r\n\r\n if (this.currentStepRef < this.state.sequence.length - 1) {\r\n this.currentStepRef++;\r\n this.isStepTransitioningRef = false;\r\n this.updateState({\r\n currentStep: this.currentStepRef,\r\n isStepTransitioning: false,\r\n snapshots: updatedSnapshots,\r\n });\r\n this.requestId = requestAnimationFrame(this.detectLoop);\r\n } else {\r\n this.updateState({ snapshots: updatedSnapshots });\r\n this.sendFinalProof();\r\n }\r\n }, 1500);\r\n }\r\n\r\n private checkAction(faceRes: any, handRes: any, challenge: Challenge): boolean {\r\n if (this.isStepTransitioningRef) return false;\r\n\r\n if (challenge === \"Thumbs_Up\" && handRes?.landmarks?.length > 0) {\r\n const l = handRes.landmarks[0];\r\n return l[4].y < l[2].y && [8, 12, 16, 20].every(i => l[i].y > l[i - 2].y);\r\n }\r\n\r\n if (faceRes?.faceLandmarks?.length > 0) {\r\n const lms: NormalizedLandmark[] = faceRes.faceLandmarks[0];\r\n switch (challenge) {\r\n case \"Smile\":\r\n return (lms[291].x - lms[61].x) > this.config.smileThreshold;\r\n case \"Blink\":\r\n const leftEar = Math.abs(lms[159].y - lms[145].y);\r\n const rightEar = Math.abs(lms[386].y - lms[374].y);\r\n return ((leftEar + rightEar) / 2) < this.config.blinkThreshold;\r\n case \"Turn_Head\":\r\n const yaw = (lms[1].x - lms[33].x) / (lms[263].x - lms[33].x);\r\n return yaw < this.config.minturnHeadThreshold || yaw > this.config.maxturnHeadThreshold;\r\n default: return false;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n private async sendFinalProof() {\r\n this.stop();\r\n this.updateState({ status: \"verifying\" });\r\n\r\n try {\r\n const blobs: Blob[] = [];\r\n let finalBase64 = \"\";\r\n\r\n for (let i = 0; i < 5; i++) {\r\n if (!this.webcam) break;\r\n const faceRes = this.models.face?.detectForVideo(this.webcam, performance.now());\r\n if (faceRes?.faceLandmarks?.[0]) {\r\n const canvas = this.getFaceCrop(this.webcam, faceRes.faceLandmarks[0]);\r\n const blob = await new Promise<Blob | null>(res => canvas.toBlob(res, \"image/jpeg\", 0.9));\r\n if (blob) blobs.push(blob);\r\n if (i === 4) finalBase64 = canvas.toDataURL(\"image/jpeg\");\r\n }\r\n await new Promise(r => setTimeout(r, 100));\r\n }\r\n\r\n const { verifyLiveness } = await import(\"../api\");\r\n const result = await verifyLiveness(this.config.apiUrl, blobs, this.state.sequence);\r\n\r\n if (result.is_live) {\r\n this.updateState({ status: \"success\" });\r\n this.config.onComplete({ success: true, image: finalBase64, skinConfidence: result.skin_confidence });\r\n } else {\r\n const reason = result.reason || \"Liveness check failed\";\r\n this.updateState({ status: \"error\", errorMsg: reason });\r\n this.config.onError({ success: false, reason });\r\n }\r\n } catch (err) {\r\n this.updateState({ status: \"error\", errorMsg: \"Verification failed.\" });\r\n this.config.onError({ success: false, reason: \"Network error\" });\r\n }\r\n }\r\n\r\n private getFaceCrop(video: HTMLVideoElement, landmarks: NormalizedLandmark[]): HTMLCanvasElement {\r\n const ctx = this.offscreenCanvas.getContext(\"2d\")!;\r\n const xs = landmarks.map(l => l.x * video.videoWidth);\r\n const ys = landmarks.map(l => l.y * video.videoHeight);\r\n \r\n const minX = Math.min(...xs);\r\n const maxX = Math.max(...xs);\r\n const minY = Math.min(...ys);\r\n const maxY = Math.max(...ys);\r\n \r\n const width = maxX - minX;\r\n const height = maxY - minY;\r\n const margin = width * 0.3;\r\n\r\n ctx.clearRect(0, 0, 224, 224);\r\n ctx.drawImage(\r\n video,\r\n minX - margin, minY - margin, \r\n width + margin * 2, height + margin * 2,\r\n 0, 0, 224, 224\r\n );\r\n\r\n return this.offscreenCanvas;\r\n }\r\n}","import { Injectable, NgZone, OnDestroy } from '@angular/core';\r\nimport { BehaviorSubject, Observable } from 'rxjs';\r\nimport { LivenessEngine, LivenessState, LivenessEngineConfig } from '../core/LivenessEngine';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class LivenessService implements OnDestroy {\r\n private engine!: LivenessEngine;\r\n private stateSubject = new BehaviorSubject<LivenessState | null>(null);\r\n \r\n // Components will subscribe to this\r\n public state$: Observable<LivenessState | null> = this.stateSubject.asObservable();\r\n\r\n constructor(private ngZone: NgZone) {}\r\n\r\n public init(config: LivenessEngineConfig) {\r\n // Run inside runOutsideAngular to prevent 60fps change detection triggers\r\n this.ngZone.runOutsideAngular(() => {\r\n this.engine = new LivenessEngine({\r\n ...config,\r\n onStateChange: (state) => {\r\n // Bring state changes BACK into the zone so the UI updates\r\n this.ngZone.run(() => this.stateSubject.next(state));\r\n }\r\n });\r\n this.engine.loadModels();\r\n });\r\n }\r\n\r\n public attach(video: HTMLVideoElement) {\r\n this.engine?.attachVideo(video);\r\n }\r\n\r\n public start() {\r\n this.engine?.start();\r\n }\r\n\r\n public reset() {\r\n this.engine?.reset();\r\n }\r\n\r\n ngOnDestroy() {\r\n this.engine?.stop();\r\n }\r\n}","import { Component, ElementRef, ViewChild, AfterViewInit, Input, Output, EventEmitter, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';\r\nimport { LivenessService } from './liveness.service';\r\nimport { LivenessSDKResult, Challenge, LivenessState } from '../core/LivenessEngine';\r\nimport { CommonModule } from '@angular/common'\r\n\r\n@Component({\r\n selector: 'LivenessCheck',\r\n standalone: true, // Make it standalone\r\n imports: [CommonModule], // Add CommonModule here to fix NG8002\r\n templateUrl: './liveness.component.html',\r\n encapsulation: ViewEncapsulation.None,\r\n})\r\n\r\nexport class LivenessComponent implements OnInit, AfterViewInit, OnDestroy {\r\n @ViewChild('webcam') webcamRef!: ElementRef<HTMLVideoElement>;\r\n\r\n // --- Logic Configuration ---\r\n @Input() apiUrl!: string;\r\n @Input() duration = 60;\r\n @Input() smileThreshold?: number;\r\n @Input() blinkThreshold?: number;\r\n @Input() minturnHeadThreshold?: number;\r\n @Input() maxturnHeadThreshold?: number;\r\n\r\n // --- Styling Configuration (Class Names) ---\r\n @Input() containerClass = '';\r\n @Input() videoWrapperClass = '';\r\n @Input() videoClass = '';\r\n @Input() timerClass = '';\r\n @Input() stateClass = '';\r\n @Input() challengeTextClass = '';\r\n @Input() buttonClass = '';\r\n @Input() retryButtonClass = '';\r\n @Input() statusOverlayClass = '';\r\n @Input() successMessageClass = '';\r\n @Input() errorMessageClass = '';\r\n @Input() instructionBoxClass = '';\r\n\r\n // --- Content Configuration ---\r\n @Input() successMessage = 'Verification Successful!';\r\n @Input() errorMessage = 'Verification failed. Please try again.';\r\n @Input() retryButtonLabel = 'Try Again';\r\n @Input() startButtonLabel = 'Start Verification';\r\n @Input() challengeMapping: Record<Challenge, string> = {\r\n 'Smile': 'Smile',\r\n 'Blink': 'Blink',\r\n 'Turn_Head': 'Turn Head',\r\n 'Thumbs_Up': 'Thumbs Up' // Default with a space\r\n };\r\n\r\n @Output() onComplete = new EventEmitter<LivenessSDKResult>();\r\n @Output() onError = new EventEmitter<any>();\r\n @Output() onStateChange = new EventEmitter<LivenessState | null>();\r\n\r\n constructor(public liveness: LivenessService) {}\r\n\r\n ngOnInit() {\r\n // Pass the custom thresholds directly to the service\r\n \r\n\r\n this.liveness.state$.subscribe(state => {\r\n // This bridges the Service to the Component's @Output\r\n this.onStateChange.emit(state);\r\n });\r\n\r\n }\r\n\r\n async ngAfterViewInit() {\r\n try {\r\n const stream = await navigator.mediaDevices.getUserMedia({ \r\n video: { width: 640, height: 480, facingMode: 'user' } \r\n });\r\n const video = this.webcamRef.nativeElement;\r\n video.srcObject = stream;\r\n video.onloadedmetadata = () => {\r\n video.play();\r\n\r\n this.liveness.init({\r\n apiUrl: this.apiUrl,\r\n duration: this.duration,\r\n smileThreshold: this.smileThreshold,\r\n blinkThreshold: this.blinkThreshold,\r\n minturnHeadThreshold: this.minturnHeadThreshold,\r\n maxturnHeadThreshold: this.maxturnHeadThreshold,\r\n onComplete: (res) => this.onComplete.emit(res),\r\n onError: (err) => this.onError.emit(err)\r\n });\r\n\r\n this.liveness.attach(video);\r\n };\r\n } catch (e) {\r\n this.onError.emit({ success: false, reason: 'Camera access denied' });\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n const stream = this.webcamRef?.nativeElement?.srcObject as MediaStream;\r\n stream?.getTracks().forEach(track => track.stop());\r\n }\r\n}","<div [ngClass]=\"containerClass\">\r\n <div [ngClass]=\"videoWrapperClass\">\r\n <video #webcam \r\n autoplay \r\n playsinline \r\n muted \r\n [ngClass]=\"videoClass\" \r\n style=\"transform: scaleX(-1);\">\r\n </video>\r\n\r\n <ng-container *ngIf=\"(liveness.state$ | async) as state\">\r\n <div [ngClass]=\"statusOverlayClass\">\r\n \r\n <div class=\"instruction-box\">\r\n <h2 class=\"status-text\" [ngClass] = \"stateClass\">{{ state.status | uppercase }}</h2>\r\n \r\n <p *ngIf=\"state.status === 'capturing'\" \r\n [ngClass]=\"challengeTextClass\">\r\n {{ challengeMapping[state.sequence[state.currentStep]] }}\r\n </p>\r\n\r\n <p *ngIf=\"state.status === 'success'\"\r\n [ngClass]=\"successMessageClass\">\r\n {{ successMessage }}\r\n </p>\r\n \r\n <p *ngIf=\"state.status === 'error' || state.status === 'expired'\" \r\n [ngClass]=\"errorMessageClass\">\r\n {{ errorMessage }}\r\n </p>\r\n </div>\r\n\r\n <div *ngIf=\"state.status === 'capturing'\" \r\n [ngClass]=\"timerClass\">\r\n {{ state.timeLeft }}\r\n </div>\r\n\r\n <div class=\"action-area\">\r\n <button *ngIf=\"state.status === 'ready'\" \r\n (click)=\"liveness.start()\"\r\n [ngClass]=\"buttonClass\">\r\n {{ startButtonLabel }}\r\n </button>\r\n \r\n <button *ngIf=\"state.status === 'error' || state.status === 'expired'\" \r\n (click)=\"liveness.reset()\"\r\n [ngClass]=\"retryButtonClass\">\r\n {{ retryButtonLabel }}\r\n </button>\r\n </div>\r\n\r\n </div>\r\n </ng-container>\r\n </div>\r\n</div>","// src/api.ts\r\n\r\nimport { Challenge } from \"./core/LivenessEngine\";\r\n\r\nexport interface LivenessResponse {\r\n is_live: boolean;\r\n reason?: string;\r\n skin_confidence?: number;\r\n [key: string]: any; // allow extra fields if backend returns more\r\n}\r\n\r\n/**\r\n * Sends captured frames to the backend API for liveness verification.\r\n * @param apiUrl - Base URL of the liveness backend\r\n * @param frameBlobs - Array of Blob objects representing captured frames\r\n * @param challenge - The current challenge string\r\n * @returns LivenessResponse from backend\r\n */\r\nexport const verifyLiveness = async (\r\n apiUrl: string,\r\n frameBlobs: Blob[],\r\n challenge: Challenge[]\r\n): Promise<LivenessResponse> => {\r\n const formData = new FormData();\r\n\r\n frameBlobs.forEach((blob, i) => {\r\n formData.append('files', blob, `frame_${i}.jpg`);\r\n });\r\n formData.append('challenge', JSON.stringify(challenge));\r\n\r\n const response = await fetch(`${apiUrl}/v1/verify`, {\r\n method: 'POST',\r\n body: formData,\r\n });\r\n\r\n if (!response.ok) {\r\n throw new Error(\"Network response was not ok\");\r\n }\r\n\r\n const data: LivenessResponse = await response.json();\r\n return data;\r\n};","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.LivenessService"],"mappings":";;;;;;;AAAA;MAyCa,cAAc,CAAA;AACjB,IAAA,MAAM;IACN,MAAM,GAAiE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;IACjG,MAAM,GAA4B,IAAI;AACtC,IAAA,KAAK;IAEL,cAAc,GAAG,CAAC;IAClB,sBAAsB,GAAG,KAAK;IAC9B,OAAO,GAA0C,IAAI;IACrD,SAAS,GAAkB,IAAI;IAC/B,WAAW,GAA0C,IAAI;;IAGzD,YAAY,GAAkB,IAAI;IAClC,WAAW,GAAoC,IAAI;IACnD,wBAAwB,GAAG,CAAC;AACnB,IAAA,OAAO,GAAG,EAAE,CAAC;IACb,iBAAiB,GAAG,yBAAyB;IACtD,eAAe,GAAG,CAAC;AACV,IAAA,kBAAkB,GAAG,EAAE,CAAC;AAEjC,IAAA,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;IAClD,cAAc,GAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC;AAElF,IAAA,WAAA,CAAY,MAA4B,EAAA;QACtC,IAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,MAAM,CAAC,MAAM;AACrB,YAAA,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;AAC/B,YAAA,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Q,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,CAAA,MAAA,EAAS,CAAC,CAAA,IAAA,CAAM,CAAC;AAClD,IAAA,CAAC,CAAC;AACF,IAAA,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAEvD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,CAAA,EAAG,MAAM,YAAY,EAAE;AAClD,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,IAAI,EAAE,QAAQ;AACf,KAAA,CAAC;AAEF,IAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;AAChB,QAAA,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC;IAChD;AAEA,IAAA,MAAM,IAAI,GAAqB,MAAM,QAAQ,CAAC,IAAI,EAAE;AACpD,IAAA,OAAO,IAAI;AACb;;;;;;;ACzCA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"richard.fadiora-liveness-detection.mjs","sources":["../../../src/core/LivenessEngine.ts","../../../src/angular/liveness.service.ts","../../../src/angular/liveness.component.ts","../../../src/angular/liveness.component.html","../../../src/api.ts","../../../src/richard.fadiora-liveness-detection.ts"],"sourcesContent":["// src/core/LivenessEngine.ts\r\nimport { FaceLandmarker, HandLandmarker, FilesetResolver, NormalizedLandmark } from \"@mediapipe/tasks-vision\";\r\n\r\nexport type Challenge = \"Smile\" | \"Blink\" | \"Turn_Head\" | \"Thumbs_Up\";\r\n\r\nexport interface ChallengeSnapshot {\r\n challenge: Challenge;\r\n image: string; // Base64 data URL\r\n timestamp: number;\r\n}\r\n\r\nexport interface LivenessSDKResult {\r\n success: boolean;\r\n image?: string;\r\n reason?: string;\r\n skinConfidence?: number;\r\n snapshots?: ChallengeSnapshot[];\r\n}\r\n\r\nexport interface LivenessState {\r\n status: \"loading\" | \"ready\" | \"capturing\" | \"verifying\" | \"success\" | \"error\" | \"expired\";\r\n sequence: Challenge[];\r\n currentStep: number;\r\n timeLeft: number;\r\n isStepTransitioning: boolean;\r\n errorMsg: string;\r\n snapshots: ChallengeSnapshot[];\r\n}\r\n\r\nexport interface LivenessEngineConfig {\r\n apiUrl: string;\r\n duration?: number;\r\n smileThreshold?: number;\r\n blinkThreshold?: number;\r\n minturnHeadThreshold?: number;\r\n maxturnHeadThreshold?: number;\r\n onStateChange?: (state: LivenessState) => void;\r\n onComplete?: (result: LivenessSDKResult) => void;\r\n onError?: (error: LivenessSDKResult) => void;\r\n}\r\n\r\nexport class LivenessEngine {\r\n private config: Required<LivenessEngineConfig>;\r\n private models: { face: FaceLandmarker | null; hand: HandLandmarker | null } = { face: null, hand: null };\r\n private webcam: HTMLVideoElement | null = null;\r\n private state: LivenessState;\r\n \r\n private currentStepRef = 0;\r\n private isStepTransitioningRef = false;\r\n private timerId: ReturnType<typeof setInterval> | null = null;\r\n private requestId: number | null = null;\r\n private heartbeatId: ReturnType<typeof setInterval> | null = null;\r\n \r\n // --- NEW SECURITY TRACKERS ---\r\n private anchorRatios: number | null = null;\r\n private lastNosePos: { x: number; y: number } | null = null;\r\n private consecutiveMissingFrames = 0;\r\n private readonly MAX_GAP = 15; // ~250ms buffer\r\n private readonly LIVENESS_LOCK_KEY = \"liveness_active_session\";\r\n private stabilityFrames = 0;\r\n private readonly REQUIRED_STABILITY = 10; // Wait for ~10 clear frames before locking\r\n \r\n private offscreenCanvas = document.createElement(\"canvas\");\r\n private CHALLENGE_POOL: Challenge[] = [\"Smile\", \"Blink\", \"Turn_Head\", \"Thumbs_Up\"];\r\n\r\n constructor(config: LivenessEngineConfig) {\r\n this.config = {\r\n apiUrl: config.apiUrl,\r\n duration: config.duration ?? 60,\r\n smileThreshold: config.smileThreshold ?? 0.2,\r\n blinkThreshold: config.blinkThreshold ?? 0.012,\r\n minturnHeadThreshold: config.minturnHeadThreshold ?? 0.15,\r\n maxturnHeadThreshold: config.maxturnHeadThreshold ?? 0.85,\r\n onStateChange: config.onStateChange || (() => {}),\r\n onComplete: config.onComplete || (() => {}),\r\n onError: config.onError || (() => {}),\r\n };\r\n\r\n this.state = {\r\n status: \"loading\",\r\n sequence: [],\r\n currentStep: 0,\r\n timeLeft: this.config.duration,\r\n isStepTransitioning: false,\r\n errorMsg: \"\",\r\n snapshots: [],\r\n };\r\n \r\n this.offscreenCanvas.width = 224;\r\n this.offscreenCanvas.height = 224;\r\n }\r\n\r\n /**\r\n * Phase 1: Load AI Assets (Call this immediately on mount)\r\n */\r\n public async loadModels() {\r\n console.log(\"[LivenessEngine] Loading AI Models...\");\r\n try {\r\n const vision = await FilesetResolver.forVisionTasks(\r\n \"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.3/wasm\"\r\n );\r\n\r\n this.models.face = await FaceLandmarker.createFromOptions(vision, {\r\n baseOptions: {\r\n modelAssetPath: \"https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task\",\r\n delegate: \"GPU\",\r\n },\r\n outputFaceBlendshapes: true,\r\n runningMode: \"VIDEO\",\r\n });\r\n\r\n this.models.hand = await HandLandmarker.createFromOptions(vision, {\r\n baseOptions: {\r\n modelAssetPath: \"https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task\",\r\n delegate: \"GPU\",\r\n },\r\n runningMode: \"VIDEO\",\r\n numHands: 1,\r\n });\r\n\r\n this.generateSequence();\r\n // Stay in 'loading' or move to a 'ready_to_mount' status if you prefer\r\n // For now, we move to ready to signal the UI can show the camera\r\n this.updateState({ status: \"ready\" });\r\n console.log(\"[LivenessEngine] Models Loaded.\");\r\n } catch (err) {\r\n console.error(\"[LivenessEngine] Init Error:\", err);\r\n this.updateState({ status: \"error\", errorMsg: \"Failed to load security assets.\" });\r\n }\r\n }\r\n\r\n /**\r\n * Phase 2: Attach Video (Call this once the Webcam is in the DOM)\r\n */\r\n public attachVideo = (video: HTMLVideoElement) => {\r\n video.setAttribute('crossorigin', 'anonymous');\r\n this.webcam = video;\r\n console.log(\"[LivenessEngine] Video stream attached.\");\r\n };\r\n\r\n // --- NEW SECURITY METHODS ---\r\n\r\n private verifyIdentity(landmarks: NormalizedLandmark[]): boolean {\r\n const eyeDist = Math.sqrt(\r\n Math.pow(landmarks[33].x - landmarks[263].x, 2) + \r\n Math.pow(landmarks[33].y - landmarks[263].y, 2)\r\n );\r\n const noseToMouth = Math.abs(landmarks[1].y - landmarks[13].y);\r\n const currentRatio = eyeDist / (noseToMouth || 1);\r\n\r\n if (this.anchorRatios === null) {\r\n this.anchorRatios = currentRatio;\r\n return true;\r\n }\r\n\r\n const diff = Math.abs(this.anchorRatios - currentRatio) / this.anchorRatios;\r\n return diff < 0.50; // 50% tolerance for head tilt\r\n }\r\n\r\n private checkMovement(landmarks: NormalizedLandmark[]): boolean {\r\n const nose = { x: landmarks[1].x, y: landmarks[1].y };\r\n if (this.lastNosePos) {\r\n const dist = Math.sqrt(\r\n Math.pow(nose.x - this.lastNosePos.x, 2) + \r\n Math.pow(nose.y - this.lastNosePos.y, 2)\r\n );\r\n if (dist > 0.3) return false; // Sudden teleportation\r\n }\r\n this.lastNosePos = nose;\r\n return true;\r\n }\r\n\r\n private failInstantly(reason: string) {\r\n this.stop();\r\n this.updateState({ status: \"error\", errorMsg: reason, isStepTransitioning: false });\r\n this.config.onError({ success: false, reason });\r\n }\r\n\r\n public start = () => {\r\n // Multi-tab Prevention\r\n const active = localStorage.getItem(this.LIVENESS_LOCK_KEY);\r\n if (active && Date.now() - parseInt(active) < 5000) {\r\n this.failInstantly(\"Another session is active.\");\r\n return;\r\n }\r\n\r\n this.heartbeatId = setInterval(() => {\r\n localStorage.setItem(this.LIVENESS_LOCK_KEY, Date.now().toString());\r\n }, 1000);\r\n\r\n if (this.state.status !== \"ready\" || !this.webcam) {\r\n console.warn(\"[LivenessEngine] Engine not ready or video missing.\");\r\n return;\r\n }\r\n\r\n console.log(\"[LivenessEngine] Session Starting...\");\r\n this.state.status = \"capturing\"; // Sync internal status immediately\r\n this.updateState({ status: \"capturing\" });\r\n this.startTimer();\r\n this.detectLoop();\r\n };\r\n\r\n public stop = () => {\r\n if (this.timerId) clearInterval(this.timerId);\r\n if (this.heartbeatId) clearInterval(this.heartbeatId);\r\n if (this.requestId) cancelAnimationFrame(this.requestId);\r\n localStorage.removeItem(this.LIVENESS_LOCK_KEY);\r\n\r\n this.timerId = null;\r\n this.heartbeatId = null;\r\n this.requestId = null;\r\n };\r\n\r\n public reset = () => {\r\n this.stop();\r\n this.currentStepRef = 0;\r\n this.isStepTransitioningRef = false;\r\n this.anchorRatios = null;\r\n this.lastNosePos = null;\r\n this.consecutiveMissingFrames = 0;\r\n this.stabilityFrames = 0;\r\n this.generateSequence();\r\n this.updateState({\r\n status: \"ready\",\r\n currentStep: 0,\r\n timeLeft: this.config.duration,\r\n isStepTransitioning: false,\r\n errorMsg: \"\",\r\n snapshots: [],\r\n });\r\n};\r\n\r\n private updateState(newState: Partial<LivenessState>) {\r\n this.state = { ...this.state, ...newState };\r\n this.config.onStateChange(this.state);\r\n }\r\n\r\n private generateSequence(): Challenge[] {\r\n const seq = [...this.CHALLENGE_POOL].sort(() => 0.5 - Math.random()).slice(0, 3);\r\n this.state.sequence = seq;\r\n return seq;\r\n }\r\n\r\n private startTimer() {\r\n if (this.timerId) clearInterval(this.timerId);\r\n this.timerId = setInterval(() => {\r\n if (this.state.timeLeft > 0) {\r\n this.updateState({ timeLeft: this.state.timeLeft - 1 });\r\n } else {\r\n this.stop();\r\n this.updateState({ status: \"expired\" });\r\n }\r\n }, 1000);\r\n }\r\n\r\n private detectLoop = () => {\r\n if (this.state.status !== \"capturing\" || !this.webcam || !this.models.face) return;\r\n\r\n const now = performance.now();\r\n try {\r\n const faceRes = this.models.face.detectForVideo(this.webcam, now);\r\n \r\n // --- NEW SECURITY CHECKS ---\r\n // 1. Multi-Face Security\r\n if (faceRes.faceLandmarks && faceRes.faceLandmarks.length > 1) {\r\n console.warn(\"[LivenessEngine] Security Alert: Multiple faces detected!\");\r\n this.failInstantly(\"Multiple faces detected. Please ensure only one person is in frame.\");\r\n return; // CRITICAL: Stop execution here\r\n }\r\n \r\n const landmarks = faceRes.faceLandmarks?.[0];\r\n\r\n // 2. Continuity & Identity Security\r\n if (!landmarks) {\r\n this.consecutiveMissingFrames++;\r\n if (this.consecutiveMissingFrames > this.MAX_GAP) {\r\n return this.failInstantly(\"Face lost. Session reset.\");\r\n }\r\n } else {\r\n this.consecutiveMissingFrames = 0;\r\n\r\n if (this.anchorRatios === null) {\r\n this.stabilityFrames++;\r\n if (this.stabilityFrames >= this.REQUIRED_STABILITY) {\r\n this.verifyIdentity(landmarks); // This sets the anchor for the first time\r\n }\r\n } else {\r\n // Only perform the security check AFTER the anchor is established\r\n if (!this.verifyIdentity(landmarks) || !this.checkMovement(landmarks)) {\r\n this.failInstantly(\"Security violation: Identity mismatch.\");\r\n return;\r\n }\r\n }\r\n\r\n // 3. Challenge Logic\r\n const currentChallenge = this.state.sequence[this.currentStepRef];\r\n const handRes = this.models.hand?.detectForVideo(this.webcam, now);\r\n\r\n if (this.checkAction(faceRes, handRes, currentChallenge)) {\r\n this.handleStepSuccess(landmarks); // Pass landmarks to capture\r\n return; \r\n }\r\n }\r\n\r\n this.requestId = requestAnimationFrame(this.detectLoop);\r\n\r\n } catch (err) {\r\n console.error(\"[LivenessEngine] Loop detection error:\", err);\r\n this.requestId = requestAnimationFrame(this.detectLoop);\r\n }\r\n\r\n };\r\n\r\n private async handleStepSuccess(landmarks: NormalizedLandmark[]) {\r\n if (this.isStepTransitioningRef) return;\r\n \r\n this.isStepTransitioningRef = true;\r\n\r\n // Capture Snapshot\r\n const canvas = await this.getFaceCrop(this.webcam!, landmarks);\r\n const snapshot: ChallengeSnapshot = {\r\n challenge: this.state.sequence[this.currentStepRef],\r\n image: canvas.toDataURL(\"image/jpeg\", 0.7),\r\n timestamp: Date.now()\r\n };\r\n\r\n const updatedSnapshots = [...this.state.snapshots, snapshot];\r\n\r\n this.updateState({ isStepTransitioning: true, snapshots: updatedSnapshots });\r\n\r\n setTimeout(() => {\r\n // Check if engine was stopped during the timeout\r\n if (this.state.status !== \"capturing\") return;\r\n\r\n if (this.currentStepRef < this.state.sequence.length - 1) {\r\n this.currentStepRef++;\r\n this.isStepTransitioningRef = false;\r\n this.updateState({\r\n currentStep: this.currentStepRef,\r\n isStepTransitioning: false,\r\n snapshots: updatedSnapshots,\r\n });\r\n this.requestId = requestAnimationFrame(this.detectLoop);\r\n } else {\r\n this.updateState({ snapshots: updatedSnapshots });\r\n this.sendFinalProof();\r\n }\r\n }, 1500);\r\n }\r\n\r\n private checkAction(faceRes: any, handRes: any, challenge: Challenge): boolean {\r\n if (this.isStepTransitioningRef) return false;\r\n\r\n if (challenge === \"Thumbs_Up\" && handRes?.landmarks?.length > 0) {\r\n const l = handRes.landmarks[0];\r\n return l[4].y < l[2].y && [8, 12, 16, 20].every(i => l[i].y > l[i - 2].y);\r\n }\r\n\r\n if (faceRes?.faceLandmarks?.length > 0) {\r\n const lms: NormalizedLandmark[] = faceRes.faceLandmarks[0];\r\n switch (challenge) {\r\n case \"Smile\":\r\n return (lms[291].x - lms[61].x) > this.config.smileThreshold;\r\n case \"Blink\":\r\n const leftEar = Math.abs(lms[159].y - lms[145].y);\r\n const rightEar = Math.abs(lms[386].y - lms[374].y);\r\n return ((leftEar + rightEar) / 2) < this.config.blinkThreshold;\r\n case \"Turn_Head\":\r\n const yaw = (lms[1].x - lms[33].x) / (lms[263].x - lms[33].x);\r\n return yaw < this.config.minturnHeadThreshold || yaw > this.config.maxturnHeadThreshold;\r\n default: return false;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n private async sendFinalProof() {\r\n this.stop();\r\n this.updateState({ status: \"verifying\" });\r\n\r\n try {\r\n const blobs: Blob[] = [];\r\n let finalBase64 = \"\";\r\n\r\n for (let i = 0; i < 5; i++) {\r\n if (!this.webcam) break;\r\n const faceRes = this.models.face?.detectForVideo(this.webcam, performance.now());\r\n if (faceRes?.faceLandmarks?.[0]) {\r\n const canvas = await this.getFaceCrop(this.webcam, faceRes.faceLandmarks[0]);\r\n const blob = await new Promise<Blob | null>(res => canvas.toBlob(res, \"image/jpeg\", 0.9));\r\n if (blob) blobs.push(blob);\r\n if (i === 4) finalBase64 = canvas.toDataURL(\"image/jpeg\");\r\n }\r\n await new Promise(r => setTimeout(r, 100));\r\n }\r\n\r\n const { verifyLiveness } = await import(\"../api\");\r\n const result = await verifyLiveness(this.config.apiUrl, blobs, this.state.sequence);\r\n\r\n if (result.is_live) {\r\n this.updateState({ status: \"success\" });\r\n this.config.onComplete({ success: true, image: finalBase64, skinConfidence: result.skin_confidence });\r\n } else {\r\n const reason = result.reason || \"Liveness check failed\";\r\n this.updateState({ status: \"error\", errorMsg: reason });\r\n this.config.onError({ success: false, reason });\r\n }\r\n } catch (err) {\r\n this.updateState({ status: \"error\", errorMsg: \"Verification failed.\" });\r\n this.config.onError({ success: false, reason: \"Network error\" });\r\n }\r\n }\r\n\r\n private async getFaceCrop(video: HTMLVideoElement, landmarks: NormalizedLandmark[]): Promise<HTMLCanvasElement> {\r\n const ctx = this.offscreenCanvas.getContext(\"2d\")!;\r\n const xs = landmarks.map(l => l.x * video.videoWidth);\r\n const ys = landmarks.map(l => l.y * video.videoHeight);\r\n \r\n const minX = Math.min(...xs);\r\n const maxX = Math.max(...xs);\r\n const minY = Math.min(...ys);\r\n const maxY = Math.max(...ys);\r\n \r\n const width = maxX - minX;\r\n const height = maxY - minY;\r\n const margin = width * 0.3;\r\n\r\n const sourceX = Math.max(0, minX - margin);\r\n const sourceY = Math.max(0, minY - margin);\r\n const sourceW = Math.min(video.videoWidth - sourceX, width + margin * 2);\r\n const sourceH = Math.min(video.videoHeight - sourceY, height + margin * 2);\r\n\r\n try {\r\n // 2. Extract the bitmap (This bypasses many canvas-tainting triggers)\r\n const bitmap = await createImageBitmap(video, sourceX, sourceY, sourceW, sourceH);\r\n \r\n const ctx = this.offscreenCanvas.getContext(\"2d\")!;\r\n ctx.clearRect(0, 0, 224, 224);\r\n \r\n // 3. Draw the clean bitmap to the offscreen canvas\r\n ctx.drawImage(bitmap, 0, 0, 224, 224);\r\n \r\n // 4. Important: close the bitmap to free memory\r\n bitmap.close();\r\n } catch (e) {\r\n console.error(\"[LivenessEngine] Bitmap extraction failed, falling back to direct draw\", e);\r\n // Fallback if createImageBitmap is not supported or fails\r\n const ctx = this.offscreenCanvas.getContext(\"2d\")!;\r\n ctx.drawImage(video, sourceX, sourceY, sourceW, sourceH, 0, 0, 224, 224);\r\n }\r\n\r\n return this.offscreenCanvas;\r\n }\r\n}","import { Injectable, NgZone, OnDestroy } from '@angular/core';\r\nimport { BehaviorSubject, Observable } from 'rxjs';\r\nimport { LivenessEngine, LivenessState, LivenessEngineConfig } from '../core/LivenessEngine';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class LivenessService implements OnDestroy {\r\n private engine!: LivenessEngine;\r\n private stateSubject = new BehaviorSubject<LivenessState | null>(null);\r\n \r\n // Components will subscribe to this\r\n public state$: Observable<LivenessState | null> = this.stateSubject.asObservable();\r\n\r\n constructor(private ngZone: NgZone) {}\r\n\r\n public init(config: LivenessEngineConfig) {\r\n // Run inside runOutsideAngular to prevent 60fps change detection triggers\r\n this.ngZone.runOutsideAngular(() => {\r\n this.engine = new LivenessEngine({\r\n ...config,\r\n onStateChange: (state) => {\r\n // Bring state changes BACK into the zone so the UI updates\r\n this.ngZone.run(() => this.stateSubject.next(state));\r\n }\r\n });\r\n this.engine.loadModels();\r\n });\r\n }\r\n\r\n public attach(video: HTMLVideoElement) {\r\n this.engine?.attachVideo(video);\r\n }\r\n\r\n public start() {\r\n this.engine?.start();\r\n }\r\n\r\n public reset() {\r\n this.engine?.reset();\r\n }\r\n\r\n ngOnDestroy() {\r\n this.engine?.stop();\r\n }\r\n}","import { Component, ElementRef, ViewChild, AfterViewInit, Input, Output, EventEmitter, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';\r\nimport { LivenessService } from './liveness.service';\r\nimport { LivenessSDKResult, Challenge, LivenessState } from '../core/LivenessEngine';\r\nimport { CommonModule } from '@angular/common'\r\n\r\n@Component({\r\n selector: 'LivenessCheck',\r\n standalone: true, // Make it standalone\r\n imports: [CommonModule], // Add CommonModule here to fix NG8002\r\n templateUrl: './liveness.component.html',\r\n encapsulation: ViewEncapsulation.None,\r\n})\r\n\r\nexport class LivenessComponent implements OnInit, AfterViewInit, OnDestroy {\r\n @ViewChild('webcam') webcamRef!: ElementRef<HTMLVideoElement>;\r\n\r\n // --- Logic Configuration ---\r\n @Input() apiUrl!: string;\r\n @Input() duration = 60;\r\n @Input() smileThreshold?: number;\r\n @Input() blinkThreshold?: number;\r\n @Input() minturnHeadThreshold?: number;\r\n @Input() maxturnHeadThreshold?: number;\r\n\r\n // --- Styling Configuration (Class Names) ---\r\n @Input() containerClass = '';\r\n @Input() videoWrapperClass = '';\r\n @Input() videoClass = '';\r\n @Input() timerClass = '';\r\n @Input() stateClass = '';\r\n @Input() challengeTextClass = '';\r\n @Input() buttonClass = '';\r\n @Input() retryButtonClass = '';\r\n @Input() statusOverlayClass = '';\r\n @Input() successMessageClass = '';\r\n @Input() errorMessageClass = '';\r\n @Input() instructionBoxClass = '';\r\n\r\n // --- Content Configuration ---\r\n @Input() successMessage = 'Verification Successful!';\r\n @Input() errorMessage = 'Verification failed. Please try again.';\r\n @Input() retryButtonLabel = 'Try Again';\r\n @Input() startButtonLabel = 'Start Verification';\r\n @Input() challengeMapping: Record<Challenge, string> = {\r\n 'Smile': 'Smile',\r\n 'Blink': 'Blink',\r\n 'Turn_Head': 'Turn Head',\r\n 'Thumbs_Up': 'Thumbs Up' // Default with a space\r\n };\r\n\r\n @Output() onComplete = new EventEmitter<LivenessSDKResult>();\r\n @Output() onError = new EventEmitter<any>();\r\n @Output() onStateChange = new EventEmitter<LivenessState | null>();\r\n\r\n constructor(public liveness: LivenessService) {}\r\n\r\n ngOnInit() {\r\n // Pass the custom thresholds directly to the service\r\n \r\n\r\n this.liveness.state$.subscribe(state => {\r\n // This bridges the Service to the Component's @Output\r\n this.onStateChange.emit(state);\r\n });\r\n\r\n }\r\n\r\n async ngAfterViewInit() {\r\n try {\r\n const stream = await navigator.mediaDevices.getUserMedia({ \r\n video: { width: 640, height: 480, facingMode: 'user' } \r\n });\r\n const video = this.webcamRef.nativeElement;\r\n video.srcObject = stream;\r\n video.onloadedmetadata = () => {\r\n video.play();\r\n\r\n this.liveness.init({\r\n apiUrl: this.apiUrl,\r\n duration: this.duration,\r\n smileThreshold: this.smileThreshold,\r\n blinkThreshold: this.blinkThreshold,\r\n minturnHeadThreshold: this.minturnHeadThreshold,\r\n maxturnHeadThreshold: this.maxturnHeadThreshold,\r\n onComplete: (res) => this.onComplete.emit(res),\r\n onError: (err) => this.onError.emit(err)\r\n });\r\n\r\n this.liveness.attach(video);\r\n };\r\n } catch (e) {\r\n this.onError.emit({ success: false, reason: 'Camera access denied' });\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n const stream = this.webcamRef?.nativeElement?.srcObject as MediaStream;\r\n stream?.getTracks().forEach(track => track.stop());\r\n }\r\n}","<div [ngClass]=\"containerClass\">\r\n <div [ngClass]=\"videoWrapperClass\">\r\n <video #webcam \r\n autoplay \r\n playsinline \r\n muted \r\n [ngClass]=\"videoClass\" \r\n style=\"transform: scaleX(-1);\">\r\n </video>\r\n\r\n <ng-container *ngIf=\"(liveness.state$ | async) as state\">\r\n <div [ngClass]=\"statusOverlayClass\">\r\n \r\n <div class=\"instruction-box\">\r\n <h2 class=\"status-text\" [ngClass] = \"stateClass\">{{ state.status | uppercase }}</h2>\r\n \r\n <p *ngIf=\"state.status === 'capturing'\" \r\n [ngClass]=\"challengeTextClass\">\r\n {{ challengeMapping[state.sequence[state.currentStep]] }}\r\n </p>\r\n\r\n <p *ngIf=\"state.status === 'success'\"\r\n [ngClass]=\"successMessageClass\">\r\n {{ successMessage }}\r\n </p>\r\n \r\n <p *ngIf=\"state.status === 'error' || state.status === 'expired'\" \r\n [ngClass]=\"errorMessageClass\">\r\n {{ errorMessage }}\r\n </p>\r\n </div>\r\n\r\n <div *ngIf=\"state.status === 'capturing'\" \r\n [ngClass]=\"timerClass\">\r\n {{ state.timeLeft }}\r\n </div>\r\n\r\n <div class=\"action-area\">\r\n <button *ngIf=\"state.status === 'ready'\" \r\n (click)=\"liveness.start()\"\r\n [ngClass]=\"buttonClass\">\r\n {{ startButtonLabel }}\r\n </button>\r\n \r\n <button *ngIf=\"state.status === 'error' || state.status === 'expired'\" \r\n (click)=\"liveness.reset()\"\r\n [ngClass]=\"retryButtonClass\">\r\n {{ retryButtonLabel }}\r\n </button>\r\n </div>\r\n\r\n </div>\r\n </ng-container>\r\n </div>\r\n</div>","// src/api.ts\r\n\r\nimport { Challenge } from \"./core/LivenessEngine\";\r\n\r\nexport interface LivenessResponse {\r\n is_live: boolean;\r\n reason?: string;\r\n skin_confidence?: number;\r\n [key: string]: any; // allow extra fields if backend returns more\r\n}\r\n\r\n/**\r\n * Sends captured frames to the backend API for liveness verification.\r\n * @param apiUrl - Base URL of the liveness backend\r\n * @param frameBlobs - Array of Blob objects representing captured frames\r\n * @param challenge - The current challenge string\r\n * @returns LivenessResponse from backend\r\n */\r\nexport const verifyLiveness = async (\r\n apiUrl: string,\r\n frameBlobs: Blob[],\r\n challenge: Challenge[]\r\n): Promise<LivenessResponse> => {\r\n const formData = new FormData();\r\n\r\n frameBlobs.forEach((blob, i) => {\r\n formData.append('files', blob, `frame_${i}.jpg`);\r\n });\r\n formData.append('challenge', JSON.stringify(challenge));\r\n\r\n const response = await fetch(`${apiUrl}/v1/verify`, {\r\n method: 'POST',\r\n body: formData,\r\n });\r\n\r\n if (!response.ok) {\r\n throw new Error(\"Network response was not ok\");\r\n }\r\n\r\n const data: LivenessResponse = await response.json();\r\n return data;\r\n};","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.LivenessService"],"mappings":";;;;;;;AAAA;MAyCa,cAAc,CAAA;AACjB,IAAA,MAAM;IAC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AO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAM;IAEzC,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,cAAc,CAA6D;gBAEvE,MAAM,EAAE,oBAAoB;IA2BxC;;OAEG;IACU,UAAU;IAoCvB;;OAEG;IACI,WAAW,GAAI,OAAO,gBAAgB,UAI3C;IAIF,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,aAAa;IAMd,KAAK,aAsBV;IAEK,IAAI,aAST;IAEK,KAAK,aAiBZ;IAEA,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,UAAU,CAwDhB;YAEY,iBAAiB;IAqC/B,OAAO,CAAC,WAAW;YA0BL,cAAc;YAqCd,WAAW;CAwC1B"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./api-CWu5ff9j.cjs"),
|
|
2
|
-
`+
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=t}});function O(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var m=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,n,o,s;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=_(i),p=c.next();!p.done;p=c.next()){var g=p.value;g.remove(this)}}catch(l){e={error:l}}finally{try{p&&!p.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else i.remove(this);var I=this.initialTeardown;if(h(I))try{I()}catch(l){s=l instanceof C?l.errors:[l]}var T=this._finalizers;if(T){this._finalizers=null;try{for(var d=_(T),f=d.next();!f.done;f=d.next()){var F=f.value;try{x(F)}catch(l){s=s??[],l instanceof C?s=E(E([],w(s)),w(l.errors)):s.push(l)}}}catch(l){n={error:l}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(n)throw n.error}}}if(s)throw new C(s)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)x(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&O(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&O(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),V=m.EMPTY;function H(r){return r instanceof m||r&&"closed"in r&&h(r.remove)&&h(r.add)&&h(r.unsubscribe)}function x(r){h(r)?r():r.unsubscribe()}var Y={Promise:void 0},$={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setTimeout.apply(void 0,E([r,e],w(t)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function Z(r){$.setTimeout(function(){throw r})}function P(){}function b(r){r()}var D=function(r){v(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,H(t)&&t.add(n)):n.destination=J,n}return e.create=function(t,n,o){return new L(t,n,o)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(m),W=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){y(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){y(n)}else y(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){y(t)}},r}(),L=function(r){v(e,r);function e(t,n,o){var s=r.call(this)||this,i;return h(t)||!t?i={next:t??void 0,error:n??void 0,complete:o??void 0}:i=t,s.destination=new W(i),s}return e}(D);function y(r){Z(r)}function G(r){throw r}var J={closed:!0,next:P,error:G,complete:P},K=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Q(r){return r}function X(r){return r.length===0?Q:r.length===1?r[0]:function(t){return r.reduce(function(n,o){return o(n)},t)}}var j=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var o=this,s=N(e)?e:new L(e,t,n);return b(function(){var i=o,c=i.operator,p=i.source;s.add(c?c.call(s,p):p?o._subscribe(s):o._trySubscribe(s))}),s},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=A(t),new t(function(o,s){var i=new L({next:function(c){try{e(c)}catch(p){s(p),i.unsubscribe()}},error:s,complete:o});n.subscribe(i)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[K]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return X(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=A(e),new e(function(n,o){var s;t.subscribe(function(i){return s=i},function(i){return o(i)},function(){return n(s)})})},r.create=function(e){return new r(e)},r}();function A(r){var e;return(e=r??Y.Promise)!==null&&e!==void 0?e:Promise}function z(r){return r&&h(r.next)&&h(r.error)&&h(r.complete)}function N(r){return r&&r instanceof D||z(r)&&H(r)}var tt=B(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),R=function(r){v(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var n=new M(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new tt},e.prototype.next=function(t){var n=this;b(function(){var o,s;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var i=_(n.currentObservers),c=i.next();!c.done;c=i.next()){var p=c.value;p.next(t)}}catch(g){o={error:g}}finally{try{c&&!c.done&&(s=i.return)&&s.call(i)}finally{if(o)throw o.error}}}})},e.prototype.error=function(t){var n=this;b(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var o=n.observers;o.length;)o.shift().error(t)}})},e.prototype.complete=function(){var t=this;b(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,o=this,s=o.hasError,i=o.isStopped,c=o.observers;return s||i?V:(this.currentObservers=null,c.push(t),new m(function(){n.currentObservers=null,O(c,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,o=n.hasError,s=n.thrownError,i=n.isStopped;o?t.error(s):i&&t.complete()},e.prototype.asObservable=function(){var t=new j;return t.source=this,t},e.create=function(t,n){return new M(t,n)},e}(j),M=function(r){v(e,r);function e(t,n){var o=r.call(this)||this;return o.destination=t,o.source=n,o}return e.prototype.next=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,t)},e.prototype.error=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&o!==void 0?o:V},e}(R),et=function(r){v(e,r);function e(t){var n=r.call(this)||this;return n._value=t,n}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var n=r.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},e.prototype.getValue=function(){var t=this,n=t.hasError,o=t.thrownError,s=t._value;if(n)throw o;return this._throwIfClosed(),s},e.prototype.next=function(t){r.prototype.next.call(this,this._value=t)},e}(R),rt=Object.getOwnPropertyDescriptor,nt=(r,e,t,n)=>{for(var o=n>1?void 0:n?rt(e,t):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(o=i(o)||o);return o};exports.LivenessService=class{constructor(e){this.ngZone=e,this.stateSubject=new et(null),this.state$=this.stateSubject.asObservable()}init(e){this.ngZone.runOutsideAngular(()=>{this.engine=new U.LivenessEngine({...e,onStateChange:t=>{this.ngZone.run(()=>this.stateSubject.next(t))}}),this.engine.loadModels()})}attach(e){var t;(t=this.engine)==null||t.attachVideo(e)}start(){var e;(e=this.engine)==null||e.start()}reset(){var e;(e=this.engine)==null||e.reset()}ngOnDestroy(){var e;(e=this.engine)==null||e.stop()}};exports.LivenessService=nt([u.Injectable({providedIn:"root"})],exports.LivenessService);var ot=Object.defineProperty,st=Object.getOwnPropertyDescriptor,a=(r,e,t,n)=>{for(var o=n>1?void 0:n?st(e,t):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(o=(n?i(e,t,o):i(o))||o);return n&&o&&ot(e,t,o),o};exports.LivenessComponent=class{constructor(e){this.liveness=e,this.duration=60,this.containerClass="",this.videoWrapperClass="",this.videoClass="",this.timerClass="",this.stateClass="",this.challengeTextClass="",this.buttonClass="",this.retryButtonClass="",this.statusOverlayClass="",this.successMessageClass="",this.errorMessageClass="",this.instructionBoxClass="",this.successMessage="Verification Successful!",this.errorMessage="Verification failed. Please try again.",this.retryButtonLabel="Try Again",this.startButtonLabel="Start Verification",this.challengeMapping={Smile:"Smile",Blink:"Blink",Turn_Head:"Turn Head",Thumbs_Up:"Thumbs Up"},this.onComplete=new u.EventEmitter,this.onError=new u.EventEmitter,this.onStateChange=new u.EventEmitter}ngOnInit(){this.liveness.state$.subscribe(e=>{this.onStateChange.emit(e)})}async ngAfterViewInit(){try{const e=await navigator.mediaDevices.getUserMedia({video:{width:640,height:480,facingMode:"user"}}),t=this.webcamRef.nativeElement;t.srcObject=e,t.onloadedmetadata=()=>{t.play(),this.liveness.init({apiUrl:this.apiUrl,duration:this.duration,smileThreshold:this.smileThreshold,blinkThreshold:this.blinkThreshold,minturnHeadThreshold:this.minturnHeadThreshold,maxturnHeadThreshold:this.maxturnHeadThreshold,onComplete:n=>this.onComplete.emit(n),onError:n=>this.onError.emit(n)}),this.liveness.attach(t)}}catch{this.onError.emit({success:!1,reason:"Camera access denied"})}}ngOnDestroy(){var t,n;const e=(n=(t=this.webcamRef)==null?void 0:t.nativeElement)==null?void 0:n.srcObject;e==null||e.getTracks().forEach(o=>o.stop())}};a([u.ViewChild("webcam")],exports.LivenessComponent.prototype,"webcamRef",2);a([u.Input()],exports.LivenessComponent.prototype,"apiUrl",2);a([u.Input()],exports.LivenessComponent.prototype,"duration",2);a([u.Input()],exports.LivenessComponent.prototype,"smileThreshold",2);a([u.Input()],exports.LivenessComponent.prototype,"blinkThreshold",2);a([u.Input()],exports.LivenessComponent.prototype,"minturnHeadThreshold",2);a([u.Input()],exports.LivenessComponent.prototype,"maxturnHeadThreshold",2);a([u.Input()],exports.LivenessComponent.prototype,"containerClass",2);a([u.Input()],exports.LivenessComponent.prototype,"videoWrapperClass",2);a([u.Input()],exports.LivenessComponent.prototype,"videoClass",2);a([u.Input()],exports.LivenessComponent.prototype,"timerClass",2);a([u.Input()],exports.LivenessComponent.prototype,"stateClass",2);a([u.Input()],exports.LivenessComponent.prototype,"challengeTextClass",2);a([u.Input()],exports.LivenessComponent.prototype,"buttonClass",2);a([u.Input()],exports.LivenessComponent.prototype,"retryButtonClass",2);a([u.Input()],exports.LivenessComponent.prototype,"statusOverlayClass",2);a([u.Input()],exports.LivenessComponent.prototype,"successMessageClass",2);a([u.Input()],exports.LivenessComponent.prototype,"errorMessageClass",2);a([u.Input()],exports.LivenessComponent.prototype,"instructionBoxClass",2);a([u.Input()],exports.LivenessComponent.prototype,"successMessage",2);a([u.Input()],exports.LivenessComponent.prototype,"errorMessage",2);a([u.Input()],exports.LivenessComponent.prototype,"retryButtonLabel",2);a([u.Input()],exports.LivenessComponent.prototype,"startButtonLabel",2);a([u.Input()],exports.LivenessComponent.prototype,"challengeMapping",2);a([u.Output()],exports.LivenessComponent.prototype,"onComplete",2);a([u.Output()],exports.LivenessComponent.prototype,"onError",2);a([u.Output()],exports.LivenessComponent.prototype,"onStateChange",2);exports.LivenessComponent=a([u.Component({selector:"LivenessCheck",standalone:!0,imports:[q.CommonModule],templateUrl:"./liveness.component.html",encapsulation:u.ViewEncapsulation.None})],exports.LivenessComponent);exports.verifyLiveness=k.verifyLiveness;exports.LivenessEngine=U.LivenessEngine;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./api-CWu5ff9j.cjs"),m=require("./LivenessCheck-CjVP-81C.cjs"),u=require("@angular/core"),q=require("@angular/common");var _=function(r,t){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},_(r,t)};function v(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");_(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function w(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function E(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(c){i={error:c}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(i)throw i.error}}return s}function L(r,t,e){if(e||arguments.length===2)for(var n=0,o=t.length,s;n<o;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return r.concat(s||Array.prototype.slice.call(t))}function h(r){return typeof r=="function"}function B(r){var t=function(n){Error.call(n),n.stack=new Error().stack},e=r(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var S=B(function(r){return function(e){r(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
|
+
`+e.map(function(n,o){return o+1+") "+n.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function O(r,t){if(r){var e=r.indexOf(t);0<=e&&r.splice(e,1)}}var g=function(){function r(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var t,e,n,o,s;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=w(i),p=c.next();!p.done;p=c.next()){var C=p.value;C.remove(this)}}catch(l){t={error:l}}finally{try{p&&!p.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else i.remove(this);var T=this.initialTeardown;if(h(T))try{T()}catch(l){s=l instanceof S?l.errors:[l]}var x=this._finalizers;if(x){this._finalizers=null;try{for(var d=w(x),f=d.next();!f.done;f=d.next()){var F=f.value;try{P(F)}catch(l){s=s??[],l instanceof S?s=L(L([],E(s)),E(l.errors)):s.push(l)}}}catch(l){n={error:l}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(n)throw n.error}}}if(s)throw new S(s)}},r.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)P(t);else{if(t instanceof r){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},r.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},r.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},r.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&O(e,t)},r.prototype.remove=function(t){var e=this._finalizers;e&&O(e,t),t instanceof r&&t._removeParent(this)},r.EMPTY=function(){var t=new r;return t.closed=!0,t}(),r}(),V=g.EMPTY;function D(r){return r instanceof g||r&&"closed"in r&&h(r.remove)&&h(r.add)&&h(r.unsubscribe)}function P(r){h(r)?r():r.unsubscribe()}var Y={Promise:void 0},$={setTimeout:function(r,t){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,L([r,t],E(e)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function Z(r){$.setTimeout(function(){throw r})}function j(){}function b(r){r()}var H=function(r){v(t,r);function t(e){var n=r.call(this)||this;return n.isStopped=!1,e?(n.destination=e,D(e)&&e.add(n)):n.destination=G,n}return t.create=function(e,n,o){return new I(e,n,o)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(g),K=function(){function r(t){this.partialObserver=t}return r.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(n){y(n)}},r.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(n){y(n)}else y(t)},r.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){y(e)}},r}(),I=function(r){v(t,r);function t(e,n,o){var s=r.call(this)||this,i;return h(e)||!e?i={next:e??void 0,error:n??void 0,complete:o??void 0}:i=e,s.destination=new K(i),s}return t}(H);function y(r){Z(r)}function W(r){throw r}var G={closed:!0,next:j,error:W,complete:j},J=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Q(r){return r}function X(r){return r.length===0?Q:r.length===1?r[0]:function(e){return r.reduce(function(n,o){return o(n)},e)}}var A=function(){function r(t){t&&(this._subscribe=t)}return r.prototype.lift=function(t){var e=new r;return e.source=this,e.operator=t,e},r.prototype.subscribe=function(t,e,n){var o=this,s=N(t)?t:new I(t,e,n);return b(function(){var i=o,c=i.operator,p=i.source;s.add(c?c.call(s,p):p?o._subscribe(s):o._trySubscribe(s))}),s},r.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},r.prototype.forEach=function(t,e){var n=this;return e=M(e),new e(function(o,s){var i=new I({next:function(c){try{t(c)}catch(p){s(p),i.unsubscribe()}},error:s,complete:o});n.subscribe(i)})},r.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},r.prototype[J]=function(){return this},r.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return X(t)(this)},r.prototype.toPromise=function(t){var e=this;return t=M(t),new t(function(n,o){var s;e.subscribe(function(i){return s=i},function(i){return o(i)},function(){return n(s)})})},r.create=function(t){return new r(t)},r}();function M(r){var t;return(t=r??Y.Promise)!==null&&t!==void 0?t:Promise}function z(r){return r&&h(r.next)&&h(r.error)&&h(r.complete)}function N(r){return r&&r instanceof H||z(r)&&D(r)}var ee=B(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),R=function(r){v(t,r);function t(){var e=r.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var n=new U(this,this);return n.operator=e,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new ee},t.prototype.next=function(e){var n=this;b(function(){var o,s;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var i=w(n.currentObservers),c=i.next();!c.done;c=i.next()){var p=c.value;p.next(e)}}catch(C){o={error:C}}finally{try{c&&!c.done&&(s=i.return)&&s.call(i)}finally{if(o)throw o.error}}}})},t.prototype.error=function(e){var n=this;b(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var o=n.observers;o.length;)o.shift().error(e)}})},t.prototype.complete=function(){var e=this;b(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var n=this,o=this,s=o.hasError,i=o.isStopped,c=o.observers;return s||i?V:(this.currentObservers=null,c.push(e),new g(function(){n.currentObservers=null,O(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var n=this,o=n.hasError,s=n.thrownError,i=n.isStopped;o?e.error(s):i&&e.complete()},t.prototype.asObservable=function(){var e=new A;return e.source=this,e},t.create=function(e,n){return new U(e,n)},t}(A),U=function(r){v(t,r);function t(e,n){var o=r.call(this)||this;return o.destination=e,o.source=n,o}return t.prototype.next=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,e)},t.prototype.error=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,e)},t.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},t.prototype._subscribe=function(e){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&o!==void 0?o:V},t}(R),te=function(r){v(t,r);function t(e){var n=r.call(this)||this;return n._value=e,n}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var n=r.prototype._subscribe.call(this,e);return!n.closed&&e.next(this._value),n},t.prototype.getValue=function(){var e=this,n=e.hasError,o=e.thrownError,s=e._value;if(n)throw o;return this._throwIfClosed(),s},t.prototype.next=function(e){r.prototype.next.call(this,this._value=e)},t}(R),re=Object.getOwnPropertyDescriptor,ne=(r,t,e,n)=>{for(var o=n>1?void 0:n?re(t,e):t,s=r.length-1,i;s>=0;s--)(i=r[s])&&(o=i(o)||o);return o};exports.LivenessService=class{constructor(t){this.ngZone=t,this.stateSubject=new te(null),this.state$=this.stateSubject.asObservable()}init(t){this.ngZone.runOutsideAngular(()=>{this.engine=new m.LivenessEngine({...t,onStateChange:e=>{this.ngZone.run(()=>this.stateSubject.next(e))}}),this.engine.loadModels()})}attach(t){var e;(e=this.engine)==null||e.attachVideo(t)}start(){var t;(t=this.engine)==null||t.start()}reset(){var t;(t=this.engine)==null||t.reset()}ngOnDestroy(){var t;(t=this.engine)==null||t.stop()}};exports.LivenessService=ne([u.Injectable({providedIn:"root"})],exports.LivenessService);var oe=Object.defineProperty,se=Object.getOwnPropertyDescriptor,a=(r,t,e,n)=>{for(var o=n>1?void 0:n?se(t,e):t,s=r.length-1,i;s>=0;s--)(i=r[s])&&(o=(n?i(t,e,o):i(o))||o);return n&&o&&oe(t,e,o),o};exports.LivenessComponent=class{constructor(t){this.liveness=t,this.duration=60,this.containerClass="",this.videoWrapperClass="",this.videoClass="",this.timerClass="",this.stateClass="",this.challengeTextClass="",this.buttonClass="",this.retryButtonClass="",this.statusOverlayClass="",this.successMessageClass="",this.errorMessageClass="",this.instructionBoxClass="",this.successMessage="Verification Successful!",this.errorMessage="Verification failed. Please try again.",this.retryButtonLabel="Try Again",this.startButtonLabel="Start Verification",this.challengeMapping={Smile:"Smile",Blink:"Blink",Turn_Head:"Turn Head",Thumbs_Up:"Thumbs Up"},this.onComplete=new u.EventEmitter,this.onError=new u.EventEmitter,this.onStateChange=new u.EventEmitter}ngOnInit(){this.liveness.state$.subscribe(t=>{this.onStateChange.emit(t)})}async ngAfterViewInit(){try{const t=await navigator.mediaDevices.getUserMedia({video:{width:640,height:480,facingMode:"user"}}),e=this.webcamRef.nativeElement;e.srcObject=t,e.onloadedmetadata=()=>{e.play(),this.liveness.init({apiUrl:this.apiUrl,duration:this.duration,smileThreshold:this.smileThreshold,blinkThreshold:this.blinkThreshold,minturnHeadThreshold:this.minturnHeadThreshold,maxturnHeadThreshold:this.maxturnHeadThreshold,onComplete:n=>this.onComplete.emit(n),onError:n=>this.onError.emit(n)}),this.liveness.attach(e)}}catch{this.onError.emit({success:!1,reason:"Camera access denied"})}}ngOnDestroy(){var e,n;const t=(n=(e=this.webcamRef)==null?void 0:e.nativeElement)==null?void 0:n.srcObject;t==null||t.getTracks().forEach(o=>o.stop())}};a([u.ViewChild("webcam")],exports.LivenessComponent.prototype,"webcamRef",2);a([u.Input()],exports.LivenessComponent.prototype,"apiUrl",2);a([u.Input()],exports.LivenessComponent.prototype,"duration",2);a([u.Input()],exports.LivenessComponent.prototype,"smileThreshold",2);a([u.Input()],exports.LivenessComponent.prototype,"blinkThreshold",2);a([u.Input()],exports.LivenessComponent.prototype,"minturnHeadThreshold",2);a([u.Input()],exports.LivenessComponent.prototype,"maxturnHeadThreshold",2);a([u.Input()],exports.LivenessComponent.prototype,"containerClass",2);a([u.Input()],exports.LivenessComponent.prototype,"videoWrapperClass",2);a([u.Input()],exports.LivenessComponent.prototype,"videoClass",2);a([u.Input()],exports.LivenessComponent.prototype,"timerClass",2);a([u.Input()],exports.LivenessComponent.prototype,"stateClass",2);a([u.Input()],exports.LivenessComponent.prototype,"challengeTextClass",2);a([u.Input()],exports.LivenessComponent.prototype,"buttonClass",2);a([u.Input()],exports.LivenessComponent.prototype,"retryButtonClass",2);a([u.Input()],exports.LivenessComponent.prototype,"statusOverlayClass",2);a([u.Input()],exports.LivenessComponent.prototype,"successMessageClass",2);a([u.Input()],exports.LivenessComponent.prototype,"errorMessageClass",2);a([u.Input()],exports.LivenessComponent.prototype,"instructionBoxClass",2);a([u.Input()],exports.LivenessComponent.prototype,"successMessage",2);a([u.Input()],exports.LivenessComponent.prototype,"errorMessage",2);a([u.Input()],exports.LivenessComponent.prototype,"retryButtonLabel",2);a([u.Input()],exports.LivenessComponent.prototype,"startButtonLabel",2);a([u.Input()],exports.LivenessComponent.prototype,"challengeMapping",2);a([u.Output()],exports.LivenessComponent.prototype,"onComplete",2);a([u.Output()],exports.LivenessComponent.prototype,"onError",2);a([u.Output()],exports.LivenessComponent.prototype,"onStateChange",2);exports.LivenessComponent=a([u.Component({selector:"LivenessCheck",standalone:!0,imports:[q.CommonModule],templateUrl:"./liveness.component.html",encapsulation:u.ViewEncapsulation.None})],exports.LivenessComponent);exports.verifyLiveness=k.verifyLiveness;exports.LivenessEngine=m.LivenessEngine;exports.LivenessSDK=m.LivenessSDK;exports.useLiveness=m.useLiveness;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { verifyLiveness as mt } from "./api-BpiDoGOd.js";
|
|
2
|
-
import { L as Z } from "./
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { L as Z } from "./LivenessCheck-uEzmlOY8.js";
|
|
3
|
+
import { a as St, u as _t } from "./LivenessCheck-uEzmlOY8.js";
|
|
4
|
+
import { Injectable as W, ViewChild as K, Input as c, Output as j, Component as q, ViewEncapsulation as G, EventEmitter as _ } from "@angular/core";
|
|
5
|
+
import { CommonModule as J } from "@angular/common";
|
|
5
6
|
var E = function(e, r) {
|
|
6
7
|
return E = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
|
|
7
8
|
t.__proto__ = n;
|
|
@@ -572,7 +573,7 @@ let a = class {
|
|
|
572
573
|
}
|
|
573
574
|
};
|
|
574
575
|
u([
|
|
575
|
-
|
|
576
|
+
K("webcam")
|
|
576
577
|
], a.prototype, "webcamRef", 2);
|
|
577
578
|
u([
|
|
578
579
|
c()
|
|
@@ -653,19 +654,21 @@ u([
|
|
|
653
654
|
j()
|
|
654
655
|
], a.prototype, "onStateChange", 2);
|
|
655
656
|
a = u([
|
|
656
|
-
|
|
657
|
+
q({
|
|
657
658
|
selector: "LivenessCheck",
|
|
658
659
|
standalone: !0,
|
|
659
660
|
// Make it standalone
|
|
660
|
-
imports: [
|
|
661
|
+
imports: [J],
|
|
661
662
|
// Add CommonModule here to fix NG8002
|
|
662
663
|
templateUrl: "./liveness.component.html",
|
|
663
|
-
encapsulation:
|
|
664
|
+
encapsulation: G.None
|
|
664
665
|
})
|
|
665
666
|
], a);
|
|
666
667
|
export {
|
|
667
668
|
a as LivenessComponent,
|
|
668
669
|
Z as LivenessEngine,
|
|
670
|
+
St as LivenessSDK,
|
|
669
671
|
H as LivenessService,
|
|
672
|
+
_t as useLiveness,
|
|
670
673
|
mt as verifyLiveness
|
|
671
674
|
};
|
package/dist/react.cjs
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var F;function te(){if(F)return k;F=1;var u=Symbol.for("react.transitional.element"),d=Symbol.for("react.fragment");function m(i,t,c){var v=null;if(c!==void 0&&(v=""+c),t.key!==void 0&&(v=""+t.key),"key"in t){c={};for(var o in t)o!=="key"&&(c[o]=t[o])}else c=t;return t=c.ref,{$$typeof:u,type:i,key:v,ref:t!==void 0?t:null,props:c}}return k.Fragment=d,k.jsx=m,k.jsxs=m,k}var S={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var M;function ne(){return M||(M=1,process.env.NODE_ENV!=="production"&&function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Z?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case q:return"Profiler";case W:return"StrictMode";case J:return"Suspense";case X:return"SuspenseList";case B: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 V:return"Portal";case z:return e.displayName||"Context";case U:return(e._context.displayName||"Context")+".Consumer";case G:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case j:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function d(e){return""+e}function m(e){try{d(e);var r=!1}catch{r=!0}if(r){r=console;var a=r.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),d(e)}}function i(e){if(e===y)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===j)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function t(){var e=x.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function v(e){if(N.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function o(e,r){function a(){Y||(Y=!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)",r))}a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}function _(){var e=u(this.type);return I[e]||(I[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 p(e,r,a,s,h,A){var l=a.ref;return e={$$typeof:C,type:e,key:r,props:a,_owner:s},(l!==void 0?l:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:_}):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:h}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function n(e,r,a,s,h,A){var l=r.children;if(l!==void 0)if(s)if(Q(l)){for(s=0;s<l.length;s++)E(l[s]);Object.freeze&&Object.freeze(l)}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 E(l);if(N.call(r,"key")){l=u(e);var T=Object.keys(r).filter(function(K){return K!=="key"});s=0<T.length?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}",D[l+s]||(T=0<T.length?"{"+T.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
-
let props = %s;
|
|
19
|
-
<%s {...props} />
|
|
20
|
-
React keys must be passed directly to JSX without using spread:
|
|
21
|
-
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,s,l,T,l),D[l+s]=!0)}if(l=null,a!==void 0&&(m(a),l=""+a),v(r)&&(m(r.key),l=""+r.key),"key"in r){a={};for(var w in r)w!=="key"&&(a[w]=r[w])}else a=r;return l&&o(a,typeof e=="function"?e.displayName||e.name||"Unknown":e),p(e,l,a,t(),h,A)}function E(e){g(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?g(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function g(e){return typeof e=="object"&&e!==null&&e.$$typeof===C}var R=b,C=Symbol.for("react.transitional.element"),V=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),z=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),Z=Symbol.for("react.client.reference"),x=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=Object.prototype.hasOwnProperty,Q=Array.isArray,O=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var Y,I={},L=R.react_stack_bottom_frame.bind(R,c)(),$=O(i(c)),D={};S.Fragment=y,S.jsx=function(e,r,a){var s=1e4>x.recentlyCreatedOwnerStacks++;return n(e,r,a,!1,s?Error("react-stack-top-frame"):L,s?O(i(e)):$)},S.jsxs=function(e,r,a){var s=1e4>x.recentlyCreatedOwnerStacks++;return n(e,r,a,!0,s?Error("react-stack-top-frame"):L,s?O(i(e)):$)}}()),S}process.env.NODE_ENV==="production"?P.exports=te():P.exports=ne();var f=P.exports;const ae=u=>{const[d,m]=b.useState({status:"loading",sequence:[],currentStep:0,timeLeft:u.duration||60,isStepTransitioning:!1,errorMsg:"",snapshots:[]}),i=b.useRef(null),t=b.useRef(null);b.useEffect(()=>{const o=new re.LivenessEngine({...u,onStateChange:_=>m({..._})});return i.current=o,o.loadModels(),()=>o.stop()},[]),b.useEffect(()=>{var o,_;if(d.status!=="loading"&&d.status!=="error"){const p=(o=t.current)==null?void 0:o.video;if(p&&p.readyState>=2)(_=i.current)==null||_.attachVideo(p);else{const n=setInterval(()=>{var g,R;const E=(g=t.current)==null?void 0:g.video;E&&E.readyState>=2&&((R=i.current)==null||R.attachVideo(E),clearInterval(n))},100);return()=>clearInterval(n)}}},[d.status]);const c=b.useCallback(()=>{var o;console.log("[Hook] Start Clicked"),(o=i.current)==null||o.start()},[]),v=b.useCallback(()=>{var o;console.log("[Hook] Reset Clicked"),(o=i.current)==null||o.reset()},[]);return{...d,webcamRef:t,start:c,reset:v}},oe=({apiUrl:u,duration:d,onComplete:m,onError:i,classNames:t={},render:c,smileThreshold:v,blinkThreshold:o,minturnHeadThreshold:_,maxturnHeadThreshold:p})=>{var E;const n=ae({apiUrl:u,duration:d,smileThreshold:v,blinkThreshold:o,minturnHeadThreshold:_,maxturnHeadThreshold:p,onComplete:m,onError:i});return c?c(n):f.jsxs("div",{className:t.container,children:[n.status==="loading"&&f.jsx("div",{children:"Initializing..."}),["ready","capturing","verifying"].includes(n.status)&&f.jsxs(f.Fragment,{children:[f.jsx(ee,{ref:n.webcamRef,mirrored:!0,screenshotFormat:"image/jpeg",className:t.webcam}),n.status==="capturing"&&f.jsx("div",{className:"liveness-challenge",children:n.isStepTransitioning?"Step verified! Get ready for the next...":`Do this: ${(E=n.sequence[n.currentStep])==null?void 0:E.replace("_"," ")}`}),["capturing","ready"].includes(n.status)&&f.jsxs("div",{className:t.timer,children:[n.timeLeft,"s"]}),n.status==="ready"&&f.jsx("button",{onClick:n.start,className:t.button,children:"Start Challenge"}),n.status==="verifying"&&f.jsx("div",{children:"Analyzing..."})]}),n.status==="error"&&f.jsxs("div",{className:t.error,children:[n.errorMsg,f.jsx("button",{onClick:n.reset,className:t.button,children:"Retry"})]}),n.status==="success"&&f.jsx("div",{className:t.success,children:"Verification Complete"})]})};exports.LivenessSDK=oe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./LivenessCheck-CjVP-81C.cjs");require("react-webcam");exports.LivenessSDK=e.LivenessSDK;
|