Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
google-recaptcha-v2
Advanced tools
A simple library of captcha based on Google reCAPTCHA v2.
<script src="https://unpkg.com/google-recaptcha-v2/index.js"></script>
npm install google-recaptcha-v2 --save-dev
The easiest method for using the invisible reCAPTCHA widget on your page. The necessary attributes are a class name 'g-recaptcha', your site key in the data-sitekey attribute, and the name of a JavaScript callback to handle completion of the captcha in the data-callback attribute.
<div id="recaptcha" class="g-recaptcha" style="display:none"></div>
you can get data-sitekey from Google reCAPTCHA Admin Console
This is data-callback attribute.
function getCaptchaToken(token) {
// get token from Google reCAPTCHA Server
if (token) {
// Next step code: AJAX request the relevant verification interface of the server, check with the API of the Google man-machine verification server, and confirm whether the verification is passed or not.
}
}
<script>
// Initialize JSSDK of Google reCAPTCHA v2
GoogleReCaptcha.init({
siteKey: '_your_site_key_',
callback: getCaptchaToken
})
</script>
var GoogleReCaptcha = require('google-recaptcha-v2');
GoogleReCaptcha.init({
siteKey: '_your_site_key_',
callback: getCaptchaToken
})
you can validate by click button. Like this, just register click function.
var element = document.getElementById('validate');
element.onclick = GoogleReCaptcha.validate;
GoogleReCaptcha.init(options)
function errorCallback(res) {
var code = res.code;// error code
var message = res.message;// error message
// console.log(message)
switch (code) {
// The JSSDK of Google reCAPTCHA load unsuccessfully
case -1:
// you can reload the JSSDK of Google reCAPTCHA or check again
break;
// Google reCAPTCHA encounters an error(usually network connectivity)
case 10001:
break;
default:
// set default operation
}
}
GoogleReCaptcha.validate(event)
google-recaptcha-v2 is MIT licensed.
1.0.4 (2022.01.24)
README.md
.FAQs
A simple library of captcha based on Google reCAPTCHA v2.
The npm package google-recaptcha-v2 receives a total of 238 weekly downloads. As such, google-recaptcha-v2 popularity was classified as not popular.
We found that google-recaptcha-v2 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's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.