Skip to main content

Videotaping Error Codes

The Videotaping module captures video recordings of users reading agreements while displaying identification documents. 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.Videotaping.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 (missing MediaDevices API)
How to handle:
try {
  const LEGEND = 'I, [Name], with date of birth [DOB], with ID number [ID_NUMBER], declare that the information provided is true and accurate.';
  
  const IDENTIFICATIONS = [
    { 
      name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_FRONT, 
      title: 'Front of ID' 
    },
    { 
      name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_BACK, 
      title: 'Back of ID' 
    }
  ];
  
  const videotapingResponse = await FAD_SDK.startVideotaping(
    LEGEND,
    IDENTIFICATIONS,
    CONFIGURATION
  );

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

  // Process videotaping data
  const videoUrl = URL.createObjectURL(videotapingResponse.data.video);
  const startSecond = videotapingResponse.data.startSecond;
  
  console.log('Videotaping completed');
  console.log('Agreement starts at second:', startSecond);
  
} catch (ex) {
  if (ex.code === FadSDK.Errors.Videotaping.NOT_ACCEPT_CAMERA_PERMISSION) {
    alert('Camera permission is required to record your statement. Please enable camera access.');
    // Provide instructions for enabling camera
  }
}
The Videotaping module requires camera access to record the user reading the agreement while showing their identification documents. Without camera permissions, the module cannot function.

Complete Error Handling Example

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

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

  try {
    // Define the agreement text the user will read
    const LEGEND = `
      I, [Full Name], with date of birth [DOB], 
      with ID number [ID_NUMBER] declare that I am [Marital Status], 
      with monthly income of $[Amount], 
      I [do/do not] own a home, 
      I [do/do not] currently have credit cards, 
      and I acknowledge that the information I have provided is true and accurate.
    `;

    // Define which ID sides to show during recording
    const IDENTIFICATIONS = [
      { 
        name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_FRONT, 
        title: 'Front of ID' 
      },
      { 
        name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_BACK, 
        title: 'Back of ID' 
      }
    ];

    const videotapingResponse = await FAD_SDK.startVideotaping(
      LEGEND,
      IDENTIFICATIONS,
      CONFIGURATION
    );

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

    // Process successful videotaping capture
    console.log('Videotaping completed successfully');

    // Create URL for video playback
    const videoUrl = URL.createObjectURL(videotapingResponse.data.video);
    const startSecond = videotapingResponse.data.startSecond;

    // Display video
    const videoElement = document.getElementById('video-id') as HTMLVideoElement;
    const downloadLink = document.getElementById('download-link') as HTMLAnchorElement;
    const startSecondDisplay = document.getElementById('startSecond');

    videoElement.src = videoUrl;
    downloadLink.href = videoUrl;
    downloadLink.download = 'videotaping-agreement.webm';
    startSecondDisplay.innerHTML = `Agreement starts at: ${startSecond}s`;

    console.log('Videotaping ready for playback');
    console.log('User statement begins at second:', startSecond);

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

    if (ex.code === FadSDK.Errors.Videotaping.NOT_ACCEPT_CAMERA_PERMISSION) {
      alert('Camera access is required to record your statement with ID verification. 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() {
  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 Videotaping module returns:
interface VideotapingResponse {
  data: {
    video: Blob;             // Complete video recording
    startSecond: number;     // Timestamp (in seconds) when user starts reading the agreement
    duration?: number;       // Total duration of the recording in seconds
    timestamp?: string;      // ISO timestamp of when recording was completed
  };
  event: string;             // Event type (PROCESS_COMPLETED, MODULE_CLOSED)
}
The startSecond field indicates when the user begins reading the agreement text. This is useful for verification purposes and for skipping to the relevant part of the video.

Identification Configuration

The module supports various identification document types:
// Available ID types
const IdsAllowed = {
  ID_MEX_FRONT: 'id_mex_front',
  ID_MEX_BACK: 'id_mex_back',
  PASSPORT: 'passport',
  DRIVER_LICENSE_FRONT: 'driver_license_front',
  DRIVER_LICENSE_BACK: 'driver_license_back',
  // Additional types as supported by your configuration
};

// Example: Single-sided ID
const IDENTIFICATIONS = [
  { 
    name: FadSDK.Constants.Videotaping.IdsAllowed.PASSPORT, 
    title: 'Passport' 
  }
];

// Example: Double-sided ID
const IDENTIFICATIONS = [
  { 
    name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_FRONT, 
    title: 'Front of ID' 
  },
  { 
    name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_BACK, 
    title: 'Back of ID' 
  }
];

Camera Permission Flow

1

Request Permission

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

User Decision

User either grants or denies camera permission.
3

Permission Granted

Module guides user through showing ID documents and reading the agreement.
4

ID Display

User shows each required ID document side to the camera as prompted.
5

Agreement Reading

User reads the agreement text aloud while recording continues.
6

Permission Denied

NOT_ACCEPT_CAMERA_PERMISSION error is thrown if camera access is 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 initVideotaping() {
  const hasCamera = await checkCameraAccess();
  
  if (!hasCamera) {
    alert('Please enable camera access to record your statement with ID verification');
    showCameraPermissionInstructions();
    return;
  }
  
  // Proceed with videotaping
  await recordVideotaping();
}
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 permissions icon and enable camera access';
  } else if (userAgent.includes('safari')) {
    return 'Go to Safari > Settings > Camera and allow access for this website';
  } else if (userAgent.includes('edge')) {
    return 'Click the lock icon in the address bar and enable camera';
  }
  
  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 not supported:', error);
    return 'prompt';
  }
}

async function handleVideotaping() {
  const state = await getCameraPermissionState();
  
  if (state === 'denied') {
    alert('Camera access is blocked. Please update your browser settings.');
    showCameraPermissionInstructions();
    return;
  } else if (state === 'prompt') {
    // Show explanation before requesting permission
    showCameraPermissionRationale();
  }
  
  await recordVideotaping();
}

function showCameraPermissionRationale() {
  alert('We need camera access to record you reading the agreement while showing your ID. This ensures the authenticity and legal validity of your consent.');
}

Best Practices

Explain Process

Before starting, clearly explain the entire process: showing ID documents, reading the agreement, and recording duration.

Preview Content

Show users the legend text and required ID documents before starting the recording so they can prepare.

Practice Mode

Consider offering a practice run where users can rehearse the process without recording.

Clear Instructions

Provide step-by-step guidance on:
  • How to hold and position ID documents
  • Lighting requirements for clear visibility
  • Speaking clearly and at appropriate pace
  • Camera positioning and distance

Retry Capability

Always allow users to retry if they’re not satisfied with their recording or if technical issues occur.

Privacy Notice

Inform users about how their video and ID information will be used, stored, and protected.

Module Closure Events

The Videotaping module can be closed by the user at any time:
if (videotapingResponse.event === FadSDK.Constants.EventModule.MODULE_CLOSED) {
  // User cancelled the videotaping process
  console.log('Videotaping cancelled by user');
  // Handle cancellation gracefully - allow restart or exit
}
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.

Video Processing Considerations

Videotaping recordings can be large files. Consider:
  • Implementing video compression before upload
  • Showing upload progress indicators
  • Setting appropriate timeout values for slow connections
  • Providing video quality options based on device capabilities
  • Storing videos securely with appropriate encryption
  • Implementing retention policies per your legal requirements

Data Protection

Ensure compliance with data protection regulations (GDPR, CCPA, etc.) when recording and storing videos with personal information and ID documents.

Consent Recording

The startSecond timestamp helps verify that the user read the complete agreement, which is important for legal validity.

Retention Policies

Implement appropriate retention and deletion policies for video recordings containing sensitive information.

Build docs developers (and LLMs) love