Latest repo

This commit is contained in:
Marc
2025-06-02 16:42:16 +00:00
parent 53ddf1a329
commit cde5fae175
27907 changed files with 3875388 additions and 1 deletions

18
node_modules/react-google-recaptcha/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,18 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
[*.js]
charset = utf-8
indent_style = space
indent_size = 2
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

1
node_modules/react-google-recaptcha/.eslintignore generated vendored Normal file
View File

@@ -0,0 +1 @@
lib/**

20
node_modules/react-google-recaptcha/.eslintrc.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
/* eslint-env node */
module.exports = {
extends: ["eslint:recommended", "plugin:react/recommended", "prettier"],
parserOptions: {
sourceType: "module",
ecmaVersion: "latest",
ecmaFeatures: {
jsx: true,
},
},
env: {
es6: true,
browser: true,
},
plugins: ["react", "prettier"],
rules: {
"prettier/prettier": "error",
},
};

1
node_modules/react-google-recaptcha/.gitattributes generated vendored Normal file
View File

@@ -0,0 +1 @@
* text=auto eol=lf

View File

@@ -0,0 +1,8 @@
---
name: Issue template
about: Standard Issue Template
---
react-google-recaptcha version: X.X.X
react-async-script version: Y.Y.Y

View File

@@ -0,0 +1,40 @@
name: standard-ci
on:
pull_request:
paths-ignore:
- '**.md'
push:
branches:
- master
paths-ignore:
- '**.md'
jobs:
test:
strategy:
matrix:
node: [14, 16, 18]
os: [ubuntu-latest, windows-latest, macos-latest]
name: Node v${{ matrix.node }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Test
run: npm test
- name: Lint
run: npm run lint
- name: Build
run: npm run build

5
node_modules/react-google-recaptcha/.prettierrc generated vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"printWidth": 100,
"trailingComma": "all",
"parser": "babel"
}

310
node_modules/react-google-recaptcha/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,310 @@
v3.1.0 - Sat 3 Jun 2023 0:30 ET
---------------------------------------
- Add Enterprise Support 1 [(#239)](https://github.com/dozoisch/react-google-recaptcha/issues/239)
- Add Enterprise Support 2 [(#270)](https://github.com/dozoisch/react-google-recaptcha/issues/270)
- Add Nonce Support [(#221)](https://github.com/dozoisch/react-google-recaptcha/issues/221)
- Update dependencies 1 [(#206)](https://github.com/dozoisch/react-google-recaptcha/issues/206)
- Update dependencies 2 [(#207)](https://github.com/dozoisch/react-google-recaptcha/issues/207)
- Update dependencies 3 [(#210)](https://github.com/dozoisch/react-google-recaptcha/issues/210)
- Update dependencies 4 [(#211)](https://github.com/dozoisch/react-google-recaptcha/issues/211)
- Update dependencies 5 [(#219)](https://github.com/dozoisch/react-google-recaptcha/issues/219)
- Update dependencies 6 [(#226)](https://github.com/dozoisch/react-google-recaptcha/issues/226)
- Update dependencies 7 [(#229)](https://github.com/dozoisch/react-google-recaptcha/issues/229)
- Update dependencies 8 [(#235)](https://github.com/dozoisch/react-google-recaptcha/issues/235)
- Update dependencies 9 [(#245)](https://github.com/dozoisch/react-google-recaptcha/issues/245)
v3.0.0-alpha.1 - Mon 23 Nov 2020 22:25 ET
---------------------------------------
- Add isolated prop [(#179)](https://github.com/dozoisch/react-google-recaptcha/issues/179)
- Update dependencies 1 [(#187)](https://github.com/dozoisch/react-google-recaptcha/issues/187)
- Update dependencies 2 [(#194)](https://github.com/dozoisch/react-google-recaptcha/issues/194)
- Remove Timeout Removal [(#196)](https://github.com/dozoisch/react-google-recaptcha/issues/196)
v2.1.0 - Fri 5 Jun 2020 22:05 PST
---------------------------------------
- Add promise based Execution [(#163)](https://github.com/dozoisch/react-google-recaptcha/issues/163)
v2.0.1 - Sat 14 Sep 2019 12:00 PST
---------------------------------------
- Fix onChange was using the function passed at mount time [(#154)](https://github.com/dozoisch/react-google-recaptcha/issues/154)
v2.0.0-rc.1 - Sat 3 Aug 2019 8:00 PST
---------------------------------------
- Remove lang and removeOnUnmount global options [(#143)](https://github.com/dozoisch/react-google-recaptcha/issues/143)
- Upgrade to node 8, 10, 12 [(#143)](https://github.com/dozoisch/react-google-recaptcha/issues/143)
- Update to react-async-script 1.1 [(#143)](https://github.com/dozoisch/react-google-recaptcha/issues/143)
v1.1.0 - Sun 14 Jul 2019 10:56 PST
---------------------------------------
- Add HL prop [(#141)](https://github.com/dozoisch/react-google-recaptcha/issues/141)
- Upgrade babel and jest [(#140)](https://github.com/dozoisch/react-google-recaptcha/issues/140)
v1.0.5 - Mon 12 Nov 2018 9:25 PST
---------------------------------------
- Fix promise timeout [(#120)](https://github.com/dozoisch/react-google-recaptcha/issues/120)
v1.0.4 - Thu 27 Sep 2018 15:14 PST
---------------------------------------
- add .babelrc to .npmignore [(#111)](https://github.com/dozoisch/react-google-recaptcha/issues/111)
v1.0.2 - Wed, 5 Sep 2018 13:21:00 EST
---------------------------------------
- fixe unbound onErrored handler [(#104)](https://github.com/dozoisch/react-google-recaptcha/pull/104)
v1.0.1 - Thu, 30 Aug 2018 12:54:00 EST
---------------------------------------
- Make the onChange prop not required [(#102)](https://github.com/dozoisch/react-google-recaptcha/pull/102)
v1.0.0 - Fri, 17 Aug 2018 18:11:00 PST
---------------------------------------
- Update to react-async-script 1.0 [(#94)](https://github.com/dozoisch/react-google-recaptcha/pull/94)
- Add on Error [(#97)](https://github.com/dozoisch/react-google-recaptcha/pull/97)
- Update build tools
- Node 8 [(#95)](https://github.com/dozoisch/react-google-recaptcha/pull/95)
- Jest [(#95)](https://github.com/dozoisch/react-google-recaptcha/pull/95)
- Eslint/Prettier [(#96)](https://github.com/dozoisch/react-google-recaptcha/pull/96)
v0.14.0 - Sun, 29 Jul 2018 19:20:03 GMT
---------------------------------------
- [701695b](../../commit/701695b) [changed] dynamic url creation to allow language change
v0.13.0 - Tue, 24 Jul 2018 21:50:35 GMT
---------------------------------------
- [fde0d51](../../commit/fde0d51) [fixed] Update async-script to get rid of Map polyfill
v0.12.0 - Mon, 11 Jun 2018 16:39:53 GMT
---------------------------------------
- [f465421](../../commit/f465421) [fixed] react-async-script to dependency
- [48a5726](../../commit/48a5726) [added] Parameter to use recaptchanet instead of google.com
v0.11.1 - Thu, 10 May 2018 22:28:19 GMT
---------------------------------------
- [b2ae438](../../commit/b2ae438) [fixed] issue grecaptcha.render is not a function by adding condition
v0.11.0 - Sun, 25 Mar 2018 20:09:27 GMT
---------------------------------------
- [4920312](../../commit/4920312) Add es2015 module build (#59)
v0.10.0 - Sun, 25 Mar 2018 20:02:26 GMT
---------------------------------------
- [8c6a8dc](../../commit/8c6a8dc) Remove rendered DOM on unmount (#73)
v0.9.8 - Tue, 28 Nov 2017 04:07:05 GMT
--------------------------------------
- [7cd1254](../../commit/7cd1254) Fix peerDependency of react
v0.9.7 - Thu, 10 Aug 2017 00:04:43 GMT
--------------------------------------
- [e5f6fd9](../../commit/e5f6fd9) Add an accessor for widgetid (#53)
- [8932900](../../commit/8932900) Fixed PropTypes warning due to extra space (#51)
v0.9.6 - Tue, 20 Jun 2017 16:20:26 GMT
--------------------------------------
- [9796adb](../../commit/9796adb) Fix race on execute() (#49)
v0.9.5 - Fri, 02 Jun 2017 09:26:50 GMT
--------------------------------------
- Fixed release
v0.9.4 - Fri, 02 Jun 2017 09:26:02 GMT
--------------------------------------
- [89a1c0e](../../commit/89a1c0e) Changed ref to use function instead of dep strings
- [5c8a04d](../../commit/5c8a04d) Update examples in readme (#47)
- [349aaa8](../../commit/349aaa8) Modified description of badge parameter (#46)
v0.9.3 - Mon, 24 Apr 2017 16:31:56 GMT
--------------------------------------
- [cb041a3](../../commit/cb041a3) [fixed] issue with handleExpired not being bound
v0.9.2 - Thu, 20 Apr 2017 01:10:09 GMT
--------------------------------------
- [1c8d411](../../commit/1c8d411) [fixed] updated async-script
v0.9.1 - Tue, 18 Apr 2017 08:27:28 GMT
--------------------------------------
- [242faf5](../../commit/242faf5) [fixed] space in peer dep version
v0.9.0 - Sun, 16 Apr 2017 23:36:41 GMT
--------------------------------------
- [bbf5312](../../commit/bbf5312) [changed] updated for react 15.5
v0.8.1 - Mon, 03 Apr 2017 04:34:00 GMT
--------------------------------------
- [dbd3a47](../../commit/dbd3a47) [fixed] react-async-script dep version
v0.8.0 - Fri, 24 Mar 2017 00:54:19 GMT
--------------------------------------
- [883210e](../../commit/883210e) Added support for badge attribute (#36)
v0.7.0 - Thu, 16 Mar 2017 17:11:15 GMT
--------------------------------------
- [4eda897](../../commit/4eda897) Added Invisible example to README.md
- [34d5e0c](../../commit/34d5e0c) Add invisible props and execute method (#34)
- [cbfe092](../../commit/cbfe092) [added] install of react-async-script in readme
v0.6.0 - Sun, 05 Mar 2017 02:45:00 GMT
--------------------------------------
- [3c92d6d](../../commit/3c92d6d) [changed] Updated babel, react and dropped 0.10, 0.12 (#30)
- [7c8424c](../../commit/7c8424c) make dependencies more friendly for consuming packages (#29)
v0.5.4 - Tue, 19 Jul 2016 21:46:12 GMT
--------------------------------------
- [cb679d7](../../commit/cb679d7) [fixed] issue with react 15.2 warnings for unknown props
v0.5.3 - Tue, 03 May 2016 01:57:36 GMT
--------------------------------------
- [50e770f](../../commit/50e770f) [added] temporary solution to the lang issue
v0.5.2 - Sat, 28 Nov 2015 00:47:54 GMT
--------------------------------------
- [0e94a8a](../../commit/0e94a8a) [added] stoken parameter
v0.5.1 - Fri, 06 Nov 2015 16:17:16 GMT
--------------------------------------
- [b7cfa5c](../../commit/b7cfa5c) [fixed] handle widgetId equal to 0
v0.5.0 - Thu, 15 Oct 2015 21:38:43 GMT
--------------------------------------
- [d217dd1](../../commit/d217dd1) [changed] updated all deps
- [fc3350a](../../commit/fc3350a) [added] mt-changelog and release-script
- [dfa9bf2](../../commit/dfa9bf2) [added] doc for react 0.14 + old 0.13
# 0.4.0
- Added Size Props |Merge #5
- Fixed bug with refs
- Bumps deps
## 0.3.2
- Bump deps
## 0.3.1
- Added babel runtime to deps
- [#1] Removed unused use strict
- Bump deps
## 0.3.0
- Can now uses the recaptcha functions `getValue` `reset` directly from Wrapper without `getComponent` first.
- bump deps
## 0.2.2
- Bump react-async-script (bug 0.2.1)
## 0.2.1
- Small lint fixes
- Updated react-async-script
## 0.2.0
- Now loads the script using react-async-script! Usage is now way simpler
## 0.1.0
- Migrated to ES6
- Added Travis
- Added Babel
- Added Karma
- Added First test
## 0.0.1
- Initial commit of component

22
node_modules/react-google-recaptcha/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Hugo Dozois
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

6
node_modules/react-google-recaptcha/MIGRATION.md generated vendored Normal file
View File

@@ -0,0 +1,6 @@
# Migrations
## Migrate from 1.0 to 2.0
- __options.removeOnUnmount__: *REMOVED* This was only useful for the lang changes. Lang is now changed through the `hl` prop.
- __options.lang__: *REMOVED* Instead pass it as the `hl` prop on the component.

228
node_modules/react-google-recaptcha/README.md generated vendored Normal file
View File

@@ -0,0 +1,228 @@
# react-google-recaptcha
[![Build Status][ci.img]][ci.url] [![npm version][npm.img]][npm.url] [![npm downloads][npm.dl.img]][npm.dl.url]
[![Edit react-google-recaptcha example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/1y4zzjq37l)
React component for [Google reCAPTCHA v2][reCAPTCHA].
## Installation
```shell
npm install --save react-google-recaptcha
```
## Usage
All you need to do is [sign up for an API key pair][signup]. You will need the client key then you can use `<ReCAPTCHA />`.
The default usage imports a wrapped component that loads the google recaptcha script asynchronously then instantiates a `reCAPTCHA` the user can then interact with.
Code Example:
```jsx
import ReCAPTCHA from "react-google-recaptcha";
function onChange(value) {
console.log("Captcha value:", value);
}
ReactDOM.render(
<ReCAPTCHA
sitekey="Your client site key"
onChange={onChange}
/>,
document.body
);
```
### Component Props
Properties used to customise the rendering:
| Name | Type | Description |
|:---- | ---- | ------ |
| asyncScriptOnLoad | func | *optional* callback when the google recaptcha script has been loaded |
| badge | enum | *optional* `bottomright`, `bottomleft` or `inline`. Positions reCAPTCHA badge. *Only for invisible reCAPTCHA* |
| hl | string | *optional* set the hl parameter, which allows the captcha to be used from different languages, see [reCAPTCHA hl] |
| isolated | bool | *optional* For plugin owners to not interfere with existing reCAPTCHA installations on a page. If true, this reCAPTCHA instance will be part of a separate ID space. *(__default:__ `false`)*
| onChange | func | The function to be called when the user successfully completes the captcha |
| onErrored | func | *optional* callback when the challenge errored, most likely due to network issues. |
| onExpired | func | *optional* callback when the challenge is expired and has to be redone by user. By default it will call the onChange with null to signify expired callback. |
| sitekey | string | The API client key |
| size | enum | *optional* `compact`, `normal` or `invisible`. This allows you to change the size or do an invisible captcha |
| stoken | string | *optional* set the stoken parameter, which allows the captcha to be used from different domains, see [reCAPTCHA secure-token] |
| tabindex | number | *optional* The tabindex on the element *(__default:__ `0`)*
| type | enum | *optional* `image` or `audio` The type of initial captcha *(__defaults:__ `image`)*
| theme | enum | *optional* `light` or `dark` The theme of the widget *(__defaults:__ `light`)*. See [example][docs_theme]
### Component Instance API
The component instance also has some utility functions that can be called. These can be accessed via `ref`.
- `getValue()` returns the value of the captcha field
- `getWidgetId()` returns the recaptcha widget Id
- `reset()` forces reset. See the [JavaScript API doc][js_api]
- `execute()` programmatically invoke the challenge
- need to call when using `"invisible"` reCAPTCHA - [example below](#invisible-recaptcha)
- `executeAsync()` programmatically invoke the challenge and return a promise that resolves to the token or errors(if encountered).
- alternative approach to `execute()` in combination with the `onChange()` prop - [example below](#invisible-recaptcha)
Example:
```javascript
const recaptchaRef = React.createRef();
...
onSubmit = () => {
const recaptchaValue = recaptchaRef.current.getValue();
this.props.onSubmit(recaptchaValue);
}
render() {
return (
<form onSubmit={this.onSubmit} >
<ReCAPTCHA
ref={recaptchaRef}
sitekey="Your client site key"
onChange={onChange}
/>
</form>
)
}
```
### Invisible reCAPTCHA
[▶ Codesandbox invisible example](https://codesandbox.io/s/gifted-cache-10q74jj593)
See the [reCAPTCHA documentation](https://developers.google.com/recaptcha/docs/invisible) to see how to configure it.
With the invisible option, you need to handle things a bit differently. You will need to call the `execute` method yourself.
```jsx
import ReCAPTCHA from "react-google-recaptcha";
const recaptchaRef = React.createRef();
ReactDOM.render(
<form onSubmit={() => { recaptchaRef.current.execute(); }}>
<ReCAPTCHA
ref={recaptchaRef}
size="invisible"
sitekey="Your client site key"
onChange={onChange}
/>
</form>,
document.body
);
```
Additionally, you can use the `executeAsync` method to use a promise based approach.
```jsx
import ReCAPTCHA from "react-google-recaptcha";
const ReCAPTCHAForm = (props) => {
const recaptchaRef = React.useRef();
const onSubmitWithReCAPTCHA = async () => {
const token = await recaptchaRef.current.executeAsync();
// apply to form data
}
return (
<form onSubmit={onSubmitWithReCAPTCHA}>
<ReCAPTCHA
ref={recaptchaRef}
size="invisible"
sitekey="Your client site key"
/>
</form>
)
}
ReactDOM.render(
<ReCAPTCHAForm />,
document.body
);
```
### Advanced usage
#### Global properties used by reCaptcha
__useRecaptchaNet__: If google.com is blocked, you can set `useRecaptchaNet` to `true` so that the component uses recaptcha.net instead.
__enterprise__: if you want to use Google Enterprise Recaptcha, instead of the free version, set `enterprise` to `true`.
Example global properties:
```js
window.recaptchaOptions = {
useRecaptchaNet: true,
enterprise: true,
};
```
### CSP Nonce support
```js
window.recaptchaOptions = {
nonce: document.querySelector('meta[name=\'csp-nonce\']').getAttribute('content'),
};
```
#### ReCaptcha loading google recaptcha script manually
You can also use the barebone components doing the following. Using that component will oblige you to manage the grecaptcha dep and load the script by yourself.
```jsx
import { ReCAPTCHA } from "react-google-recaptcha";
const grecaptchaObject = window.grecaptcha // You must provide access to the google grecaptcha object.
render(
<ReCAPTCHA
ref={(r) => this.recaptcha = r}
sitekey="Your client site key"
grecaptcha={grecaptchaObject}
/>,
document.body
);
```
#### Hiding the Recaptcha
According to the [google docs](https://developers.google.com/recaptcha/docs/faq#id-like-to-hide-the-recaptcha-badge.-what-is-allowed) you are allowed to hide the badge as long as you include the reCAPTCHA branding visibly in the user flow. Please include the following text:
```
This site is protected by reCAPTCHA and the Google
<a href="https://policies.google.com/privacy">Privacy Policy</a> and
<a href="https://policies.google.com/terms">Terms of Service</a> apply.
```
If you wish to hide the badge you must add:
```
.grecaptcha-badge { visibility: hidden; }
```
to your css.
[ci.img]: https://github.com/dozoisch/react-google-recaptcha/actions/workflows/standard-ci.yml/badge.svg?branch=master
[ci.url]: https://github.com/dozoisch/react-google-recaptcha/actions/workflows/standard-ci.yml
[npm.img]: https://badge.fury.io/js/react-google-recaptcha.svg
[npm.url]: http://badge.fury.io/js/react-google-recaptcha
[npm.dl.img]: https://img.shields.io/npm/dm/react-google-recaptcha.svg
[npm.dl.url]: https://www.npmjs.com/package/react-google-recaptcha
[reCAPTCHA]: https://developers.google.com/recaptcha/docs/display
[signup]: http://www.google.com/recaptcha/admin
[docs]: https://developers.google.com/recaptcha
[docs_theme]: https://developers.google.com/recaptcha/docs/faq#can-i-customize-the-recaptcha-widget
[js_api]: https://developers.google.com/recaptcha/docs/display#js_api
[rb]: https://github.com/react-bootstrap/react-bootstrap/
[reCAPTCHA secure-token]: https://developers.google.com/recaptcha/docs/secure_token
[reCAPTCHA hl]: https://developers.google.com/recaptcha/docs/language

177
node_modules/react-google-recaptcha/jest.config.js generated vendored Normal file
View File

@@ -0,0 +1,177 @@
/* eslint-env node */
"use strict";
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after the first failure
// bail: false,
// Respect "browser" field in package.json when resolving modules
// browser: false,
// The directory where Jest should store its cached dependency information
// cacheDirectory: "/var/folders/l7/cx7wgg653n7619h3gf_zjjzr0000gn/T/jest_dx",
// Automatically clear mock calls and instances between every test
clearMocks: true,
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,
// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: null,
// The directory where Jest should output its coverage files
// coverageDirectory: null,
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: null,
// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
// Force coverage collection from ignored files usin a array of glob patterns
// forceCoverageMatch: [],
// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: null,
// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: null,
// A set of global variables that need to be available in all test environments
// globals: {},
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "json",
// "jsx",
// "node"
// ],
// A map from regular expressions to module names that allow to stub out resources with a single module
// moduleNameMapper: {},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
// Activates notifications for test results
// notify: false,
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "always",
// A preset that is used as a base for Jest's configuration
// preset: null,
// Run tests from one or more projects
// projects: null,
// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
// Automatically reset mock state between every test
// resetMocks: false,
// Reset the module registry before running each individual test
// resetModules: false,
// A path to a custom resolver
// resolver: null,
// Automatically restore mock state between every test
// restoreMocks: false,
// The root directory that Jest should scan for tests and modules within
// rootDir: null,
// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],
// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],
// The path to a module that runs some code to configure or set up the testing framework before each test
// setupTestFrameworkScriptFile: null,
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
// The test environment that will be used for testing
testEnvironment: "jsdom",
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
// Adds a location field to test results
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
testMatch: ["**/?(*.)+(spec|test).js?(x)"],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ["/node_modules/", "webpack.config.test.js"],
// The regexp pattern Jest uses to detect test files
// testRegex: "",
// This option allows the use of a custom results processor
// testResultsProcessor: null,
// This option allows use of a custom test runner
// testRunner: "jasmine2",
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",
// A map from regular expressions to paths to transformers
// transform: null,
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/"
// ],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
// Indicates whether each individual test should be reported during the run
// verbose: null,
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
// Whether to use watchman for file crawling
// watchman: true,
};

4
node_modules/react-google-recaptcha/lib/esm/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import RecaptchaWrapper from "./recaptcha-wrapper";
import ReCAPTCHA from "./recaptcha";
export default RecaptchaWrapper;
export { ReCAPTCHA };

View File

@@ -0,0 +1,22 @@
import ReCAPTCHA from "./recaptcha";
import makeAsyncScriptLoader from "react-async-script";
var callbackName = "onloadcallback";
var globalName = "grecaptcha";
function getOptions() {
return typeof window !== "undefined" && window.recaptchaOptions || {};
}
function getURL() {
var dynamicOptions = getOptions();
var hostname = dynamicOptions.useRecaptchaNet ? "recaptcha.net" : "www.google.com";
if (dynamicOptions.enterprise) {
return "https://" + hostname + "/recaptcha/enterprise.js?onload=" + callbackName + "&render=explicit";
}
return "https://" + hostname + "/recaptcha/api.js?onload=" + callbackName + "&render=explicit";
}
export default makeAsyncScriptLoader(getURL, {
callbackName: callbackName,
globalName: globalName,
attributes: getOptions().nonce ? {
nonce: getOptions().nonce
} : {}
})(ReCAPTCHA);

View File

@@ -0,0 +1,181 @@
var _excluded = ["sitekey", "onChange", "theme", "type", "tabindex", "onExpired", "onErrored", "size", "stoken", "grecaptcha", "badge", "hl", "isolated"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
import * as React from "react";
import PropTypes from "prop-types";
var ReCAPTCHA = /*#__PURE__*/function (_React$Component) {
_inheritsLoose(ReCAPTCHA, _React$Component);
function ReCAPTCHA() {
var _this;
_this = _React$Component.call(this) || this;
_this.handleExpired = _this.handleExpired.bind(_assertThisInitialized(_this));
_this.handleErrored = _this.handleErrored.bind(_assertThisInitialized(_this));
_this.handleChange = _this.handleChange.bind(_assertThisInitialized(_this));
_this.handleRecaptchaRef = _this.handleRecaptchaRef.bind(_assertThisInitialized(_this));
return _this;
}
var _proto = ReCAPTCHA.prototype;
_proto.getCaptchaFunction = function getCaptchaFunction(fnName) {
if (this.props.grecaptcha) {
if (this.props.grecaptcha.enterprise) {
return this.props.grecaptcha.enterprise[fnName];
}
return this.props.grecaptcha[fnName];
}
return null;
};
_proto.getValue = function getValue() {
var getResponse = this.getCaptchaFunction("getResponse");
if (getResponse && this._widgetId !== undefined) {
return getResponse(this._widgetId);
}
return null;
};
_proto.getWidgetId = function getWidgetId() {
if (this.props.grecaptcha && this._widgetId !== undefined) {
return this._widgetId;
}
return null;
};
_proto.execute = function execute() {
var execute = this.getCaptchaFunction("execute");
if (execute && this._widgetId !== undefined) {
return execute(this._widgetId);
} else {
this._executeRequested = true;
}
};
_proto.executeAsync = function executeAsync() {
var _this2 = this;
return new Promise(function (resolve, reject) {
_this2.executionResolve = resolve;
_this2.executionReject = reject;
_this2.execute();
});
};
_proto.reset = function reset() {
var resetter = this.getCaptchaFunction("reset");
if (resetter && this._widgetId !== undefined) {
resetter(this._widgetId);
}
};
_proto.forceReset = function forceReset() {
var resetter = this.getCaptchaFunction("reset");
if (resetter) {
resetter();
}
};
_proto.handleExpired = function handleExpired() {
if (this.props.onExpired) {
this.props.onExpired();
} else {
this.handleChange(null);
}
};
_proto.handleErrored = function handleErrored() {
if (this.props.onErrored) {
this.props.onErrored();
}
if (this.executionReject) {
this.executionReject();
delete this.executionResolve;
delete this.executionReject;
}
};
_proto.handleChange = function handleChange(token) {
if (this.props.onChange) {
this.props.onChange(token);
}
if (this.executionResolve) {
this.executionResolve(token);
delete this.executionReject;
delete this.executionResolve;
}
};
_proto.explicitRender = function explicitRender() {
var render = this.getCaptchaFunction("render");
if (render && this._widgetId === undefined) {
var wrapper = document.createElement("div");
this._widgetId = render(wrapper, {
sitekey: this.props.sitekey,
callback: this.handleChange,
theme: this.props.theme,
type: this.props.type,
tabindex: this.props.tabindex,
"expired-callback": this.handleExpired,
"error-callback": this.handleErrored,
size: this.props.size,
stoken: this.props.stoken,
hl: this.props.hl,
badge: this.props.badge,
isolated: this.props.isolated
});
this.captcha.appendChild(wrapper);
}
if (this._executeRequested && this.props.grecaptcha && this._widgetId !== undefined) {
this._executeRequested = false;
this.execute();
}
};
_proto.componentDidMount = function componentDidMount() {
this.explicitRender();
};
_proto.componentDidUpdate = function componentDidUpdate() {
this.explicitRender();
};
_proto.handleRecaptchaRef = function handleRecaptchaRef(elem) {
this.captcha = elem;
};
_proto.render = function render() {
// consume properties owned by the reCATPCHA, pass the rest to the div so the user can style it.
/* eslint-disable no-unused-vars */
var _this$props = this.props,
sitekey = _this$props.sitekey,
onChange = _this$props.onChange,
theme = _this$props.theme,
type = _this$props.type,
tabindex = _this$props.tabindex,
onExpired = _this$props.onExpired,
onErrored = _this$props.onErrored,
size = _this$props.size,
stoken = _this$props.stoken,
grecaptcha = _this$props.grecaptcha,
badge = _this$props.badge,
hl = _this$props.hl,
isolated = _this$props.isolated,
childProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
/* eslint-enable no-unused-vars */
return /*#__PURE__*/React.createElement("div", _extends({}, childProps, {
ref: this.handleRecaptchaRef
}));
};
return ReCAPTCHA;
}(React.Component);
export { ReCAPTCHA as default };
ReCAPTCHA.displayName = "ReCAPTCHA";
ReCAPTCHA.propTypes = {
sitekey: PropTypes.string.isRequired,
onChange: PropTypes.func,
grecaptcha: PropTypes.object,
theme: PropTypes.oneOf(["dark", "light"]),
type: PropTypes.oneOf(["image", "audio"]),
tabindex: PropTypes.number,
onExpired: PropTypes.func,
onErrored: PropTypes.func,
size: PropTypes.oneOf(["compact", "normal", "invisible"]),
stoken: PropTypes.string,
hl: PropTypes.string,
badge: PropTypes.oneOf(["bottomright", "bottomleft", "inline"]),
isolated: PropTypes.bool
};
ReCAPTCHA.defaultProps = {
onChange: function onChange() {},
theme: "light",
type: "image",
tabindex: 0,
size: "normal",
badge: "bottomright"
};

10
node_modules/react-google-recaptcha/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
"use strict";
exports.__esModule = true;
exports["default"] = void 0;
var _recaptchaWrapper = _interopRequireDefault(require("./recaptcha-wrapper"));
var _recaptcha = _interopRequireDefault(require("./recaptcha"));
exports.ReCAPTCHA = _recaptcha["default"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _default = _recaptchaWrapper["default"];
exports["default"] = _default;

View File

@@ -0,0 +1,28 @@
"use strict";
exports.__esModule = true;
exports["default"] = void 0;
var _recaptcha = _interopRequireDefault(require("./recaptcha"));
var _reactAsyncScript = _interopRequireDefault(require("react-async-script"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var callbackName = "onloadcallback";
var globalName = "grecaptcha";
function getOptions() {
return typeof window !== "undefined" && window.recaptchaOptions || {};
}
function getURL() {
var dynamicOptions = getOptions();
var hostname = dynamicOptions.useRecaptchaNet ? "recaptcha.net" : "www.google.com";
if (dynamicOptions.enterprise) {
return "https://" + hostname + "/recaptcha/enterprise.js?onload=" + callbackName + "&render=explicit";
}
return "https://" + hostname + "/recaptcha/api.js?onload=" + callbackName + "&render=explicit";
}
var _default = (0, _reactAsyncScript["default"])(getURL, {
callbackName: callbackName,
globalName: globalName,
attributes: getOptions().nonce ? {
nonce: getOptions().nonce
} : {}
})(_recaptcha["default"]);
exports["default"] = _default;

188
node_modules/react-google-recaptcha/lib/recaptcha.js generated vendored Normal file
View File

@@ -0,0 +1,188 @@
"use strict";
exports.__esModule = true;
exports["default"] = void 0;
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _excluded = ["sitekey", "onChange", "theme", "type", "tabindex", "onExpired", "onErrored", "size", "stoken", "grecaptcha", "badge", "hl", "isolated"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ReCAPTCHA = /*#__PURE__*/function (_React$Component) {
_inheritsLoose(ReCAPTCHA, _React$Component);
function ReCAPTCHA() {
var _this;
_this = _React$Component.call(this) || this;
_this.handleExpired = _this.handleExpired.bind(_assertThisInitialized(_this));
_this.handleErrored = _this.handleErrored.bind(_assertThisInitialized(_this));
_this.handleChange = _this.handleChange.bind(_assertThisInitialized(_this));
_this.handleRecaptchaRef = _this.handleRecaptchaRef.bind(_assertThisInitialized(_this));
return _this;
}
var _proto = ReCAPTCHA.prototype;
_proto.getCaptchaFunction = function getCaptchaFunction(fnName) {
if (this.props.grecaptcha) {
if (this.props.grecaptcha.enterprise) {
return this.props.grecaptcha.enterprise[fnName];
}
return this.props.grecaptcha[fnName];
}
return null;
};
_proto.getValue = function getValue() {
var getResponse = this.getCaptchaFunction("getResponse");
if (getResponse && this._widgetId !== undefined) {
return getResponse(this._widgetId);
}
return null;
};
_proto.getWidgetId = function getWidgetId() {
if (this.props.grecaptcha && this._widgetId !== undefined) {
return this._widgetId;
}
return null;
};
_proto.execute = function execute() {
var execute = this.getCaptchaFunction("execute");
if (execute && this._widgetId !== undefined) {
return execute(this._widgetId);
} else {
this._executeRequested = true;
}
};
_proto.executeAsync = function executeAsync() {
var _this2 = this;
return new Promise(function (resolve, reject) {
_this2.executionResolve = resolve;
_this2.executionReject = reject;
_this2.execute();
});
};
_proto.reset = function reset() {
var resetter = this.getCaptchaFunction("reset");
if (resetter && this._widgetId !== undefined) {
resetter(this._widgetId);
}
};
_proto.forceReset = function forceReset() {
var resetter = this.getCaptchaFunction("reset");
if (resetter) {
resetter();
}
};
_proto.handleExpired = function handleExpired() {
if (this.props.onExpired) {
this.props.onExpired();
} else {
this.handleChange(null);
}
};
_proto.handleErrored = function handleErrored() {
if (this.props.onErrored) {
this.props.onErrored();
}
if (this.executionReject) {
this.executionReject();
delete this.executionResolve;
delete this.executionReject;
}
};
_proto.handleChange = function handleChange(token) {
if (this.props.onChange) {
this.props.onChange(token);
}
if (this.executionResolve) {
this.executionResolve(token);
delete this.executionReject;
delete this.executionResolve;
}
};
_proto.explicitRender = function explicitRender() {
var render = this.getCaptchaFunction("render");
if (render && this._widgetId === undefined) {
var wrapper = document.createElement("div");
this._widgetId = render(wrapper, {
sitekey: this.props.sitekey,
callback: this.handleChange,
theme: this.props.theme,
type: this.props.type,
tabindex: this.props.tabindex,
"expired-callback": this.handleExpired,
"error-callback": this.handleErrored,
size: this.props.size,
stoken: this.props.stoken,
hl: this.props.hl,
badge: this.props.badge,
isolated: this.props.isolated
});
this.captcha.appendChild(wrapper);
}
if (this._executeRequested && this.props.grecaptcha && this._widgetId !== undefined) {
this._executeRequested = false;
this.execute();
}
};
_proto.componentDidMount = function componentDidMount() {
this.explicitRender();
};
_proto.componentDidUpdate = function componentDidUpdate() {
this.explicitRender();
};
_proto.handleRecaptchaRef = function handleRecaptchaRef(elem) {
this.captcha = elem;
};
_proto.render = function render() {
// consume properties owned by the reCATPCHA, pass the rest to the div so the user can style it.
/* eslint-disable no-unused-vars */
var _this$props = this.props,
sitekey = _this$props.sitekey,
onChange = _this$props.onChange,
theme = _this$props.theme,
type = _this$props.type,
tabindex = _this$props.tabindex,
onExpired = _this$props.onExpired,
onErrored = _this$props.onErrored,
size = _this$props.size,
stoken = _this$props.stoken,
grecaptcha = _this$props.grecaptcha,
badge = _this$props.badge,
hl = _this$props.hl,
isolated = _this$props.isolated,
childProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
/* eslint-enable no-unused-vars */
return /*#__PURE__*/React.createElement("div", _extends({}, childProps, {
ref: this.handleRecaptchaRef
}));
};
return ReCAPTCHA;
}(React.Component);
exports["default"] = ReCAPTCHA;
ReCAPTCHA.displayName = "ReCAPTCHA";
ReCAPTCHA.propTypes = {
sitekey: _propTypes["default"].string.isRequired,
onChange: _propTypes["default"].func,
grecaptcha: _propTypes["default"].object,
theme: _propTypes["default"].oneOf(["dark", "light"]),
type: _propTypes["default"].oneOf(["image", "audio"]),
tabindex: _propTypes["default"].number,
onExpired: _propTypes["default"].func,
onErrored: _propTypes["default"].func,
size: _propTypes["default"].oneOf(["compact", "normal", "invisible"]),
stoken: _propTypes["default"].string,
hl: _propTypes["default"].string,
badge: _propTypes["default"].oneOf(["bottomright", "bottomleft", "inline"]),
isolated: _propTypes["default"].bool
};
ReCAPTCHA.defaultProps = {
onChange: function onChange() {},
theme: "light",
type: "image",
tabindex: 0,
size: "normal",
badge: "bottomright"
};

61
node_modules/react-google-recaptcha/package.json generated vendored Normal file
View File

@@ -0,0 +1,61 @@
{
"name": "react-google-recaptcha",
"version": "3.1.0",
"description": "React Component Wrapper for Google reCAPTCHA",
"main": "lib/index.js",
"module": "lib/esm/index.js",
"directories": {
"lib": "lib/"
},
"scripts": {
"build": "rm -rf lib && npm run build:cjs && npm run build:esm",
"build:cjs": "babel src --out-dir lib",
"build:esm": "cross-env BABEL_ENV=esm babel src --out-dir lib/esm",
"prepare": "npm run build",
"pretty": "prettier --write src/*.js ./*.js test/*.js",
"lint": "eslint ./",
"lint:fix": "eslint ./ --fix",
"test": "cross-env BABEL_ENV=development jest"
},
"repository": {
"type": "git",
"url": "https://github.com/dozoisch/react-google-recaptcha.git"
},
"keywords": [
"react",
"react-component",
"captcha",
"recaptcha",
"google-recaptcha"
],
"author": "Hugo Dozois <hugo@dozoisch.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/dozoisch/react-google-recaptcha/issues"
},
"homepage": "https://github.com/dozoisch/react-google-recaptcha",
"peerDependencies": {
"react": ">=16.4.1"
},
"devDependencies": {
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.6",
"@babel/preset-env": "^7.19.4",
"@babel/preset-react": "^7.18.6",
"@testing-library/react": "^13.4.0",
"cross-env": "^7.0.3",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.31.10",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"prettier": "^2.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"dependencies": {
"prop-types": "^15.5.0",
"react-async-script": "^1.2.0"
}
}

5
node_modules/react-google-recaptcha/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import RecaptchaWrapper from "./recaptcha-wrapper";
import ReCAPTCHA from "./recaptcha";
export default RecaptchaWrapper;
export { ReCAPTCHA };

View File

@@ -0,0 +1,24 @@
import ReCAPTCHA from "./recaptcha";
import makeAsyncScriptLoader from "react-async-script";
const callbackName = "onloadcallback";
const globalName = "grecaptcha";
function getOptions() {
return (typeof window !== "undefined" && window.recaptchaOptions) || {};
}
function getURL() {
const dynamicOptions = getOptions();
const hostname = dynamicOptions.useRecaptchaNet ? "recaptcha.net" : "www.google.com";
if (dynamicOptions.enterprise) {
return `https://${hostname}/recaptcha/enterprise.js?onload=${callbackName}&render=explicit`;
}
return `https://${hostname}/recaptcha/api.js?onload=${callbackName}&render=explicit`;
}
export default makeAsyncScriptLoader(getURL, {
callbackName,
globalName,
attributes: getOptions().nonce ? { nonce: getOptions().nonce } : {},
})(ReCAPTCHA);

184
node_modules/react-google-recaptcha/src/recaptcha.js generated vendored Normal file
View File

@@ -0,0 +1,184 @@
import * as React from "react";
import PropTypes from "prop-types";
export default class ReCAPTCHA extends React.Component {
constructor() {
super();
this.handleExpired = this.handleExpired.bind(this);
this.handleErrored = this.handleErrored.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleRecaptchaRef = this.handleRecaptchaRef.bind(this);
}
getCaptchaFunction(fnName) {
if (this.props.grecaptcha) {
if (this.props.grecaptcha.enterprise) {
return this.props.grecaptcha.enterprise[fnName];
}
return this.props.grecaptcha[fnName];
}
return null;
}
getValue() {
const getResponse = this.getCaptchaFunction("getResponse");
if (getResponse && this._widgetId !== undefined) {
return getResponse(this._widgetId);
}
return null;
}
getWidgetId() {
if (this.props.grecaptcha && this._widgetId !== undefined) {
return this._widgetId;
}
return null;
}
execute() {
const execute = this.getCaptchaFunction("execute");
if (execute && this._widgetId !== undefined) {
return execute(this._widgetId);
} else {
this._executeRequested = true;
}
}
executeAsync() {
return new Promise((resolve, reject) => {
this.executionResolve = resolve;
this.executionReject = reject;
this.execute();
});
}
reset() {
const resetter = this.getCaptchaFunction("reset");
if (resetter && this._widgetId !== undefined) {
resetter(this._widgetId);
}
}
forceReset() {
const resetter = this.getCaptchaFunction("reset");
if (resetter) {
resetter();
}
}
handleExpired() {
if (this.props.onExpired) {
this.props.onExpired();
} else {
this.handleChange(null);
}
}
handleErrored() {
if (this.props.onErrored) {
this.props.onErrored();
}
if (this.executionReject) {
this.executionReject();
delete this.executionResolve;
delete this.executionReject;
}
}
handleChange(token) {
if (this.props.onChange) {
this.props.onChange(token);
}
if (this.executionResolve) {
this.executionResolve(token);
delete this.executionReject;
delete this.executionResolve;
}
}
explicitRender() {
const render = this.getCaptchaFunction("render");
if (render && this._widgetId === undefined) {
const wrapper = document.createElement("div");
this._widgetId = render(wrapper, {
sitekey: this.props.sitekey,
callback: this.handleChange,
theme: this.props.theme,
type: this.props.type,
tabindex: this.props.tabindex,
"expired-callback": this.handleExpired,
"error-callback": this.handleErrored,
size: this.props.size,
stoken: this.props.stoken,
hl: this.props.hl,
badge: this.props.badge,
isolated: this.props.isolated,
});
this.captcha.appendChild(wrapper);
}
if (this._executeRequested && this.props.grecaptcha && this._widgetId !== undefined) {
this._executeRequested = false;
this.execute();
}
}
componentDidMount() {
this.explicitRender();
}
componentDidUpdate() {
this.explicitRender();
}
handleRecaptchaRef(elem) {
this.captcha = elem;
}
render() {
// consume properties owned by the reCATPCHA, pass the rest to the div so the user can style it.
/* eslint-disable no-unused-vars */
const {
sitekey,
onChange,
theme,
type,
tabindex,
onExpired,
onErrored,
size,
stoken,
grecaptcha,
badge,
hl,
isolated,
...childProps
} = this.props;
/* eslint-enable no-unused-vars */
return <div {...childProps} ref={this.handleRecaptchaRef} />;
}
}
ReCAPTCHA.displayName = "ReCAPTCHA";
ReCAPTCHA.propTypes = {
sitekey: PropTypes.string.isRequired,
onChange: PropTypes.func,
grecaptcha: PropTypes.object,
theme: PropTypes.oneOf(["dark", "light"]),
type: PropTypes.oneOf(["image", "audio"]),
tabindex: PropTypes.number,
onExpired: PropTypes.func,
onErrored: PropTypes.func,
size: PropTypes.oneOf(["compact", "normal", "invisible"]),
stoken: PropTypes.string,
hl: PropTypes.string,
badge: PropTypes.oneOf(["bottomright", "bottomleft", "inline"]),
isolated: PropTypes.bool,
};
ReCAPTCHA.defaultProps = {
onChange: () => {},
theme: "light",
type: "image",
tabindex: 0,
size: "normal",
badge: "bottomright",
};