vue-recaptcha-v3
Advanced tools
Comparing version 1.7.2 to 1.8.0
@@ -44,10 +44,12 @@ "use strict"; | ||
var recaptchaLoaded = false; | ||
var recaptchaError = null; | ||
var loadedWaiters = []; | ||
Vue.prototype.$recaptchaLoaded = function () { return new Promise(function (resolve, reject) { | ||
if (recaptchaError !== null) { | ||
return reject(recaptchaError); | ||
} | ||
if (recaptchaLoaded === true) { | ||
resolve(true); | ||
return resolve(true); | ||
} | ||
else { | ||
loadedWaiters.push(resolve); | ||
} | ||
loadedWaiters.push({ resolve: resolve, reject: reject }); | ||
}); }; | ||
@@ -62,4 +64,7 @@ plugin.initializeReCaptcha(options).then(function (wrapper) { | ||
Vue.prototype.$recaptchaInstance = wrapper; | ||
loadedWaiters.forEach(function (v) { return v(true); }); | ||
}).catch(console.error); | ||
loadedWaiters.forEach(function (v) { return v.resolve(true); }); | ||
}).catch(function (error) { | ||
recaptchaError = error; | ||
loadedWaiters.forEach(function (v) { return v.reject(error); }); | ||
}); | ||
} | ||
@@ -66,0 +71,0 @@ exports.VueReCaptcha = VueReCaptcha; |
{ | ||
"name": "vue-recaptcha-v3", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "captcha", |
@@ -32,6 +32,10 @@ # Vue reCAPTCHA-v3 | ||
methods: { | ||
recaptcha() { | ||
this.$recaptcha('login').then((token) => { | ||
console.log(token) // Will print the token | ||
}) | ||
async recaptcha() { | ||
// (optional) Wait until recaptcha has been loaded. | ||
await this.$recaptchaLoaded() | ||
// Execute reCAPTCHA with action "login". | ||
const token = await this.$recaptcha('login') | ||
// Do stuff with the received token. | ||
} | ||
@@ -51,3 +55,3 @@ }, | ||
|siteKey|The site key for your domain from Google.|*string*|*none* | ||
|loaderOptions|Optional options for the [recaptcha-v3](https://github.com/AurityLab/recaptcha-v3) loader. The available options are described [here](https://github.com/AurityLab/recaptcha-v3/#usage-1).|*object*|`null` | ||
|loaderOptions|Optional options for the [recaptcha-v3](https://github.com/AurityLab/recaptcha-v3) loader. The available options are described [here](https://github.com/AurityLab/recaptcha-v3/#load-options-usage).|*object*|`null` | ||
@@ -67,1 +71,16 @@ ### Usage | ||
``` | ||
## Advanced usage | ||
Some topics which are not commonly used, but required in some cases. | ||
### Access [reCAPTCHA-v3](https://github.com/AurityLab/recaptcha-v3/#load-options-usage) instance | ||
In some cases it's necessary to interact with the reCAPTCHA-v3 instance, which provides more control over reCAPTCHA. | ||
```javascript | ||
const recaptcha = this.$recaptchaInstance | ||
// Hide reCAPTCHA badge: | ||
recaptcha.hideBadge() | ||
// Show reCAPTCHA badge: | ||
recaptcha.showBadge() | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20058
99
84