Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Fork of jsqr (github.com/cozmo/jsQR) that builds a es-6 target and adds color correction and performance improvements.
This project is a fork of cozmo/jsQR that provides an es6 build and contains several of the open pull requests of the original project which lately doesn't seem to be maintained much anymore.
A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.
Available on npm. Can be used in a Node.js program or with a module bundler such as Webpack or Browserify.
npm install jsqr-es6 --save
// ES6 import
import jsQR from "jsqr-es6";
// CommonJS require
const jsQR = require("jsqr-es6");
jsQR(...);
Alternatively for frontend use jsQR.js
can be included with a script tag
<script type="module">
import jsQR from 'path/to/jsQR.js';
jsQR(...);
</script>
jsQR is designed to be a completely standalone library for scanning QR codes. By design it does not include any platform specific code. This allows it to just as easily scan a frontend webcam stream, a user uploaded image, or be used as part of a backend Node.js process.
If you want to have webcam support out of the box, this qr scanner based on this library is recommended: https://github.com/nimiq/qr-scanner/
jsQR exports a method that takes in 3 arguments representing the image data you wish to decode. Additionally can take an options object to further configure scanning behavior.
const code = jsQR(imageData, width, height, options?);
if (code) {
console.log("Found QR code", code);
}
imageData
- An Uint8ClampedArray
of RGBA pixel values in the form [r0, g0, b0, a0, r1, g1, b1, a1, ...]
.
As such the length of this array should be 4 * width * height
.
This data is in the same form as the ImageData
interface, and it's also commonly returned by node modules for reading images.width
- The width of the image you wish to decode.height
- The height of the image you wish to decode.options
(optional) - Additional options.
inversionAttempts
- (attemptBoth
(default), dontInvert
, onlyInvert
, or invertFirst
) - Should jsQR attempt to invert the image to find QR codes with white modules on black backgrounds instead of the black modules on white background. This option defaults to attemptBoth
for backwards compatibility but causes a ~50% performance hit, and will probably be default to dontInvert
in future versions.canOverwriteImage
- (true
(default) or false
) - Specifies whether the image data can be overwritten for performance improvements or whether it should be kept untouched. If true
the image buffer will be used internally to reduce additional memory allocation.If a QR is able to be decoded the library will return an object with the following keys.
binaryData
- Uint8ClampedArray
- The raw bytes of the QR code.data
- The string version of the QR code data.chunks
- The QR chunks.version
- The QR version.location
- An object with keys describing key points of the QR code. Each key is a point of the form {x: number, y: number}
.
Has points for the following locations.
topRightCorner
/topLeftCorner
/bottomRightCorner
/bottomLeftCorner
;topRightFinderPattern
/topLeftFinderPattern
/bottomLeftFinderPattern
bottomRightAlignmentPattern
assuming one exists and can be located.Because the library is written in typescript you can also view the type definitions to understand the API.
jsQR is written using typescript.
You can view the development source in the src
directory.
Tests can be run with
npm test
Besides unit tests the test suite contains several hundred images that can be found in the /tests/end-to-end/ folder.
Not all the images can be read. In general changes should hope to increase the number of images that read. However due to the nature of computer vision some changes may cause images that pass to start to fail and visa versa. To update the expected outcomes run npm run-script generate-test-data
. These outcomes can be evaluated in the context of a PR to determine if a change improves or harms the overall ability of the library to read QR codes. A summary of which are passing
and failing can be found at /tests/end-to-end/report.json
After testing any changes, you can compile the production version by running
npm run-script build
Pull requests are welcome! Please create seperate branches for seperate features/patches.
FAQs
Fork of jsqr (github.com/cozmo/jsQR) that builds a es-6 target and adds color correction and performance improvements.
The npm package jsqr-es6 receives a total of 1,720 weekly downloads. As such, jsqr-es6 popularity was classified as popular.
We found that jsqr-es6 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.