
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
barcode-detector-zbar
Advanced tools
This is a very simple polyfill using zbar.wasm under the hood written in plain ES6.
You can install the polyfill with BarcodeDetectorPolyfill.setupPolyfill()
.
<script type="module">
import BarcodeDetectorPolyfill from "./BarcodeDetectorPolyfill.min.js";
console.log("Native api support", BarcodeDetectorPolyfill.checkBarcodeDetectorSupport());
BarcodeDetectorPolyfill.setupPolyfill();
</script>
Simply use like the regular api (check https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API).
This polyfill uses zbar.wasm and therefore needs to load a ~200kb bin file in order to work. The polyfill itself is 9.5kb.
Webcam is only available in a secure context. Here is some sample code to help you (using Swal to show an error message).
if (!BarcodeDetectorPolyfill.checkWebcamSupport()) {
if (!BarcodeDetectorPolyfill.checkSecureContext()) {
Swal.fire("You need a secure context!");
} else {
Swal.fire("No webcam connected!");
}
}
Running npm run start
and see demo.html or https://codepen.io/lekoalabe/pen/abyrqaL (currently not working due to CORS issue loading the wasm file)
Other
Api ref
Scanner app
Zbar
Zxing
Other libs
Other polyfills
FAQs
Barcode detector polyfill using zbar.wasm
We found that barcode-detector-zbar 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.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.