New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

reaptcha

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reaptcha - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

LICENSE

69

CHANGELOG.md

@@ -6,95 +6,82 @@ # Change Log

<a name="1.3.0"></a>
# [1.3.0](https://github.com/sarneeh/reaptcha/compare/v1.2.1...v1.3.0) (2018-07-22)
<a name="1.4.0"></a>
# [1.4.0](https://github.com/sarneeh/reaptcha/compare/v1.3.0...v1.4.0) (2018-10-25)
### Bug Fixes
* cleanup on unmount, removed deprecated react methods ([7c30ba4](https://github.com/sarneeh/reaptcha/commit/7c30ba4)), closes [#29](https://github.com/sarneeh/reaptcha/issues/29) [#28](https://github.com/sarneeh/reaptcha/issues/28) [#26](https://github.com/sarneeh/reaptcha/issues/26)
* do not inject script when one already present ([5db105d](https://github.com/sarneeh/reaptcha/commit/5db105d)), closes [#18](https://github.com/sarneeh/reaptcha/issues/18)
- ava tests on babel 7 ([4370fc6](https://github.com/sarneeh/reaptcha/commit/4370fc6))
- babel-loader version bump breaking build ([2ed8d81](https://github.com/sarneeh/reaptcha/commit/2ed8d81))
- better test when hl parameter is not specified ([eed56be](https://github.com/sarneeh/reaptcha/commit/eed56be))
- if hl param is specified, inject it in script ([2ad96a8](https://github.com/sarneeh/reaptcha/commit/2ad96a8))
- use props hl to init script to set up the correct language ([ebeb734](https://github.com/sarneeh/reaptcha/commit/ebeb734))
<a name="1.3.0"></a>
# [1.3.0](https://github.com/sarneeh/reaptcha/compare/v1.2.1...v1.3.0) (2018-07-22)
### Bug Fixes
- cleanup on unmount, removed deprecated react methods ([7c30ba4](https://github.com/sarneeh/reaptcha/commit/7c30ba4)), closes [#29](https://github.com/sarneeh/reaptcha/issues/29) [#28](https://github.com/sarneeh/reaptcha/issues/28) [#26](https://github.com/sarneeh/reaptcha/issues/26)
- do not inject script when one already present ([5db105d](https://github.com/sarneeh/reaptcha/commit/5db105d)), closes [#18](https://github.com/sarneeh/reaptcha/issues/18)
<a name="1.2.1"></a>
## [1.2.1](https://github.com/sarneeh/reaptcha/compare/v1.2.0...v1.2.1) (2018-07-04)
### Bug Fixes
* default container classname ([d2071fa](https://github.com/sarneeh/reaptcha/commit/d2071fa))
- default container classname ([d2071fa](https://github.com/sarneeh/reaptcha/commit/d2071fa))
<a name="1.2.0"></a>
<a name="1.2.0"></a>
# [1.2.0](https://github.com/sarneeh/reaptcha/compare/v1.1.0...v1.2.0) (2018-07-04)
### Features
* **render:** language support with `hl` ([7bd5e90](https://github.com/sarneeh/reaptcha/commit/7bd5e90))
- **render:** language support with `hl` ([7bd5e90](https://github.com/sarneeh/reaptcha/commit/7bd5e90))
<a name="1.1.0"></a>
<a name="1.1.0"></a>
# [1.1.0](https://github.com/sarneeh/reaptcha/compare/v1.0.0...v1.1.0) (2018-06-13)
### Features
* make package usable in script tags ([c5ac515](https://github.com/sarneeh/reaptcha/commit/c5ac515))
- make package usable in script tags ([c5ac515](https://github.com/sarneeh/reaptcha/commit/c5ac515))
<a name="1.1.0-beta.1"></a>
<a name="1.1.0-beta.1"></a>
# [1.1.0-beta.1](https://github.com/sarneeh/reaptcha/compare/v1.0.0...v1.1.0-beta.1) (2018-06-13)
### Features
* make package usable in script tags ([ac0733a](https://github.com/sarneeh/reaptcha/commit/ac0733a))
- make package usable in script tags ([ac0733a](https://github.com/sarneeh/reaptcha/commit/ac0733a))
<a name="1.1.0-beta.0"></a>
<a name="1.1.0-beta.0"></a>
# [1.1.0-beta.0](https://github.com/sarneeh/reaptcha/compare/v1.0.0...v1.1.0-beta.0) (2018-06-13)
### Features
* make package usable in script tags ([ac0733a](https://github.com/sarneeh/reaptcha/commit/ac0733a))
- make package usable in script tags ([ac0733a](https://github.com/sarneeh/reaptcha/commit/ac0733a))
<a name="1.0.0"></a>
<a name="1.0.0"></a>
# [1.0.0](https://github.com/sarneeh/reaptcha/compare/v0.1.0-beta.1...v1.0.0) (2018-06-13)
**Note:** Version bump only for package reaptcha
<a name="0.1.0-beta.1"></a>
# [0.1.0-beta.1](https://github.com/sarneeh/reaptcha/compare/v0.1.0-beta.0...v0.1.0-beta.1) (2018-06-13)
### Bug Fixes
* don't reset on execution ([8047e1e](https://github.com/sarneeh/reaptcha/commit/8047e1e))
* reset recaptcha before execute ([e75a355](https://github.com/sarneeh/reaptcha/commit/e75a355))
- don't reset on execution ([8047e1e](https://github.com/sarneeh/reaptcha/commit/8047e1e))
- reset recaptcha before execute ([e75a355](https://github.com/sarneeh/reaptcha/commit/e75a355))
<a name="0.1.0-beta.0"></a>
<a name="0.1.0-beta.0"></a>
# 0.1.0-beta.0 (2018-06-12)
**Note:** Version bump only for package reaptcha

@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["Reaptcha"] = factory(root["React"]);
})(global, function(__WEBPACK_EXTERNAL_MODULE__1__) {
})(global, function(__WEBPACK_EXTERNAL_MODULE__0__) {
return /******/ (function(modules) { // webpackBootstrap

@@ -95,3 +95,3 @@ /******/ // The module cache

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })

@@ -101,10 +101,18 @@ /************************************************************************/

/* 0 */
/***/ (function(module, exports, __webpack_require__) {
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: external {"amd":"react","commonjs":"react","commonjs2":"react","root":"React"}
var external_amd_react_commonjs_react_commonjs2_react_root_React_ = __webpack_require__(0);
var external_amd_react_commonjs_react_commonjs2_react_root_React_default = /*#__PURE__*/__webpack_require__.n(external_amd_react_commonjs_react_commonjs2_react_root_React_);
Object.defineProperty(exports, "__esModule", {
value: true
});
// CONCATENATED MODULE: ./utils/index.js
var getFilteredScripts = function getFilteredScripts(scriptSrc) {

@@ -120,3 +128,3 @@ return Array.from(document.scripts).filter(function (script) {

var isAnyScriptPresent = exports.isAnyScriptPresent = function isAnyScriptPresent(scripts) {
var isAnyScriptPresent = function isAnyScriptPresent(scripts) {
return scripts.reduce(function (isPresent, url) {

@@ -126,6 +134,4 @@ return isPresent ? isPresent : isScriptPresent(url);

};
var injectScript = exports.injectScript = function injectScript(scriptSrc) {
var injectScript = function injectScript(scriptSrc) {
var script = document.createElement('script');
script.async = true;

@@ -139,68 +145,62 @@ script.defer = true;

};
// CONCATENATED MODULE: ./index.js
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/***/ }),
/* 1 */
/***/ (function(module, exports) {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
"use strict";
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
Object.defineProperty(exports, "__esModule", {
value: true
});
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var _react = __webpack_require__(1);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _react2 = _interopRequireDefault(_react);
var _utils = __webpack_require__(0);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var USED_RECAPTCHA_SCRIPT_URL = 'https://recaptcha.net/recaptcha/api.js';
var RECAPTCHA_SCRIPTS_URLS = ['https://google.com/recaptcha', 'https://recaptcha.net/recaptcha', 'https://www.gstatic.com/recaptcha'];
var Reaptcha = function (_Component) {
var index_Reaptcha =
/*#__PURE__*/
function (_Component) {
_inherits(Reaptcha, _Component);
function Reaptcha(props) {
var _this;
_classCallCheck(this, Reaptcha);
var _this = _possibleConstructorReturn(this, (Reaptcha.__proto__ || Object.getPrototypeOf(Reaptcha)).call(this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(Reaptcha).call(this, props));
_this.container = null;
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "container", null);
_this._isAvailable = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_isAvailable", function () {
return Boolean(window && window.grecaptcha && window.grecaptcha.ready);
};
});
_this._inject = function () {
if (_this.props.inject && !(0, _utils.isAnyScriptPresent)(RECAPTCHA_SCRIPTS_URLS)) {
(0, _utils.injectScript)(USED_RECAPTCHA_SCRIPT_URL + '?render=explicit');
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_inject", function () {
if (_this.props.inject && !isAnyScriptPresent(RECAPTCHA_SCRIPTS_URLS)) {
var hlParam = _this.props.hl ? "&hl=".concat(_this.props.hl) : '';
var src = "".concat(USED_RECAPTCHA_SCRIPT_URL, "?render=explicit").concat(hlParam);
injectScript(src);
}
};
});
_this._prepare = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_prepare", function () {
var _this$props = _this.props,
explicit = _this$props.explicit,
onLoad = _this$props.onLoad;
window.grecaptcha.ready(function () {
_this.setState({ ready: true }, function () {
_this.setState({
ready: true
}, function () {
if (!explicit) {
_this.renderExplicitly();
}
if (onLoad) {

@@ -211,23 +211,23 @@ onLoad();

});
};
});
_this._renderRecaptcha = function (container, config) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_renderRecaptcha", function (container, config) {
return window.grecaptcha.render(container, config);
};
});
_this._resetRecaptcha = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_resetRecaptcha", function () {
return window.grecaptcha.reset(_this.state.instanceId);
};
});
_this._executeRecaptcha = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_executeRecaptcha", function () {
return window.grecaptcha.execute(_this.state.instanceId);
};
});
_this._stopTimer = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_stopTimer", function () {
if (_this.state.timer) {
clearInterval(_this.state.timer);
}
};
});
_this.componentDidMount = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "componentDidMount", function () {
_this._inject();

@@ -238,17 +238,21 @@

} else {
var _timer = setInterval(function () {
var timer = setInterval(function () {
if (_this._isAvailable()) {
_this._prepare();
_this._stopTimer();
}
}, 500);
_this.setState({ timer: _timer });
_this.setState({
timer: timer
});
}
};
});
_this.shouldComponentUpdate = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "shouldComponentUpdate", function () {
return !_this.state.rendered;
};
});
_this.componentWillUnmount = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "componentWillUnmount", function () {
_this._stopTimer();

@@ -259,11 +263,12 @@

}
};
});
_this.renderExplicitly = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderExplicitly", function () {
return new Promise(function (resolve, reject) {
if (_this.state.rendered) {
return reject('This recaptcha instance has been already rendered.');
return reject(new Error('This recaptcha instance has been already rendered.'));
}
if (_this.state.ready && _this.container) {
var _instanceId = _this._renderRecaptcha(_this.container, {
var instanceId = _this._renderRecaptcha(_this.container, {
sitekey: _this.props.sitekey,

@@ -282,3 +287,3 @@ theme: _this.state.invisible ? null : _this.props.theme,

_this.setState({
instanceId: _instanceId,
instanceId: instanceId,
rendered: true

@@ -289,35 +294,41 @@ }, function () {

}
resolve();
});
} else {
return reject('Recaptcha is not ready for rendering yet.');
return reject(new Error('Recaptcha is not ready for rendering yet.'));
}
});
};
});
_this.reset = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "reset", function () {
return new Promise(function (resolve, reject) {
if (_this.state.rendered) {
_this._resetRecaptcha();
return resolve();
}
reject('This recaptcha instance did not render yet.');
reject(new Error('This recaptcha instance did not render yet.'));
});
};
});
_this.execute = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "execute", function () {
return new Promise(function (resolve, reject) {
if (!_this.state.invisible) {
return reject('Manual execution is only available for invisible size.');
return reject(new Error('Manual execution is only available for invisible size.'));
}
if (_this.state.rendered) {
_this._executeRecaptcha();
resolve();
}
return reject('This recaptcha instance did not render yet.');
return reject(new Error('This recaptcha instance did not render yet.'));
});
};
});
_this.render = function () {
return _react2.default.createElement('div', {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "render", function () {
return external_amd_react_commonjs_react_commonjs2_react_root_React_default.a.createElement("div", {
id: _this.props.id,

@@ -329,3 +340,3 @@ className: _this.props.className,

});
};
});

@@ -343,5 +354,5 @@ _this.state = {

return Reaptcha;
}(_react.Component);
}(external_amd_react_commonjs_react_commonjs2_react_root_React_["Component"]);
Reaptcha.defaultProps = {
_defineProperty(index_Reaptcha, "defaultProps", {
id: '',

@@ -357,7 +368,8 @@ className: 'g-recaptcha',

hl: ''
};
exports.default = Reaptcha;
});
/* harmony default export */ var index = __webpack_exports__["default"] = (index_Reaptcha);
/***/ })
/******/ ])["default"];
});

@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["Reaptcha"] = factory(root["React"]);
})(global, function(__WEBPACK_EXTERNAL_MODULE__1__) {
})(global, function(__WEBPACK_EXTERNAL_MODULE__0__) {
return /******/ (function(modules) { // webpackBootstrap

@@ -95,3 +95,3 @@ /******/ // The module cache

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })

@@ -101,10 +101,18 @@ /************************************************************************/

/* 0 */
/***/ (function(module, exports, __webpack_require__) {
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: external {"amd":"react","commonjs":"react","commonjs2":"react","root":"React"}
var external_amd_react_commonjs_react_commonjs2_react_root_React_ = __webpack_require__(0);
var external_amd_react_commonjs_react_commonjs2_react_root_React_default = /*#__PURE__*/__webpack_require__.n(external_amd_react_commonjs_react_commonjs2_react_root_React_);
Object.defineProperty(exports, "__esModule", {
value: true
});
// CONCATENATED MODULE: ./utils/index.js
var getFilteredScripts = function getFilteredScripts(scriptSrc) {

@@ -120,3 +128,3 @@ return Array.from(document.scripts).filter(function (script) {

var isAnyScriptPresent = exports.isAnyScriptPresent = function isAnyScriptPresent(scripts) {
var isAnyScriptPresent = function isAnyScriptPresent(scripts) {
return scripts.reduce(function (isPresent, url) {

@@ -126,6 +134,4 @@ return isPresent ? isPresent : isScriptPresent(url);

};
var injectScript = exports.injectScript = function injectScript(scriptSrc) {
var injectScript = function injectScript(scriptSrc) {
var script = document.createElement('script');
script.async = true;

@@ -139,68 +145,62 @@ script.defer = true;

};
// CONCATENATED MODULE: ./index.js
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/***/ }),
/* 1 */
/***/ (function(module, exports) {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
"use strict";
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
Object.defineProperty(exports, "__esModule", {
value: true
});
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var _react = __webpack_require__(1);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _react2 = _interopRequireDefault(_react);
var _utils = __webpack_require__(0);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var USED_RECAPTCHA_SCRIPT_URL = 'https://recaptcha.net/recaptcha/api.js';
var RECAPTCHA_SCRIPTS_URLS = ['https://google.com/recaptcha', 'https://recaptcha.net/recaptcha', 'https://www.gstatic.com/recaptcha'];
var Reaptcha = function (_Component) {
var index_Reaptcha =
/*#__PURE__*/
function (_Component) {
_inherits(Reaptcha, _Component);
function Reaptcha(props) {
var _this;
_classCallCheck(this, Reaptcha);
var _this = _possibleConstructorReturn(this, (Reaptcha.__proto__ || Object.getPrototypeOf(Reaptcha)).call(this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(Reaptcha).call(this, props));
_this.container = null;
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "container", null);
_this._isAvailable = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_isAvailable", function () {
return Boolean(window && window.grecaptcha && window.grecaptcha.ready);
};
});
_this._inject = function () {
if (_this.props.inject && !(0, _utils.isAnyScriptPresent)(RECAPTCHA_SCRIPTS_URLS)) {
(0, _utils.injectScript)(USED_RECAPTCHA_SCRIPT_URL + '?render=explicit');
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_inject", function () {
if (_this.props.inject && !isAnyScriptPresent(RECAPTCHA_SCRIPTS_URLS)) {
var hlParam = _this.props.hl ? "&hl=".concat(_this.props.hl) : '';
var src = "".concat(USED_RECAPTCHA_SCRIPT_URL, "?render=explicit").concat(hlParam);
injectScript(src);
}
};
});
_this._prepare = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_prepare", function () {
var _this$props = _this.props,
explicit = _this$props.explicit,
onLoad = _this$props.onLoad;
window.grecaptcha.ready(function () {
_this.setState({ ready: true }, function () {
_this.setState({
ready: true
}, function () {
if (!explicit) {
_this.renderExplicitly();
}
if (onLoad) {

@@ -211,23 +211,23 @@ onLoad();

});
};
});
_this._renderRecaptcha = function (container, config) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_renderRecaptcha", function (container, config) {
return window.grecaptcha.render(container, config);
};
});
_this._resetRecaptcha = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_resetRecaptcha", function () {
return window.grecaptcha.reset(_this.state.instanceId);
};
});
_this._executeRecaptcha = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_executeRecaptcha", function () {
return window.grecaptcha.execute(_this.state.instanceId);
};
});
_this._stopTimer = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_stopTimer", function () {
if (_this.state.timer) {
clearInterval(_this.state.timer);
}
};
});
_this.componentDidMount = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "componentDidMount", function () {
_this._inject();

@@ -238,17 +238,21 @@

} else {
var _timer = setInterval(function () {
var timer = setInterval(function () {
if (_this._isAvailable()) {
_this._prepare();
_this._stopTimer();
}
}, 500);
_this.setState({ timer: _timer });
_this.setState({
timer: timer
});
}
};
});
_this.shouldComponentUpdate = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "shouldComponentUpdate", function () {
return !_this.state.rendered;
};
});
_this.componentWillUnmount = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "componentWillUnmount", function () {
_this._stopTimer();

@@ -259,11 +263,12 @@

}
};
});
_this.renderExplicitly = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderExplicitly", function () {
return new Promise(function (resolve, reject) {
if (_this.state.rendered) {
return reject('This recaptcha instance has been already rendered.');
return reject(new Error('This recaptcha instance has been already rendered.'));
}
if (_this.state.ready && _this.container) {
var _instanceId = _this._renderRecaptcha(_this.container, {
var instanceId = _this._renderRecaptcha(_this.container, {
sitekey: _this.props.sitekey,

@@ -282,3 +287,3 @@ theme: _this.state.invisible ? null : _this.props.theme,

_this.setState({
instanceId: _instanceId,
instanceId: instanceId,
rendered: true

@@ -289,35 +294,41 @@ }, function () {

}
resolve();
});
} else {
return reject('Recaptcha is not ready for rendering yet.');
return reject(new Error('Recaptcha is not ready for rendering yet.'));
}
});
};
});
_this.reset = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "reset", function () {
return new Promise(function (resolve, reject) {
if (_this.state.rendered) {
_this._resetRecaptcha();
return resolve();
}
reject('This recaptcha instance did not render yet.');
reject(new Error('This recaptcha instance did not render yet.'));
});
};
});
_this.execute = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "execute", function () {
return new Promise(function (resolve, reject) {
if (!_this.state.invisible) {
return reject('Manual execution is only available for invisible size.');
return reject(new Error('Manual execution is only available for invisible size.'));
}
if (_this.state.rendered) {
_this._executeRecaptcha();
resolve();
}
return reject('This recaptcha instance did not render yet.');
return reject(new Error('This recaptcha instance did not render yet.'));
});
};
});
_this.render = function () {
return _react2.default.createElement('div', {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "render", function () {
return external_amd_react_commonjs_react_commonjs2_react_root_React_default.a.createElement("div", {
id: _this.props.id,

@@ -329,3 +340,3 @@ className: _this.props.className,

});
};
});

@@ -343,5 +354,5 @@ _this.state = {

return Reaptcha;
}(_react.Component);
}(external_amd_react_commonjs_react_commonjs2_react_root_React_["Component"]);
Reaptcha.defaultProps = {
_defineProperty(index_Reaptcha, "defaultProps", {
id: '',

@@ -357,7 +368,8 @@ className: 'g-recaptcha',

hl: ''
};
exports.default = Reaptcha;
});
/* harmony default export */ var index = __webpack_exports__["default"] = (index_Reaptcha);
/***/ })
/******/ ])["default"];
});
{
"name": "reaptcha",
"version": "1.3.0",
"version": "1.4.0",
"description": "Google reCAPTCHA for React",

@@ -19,4 +19,5 @@ "repository": "git@github.com:sarneeh/reaptcha.git",

"devDependencies": {
"webpack": "^4.11.1"
}
"webpack": "^4.17.1"
},
"gitHead": "7abe82a94714f7ed89130a130183a8bbc5c675ff"
}
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