Skip to main content

Method Signature

FAD_SDK.startFacetec(
  credentials: FacetecCredentials,
  configuration?: Configuration
): Promise<FacetecResponse>

Description

The startFacetec() method initiates the FaceTec 3D liveness detection module. This advanced biometric verification technology ensures that a live person is present by analyzing 3D facial features and movements.

Parameters

credentials
FacetecCredentials
required
FaceTec service credentials and configuration
configuration
Configuration
Optional configuration object for customizing the module’s behavior and appearance

Returns

FacetecResponse
Promise<object>
A promise that resolves with the FaceTec module response

Code Example

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

const CREDENTIALS = {
  deviceKeyIdentifier: 'YOUR_DEVICE_KEY',
  baseURL: 'YOUR_BASE_URL',
  publicFaceScanEncryptionKey:
    '-----BEGIN PUBLIC KEY-----\n' +
    'YOUR_PUBLIC_KEY_HERE' +
    '\n-----END PUBLIC KEY-----',
  productionKeyText: {
    domains: 'yourdomain.com',
    expiryDate: '2025-12-31',
    key: 'YOUR_PRODUCTION_KEY',
  },
};

const TOKEN = 'YOUR_FAD_TOKEN';

const CONFIGURATION = {
  views: {
    instructions: true,
  },
  customization: {
    fadCustomization: {
      colors: {
        primary: '#0066CC',
        secondary: '#0066CC',
        tertiary: '#363636',
        succesful: '#5A9A92',
      },
      buttons: {
        primary: {
          backgroundColor: '#0066CC',
          labelColor: '#ffffff',
        },
      },
    },
    moduleCustomization: {
      legends: {
        facetec: {
          instructionsHeaderReadyDesktop: 'Facial Biometry',
          instructionsMessageReadyDesktop: 'Frame your face in the guide and click the button to continue',
          actionImReady: 'Continue',
          feedbackCenterFace: 'Center your face',
          feedbackFaceNotFound: 'Frame your face',
        },
      },
      legendsInstructions: {
        title: 'Liveness Check',
        subtitle: 'Frame your face in the guide',
        buttonNext: 'Continue',
      },
    },
  },
};

async function performLivenessCheck() {
  const options = {
    environment: FadSDK.getFadEnvironments().UATHA
  };

  const FAD_SDK = new FadSDK(TOKEN, options);
  
  try {
    const facetecResponse = await FAD_SDK.startFacetec(
      CREDENTIALS,
      CONFIGURATION
    );

    // Process the results
    console.log('Face scan:', facetecResponse.data.faceScan);
    console.log('Audit trail images:', facetecResponse.data.auditTrail);
    
    // Display the first audit trail image
    const firstImage = facetecResponse.data.auditTrail[0];
    console.log('First audit image:', 'data:image/png;base64,' + firstImage);

  } catch (error) {
    if (error.code === FadSDK.Errors.Facetec.Session.CAMERA_NOT_RUNNING) {
      console.error('Camera is not supported or not running');
    } else if (error.code === FadSDK.Errors.Facetec.Session.INITIALIZATION_NOT_COMPLETED) {
      console.error('FaceTec initialization not completed');
    } else {
      console.error('Error:', error);
    }
  } finally {
    FAD_SDK.end();
  }
}

Error Handling

The method may throw errors that can be identified using FadSDK.Errors.Facetec:
  • Session.CAMERA_NOT_RUNNING - Camera is not running or not supported
  • Session.INITIALIZATION_NOT_COMPLETED - FaceTec SDK initialization failed
  • Additional session-related errors for various failure scenarios
See the FaceTec Error Codes page for a complete list of error codes.
FaceTec requires HTTPS in production environments and specific browser permissions for camera access.
Always call FAD_SDK.end() in a finally block to properly clean up resources after the module completes or fails.

Build docs developers (and LLMs) love