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.
Thrown when the user denies camera permissions or camera access is not available.Code:FadSDK.Errors.Signature.NOT_ACCEPT_CAMERA_PERMISSIONWhen 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.
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)}
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();}
Browser-Specific Instructions
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';}
Permission State Detection
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();}
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.