flve-sdk
v0.1.0
Published
TypeScript SDK for Face Liveness Verification Engine (FLVE)
Downloads
104
Maintainers
Readme
flve-ts-sdk
TypeScript SDK for Face Liveness Verification Engine (FLVE)
Installation
npm install @labaid-ai/flve-sdkQuick Start
import { createClient } from '@labaid-ai/flve-sdk';
import * as fs from 'fs';
// Create client pointing to HuggingFace Space
const client = createClient({
baseUrl: 'https://farukhannan-flve.hf.space',
headers: {
// Add authentication token if required
// 'Authorization': 'Bearer YOUR_HF_TOKEN'
}
});
// Read image file
const imageBytes = fs.readFileSync('path/to/image.jpg');
// Enroll a face
const enrollResponse = await client.enroll({
userId: 'user123',
imageData: imageBytes,
format: 'IMAGE_FORMAT_JPEG',
});
// Verify a face
const verifyResponse = await client.verify({
referenceId: enrollResponse.referenceId,
imageData: imageBytes,
format: 'IMAGE_FORMAT_JPEG',
});
console.log('Match:', verifyResponse.isMatch);
console.log('Confidence:', verifyResponse.confidenceScore);Note: This SDK connects to the FLVE HuggingFace Space at https://farukhannan-flve.hf.space. The space may take a few seconds to wake up from sleep mode on first request.
Features
- Face Enrollment: Register faces for verification
- Face Verification: Verify faces against enrolled references
- Liveness Detection: Check if face is live (anti-spoofing)
- eKYC: Electronic Know Your Customer with challenge-response
- Streaming: Real-time video verification support
- TypeScript: Full type safety and autocompletion
API Specifications
This SDK includes bundled API specifications in the specs/ directory:
specs/openapi.yaml- REST API specificationspecs/proto/- gRPC Protocol Buffer definitions
These are included for reference and documentation purposes.
API Reference
Client Methods
enroll(request: EnrollRequest): Promise<EnrollResponse>
Enroll a new face for verification.
verify(request: VerifyRequest): Promise<VerifyResponse>
Verify a face against an enrolled reference.
checkLiveness(request: LivenessRequest): Promise<LivenessResponse>
Check if a face is live (anti-spoofing).
startEKYC(request: StartEKYCRequest): Promise<StartEKYCResponse>
Start an eKYC session with challenges.
submitEKYCFrame(request: SubmitEKYCFrameRequest): Promise<SubmitEKYCFrameResponse>
Submit a frame during eKYC session.
completeEKYC(request: CompleteEKYCRequest): Promise<CompleteEKYCResponse>
Complete an eKYC session and get results.
getEKYCStatus(request: GetEKYCStatusRequest): Promise<GetEKYCStatusResponse>
Get the status of an eKYC session.
health(request?: HealthRequest): Promise<HealthResponse>
Check service health.
Configuration
Default Configuration
The SDK is pre-configured to use the HuggingFace Space:
- Base URL:
https://farukhannan-flve.hf.space - Timeout: 30000ms
- Retry: Enabled with 3 attempts
Custom Configuration
const client = createClient({
baseUrl: 'https://farukhannan-flve.hf.space',
timeout: 30000,
retry: {
enabled: true,
maxAttempts: 3,
backoffMs: 1000,
},
headers: {
// Add HuggingFace authentication token if needed
'Authorization': 'Bearer YOUR_HF_TOKEN',
},
interceptors: {
request: (config) => {
// Modify request before sending
console.log('Request:', config);
return config;
},
response: (response) => {
// Process response
return response;
},
error: (error) => {
// Handle errors
console.error('Request failed:', error);
},
},
});Environment Variables
For local development or custom deployments, you can override the base URL:
const client = createClient({
baseUrl: process.env.FLVE_API_URL || 'https://farukhannan-flve.hf.space',
});License
MIT
Version
0.1.0
Generated by FLVE SDK Generator
This SDK is auto-generated and self-contained. All API specifications are bundled for portability.
