Skip to content

Usage

  1. Import the component into your application

    import 'idlive-face-capture-web';
    
  2. Add the component's html tag to the place on the page where you want to display the video from the camera

    <idlive-face-capture></idlive-face-capture>
    

    NOTE: The component occupies 100% of the parent's element. Make sure it has a non-zero height and width

  3. Get the component to interact with

    const idliveFaceCapture = document.querySelector('idlive-face-capture');
    
  4. Call openCamera action to open the camera and show video

    idliveFaceCapture.openCamera();
    
  5. Subscribe to capture event to get an encrypted file for verification after the photo is captured

    idliveFaceCapture.addEventListener('capture', (event) => {
        const { photo, encryptedFile } = event.detail[0];
    
        sendEncryptedFileToServer(encryptedFile)
    });
    
  6. 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
            });
    }