@moveris/shared 0.0.1 → 1.0.0

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/index.d.ts CHANGED
@@ -1,130 +1,263 @@
1
- type MessageType = 'auth_required' | 'auth' | 'auth_success' | 'auth_error' | 'frame' | 'frame_received' | 'processing_complete' | 'error' | 'session_resume';
2
- interface BaseMessage {
3
- type: MessageType;
4
- timestamp?: number;
5
- }
6
- interface AuthRequiredMessage extends BaseMessage {
7
- type: 'auth_required';
8
- }
9
- interface AuthMessage extends BaseMessage {
10
- type: 'auth';
11
- token: string;
12
- model_file_name: string;
13
- }
14
- interface AuthSuccessMessage extends BaseMessage {
15
- type: 'auth_success';
16
- request_id: string;
17
- last_acked_frame?: number;
18
- }
19
- interface AuthErrorMessage extends BaseMessage {
20
- type: 'auth_error';
21
- error: string;
22
- code?: string;
1
+ type Verdict = 'live' | 'fake';
2
+ type FastCheckModel = '10' | '50' | '250';
3
+ type FrameSource = 'media' | 'live';
4
+ type JobStatus = 'queued' | 'processing' | 'complete' | 'failed';
5
+ interface FrameData {
6
+ index: number;
7
+ timestamp_ms: number;
8
+ pixels: string;
9
+ }
10
+ interface CropData {
11
+ index: number;
12
+ pixels: string;
13
+ }
14
+ interface HybridFrameData {
15
+ timestamp_ms: number;
16
+ pixels: string;
17
+ }
18
+ interface FastCheckRequest {
19
+ session_id: string;
20
+ model?: FastCheckModel;
21
+ source?: FrameSource;
22
+ frames: FrameData[];
23
+ }
24
+ interface FastCheckCropsRequest {
25
+ session_id: string;
26
+ model?: FastCheckModel;
27
+ source?: FrameSource;
28
+ crops: CropData[];
29
+ }
30
+ interface VerifyRequest {
31
+ session_id: string;
32
+ capture_start_ms?: number;
33
+ frame_width?: number;
34
+ frame_height?: number;
35
+ fps?: number;
36
+ frames: FrameData[];
37
+ }
38
+ interface HybridCheckRequest {
39
+ session_id: string;
40
+ fps?: number;
41
+ frames: HybridFrameData[];
23
42
  }
24
- interface FrameMessage extends BaseMessage {
25
- type: 'frame';
26
- frame_data: string;
27
- frame_number: number;
43
+ interface Hybrid50CheckRequest {
44
+ session_id: string;
45
+ fps?: number;
46
+ frames: HybridFrameData[];
28
47
  }
29
- interface FrameReceivedMessage extends BaseMessage {
30
- type: 'frame_received';
31
- frame_number: number;
48
+ interface Hybrid150CheckRequest {
49
+ session_id: string;
50
+ fps?: number;
51
+ frames: HybridFrameData[];
32
52
  }
33
- interface ProcessingCompleteMessage extends BaseMessage {
34
- type: 'processing_complete';
35
- request_id: string;
36
- prediction: 'real' | 'spoof';
53
+ interface FastCheckResponse {
54
+ verdict: Verdict | null;
55
+ confidence: number | null;
56
+ real_score: number | null;
57
+ score: number | null;
58
+ session_id: string;
59
+ model: string | null;
60
+ processing_ms: number;
61
+ frames_processed: number;
62
+ available: boolean;
63
+ warning: string | null;
64
+ error: string | null;
65
+ }
66
+ interface VerifyResponse {
67
+ verdict: Verdict;
37
68
  confidence: number;
69
+ real_score: number;
70
+ score: number;
71
+ session_id: string;
72
+ processing_ms: number;
73
+ }
74
+ interface HybridCheckResponse {
75
+ verdict: Verdict | null;
76
+ confidence: number | null;
77
+ real_score: number | null;
78
+ score: number | null;
79
+ visual_score: number | null;
80
+ physio_extracted: boolean;
81
+ session_id: string;
82
+ processing_ms: number;
83
+ frames_processed: number;
84
+ available: boolean;
85
+ warning: string | null;
86
+ error: string | null;
87
+ }
88
+ interface JobStatusResponse {
89
+ job_id: string;
90
+ status: JobStatus;
91
+ session_id: string | null;
92
+ created_at: string | null;
93
+ started_at: string | null;
94
+ completed_at: string | null;
95
+ verdict: Verdict | null;
96
+ confidence: number | null;
97
+ real_score: number | null;
98
+ processing_ms: number | null;
99
+ frames_processed: number | null;
100
+ available: boolean;
101
+ warning: string | null;
102
+ error: string | null;
103
+ }
104
+ interface QueueStatsResponse {
105
+ queue_length: number;
106
+ queue_key: string;
38
107
  }
39
- interface ErrorMessage extends BaseMessage {
40
- type: 'error';
108
+ interface HealthResponse {
109
+ status: string;
110
+ version: string;
111
+ environment: string;
112
+ models_loaded?: string[];
113
+ dependencies?: Record<string, unknown>;
114
+ }
115
+ interface ErrorResponse {
41
116
  error: string;
42
- code: string;
117
+ message: string;
118
+ required?: number;
119
+ received?: number;
120
+ }
121
+ interface LivenessResult {
122
+ verdict: Verdict;
123
+ confidence: number;
124
+ score: number;
125
+ sessionId: string;
126
+ processingMs: number;
127
+ framesProcessed: number;
128
+ }
129
+ type LivenessState = 'idle' | 'capturing' | 'uploading' | 'processing' | 'complete' | 'error';
130
+ interface LivenessConfig {
131
+ baseUrl: string;
132
+ apiKey: string;
133
+ model?: FastCheckModel;
134
+ source?: FrameSource;
135
+ fps?: number;
136
+ frameCount?: number;
137
+ timeout?: number;
138
+ }
139
+ interface CapturedFrame {
140
+ index: number;
141
+ timestampMs: number;
142
+ pixels: string;
143
+ }
144
+
145
+ type ModelType = FastCheckModel;
146
+ interface ModelConfig {
147
+ type: FastCheckModel;
148
+ minFrames: number;
149
+ recommendedFrames: number;
150
+ description: string;
43
151
  }
44
- interface SessionResumeMessage extends BaseMessage {
45
- type: 'session_resume';
46
- last_acked_frame: number;
152
+ declare const MODEL_CONFIGS: Record<FastCheckModel, ModelConfig>;
153
+ interface HybridModelConfig {
154
+ type: 'hybrid-50' | 'hybrid-150';
155
+ minFrames: number;
156
+ recommendedFps: number;
157
+ captureDurationSeconds: number;
158
+ description: string;
47
159
  }
48
- type WebSocketMessage = AuthRequiredMessage | AuthMessage | AuthSuccessMessage | AuthErrorMessage | FrameMessage | FrameReceivedMessage | ProcessingCompleteMessage | ErrorMessage | SessionResumeMessage;
160
+ declare const HYBRID_MODEL_CONFIGS: Record<string, HybridModelConfig>;
161
+ declare function getMinFramesForModel(model: FastCheckModel): number;
162
+ declare function hasEnoughFrames(model: FastCheckModel, frameCount: number): boolean;
49
163
 
50
164
  interface Frame {
51
- number: number;
165
+ index: number;
52
166
  data: string;
53
167
  timestamp: number;
54
168
  size: number;
55
169
  }
56
- type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error';
57
- interface LivenessResult {
58
- prediction: 'real' | 'spoof';
59
- confidence: number;
60
- requestId: string;
61
- }
62
170
  type OnResultCallback = (result: LivenessResult) => void;
63
171
  type OnErrorCallback = (error: Error) => void;
64
- type OnFrameAckCallback = (frameNumber: number) => void;
65
- type OnConnectionStateChangeCallback = (state: ConnectionState) => void;
172
+ type OnFrameCapturedCallback = (frame: Frame) => void;
66
173
  type OnProgressCallback = (current: number, total: number) => void;
174
+ type OnStateChangeCallback = (state: LivenessState) => void;
67
175
  interface LivenessCallbacks {
68
176
  onResult?: OnResultCallback;
69
177
  onError?: OnErrorCallback;
70
- onFrameAck?: OnFrameAckCallback;
71
- onConnectionStateChange?: OnConnectionStateChangeCallback;
178
+ onFrameCaptured?: OnFrameCapturedCallback;
72
179
  onProgress?: OnProgressCallback;
180
+ onStateChange?: OnStateChangeCallback;
73
181
  }
74
182
 
75
- interface WebSocketClientConfig {
76
- url: string;
183
+ interface LivenessClientConfig {
184
+ baseUrl?: string;
77
185
  apiKey: string;
78
- model: string;
79
- onMessage?: (message: WebSocketMessage) => void;
80
- onConnectionStateChange?: OnConnectionStateChangeCallback;
81
- onError?: (error: Error) => void;
82
- }
83
- declare class WebSocketClient {
84
- private ws;
85
- private connectionManager;
86
- private authManager;
87
- private config;
88
- private state;
89
- constructor(config: WebSocketClientConfig);
90
- connect(): Promise<void>;
91
- disconnect(): void;
92
- sendFrame(frameData: string, frameNumber: number): void;
93
- getState(): ConnectionState;
94
- private setState;
95
- private handleMessage;
96
- private handleError;
186
+ timeout?: number;
187
+ enableRetry?: boolean;
188
+ customFetch?: typeof fetch;
97
189
  }
98
-
99
- declare class AuthManager {
100
- authenticate(ws: WebSocket, apiKey: string, model: string): Promise<string>;
101
- }
102
-
103
- interface ConnectionManagerConfig {
104
- onReconnect: () => Promise<void>;
105
- maxAttempts?: number;
190
+ declare class LivenessApiError extends Error {
191
+ readonly code: string;
192
+ readonly statusCode: number;
193
+ readonly required?: number;
194
+ readonly received?: number;
195
+ constructor(message: string, code: string, statusCode: number, required?: number, received?: number);
106
196
  }
107
- declare class ConnectionManager {
108
- private config;
109
- private reconnectAttempts;
110
- constructor(config: ConnectionManagerConfig);
111
- handleDisconnect(): Promise<void>;
112
- reset(): void;
197
+ declare function toFrameData(frames: CapturedFrame[]): FrameData[];
198
+ declare function toHybridFrameData(frames: CapturedFrame[]): HybridFrameData[];
199
+ declare function toLivenessResult(response: FastCheckResponse | VerifyResponse | HybridCheckResponse): LivenessResult;
200
+ declare function generateSessionId(): string;
201
+ declare class LivenessClient {
202
+ private readonly baseUrl;
203
+ private readonly apiKey;
204
+ private readonly timeout;
205
+ private readonly enableRetry;
206
+ private readonly fetchFn;
207
+ constructor(config: LivenessClientConfig);
208
+ private request;
209
+ private requestWithRetry;
210
+ health(): Promise<HealthResponse>;
211
+ queueStats(): Promise<QueueStatsResponse>;
212
+ fastCheck(frames: CapturedFrame[], options?: {
213
+ sessionId?: string;
214
+ model?: FastCheckModel;
215
+ source?: FrameSource;
216
+ }): Promise<LivenessResult>;
217
+ fastCheckCrops(crops: CropData[], options?: {
218
+ sessionId?: string;
219
+ model?: FastCheckModel;
220
+ source?: FrameSource;
221
+ }): Promise<LivenessResult>;
222
+ verify(frames: CapturedFrame[], options?: {
223
+ sessionId?: string;
224
+ captureStartMs?: number;
225
+ frameWidth?: number;
226
+ frameHeight?: number;
227
+ fps?: number;
228
+ }): Promise<LivenessResult>;
229
+ hybridCheck(frames: CapturedFrame[], options?: {
230
+ sessionId?: string;
231
+ fps?: number;
232
+ }): Promise<LivenessResult>;
233
+ hybrid50(frames: CapturedFrame[], options?: {
234
+ sessionId?: string;
235
+ fps?: number;
236
+ }): Promise<LivenessResult>;
237
+ hybrid150(frames: CapturedFrame[], options?: {
238
+ sessionId?: string;
239
+ fps?: number;
240
+ }): Promise<LivenessResult>;
241
+ getJobResult(jobId: string): Promise<JobStatusResponse>;
242
+ waitForJobResult(jobId: string, timeout?: number): Promise<JobStatusResponse>;
113
243
  }
114
244
 
115
245
  declare class FrameBuffer {
116
246
  private buffer;
117
- private lastAcknowledged;
118
247
  private currentMemoryUsage;
119
248
  private readonly maxSize;
120
249
  private readonly maxMemory;
121
250
  constructor(maxSize?: number, maxMemory?: number);
122
251
  add(frame: Frame): void;
123
- acknowledge(frameNumber: number): void;
124
- getUnacknowledged(): Frame[];
125
- getLastAcknowledged(): number;
252
+ get(index: number): Frame | undefined;
253
+ getAll(): Frame[];
254
+ getRange(startIndex: number, endIndex: number): Frame[];
255
+ getLatest(count: number): Frame[];
256
+ removeUpTo(index: number): void;
126
257
  size(): number;
127
258
  getMemoryUsage(): number;
259
+ isEmpty(): boolean;
260
+ isFull(): boolean;
128
261
  clear(): void;
129
262
  private remove;
130
263
  private flushOldest;
@@ -141,24 +274,27 @@ declare class FrameQueue {
141
274
  toArray(): Frame[];
142
275
  }
143
276
 
144
- type ModelType = '50-frame' | '250-frame';
145
- interface ModelConfig {
146
- type: ModelType;
147
- fileName: string;
148
- frameCount: number;
149
- }
150
- declare const MODEL_CONFIGS: Record<ModelType, ModelConfig>;
151
-
152
277
  declare const API_ENDPOINTS: {
153
- readonly production: "wss://api.moveris.com/v1/liveness";
154
- readonly staging: "wss://staging-api.moveris.com/v1/liveness";
155
- readonly development: "ws://localhost:8080/v1/liveness";
278
+ readonly production: "https://api.moveris.com";
279
+ readonly staging: "https://moveris-api-v2-staging.fly.dev";
280
+ readonly development: "http://localhost:8000";
281
+ };
282
+ declare const DEFAULT_ENDPOINT: "https://api.moveris.com";
283
+ declare const API_PATHS: {
284
+ readonly health: "/health";
285
+ readonly fastCheck: "/api/v1/fast-check";
286
+ readonly fastCheckCrops: "/api/v1/fast-check-crops";
287
+ readonly verify: "/api/v1/verify";
288
+ readonly hybridCheck: "/api/v1/hybrid-check";
289
+ readonly hybrid50: "/api/v1/hybrid-50";
290
+ readonly hybrid150: "/api/v1/hybrid-150";
291
+ readonly jobResult: "/api/v1/result";
292
+ readonly queueStats: "/api/v1/queue/stats";
156
293
  };
157
- declare const DEFAULT_ENDPOINT: "wss://api.moveris.com/v1/liveness";
158
- declare const RECONNECTION_CONFIG: {
159
- readonly maxAttempts: 10;
294
+ declare const RETRY_CONFIG: {
295
+ readonly maxAttempts: 3;
160
296
  readonly initialDelay: 1000;
161
- readonly maxDelay: 30000;
297
+ readonly maxDelay: 10000;
162
298
  readonly backoffMultiplier: 2;
163
299
  };
164
300
  declare const FRAME_BUFFER_CONFIG: {
@@ -166,18 +302,127 @@ declare const FRAME_BUFFER_CONFIG: {
166
302
  readonly maxMemory: number;
167
303
  };
168
304
  declare const AUTH_CONFIG: {
169
- readonly timeout: 10000;
170
- readonly apiKeyPattern: RegExp;
305
+ readonly timeout: 30000;
306
+ readonly apiKeyHeader: "X-API-Key";
171
307
  };
172
308
  declare const FRAME_CONFIG: {
173
309
  readonly targetFPS: 30;
174
310
  readonly frameInterval: 33;
175
311
  readonly jpegQuality: 0.8;
312
+ readonly defaultModel: "10";
313
+ readonly defaultSource: "live";
314
+ };
315
+ declare const DEFAULT_LIVENESS_CONFIG: {
316
+ readonly model: "10";
317
+ readonly source: "live";
318
+ readonly fps: 30;
319
+ readonly timeout: 30000;
176
320
  };
177
321
 
322
+ declare const ALIGNMENT_THRESHOLD_CAPTURE = 0.6;
323
+ declare const ALIGNMENT_THRESHOLD_POOR = 0.5;
324
+ declare const ALIGNMENT_THRESHOLD_GOOD = 0.5;
325
+ declare const ALIGNMENT_THRESHOLD_PERFECT = 0.85;
326
+ type OvalGuideState = 'no_face' | 'poor' | 'good' | 'perfect';
327
+ declare const OVAL_GUIDE_COLORS: {
328
+ readonly no_face: "#ef4444";
329
+ readonly poor: "#f97316";
330
+ readonly good: "#eab308";
331
+ readonly perfect: "#22c55e";
332
+ };
333
+ declare const OVAL_GUIDE_STYLES: {
334
+ readonly no_face: {
335
+ readonly color: "#ef4444";
336
+ readonly dashed: true;
337
+ readonly pulse: false;
338
+ };
339
+ readonly poor: {
340
+ readonly color: "#f97316";
341
+ readonly dashed: false;
342
+ readonly pulse: false;
343
+ };
344
+ readonly good: {
345
+ readonly color: "#eab308";
346
+ readonly dashed: false;
347
+ readonly pulse: false;
348
+ };
349
+ readonly perfect: {
350
+ readonly color: "#22c55e";
351
+ readonly dashed: false;
352
+ readonly pulse: true;
353
+ };
354
+ };
355
+ declare function getOvalGuideState(hasFace: boolean, alignment: number): OvalGuideState;
356
+ declare const DEFAULT_STATUS_MESSAGES: {
357
+ readonly idle: "Ready to start";
358
+ readonly capturing: "Hold still...";
359
+ readonly uploading: "Processing...";
360
+ readonly processing: "Analyzing...";
361
+ readonly complete: "Complete!";
362
+ readonly error: "Error occurred";
363
+ };
364
+ type StatusMessageKey = keyof typeof DEFAULT_STATUS_MESSAGES;
365
+ declare const FEEDBACK_MESSAGES: {
366
+ readonly position_face: "Position your face in the oval";
367
+ readonly no_face: "No face detected - move into frame";
368
+ readonly multiple_faces: "Multiple people detected - please verify alone";
369
+ readonly move_closer_to_center: "Move closer to center";
370
+ readonly center_face: "Center your face";
371
+ readonly almost_there: "Almost there...";
372
+ readonly keep_steady: "Keep steady...";
373
+ readonly perfect: "Perfect! Hold still";
374
+ readonly scanning: "Scanning...";
375
+ readonly move_closer: "Move closer - face too far";
376
+ readonly move_back: "Move back - face too close";
377
+ readonly too_close: "Move back - face too close";
378
+ readonly too_far: "Move closer - face too far";
379
+ readonly face_not_visible: "Center your face - edges cut off";
380
+ readonly partial_face: "Center your face - edges cut off";
381
+ readonly hold_still: "Hold still - image blurry";
382
+ readonly blurry: "Hold still - image blurry";
383
+ readonly poor_lighting: "Improve lighting";
384
+ readonly too_dark: "Low lighting - move to a brighter area";
385
+ readonly backlit: "Backlit - try facing the light source";
386
+ readonly hand_detected: "Remove hand from face";
387
+ readonly capturing: "Capturing...";
388
+ readonly almost_done: "Almost done...";
389
+ readonly verification_complete: "Verification complete";
390
+ readonly align_face: "Align your face";
391
+ };
392
+ type FeedbackMessageKey = keyof typeof FEEDBACK_MESSAGES;
393
+ interface FeedbackLocale {
394
+ status: Record<StatusMessageKey, string>;
395
+ feedback: Record<FeedbackMessageKey, string>;
396
+ }
397
+ declare const DEFAULT_LOCALE: FeedbackLocale;
398
+ declare const ES_LOCALE: FeedbackLocale;
399
+ declare function getFeedbackMessage(key: FeedbackMessageKey, locale?: FeedbackLocale): string;
400
+ declare function getStatusMessage(key: StatusMessageKey, locale?: FeedbackLocale): string;
401
+ interface CaptureQualityState {
402
+ hasFace: boolean;
403
+ alignment: number;
404
+ isCapturing: boolean;
405
+ tooClose: boolean;
406
+ tooFar: boolean;
407
+ isBlurry: boolean;
408
+ isPartialFace: boolean;
409
+ framesCaptured: number;
410
+ targetFrames: number;
411
+ }
412
+ declare function getCaptureQualityFeedback(state: CaptureQualityState): string;
413
+ declare function canCaptureFrame(state: Omit<CaptureQualityState, 'framesCaptured' | 'targetFrames' | 'isCapturing'>): boolean;
414
+
178
415
  declare function validateApiKey(apiKey: string): boolean;
179
416
  declare function validateFrameData(data: string): boolean;
180
- declare function validateFrameNumber(frameNumber: number): boolean;
417
+ declare function validateFrameIndex(index: number): boolean;
418
+ declare function validateTimestamp(timestamp: number): boolean;
419
+ declare function validateFrameCount(model: FastCheckModel, frameCount: number): {
420
+ valid: boolean;
421
+ required: number;
422
+ received: number;
423
+ };
424
+ declare function validateUUID(uuid: string): boolean;
425
+ declare function validateUrl(url: string): boolean;
181
426
 
182
427
  declare function encodeBase64(buffer: ArrayBuffer | Uint8Array): string;
183
428
  declare function decodeBase64(base64: string): Uint8Array;
@@ -187,7 +432,113 @@ interface RetryOptions {
187
432
  initialDelay?: number;
188
433
  maxDelay?: number;
189
434
  backoffMultiplier?: number;
435
+ isRetryable?: (error: unknown) => boolean;
190
436
  }
191
437
  declare function retryWithBackoff<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
438
+ declare function sleep(ms: number): Promise<void>;
439
+
440
+ interface FaceBoundingBox {
441
+ originX: number;
442
+ originY: number;
443
+ width: number;
444
+ height: number;
445
+ }
446
+ interface BlurAnalysis {
447
+ variance: number;
448
+ isBlurry: boolean;
449
+ threshold: number;
450
+ }
451
+ interface LightingAnalysis {
452
+ faceBrightness: number;
453
+ backgroundBrightness: number;
454
+ ratio: number;
455
+ status: 'good' | 'backlit' | 'low_light';
456
+ warning?: string;
457
+ }
458
+ interface FaceVisibilityResult {
459
+ visible: boolean;
460
+ reason?: string;
461
+ }
462
+ interface FaceAlignmentResult {
463
+ score: number;
464
+ tooClose: boolean;
465
+ tooFar: boolean;
466
+ }
467
+ interface OvalRegion {
468
+ centerX: number;
469
+ centerY: number;
470
+ width: number;
471
+ height: number;
472
+ }
473
+ interface FaceInOvalResult {
474
+ isInside: boolean;
475
+ centerInOval: boolean;
476
+ sizeMatch: boolean;
477
+ feedback?: string;
478
+ }
479
+ interface FrameQualityResult {
480
+ passed: boolean;
481
+ blur?: BlurAnalysis;
482
+ lighting?: LightingAnalysis;
483
+ visibility?: FaceVisibilityResult;
484
+ alignment?: FaceAlignmentResult;
485
+ rejectionReason?: 'blur' | 'backlit' | 'low_light' | 'partial_face' | 'no_face' | 'too_close' | 'too_far' | 'misaligned';
486
+ }
487
+ declare const DEFAULT_BLUR_THRESHOLD = 100;
488
+ declare const BLUR_THRESHOLD_MOBILE = 150;
489
+ declare const BACKLIT_RATIO_THRESHOLD = 0.6;
490
+ declare const LOW_LIGHT_THRESHOLD = 50;
491
+ declare const MIN_FACE_TOP_MARGIN = 0.1;
492
+ declare const MIN_FACE_BOTTOM_MARGIN = 0.08;
493
+ declare const MIN_FACE_SIDE_MARGIN = 0.05;
494
+ declare const MIN_CAPTURE_ALIGNMENT = 0.6;
495
+ declare const HIGH_ALIGNMENT = 0.85;
496
+ declare const GOOD_ALIGNMENT = 0.5;
497
+ declare const IDEAL_CROP_MULTIPLIER = 3.33;
498
+ declare const MIN_CROP_MULTIPLIER = 1.5;
499
+ declare const MAX_CROP_MULTIPLIER = 4;
500
+ declare const FACE_CENTER_VERTICAL_OFFSET = 0.15;
501
+ declare const MIN_FACE_RATIO = 0.03;
502
+ declare const MAX_FACE_RATIO = 0.7;
503
+ declare const FACE_CROP_OUTPUT_SIZE = 224;
504
+ declare const MAX_FACE_PERCENTAGE_IN_CROP = 0.5;
505
+ declare const TARGET_FACE_PERCENTAGE_IN_CROP = 0.3;
506
+ declare function analyzeBlur(grayscalePixels: number[], width: number, height: number, threshold?: number): BlurAnalysis;
507
+ declare function rgbaToGrayscale(rgbaPixels: Uint8ClampedArray | number[]): number[];
508
+ declare function calculateBrightness(rgbaPixels: Uint8ClampedArray | number[]): number;
509
+ declare function analyzeLighting(faceBrightness: number, backgroundBrightness: number): LightingAnalysis;
510
+ declare function isFaceFullyVisible(boundingBox: FaceBoundingBox, frameWidth: number, frameHeight: number): FaceVisibilityResult;
511
+ declare const DEFAULT_OVAL_REGION: OvalRegion;
512
+ declare function isFaceInOval(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number, oval?: OvalRegion, tolerance?: number): FaceInOvalResult;
513
+ declare function calculateFaceAlignment(boundingBox: FaceBoundingBox, frameWidth: number, frameHeight: number): FaceAlignmentResult;
514
+ declare function calculateAdaptiveCropMultiplier(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number): number;
515
+ declare function isFaceCropFullyInFrame(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number): boolean;
516
+ declare function calculateFaceCropRegion(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number): {
517
+ x: number;
518
+ y: number;
519
+ size: number;
520
+ };
521
+ declare function checkFrameQuality(options: {
522
+ faceBox?: FaceBoundingBox;
523
+ frameWidth: number;
524
+ frameHeight: number;
525
+ blurAnalysis?: BlurAnalysis;
526
+ lightingAnalysis?: LightingAnalysis;
527
+ minAlignment?: number;
528
+ }): FrameQualityResult;
529
+ declare class BaseFrameCollector {
530
+ protected frames: CapturedFrame[];
531
+ protected maxFrames: number;
532
+ protected startTime: number;
533
+ constructor(maxFrames?: number);
534
+ setMaxFrames(max: number): void;
535
+ addFrame(frame: CapturedFrame): void;
536
+ getFrames(): CapturedFrame[];
537
+ getCount(): number;
538
+ isComplete(): boolean;
539
+ reset(): void;
540
+ getStartTime(): number;
541
+ getNextIndex(): number;
542
+ }
192
543
 
193
- export { API_ENDPOINTS, AUTH_CONFIG, type AuthErrorMessage, AuthManager, type AuthMessage, type AuthRequiredMessage, type AuthSuccessMessage, type BaseMessage, ConnectionManager, type ConnectionState, DEFAULT_ENDPOINT, type ErrorMessage, FRAME_BUFFER_CONFIG, FRAME_CONFIG, type Frame, FrameBuffer, type FrameMessage, FrameQueue, type FrameReceivedMessage, type LivenessCallbacks, type LivenessResult, MODEL_CONFIGS, type MessageType, type ModelConfig, type ModelType, type OnConnectionStateChangeCallback, type OnErrorCallback, type OnFrameAckCallback, type OnProgressCallback, type OnResultCallback, type ProcessingCompleteMessage, RECONNECTION_CONFIG, type RetryOptions, type SessionResumeMessage, WebSocketClient, type WebSocketMessage, decodeBase64, encodeBase64, retryWithBackoff, validateApiKey, validateFrameData, validateFrameNumber };
544
+ export { ALIGNMENT_THRESHOLD_CAPTURE, ALIGNMENT_THRESHOLD_GOOD, ALIGNMENT_THRESHOLD_PERFECT, ALIGNMENT_THRESHOLD_POOR, API_ENDPOINTS, API_PATHS, AUTH_CONFIG, BACKLIT_RATIO_THRESHOLD, BLUR_THRESHOLD_MOBILE, BaseFrameCollector, type BlurAnalysis, type CaptureQualityState, type CapturedFrame, type CropData, DEFAULT_BLUR_THRESHOLD, DEFAULT_ENDPOINT, DEFAULT_LIVENESS_CONFIG, DEFAULT_LOCALE, DEFAULT_OVAL_REGION, DEFAULT_STATUS_MESSAGES, ES_LOCALE, type ErrorResponse, FACE_CENTER_VERTICAL_OFFSET, FACE_CROP_OUTPUT_SIZE, FEEDBACK_MESSAGES, FRAME_BUFFER_CONFIG, FRAME_CONFIG, type FaceAlignmentResult, type FaceBoundingBox, type FaceInOvalResult, type FaceVisibilityResult, type FastCheckCropsRequest, type FastCheckModel, type FastCheckRequest, type FastCheckResponse, type FeedbackLocale, type FeedbackMessageKey, type Frame, FrameBuffer, type FrameData, type FrameQualityResult, FrameQueue, type FrameSource, GOOD_ALIGNMENT, HIGH_ALIGNMENT, HYBRID_MODEL_CONFIGS, type HealthResponse, type Hybrid150CheckRequest, type Hybrid50CheckRequest, type HybridCheckRequest, type HybridCheckResponse, type HybridFrameData, type HybridModelConfig, IDEAL_CROP_MULTIPLIER, type JobStatus, type JobStatusResponse, LOW_LIGHT_THRESHOLD, type LightingAnalysis, LivenessApiError, type LivenessCallbacks, LivenessClient, type LivenessClientConfig, type LivenessConfig, type LivenessResult, type LivenessState, MAX_CROP_MULTIPLIER, MAX_FACE_PERCENTAGE_IN_CROP, MAX_FACE_RATIO, MIN_CAPTURE_ALIGNMENT, MIN_CROP_MULTIPLIER, MIN_FACE_BOTTOM_MARGIN, MIN_FACE_RATIO, MIN_FACE_SIDE_MARGIN, MIN_FACE_TOP_MARGIN, MODEL_CONFIGS, type ModelConfig, type ModelType, OVAL_GUIDE_COLORS, OVAL_GUIDE_STYLES, type OnErrorCallback, type OnFrameCapturedCallback, type OnProgressCallback, type OnResultCallback, type OnStateChangeCallback, type OvalGuideState, type OvalRegion, type QueueStatsResponse, RETRY_CONFIG, type RetryOptions, type StatusMessageKey, TARGET_FACE_PERCENTAGE_IN_CROP, type Verdict, type VerifyRequest, type VerifyResponse, analyzeBlur, analyzeLighting, calculateAdaptiveCropMultiplier, calculateBrightness, calculateFaceAlignment, calculateFaceCropRegion, canCaptureFrame, checkFrameQuality, decodeBase64, encodeBase64, generateSessionId, getCaptureQualityFeedback, getFeedbackMessage, getMinFramesForModel, getOvalGuideState, getStatusMessage, hasEnoughFrames, isFaceCropFullyInFrame, isFaceFullyVisible, isFaceInOval, retryWithBackoff, rgbaToGrayscale, sleep, toFrameData, toHybridFrameData, toLivenessResult, validateApiKey, validateFrameCount, validateFrameData, validateFrameIndex, validateTimestamp, validateUUID, validateUrl };