export type LivenessCallbacks = { onChallengeChanged?: (stepIndex: number, stepLabel: string) => void; onFailure?: (reason: string) => void; onSuccess?: (imageBase64: string) => void; onFaceInOval?: (inside: boolean, reason?: string) => void; onDebugFrame?: (info: { hasFace: boolean; metrics: Metrics | null; step: string; }) => void; }; export type LivenessSoundOptions = { baseUrl?: string; left?: string; blink?: string; right?: string; nod?: string; mouth?: string; good?: string; capture?: string; }; export type LivenessOptions = { videoElement: HTMLVideoElement; canvasElement: HTMLCanvasElement; modelUrl?: string; wasmUrl?: string; callbacks?: LivenessCallbacks; sounds?: LivenessSoundOptions; /** Subset of challenges to run. Default: all 5. Empty array, duplicates and unknown keys fall back to all 5. */ steps?: LivenessStepKey[]; /** Shuffle the selected step order. Default true. */ shuffleSteps?: boolean; }; /** Identifier for a liveness challenge step. Lowercase, matches the sound-key form. */ export type LivenessStepKey = "left" | "blink" | "right" | "nod" | "mouth"; export declare const DEFAULT_MODEL_URL = "https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task"; export declare const DEFAULT_WASM_URL = "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"; /** Error code when CDN/assets are unavailable after retries (internet confirmed). */ export declare const LIVENESS_ERROR_CDN_NOT_AVAILABLE: "cdnNotAvailable"; /** Error code when the user has no internet connection. */ export declare const LIVENESS_ERROR_OFFLINE: "offline"; export declare function isCdnNotAvailableError(reason: string): boolean; export declare function isOfflineError(reason: string): boolean; export declare class LivenessError extends Error { readonly code: typeof LIVENESS_ERROR_CDN_NOT_AVAILABLE | typeof LIVENESS_ERROR_OFFLINE; constructor(code: typeof LIVENESS_ERROR_CDN_NOT_AVAILABLE | typeof LIVENESS_ERROR_OFFLINE, message: string); } export type Metrics = { yaw: number; pitch: number; ear: number; mar: number; blinkScore: number; mouthScore: number; faceCx: number; faceCy: number; faceSize: number; }; /** Resolve a caller-supplied step-key array into the corresponding display labels. * Empty / undefined / all-invalid → default to all 5 steps. Duplicates are dropped. */ export declare function resolveStepLabels(keys?: readonly LivenessStepKey[] | null): string[]; /** Default step count (5). The active session may have fewer if `options.steps` is set. */ export declare const LIVENESS_STEP_COUNT: number; export declare class LivenessEngine { private opts; private landmarker; private running; private rafId; private stream; private steps; private stepIndex; private stepStart; private baselineYaw; private baselinePitch; private baselineSamples; private blinkState; private blinkCloseTs; private blinkSeenOpen; private nodState; private holdStart; private latestMetrics; private nodPeakDPitch; private lastDetectTs; private lastOvalState; private stepSoundPlayedForCurrentStep; private currentAudio; private currentAudioCleanup; private currentAudioToken; private sessionTimeoutId; constructor(opts: LivenessOptions); private playSound; private getSoundUrl; private playStepSound; private stopAllSounds; private clearSessionTimeout; private playGoodSound; private playCaptureSound; /** Number of challenge steps in the active session (after applying `options.steps`). */ get stepCount(): number; start(): Promise; stop(): void; private stopDetectionOnly; private ensureVideo; private createLandmarker; private loop; private checkFaceInOval; private resetStepState; private updateState; private advanceStep; private fail; private scheduleCapture; private captureImage; }