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

react-google-recaptcha-hook

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.2.3 to 0.2.4

2

dist/react-google-recaptcha-hook.cjs.js

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

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var h=require("react");const w=()=>{var c;(c=window.___grecaptcha_cfg)!=null||(window.___grecaptcha_cfg={fns:[]})},g=c=>new Promise(e=>{var a;w(),c?(a=window==null?void 0:window.grecaptcha)!=null&&a.enterprise?e(window.grecaptcha.enterprise):window.___grecaptcha_cfg.fns.push(()=>e(window.grecaptcha.enterprise)):window!=null&&window.grecaptcha?e(window.grecaptcha):window.___grecaptcha_cfg.fns.push(()=>e(window.grecaptcha))}),n=async(c,e,a)=>(await g(c)).execute(e,{action:a}),f=async c=>{(await g(c)).ready(()=>{const a=document.querySelector(".grecaptcha-badge");a&&(a.style.visibility="hidden")})},s=async c=>{(await g(c)).ready(()=>{const a=document.querySelector(".grecaptcha-badge");a&&(a.style.visibility="visible")})},_=(c,e)=>{const a=e!=null&&e.language?`&hl=${e.language}`:"",t=e!=null&&e.enterprise?"enterprise.js":"api.js";return`https://www.${e!=null&&e.recaptchaNet?"recaptcha.net":"google.com"}/recaptcha/${t}?render=${c}${a}`},b=(c,e)=>{const a=h.useCallback(()=>{if(document.getElementById(c))return;const r=document.createElement("script");r.async=!0,r.type="text/javascript",r.src=_(c,e),r.id=c,document.getElementsByTagName("head")[0].appendChild(r)},[e,c]),t=h.useCallback(()=>f(!!(e!=null&&e.enterprise)),[e==null?void 0:e.enterprise]),u=h.useCallback(()=>s(!!(e!=null&&e.enterprise)),[e==null?void 0:e.enterprise]),l=h.useCallback(r=>n(!!(e!=null&&e.enterprise),c,r),[e==null?void 0:e.enterprise,c]),d=h.useRef(!1);return h.useEffect(()=>{d.current||(d.current=!0,e!=null&&e.hide&&t(),a())},[a,t,e]),{executeGoogleReCaptcha:l,hideGoogleReCaptcha:t,showGoogleReCaptcha:u}};exports.useGoogleReCaptcha=b;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var g=require("react");const h=c=>new Promise(e=>{var a,r;(a=window.___grecaptcha_cfg)!=null||(window.___grecaptcha_cfg={fns:[]}),c?(r=window==null?void 0:window.grecaptcha)!=null&&r.enterprise?e(window.grecaptcha.enterprise):window.___grecaptcha_cfg.fns.push(()=>e(window.grecaptcha.enterprise)):window!=null&&window.grecaptcha?e(window.grecaptcha):window.___grecaptcha_cfg.fns.push(()=>e(window.grecaptcha))}),w=async(c,e,a)=>(await h(c)).execute(e,{action:a}),n=async c=>{(await h(c)).ready(()=>{const a=document.querySelector(".grecaptcha-badge");a&&(a.style.visibility="hidden")})},f=async c=>{(await h(c)).ready(()=>{const a=document.querySelector(".grecaptcha-badge");a&&(a.style.visibility="visible")})},_=(c,e)=>{const a=e!=null&&e.language?`&hl=${e.language}`:"",r=e!=null&&e.enterprise?"enterprise.js":"api.js";return`https://www.${e!=null&&e.recaptchaNet?"recaptcha.net":"google.com"}/recaptcha/${r}?render=${c}${a}`},b=(c,e)=>{const a=g.useCallback(()=>{if(document.getElementById(c))return;const t=document.createElement("script");t.async=!0,t.type="text/javascript",t.src=_(c,e),t.id=c,document.getElementsByTagName("head")[0].appendChild(t)},[e,c]),r=g.useCallback(()=>n(!!(e!=null&&e.enterprise)),[e==null?void 0:e.enterprise]),u=g.useCallback(()=>f(!!(e!=null&&e.enterprise)),[e==null?void 0:e.enterprise]),l=g.useCallback(t=>w(!!(e!=null&&e.enterprise),c,t),[e==null?void 0:e.enterprise,c]),d=g.useRef(!1);return g.useEffect(()=>{d.current||(d.current=!0,e!=null&&e.hide&&r(),a())},[a,r,e]),{executeGoogleReCaptcha:l,hideGoogleReCaptcha:r,showGoogleReCaptcha:u}};exports.useGoogleReCaptcha=b;
import { useCallback, useRef, useEffect } from "react";
const initGrecaptcha = () => {
var _a;
const getGrecaptcha = (enterprise) => new Promise((resolve) => {
var _a, _b;
(_a = window.___grecaptcha_cfg) != null ? _a : window.___grecaptcha_cfg = {
fns: []
};
};
const getGrecaptcha = (enterprise) => new Promise((resolve) => {
var _a;
initGrecaptcha();
if (enterprise) {
((_a = window == null ? void 0 : window.grecaptcha) == null ? void 0 : _a.enterprise) ? resolve(window.grecaptcha.enterprise) : window.___grecaptcha_cfg.fns.push(() => resolve(window.grecaptcha.enterprise));
((_b = window == null ? void 0 : window.grecaptcha) == null ? void 0 : _b.enterprise) ? resolve(window.grecaptcha.enterprise) : window.___grecaptcha_cfg.fns.push(() => resolve(window.grecaptcha.enterprise));
} else {

@@ -14,0 +10,0 @@ (window == null ? void 0 : window.grecaptcha) ? resolve(window.grecaptcha) : window.___grecaptcha_cfg.fns.push(() => resolve(window.grecaptcha));

@@ -20,3 +20,3 @@ {

"license": "MIT",
"version": "0.2.3",
"version": "0.2.4",
"files": [

@@ -63,3 +63,3 @@ "dist",

"@testing-library/react": "^13.3.0",
"@types/node": "^17.0.36",
"@types/node": "^18.0.3",
"@types/react": "^18.0.9",

@@ -76,3 +76,3 @@ "@types/react-dom": "^18.0.5",

"eslint-plugin-react-hooks": "^4.5.0",
"happy-dom": "^4.1.0",
"happy-dom": "^6.0.2",
"husky": "^8.0.1",

@@ -79,0 +79,0 @@ "prettier": "^2.6.2",

import { ReCaptcha } from "./useGoogleRecaptcha";
/**
* @see https://developers.google.com/recaptcha/docs/loading#loading_recaptcha_asynchronously
**/
export declare const initGrecaptcha: () => void;
export declare const getGrecaptcha: (enterprise: boolean) => Promise<ReCaptcha>;

@@ -7,0 +3,0 @@ export declare const executeGrecaptcha: (enterprise: boolean, siteKey: string, action: string) => Promise<string>;

declare global {
interface Window {
grecaptcha: ReCaptcha & {
grecaptcha?: ReCaptcha & {
enterprise: ReCaptcha;
};
___grecaptcha_cfg: {
___grecaptcha_cfg?: {
fns: (() => void)[];

@@ -8,0 +8,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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