vue-recaptcha-v3
vue-recaptcha-v3 copied to clipboard
Allow late configuration: siteKey
I don't have the siteKey ready with DOMContentLoaded, but rather later. I do not want to delay initialization of the whole app for this plugin.
Wondering why this isn't possible here. Am I missing something? Currently testing this implementation (no real Vue integration though..):
// Not using vue-recaptcha-v3, because it wants the siteKey for initial siteload
import { load as loadReCaptcha, ReCaptchaInstance } from "recaptcha-v3";
import { IReCaptchaLoaderOptions } from "recaptcha-v3/dist/ReCaptchaLoader";
// For a more verbose implementation check:
// https://github.com/AurityLab/vue-recaptcha-v3/blob/master/src/ReCaptchaVuePlugin.ts
export async function reCaptcha(action: string, siteKey: string, loaderOptions: IReCaptchaLoaderOptions) {
const wrapper = await loadReCaptcha(siteKey, loaderOptions);
// TODO cache or preload wrapper?
const token = await wrapper.execute(action);
console.log("reCaptcha token", token);
return token;
}