
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
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 547 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.