Google Recaptcha Enterprise
react-google-recaptcha version: 2.1.0
Hello, is there any way to use this plugin with recaptcha enterprise? Currently I've configured the enterprise key, no error appears but in the recaptcha graphics I get hits marked "without captcha".
i have checked the code and seems like it doesn't fetch the enterprise js which is https://www.google.com/recaptcha/enterprise.js?render=explicit
good to have a prop to enable this handling
Hello, I am also interested to use this plugin with recaptcha enterprise. Is there any news about this ticket? Thanks!
💭 💡 This may be pretty straightforward and able to be backwards compatible.
We could utilize window.recaptchaOptions.
https://github.com/dozoisch/react-google-recaptcha/blob/d85b97f70ce95fad40f29c14e463118ff175ee31/src/recaptcha-wrapper.js#L7-L15
Possible approach:
function getOptions() {
return (typeof window !== "undefined" && window.recaptchaOptions) || {};
}
function getURL() {
const dynamicOptions = getOptions();
if (dynamicOptions.recaptchaUrl) {
return dynamicOptions.recaptchaUrl;
}
const hostname = dynamicOptions.useRecaptchaNet ? "recaptcha.net" : "www.google.com";
return `https://${hostname}/recaptcha/api.js?onload=${callbackName}&render=explicit`;
}
Check for a new property on recaptchaOptions called recaptchaUrl and if present use it as the js url. Then users could try to use the enterprise recaptcha.
And also, for the methods as exposed by the enterprise library like grecaptcha.enterprise.execute, grecaptcha.enterprise.reset and grecaptcha.enterprise.reset, we'll need some changes.
I created a pull request and tested it against my Enterprise account here.
Hey! I faced same problem with libraries not supporting Enterprise Recaptcha, ended up writing own solution: https://gist.github.com/sladg/1e22ffccc7f1b4ec65f08ec0d22bca95