facezk-core
Version:
ZKP-AI Proof of Humanity: Live Selfie Check with Biometric Template Extraction and Fuzzy Hashing
125 lines • 3.72 kB
TypeScript
/**
* FaceZK Core Types
* Simplified and clear type definitions for the improved API
*/
import type { Config as HumanConfig } from '@vladmandic/human';
export interface FaceZKConfig {
/** TensorFlow.js backend to use */
backend?: 'webgl' | 'wasm' | 'cpu';
/** Enable debug mode for detailed logging */
debug?: boolean;
/** Minimum confidence threshold for face detection */
minConfidence?: number;
/** Minimum liveness score threshold */
minLivenessScore?: number;
/** Model base path for loading AI models */
modelBasePath?: string;
/** System salt for humanity code generation */
systemSalt?: string;
/** Enable liveness detection */
enableLiveness?: boolean;
/** Custom Human.js configuration */
humanConfig?: Partial<HumanConfig>;
}
export interface VerificationResult {
/** Whether the verification was successful */
verified: boolean;
/** Confidence score (0-1) */
confidence: number;
/** Liveness score (0-1) */
livenessScore: number;
/** Biometric template */
biometricTemplate: BiometricTemplate;
/** Humanity code (fuzzy hash) */
humanityCode: HumanityCode;
/** Face detection results */
face?: {
box: [number, number, number, number];
landmarks: number[][];
mesh: number[][];
};
/** Processing metadata */
metadata: {
processingTime: number;
timestamp: number;
sessionId: string;
};
}
export interface BiometricTemplate {
/** Template data (encrypted/encoded) */
data: string;
/** Template version */
version: string;
/** Template creation timestamp */
timestamp: number;
/** Template hash for integrity */
hash: string;
}
export interface HumanityCode {
/** The fuzzy hash string */
hash: string;
/** Hash algorithm used */
algorithm: string;
/** Hash creation timestamp */
timestamp: number;
/** System salt used */
salt: string;
}
export interface LivenessChallenge {
/** Challenge type */
type: 'blink' | 'head-turn' | 'smile' | 'mouth-open';
/** Challenge description */
description: string;
/** Expected duration in milliseconds */
duration: number;
/** Challenge parameters */
parameters?: Record<string, any>;
}
export interface SessionState {
/** Session ID */
id: string;
/** Current state */
state: 'idle' | 'initializing' | 'ready' | 'processing' | 'completed' | 'error';
/** Progress (0-1) */
progress: number;
/** Current liveness challenge */
currentChallenge?: LivenessChallenge;
/** Session start time */
startTime: number;
/** Last activity time */
lastActivity: number;
}
export interface ProcessingOptions {
/** Force new session creation */
forceNewSession?: boolean;
/** Skip liveness detection */
skipLiveness?: boolean;
/** Custom processing timeout */
timeout?: number;
/** Additional metadata */
metadata?: Record<string, any>;
}
export type Input = HTMLVideoElement | HTMLImageElement | ImageData | HTMLCanvasElement;
export type Backend = 'webgl' | 'wasm' | 'cpu';
export interface VerificationEvent {
type: string;
data: any;
timestamp: number;
}
export interface VerificationEventListener {
(event: VerificationEvent): void;
}
export interface HumanityResult extends VerificationResult {
}
export interface LivenessResult {
passed: boolean;
score: number;
challenge?: LivenessChallenge;
}
export interface VerificationSession extends SessionState {
}
/**
* Create an empty humanity result
*/
export declare function createEmptyHumanityResult(): HumanityResult;
//# sourceMappingURL=types.d.ts.map