How to implement Tap To Focus for camera in JavaScript?

I’m working on a web application that has a custom camera screen, for which I’m supposed to implement tap to focus using getUserMedia

Here’s the code:

 const permissionConstraints = {
       video: { 
       width: { exact: 1280 }, height: { exact: 1280 },
       aspectRatio: { ideal: 1 }, facingMode: 'environment' }
 };

 navigator.mediaDevices.getUserMedia(permissionConstraints).then((permissionsObj) => {
        console.log(permissionsObj);
 })