import { HttpClient } from "../../client/HttpClient"; import { ChallengeAction, LivenessCreateRequest, LivenessCreateResponse, LivenessSubmitResponse } from "../../types/liveness"; import { LivenessUIColors } from "./LivenessUI"; /** * Liveness module — 3-step flow aligned with Adhere backend. * * Flow: * Step 1: liveness.create() → POST /v1/sdk/liveness/create/ (multipart) * Step 2: [camera runs, user performs challenge actions] * Step 3: liveness.submit() → POST /v1/sdk/liveness/submit/ (multipart) * * After submit, the backend returns status: "processing". * Final results are delivered via webhook (liveness.completed event). */ export declare class LivenessModule { private http; constructor(http: HttpClient); /** * Step 1: Create a liveness challenge entry. * * POST /v1/sdk/liveness/create/ * Auth: x-access-token: * Content-Type: multipart/form-data */ create(params: LivenessCreateRequest): Promise; /** * Step 3: Submit liveness video recording. * * POST /v1/sdk/liveness/submit/ * Auth: x-access-token: * Content-Type: multipart/form-data * * Note: After submission, the session is revoked (single-use). * The backend returns status: "processing" — results come via webhook. * * Pass onProgress for 0–1 upload-fraction callbacks (via LivenessUploader). */ submit(entryId: number, videoBlob: Blob, snapshotBlob: Blob, autoshotBlob?: Blob, videoDurationSeconds?: number, videoSizeBytes?: number, onProgress?: (fraction: number) => void): Promise; /** * Poll the public SDK status endpoint for the final verification result. * Safe to call after the session has been revoked (no auth required) — * the ocr_* fields below are only populated by the backend when a live * session token is still attached (see HttpClient.publicGet), since they * carry PII (name, document number, face thumbnail). * * GET /v1/sdk/liveness//sdk-result/ */ pollResult(entryId: number): Promise<{ id: number; status: string; failure_reason: string | null; completed_at: string | null; ocr_status?: string; is_expired?: boolean; ocr_quality_failed?: boolean; ocr_name?: string | null; ocr_document_number?: string | null; ocr_expiry_date?: string | null; ocr_face_image_url?: string | null; ocr_rejection_reason?: string | null; }>; /** * Full liveness check — orchestrates the entire flow: * * 1. Run action detection loop (camera + MediaPipe) — challenge actions only, * not recorded (fast head/mouth motion produces blurry frames). * 2. Create liveness entry on backend (with challenge actions + optional doc) * 3. Record a short, clean, post-challenge clip (neutral pose + a natural * blink) — this is what's sent for face comparison in LIVENESS mode. * 4. Submit to backend and return response (status: "processing") * * Backend runs LIVENESS mode (blink/motion check, then its own comparison * frame extracted from this same video) for both data and document * verification — see FACE_COMPARISON_USER_GUIDE.md. * * @param container - DOM element to mount the liveness UI into * @param params - identifier info and optional document image * @param actions - override the challenge_actions tag sent to the backend (default: BLINK) * @param existingEntryId - reuse an already-created LivenessEntry (avoids double charge) */ startCheck(container: HTMLElement, params: { identifier: string; identifier_type: string; country: string; id_file?: File | Blob; document?: File | Blob; document_front?: File | Blob; document_back?: File | Blob; identity_check?: number; verification_type?: "data_verification" | "document_verification" | "liveness_only"; prewarmedStream?: MediaStream | null; colors?: Partial; }, actions?: ChallengeAction[], existingEntryId?: number): Promise; /** * Capture a single sharp frame from a video element as a JPEG Blob. * Retries up to maxAttempts times (300 ms apart) if the Laplacian blur * score is below threshold, then falls back to the best frame captured. * * Threshold calibration: * The server rejects images with OpenCV Laplacian variance < 80. * This SDK uses sum-of-squared Laplacian (different normalisation) — * empirically ~100 here corresponds to ~80 server-side. We aim for 120 * to give a comfortable safety margin. */ private captureFrame; /** * Compute average brightness (0–255) of the centre-cropped frame. * Used to reject frames that are too dark or overexposed before sending * to face comparison — server rejects IMAGE_TOO_DARK below ~40 luminance. */ private _computeBrightness; /** * Sum-of-squared Laplacian blur metric on a centre-cropped region (320×240 max). * Higher score = sharper image. * * NOTE: This is sum-of-squares, NOT Laplacian variance (which OpenCV uses). * The two scales differ — empirically, a score of ~120 here corresponds to * ~80 on the server side (OpenCV cv2.Laplacian().var()). Keep MIN_BLUR_SCORE * in captureFrame() calibrated against this. */ private _computeBlurScore; } //# sourceMappingURL=liveness.d.ts.map