Skip to main content

Method Signature

FAD_SDK.startSignature(
  configuration?: Configuration
): Promise<SignatureResponse>

Description

The startSignature() method initiates the signature capture module, which simultaneously records the user’s face and their signature. This provides a secure way to capture digital signatures with biometric verification.

Parameters

configuration
Configuration
Optional configuration object for customizing the module’s behavior and appearance

Returns

SignatureResponse
Promise<object>
A promise that resolves with the signature module response

Code Example

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

const TOKEN = 'YOUR_FAD_TOKEN';

const CONFIGURATION = {
  allowClose: true,
  views: {
    instructions: true,
    preview: true,
  },
  selfie: {
    captureSelfie: false,
    imageType: 'image/png',
    imageQuality: 1,
  },
  timer: {
    recording: { min: 2, max: 15 },
    faceUndetected: 5,
  },
  customization: {
    fadCustomization: {
      colors: {
        succesful: '#5A9A92',
      },
      buttons: {
        primary: {
          backgroundColor: '#0066CC',
          labelColor: '#ffffff',
        },
      },
    },
    moduleCustomization: {
      legends: {
        tapInstruction: 'Tap the box to start signing',
        buttonFinish: 'Finish',
        recording: 'Recording',
        focusFace: 'Frame your face within the guide',
        signNowHere: 'Sign here now',
      },
      legendsInstructions: {
        title: 'Video Signature',
        subtitle: 'Frame your face within the guide and sign in the box',
        buttonNext: 'Continue',
      },
      legendsPreview: {
        title: 'Signature',
        buttonRetry: 'Sign again',
        buttonNext: 'Confirm signature',
      },
    },
  },
};

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

  const FAD_SDK = new FadSDK(TOKEN, options);
  
  try {
    const signatureResponse = await FAD_SDK.startSignature(CONFIGURATION);

    if (signatureResponse.event === FadSDK.Constants.EventModule.MODULE_CLOSED) {
      console.log('Module closed by the user');
      return;
    }

    // Process the results
    console.log('Signature captured successfully');

    // Create URLs for the video blobs
    const faceVideoUrl = URL.createObjectURL(signatureResponse.data.videoFace);
    const signatureVideoUrl = URL.createObjectURL(signatureResponse.data.videoSignature);
    
    console.log('Face video URL:', faceVideoUrl);
    console.log('Signature video URL:', signatureVideoUrl);
    console.log('Signature image:', signatureResponse.data.imageSignature);

    // Display in HTML elements
    // document.getElementById('face-video').src = faceVideoUrl;
    // document.getElementById('signature-video').src = signatureVideoUrl;
    // document.getElementById('signature-img').src = signatureResponse.data.imageSignature;

  } catch (error) {
    if (error.code === FadSDK.Errors.Signature.NOT_ACCEPT_CAMERA_PERMISSION) {
      console.error('Camera permission not granted');
    } else {
      console.error('Error:', error);
    }
  } finally {
    FAD_SDK.end();
  }
}

Error Handling

The method may throw errors that can be identified using FadSDK.Errors.Signature:
  • NOT_ACCEPT_CAMERA_PERMISSION - Camera permission was not granted
See the Signature Error Codes page for a complete list of error codes.
The signature module requires both camera and microphone permissions to function properly.
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