Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-google-recaptcha-ultimate

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-recaptcha-ultimate - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

LICENSE

2

dist/cjs/index.js

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
"use strict";var e=require("react");const t=e.createContext({googleReCaptcha:{},siteKey:"",language:"",isLoading:!0,executeV3:()=>{throw Error("GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")},executeV2Invisible:()=>{throw Error("GoogleReCaptchaContext has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")},reset:()=>{throw Error("GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")},getResponse:()=>{throw Error("GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")},render:()=>{throw Error("GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")}}),{Provider:o,Consumer:a}=t,r=()=>e.useContext(t),n=({host:e="google.com",isEnterprise:t,render:o,hl:a,badge:r})=>`https://www.${e}/recaptcha/${t?"enterprise.js":"api.js"}?${new URLSearchParams({...a&&{hl:a},...r&&{badge:r},render:o})}`,c=()=>".grecaptcha-badge{display: none !important;}",i=e=>{const t=document.getElementById(e);if(t)for(;t.lastChild;)t.lastChild.remove()},s="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;exports.GoogleReCaptchaCheckbox=({id:t="google-recaptcha-checkbox-container",onChange:o,action:a,language:n,...c})=>{const{siteKey:d,render:l,language:p}=r(),h=e.useRef(null);return s((()=>{if(!l)return;const e=document.createElement("div"),r={sitekey:d,callback:o,...(n??p)&&{hl:n??p},...c};return l(e,a?{...r,action:a}:r),h.current&&h.current.appendChild(e),()=>{i(t)}}),[l,n,o,t,d,c.size,a,c.theme]),e.createElement("div",{id:t,ref:h,...c})},exports.GoogleReCaptchaProvider=({type:t,siteKey:a,language:r,scriptProps:c,isEnterprise:s=!1,host:d,children:l,explicit:p,onLoad:h,onError:g})=>{const[u,m]=e.useState(!0),[b,y]=e.useState();e.useEffect((()=>{if(!a)throw new Error("Google ReCaptcha site key not provided");const e=c?.id??"google-recaptcha-script",o=(e=>!!document.querySelector(`#${e}`)||!!document.querySelector('script[src*="/recaptcha/"]:not([src*="gstatic"])'))(e),l=()=>{const e=s?window.grecaptcha?.enterprise:window.grecaptcha;if(e){if(p||e.ready((async()=>{y(e),h&&await h(e),m(!0)})),p){const r={size:"v3"===t||"v2-invisible"===t?"invisible":"normal",...("v3"===t||"v2-invisible"===t)&&{badge:"bottomright"},sitekey:a,...p};if(!o){("v3"===t||"v2-invisible"===t)&&"hidden"===p?.badge&&(()=>{const e=document.createElement("style");e.innerHTML=".grecaptcha-badge{display: none !important;}",document.body.appendChild(e)})()}e.ready((async()=>{p.container&&e.render(p.container,r,!!p.inherit),y(e),h&&await h(e),m(!0)}))}}else g&&g()};return window.onGoogleReCaptchaLoad=l,o?l():(({onload:e,appendTo:t="head",isEnterprise:o=!1,host:a,render:r,badge:c,hl:i,...s})=>{const d=n({host:a,isEnterprise:o,render:r,hl:i,badge:c}),l=document.createElement("script");Object.entries(s).forEach((([e,t])=>{l.setAttribute(e,t?.toString()??"")})),l.src=d,l.onload=e,document[t].appendChild(l)})({isEnterprise:s,host:d,...("v3"===t||"v2-invisible"===t)&&p?.badge&&{badge:"hidden"===p?.badge?"bottomright":p?.badge},...r&&{hl:r},render:("v3"===t||"v2-invisible"===t)&&p?.container||"v2-checkbox"===t?"explicit":a,...c,onload:l,id:e}),()=>{b?.reset(),o||(e=>{window.___grecaptcha_cfg=void 0;const t=document.querySelector(`#${e}`);t&&t.remove();const o=document.querySelector('script[src^="https://www.gstatic.com/recaptcha/releases"]');o&&o.remove()})(e),"v3"!==t&&"v2-invisible"!==t||p?.container||!p?.badge?(()=>{const e=document.querySelector(".grecaptcha-badge");e&&e.parentNode&&document.body.removeChild(e.parentNode)})():i("google-recaptcha-container")}}),[s,r,d]);const C=e.useCallback((e=>{if(!b?.execute)throw new Error("Google ReCaptcha has not been loaded");return b.execute(a,{action:e})}),[b]),v=e.useCallback((e=>{if(!b?.execute)throw new Error("Google ReCaptcha has not been loaded");return b.execute(e)}),[b]),w=e.useMemo((()=>({googleReCaptcha:b,siteKey:a,isLoading:u,executeV2Invisible:v,executeV3:C,reset:b?.reset,getResponse:b?.getResponse,render:b?.render,...r&&{language:r}})),[a,b,u,r]);return e.createElement(o,{value:w},l)},exports.generateGoogleReCaptchaHiddenBadgeStyles=c,exports.generateGoogleReCaptchaScriptSrc=n,exports.useGoogleReCaptcha=r,exports.withGoogleReCaptcha=t=>{const o=o=>e.createElement(a,null,(a=>e.createElement(t,{...o,googleReCaptcha:a})));return o.displayName=`withGoogleReCaptcha(${t.displayName||t.name||"Component"})`,o};
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
import e from"react";import{useGoogleReCaptcha as t}from"../context/useGoogleReCaptcha.js";import{removeGoogleReCaptchaContainer as o}from"../utils/helpers/removeGoogleReCaptchaContainer.js";import{useIsomorphicLayoutEffect as r}from"../utils/hooks/useIsomorphicLayoutEffect.js";const n=({id:n="google-recaptcha-checkbox-container",onChange:a,action:c,language:i,...s})=>{const{siteKey:l,render:u,language:m}=t(),p=e.useRef(null);return r((()=>{if(!u)return;const e=document.createElement("div"),t={sitekey:l,callback:a,...(i??m)&&{hl:i??m},...s};return u(e,c?{...t,action:c}:t),p.current&&p.current.appendChild(e),()=>{o(n)}}),[u,i,a,n,l,s.size,c,s.theme]),e.createElement("div",{id:n,ref:p,...s})};export{n as GoogleReCaptchaCheckbox,n as default};
//# sourceMappingURL=GoogleReCaptchaCheckbox.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
import{createContext as e}from"react";const o=e({googleReCaptcha:{},siteKey:"",language:"",isLoading:!0,executeV3:()=>{throw Error("GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")},executeV2Invisible:()=>{throw Error("GoogleReCaptchaContext has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")},reset:()=>{throw Error("GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")},getResponse:()=>{throw Error("GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")},render:()=>{throw Error("GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider")}}),{Provider:t,Consumer:a}=o;export{o as GoogleReCaptchaContext,a as GoogleReCaptchaContextConsumer,t as GoogleReCaptchaContextProvider};
//# sourceMappingURL=GoogleReCaptchaContext.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
import e from"react";import{removeGoogleReCaptchaScript as t}from"../utils/helpers/removeGoogleReCaptchaScript.js";import{injectGoogleReCaptchaScript as o}from"../utils/helpers/injectGoogleReCaptchaScript.js";import{hideGoogleReCaptchaBadge as r}from"../utils/helpers/hideGoogleReCaptchaBadge.js";import{removeGoogleReCaptchaBadge as i}from"../utils/helpers/removeGoogleReCaptchaBadge.js";import{removeGoogleReCaptchaContainer as a}from"../utils/helpers/removeGoogleReCaptchaContainer.js";import{checkGoogleReCaptchaInjected as n}from"../utils/helpers/checkGoogleReCaptchaInjected.js";import{GoogleReCaptchaContextProvider as s}from"./GoogleReCaptchaContext.js";const c=({type:c,siteKey:l,language:p,scriptProps:h,isEnterprise:d=!1,host:g,children:v,explicit:u,onLoad:m,onError:b})=>{const[f,C]=e.useState(!0),[w,R]=e.useState();e.useEffect((()=>{if(!l)throw new Error("Google ReCaptcha site key not provided");const e=h?.id??"google-recaptcha-script",s=n(e),v=()=>{const e=d?window.grecaptcha?.enterprise:window.grecaptcha;if(e){if(u||e.ready((async()=>{R(e),m&&await m(e),C(!0)})),u){const t={size:"v3"===c||"v2-invisible"===c?"invisible":"normal",...("v3"===c||"v2-invisible"===c)&&{badge:"bottomright"},sitekey:l,...u};if(!s){("v3"===c||"v2-invisible"===c)&&"hidden"===u?.badge&&r()}e.ready((async()=>{u.container&&e.render(u.container,t,!!u.inherit),R(e),m&&await m(e),C(!0)}))}}else b&&b()};return window.onGoogleReCaptchaLoad=v,s?v():o({isEnterprise:d,host:g,...("v3"===c||"v2-invisible"===c)&&u?.badge&&{badge:"hidden"===u?.badge?"bottomright":u?.badge},...p&&{hl:p},render:("v3"===c||"v2-invisible"===c)&&u?.container||"v2-checkbox"===c?"explicit":l,...h,onload:v,id:e}),()=>{w?.reset(),s||t(e),"v3"!==c&&"v2-invisible"!==c||u?.container||!u?.badge?i():a("google-recaptcha-container")}}),[d,p,g]);const x=e.useCallback((e=>{if(!w?.execute)throw new Error("Google ReCaptcha has not been loaded");return w.execute(l,{action:e})}),[w]),G=e.useCallback((e=>{if(!w?.execute)throw new Error("Google ReCaptcha has not been loaded");return w.execute(e)}),[w]),j=e.useMemo((()=>({googleReCaptcha:w,siteKey:l,isLoading:f,executeV2Invisible:G,executeV3:x,reset:w?.reset,getResponse:w?.getResponse,render:w?.render,...p&&{language:p}})),[l,w,f,p]);return e.createElement(s,{value:j},v)};export{c as GoogleReCaptchaProvider};
//# sourceMappingURL=GoogleReCaptchaProvider.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
import o from"react";import{GoogleReCaptchaContext as t}from"./GoogleReCaptchaContext.js";const e=()=>o.useContext(t);export{e as useGoogleReCaptcha};
//# sourceMappingURL=useGoogleReCaptcha.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
import e from"react";import{GoogleReCaptchaContextConsumer as t}from"./GoogleReCaptchaContext.js";const o=o=>{const a=a=>e.createElement(t,null,(t=>e.createElement(o,{...a,googleReCaptcha:t})));return a.displayName=`withGoogleReCaptcha(${o.displayName||o.name||"Component"})`,a};export{o as withGoogleReCaptcha};
//# sourceMappingURL=withGoogleReCaptcha.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
export{GoogleReCaptchaCheckbox}from"./components/GoogleReCaptchaCheckbox.js";export{GoogleReCaptchaProvider}from"./context/GoogleReCaptchaProvider.js";export{useGoogleReCaptcha}from"./context/useGoogleReCaptcha.js";export{withGoogleReCaptcha}from"./context/withGoogleReCaptcha.js";export{generateGoogleReCaptchaScriptSrc}from"./utils/helpers/generateGoogleReCaptchaScriptSrc.js";export{generateGoogleReCaptchaHiddenBadgeStyles}from"./utils/helpers/generateGoogleReCaptchaHiddenBadgeStyles.js";
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
const c=c=>!!document.querySelector(`#${c}`)||!!document.querySelector('script[src*="/recaptcha/"]:not([src*="gstatic"])');export{c as checkGoogleReCaptchaInjected};
//# sourceMappingURL=checkGoogleReCaptchaInjected.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
const a=()=>".grecaptcha-badge{display: none !important;}";export{a as generateGoogleReCaptchaHiddenBadgeStyles};
//# sourceMappingURL=generateGoogleReCaptchaHiddenBadgeStyles.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
const e=({host:e="google.com",isEnterprise:r,render:s,hl:a,badge:t})=>`https://www.${e}/recaptcha/${r?"enterprise.js":"api.js"}?${new URLSearchParams({...a&&{hl:a},...t&&{badge:t},render:s})}`;export{e as generateGoogleReCaptchaScriptSrc};
//# sourceMappingURL=generateGoogleReCaptchaScriptSrc.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
import{generateGoogleReCaptchaHiddenBadgeStyles as e}from"./generateGoogleReCaptchaHiddenBadgeStyles.js";const t=()=>{const t=document.createElement("style");t.innerHTML=e(),document.body.appendChild(t)};export{t as hideGoogleReCaptchaBadge};
//# sourceMappingURL=hideGoogleReCaptchaBadge.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
import{generateGoogleReCaptchaScriptSrc as e}from"./generateGoogleReCaptchaScriptSrc.js";const t=({onload:t,appendTo:r="head",isEnterprise:o=!1,host:n,render:s,badge:a,hl:c,...d})=>{const i=e({host:n,isEnterprise:o,render:s,hl:c,badge:a}),p=document.createElement("script");Object.entries(d).forEach((([e,t])=>{p.setAttribute(e,t?.toString()??"")})),p.src=i,p.onload=t,document[r].appendChild(p)};export{t as injectGoogleReCaptchaScript};
//# sourceMappingURL=injectGoogleReCaptchaScript.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
const e=()=>{const e=document.querySelector(".grecaptcha-badge");e&&e.parentNode&&document.body.removeChild(e.parentNode)};export{e as removeGoogleReCaptchaBadge};
//# sourceMappingURL=removeGoogleReCaptchaBadge.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
const t=t=>{const e=document.getElementById(t);if(e)for(;e.lastChild;)e.lastChild.remove()};export{t as removeGoogleReCaptchaContainer};
//# sourceMappingURL=removeGoogleReCaptchaContainer.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
const e="https://www.gstatic.com/recaptcha/releases",c=c=>{window.___grecaptcha_cfg=void 0;const t=document.querySelector(`#${c}`);t&&t.remove();const o=document.querySelector(`script[src^="${e}"]`);o&&o.remove()};export{e as GSTATIC_URL,c as removeGoogleReCaptchaScript};
//# sourceMappingURL=removeGoogleReCaptchaScript.js.map

@@ -1,3 +0,3 @@

/* @license react-google-recaptcha-ultimate v1.0.0 */
/* @license react-google-recaptcha-ultimate v1.0.1 */
import{useLayoutEffect as o,useEffect as e}from"react";const t="undefined"!=typeof window?o:e;export{t as useIsomorphicLayoutEffect};
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
{
"name": "react-google-recaptcha-ultimate",
"version": "1.0.0",
"version": "1.0.1",
"description": "Tool that easily and quickly add Google ReCaptcha for your website or application\n",

@@ -109,2 +109,2 @@ "author": {

}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc