@moveris/shared 2.7.0 → 3.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/README.md +169 -20
- package/dist/index.d.mts +52 -6
- package/dist/index.d.ts +52 -6
- package/dist/index.js +215 -59
- package/dist/index.mjs +211 -59
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,18 @@ interface ModelEntry {
|
|
|
5
5
|
description: string;
|
|
6
6
|
min_frames: number;
|
|
7
7
|
deprecated: boolean;
|
|
8
|
+
aliases?: string[];
|
|
8
9
|
}
|
|
9
10
|
type ModelsResponse = ModelEntry[];
|
|
10
11
|
type FastCheckModel = '10' | '50' | '250' | 'hybrid-v2-10' | 'hybrid-v2-30' | 'hybrid-v2-50' | 'hybrid-v2-60' | 'hybrid-v2-90' | 'hybrid-v2-100' | 'hybrid-v2-125' | 'hybrid-v2-150' | 'hybrid-v2-250' | 'mixed-10' | 'mixed-30' | 'mixed-60' | 'mixed-90' | 'mixed-120' | 'mixed-150' | 'mixed-250' | 'mixed-10-v2' | 'mixed-30-v2' | 'mixed-60-v2' | 'mixed-90-v2' | 'mixed-120-v2' | (string & object);
|
|
12
|
+
type ModelVersion = 'latest' | 'v2' | 'v1' | 'fast' | 'spatial' | 'hybrid' | (string & object);
|
|
13
|
+
interface DeprecationInfo {
|
|
14
|
+
deprecated: boolean;
|
|
15
|
+
resolvedModel: string;
|
|
16
|
+
deprecatedModel?: string;
|
|
17
|
+
sunsetDate?: string;
|
|
18
|
+
suggestedModel?: string;
|
|
19
|
+
}
|
|
11
20
|
type StreamingStatus = 'buffering' | 'complete';
|
|
12
21
|
type FrameSource = 'media' | 'live';
|
|
13
22
|
type JobStatus = 'queued' | 'processing' | 'complete' | 'failed';
|
|
@@ -29,6 +38,7 @@ interface FastCheckRequest {
|
|
|
29
38
|
model?: FastCheckModel;
|
|
30
39
|
source?: FrameSource;
|
|
31
40
|
frames: FrameData[];
|
|
41
|
+
frame_count?: number;
|
|
32
42
|
warnings?: string[];
|
|
33
43
|
}
|
|
34
44
|
interface FastCheckCropsRequest {
|
|
@@ -36,6 +46,7 @@ interface FastCheckCropsRequest {
|
|
|
36
46
|
model?: FastCheckModel;
|
|
37
47
|
source?: FrameSource;
|
|
38
48
|
crops: CropData[];
|
|
49
|
+
frame_count?: number;
|
|
39
50
|
}
|
|
40
51
|
interface VerifyRequest {
|
|
41
52
|
session_id: string;
|
|
@@ -65,6 +76,7 @@ interface FastCheckStreamRequest {
|
|
|
65
76
|
model?: FastCheckModel;
|
|
66
77
|
source?: FrameSource;
|
|
67
78
|
frame: FrameData;
|
|
79
|
+
frame_count?: number;
|
|
68
80
|
warnings?: string[];
|
|
69
81
|
}
|
|
70
82
|
interface FastCheckResponse {
|
|
@@ -162,12 +174,14 @@ interface LivenessResult {
|
|
|
162
174
|
processingMs: number;
|
|
163
175
|
framesProcessed: number;
|
|
164
176
|
warnings?: string[];
|
|
177
|
+
deprecation?: DeprecationInfo;
|
|
165
178
|
}
|
|
166
179
|
type LivenessState = 'idle' | 'capturing' | 'uploading' | 'processing' | 'complete' | 'error';
|
|
167
180
|
interface LivenessConfig {
|
|
168
181
|
baseUrl: string;
|
|
169
182
|
apiKey: string;
|
|
170
183
|
model?: FastCheckModel;
|
|
184
|
+
modelVersion?: ModelVersion;
|
|
171
185
|
source?: FrameSource;
|
|
172
186
|
fps?: number;
|
|
173
187
|
frameCount?: number;
|
|
@@ -180,12 +194,16 @@ interface CapturedFrame {
|
|
|
180
194
|
}
|
|
181
195
|
|
|
182
196
|
type ModelType = FastCheckModel;
|
|
197
|
+
declare const VALID_FRAME_COUNTS: readonly [10, 30, 60, 90, 120];
|
|
183
198
|
interface ModelConfig {
|
|
184
199
|
type: FastCheckModel;
|
|
185
200
|
minFrames: number;
|
|
186
201
|
recommendedFrames: number;
|
|
187
202
|
description: string;
|
|
188
203
|
deprecated: boolean;
|
|
204
|
+
aliases?: string[];
|
|
205
|
+
sunsetDate?: string;
|
|
206
|
+
replacement?: string;
|
|
189
207
|
}
|
|
190
208
|
declare const MODEL_CONFIGS: Record<FastCheckModel, ModelConfig>;
|
|
191
209
|
interface HybridModelConfig {
|
|
@@ -301,7 +319,7 @@ interface FrameQualityResult {
|
|
|
301
319
|
alignment?: FaceAlignmentResult;
|
|
302
320
|
rejectionReason?: 'blur' | 'backlit' | 'low_light' | 'partial_face' | 'no_face' | 'too_close' | 'too_far' | 'misaligned';
|
|
303
321
|
}
|
|
304
|
-
declare const DEFAULT_BLUR_THRESHOLD =
|
|
322
|
+
declare const DEFAULT_BLUR_THRESHOLD = 110;
|
|
305
323
|
declare const BLUR_THRESHOLD_MOBILE = 60;
|
|
306
324
|
declare const BACKLIT_RATIO_THRESHOLD = 0.6;
|
|
307
325
|
declare const LOW_LIGHT_THRESHOLD = 50;
|
|
@@ -353,6 +371,14 @@ interface FaceRollResult {
|
|
|
353
371
|
}
|
|
354
372
|
declare const MAX_FACE_ROLL_DEGREES = 15;
|
|
355
373
|
declare function detectFaceRoll(landmarks: FaceLandmarkPoint[]): FaceRollResult;
|
|
374
|
+
interface CameraAngleResult {
|
|
375
|
+
ratio: number;
|
|
376
|
+
cameraAbove: boolean;
|
|
377
|
+
cameraBelow: boolean;
|
|
378
|
+
}
|
|
379
|
+
declare const CAMERA_ANGLE_HIGH_RATIO = 1.35;
|
|
380
|
+
declare const CAMERA_ANGLE_LOW_RATIO = 0.75;
|
|
381
|
+
declare function detectCameraAngle(landmarks: FaceLandmarkPoint[]): CameraAngleResult;
|
|
356
382
|
declare class BaseFrameCollector {
|
|
357
383
|
protected frames: CapturedFrame[];
|
|
358
384
|
protected maxFrames: number;
|
|
@@ -446,6 +472,7 @@ declare const DEFAULT_STABILIZER_CONFIG: StabilizerConfig;
|
|
|
446
472
|
interface LivenessClientConfig {
|
|
447
473
|
baseUrl?: string;
|
|
448
474
|
apiKey: string;
|
|
475
|
+
modelVersion?: ModelVersion;
|
|
449
476
|
timeout?: number;
|
|
450
477
|
enableRetry?: boolean;
|
|
451
478
|
customFetch?: typeof fetch;
|
|
@@ -465,34 +492,46 @@ declare function generateSessionId(): string;
|
|
|
465
492
|
declare class LivenessClient {
|
|
466
493
|
private readonly baseUrl;
|
|
467
494
|
private readonly apiKey;
|
|
495
|
+
private readonly modelVersion;
|
|
468
496
|
private readonly timeout;
|
|
469
497
|
private readonly enableRetry;
|
|
470
498
|
private readonly fetchFn;
|
|
471
499
|
constructor(config: LivenessClientConfig);
|
|
472
500
|
private request;
|
|
501
|
+
private requestRaw;
|
|
473
502
|
private parseErrorResponse;
|
|
474
503
|
private static unwrapErrorCode;
|
|
475
504
|
private static unwrapErrorMessage;
|
|
476
505
|
private static extractCodeFromText;
|
|
506
|
+
private static parseDeprecationHeaders;
|
|
507
|
+
private buildModelVersionHeaders;
|
|
477
508
|
private requestWithRetry;
|
|
509
|
+
private requestWithRetryRaw;
|
|
478
510
|
health(): Promise<HealthResponse>;
|
|
479
511
|
getModels(): Promise<ModelEntry[]>;
|
|
480
512
|
queueStats(): Promise<QueueStatsResponse>;
|
|
481
513
|
fastCheck(frames: CapturedFrame[], options?: {
|
|
482
514
|
sessionId?: string;
|
|
483
515
|
model?: FastCheckModel;
|
|
516
|
+
modelVersion?: ModelVersion;
|
|
517
|
+
frameCount?: number;
|
|
484
518
|
source?: FrameSource;
|
|
485
519
|
warnings?: string[];
|
|
486
520
|
}): Promise<LivenessResult>;
|
|
487
521
|
fastCheckCrops(crops: CropData[], options?: {
|
|
488
522
|
sessionId?: string;
|
|
489
523
|
model?: FastCheckModel;
|
|
524
|
+
modelVersion?: ModelVersion;
|
|
525
|
+
frameCount?: number;
|
|
490
526
|
source?: FrameSource;
|
|
491
527
|
warnings?: string[];
|
|
528
|
+
bgSegmentation?: boolean;
|
|
492
529
|
}): Promise<LivenessResult>;
|
|
493
530
|
streamFrame(frame: CapturedFrame, options: {
|
|
494
531
|
sessionId: string;
|
|
495
532
|
model?: FastCheckModel;
|
|
533
|
+
modelVersion?: ModelVersion;
|
|
534
|
+
frameCount?: number;
|
|
496
535
|
source?: FrameSource;
|
|
497
536
|
warnings?: string[];
|
|
498
537
|
}): Promise<FastCheckStreamResponse>;
|
|
@@ -500,6 +539,8 @@ declare class LivenessClient {
|
|
|
500
539
|
fastCheckStream(frames: CapturedFrame[], options?: {
|
|
501
540
|
sessionId?: string;
|
|
502
541
|
model?: FastCheckModel;
|
|
542
|
+
modelVersion?: ModelVersion;
|
|
543
|
+
frameCount?: number;
|
|
503
544
|
source?: FrameSource;
|
|
504
545
|
warnings?: string[];
|
|
505
546
|
}, callbacks?: {
|
|
@@ -509,6 +550,8 @@ declare class LivenessClient {
|
|
|
509
550
|
fastCheckStreamSequential(frames: CapturedFrame[], options?: {
|
|
510
551
|
sessionId?: string;
|
|
511
552
|
model?: FastCheckModel;
|
|
553
|
+
modelVersion?: ModelVersion;
|
|
554
|
+
frameCount?: number;
|
|
512
555
|
source?: FrameSource;
|
|
513
556
|
warnings?: string[];
|
|
514
557
|
}, callbacks?: {
|
|
@@ -602,6 +645,7 @@ declare const FRAME_BUFFER_CONFIG: {
|
|
|
602
645
|
declare const AUTH_CONFIG: {
|
|
603
646
|
readonly timeout: 30000;
|
|
604
647
|
readonly apiKeyHeader: "X-API-Key";
|
|
648
|
+
readonly modelVersionHeader: "X-Model-Version";
|
|
605
649
|
};
|
|
606
650
|
declare const FRAME_CONFIG: {
|
|
607
651
|
readonly targetFPS: 30;
|
|
@@ -704,8 +748,9 @@ declare const FEEDBACK_MESSAGES: {
|
|
|
704
748
|
readonly poor_lighting: "Improve lighting";
|
|
705
749
|
readonly too_dark: "Low lighting - move to a brighter area";
|
|
706
750
|
readonly backlit: "Backlit - try facing the light source";
|
|
707
|
-
readonly
|
|
708
|
-
readonly
|
|
751
|
+
readonly camera_angle_low: "Raise camera to eye level";
|
|
752
|
+
readonly camera_angle_high: "Lower camera to eye level";
|
|
753
|
+
readonly camera_tilted: "Hold camera level";
|
|
709
754
|
readonly hand_detected: "Remove hand from face";
|
|
710
755
|
readonly eyes_not_visible: "Eyes not clearly visible";
|
|
711
756
|
readonly eyes_shadowed: "Eyes are in shadow - improve lighting";
|
|
@@ -738,8 +783,9 @@ interface CaptureQualityState {
|
|
|
738
783
|
targetFrames: number;
|
|
739
784
|
tooFarFromIdeal?: boolean;
|
|
740
785
|
tooCloseToIdeal?: boolean;
|
|
741
|
-
|
|
742
|
-
|
|
786
|
+
cameraAngleLow?: boolean;
|
|
787
|
+
cameraAngleHigh?: boolean;
|
|
788
|
+
cameraTilted?: boolean;
|
|
743
789
|
}
|
|
744
790
|
declare function getCaptureQualityFeedback(state: CaptureQualityState): string;
|
|
745
791
|
declare function canCaptureFrame(state: Omit<CaptureQualityState, 'framesCaptured' | 'targetFrames' | 'isCapturing'>): boolean;
|
|
@@ -790,4 +836,4 @@ declare function analyzeEyeRegionContrast(pixels: Uint8Array | Uint8ClampedArray
|
|
|
790
836
|
declare function detectSpecularHighlights(pixels: Uint8Array | Uint8ClampedArray, relativeFactor?: number, meanBrightness?: number): number;
|
|
791
837
|
declare function checkEyeRegionQuality(pixels: Uint8Array | Uint8ClampedArray, thresholds?: EyeQualityThresholds): EyeRegionQuality;
|
|
792
838
|
|
|
793
|
-
export { ALIGNMENT_THRESHOLD_CAPTURE, ALIGNMENT_THRESHOLD_GOOD, ALIGNMENT_THRESHOLD_PERFECT, ALIGNMENT_THRESHOLD_POOR, API_ENDPOINTS, API_ERROR_CODES, API_PATHS, AUTH_CONFIG, type ApiErrorCode, BACKLIT_RATIO_THRESHOLD, BLUR_THRESHOLD_MOBILE, BaseFrameCollector, type BlurAnalysis, type CaptureQualityState, type CapturedFrame, type CropData, DEFAULT_BLUR_THRESHOLD, DEFAULT_ENDPOINT, DEFAULT_FACE_DETECTION_TIERS, DEFAULT_GAZE_THRESHOLDS, DEFAULT_HAND_OCCLUSION_CONFIG, DEFAULT_LIVENESS_CONFIG, DEFAULT_LOCALE, DEFAULT_OVAL_REGION, DEFAULT_STABILIZER_CONFIG, DEFAULT_STATUS_MESSAGES, type DetectionResult, type DetectionSummary, type DetectorConfig, ERROR_MESSAGES, ERROR_MESSAGES_ES, ES_LOCALE, EYE_LANDMARK_INDICES, EYE_QUALITY_THRESHOLDS, type ErrorResponse, type EyeQualityThresholds, type EyeRegionBounds, type EyeRegionQuality, type EyeRegionsBounds, FACE_CENTER_VERTICAL_OFFSET, FACE_CROP_OUTPUT_SIZE, FEEDBACK_MESSAGES, FRAME_BUFFER_CONFIG, FRAME_CONFIG, type FaceAlignmentResult, type FaceBoundingBox, type FaceDetectionTiers, type FaceInOvalResult, type FaceLandmarkPoint, type FaceRollResult, type FaceVisibilityResult, type FastCheckCropsRequest, type FastCheckModel, type FastCheckRequest, type FastCheckResponse, type FastCheckStreamRequest, type FastCheckStreamResponse, type FeedbackLocale, type FeedbackMessageKey, type Frame, FrameBuffer, type FrameData, type FrameQualityResult, FrameQueue, type FrameSource, GOOD_ALIGNMENT, type GazeThresholds, HIGH_ALIGNMENT, HYBRID_MODEL_CONFIGS, type HandOcclusionConfig, type HeadPose, type HealthResponse, type Hybrid150CheckRequest, type Hybrid50CheckRequest, type HybridCheckRequest, type HybridCheckResponse, type HybridFrameData, type HybridModelConfig, IDEAL_CROP_MULTIPLIER, type JobStatus, type JobStatusResponse, LANDMARK_INDEX, LANDMARK_MAX_BOUND, LANDMARK_MIN_BOUND, LOW_LIGHT_THRESHOLD, type LandmarkValidationResult, 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, MAX_FACE_ROLL_DEGREES, MAX_IDEAL_FACE_RATIO, MIN_CAPTURE_ALIGNMENT, MIN_CROP_MULTIPLIER, MIN_FACE_BOTTOM_MARGIN, MIN_FACE_RATIO, MIN_FACE_SIDE_MARGIN, MIN_FACE_TOP_MARGIN, MIN_IDEAL_FACE_RATIO, MIN_LANDMARK_COUNT, MODEL_CONFIGS, type ModelConfig, type ModelEntry, type ModelType, type ModelsResponse, OVAL_GUIDE_COLORS, OVAL_GUIDE_STYLES, OVAL_REGION_DESKTOP, OVAL_REGION_MOBILE, type OnErrorCallback, type OnFrameCapturedCallback, type OnProgressCallback, type OnResultCallback, type OnStateChangeCallback, type OvalGuideState, type OvalRegion, type QueueStatsResponse, RETRY_CONFIG, type RetryOptions, type StabilizationProgress, type StabilizationResult, type StabilizerConfig, type StatusMessageKey, type StreamingStatus, TARGET_FACE_PERCENTAGE_IN_CROP, type Verdict, type VerifyRequest, type VerifyResponse, type VideoFrameMetadata, analyzeBlur, analyzeEyeRegionBrightness, analyzeEyeRegionContrast, analyzeLighting, calculateAdaptiveCropMultiplier, calculateBrightness, calculateFaceAlignment, calculateFaceCropRegion, canCaptureFrame, checkEyeRegionQuality, checkFrameQuality, decodeBase64, detectFaceRoll, detectSpecularHighlights, encodeBase64, generateSessionId, getActiveModels, getApiErrorMessage, getCaptureQualityFeedback, getEyeRegionBounds, getFeedbackMessage, getMinFramesForModel, getOvalGuideState, getStatusMessage, hasEnoughFrames, isDeprecatedModel, isFaceCropFullyInFrame, isFaceFullyVisible, isFaceInOval, isRetryableError, retryWithBackoff, rgbaToGrayscale, sleep, toFrameData, toHybridFrameData, toLivenessResult, toLivenessResultFromStream, validateApiKey, validateFaceLandmarks, validateFrameCount, validateFrameData, validateFrameIndex, validateTimestamp, validateUUID, validateUrl };
|
|
839
|
+
export { ALIGNMENT_THRESHOLD_CAPTURE, ALIGNMENT_THRESHOLD_GOOD, ALIGNMENT_THRESHOLD_PERFECT, ALIGNMENT_THRESHOLD_POOR, API_ENDPOINTS, API_ERROR_CODES, API_PATHS, AUTH_CONFIG, type ApiErrorCode, BACKLIT_RATIO_THRESHOLD, BLUR_THRESHOLD_MOBILE, BaseFrameCollector, type BlurAnalysis, CAMERA_ANGLE_HIGH_RATIO, CAMERA_ANGLE_LOW_RATIO, type CameraAngleResult, type CaptureQualityState, type CapturedFrame, type CropData, DEFAULT_BLUR_THRESHOLD, DEFAULT_ENDPOINT, DEFAULT_FACE_DETECTION_TIERS, DEFAULT_GAZE_THRESHOLDS, DEFAULT_HAND_OCCLUSION_CONFIG, DEFAULT_LIVENESS_CONFIG, DEFAULT_LOCALE, DEFAULT_OVAL_REGION, DEFAULT_STABILIZER_CONFIG, DEFAULT_STATUS_MESSAGES, type DeprecationInfo, type DetectionResult, type DetectionSummary, type DetectorConfig, ERROR_MESSAGES, ERROR_MESSAGES_ES, ES_LOCALE, EYE_LANDMARK_INDICES, EYE_QUALITY_THRESHOLDS, type ErrorResponse, type EyeQualityThresholds, type EyeRegionBounds, type EyeRegionQuality, type EyeRegionsBounds, FACE_CENTER_VERTICAL_OFFSET, FACE_CROP_OUTPUT_SIZE, FEEDBACK_MESSAGES, FRAME_BUFFER_CONFIG, FRAME_CONFIG, type FaceAlignmentResult, type FaceBoundingBox, type FaceDetectionTiers, type FaceInOvalResult, type FaceLandmarkPoint, type FaceRollResult, type FaceVisibilityResult, type FastCheckCropsRequest, type FastCheckModel, type FastCheckRequest, type FastCheckResponse, type FastCheckStreamRequest, type FastCheckStreamResponse, type FeedbackLocale, type FeedbackMessageKey, type Frame, FrameBuffer, type FrameData, type FrameQualityResult, FrameQueue, type FrameSource, GOOD_ALIGNMENT, type GazeThresholds, HIGH_ALIGNMENT, HYBRID_MODEL_CONFIGS, type HandOcclusionConfig, type HeadPose, type HealthResponse, type Hybrid150CheckRequest, type Hybrid50CheckRequest, type HybridCheckRequest, type HybridCheckResponse, type HybridFrameData, type HybridModelConfig, IDEAL_CROP_MULTIPLIER, type JobStatus, type JobStatusResponse, LANDMARK_INDEX, LANDMARK_MAX_BOUND, LANDMARK_MIN_BOUND, LOW_LIGHT_THRESHOLD, type LandmarkValidationResult, 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, MAX_FACE_ROLL_DEGREES, MAX_IDEAL_FACE_RATIO, MIN_CAPTURE_ALIGNMENT, MIN_CROP_MULTIPLIER, MIN_FACE_BOTTOM_MARGIN, MIN_FACE_RATIO, MIN_FACE_SIDE_MARGIN, MIN_FACE_TOP_MARGIN, MIN_IDEAL_FACE_RATIO, MIN_LANDMARK_COUNT, MODEL_CONFIGS, type ModelConfig, type ModelEntry, type ModelType, type ModelVersion, type ModelsResponse, OVAL_GUIDE_COLORS, OVAL_GUIDE_STYLES, OVAL_REGION_DESKTOP, OVAL_REGION_MOBILE, type OnErrorCallback, type OnFrameCapturedCallback, type OnProgressCallback, type OnResultCallback, type OnStateChangeCallback, type OvalGuideState, type OvalRegion, type QueueStatsResponse, RETRY_CONFIG, type RetryOptions, type StabilizationProgress, type StabilizationResult, type StabilizerConfig, type StatusMessageKey, type StreamingStatus, TARGET_FACE_PERCENTAGE_IN_CROP, VALID_FRAME_COUNTS, type Verdict, type VerifyRequest, type VerifyResponse, type VideoFrameMetadata, analyzeBlur, analyzeEyeRegionBrightness, analyzeEyeRegionContrast, analyzeLighting, calculateAdaptiveCropMultiplier, calculateBrightness, calculateFaceAlignment, calculateFaceCropRegion, canCaptureFrame, checkEyeRegionQuality, checkFrameQuality, decodeBase64, detectCameraAngle, detectFaceRoll, detectSpecularHighlights, encodeBase64, generateSessionId, getActiveModels, getApiErrorMessage, getCaptureQualityFeedback, getEyeRegionBounds, getFeedbackMessage, getMinFramesForModel, getOvalGuideState, getStatusMessage, hasEnoughFrames, isDeprecatedModel, isFaceCropFullyInFrame, isFaceFullyVisible, isFaceInOval, isRetryableError, retryWithBackoff, rgbaToGrayscale, sleep, toFrameData, toHybridFrameData, toLivenessResult, toLivenessResultFromStream, validateApiKey, validateFaceLandmarks, validateFrameCount, validateFrameData, validateFrameIndex, validateTimestamp, validateUUID, validateUrl };
|