react-google-invisible-recaptcha
Advanced tools
Comparing version 0.2.11 to 0.2.12
@@ -33,3 +33,3 @@ 'use strict'; | ||
var injectScript = function injectScript(locale) { | ||
var injectScript = function injectScript(locale, nonce) { | ||
window.GoogleRecaptchaLoaded = function () { | ||
@@ -43,10 +43,11 @@ while (renderers.length) { | ||
var script = document.createElement('script'); | ||
script.id = 'recaptcha'; | ||
script.src = 'https://www.google.com/recaptcha/api.js?hl=' + locale + '&onload=GoogleRecaptchaLoaded&render=explicit'; | ||
script.type = 'text/javascript'; | ||
script.async = true; | ||
script.defer = true; | ||
script.id = 'recaptcha'; | ||
script.onerror = function (error) { | ||
throw error; | ||
}; | ||
script.src = 'https://www.google.com/recaptcha/api.js?' + (locale && 'hl=' + locale) + '&onload=GoogleRecaptchaLoaded&render=explicit'; | ||
script.type = 'text/javascript'; | ||
nonce && script.setAttribute("nonce", nonce); | ||
document.body.appendChild(script); | ||
@@ -70,10 +71,11 @@ }; | ||
var _props = this.props, | ||
sitekey = _props.sitekey, | ||
badge = _props.badge, | ||
locale = _props.locale, | ||
badge = _props.badge, | ||
tabindex = _props.tabindex, | ||
nonce = _props.nonce, | ||
onExpired = _props.onExpired, | ||
onError = _props.onError, | ||
onLoaded = _props.onLoaded, | ||
onResolved = _props.onResolved, | ||
onError = _props.onError, | ||
onExpired = _props.onExpired, | ||
onLoaded = _props.onLoaded; | ||
sitekey = _props.sitekey, | ||
tabindex = _props.tabindex; | ||
@@ -91,9 +93,9 @@ | ||
var recaptchaId = window.grecaptcha.render(wrapper, { | ||
sitekey: sitekey, | ||
size: 'invisible', | ||
badge: badge, | ||
tabindex: tabindex, | ||
callback: _this2.callbackName, | ||
'error-callback': onError, | ||
'expired-callback': onExpired | ||
'expired-callback': onExpired, | ||
sitekey: sitekey, | ||
size: 'invisible', | ||
tabindex: tabindex | ||
}); | ||
@@ -118,3 +120,3 @@ _this2.execute = function () { | ||
if (!document.querySelector('#recaptcha')) { | ||
injectScript(locale); | ||
injectScript(locale, nonce); | ||
} | ||
@@ -155,23 +157,24 @@ } | ||
GoogleRecaptcha.propTypes = { | ||
sitekey: _propTypes2.default.string.isRequired, | ||
badge: _propTypes2.default.oneOf(['bottomright', 'bottomleft', 'inline']), | ||
locale: _propTypes2.default.string, | ||
badge: _propTypes2.default.oneOf(['bottomright', 'bottomleft', 'inline']), | ||
tabindex: _propTypes2.default.number, | ||
nonce: _propTypes2.default.string, | ||
onExpired: _propTypes2.default.func, | ||
onError: _propTypes2.default.func, | ||
onResolved: _propTypes2.default.func, | ||
onError: _propTypes2.default.func, | ||
onExpired: _propTypes2.default.func, | ||
onLoaded: _propTypes2.default.func, | ||
style: _propTypes2.default.object | ||
sitekey: _propTypes2.default.string.isRequired, | ||
style: _propTypes2.default.object, | ||
tabindex: _propTypes2.default.number | ||
}; | ||
GoogleRecaptcha.defaultProps = { | ||
locale: 'en', | ||
badge: 'bottomright', | ||
tabindex: 0, | ||
locale: '', | ||
onExpired: function onExpired() {}, | ||
onError: function onError() {}, | ||
onLoaded: function onLoaded() {}, | ||
onResolved: function onResolved() {}, | ||
onError: function onError() {}, | ||
onExpired: function onExpired() {}, | ||
onLoaded: function onLoaded() {} | ||
tabindex: 0 | ||
}; | ||
exports.default = GoogleRecaptcha; |
{ | ||
"name": "react-google-invisible-recaptcha", | ||
"author": "szchenghuang <szchenghuang@gmail.com>", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"description": "A React component which is simply interested in Google invisible reCaptcha.", | ||
@@ -31,13 +31,13 @@ "main": "index.js", | ||
"dependencies": { | ||
"prop-types": "^15.6.0", | ||
"uuid": "^3.1.0" | ||
"prop-types": "^15.6.2", | ||
"uuid": "^3.3.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "16.*" | ||
"react": "16.* || ^17.0.0-0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.0.1", | ||
"babel-loader": "^7.1.2", | ||
"babel-core": "^6.26.3", | ||
"babel-eslint": "^8.2.6", | ||
"babel-loader": "^7.1.5", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
@@ -48,16 +48,16 @@ "babel-preset-es2015": "^6.24.1", | ||
"babel-runtime": "^6.26.0", | ||
"eslint": "^4.9.0", | ||
"eslint": "^4.19.1", | ||
"eslint-config-airbnb": "^16.1.0", | ||
"eslint-config-google": "^0.9.1", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-import": "^2.8.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.2", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jsx-a11y": "^6.1.2", | ||
"eslint-plugin-node": "^5.2.1", | ||
"eslint-plugin-promise": "^3.6.0", | ||
"eslint-plugin-react": "^7.4.0", | ||
"eslint-plugin-standard": "^3.0.1", | ||
"eslint-plugin-promise": "^3.8.0", | ||
"eslint-plugin-react": "^7.12.3", | ||
"eslint-plugin-standard": "^3.1.0", | ||
"html-webpack-plugin": "^2.30.1", | ||
"react": "^16.3.1", | ||
"react-dom": "^16.3.1", | ||
"webpack": "^3.8.1" | ||
"react": "^16.7.0", | ||
"react-dom": "^16.7.0", | ||
"webpack": "^3.12.0" | ||
}, | ||
@@ -64,0 +64,0 @@ "directories": { |
@@ -0,1 +1,23 @@ | ||
# Migration from 0.x to 1.0.0 | ||
Version 1.0.0 is going to have breaking changes in the API: | ||
```js | ||
// Version 0.x | ||
<Recaptcha ref={ref => this.recaptcha = ref} ... /> | ||
// this.recaptcha.execute invokes the reCAPTCHA check. | ||
// Version 1.0.0 | ||
const refCaptcha = React.useRef(null) // or React.createRef(). | ||
<Recaptcha ref={refRecaptcha} ... /> | ||
// refRecaptcha.current.callbacks.execute invokes the reCAPTCHA check. | ||
// ^^^^^^^^^^^^^^^^^^ | ||
``` | ||
It will support React hooks and Typescript out of the box. Navigate to the [versions][versions] page for the release candidates, say [1.0.0-rc.2][1.0.0-rc.2], and install by | ||
```sh | ||
npm i react-google-invisible-recaptcha@1.0.0-rc.2 | ||
``` | ||
# react-google-invisible-recaptcha # | ||
@@ -6,3 +28,3 @@ | ||
* Support multiple reCAPTCHA widgets on one page. | ||
* Vallina JS. | ||
* Vanilla JS. | ||
@@ -81,5 +103,5 @@ ## [Demo][demo] ## | ||
* badge: `bottomright`, `bottomleft`, or `inline`. **Default: bottomright.** | ||
* locale: in which language it speaks. **Default: en.** | ||
* badge: `bottomright`, `bottomleft`, or `inline`. **Default: bottomright.** | ||
* tabindex: tabindex of the challenge. **Default: 0.** | ||
* nonce: nonce included in the reCAPTCHA script tag. **Default: undefined.** | ||
* onResolved: callback when the recaptcha is resolved. **Default: noop.** | ||
@@ -90,2 +112,3 @@ * onError: callback when the recaptcha encounters an error. **Default: noop.** | ||
* style: custom CSS applied to the root node. **Default: undefined.** | ||
* tabindex: tabindex of the challenge. **Default: 0.** | ||
@@ -107,1 +130,3 @@ ## APIs ## | ||
[demo]: https://szchenghuang.github.io/react-google-invisible-recaptcha/ | ||
[versions]: https://www.npmjs.com/package/react-google-invisible-recaptcha?activeTab=versions | ||
[1.0.0-rc.2]: https://www.npmjs.com/package/react-google-invisible-recaptcha/v/1.0.0-rc.2 |
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
14302
145
129
+ Addedreact@17.0.2(transitive)
- Removedreact@16.14.0(transitive)
Updatedprop-types@^15.6.2
Updateduuid@^3.3.2