| import { apiRequest } from './client' |
|
|
| |
| export type ModalityState = 'available' | 'demo_untrained' | 'unavailable' |
| export interface ModalityInfo { |
| available: boolean |
| trained?: boolean |
| experimental?: boolean |
| state: ModalityState |
| } |
| export interface BiometricStatus { |
| device: string |
| modalities: Record<string, ModalityInfo> |
| } |
| export function getBiometricStatus(): Promise<BiometricStatus> { |
| return apiRequest<BiometricStatus>('/biometrics/status') |
| } |
|
|
| |
| export interface DemoSamples { |
| face_image?: string |
| fingerprint_image?: string |
| voice_audio?: string |
| } |
| export async function getDemoSamples(userId: string): Promise<DemoSamples> { |
| const r = await apiRequest<{ samples?: DemoSamples }>('/demo/seed', { body: { user_id: userId } }) |
| return r.samples ?? {} |
| } |
|
|
| |
| export interface UnifiedEnrollInput { |
| userId: string |
| faceImage?: string |
| fingerprintImage?: string |
| voiceAudio?: string |
| } |
| export interface UnifiedEnrollResult { |
| success: boolean |
| modalities?: string[] |
| reason?: string | null |
| token?: string |
| } |
| export function unifiedEnroll(i: UnifiedEnrollInput): Promise<UnifiedEnrollResult> { |
| const body: Record<string, string> = { user_id: i.userId } |
| if (i.faceImage) body.face_image = i.faceImage |
| if (i.fingerprintImage) body.fingerprint_image = i.fingerprintImage |
| if (i.voiceAudio) body.voice_audio = i.voiceAudio |
| return apiRequest<UnifiedEnrollResult>('/unified/enroll', { body }) |
| } |
|
|
| |
| export interface UnifiedAuthResult { |
| success: boolean |
| similarity: number |
| threshold: number |
| confidence?: number |
| modalities?: string[] |
| per_modality?: Record<string, number> |
| quality_weights?: Record<string, number> |
| deepfake_score?: number | null |
| is_deepfake?: boolean |
| reason?: string | null |
| } |
| export function unifiedAuthenticate(i: UnifiedEnrollInput): Promise<UnifiedAuthResult> { |
| const body: Record<string, string> = { user_id: i.userId } |
| if (i.faceImage) body.face_image = i.faceImage |
| if (i.fingerprintImage) body.fingerprint_image = i.fingerprintImage |
| if (i.voiceAudio) body.voice_audio = i.voiceAudio |
| return apiRequest<UnifiedAuthResult>('/unified/authenticate', { body }) |
| } |
|
|
| export interface AuthResult { |
| success: boolean |
| similarity: number |
| threshold: number |
| face_liveness?: number |
| fp_liveness?: number |
| confidence?: number |
| face_quality?: number |
| fp_quality?: number |
| deepfake_score?: number | null |
| is_deepfake?: boolean |
| reason?: string | null |
| } |
| export function authenticate(userId: string, faceImage: string, fingerprintImage: string): Promise<AuthResult> { |
| return apiRequest<AuthResult>('/authenticate', { |
| body: { user_id: userId, face_image: faceImage, fingerprint_image: fingerprintImage }, |
| }) |
| } |
|
|
| export interface VerifyResult { |
| fused_similarity: number |
| face_similarity: number |
| fingerprint_similarity: number |
| } |
| export function verify1to1(face1: string, fp1: string, face2: string, fp2: string): Promise<VerifyResult> { |
| return apiRequest<VerifyResult>('/verify', { body: { face1, fp1, face2, fp2 } }) |
| } |
|
|
| |
| export function voiceEnroll(userId: string, audio: string): Promise<{ success: boolean }> { |
| return apiRequest('/voice/enroll', { body: { user_id: userId, audio } }) |
| } |
| export function voiceVerify(userId: string, audio: string): Promise<{ success: boolean; similarity: number; threshold: number }> { |
| return apiRequest('/voice/verify', { body: { user_id: userId, audio } }) |
| } |
|
|
| |
| export interface LivenessChallenge { session_id: string; challenges: string[] } |
| export function livenessChallenge(userId: string, n = 3): Promise<LivenessChallenge> { |
| return apiRequest<LivenessChallenge>('/liveness/challenge', { body: { user_id: userId, n } }) |
| } |
| export function livenessVerify(sessionId: string, completed: string[], faceImage?: string): Promise<{ success: boolean; reason?: string | null }> { |
| const body: Record<string, unknown> = { session_id: sessionId, completed } |
| if (faceImage) body.face_image = faceImage |
| return apiRequest('/liveness/verify', { body }) |
| } |
|
|
| |
| export interface FlashChallenge { session_id: string; sequence: string[]; expires?: number } |
| export function flashChallenge(userId: string, n = 4): Promise<FlashChallenge> { |
| return apiRequest<FlashChallenge>('/pad/challenge', { body: { user_id: userId, n } }) |
| } |
| export function flashVerify(sessionId: string, baseline: number[], measurements: number[][]): Promise<{ success: boolean; score?: number; reason?: string | null }> { |
| return apiRequest('/pad/verify', { body: { session_id: sessionId, baseline, measurements } }) |
| } |
|
|