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

auth0-lock

Package Overview
Dependencies
Maintainers
37
Versions
339
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth0-lock - npm Package Compare versions

Comparing version 11.24.2 to 11.24.3

lib/__tests__/i18n.js

12

lib/__tests__/field/captcha.js

@@ -19,4 +19,2 @@ 'use strict';

var _recaptchav2 = _interopRequireDefault(_recaptchav);
var _captcha_input = require('../../ui/input/captcha_input');

@@ -31,3 +29,5 @@

_ref$provider = _ref.provider,
provider = _ref$provider === undefined ? 'none' : _ref$provider,
provider = _ref$provider === undefined ? 'auth0' : _ref$provider,
_ref$required = _ref.required,
required = _ref$required === undefined ? true : _ref$required,
_ref$siteKey = _ref.siteKey,

@@ -39,3 +39,3 @@ siteKey = _ref$siteKey === undefined ? '' : _ref$siteKey;

core: {
captcha: { provider: provider, siteKey: siteKey }
captcha: { provider: provider, siteKey: siteKey, required: required }
}

@@ -81,9 +81,9 @@ });

it('should render reCaptcha if provider is recaptchav2', function () {
expect(wrapper.find(_recaptchav2.default)).toHaveLength(1);
expect(wrapper.find(_recaptchav.ReCAPTCHA)).toHaveLength(1);
});
it('should pass the sitekey', function () {
expect(wrapper.find(_recaptchav2.default).props().siteKey).toBe('mySiteKey');
expect(wrapper.find(_recaptchav.ReCAPTCHA).props().sitekey).toBe('mySiteKey');
});
});
});

@@ -15,4 +15,2 @@ 'use strict';

var _recaptchav2 = _interopRequireDefault(_recaptchav);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -24,4 +22,4 @@

provider = _ref$provider === undefined ? 'none' : _ref$provider,
_ref$siteKey = _ref.siteKey,
siteKey = _ref$siteKey === undefined ? '' : _ref$siteKey;
_ref$sitekey = _ref.sitekey,
sitekey = _ref$sitekey === undefined ? '' : _ref$sitekey;

@@ -31,3 +29,3 @@ return _immutable2.default.fromJS({

core: {
captcha: { provider: provider, siteKey: siteKey },
captcha: { provider: provider, sitekey: sitekey },
transient: {

@@ -44,4 +42,5 @@ ui: {

it('should match the snapshot', function () {
var mockLock = createLockMock({ provider: 'recaptchav2', siteKey: 'mySiteKey' });
var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_recaptchav2.default, { lock: mockLock, siteKey: 'mySiteKey' }));
var mockLock = createLockMock({ provider: 'recaptchav2', sitekey: 'mySiteKey' });
var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_recaptchav.ReCAPTCHA, { lock: mockLock, sitekey: 'mySiteKey' }));
expect(wrapper).toMatchSnapshot();

@@ -58,7 +57,7 @@ });

it('injects the script', function () {
var mockLock = createLockMock({ provider: 'recaptchav2', siteKey: 'mySiteKey' });
(0, _recaptchav.render)(mockLock, document.getElementById('renderTest'), {});
expect(document.body.innerHTML).toBe('<div id="renderTest"></div><script src="https://www.google.com/recaptcha/api.js?hl=en-US"></script>');
_recaptchav.ReCAPTCHA.loadScript({ hl: 'en-US' }, document.body);
expect(document.body.innerHTML).toContain('<div id="renderTest">');
expect(document.body.innerHTML).toContain('<script src="https://www.google.com/recaptcha/api.js?hl=en-US');
});
});
});

@@ -13,2 +13,6 @@ 'use strict';

var _input_wrap = require('../../../ui/input/input_wrap');
var _input_wrap2 = _interopRequireDefault(_input_wrap);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -77,2 +81,7 @@

});
test('shows invalid Hint', function () {
var Input = getComponent();
var wrapper = (0, _enzyme.mount)(_react2.default.createElement(Input, defaultProps));
expect(wrapper.find(_input_wrap2.default).props().invalidHint).toBe('invalidHint');
});
});

@@ -179,3 +179,3 @@ 'use strict';

function getVersion() {
return '11.24.2';
return '11.24.3';
}

@@ -7,5 +7,8 @@ 'use strict';

exports.reset = reset;
exports.getValue = getValue;
var _index = require('./index');
var onResetCallbacks = [];
function validate(captcha) {

@@ -26,1 +29,5 @@ return !!captcha;

}
function getValue(m) {
return (0, _index.getFieldValue)(m, 'captcha');
}

@@ -31,4 +31,2 @@ 'use strict';

var _recaptchav2 = _interopRequireDefault(_recaptchav);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -62,12 +60,26 @@

function handleChange(e) {
(0, _index2.swap)(_index2.updateEntity, 'lock', lockId, captchaField.set, e.target.value);
}
var captcha = l.captcha(lock);
if (captcha.get('provider') === 'recaptcha_v2') {
return _react2.default.createElement(_recaptchav2.default, { lock: lock, siteKey: captcha.get('siteKey') });
var _handleChange = function _handleChange(value) {
(0, _index2.swap)(_index2.updateEntity, 'lock', lockId, captchaField.set, value);
};
var reset = function reset() {
_handleChange();
};
return _react2.default.createElement(_recaptchav.ReCAPTCHA, {
sitekey: captcha.get('siteKey'),
onChange: _handleChange,
onExpired: reset,
hl: l.ui.language(lock),
value: captchaField.getValue(lock)
});
}
function handleChange(e) {
(0, _index2.swap)(_index2.updateEntity, 'lock', lockId, captchaField.set, e.target.value);
}
var placeholder = captcha.get('type') === 'code' ? i18n.str('captchaCodeInputPlaceholder') : i18n.str('captchaMathInputPlaceholder');

@@ -74,0 +86,0 @@

'use strict';
exports.__esModule = true;
exports.ReCAPTCHA = undefined;
var _extends = Object.assign || 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; };
var _createRef = require('../../utils/createRef');
exports.render = render;
var _react = require('react');

@@ -13,85 +12,135 @@

var _immutable = require('immutable');
var _propTypes = require('prop-types');
var _index = require('../../core/index');
var _propTypes2 = _interopRequireDefault(_propTypes);
var l = _interopRequireWildcard(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _store = require('../../store');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _captcha = require('../captcha');
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; }
var captcha = _interopRequireWildcard(_captcha);
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; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var noop = function noop() {};
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var ReCAPTCHA = exports.ReCAPTCHA = function (_React$Component) {
_inherits(ReCAPTCHA, _React$Component);
function isScriptAvailable(scriptUrl) {
//check the window object
if (window.grecaptcha && typeof window.grecaptcha.render === 'function') {
return true;
}
//check the scripts element, it might be loading
var allScripts = new _immutable.Set(document.scripts);
return allScripts.some(function (s) {
return s.src === scriptUrl;
});
}
function ReCAPTCHA(props) {
_classCallCheck(this, ReCAPTCHA);
function injectGoogleCaptchaIfMissing(lock) {
var lang = l.ui.language(lock);
var scriptUrl = 'https://www.google.com/recaptcha/api.js?hl=' + lang;
if (isScriptAvailable(scriptUrl)) {
return;
}
var script = document.createElement('script');
script.src = scriptUrl;
script.async = true;
document.body.appendChild(script);
}
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
/**
* waits until google recaptcha is ready and renders
*/
function renderElement(lock, el, prop) {
if (!window.grecaptcha || typeof window.grecaptcha.render !== 'function') {
return setTimeout(function () {
return renderElement(lock, el, prop);
}, 100);
}
_this.state = {};
//this version of react doesn't have React.createRef
_this.ref = (0, _createRef.createRef)();
var id = l.id(lock);
try {
window.grecaptcha.render(el, _extends({
callback: function callback(value) {
(0, _store.swap)(_store.updateEntity, 'lock', id, captcha.set, value, false);
},
'expired-callback': function expiredCallback() {
(0, _store.swap)(_store.updateEntity, 'lock', id, captcha.reset);
}
}, prop));
} catch (err) {}
}
_this.changeHandler = function (value) {
_this.setState({ value: value }, function () {
_this.props.onChange(value);
});
};
function render(lock, element, properties) {
if (!element || element.innerHTML !== '') {
return;
_this.expiredHandler = function () {
var value = '';
_this.setState({ value: value }, function () {
_this.props.onChange(value);
_this.props.onExpired();
});
};
_this.erroredHandler = function () {
var value = '';
_this.setState({ value: value }, function () {
_this.props.onChange(value);
_this.props.onErrored();
});
};
return _this;
}
injectGoogleCaptchaIfMissing(lock);
ReCAPTCHA.loadScript = function loadScript(props) {
var element = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.body;
var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
renderElement(lock, element, properties);
}
var callbackName = 'recatpchaCallback_' + Math.floor(Math.random() * 1000001);
var scriptUrl = 'https://www.google.com/recaptcha/api.js?hl=' + props.hl + '&onload=' + callbackName;
var script = document.createElement('script');
exports.default = function (_ref) {
var lock = _ref.lock,
siteKey = _ref.siteKey;
return _react2.default.createElement('div', {
style: { transform: 'scale(0.86)', transformOrigin: '0 0', position: 'relative' },
className: 'auth0-lock-recaptchav2',
ref: function ref(el) {
return render(lock, el, { sitekey: siteKey });
window[callbackName] = function () {
delete window[callbackName];
callback(null, script);
};
script.src = scriptUrl;
script.async = true;
element.appendChild(script);
};
ReCAPTCHA.prototype.componentWillUnmount = function componentWillUnmount() {
if (!this.scriptNode) {
return;
}
});
document.body.removeChild(this.scriptNode);
};
ReCAPTCHA.prototype.componentDidMount = function componentDidMount() {
var _this2 = this;
ReCAPTCHA.loadScript(this.props, document.body, function (err, scriptNode) {
_this2.scriptNode = scriptNode;
_this2.widgetId = window.grecaptcha.render(_this2.ref.current, {
callback: _this2.changeHandler,
'expired-callback': _this2.expiredHandler,
'error-callback': _this2.erroredHandler,
sitekey: _this2.props.sitekey
});
});
};
ReCAPTCHA.prototype.reset = function reset() {
window.grecaptcha.reset(this.widgetId);
};
ReCAPTCHA.prototype.render = function render() {
return _react2.default.createElement('div', {
style: { transform: 'scale(0.86)', transformOrigin: '0 0', position: 'relative' },
className: 'auth0-lock-recaptchav2',
ref: this.ref
});
};
ReCAPTCHA.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.value !== prevState.value) {
return { value: nextProps.value };
} else {
return null;
}
};
ReCAPTCHA.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
if (prevProps.value !== this.props.value && this.props.value === '') {
this.reset();
}
};
return ReCAPTCHA;
}(_react2.default.Component);
ReCAPTCHA.displayName = 'ReCAPTCHA';
ReCAPTCHA.propTypes = {
sitekey: _propTypes2.default.string.isRequired,
onChange: _propTypes2.default.func,
onExpired: _propTypes2.default.func,
onErrored: _propTypes2.default.func,
hl: _propTypes2.default.string,
value: _propTypes2.default.string
};
ReCAPTCHA.defaultProps = {
onChange: noop,
onExpired: noop,
onErrored: noop
};

@@ -119,3 +119,3 @@ 'use strict';

method: 'registerLanguageDictionary',
url: l.languageBaseUrl(m) + '/js/lock/' + '11.24.2' + '/' + language + '.js',
url: l.languageBaseUrl(m) + '/js/lock/' + '11.24.3' + '/' + language + '.js',
check: function check(str) {

@@ -136,4 +136,2 @@ return str && str === language;

registerLanguageDictionary('en', _en2.default);
(0, _cdn_utils.preload)({

@@ -140,0 +138,0 @@ method: 'registerLanguageDictionary',

@@ -45,3 +45,3 @@ 'use strict';

exports.default = Auth0Lock;
Auth0Lock.version = '11.24.2';
Auth0Lock.version = '11.24.3';

@@ -48,0 +48,0 @@ // TODO: should we have different telemetry for classic/passwordless?

@@ -44,2 +44,2 @@ 'use strict';

Auth0LockPasswordless.version = '11.24.2';
Auth0LockPasswordless.version = '11.24.3';

@@ -80,5 +80,5 @@ 'use strict';

iconElement,
this.props.children
this.props.children,
after
),
after,
errorTooltip

@@ -85,0 +85,0 @@ );

@@ -89,3 +89,3 @@ 'use strict';

focused: focused,
invalidHint: policy ? undefined : invalidHint,
invalidHint: invalidHint,
isValid: isValid,

@@ -92,0 +92,0 @@ name: 'password',

{
"name": "auth0-lock",
"version": "11.24.2",
"version": "11.24.3",
"description": "Auth0 Lock",

@@ -5,0 +5,0 @@ "author": "Auth0 <support@auth0.com> (http://auth0.com)",

@@ -26,3 +26,3 @@ [![NPM version][npm-image]][npm-url]

<!-- Latest patch release (recommended for production) -->
<script src="https://cdn.auth0.com/js/lock/11.24.2/lock.min.js"></script>
<script src="https://cdn.auth0.com/js/lock/11.24.3/lock.min.js"></script>
```

@@ -29,0 +29,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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