Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
easy-js-camera
Advanced tools
A package which helps with adding camera support to a web application
This package helps you to add camera support to your web application easily and support front and rear camera out of the box.
npm install easy-js-camera
Add your video and canvas as follow,
<video autoplay playsinline></video>
<canvas></canvas>
Import the Camera class as follow,
import Camera from 'easy-js-camera';
To be able to access to all Video Inputs you first need to get the permission from the user.
Note: On some devices it is not needed to first get the permission but it is better to do that first since on some devices if the permission is not granted it doesn't return all the devices.
var video = document.getElementsByTagName('video')[0];
var canvas = document.getElementsByTagName('canvas')[0];
Camera
.tryInvokePermission(video, canvas)
.then(camera => {
camera.start()
})
.catch(error => {
// Mostly happens if the user blocks the camera or the media devices are not supported
});
Note: In order to make sure that the browser supports MediaDevices you can do as follow.
import Camera from 'easy-js-camera';
Camera.isCameraSupported();
facingMode
key of the video constraints is set. With this method you can expand the constraints and add your own costraints but please NOTICE that the facingMode
is being used in switch method.blob
.front
and rear
. This method returns a promise. It is better that you disable the switch camera button while it is doing its job because on some phones with motorized
selfie camera if the user press the button multiple times the camera will hang and will just stickout and no longer works unless he/she restarts the phone. Please Note that this method accept a boolean which is called tryAgain
and it basically tries to access the rear camera. Sometime the rear camera is not accessible and on catch you can do something like belowfunction switchCamera(tryAgain = false) {
this.camera.switch(tryAgain)
.catch(() => {
if(tryAgain) return; // This line prevents loops. Because the tryAgain may also fail
this.camera.switch(true);
});
}
FAQs
A package which helps with adding camera support to a web application
The npm package easy-js-camera receives a total of 167 weekly downloads. As such, easy-js-camera popularity was classified as not popular.
We found that easy-js-camera demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.