Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
vue-qrcode-reader
Advanced tools
A Vue.js component, accessing the device camera and allowing users to read QR-Codes, within the browser
A Vue.js component, accessing the device camera and allowing users to read QR-Codes, within the browser. It utilizes WebRTC, which only works in secure context (i.e. HTTPS).
As soon as it's mounted, this component will ask the user for permisson to access his device camera (back camera if available). Even if the user granted permission earlier, some time might pass between mounting and the moment the camera stream is loaded. Until then you might want to show a preloader. Just listen to the stream-loaded
event.
Once the stream is loaded, it is displayed and continuously scanned for QR-Codes. Results are indicated by the decode
event.
<qrcode-reader @decode="onDecode"></qrcode-reader>
methods: {
onDecode (event) {
event.content // string of read data or null
event.location // set of QR-Code module positions or null
}
}
If the user denies camera access, the permission-deny
event is fired. You can't really ask for permissons twice so you should tell the user why you need it.
Distributed content will overlay the camera stream, wrapped in a position: absolute
container. You can use this for example to highlight the detected position of QR-Code modules.
<qrcode-reader>
<b>stuff here overlays the camera stream</b>
</qrcode-reader>
With the paused
prop you can prevent further decode
propagation. Useful for example if you're only interested in the first result.
<qrcode-reader @decode="onDecode" :paused="paused"></qrcode-reader>
data () {
return {
paused: false
}
},
methods: {
onDecode (event) {
this.paused = true
// ...
}
}
There is also a no-support
event which is fired when the users browser lacks support for Canvas, WebRTC or if the page is not served over HTTPS. Since iOS 11 release, all major browsers support WebRTC. However, you probably want to install a shim like webrtc-adapter anyway.
yarn add vue-qrcode-reader
# or
npm install --save vue-qrcode-reader
Register component globally:
import Vue from 'vue'
import VueQrcodeReader from 'vue-qrcode-reader'
Vue.use(VueQrcodeReader)
Register locally in other components scope:
import Vue from 'vue'
import { QrcodeReader } from 'vue-qrcode-reader'
Vue.component('my-component', {
// ...
components: {
// ...
'qrcode-reader': QrcodeReader
},
// ...
)
⚠️ A css file is included when importing the package. You may have to setup your bundler to embed the css in your page.
Register component globally:
import 'vue-qrcode-reader/dist/vue-qrcode-reader.css'
import VueQrcodeReader from 'vue-qrcode-reader/dist/vue-qrcode-reader.common'
Vue.use(VueQrcodeReader)
Register locally in other components scope:
import 'vue-qrcode-reader/dist/vue-qrcode-reader.css'
import { QrcodeReader } from 'vue-qrcode-reader/dist/vue-qrcode-reader.common'
Vue.component('my-component', {
// ...
components: {
// ...
'qrcode-reader': QrcodeReader
},
// ...
)
⚠️ You may have to setup your bundler to embed the css file in your page.
<link rel="stylesheet" href="vue-qrcode-reader/dist/vue-qrcode-reader.css"/>
<script src="vue.js"></script>
<script src="vue-qrcode-reader/dist/vue-qrcode-reader.browser.js"></script>
The plugin should be auto-installed. If not, you can install it manually with the instructions below.
Register component globally:
Vue.use(VueQrcodeReader)
Register locally in other components scope:
Vue.component('my-component', {
// ...
components: {
// ...
'qrcode-reader': VueQrcodeReader.QrcodeReader
},
// ...
)
Register component globally:
import Vue from 'vue'
import VueQrcodeReader from 'vue-qrcode-reader/src'
Vue.use(VueQrcodeReader)
Register locally in other components scope:
import Vue from 'vue'
import { QrcodeReader } from 'vue-qrcode-reader/src'
Vue.component('my-component', {
// ...
components: {
// ...
'qrcode-reader': QrcodeReader
},
// ...
)
⚠️ You need to configure your bundler to compile .vue
files. More info in the official documentation.
FAQs
A set of Vue.js components for detecting and decoding QR codes.
The npm package vue-qrcode-reader receives a total of 15,004 weekly downloads. As such, vue-qrcode-reader popularity was classified as popular.
We found that vue-qrcode-reader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.