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

react-recaptcha-x

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-recaptcha-x - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

8

CHANGELOG.md

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

## [1.1.7](https://github.com/antokara/react-recaptcha-x/compare/v1.1.6...v1.1.7) (2020-06-14)
### Bug Fixes
* **packages:** update npm packages ([ad753e4](https://github.com/antokara/react-recaptcha-x/commit/ad753e465b74277bd7945e7453ddea8bf57fa862))
* **recaptcha provider:** handle remount ([e72f95b](https://github.com/antokara/react-recaptcha-x/commit/e72f95b14b10e0a5934befb683ad389111293c9c)), closes [#37](https://github.com/antokara/react-recaptcha-x/issues/37) [#37](https://github.com/antokara/react-recaptcha-x/issues/37) [#37](https://github.com/antokara/react-recaptcha-x/issues/37)
## [1.1.6](https://github.com/antokara/react-recaptcha-x/compare/v1.1.5...v1.1.6) (2020-06-07)

@@ -2,0 +10,0 @@

2

dist/index.js

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

module.exports=function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([function(e,t){e.exports=require("react")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Context=void 0;const o=r(0).createContext({siteKeyV2:"",siteKeyV3:"",loaded:!1});t.Context=o},function(e,t,r){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),t.ESize=void 0,function(e){e.Normal="normal",e.Compact="compact"}(o||(o={})),t.ESize=o},function(e,t,r){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),t.ETheme=void 0,function(e){e.Light="light",e.Dark="dark"}(o||(o={})),t.ETheme=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withContext=void 0;const o=r(0),n=r(1);t.withContext=e=>class extends o.Component{render(){return o.createElement(n.Context.Consumer,null,((e,t)=>r=>o.createElement(e,Object.assign({},t,{providerContext:r})))(e,this.props))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=t.ReCaptchaV2=t.ReCaptchaProvider=t.EReCaptchaV2Size=t.EReCaptchaV2Theme=void 0;const o=r(6);Object.defineProperty(t,"ReCaptchaProvider",{enumerable:!0,get:function(){return o.ReCaptchaProvider}});const n=r(2);Object.defineProperty(t,"EReCaptchaV2Size",{enumerable:!0,get:function(){return n.ESize}});const i=r(3);Object.defineProperty(t,"EReCaptchaV2Theme",{enumerable:!0,get:function(){return i.ETheme}});const a=r(7);Object.defineProperty(t,"ReCaptchaV2",{enumerable:!0,get:function(){return a.ReCaptchaV2}});const s=r(9);Object.defineProperty(t,"ReCaptchaV3",{enumerable:!0,get:function(){return s.ReCaptchaV3}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaProvider=void 0;const o=r(0),n=r(1);class i extends o.Component{constructor(e){super(e),this.state={loaded:!1},this.onLoadHandler=this.onLoadHandler.bind(this)}componentDidMount(){const{siteKeyV3:e="explicit",langCode:t="",hideV3Badge:r=!1}=this.props;window.GoogleReCaptcha_onload=this.onLoadHandler;if(null===document.querySelector('script[data-id="react-recaptcha-v3-v2-script"]')){const r=document.createElement("script");r.setAttribute("data-id","react-recaptcha-v3-v2-script"),r.setAttribute("src",`https://www.google.com/recaptcha/api.js?render=${e}&onload=GoogleReCaptcha_onload&hl=${t}`),r.setAttribute("async","true"),r.setAttribute("defer","true"),document.body.appendChild(r)}if(r&&null===document.querySelector('style[data-id="react-recaptcha-v3-v2-style"]')){const e=document.createElement("style");e.innerHTML=".grecaptcha-badge{display: none;}",e.setAttribute("data-id","react-recaptcha-v3-v2-style"),document.body.appendChild(e)}}render(){const{children:e,siteKeyV3:t,siteKeyV2:r}=this.props,{loaded:i}=this.state,a={siteKeyV2:r,siteKeyV3:t,loaded:i};return o.createElement(n.Context.Provider,{value:a},e)}onLoadHandler(){delete window.GoogleReCaptcha_onload,this.setState({loaded:!0})}}t.ReCaptchaProvider=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV2=void 0;const o=r(4),n=r(8),i=o.withContext(n.ReCaptchaV2);t.ReCaptchaV2=i},function(e,t,r){"use strict";var o=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV2=void 0;const n=r(0),i=r(2),a=r(3);class s extends n.Component{constructor(e){super(e);const{siteKeyV2:t}=this.props.providerContext;if(!t)throw new Error('The prop "siteKeyV2" must be set on the ReCaptchaProvider before using the ReCaptchaV2 component');this.state={ref:n.createRef(),widgetId:void 0,token:void 0,expired:!1,error:!1},this.successCallback=this.successCallback.bind(this),this.expiredCallback=this.expiredCallback.bind(this),this.errorCallback=this.errorCallback.bind(this),this.shouldRenderWidget=this.shouldRenderWidget.bind(this)}componentDidUpdate(){this.shouldRenderWidget(this.state.ref,this.props)}componentDidMount(){this.shouldRenderWidget(this.state.ref,this.props)}shouldRenderWidget(e,t){const{loaded:r,siteKeyV2:o}=t.providerContext,{theme:n,size:i,tabindex:a}=t,{widgetId:s}=this.state;void 0===s&&r&&e.current&&o&&this.setState({expired:!1,error:!1,widgetId:grecaptcha.render(e.current,{sitekey:o,callback:this.successCallback,"expired-callback":this.expiredCallback,"error-callback":this.errorCallback,theme:n,size:i,tabindex:a})})}render(){const{ref:e}=this.state,t=this.props,{theme:r,callback:i,size:a,tabindex:s,providerContext:c}=t,d=o(t,["theme","callback","size","tabindex","providerContext"]);return n.createElement("div",Object.assign({ref:e},d))}successCallback(e){const{callback:t}=this.props;this.setState({token:e,expired:!1,error:!1},()=>{t(e)})}expiredCallback(){const{callback:e}=this.props;this.setState({expired:!0},()=>{e(!1)})}errorCallback(){const{callback:e}=this.props;this.setState({error:!0},()=>{e(new Error)})}}t.ReCaptchaV2=s,s.defaultProps={theme:a.ETheme.Light,size:i.ESize.Normal,tabindex:0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=void 0;const o=r(4),n=r(10),i=o.withContext(n.ReCaptchaV3);t.ReCaptchaV3=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=void 0;const o=r(0);class n extends o.Component{constructor(e){super(e),this.unMounting=!1;const{siteKeyV3:t}=this.props.providerContext;if(!t)throw new Error('The prop "siteKeyV3" must be set on the ReCaptchaProvider before using the ReCaptchaV3 component');this.state={token:void 0,retrieving:!1},this.getToken=this.getToken.bind(this)}componentDidMount(){this.getToken()}componentDidUpdate(e){const{loaded:t}=this.props.providerContext;e.providerContext.loaded!==t&&t&&this.getToken()}render(){return!1}componentWillUnmount(){this.unMounting=!0}getToken(){const{loaded:e,siteKeyV3:t}=this.props.providerContext,{retrieving:r}=this.state,{action:o,callback:n}=this.props;e&&!r&&t&&this.setState({token:void 0,retrieving:!0},()=>{n(),grecaptcha.execute(t,{action:o}).then(e=>{this.unMounting||this.setState({token:e,retrieving:!1},()=>{n(e,this.getToken)})})})}}t.ReCaptchaV3=n}]);
module.exports=function(e){var t={};function o(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=5)}([function(e,t){e.exports=require("react")},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Context=void 0;const r=o(0).createContext({siteKeyV2:"",siteKeyV3:"",loaded:!1});t.Context=r},function(e,t,o){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.ESize=void 0,function(e){e.Normal="normal",e.Compact="compact"}(r||(r={})),t.ESize=r},function(e,t,o){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.ETheme=void 0,function(e){e.Light="light",e.Dark="dark"}(r||(r={})),t.ETheme=r},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withContext=void 0;const r=o(0),n=o(1);t.withContext=e=>class extends r.Component{render(){return r.createElement(n.Context.Consumer,null,((e,t)=>o=>r.createElement(e,Object.assign({},t,{providerContext:o})))(e,this.props))}}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=t.ReCaptchaV2=t.ReCaptchaProvider=t.EReCaptchaV2Size=t.EReCaptchaV2Theme=void 0;const r=o(6);Object.defineProperty(t,"ReCaptchaProvider",{enumerable:!0,get:function(){return r.ReCaptchaProvider}});const n=o(2);Object.defineProperty(t,"EReCaptchaV2Size",{enumerable:!0,get:function(){return n.ESize}});const i=o(3);Object.defineProperty(t,"EReCaptchaV2Theme",{enumerable:!0,get:function(){return i.ETheme}});const a=o(7);Object.defineProperty(t,"ReCaptchaV2",{enumerable:!0,get:function(){return a.ReCaptchaV2}});const s=o(9);Object.defineProperty(t,"ReCaptchaV3",{enumerable:!0,get:function(){return s.ReCaptchaV3}})},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaProvider=void 0;const r=o(0),n=o(1);class i extends r.Component{constructor(e){super(e),this.state={loaded:!1},this.onLoadHandler=this.onLoadHandler.bind(this)}componentDidMount(){const{siteKeyV3:e="explicit",langCode:t="",hideV3Badge:o=!1}=this.props;if(null===document.querySelector('script[data-id="react-recaptcha-v3-v2-script"]')){window.GoogleReCaptcha_onload=this.onLoadHandler;const o=document.createElement("script");o.setAttribute("data-id","react-recaptcha-v3-v2-script"),o.setAttribute("src",`https://www.google.com/recaptcha/api.js?render=${e}&onload=GoogleReCaptcha_onload&hl=${t}`),o.setAttribute("async","true"),o.setAttribute("defer","true"),document.body.appendChild(o)}else window.GoogleReCaptcha_onload?window.GoogleReCaptcha_onload=this.onLoadHandler:this.setState({loaded:!0});if(o&&null===document.querySelector('style[data-id="react-recaptcha-v3-v2-style"]')){const e=document.createElement("style");e.innerHTML=".grecaptcha-badge{display: none;}",e.setAttribute("data-id","react-recaptcha-v3-v2-style"),document.body.appendChild(e)}}componentWillUnmount(){window.GoogleReCaptcha_onload&&(window.GoogleReCaptcha_onload=()=>{delete window.GoogleReCaptcha_onload})}render(){const{children:e,siteKeyV3:t,siteKeyV2:o}=this.props,{loaded:i}=this.state,a={siteKeyV2:o,siteKeyV3:t,loaded:i};return r.createElement(n.Context.Provider,{value:a},e)}onLoadHandler(){delete window.GoogleReCaptcha_onload,this.setState({loaded:!0})}}t.ReCaptchaProvider=i},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV2=void 0;const r=o(4),n=o(8),i=r.withContext(n.ReCaptchaV2);t.ReCaptchaV2=i},function(e,t,o){"use strict";var r=this&&this.__rest||function(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(o[r[n]]=e[r[n]])}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV2=void 0;const n=o(0),i=o(2),a=o(3);class s extends n.Component{constructor(e){super(e);const{siteKeyV2:t}=this.props.providerContext;if(!t)throw new Error('The prop "siteKeyV2" must be set on the ReCaptchaProvider before using the ReCaptchaV2 component');this.state={ref:n.createRef(),widgetId:void 0,token:void 0,expired:!1,error:!1},this.successCallback=this.successCallback.bind(this),this.expiredCallback=this.expiredCallback.bind(this),this.errorCallback=this.errorCallback.bind(this),this.shouldRenderWidget=this.shouldRenderWidget.bind(this)}componentDidUpdate(){this.shouldRenderWidget(this.state.ref,this.props)}componentDidMount(){this.shouldRenderWidget(this.state.ref,this.props)}shouldRenderWidget(e,t){const{loaded:o,siteKeyV2:r}=t.providerContext,{theme:n,size:i,tabindex:a}=t,{widgetId:s}=this.state;void 0===s&&o&&e.current&&r&&this.setState({expired:!1,error:!1,widgetId:grecaptcha.render(e.current,{sitekey:r,callback:this.successCallback,"expired-callback":this.expiredCallback,"error-callback":this.errorCallback,theme:n,size:i,tabindex:a})})}render(){const{ref:e}=this.state,t=this.props,{theme:o,callback:i,size:a,tabindex:s,providerContext:c}=t,d=r(t,["theme","callback","size","tabindex","providerContext"]);return n.createElement("div",Object.assign({ref:e},d))}successCallback(e){const{callback:t}=this.props;this.setState({token:e,expired:!1,error:!1},()=>{t(e)})}expiredCallback(){const{callback:e}=this.props;this.setState({expired:!0},()=>{e(!1)})}errorCallback(){const{callback:e}=this.props;this.setState({error:!0},()=>{e(new Error)})}}t.ReCaptchaV2=s,s.defaultProps={theme:a.ETheme.Light,size:i.ESize.Normal,tabindex:0}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=void 0;const r=o(4),n=o(10),i=r.withContext(n.ReCaptchaV3);t.ReCaptchaV3=i},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=void 0;const r=o(0);class n extends r.Component{constructor(e){super(e),this.unMounting=!1;const{siteKeyV3:t}=this.props.providerContext;if(!t)throw new Error('The prop "siteKeyV3" must be set on the ReCaptchaProvider before using the ReCaptchaV3 component');this.state={token:void 0,retrieving:!1},this.getToken=this.getToken.bind(this)}componentDidMount(){this.getToken()}componentDidUpdate(e){const{loaded:t}=this.props.providerContext;e.providerContext.loaded!==t&&t&&this.getToken()}render(){return!1}componentWillUnmount(){this.unMounting=!0}getToken(){const{loaded:e,siteKeyV3:t}=this.props.providerContext,{retrieving:o}=this.state,{action:r,callback:n}=this.props;e&&!o&&t&&this.setState({token:void 0,retrieving:!0},()=>{n(),grecaptcha.execute(t,{action:r}).then(e=>{this.unMounting||this.setState({token:e,retrieving:!1},()=>{n(e,this.getToken)})})})}}t.ReCaptchaV3=n}]);

@@ -20,2 +20,3 @@ import * as React from 'react';

componentDidMount(): void;
componentWillUnmount(): void;
render(): React.ReactNode;

@@ -22,0 +23,0 @@ private onLoadHandler;

{
"name": "react-recaptcha-x",
"version": "1.1.6",
"version": "1.1.7",
"description": "a React component for Google's reCAPTCHA v3 and v2 (checkbox) component",

@@ -52,6 +52,6 @@ "main": "./dist/index.js",

"@semantic-release/npm": "^7.0.5",
"@testing-library/dom": "^7.10.1",
"@testing-library/jest-dom": "^5.9.0",
"@testing-library/dom": "^7.14.2",
"@testing-library/jest-dom": "^5.10.0",
"@testing-library/react": "^10.2.1",
"@types/jest": "^25.2.3",
"@types/jest": "^26.0.0",
"@types/react-dom": "^16.9.8",

@@ -75,3 +75,3 @@ "coveralls": "^3.1.0",

"dependencies": {
"@types/react": "^16.9.35",
"@types/react": "^16.9.36",
"react": "^16.13.1"

@@ -78,0 +78,0 @@ },

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