import { n as WasmPipeline } from "./warmup-Dv2alr2-.js"; import { a as MLProviderConfig, i as IMLProviderCapability, o as IncodeCanvas } from "./IStorageCapability-ORkQfK3F.js"; //#region ../infra/src/wasm/wasmWebClient.d.ts /** * Configuration shape that the C++ `WebApi` passes when calling `.post(...)` * on its host JS adapter. Mirrors the upstream `ml-wasm-kit/WebClient` * `RequestConfig` for the subset of fields actually set by `WebApi`. */ type WebApiHostRequestConfig = { ie?: boolean; headers?: Record; params?: Record; timeout?: number; }; //#endregion //#region ../infra/src/capabilities/IFaceDetectionCapability.d.ts /** * Configuration for face detection provider. * Extends base ML provider config with face-detection specific options. */ interface FaceDetectionConfig extends MLProviderConfig { autocaptureInterval?: number; /** * Load the on-device selfie workflow (6 models including liveness + age * estimation) instead of the default selfie workflow (4 models). Required * when SELFIE/AUTHENTICATION has `onDeviceFaceResultsSubmissionEnabled`. */ useOnDeviceWorkflow?: boolean; /** * Load the video-selfie face workflow (`SelfieWithAggregationMetrics`, the * frame-aggregation best-shot pipeline used by the video-selfie flow) * instead of the default quality-metrics selfie workflow. Mutually exclusive * with `useOnDeviceWorkflow`. */ videoSelfie?: boolean; } interface FacePositionConstraints { minX: number; minY: number; maxX: number; maxY: number; } interface FaceDetectionThresholds { brightnessThreshold: number; blurrinessThreshold: number; tiltRotationAngleThreshold: number; minMagicCropSize: number; autocaptureInterval: number; minFaceQualityScore: number; faceOcclusionThreshold: number; /** * Milliseconds the C++ workflow waits after `onGetReady` fires before * triggering autocapture. Mirrors V1's `getReadyDelay` (2000 ms) — without * it, autocapture can fire on the first quality-passing frame, before the * front camera has finished locking focus, producing blurry captures that * the on-device quality model rejects. */ getReadyDelay: number; /** * Milliseconds over which face-detection results are aggregated before the * autocapture decision. Mirrors V1's `framesAggregationInterval` (2000 ms). */ framesAggregationInterval: number; /** * Minimum consecutive frames with a detected face required before * autocapture can trigger. Mirrors V1's `minFramesWithFace` (3). */ minFramesWithFace: number; } interface FaceAttributesThresholds { headwearThreshold: number; lensesThreshold: number; closedEyesThreshold: number; maskThreshold: number; } interface FaceChecksConfig { lenses: boolean; mask: boolean; closedEyes: boolean; headWear: boolean; occlusion: boolean; } interface FaceData { rect: { x: number; y: number; width: number; height: number; }; rightEye: { x: number; y: number; }; leftEye: { x: number; y: number; }; noseTip: { x: number; y: number; }; rightMouthCorner: { x: number; y: number; }; leftMouthCorner: { x: number; y: number; }; pitch: number; yaw: number; roll: number; } type FaceCoordinates = { rightEyeX: number; rightEyeY: number; leftEyeX: number; leftEyeY: number; noseTipX: number; noseTipY: number; rightMouthX: number; rightMouthY: number; mouthX: number; mouthY: number; x: number; y: number; width: number; height: number; }; interface FaceDetectionCallbacks { onFarAway?: () => void; onTooClose?: () => void; onTooManyFaces?: () => void; onNoFace?: () => void; onCapture?: (canvas: IncodeCanvas, faceCoordinates: FaceCoordinates) => void; onGetReady?: () => void; onGetReadyFinished?: () => void; onCenterFace?: () => void; onDark?: () => void; onBlur?: () => void; onFaceAngle?: () => void; /** * Fires on **every** processed frame that contains at least one detected * face, with the freshly-computed face data (pitch/yaw/roll/landmarks). * * Use `onFaceData` when you need a dense per-frame signal for live UI * feedback — e.g. the Personhood avatar that mirrors head pose. The * default capture pipeline does not subscribe to this, so consumers * that don't need per-frame data pay no cost. * * `frameSize` is the source frame's pixel dimensions. Optional so * existing single-arg consumers keep working (TypeScript callback * variance handles it). Personhood uses it to compute an * orientation-invariant face-size ratio for distance-aware smoothing. */ onFaceData?: (face: FaceData, frameSize?: { width: number; height: number; }) => void; onLenses?: () => void; onMask?: () => void; onEyesClosed?: () => void; onHeadWear?: () => void; onSwitchToManualCapture?: () => void; onFaceOccluded?: () => void; } /** * Capability interface for face detection and selfie capture. * Extends the base ML provider capability with face-detection specific methods. */ interface IFaceDetectionCapability extends IMLProviderCapability { /** * Sets callbacks for face detection events. * @param callbacks - Object containing callback functions for various detection events */ setCallbacks(callbacks: FaceDetectionCallbacks): void; /** * Sets position constraints for face detection. * @param constraints - Bounding box constraints for valid face position */ setPositionConstraints(constraints: FacePositionConstraints): void; /** * Sets detection thresholds for quality checks. * @param thresholds - Threshold values for various quality metrics */ setThresholds(thresholds: FaceDetectionThresholds): void; /** * Sets thresholds for face attribute detection. * @param thresholds - Threshold values for attribute detection (headwear, lenses, etc.) */ setAttributesThresholds(thresholds: FaceAttributesThresholds): void; /** * Enables or disables specific face checks. * @param config - Configuration for which checks to enable */ setChecksEnabled(config: FaceChecksConfig): void; /** * Sets video selfie mode. * @param enabled - Whether to enable video selfie mode */ setVideoSelfieMode(enabled: boolean): void; /** * Manually triggers the `onCapture` callback registered via * `setCallbacks`, using the best-quality frame the provider has * seen so far (or the most recent processed frame as a fallback). * Used by callers that want to complete a capture flow without * waiting for WASM's own autocapture criteria — e.g. Personhood's * "complete with far-away face" path, where the user may be too * small in frame for autocapture to ever fire but a verdict * (likely lower-confidence) is still desired. * * No-op when no frame is available at all (camera hasn't produced * a single decoded frame yet) or when no `onCapture` callback was * registered. */ forceCapture(): void; /** * Synchronous manual-capture entry point for the on-device selfie workflow. * Runs the full on-device pipeline on a single canvas image and stages the * results inside WASM for the next {@link postFaceResults} call. No-op for * default (non-on-device) configurations; callers should guard with the * `onDeviceFaceResultsSubmissionEnabled` flag. */ processPhoto(canvas: HTMLCanvasElement): void; /** * POSTs the staged on-device face-results JSON to `/omni/add/face-results`. * The C++ side encrypts the body via `SessionEncryptor` and routes through * the WASM `WebClient`, so the SDK's WebClient must be initialized first * (consumers calling this must configure `setup({ apiURL, wasm })`). */ postFaceResults(config?: WebApiHostRequestConfig): Promise; } //#endregion //#region ../infra/src/wasm/WasmPipelineType.d.ts declare enum WasmPipelineType { IdBlurGlarePipeline = 0, IdBarcodeAndTextQualityPipeline = 1, IdVideoSelfiePipeline = 2, SelfieWithAggregationMetrics = 3, SelfieWithQualityMetrics = 4, OnDeviceSelfieWorkflow = 5 } //#endregion //#region ../infra/src/providers/wasm/BaseWasmProvider.d.ts /** * Base configuration for WASM providers */ interface BaseWasmConfig { /** Path to the WASM binary */ wasmPath?: string; /** Path to the SIMD-optimized WASM binary (optional) */ wasmSimdPath?: string; /** Path to the WASM glue code (paired with `wasmPath`) */ glueCodePath?: string; /** * Path to the SIMD-optimized WASM glue code (paired with `wasmSimdPath`). * If omitted, defaults to a sibling `.js` derived from `wasmSimdPath`. */ glueCodeSimdPath?: string; /** Whether to use SIMD optimizations (default: true) */ useSimd?: boolean; /** * Base path for ML model files. Models will be loaded from `${modelsBasePath}/${modelFileName}`. * If not provided, models are expected in a 'models' subdirectory relative to the WASM binary. */ modelsBasePath?: string; } /** * Base provider class that abstracts common WASM functionality. * This serves as a foundation for specific ML capability providers * like FaceDetectionProvider and IdCaptureProvider. */ declare abstract class BaseWasmProvider { private _isInitialized; protected pipelineType: WasmPipelineType | undefined; /** * Creates a new BaseWasmProvider * @param pipelineType - The WASM pipeline type this provider uses */ constructor(pipelineType?: WasmPipelineType); /** * Returns whether this provider has been initialized. */ get initialized(): boolean; protected getPipelineType(): WasmPipelineType; /** * Initializes the provider by ensuring WASM is loaded * @param config - Provider configuration * @param pipeline - The pipeline type to warm up ('selfie', 'idCapture', etc.) */ protected initializeBase(config: BaseWasmConfig, pipeline: WasmPipeline): Promise; /** * Ensures the provider is initialized before performing operations. * @throws Error if not initialized */ protected ensureInitialized(): void; /** * Processes a frame through the WASM pipeline * @param image - Image data to process * @returns The pipeline result (type depends on pipeline - WASM returns any) */ protected processFrameWasm(image: ImageData): Promise; abstract processFrame(image: ImageData): Promise; /** * Resets the pipeline to its initial state. * Safe to call even if not initialized (no-op in that case). */ reset(): void; /** * Disposes of resources and resets initialization state. * Safe to call even if not initialized. */ dispose(): Promise; } //#endregion //#region ../infra/src/providers/wasm/FaceDetectionProvider.d.ts declare class FaceDetectionProvider extends BaseWasmProvider implements IFaceDetectionCapability { private defaultThresholds; private currentThresholds; private currentFrame; private onFaceDataCallback; constructor(); processFrame(image: ImageData): Promise; initialize(config: FaceDetectionConfig): Promise; /** * Last-registered onCapture callback — captured into a private * field so `forceCapture()` (called from outside the WASM-callback * lifecycle) can re-fire the same wrapper. `setCallbacks` rebinds * this on each invocation, so the field always reflects the * current consumer. */ private currentOnCaptureWrapper; processPhoto(canvas: HTMLCanvasElement): void; postFaceResults(config?: WebApiHostRequestConfig): Promise; setCallbacks(callbacks: FaceDetectionCallbacks): void; setPositionConstraints(constraints: FacePositionConstraints): void; applyDefaults(autocaptureInterval?: number): void; setAutocaptureInterval(interval: number): void; setThresholds(thresholds: FaceDetectionThresholds): void; setAttributesThresholds(thresholds: FaceAttributesThresholds): void; setChecksEnabled(config: FaceChecksConfig): void; setVideoSelfieMode(enabled: boolean): void; forceCapture(): void; reset(): void; private createDefaultFaceCoordinates; private formatFaceCoordinates; } //#endregion export { FaceData as i, BaseWasmProvider as n, FaceCoordinates as r, FaceDetectionProvider as t };