Usage¶
-
Import the component into your application
import 'idlive-document-capture-web';
-
Add the component's html tag to the place on the page where you want to display the video from the camera
<idlive-document-capture></idlive-document-capture>
NOTE: The component occupies 100% of the parent's element. Make sure it has a non-zero height and width
-
Get the component to interact with
const idliveDocCapture = document.querySelector('idlive-document-capture');
-
Call
openCamera
action to open the camera and show videoidliveDocCapture.openCamera();
-
Subscribe to
capture
event to get an encrypted file for verification after the photo is capturedidliveDocCapture.addEventListener('capture', (event) => { const { photo, encryptedFile } = event.detail[0]; sendEncryptedFileToServer(encryptedFile) });
-
Implement a method to interact with the IAD server
const sendEncryptedFileToServer = (encryptedFile) => { const serverUrl = 'https://IAD_SERVER_URL:PORT'; fetch(`${serverUrl}/check_capture_liveness`, { method: 'post', headers: { 'Content-Type': 'application/octet-stream' }, body: encryptedFile, }) .then(response => response.json()) .then(result => { // process result from the server }) .catch(e => { // error }); }