react-recaptcha-x
Advanced tools
Comparing version 1.1.12 to 1.1.13
@@ -78,3 +78,3 @@ # Contributing to react-recaptcha-x | ||
1. `$npm start` | ||
1. open browser to `http://locahost:9000` | ||
1. open browser to `http://localhost:9000` | ||
@@ -88,6 +88,3 @@ ### Code Quality / Linting | ||
1. [Prettier](https://prettier.io/) | ||
1. [TSLint](https://palantir.github.io/tslint/) | ||
1. [consistent codestyle](https://github.com/ajafff/tslint-consistent-codestyle#rules) | ||
1. [microsoft contrib](https://github.com/microsoft/tslint-microsoft-contrib#supported-rules) | ||
1. [tslint react](https://github.com/palantir/tslint-react#rules) | ||
1. [ESLint](https://eslint.org/) | ||
@@ -98,3 +95,3 @@ #### Code Quality / Linting - Commands | ||
1. for Prettier run `$npm run prettier` | ||
1. for TSLint run `$npm run lint` | ||
1. for ESLint run `$npm run lint` | ||
1. for Typescript compilation validation run `$npm run ts:validate` | ||
@@ -101,0 +98,0 @@ |
@@ -0,1 +1,8 @@ | ||
## [1.1.13](https://github.com/antokara/react-recaptcha-x/compare/v1.1.12...v1.1.13) (2021-07-07) | ||
### Bug Fixes | ||
* **npm packages:** upgrade ([634e828](https://github.com/antokara/react-recaptcha-x/commit/634e828a76555205a3a8311fda0f2a9343d644ec)) | ||
## [1.1.12](https://github.com/antokara/react-recaptcha-x/compare/v1.1.11...v1.1.12) (2021-04-10) | ||
@@ -2,0 +9,0 @@ |
@@ -1,1 +0,1 @@ | ||
module.exports=(()=>{"use strict";var e={465:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=t.ReCaptchaV2=t.ReCaptchaProvider=t.EReCaptchaV2Size=t.EReCaptchaV2Theme=void 0;const r=o(644);Object.defineProperty(t,"ReCaptchaProvider",{enumerable:!0,get:function(){return r.ReCaptchaProvider}});const n=o(160);Object.defineProperty(t,"EReCaptchaV2Size",{enumerable:!0,get:function(){return n.ESize}});const a=o(362);Object.defineProperty(t,"EReCaptchaV2Theme",{enumerable:!0,get:function(){return a.ETheme}});const i=o(327);Object.defineProperty(t,"ReCaptchaV2",{enumerable:!0,get:function(){return i.ReCaptchaV2}});const s=o(24);Object.defineProperty(t,"ReCaptchaV3",{enumerable:!0,get:function(){return s.ReCaptchaV3}})},411:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Context=void 0;const r=o(297).createContext({siteKeyV2:"",siteKeyV3:"",loaded:!1});t.Context=r},644:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaProvider=void 0;const r=o(297),n=o(411);class a 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,r="react-recaptcha-v3-v2-script";if(null===document.querySelector(`script[data-id="${r}"]`)){window.GoogleReCaptcha_onload=this.onLoadHandler;const o=document.createElement("script");o.setAttribute("data-id",r),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});const n="react-recaptcha-v3-v2-style";if(o&&null===document.querySelector(`style[data-id="${n}"]`)){const e=document.createElement("style");e.innerHTML=".grecaptcha-badge{display: none;}",e.setAttribute("data-id",n),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:a}=this.state,i={siteKeyV2:o,siteKeyV3:t,loaded:a};return r.createElement(n.Context.Provider,{value:i},e)}onLoadHandler(){delete window.GoogleReCaptcha_onload,this.setState({loaded:!0})}}t.ReCaptchaProvider=a},432:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.withContext=void 0;const r=o(297),n=o(411);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))}}},160:(e,t)=>{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},362:(e,t)=>{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},276:function(e,t,o){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(297),a=o(160),i=o(362);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:a,tabindex:i}=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:a,tabindex:i})})}render(){const{ref:e}=this.state,t=this.props,{theme:o,callback:a,size:i,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:i.ETheme.Light,size:a.ESize.Normal,tabindex:0}},327:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV2=void 0;const r=o(432),n=o(276),a=r.withContext(n.ReCaptchaV2);t.ReCaptchaV2=a},831:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=void 0;const r=o(297);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},24:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=void 0;const r=o(432),n=o(831),a=r.withContext(n.ReCaptchaV3);t.ReCaptchaV3=a},297:e=>{e.exports=require("react")}},t={};return function o(r){if(t[r])return t[r].exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,o),n.exports}(465)})(); | ||
(()=>{"use strict";var e={411:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Context=void 0;const r=o(297).createContext({siteKeyV2:"",siteKeyV3:"",loaded:!1});t.Context=r},644:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaProvider=void 0;const r=o(297),n=o(411);class a 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,r="react-recaptcha-v3-v2-script";if(null===document.querySelector(`script[data-id="${r}"]`)){window.GoogleReCaptcha_onload=this.onLoadHandler;const o=document.createElement("script");o.setAttribute("data-id",r),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});const n="react-recaptcha-v3-v2-style";if(o&&null===document.querySelector(`style[data-id="${n}"]`)){const e=document.createElement("style");e.innerHTML=".grecaptcha-badge{display: none;}",e.setAttribute("data-id",n),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:a}=this.state,i={siteKeyV2:o,siteKeyV3:t,loaded:a};return r.createElement(n.Context.Provider,{value:i},e)}onLoadHandler(){delete window.GoogleReCaptcha_onload,this.setState({loaded:!0})}}t.ReCaptchaProvider=a},432:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.withContext=void 0;const r=o(297),n=o(411);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))}}},160:(e,t)=>{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},362:(e,t)=>{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},276:function(e,t,o){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(297),a=o(160),i=o(362);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:a,tabindex:i}=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:a,tabindex:i})})}render(){const{ref:e}=this.state,t=this.props,{theme:o,callback:a,size:i,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:i.ETheme.Light,size:a.ESize.Normal,tabindex:0}},327:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV2=void 0;const r=o(432),n=o(276),a=r.withContext(n.ReCaptchaV2);t.ReCaptchaV2=a},831:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=void 0;const r=o(297);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},24:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReCaptchaV3=void 0;const r=o(432),n=o(831),a=r.withContext(n.ReCaptchaV3);t.ReCaptchaV3=a},297:e=>{e.exports=require("react")}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,o),a.exports}var r={};(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.ReCaptchaV3=e.ReCaptchaV2=e.ReCaptchaProvider=e.EReCaptchaV2Size=e.EReCaptchaV2Theme=void 0;const t=o(644);Object.defineProperty(e,"ReCaptchaProvider",{enumerable:!0,get:function(){return t.ReCaptchaProvider}});const n=o(160);Object.defineProperty(e,"EReCaptchaV2Size",{enumerable:!0,get:function(){return n.ESize}});const a=o(362);Object.defineProperty(e,"EReCaptchaV2Theme",{enumerable:!0,get:function(){return a.ETheme}});const i=o(327);Object.defineProperty(e,"ReCaptchaV2",{enumerable:!0,get:function(){return i.ReCaptchaV2}});const s=o(24);Object.defineProperty(e,"ReCaptchaV3",{enumerable:!0,get:function(){return s.ReCaptchaV3}})})(),module.exports=r})(); |
import * as React from 'react'; | ||
declare global { | ||
interface Window { | ||
GoogleReCaptcha_onload?: Function; | ||
GoogleReCaptcha_onload?: () => void; | ||
} | ||
@@ -6,0 +6,0 @@ } |
@@ -5,2 +5,3 @@ const { pathsToModuleNameMapper } = require('ts-jest/utils'); | ||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
preset: 'ts-jest', | ||
@@ -7,0 +8,0 @@ moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { |
// enable Jest DOM custom matchers | ||
// @see https://github.com/testing-library/jest-dom#usage | ||
// tslint:disable-next-line:no-import-side-effect no-submodule-imports | ||
import '@testing-library/jest-dom/extend-expect'; | ||
@@ -5,0 +4,0 @@ |
{ | ||
"name": "react-recaptcha-x", | ||
"version": "1.1.12", | ||
"version": "1.1.13", | ||
"description": "a React component for Google's reCAPTCHA v3 and v2 (checkbox) component", | ||
@@ -11,3 +11,3 @@ "main": "./dist/index.js", | ||
"prettier": "npx prettier --check 'src/**/*.ts?(x)'", | ||
"lint": "tslint 'src/**/*.ts?(x)' -c tslint.json", | ||
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx", | ||
"build": "npm run build:clean && npm run build:types && npm run build:js && npm run build:tscpaths", | ||
@@ -17,3 +17,3 @@ "build:clean": "rm dist/* -rf", | ||
"build:js": "webpack --config ./webpack.config.js --progress", | ||
"build:tscpaths": "tscpaths -p tsconfig.build.json -s ./src -o ./dist", | ||
"build:tscpaths": "tsconfig-replace-paths -p tsconfig.build.json -s ./src -o ./dist", | ||
"cl": "commitlint --from=HEAD~1", | ||
@@ -48,30 +48,29 @@ "ts:validate": "tsc --noEmit" | ||
"devDependencies": { | ||
"@commitlint/cli": "^12.1.1", | ||
"@commitlint/config-conventional": "^12.1.1", | ||
"@commitlint/cli": "^12.1.4", | ||
"@commitlint/config-conventional": "^12.1.4", | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/git": "^9.0.0", | ||
"@semantic-release/github": "^7.2.0", | ||
"@semantic-release/npm": "^7.1.1", | ||
"@testing-library/dom": "^7.29.4", | ||
"@testing-library/jest-dom": "^5.11.9", | ||
"@testing-library/react": "^11.2.5", | ||
"@types/jest": "^26.0.20", | ||
"@types/react": "^17.0.2", | ||
"@types/react-dom": "^17.0.1", | ||
"@semantic-release/github": "^7.2.3", | ||
"@semantic-release/npm": "^7.1.3", | ||
"@testing-library/dom": "^8.0.0", | ||
"@testing-library/jest-dom": "^5.14.1", | ||
"@testing-library/react": "^12.0.0", | ||
"@types/jest": "^26.0.24", | ||
"@types/react": "^17.0.11", | ||
"@types/react-dom": "^17.0.8", | ||
"@typescript-eslint/eslint-plugin": "^4.28.2", | ||
"@typescript-eslint/parser": "^4.28.2", | ||
"coveralls": "^3.1.0", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"semantic-release": "^17.3.9", | ||
"ts-jest": "^26.5.1", | ||
"ts-loader": "^8.0.17", | ||
"tscpaths": "0.0.9", | ||
"tslint": "^6.1.3", | ||
"tslint-consistent-codestyle": "^1.16.0", | ||
"tslint-microsoft-contrib": "^6.2.0", | ||
"tslint-react": "^5.0.0", | ||
"typescript": "^4.1.5", | ||
"webpack": "^5.21.2", | ||
"webpack-cli": "^4.5.0" | ||
"eslint": "^7.30.0", | ||
"jest": "^27.0.5", | ||
"prettier": "^2.3.2", | ||
"react": "17.0.2", | ||
"react-dom": "^17.0.2", | ||
"semantic-release": "^17.4.4", | ||
"ts-jest": "^27.0.3", | ||
"ts-loader": "^9.2.3", | ||
"tsconfig-replace-paths": "^0.0.5", | ||
"typescript": "^4.3.5", | ||
"webpack": "^5.43.0", | ||
"webpack-cli": "^4.7.2" | ||
}, | ||
@@ -78,0 +77,0 @@ "peerDependencies": { |
@@ -219,3 +219,3 @@ # react-recaptcha-x | ||
1. [nodejs](https://nodejs.org/en/) 10.x.x LTS | ||
1. [nodejs](https://nodejs.org/en/) 16.x LTS | ||
1. `$npm install` | ||
@@ -222,0 +222,0 @@ 1. `$npm run build` |
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
136187
27
41
347