auth0-lock 11.31.0 → 11.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,24 @@
1
1
  # Change Log
2
2
 
3
+ ## [v11.31.1](https://github.com/auth0/lock/tree/v11.31.1) (2021-11-02)
4
+
5
+ [Full Changelog](https://github.com/auth0/lock/compare/v11.31.0...v11.31.1)
6
+
7
+ **Fixed**
8
+
9
+ - Guard references to window on module load [\#2057](https://github.com/auth0/lock/pull/2057) ([stevehobbsdev](https://github.com/stevehobbsdev))
10
+ - Ensure Captcha is completed before authenticating with enterprise SSO connection [\#2060](https://github.com/auth0/lock/pull/2060) ([stevehobbsdev](https://github.com/stevehobbsdev))
11
+
3
12
  ## [v11.31.0](https://github.com/auth0/lock/tree/v11.31.0) (2021-10-15)
13
+
4
14
  [Full Changelog](https://github.com/auth0/lock/compare/v11.30.6...v11.31.0)
5
15
 
6
16
  **Added**
17
+
7
18
  - [SDK-2295] Add forceAutoHeight property to UI config [\#2050](https://github.com/auth0/lock/pull/2050) ([stevehobbsdev](https://github.com/stevehobbsdev))
8
19
 
9
20
  **Fixed**
21
+
10
22
  - [SDK-2823] Fix password reset when using custom connection resolver [\#2048](https://github.com/auth0/lock/pull/2048) ([stevehobbsdev](https://github.com/stevehobbsdev))
11
23
 
12
24
  ## [v11.30.6](https://github.com/auth0/lock/tree/v11.30.6) (2021-09-27)
package/README.md CHANGED
@@ -25,7 +25,7 @@ From CDN
25
25
 
26
26
  ```html
27
27
  <!-- Latest patch release (recommended for production) -->
28
- <script src="https://cdn.auth0.com/js/lock/11.31.0/lock.min.js"></script>
28
+ <script src="https://cdn.auth0.com/js/lock/11.31.1/lock.min.js"></script>
29
29
  ```
30
30
 
31
31
  From [npm](https://npmjs.org)
@@ -423,6 +423,7 @@ new Auth0Lock('client ID', 'domain', {
423
423
  console.log('Hello from the sign-up hook!');
424
424
  cb();
425
425
  }
426
+ }
426
427
  });
427
428
  ```
428
429
 
@@ -439,7 +440,8 @@ new Auth0Lock('client ID', 'domain', {
439
440
 
440
441
  // Throw something generic to show a fallback error message
441
442
  throw "Some error happened";
442
- },
443
+ }
444
+ }
443
445
  });
444
446
  ```
445
447
 
@@ -87,6 +87,25 @@ describe('Login with connection scopes', function () {
87
87
  login_hint: 'test@test.com'
88
88
  });
89
89
  });
90
+
91
+ it('should throw an error if the captcha was not completed', function () {
92
+ lock = l.setup('__lock__', 'client', 'domain', {});
93
+ lock = (0, _index2.setField)(lock, 'email', 'test@test.com');
94
+
95
+ lock = l.setCaptcha(lock, {
96
+ required: true,
97
+ provider: 'recaptcha_v2'
98
+ });
99
+
100
+ require('store/index').read.mockReturnValue(lock);
101
+
102
+ require('connection/enterprise').matchConnection.mockReturnValue(_immutable2.default.fromJS({ name: 'sso-connection' }));
103
+
104
+ var coreActions = require('core/actions');
105
+
106
+ (0, _actions.logIn)('__lock__');
107
+ expect(coreActions.logIn).not.toHaveBeenCalled();
108
+ });
90
109
  });
91
110
 
92
111
  describe('for a non-SSO connection', function () {
package/lib/browser.js CHANGED
@@ -19,14 +19,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
19
19
  * the package.json file points to index.js.
20
20
  */
21
21
 
22
- if (typeof window.define == 'function' && window.define.amd) {
23
- window.define('auth0Lock', function () {
24
- return _index2.default;
25
- });
26
- window.define('auth0LockPasswordless', function () {
27
- return _passwordless2.default;
28
- });
29
- } else if (window.window) {
30
- window.Auth0Lock = _index2.default;
31
- window.Auth0LockPasswordless = _passwordless2.default;
22
+ if (typeof window !== 'undefined') {
23
+ if (typeof window.define == 'function' && window.define.amd) {
24
+ window.define('auth0Lock', function () {
25
+ return _index2.default;
26
+ });
27
+ window.define('auth0LockPasswordless', function () {
28
+ return _passwordless2.default;
29
+ });
30
+ } else if (window.window) {
31
+ window.Auth0Lock = _index2.default;
32
+ window.Auth0LockPasswordless = _passwordless2.default;
33
+ }
32
34
  }
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+ exports.showMissingCaptcha = showMissingCaptcha;
5
+ exports.setCaptchaParams = setCaptchaParams;
6
+ exports.swapCaptcha = swapCaptcha;
7
+
8
+ var _index = require('../core/index');
9
+
10
+ var l = _interopRequireWildcard(_index);
11
+
12
+ var _index2 = require('../field/index');
13
+
14
+ var c = _interopRequireWildcard(_index2);
15
+
16
+ var _i18n = require('../i18n');
17
+
18
+ var i18n = _interopRequireWildcard(_i18n);
19
+
20
+ var _index3 = require('../store/index');
21
+
22
+ var _web_api = require('../core/web_api');
23
+
24
+ var _web_api2 = _interopRequireDefault(_web_api);
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+
28
+ 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; } }
29
+
30
+ /**
31
+ * Display the error message of missing captcha in the header of lock.
32
+ *
33
+ * @param {Object} m model
34
+ * @param {Number} id
35
+ */
36
+ function showMissingCaptcha(m, id) {
37
+ var captchaConfig = l.captcha(m);
38
+
39
+ var captchaError = captchaConfig.get('provider') === 'recaptcha_v2' ? 'invalid_recaptcha' : 'invalid_captcha';
40
+
41
+ var errorMessage = i18n.html(m, ['error', 'login', captchaError]);
42
+
43
+ (0, _index3.swap)(_index3.updateEntity, 'lock', id, function (m) {
44
+ m = l.setSubmitting(m, false, errorMessage);
45
+ return c.showInvalidField(m, 'captcha');
46
+ });
47
+
48
+ return m;
49
+ }
50
+
51
+ /**
52
+ * Set the captcha value in the fields object before sending the request.
53
+ *
54
+ * @param {Object} m model
55
+ * @param {Object} params
56
+ * @param {Object} fields
57
+ *
58
+ * @returns {Boolean} returns true if is required and missing the response from the user
59
+ */
60
+ function setCaptchaParams(m, params, fields) {
61
+ var captchaConfig = l.captcha(m);
62
+ var isCaptchaRequired = captchaConfig && l.captcha(m).get('required');
63
+
64
+ if (!isCaptchaRequired) {
65
+ return true;
66
+ }
67
+ var captcha = c.getFieldValue(m, 'captcha');
68
+ //captcha required and missing
69
+ if (!captcha) {
70
+ return false;
71
+ }
72
+
73
+ params['captcha'] = captcha;
74
+ fields.push('captcha');
75
+ return true;
76
+ }
77
+
78
+ /**
79
+ * Get a new challenge and display the new captcha image.
80
+ *
81
+ * @param {number} id The id of the Lock instance.
82
+ * @param {boolean} wasInvalid A boolean indicating if the previous captcha was invalid.
83
+ * @param {Function} [next] A callback.
84
+ */
85
+ function swapCaptcha(id, wasInvalid, next) {
86
+ return _web_api2.default.getChallenge(id, function (err, newCaptcha) {
87
+ if (!err && newCaptcha) {
88
+ (0, _index3.swap)(_index3.updateEntity, 'lock', id, l.setCaptcha, newCaptcha, wasInvalid);
89
+ }
90
+ if (next) {
91
+ next();
92
+ }
93
+ });
94
+ }
@@ -12,7 +12,6 @@ exports.cancelResetPassword = cancelResetPassword;
12
12
  exports.cancelMFALogin = cancelMFALogin;
13
13
  exports.toggleTermsAcceptance = toggleTermsAcceptance;
14
14
  exports.showLoginMFAActivity = showLoginMFAActivity;
15
- exports.swapCaptcha = swapCaptcha;
16
15
 
17
16
  var _immutable = require('immutable');
18
17
 
@@ -40,6 +39,8 @@ var _i18n = require('../../i18n');
40
39
 
41
40
  var i18n = _interopRequireWildcard(_i18n);
42
41
 
42
+ var _captcha = require('../captcha');
43
+
43
44
  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; } }
44
45
 
45
46
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -58,9 +59,9 @@ function logIn(id) {
58
59
 
59
60
  var fields = [usernameField, 'password'];
60
61
 
61
- var isCaptchaValid = setCaptchaParams(m, params, fields);
62
+ var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, fields);
62
63
  if (!isCaptchaValid) {
63
- return showMissingCaptcha(m, id);
64
+ return (0, _captcha.showMissingCaptcha)(m, id);
64
65
  }
65
66
 
66
67
  var mfaCode = c.getFieldValue(m, 'mfa_code');
@@ -76,7 +77,7 @@ function logIn(id) {
76
77
 
77
78
  if (error) {
78
79
  var wasInvalid = error && error.code === 'invalid_captcha';
79
- return swapCaptcha(id, wasInvalid, next);
80
+ return (0, _captcha.swapCaptcha)(id, wasInvalid, next);
80
81
  }
81
82
 
82
83
  next();
@@ -113,9 +114,9 @@ function signUp(id) {
113
114
  autoLogin: (0, _index4.shouldAutoLogin)(m)
114
115
  };
115
116
 
116
- var isCaptchaValid = setCaptchaParams(m, params, fields);
117
+ var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, fields);
117
118
  if (!isCaptchaValid) {
118
- return showMissingCaptcha(m, id);
119
+ return (0, _captcha.showMissingCaptcha)(m, id);
119
120
  }
120
121
 
121
122
  if ((0, _index4.databaseConnectionRequiresUsername)(m)) {
@@ -155,7 +156,7 @@ function signUp(id) {
155
156
 
156
157
  var wasInvalidCaptcha = error && error.code === 'invalid_captcha';
157
158
 
158
- swapCaptcha(id, wasInvalidCaptcha, function () {
159
+ (0, _captcha.swapCaptcha)(id, wasInvalidCaptcha, function () {
159
160
  setTimeout(function () {
160
161
  return signUpError(id, error);
161
162
  }, 250);
@@ -255,7 +256,7 @@ function signUpError(id, error) {
255
256
 
256
257
  if (errorKey === 'invalid_captcha') {
257
258
  errorMessage = i18n.html(m, ['error', 'login', errorKey]);
258
- return swapCaptcha(id, true, function () {
259
+ return (0, _captcha.swapCaptcha)(id, true, function () {
259
260
  (0, _index.swap)(_index.updateEntity, 'lock', id, l.setSubmitting, false, errorMessage);
260
261
  });
261
262
  }
@@ -360,64 +361,3 @@ function showLoginMFAActivity(id) {
360
361
 
361
362
  (0, _index.swap)(_index.updateEntity, 'lock', id, _index4.setScreen, 'mfaLogin', fields);
362
363
  }
363
-
364
- /**
365
- * Get a new challenge and display the new captcha image.
366
- *
367
- * @param {number} id The id of the Lock instance.
368
- * @param {boolean} wasInvalid A boolean indicating if the previous captcha was invalid.
369
- * @param {Function} [next] A callback.
370
- */
371
- function swapCaptcha(id, wasInvalid, next) {
372
- return _web_api2.default.getChallenge(id, function (err, newCaptcha) {
373
- if (!err && newCaptcha) {
374
- (0, _index.swap)(_index.updateEntity, 'lock', id, l.setCaptcha, newCaptcha, wasInvalid);
375
- }
376
- if (next) {
377
- next();
378
- }
379
- });
380
- }
381
-
382
- /**
383
- * Display the error message of missing captcha in the header of lock.
384
- *
385
- * @param {Object} m model
386
- * @param {Number} id
387
- */
388
- function showMissingCaptcha(m, id) {
389
- var captchaConfig = l.captcha(m);
390
- var captchaError = captchaConfig.get('provider') === 'recaptcha_v2' ? 'invalid_recaptcha' : 'invalid_captcha';
391
- var errorMessage = i18n.html(m, ['error', 'login', captchaError]);
392
- (0, _index.swap)(_index.updateEntity, 'lock', id, function (m) {
393
- m = l.setSubmitting(m, false, errorMessage);
394
- return c.showInvalidField(m, 'captcha');
395
- });
396
- return m;
397
- }
398
-
399
- /**
400
- * Set the captcha value in the fields object before sending the request.
401
- *
402
- * @param {Object} m model
403
- * @param {Object} params
404
- * @param {Object} fields
405
- *
406
- * @returns {Boolean} returns true if is required and missing the response from the user
407
- */
408
- function setCaptchaParams(m, params, fields) {
409
- var captchaConfig = l.captcha(m);
410
- var isCaptchaRequired = captchaConfig && l.captcha(m).get('required');
411
- if (!isCaptchaRequired) {
412
- return true;
413
- }
414
- var captcha = c.getFieldValue(m, 'captcha');
415
- //captcha required and missing
416
- if (!captcha) {
417
- return false;
418
- }
419
-
420
- params['captcha'] = captcha;
421
- fields.push('captcha');
422
- return true;
423
- }
@@ -24,6 +24,8 @@ var _password_pane2 = _interopRequireDefault(_password_pane);
24
24
 
25
25
  var _actions = require('./actions');
26
26
 
27
+ var _captcha = require('../captcha');
28
+
27
29
  var _index = require('./index');
28
30
 
29
31
  var _index2 = require('../../core/index');
@@ -103,7 +105,7 @@ var LoginPane = function (_React$Component) {
103
105
  });
104
106
 
105
107
  var captchaPane = l.captcha(lock) && l.captcha(lock).get('required') ? _react2.default.createElement(_captcha_pane2.default, { i18n: i18n, lock: lock, onReload: function onReload() {
106
- return (0, _actions.swapCaptcha)(l.id(lock), false);
108
+ return (0, _captcha.swapCaptcha)(l.id(lock), false);
107
109
  } }) : null;
108
110
 
109
111
  var dontRememberPassword = showForgotPasswordLink && (0, _index.hasScreen)(lock, 'forgotPassword') ? _react2.default.createElement(
@@ -30,6 +30,8 @@ var _index3 = require('../../core/index');
30
30
 
31
31
  var l = _interopRequireWildcard(_index3);
32
32
 
33
+ var _captcha = require('../captcha');
34
+
33
35
  var _index4 = require('../database/index');
34
36
 
35
37
  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; } }
@@ -57,11 +59,19 @@ function logIn(id) {
57
59
  var ssoConnection = (0, _enterprise.matchConnection)(m, email);
58
60
  var enterpriseConnection = (0, _enterprise.enterpriseActiveFlowConnection)(m);
59
61
  var connectionScopes = getConnectionScopesFrom(m, ssoConnection || enterpriseConnection);
62
+ var usernameField = (0, _index4.databaseLogInWithEmail)(m) ? 'email' : 'username';
63
+ var fields = [usernameField, 'password'];
60
64
 
61
65
  var params = {
62
66
  connection_scope: connectionScopes ? connectionScopes.toJS() : undefined
63
67
  };
64
68
 
69
+ var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, fields);
70
+
71
+ if (!isCaptchaValid) {
72
+ return (0, _captcha.showMissingCaptcha)(m, id);
73
+ }
74
+
65
75
  if (ssoConnection && !(0, _enterprise.isHRDActive)(m)) {
66
76
  return logInSSO(id, ssoConnection, params);
67
77
  }
@@ -176,5 +176,5 @@ function trimAuthParams() {
176
176
  }
177
177
 
178
178
  function getVersion() {
179
- return '11.31.0';
179
+ return '11.31.1';
180
180
  }
@@ -66,7 +66,7 @@ function shouldRenderTabs(m) {
66
66
  if (l.hasSomeConnections(m, 'social') && (0, _index.hasInitialScreen)(m, 'signUp')) return (0, _index.hasScreen)(m, 'signUp');
67
67
  }
68
68
 
69
- var Component = function Component(_ref) {
69
+ var LoginComponent = function LoginComponent(_ref) {
70
70
  var i18n = _ref.i18n,
71
71
  model = _ref.model;
72
72
 
@@ -182,7 +182,7 @@ var Login = function (_Screen) {
182
182
  };
183
183
 
184
184
  Login.prototype.render = function render() {
185
- return Component;
185
+ return LoginComponent;
186
186
  };
187
187
 
188
188
  return Login;
@@ -32,7 +32,7 @@ var _index2 = require('../../core/index');
32
32
 
33
33
  var l = _interopRequireWildcard(_index2);
34
34
 
35
- var _actions = require('../../connection/database/actions');
35
+ var _captcha = require('../../connection/captcha');
36
36
 
37
37
  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; } }
38
38
 
@@ -97,7 +97,7 @@ var SignUpPane = function (_React$Component) {
97
97
  });
98
98
 
99
99
  var captchaPane = l.captcha(model) && l.captcha(model).get('required') ? _react2.default.createElement(_captcha_pane2.default, { i18n: i18n, lock: model, onReload: function onReload() {
100
- return (0, _actions.swapCaptcha)(l.id(model), false);
100
+ return (0, _captcha.swapCaptcha)(l.id(model), false);
101
101
  } }) : null;
102
102
 
103
103
  var passwordPane = !onlyEmail && _react2.default.createElement(_password_pane2.default, {
package/lib/i18n.js CHANGED
@@ -125,7 +125,7 @@ function assertLanguage(m, language, base) {
125
125
  function syncLang(m, language, _cb) {
126
126
  (0, _cdn_utils.load)({
127
127
  method: 'registerLanguageDictionary',
128
- url: l.languageBaseUrl(m) + '/js/lock/' + '11.31.0' + '/' + language + '.js',
128
+ url: l.languageBaseUrl(m) + '/js/lock/' + '11.31.1' + '/' + language + '.js',
129
129
  check: function check(str) {
130
130
  return str && str === language;
131
131
  },
@@ -141,7 +141,9 @@ function registerLanguageDictionary(language, dictionary) {
141
141
  languageDictionaries[language] = _immutable2.default.fromJS(dictionary);
142
142
  }
143
143
 
144
- (0, _cdn_utils.preload)({
145
- method: 'registerLanguageDictionary',
146
- cb: registerLanguageDictionary
147
- });
144
+ if (typeof window !== 'undefined') {
145
+ (0, _cdn_utils.preload)({
146
+ method: 'registerLanguageDictionary',
147
+ cb: registerLanguageDictionary
148
+ });
149
+ }
package/lib/lock.js CHANGED
@@ -42,7 +42,7 @@ var Auth0Lock = function (_Core) {
42
42
 
43
43
 
44
44
  exports.default = Auth0Lock;
45
- Auth0Lock.version = '11.31.0';
45
+ Auth0Lock.version = '11.31.1';
46
46
 
47
47
  // TODO: should we have different telemetry for classic/passwordless?
48
48
  // TODO: should we set telemetry info before each request?
@@ -41,4 +41,4 @@ var Auth0LockPasswordless = function (_Core) {
41
41
  exports.default = Auth0LockPasswordless;
42
42
 
43
43
 
44
- Auth0LockPasswordless.version = '11.31.0';
44
+ Auth0LockPasswordless.version = '11.31.1';
@@ -112,7 +112,7 @@ var EscKeyDownHandler = function () {
112
112
  return EscKeyDownHandler;
113
113
  }();
114
114
 
115
- var IPHONE = window.navigator && !!window.navigator.userAgent.match(/iPhone/i);
115
+ var IPHONE = typeof window !== 'undefined' && window.navigator && !!window.navigator.userAgent.match(/iPhone/i);
116
116
 
117
117
  var Container = function (_React$Component) {
118
118
  _inherits(Container, _React$Component);
@@ -384,7 +384,7 @@ Container.propTypes = {
384
384
  };
385
385
 
386
386
  // NOTE: detecting the file protocol is important for things like electron.
387
- var isFileProtocol = window.window && window.location && window.location.protocol === 'file:';
387
+ var isFileProtocol = typeof window !== 'undefined' && window.window && window.location && window.location.protocol === 'file:';
388
388
 
389
389
  var defaultProps = exports.defaultProps = Container.defaultProps = {
390
390
  autofocus: false,
@@ -155,12 +155,17 @@ WelcomeMessage.propTypes = {
155
155
  };
156
156
 
157
157
  var cssBlurSupport = function () {
158
+ if (typeof window === 'undefined') {
159
+ return;
160
+ }
161
+
158
162
  // Check stolen from Modernizr, see https://github.com/Modernizr/Modernizr/blob/29eab707f7a2fb261c8a9c538370e97eb1f86e25/feature-detects/css/filters.js
159
163
  var isEdge = window.navigator && !!window.navigator.userAgent.match(/Edge/i);
160
164
  if (typeof window.document === 'undefined' || isEdge) return false;
161
165
 
162
166
  var el = window.document.createElement('div');
163
167
  el.style.cssText = 'filter: blur(2px); -webkit-filter: blur(2px)';
168
+
164
169
  return !!el.style.length && (window.document.documentMode === undefined || window.document.documentMode > 9);
165
170
  }();
166
171
 
@@ -10,7 +10,7 @@ var _auth0Js2 = _interopRequireDefault(_auth0Js);
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
 
13
- if (!window.Auth0) {
13
+ if (typeof window !== 'undefined' && !window.Auth0) {
14
14
  window.Auth0 = {};
15
15
  }
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0-lock",
3
- "version": "11.31.0",
3
+ "version": "11.31.1",
4
4
  "description": "Auth0 Lock",
5
5
  "author": "Auth0 <support@auth0.com> (http://auth0.com)",
6
6
  "license": "MIT",
@@ -107,7 +107,7 @@
107
107
  "dependencies": {
108
108
  "auth0-js": "^9.16.4",
109
109
  "auth0-password-policies": "^1.0.2",
110
- "blueimp-md5": "^2.18.0",
110
+ "blueimp-md5": "^2.19.0",
111
111
  "classnames": "^2.3.1",
112
112
  "dompurify": "^2.2.8",
113
113
  "immutable": "^3.7.3",