Overview
The FadSDK.Constants namespace provides constant values used throughout the SDK for event handling, module configuration, and type-safe operations.
import FadSDK from '@fad-producto/fad-sdk' ;
// Access constants
FadSDK . Constants . EventModule . PROCESS_COMPLETED
FadSDK . Constants . Regula . CaptureType . DOCUMENT_READER
FadSDK . Constants . Facetec . ProcessType . VALIDATION
EventModule
Event types returned by SDK module methods to indicate the status of operations.
FadSDK . Constants . EventModule
Values
The process completed successfully. Response data is available. if ( response . event === FadSDK . Constants . EventModule . PROCESS_COMPLETED ) {
console . log ( 'Success:' , response . data );
}
The user closed the module before completion. No response data is available. if ( response . event === FadSDK . Constants . EventModule . MODULE_CLOSED ) {
console . log ( 'User cancelled the operation' );
}
Process initialization event (internal use).
An error occurred during the process (internal use).
Module is ready to start (internal use).
Module failed to load (internal use).
Entry path event (internal use).
Usage Example
import FadSDK from '@fad-producto/fad-sdk' ;
const FAD_SDK = new FadSDK ( TOKEN , options );
try {
const response = await FAD_SDK . startRegula (
credentials ,
FadSDK . Constants . Regula . CaptureType . DOCUMENT_READER ,
true ,
true
);
// Check the event type
switch ( response . event ) {
case FadSDK . Constants . EventModule . PROCESS_COMPLETED :
console . log ( 'Document captured:' , response . data );
break ;
case FadSDK . Constants . EventModule . MODULE_CLOSED :
console . log ( 'User cancelled' );
break ;
default :
console . log ( 'Unknown event:' , response . event );
}
} catch ( error ) {
console . error ( 'Error:' , error );
} finally {
FAD_SDK . end ();
}
Regula
Constants specific to the Regula document capture module.
CaptureType
Defines the capture mode for document scanning.
Manual capture mode where the user takes a photo of the document.
User controls when to capture
Manual camera button
Good for difficult lighting conditions
const response = await FAD_SDK . startRegula (
credentials ,
FadSDK . Constants . Regula . CaptureType . CAMERA_SNAPSHOT ,
true ,
true
);
Automatic capture mode with document detection and quality checks.
Automatic document detection
Real-time quality validation
Guides user to position document correctly
Captures automatically when quality is good
const response = await FAD_SDK . startRegula (
credentials ,
FadSDK . Constants . Regula . CaptureType . DOCUMENT_READER ,
true ,
true ,
configuration
);
Example: Comparing Capture Types
Camera Snapshot
Document Reader
// Manual capture - user controls when to take photo
const response = await FAD_SDK . startRegula (
credentials ,
FadSDK . Constants . Regula . CaptureType . CAMERA_SNAPSHOT ,
true , // get OCR data
true // get ID photo
);
Facetec
Constants specific to the FaceTec liveness detection module.
ProcessType
Defines the type of biometric process.
Validation process type for identity verification. const processType = FadSDK . Constants . Facetec . ProcessType . VALIDATION ;
Enrollment process type for registering a new user. const processType = FadSDK . Constants . Facetec . ProcessType . ENROLLMENT ;
Signature process type. const processType = FadSDK . Constants . Facetec . ProcessType . SIGNATURE ;
Videoconference process type. const processType = FadSDK . Constants . Facetec . ProcessType . VIDEOCONFERENCE ;
Other process types. const processType = FadSDK . Constants . Facetec . ProcessType . OTHER ;
Videotaping
Constants specific to the videotaping module.
FadSDK . Constants . Videotaping
IdsAllowed
Defines which identification types are allowed for videotaping.
Mexican ID front side. const allowedIds = [ FadSDK . Constants . Videotaping . IdsAllowed . ID_MEX_FRONT ];
Mexican ID back side. const allowedIds = [
FadSDK . Constants . Videotaping . IdsAllowed . ID_MEX_FRONT ,
FadSDK . Constants . Videotaping . IdsAllowed . ID_MEX_BACK
];
Mexican passport. const allowedIds = [ FadSDK . Constants . Videotaping . IdsAllowed . ID_PASSPORT ];
Example: Videotaping with IDs
import FadSDK from '@fad-producto/fad-sdk' ;
const FAD_SDK = new FadSDK ( TOKEN , options );
try {
const response = await FAD_SDK . startVideotaping (
'Please read the following agreement...' ,
[
FadSDK . Constants . Videotaping . IdsAllowed . ID_MEX_FRONT ,
FadSDK . Constants . Videotaping . IdsAllowed . ID_MEX_BACK ,
FadSDK . Constants . Videotaping . IdsAllowed . ID_PASSPORT
],
configuration
);
console . log ( 'Videotaping completed:' , response . data );
} finally {
FAD_SDK . end ();
}
Videoagreement
Constants specific to the videoagreement module.
FadSDK . Constants . Videoagreement
LegendSpeedMode
Defines the speed at which text is displayed in karaoke mode.
Slow text scrolling speed. const configuration = {
legendSpeedMode: FadSDK . Constants . Videoagreement . LegendSpeedMode . SLOW
};
Medium text scrolling speed. const configuration = {
legendSpeedMode: FadSDK . Constants . Videoagreement . LegendSpeedMode . MEDIUM
};
Fast text scrolling speed. const configuration = {
legendSpeedMode: FadSDK . Constants . Videoagreement . LegendSpeedMode . FAST
};
Example: Videoagreement with Speed Control
import FadSDK from '@fad-producto/fad-sdk' ;
const FAD_SDK = new FadSDK ( TOKEN , options );
const legend = `
I agree to the terms and conditions of this service.
I understand that my data will be processed according to privacy laws.
I consent to the use of biometric verification.
` ;
const configuration = {
legendSpeedMode: FadSDK . Constants . Videoagreement . LegendSpeedMode . MEDIUM
};
try {
const response = await FAD_SDK . startVideoagreement ( legend , configuration );
if ( response . event === FadSDK . Constants . EventModule . PROCESS_COMPLETED ) {
console . log ( 'Video agreement recorded:' , response . data );
}
} finally {
FAD_SDK . end ();
}
Complete Constants Reference
All Available Constants
import FadSDK from '@fad-producto/fad-sdk' ;
// Event types
const events = FadSDK . Constants . EventModule ;
console . log ( events . PROCESS_COMPLETED ); // "PROCESS_COMPLETED"
console . log ( events . MODULE_CLOSED ); // "MODULE_CLOSED"
// Regula capture types
const regulaTypes = FadSDK . Constants . Regula . CaptureType ;
console . log ( regulaTypes . CAMERA_SNAPSHOT ); // "CAMERA_SNAPSHOT"
console . log ( regulaTypes . DOCUMENT_READER ); // "DOCUMENT_READER"
// Facetec process types
const facetecTypes = FadSDK . Constants . Facetec . ProcessType ;
console . log ( facetecTypes . VALIDATION ); // 1
console . log ( facetecTypes . ENROLLMENT ); // 2
console . log ( facetecTypes . SIGNATURE ); // 3
// Videotaping IDs
const ids = FadSDK . Constants . Videotaping . IdsAllowed ;
console . log ( ids . ID_MEX_FRONT ); // "ID_MEX_FRONT"
console . log ( ids . ID_MEX_BACK ); // "ID_MEX_BACK"
console . log ( ids . ID_PASSPORT ); // "ID_PASSPORT"
// Videoagreement speeds
const speeds = FadSDK . Constants . Videoagreement . LegendSpeedMode ;
console . log ( speeds . SLOW ); // 1
console . log ( speeds . MEDIUM ); // 2
console . log ( speeds . FAST ); // 3
Type-Safe Constants Usage
Using Constants for Type Safety
import FadSDK from '@fad-producto/fad-sdk' ;
// Instead of using magic strings/numbers
// DON'T DO THIS:
const badResponse = await FAD_SDK . startRegula (
credentials ,
"DOCUMENT_READER" , // Magic string - prone to typos
true ,
true
);
// DO THIS:
const goodResponse = await FAD_SDK . startRegula (
credentials ,
FadSDK . Constants . Regula . CaptureType . DOCUMENT_READER , // Type-safe constant
true ,
true
);
// Check events with constants
if ( goodResponse . event === FadSDK . Constants . EventModule . PROCESS_COMPLETED ) {
// Handle success
}
Error Constants
While not in the Constants namespace, error codes are available in FadSDK.Errors:
import FadSDK from '@fad-producto/fad-sdk' ;
try {
const response = await FAD_SDK . startRegula ( ... );
} catch ( error ) {
// Use error constants for type-safe error handling
if ( error . code === FadSDK . Errors . Regula . CAMERA_PERMISSION_DENIED ) {
console . error ( 'Camera permission denied' );
} else if ( error . code === FadSDK . Errors . Regula . OCR_NOT_FOUND ) {
console . error ( 'OCR extraction failed' );
} else if ( error . code === FadSDK . Errors . Regula . ID_PHOTO_NOT_FOUND ) {
console . error ( 'ID photo extraction failed' );
}
}
Best Practices
Always use constants instead of hardcoded values
Using constants prevents typos and makes code more maintainable. // Good
if ( response . event === FadSDK . Constants . EventModule . PROCESS_COMPLETED ) {
// ...
}
// Bad - prone to typos
if ( response . event === "PROCESS_COMPLETED" ) {
// ...
}
Store constants in variables for repeated use
If you’re using the same constant multiple times, store it in a variable. const { EventModule , Regula } = FadSDK . Constants ;
const { DOCUMENT_READER } = Regula . CaptureType ;
// Now use the shorter variable names
if ( response . event === EventModule . PROCESS_COMPLETED ) {
// ...
}
Document constant usage in your code
Add comments explaining why specific constants are used. // Use DOCUMENT_READER for automatic capture with quality validation
const captureType = FadSDK . Constants . Regula . CaptureType . DOCUMENT_READER ;
// MEDIUM speed provides good balance between readability and duration
const speedMode = FadSDK . Constants . Videoagreement . LegendSpeedMode . MEDIUM ;
Next Steps
FadSDK Class Explore all SDK methods
Constructor Learn about initialization options
Environments Configure SDK environments