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.
@mathewparet/instascan
Advanced tools
Real-time webcam-driven HTML5 QR code scanner.
Note: Chrome requires HTTPS when using the WebRTC API. Any pages using this library should be served over HTTPS.
npm install --save @mathewparet/instascan
import Instascan from '@mathewparet/instascan'
There is a known issue with Webpack. So if you are using webpack you need to add the below to your webpack.config.js file.
/**
* Fix for instascan as detailed in https://github.com/webpack-contrib/css-loader/issues/447#issuecomment-285600014
*/
node: {
fs: "empty"
}
If you are using Laravel Mix you can add it to the webpack.mix.js
file in your root:
/**
* Fix for instascan as detailed in https://github.com/webpack-contrib/css-loader/issues/447#issuecomment-285600014
*/
mix.webpackConfig({
node: {
fs: "empty"
}
});
<!DOCTYPE html>
<html>
<head>
<title>Instascan</title>
</head>
<body>
<video id="preview"></video>
<script type="text/javascript">
import Instascan from '@mathewparet/instascan'
var scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
scanner.addListener('scan', function (content, image) {
console.log(content);
});
Instascan.Camera.getCameras().then(function (cameras) {
if (cameras.length > 0) {
scanner.start(cameras[0]);
}
});
</script>
</body>
</html>
opts.continuous
: Whether to scan continuously for QR codes. If false
, use scanner.scan
to manually scan. Default true
.opts.video
: The HTML element to use for the camera's video preview. Must be a <video>
element. When the camera is active, this element will have the active
CSS class, otherwise, it will have the inactive
class. By default, an invisible element will be created to host the video.opts.mirror
: Whether to horizontally mirror the video preview. This is helpful when trying to scan a QR code with a user-facing camera. Default true
.opts.captureImage
: Whether to include the scanned image data as part of the scan result. See the scan
event for format details. Default false
.opts.backgroundScan
: Only applies to continuous mode. Whether to actively scan when the tab is not active. When false
, this reduces CPU usage when the tab is not active. Default false
.opts.refractoryPeriod
: Only applies to continuous mode. The period, in milliseconds, before the same QR code will be recognized in succession. Default 5000
.opts.scanPeriod
: Only applies to continuous mode. The period, in rendered frames, between scans. A lower scan period increases CPU usage but makes scan response faster. Default 1
(i.e. analyze every frame).camera
and start scanning using it as the source. Returns promise.scanner.scan
or receive scan
events.camera
: Instance of Instascan.Camera
from Instascan.Camera.getCameras
.function ()
, called when camera is active and scanning has started.function ()
, called when camera and scanning have stopped.scan
event.result
is null
.result.content
: Scanned content decoded from the QR code.result.image
: Undefined if scanner.captureImage
is false
, otherwise, see the scan
event for format.scanner.continuous
).callback
: function (content, image)
content
: Scanned content decoded from the QR code.image
: null
if scanner.captureImage
is false
, otherwise, a base64-encoded WebP-compressed data URI of the camera frame used to decode the QR code.scanner.start
or the tab gaining focus.opts.video
element was specified, it will have the active
CSS class.callback
: function ()
scanner.stop
or the tab losing focus.opts.video
element was specified, it will have the inactive
CSS class.callback
: function ()
function (cameras)
, called when cameras are available.cameras
: Array of Instascan.Camera
instances available for use.null
if the user has not yet allowed camera access, e.g. on first launch of the app.Instascan works with any browser that supports the getUserMedia API, which currently includes Chome, Firefox, Opera, and Edge. IE and Safari are not supported.
Many factors affect how quickly and reliably Instascan can detect QR codes.
If you control creation of the QR code, consider the following:
When scanning, consider the following:
Powered by the Emscripten JavaScript build of the C++ port of the ZXing Java library.
Copyright © 2016 Chris Schmich
MIT License. See LICENSE for details.
FAQs
Webcam-driven QR code scanner.
We found that @mathewparet/instascan 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.