Skip to main content

Overview

The FadSDK class is the entry point for integrating FAD’s biometric and document capture capabilities into your web application. It provides methods for various modules including document capture, liveness detection, signature capture, and more.

Installation

npm install @fad-producto/fad-sdk

Import

import FadSDK from '@fad-producto/fad-sdk';

Basic Usage

import FadSDK from '@fad-producto/fad-sdk';

// Initialize SDK
const options = {
  environment: FadSDK.getFadEnvironments().UATHA
};

const FAD_SDK = new FadSDK(token, options);

try {
  // Start a module process
  const response = await FAD_SDK.startRegula(
    credentials,
    FadSDK.Constants.Regula.CaptureType.DOCUMENT_READER,
    true,  // idData
    true,  // idPhoto
    configuration
  );
  
  console.log('Process completed:', response.data);
} catch (error) {
  console.error('Process error:', error);
} finally {
  FAD_SDK.end();
}

Static Properties

version

The current version of the SDK.
FadSDK.version // "3.0.0"

Constants

Namespace containing constant values for SDK configuration. See Constants for details.
FadSDK.Constants.EventModule.PROCESS_COMPLETED
FadSDK.Constants.Regula.CaptureType.DOCUMENT_READER
FadSDK.Constants.Facetec.ProcessType.VALIDATION

Errors

Namespace containing error codes for all modules.
FadSDK.Errors.Regula.CAMERA_PERMISSION_DENIED
FadSDK.Errors.Facetec.Session.CAMERA_NOT_RUNNING
FadSDK.Errors.Signature.NOT_ACCEPT_CAMERA_PERMISSION

Static Methods

getFadEnvironments()

Returns available environment options for SDK initialization.
const environments = FadSDK.getFadEnvironments();
// { UATHA: 2, PROD: 3 }
See Environments for details.

Instance Methods

Core Module Methods

startRegula()

Capture and process identity documents (Capture-id&R)

startAcuant()

Document capture with Acuant (Capture-id&A)

startFacetec()

3D liveness detection (Liveness-3D)

startSignature()

Signature capture with video recording

startVideoagreement()

Video agreement recording

startVideotaping()

Video recording with face and ID detection

startRegula()

Captures and processes identity documents using Regula technology.
startRegula(
  credentials: RegulaCredentials,
  captureType: CaptureType,
  idData: boolean,
  idPhoto: boolean,
  configuration?: Configuration
): Promise<RegulaResponse>
credentials
object
required
Regula API credentials
captureType
string
required
Type of capture mode: CAMERA_SNAPSHOT or DOCUMENT_READER
idData
boolean
required
Whether to extract OCR data from the document
idPhoto
boolean
required
Whether to extract the face photo from the document
configuration
object
Optional UI and behavior customization

Example

const credentials = {
  license: 'YOUR_REGULA_LICENSE',
  apiBasePath: 'YOUR_API_BASE_PATH'
};

const response = await FAD_SDK.startRegula(
  credentials,
  FadSDK.Constants.Regula.CaptureType.DOCUMENT_READER,
  true,  // get OCR data
  true,  // get ID photo
  configuration
);

if (response.event === FadSDK.Constants.EventModule.MODULE_CLOSED) {
  console.log('User closed the module');
} else {
  console.log('Document front:', response.data.id.front);
  console.log('Document back:', response.data.id.back);
  console.log('Face photo:', response.data.idPhoto);
  console.log('OCR data:', response.data.idData.ocr);
}

startAcuant()

Captures and processes identity documents using Acuant technology.
startAcuant(
  credentials: AcuantCredentials,
  idData: boolean,
  idPhoto: boolean,
  manualCapture: boolean,
  configuration?: Configuration
): Promise<AcuantResponse>

startFacetec()

Performs 3D liveness detection using FaceTec technology.
startFacetec(
  credentials: FacetecCredentials,
  configuration?: Configuration
): Promise<FacetecResponse>

Example

const credentials = {
  // FaceTec credentials
};

const response = await FAD_SDK.startFacetec(credentials, configuration);

console.log('Audit trail:', response.data.auditTrail);
console.log('Face scan:', response.data.faceScan);

startSignature()

Captures signature with optional video recording.
startSignature(
  configuration?: Configuration
): Promise<SignatureResponse>

Example

const response = await FAD_SDK.startSignature(configuration);

if (response.event === FadSDK.Constants.EventModule.MODULE_CLOSED) {
  console.log('User closed the module');
} else {
  console.log('Signature image:', response.data.imageSignature);
  console.log('Face video:', response.data.videoFace);
  console.log('Signature video:', response.data.videoSignature);
}

startVideoagreement()

Records a video agreement with face detection.
startVideoagreement(
  legend: string,
  configuration?: Configuration
): Promise<VideoagreementResponse>

startVideotaping()

Records video with face and ID detection.
startVideotaping(
  legend: string,
  identifications: string[],
  configuration?: Configuration
): Promise<VideotapingResponse>

Additional Methods

startCaptureId()

Captures Mexican identification documents (IFE, INE, Passport).
startCaptureId(configuration?: Configuration): Promise<CaptureIdResponse>

startIdentyFace()

Performs liveness detection using Identy technology.
startIdentyFace(
  credentials: IdentyCredentials,
  configuration?: Configuration
): Promise<IdentyFaceResponse>

startIdentyFingerprints()

Captures fingerprints.
startIdentyFingerprints(
  detectionModes: DetectionModes,
  credentials: IdentyCredentials,
  configuration?: Configuration
): Promise<IdentyFingerprintsResponse>

startLivenessToc()

Performs liveness detection using TOC technology.
startLivenessToc(configuration?: Configuration): Promise<LivenessTocResponse>

startFadWeb4()

Starts the FAD Web 4 process for document signing.
startFadWeb4(ticket: string): Promise<FadWeb4Response>

startBiometrics()

Starts the biometrics validation process.
startBiometrics(ticket: string): Promise<BiometricsResponse>

startValidationId()

Starts the ID validation process.
startValidationId(
  identificationData: IdentificationData,
  configuration?: Configuration
): Promise<ValidationIdResponse>

end()

Cleans up SDK resources and removes the iframe from the DOM. Always call this method when the process is complete or if an error occurs.
FAD_SDK.end();
Always call end() in a finally block to ensure proper cleanup even if errors occur.

Response Structure

All module methods return a Promise that resolves with a response object:
event
string
Event type: PROCESS_COMPLETED or MODULE_CLOSED
data
object
Module-specific response data (only present when event is PROCESS_COMPLETED)

Error Handling

All methods throw errors with a consistent structure:
try {
  const response = await FAD_SDK.startRegula(...);
} catch (error) {
  console.error('Error code:', error.code);
  console.error('Error message:', error.error);
  
  if (error.code === FadSDK.Errors.Regula.CAMERA_PERMISSION_DENIED) {
    // Handle camera permission error
  }
}
code
number | string
Error code specific to the module. See the Errors namespace for all codes.
error
string
Human-readable error message

Next Steps

Constructor

Learn about SDK initialization options

Constants

Explore available constants and enums

Environments

Understand environment configuration

Build docs developers (and LLMs) love