Overview
The Fad Web 4 module provides a streamlined approach to biometric verification workflows. Instead of configuring individual modules, you use pre-configured tickets that orchestrate complete verification processes. This module is ideal for integrating with backend systems that manage verification workflows.
Key Features
Ticket-Based Workflow : Single ticket initiates entire verification process
Backend Orchestration : Workflows configured server-side
Simplified Integration : Minimal client-side configuration required
Multi-Step Processes : Automatically handles multiple verification steps
Version Tracking : Built-in SDK version information
No Token Required : Uses ticket authentication instead
Flexible Workflows : Backend can define any combination of verification steps
Use Cases
Backend-Managed Workflows Let your backend orchestrate complex verification flows without client updates.
Dynamic Verification Change verification requirements based on risk levels or user context.
Simplified Frontend Reduce frontend complexity by moving workflow logic to backend.
Audit and Compliance Centralized workflow management for better audit trails and compliance.
Hardware Requirements
Modern web browser with camera access (if biometric capture required)
Device camera (if facial recognition or document capture required)
Stable internet connection
HTTPS protocol (required)
Specific hardware requirements depend on the workflow configured in the ticket.
Installation
npm install @fad-producto/fad-sdk
Implementation
Import SDK
Import the FAD SDK: import FadSDK from '@fad-producto/fad-sdk' ;
Obtain Ticket from Backend
Request a verification ticket from your backend: async function getVerificationTicket ( userId ) {
const response = await fetch ( '/api/verification/create-ticket' , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({
userId ,
verificationType: 'full_kyc' , // or other verification type
}),
});
const data = await response . json ();
return data . ticket ; // Ticket string from backend
}
Initialize SDK Without Token
Create SDK instance without authentication token: const options = {
environment: FadSDK . getFadEnvironments (). UATHA ,
};
const FAD_SDK = new FadSDK ( null , options ); // No token required
Start Workflow with Ticket
Initiate the verification workflow using the ticket: async function initProcess () {
const options = {
environment: FadSDK . getFadEnvironments (). UATHA ,
};
// Check SDK version if needed
console . log ( `FAD SDK Version: ${ FadSDK . version } ` );
const FAD_SDK = new FadSDK ( null , options );
try {
// Get ticket from your backend
const ticket = await getVerificationTicket ( userId );
// Start the workflow
const result = await FAD_SDK . startFadWeb4 ( ticket );
console . log ( 'Workflow completed:' , result );
// Notify backend of completion
await notifyBackend ( result );
} catch ( ex ) {
console . error ( 'Workflow error:' , ex );
handleError ( ex );
} finally {
FAD_SDK . end ();
}
}
Response Structure
{
// Response structure depends on workflow configured in ticket
// Typically includes:
status : string , // 'completed', 'failed', 'cancelled'
workflowId : string , // Backend workflow identifier
results : object , // Results from each step in workflow
timestamp : string , // Completion timestamp
// Additional fields based on workflow
}
The exact response structure is determined by your backend configuration and the workflow steps executed.
Error Handling
Invalid Ticket
Network Error
Workflow Cancelled
try {
const result = await FAD_SDK . startFadWeb4 ( ticket );
} catch ( ex ) {
if ( ex . message . includes ( 'Invalid ticket' )) {
alert ( 'Verification session expired. Please start again.' );
// Request new ticket
}
}
Usage Examples
Complete Flow
With Status Updates
With Retry Logic
import FadSDK from '@fad-producto/fad-sdk' ;
async function performVerification ( userId ) {
// 1. Request ticket from backend
const ticketResponse = await fetch ( '/api/verification/ticket' , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({ userId }),
});
const { ticket } = await ticketResponse . json ();
// 2. Initialize SDK
const FAD_SDK = new FadSDK ( null , {
environment: FadSDK . getFadEnvironments (). UATHA ,
});
try {
// 3. Execute workflow
const result = await FAD_SDK . startFadWeb4 ( ticket );
// 4. Send results to backend
await fetch ( '/api/verification/complete' , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({
userId ,
result ,
timestamp: new Date (). toISOString (),
}),
});
return result ;
} finally {
FAD_SDK . end ();
}
}
async function verificationWithUpdates ( userId ) {
const FAD_SDK = new FadSDK ( null , {
environment: FadSDK . getFadEnvironments (). UATHA ,
});
try {
// Show initial loading
updateStatus ( 'Initializing verification...' );
// Get ticket
updateStatus ( 'Preparing verification session...' );
const ticket = await getTicket ( userId );
// Start workflow
updateStatus ( 'Please complete the verification steps...' );
const result = await FAD_SDK . startFadWeb4 ( ticket );
// Check result
if ( result . status === 'completed' ) {
updateStatus ( 'Verification completed successfully!' );
showSuccess ();
} else if ( result . status === 'cancelled' ) {
updateStatus ( 'Verification cancelled.' );
showWarning ();
} else {
updateStatus ( 'Verification incomplete.' );
showError ();
}
return result ;
} catch ( error ) {
updateStatus ( 'Verification failed.' );
showError ( error . message );
throw error ;
} finally {
FAD_SDK . end ();
}
}
async function verificationWithRetry ( userId , maxRetries = 3 ) {
let attempt = 0 ;
while ( attempt < maxRetries ) {
const FAD_SDK = new FadSDK ( null , {
environment: FadSDK . getFadEnvironments (). UATHA ,
});
try {
// Get fresh ticket for each attempt
const ticket = await getTicket ( userId );
const result = await FAD_SDK . startFadWeb4 ( ticket );
if ( result . status === 'completed' ) {
return result ;
}
if ( result . status === 'cancelled' ) {
// User cancelled, don't retry
throw new Error ( 'Verification cancelled by user' );
}
// Failed but not cancelled, retry
attempt ++ ;
console . log ( `Attempt ${ attempt } failed, retrying...` );
} catch ( error ) {
attempt ++ ;
if ( attempt >= maxRetries ) {
throw new Error ( `Verification failed after ${ maxRetries } attempts` );
}
console . log ( `Attempt ${ attempt } error:` , error . message );
await new Promise ( resolve => setTimeout ( resolve , 2000 ));
} finally {
FAD_SDK . end ();
}
}
}
Backend Integration
Creating Tickets
Your backend should provide an endpoint to create verification tickets:
// Backend example (Node.js/Express)
app . post ( '/api/verification/create-ticket' , async ( req , res ) => {
const { userId , verificationType } = req . body ;
// Create ticket with FAD backend
const ticket = await fadBackend . createTicket ({
userId ,
workflow: getWorkflowConfig ( verificationType ),
expiresIn: 3600 , // 1 hour
});
res . json ({ ticket });
});
Workflow Configuration
Tickets can be configured to include different verification steps:
// Example workflow configurations
const workflows = {
basic_kyc: {
steps: [ 'liveness' , 'document_capture' ],
settings: { /* ... */ },
},
full_kyc: {
steps: [ 'liveness' , 'document_capture' , 'face_match' ],
settings: { /* ... */ },
},
quick_verify: {
steps: [ 'liveness' ],
settings: { /* ... */ },
},
};
Best Practices
Ticket Expiration Set appropriate ticket expiration times (e.g., 1 hour) to balance security and user experience.
Secure Transmission Always transmit tickets over HTTPS and never expose ticket generation logic client-side.
Status Tracking Track workflow progress on backend for analytics and user support.
Error Recovery Implement retry logic and provide clear error messages to users.
Version Checking
The module provides SDK version information:
import FadSDK from '@fad-producto/fad-sdk' ;
console . log ( `FAD SDK Version: ${ FadSDK . version } ` );
// Use version for debugging or feature detection
if ( FadSDK . version . startsWith ( '4.' )) {
// Version 4.x features available
}
Workflow Examples
Basic KYC
Enhanced KYC
Quick Verification
Full Compliance
Steps:
Liveness detection
Document capture (front and back)
Duration: 2-3 minutesUse Case: Standard customer onboardingSteps:
Liveness detection
Document capture
Face matching
Address verification
Duration: 3-5 minutesUse Case: Financial services, regulated industriesSteps:
Liveness detection only
Duration: 30 secondsUse Case: Login verification, low-risk transactionsSteps:
Liveness detection
Document capture (multiple documents)
Face matching
Fingerprint capture
Video agreement
Duration: 5-10 minutesUse Case: High-value transactions, government services
Security Considerations
Tickets contain sensitive authorization data. Implement proper security measures.
Generate tickets server-side only
Use HTTPS for all communications
Set appropriate ticket expiration times
Implement rate limiting on ticket creation
Validate ticket results on backend
Log all verification attempts
Implement fraud detection
Never expose backend credentials client-side
Troubleshooting
Ticket may have expired
Ticket format incorrect
Backend service unavailable
Request new ticket from backend
Check network connectivity
Verify FAD SDK version
Ensure proper initialization
Check browser console for errors
User may have cancelled
Workflow step failed
Network interruption
Check backend logs for details
Backend Communication Issues
Verify API endpoints are accessible
Check CORS configuration
Ensure proper authentication
Review backend logs