Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
vue-programmatic-invisible-google-recaptcha
Advanced tools
Changelog
2.0.0 (2018-11-16)
Readme
A simple invisible Google reCAPTCHA component focused solely on programmatic invocation.
# npm
npm i vue-programmatic-invisible-google-recaptcha
# yarn
yarn add vue-programmatic-invisible-google-recaptcha
Or you can include it through the browser at the bottom of your page:
<script src="https://unpkg.com/vue-programmatic-invisible-google-recaptcha"></script>
This is a simple component that helps deal with an invisible Google reCAPTCHA that you intend to invoke programmatically. There are a few plugins that help with Google's reCAPTCHA, but this one is focused on the invisble version with a programmatic invocation only. Due to its nature, reCAPTCHA can be a little complex - so that is what is driving the narrow scope here. Library supports easy multiple reCAPTCHAs on the same page.
Here's a breakdown of the steps you go through when using this library:
script
tag.this.$refs.invisibleRecaptcha1.execute()
method (replacing invisibleRecaptcha1
with the ref
name you set).recaptchaToken
in the registered recaptcha-callback
event. Make sure to register for that.import VueProgrammaticInvisibleGoogleRecaptcha from 'vue-programmatic-invisible-google-recaptcha'
Vue.component('vue-programmatic-invisible-google-recaptcha', VueProgrammaticInvisibleGoogleRecaptcha)
<!-- Put this in your base HTML file - I use Vue CLI 3 so I put it at the bottom of the ./public/index.html file. -->
<script src="https://www.google.com/recaptcha/api.js?render=explicit" async defer></script>
<!-- This is in the component you want to have the reCAPTCHA -->
<vue-programmatic-invisible-google-recaptcha
ref="invisibleRecaptcha1"
:sitekey="'<YOUR_SITEKEY_HERE>'"
:elementId="'invisibleRecaptcha1'"
:badgePosition="'left'"
:showBadgeMobile="false"
:showBadgeDesktop="true"
@recaptcha-callback="recaptchaCallback"
></vue-programmatic-invisible-google-recaptcha>
<!-- Where you want to invoke the reCAPTCHA -->
submitButtonClicked() {
// Do whatever you want here (probably some validation). After
// that's done (or passed your expectations) you can then invoke the reCAPTCHA.
this.$refs.invisibleRecaptcha1.execute()
},
<!-- The reCAPTCHA's registered callback. This is where you'll get your token. -->
recaptchaCallback (recaptchaToken) {
// Use the `recaptchaToken` to pass to your backend to verify the token
axios.post('/enter', {recaptchaToken: recaptchaToken}).then((result) => {
console.log(result)
})
},
Note - I find it to be a good idea to allow the user to reset their reCAPTCHA on their own if they're experiencing an issue. This component exposes a function for this. To do this, give them a button with the following code in the click function: this.$refs.invisibleRecaptcha1.reset()
. This will reset the reCAPTCHA and hopefully get them passed the issue they're having.
prop | type | description | required | default |
---|---|---|---|---|
ref | String | Unique String gives you control over the component | Yes | |
sitekey | String | Public key given to you by Google. | Yes | |
elementId | String | Unique String for the id of the element. Allows for multiple seperate reCAPTCHAs | Yes | |
badgePosition | String | Pass 'left' to show badge on left side of screen. | No | 'right' |
showBadgeMobile | Boolean | true to show badge on mobile. false to hide badge on mobile. | No | true |
showBadgeDesktop | Boolean | true to show badge on desktop. false to hide badge on desktop. | No | true |
Note - call these methods through the ref
you set up with your component. Example: this.$refs.invisibleRecaptcha1.execute()
.
method | parameters | description |
---|---|---|
execute | none | Used to gather the token. If Google decides that the user needs to complete a test they'll do it here. |
reset | none | Used to reset the reCAPTCHA instance. |
event | parameter value | description |
---|---|---|
recaptcha-callback | String | This even gets emitted when the token has been aquired. You can then use this token to verify the user on your backend. |
# install dependencies
npm install
# serve with hot reload
npm run watch
# build demo page
npm run build:example
# build
npm run build
# publish to npm
npm version patch
npm publish
Go ahead and fork the project! Submit an issue if needed. Have fun!
Thanks to Google for their reCAPTCHA library.
Packaged with a mixture of vue-lib-template and vue-sfc-rollup.
FAQs
A simple invisible Google reCAPTCHA component focused solely on programmatic invocation.
The npm package vue-programmatic-invisible-google-recaptcha receives a total of 367 weekly downloads. As such, vue-programmatic-invisible-google-recaptcha popularity was classified as not popular.
We found that vue-programmatic-invisible-google-recaptcha 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.