Skip to main content

Signature Error Codes

The Signature module enables users to provide digital signatures with video recording. When errors occur, they are thrown as ResponseError objects with specific error codes.

Error Structure

All errors follow the ResponseError structure:
interface ResponseError {
  code: string;        // Error code constant
  message: string;     // Human-readable error message
  details?: any;       // Optional additional error details
}

Error Codes

NOT_ACCEPT_CAMERA_PERMISSION

Thrown when the user denies camera permissions or camera access is not available. Code: FadSDK.Errors.Signature.NOT_ACCEPT_CAMERA_PERMISSION When it occurs:
  • User explicitly denies camera permission
  • Camera permissions blocked by browser or system settings
  • Camera is already in use by another application
  • Camera hardware is not available or malfunctioning
  • Browser doesn’t support camera access
How to handle:
try {
  const signatureResponse = await FAD_SDK.startSignature(CONFIGURATION);

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

  // Process signature data
  const videoFace = signatureResponse.data.videoFace;
  const videoSignature = signatureResponse.data.videoSignature;
  const imageSignature = signatureResponse.data.imageSignature;

  console.log('Signature captured successfully');
} catch (ex) {
  if (ex.code === FadSDK.Errors.Signature.NOT_ACCEPT_CAMERA_PERMISSION) {
    alert('Camera permission is required. Please enable camera access in your browser settings.');
    // Provide instructions for enabling camera
  }
}
The Signature module requires camera access to record the signing process. Without camera permissions, the module cannot function.

Complete Error Handling Example

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

async function captureSignature() {
  const FAD_SDK = new FadSDK(TOKEN, {
    environment: FadSDK.getFadEnvironments().UATHA
  });

  try {
    const signatureResponse = await FAD_SDK.startSignature(CONFIGURATION);

    // Check if user closed the module
    if (signatureResponse.event === FadSDK.Constants.EventModule.MODULE_CLOSED) {
      console.log('User closed the signature module');
      return;
    }

    // Process successful signature capture
    console.log('Signature captured successfully');

    // Create URLs for video playback
    const faceVideoUrl = URL.createObjectURL(signatureResponse.data.videoFace);
    const signatureVideoUrl = URL.createObjectURL(signatureResponse.data.videoSignature);

    // Display results
    const faceVideo = document.getElementById('face-video') as HTMLVideoElement;
    const signatureVideo = document.getElementById('signature-video') as HTMLVideoElement;
    const signatureImage = document.getElementById('signature-img') as HTMLImageElement;

    faceVideo.src = faceVideoUrl;
    signatureVideo.src = signatureVideoUrl;
    signatureImage.src = signatureResponse.data.imageSignature;

    // Enable download links
    const downloadFaceVideo = document.getElementById('download-face-video') as HTMLAnchorElement;
    const downloadSignatureVideo = document.getElementById('download-signature-video') as HTMLAnchorElement;

    downloadFaceVideo.href = faceVideoUrl;
    downloadSignatureVideo.href = signatureVideoUrl;

    console.log('Videos and signature image ready for display');

  } catch (ex) {
    console.error('Signature error:', ex);

    if (ex.code === FadSDK.Errors.Signature.NOT_ACCEPT_CAMERA_PERMISSION) {
      alert('Camera access required. Please enable camera permissions and try again.');
      // Show instructions for enabling camera
      showCameraPermissionInstructions();
    } else {
      // Handle unexpected errors
      console.error('Unexpected error:', ex);
      alert(`An error occurred: ${ex.message}`);
    }
  } finally {
    FAD_SDK.end();
  }
}

function showCameraPermissionInstructions() {
  // Display browser-specific instructions
  const instructions = `
    To enable camera access:
    1. Click the camera icon in your browser's address bar
    2. Select 'Allow' for camera access
    3. Reload the page and try again
  `;
  console.log(instructions);
}

Response Data Structure

When successful, the Signature module returns:
interface SignatureResponse {
  data: {
    videoFace: Blob;           // Video recording of user's face during signing
    videoSignature: Blob;      // Video recording of signature being created
    imageSignature: string;    // Base64 encoded image of the final signature
  };
  event: string;               // Event type (PROCESS_COMPLETED, MODULE_CLOSED)
}

Camera Permission Flow

1

Request Permission

When startSignature() is called, the browser prompts for camera access.
2

User Decision

User either grants or denies camera permission.
3

Permission Granted

Module proceeds with signature capture if permission is granted.
4

Permission Denied

NOT_ACCEPT_CAMERA_PERMISSION error is thrown if denied.

Error Recovery Strategies

Check camera permissions before starting the module:
async function checkCameraAccess(): Promise<boolean> {
  try {
    const stream = await navigator.mediaDevices.getUserMedia({ 
      video: true, 
      audio: false 
    });
    
    // Stop all tracks immediately
    stream.getTracks().forEach(track => track.stop());
    
    return true;
  } catch (error) {
    console.error('Camera access check failed:', error);
    return false;
  }
}

async function initSignature() {
  const hasCamera = await checkCameraAccess();
  
  if (!hasCamera) {
    alert('Please enable camera access to continue');
    return;
  }
  
  // Proceed with signature capture
  await captureSignature();
}
Provide platform-specific guidance:
function getCameraInstructions(): string {
  const userAgent = navigator.userAgent.toLowerCase();
  
  if (userAgent.includes('chrome')) {
    return 'Click the camera icon in the address bar and select "Allow"';
  } else if (userAgent.includes('firefox')) {
    return 'Click the camera icon in the address bar and select "Allow"';
  } else if (userAgent.includes('safari')) {
    return 'Go to Safari > Settings > Camera and allow access';
  }
  
  return 'Please enable camera permissions in your browser settings';
}
Query current permission state:
async function getCameraPermissionState(): Promise<PermissionState> {
  try {
    const result = await navigator.permissions.query({ name: 'camera' as PermissionName });
    return result.state; // 'granted', 'denied', or 'prompt'
  } catch (error) {
    console.error('Permission query failed:', error);
    return 'prompt';
  }
}

async function handleSignature() {
  const state = await getCameraPermissionState();
  
  if (state === 'denied') {
    alert('Camera access is blocked. Please update your browser settings.');
    showCameraPermissionInstructions();
    return;
  }
  
  await captureSignature();
}

Best Practices

Early Permission Request

Request camera permissions early in the user flow, ideally with context about why it’s needed.

Clear Communication

Explain why camera access is required for signature capture before requesting permission.

Fallback Options

Consider providing alternative signature methods for users who cannot or will not grant camera access.

Visual Feedback

Show camera preview before starting signature capture to confirm camera is working properly.

Module Closure Events

The Signature module can be closed by the user at any time:
if (signatureResponse.event === FadSDK.Constants.EventModule.MODULE_CLOSED) {
  // User cancelled the signature process
  console.log('Signature cancelled by user');
  // Handle cancellation (e.g., return to previous step)
}
Module closure is not an error condition - it’s a normal user action. Handle it gracefully by allowing users to restart or exit the flow.

Build docs developers (and LLMs) love