Skip to main content

Method Signature

FAD_SDK.startIdentyFace(
  credentials: IdentyCredentials,
  configuration?: Configuration
): Promise<IdentyFaceResponse>

Description

The startIdentyFace() method initiates the Identy face capture module for capturing high-quality facial biometric data. This method captures face templates suitable for biometric verification and authentication.

Parameters

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

Returns

IdentyFaceResponse
Promise<object>
A promise that resolves with the Identy face module response

Code Example

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

const CREDENTIALS = {
  app: 'YOUR_IDENTY_APP_ID',
};

const TOKEN = 'YOUR_FAD_TOKEN';

const CONFIGURATION = {
  views: {
    instructions: true,
  },
  customization: {
    fadCustomization: {
      colors: {
        primary: '#0066CC',
      },
      buttons: {
        primary: {
          backgroundColor: '#0066CC',
          labelColor: '#ffffff',
        },
      },
    },
    moduleCustomization: {
      legends: {
        locale: 'en',
      },
      legendsInstructions: {
        title: 'Face Capture',
        subtitle: 'Position your face in the guide',
        buttonNext: 'Continue',
      },
    },
  },
};

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

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

    // Process the results
    console.log('Face captured successfully');
    
    const faceImage = moduleResponse.data.templates.JPEG;
    const dataInfo = {
      quality: moduleResponse.data.quality,
      resolution: moduleResponse.data.resolution,
      captureDate: moduleResponse.data.capture_date
    };
    
    console.log('Face image:', 'data:image/png;base64,' + faceImage);
    console.log('Capture info:', dataInfo);

    // Display in HTML elements
    // document.getElementById('image-id').src = 'data:image/png;base64,' + faceImage;
    // document.getElementById('info').textContent = JSON.stringify(dataInfo, null, 2);

  } catch (error) {
    if (error.code === FadSDK.Errors.IdentyFace.NO_MODEL_URL) {
      console.error('Missing credentials or model URL');
    } else if (error.code === FadSDK.Errors.IdentyFace.ERROR_BROWSER_VERSION_NOT_SUPPORTED) {
      console.error('Browser version not supported');
    } else if (error.code === FadSDK.Errors.IdentyFace.TIMEOUT) {
      console.error('Capture timeout exceeded');
    } else {
      console.error('Error:', error);
    }
  } finally {
    FAD_SDK.end();
  }
}

Error Handling

The method may throw errors that can be identified using FadSDK.Errors.IdentyFace:
  • NO_MODEL_URL - Missing credentials or model URL
  • ERROR_BROWSER_VERSION_NOT_SUPPORTED - Browser version is not supported
  • TIMEOUT - Capture timeout exceeded
The Identy face capture module requires camera permissions and a supported browser version.
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