import {SdkResponseType, SdkVerifierType} from "../core/generated/zenid-enums.generated.js"; import {NfcKey, UploadReadyData, VerifierSettingsBase, VerifierStateContainerForPublicDataBase} from "../core/generated/zenid-types.generated.js"; /** * Camera frame data structure */ export interface CameraFrame { /** * Raw image data (typically RGBA format) */ image: Uint8ClampedArray; /** * Frame width in pixels */ width: number; /** * Frame height in pixels */ height: number; } export enum CameraFacingMode { user = 'user', environment = 'environment', unknown = 'unknown' } /** * Interface for a camera that provides frames for verification */ export interface ICamera { stop(): Promise; init(): Promise; start(facingMode?: CameraFacingMode, resolution?: number): Promise; canSwitchCamera(): Promise; switchCamera(): Promise; /** * Control the camera torch (flashlight) * @param on - true to turn torch on, false to turn it off */ setTorch(on: boolean): Promise; /** * Check if the camera is active and ready to provide frames */ isActive(): boolean; /** * Capture and return the current frame */ getFrame(): Promise; /** * Capture the current frame and return it as an encoded blob. */ getHighResolutionFrameAsEncodedBlob(resolution?: number): Promise; } /** * Interface for a visual container (abstracting the platform-specific container) */ export interface IVisualContainer { /** * Get the width of the visual container */ getWidth(): number; /** * Get the height of the visual container */ getHeight(): number; } /** * Interface for visualization renderer */ export interface IVisualizer { /** * Initialize the visualizer with a visual container */ init(): Promise; /** * Draw overlay based on render commands */ drawOverlay(verifier: IVerifier, commands: string): void; renderText(isOn: boolean): void; /** * Clean up visualizer resources */ cleanup(): void; getWidth(): number; getHeight(): number; } /** * Interface for a verifier that processes frames and generates visualization data */ export abstract class IVerifier { /** * Check if the verifier is ready for a new frame */ abstract readyForFrame(): Promise; /** * Process a frame * @param frameData - Raw frame data * @param width - Frame width * @param height - Frame height */ abstract processFrame(frameData: Uint8ClampedArray, width: number, height: number): Promise; /** * Get render commands for visualization * @param width - Frame width * @param height - Frame height */ abstract getRenderCommands(width: number, height: number): Promise; /** * Get data ready for upload */ abstract getUploadReadyData(): Promise; /** * Submit an external response to the verifier */ abstract submitExternalResponse( responseType: SdkResponseType, request: string ): Promise; /** * Initialize or restart the verifier */ abstract initOrRestart( settings?: VerifierSettingsBase | string ): Promise; /** * Restart the verifier with previously used settings */ abstract restartWithPreviousSettings(): Promise; /** * Get the current state container */ abstract getStateContainer(): Promise; /** * Set the global visualizer version */ abstract setVisualizerVersion(visualizerVersion?: number): Promise; /** * Start the camera processing loop */ abstract processFramesFromCamera(camera: ICamera, visualizer: IVisualizer, onGiveMe?: ((state: VerifierStateContainerForPublicDataBase) => Promise) | null, onFrameProcessed?: OnFrameProcessedCallback, signal?: AbortSignal): Promise; /** * Stop the processing loop */ abstract stopProcessingLoop(): Promise; /** * Get the verifier type */ abstract getVerifierType(): SdkVerifierType; /** * Get the recommended camera facing mode */ abstract facingMode(): CameraFacingMode; abstract getSettings(): VerifierSettingsBase | null; } /** * Callback type for frame processing event */ export type OnFrameProcessedCallback = (state: VerifierStateContainerForPublicDataBase, verifier: IVerifier) => void | Promise; /** * Base camera options that can be extended by platform-specific implementations */ export interface BaseCameraOptions { /** * Target frame width */ width?: number; /** * Target frame height */ height?: number; /** * Target frame rate (fps) */ frameRate?: number; /** * Whether to use front-facing camera ('user') or back-facing camera ('environment') */ facingMode?: CameraFacingMode; /** * Enable high-resolution camera if available */ enableHighRes?: boolean; } /** * Base visualizer options that can be extended by platform-specific implementations */ export interface BaseVisualizerOptions { /** * Font to use for text rendering */ font?: string; /** * Whether to draw text in visualizations */ drawText?: boolean; /** * Additional platform-specific options */ [key: string]: any; } /** * Definition for style properties loaded from CSS */ export interface StyleDefinition { /** * CSS variable name */ key: string; /** * CSS variable value */ value: string; } /** * Status images for liveness checks */ export interface StatusImages { /** * Image for success status */ statusSuccess: ImageBitmap | null; /** * Image for error status */ statusError: ImageBitmap | null; /** * Image for waiting status */ statusWaiting: ImageBitmap | null; } /** * Rectangle definition for visual elements */ export interface Rect { /** * X coordinate (Left position) */ x: number; /** * Y coordinate (Top position) */ y: number; /** * Width of the rectangle */ width: number; /** * Height of the rectangle */ height: number; }