react-google-recaptcha-hook
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var r=require("react");const s=()=>{var c;typeof window.grecaptcha=="undefined"&&((c=window.___grecaptcha_cfg)!=null||(window.___grecaptcha_cfg={fns:[]}),window.grecaptcha={ready:e=>{window.___grecaptcha_cfg.fns.push(e)}})},d=()=>new Promise(c=>{s(),window.grecaptcha.ready(()=>c(window.grecaptcha))}),l=(c,e)=>{const t=e!=null&&e.language?`&hl=${e.language}`:"",n=e!=null&&e.enterprise?"enterprise.js":"api.js";return`https://www.${e!=null&&e.recaptchaNet?"recaptcha.net":"google.com"}/recaptcha/${n}?render=${c}${t}`},w=(c,e)=>{const t=r.useCallback(()=>{if(document.getElementById(c))return;const a=document.createElement("script");a.async=!0,a.type="text/javascript",a.src=l(c,e),a.id=c,document.getElementsByTagName("head")[0].appendChild(a)},[]),n=r.useCallback(async a=>{var h;const g=await d();return(h=g.execute)==null?void 0:h.call(g,c,{action:a})},[]),u=r.useRef(!1);return r.useEffect(()=>{u.current||(u.current=!0,t())},[t]),{executeGoogleReCaptcha:n,load:t}};exports.generateGrecaptchaSrc=l;exports.getGrecaptcha=d;exports.initGrecaptcha=s;exports.useGoogleReCaptcha=w; | ||
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var r=require("react");const s=()=>{var c;typeof window.grecaptcha=="undefined"&&((c=window.___grecaptcha_cfg)!=null||(window.___grecaptcha_cfg={fns:[]}),window.grecaptcha={ready:e=>{window.___grecaptcha_cfg.fns.push(e)}})},d=()=>new Promise(c=>{s(),window.grecaptcha.ready(()=>c(window.grecaptcha.enterprise||window.grecaptcha))}),l=(c,e)=>{const t=e!=null&&e.language?`&hl=${e.language}`:"",n=e!=null&&e.enterprise?"enterprise.js":"api.js";return`https://www.${e!=null&&e.recaptchaNet?"recaptcha.net":"google.com"}/recaptcha/${n}?render=${c}${t}`},w=(c,e)=>{const t=r.useCallback(()=>{if(document.getElementById(c))return;const a=document.createElement("script");a.async=!0,a.type="text/javascript",a.src=l(c,e),a.id=c,document.getElementsByTagName("head")[0].appendChild(a)},[]),n=r.useCallback(async a=>{var h;const g=await d();return(h=g.execute)==null?void 0:h.call(g,c,{action:a})},[]),u=r.useRef(!1);return r.useEffect(()=>{u.current||(u.current=!0,t())},[t]),{executeGoogleReCaptcha:n,load:t}};exports.generateGrecaptchaSrc=l;exports.getGrecaptcha=d;exports.initGrecaptcha=s;exports.useGoogleReCaptcha=w; |
@@ -17,3 +17,3 @@ import { useCallback, useRef, useEffect } from "react"; | ||
initGrecaptcha(); | ||
window.grecaptcha.ready(() => resolve(window.grecaptcha)); | ||
window.grecaptcha.ready(() => resolve(window.grecaptcha.enterprise || window.grecaptcha)); | ||
}); | ||
@@ -20,0 +20,0 @@ const generateGrecaptchaSrc = (siteKey, options) => { |
@@ -20,3 +20,3 @@ { | ||
"license": "MIT", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"files": [ | ||
@@ -39,2 +39,4 @@ "dist", | ||
"coverage": "vitest run --coverage", | ||
"lint:prettier": "prettier . --check --ignore-path .gitignore", | ||
"fix:prettier": "prettier . --write --ignore-path .gitignore", | ||
"prepare": "husky install" | ||
@@ -41,0 +43,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
9223