auth0-lock 11.30.6 → 11.32.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.
@@ -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 }; }
@@ -50,6 +51,7 @@ function logIn(id) {
50
51
  var m = (0, _index.read)(_index.getEntity, 'lock', id);
51
52
  var usernameField = (0, _index4.databaseLogInWithEmail)(m) ? 'email' : 'username';
52
53
  var username = c.getFieldValue(m, usernameField);
54
+
53
55
  var params = {
54
56
  connection: (0, _index4.databaseConnectionName)(m),
55
57
  username: username,
@@ -57,13 +59,14 @@ function logIn(id) {
57
59
  };
58
60
 
59
61
  var fields = [usernameField, 'password'];
62
+ var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, fields);
60
63
 
61
- var isCaptchaValid = setCaptchaParams(m, params, fields);
62
64
  if (!isCaptchaValid) {
63
- return showMissingCaptcha(m, id);
65
+ return (0, _captcha.showMissingCaptcha)(m, id);
64
66
  }
65
67
 
66
68
  var mfaCode = c.getFieldValue(m, 'mfa_code');
69
+
67
70
  if (needsMFA) {
68
71
  params['mfa_code'] = mfaCode;
69
72
  fields.push('mfa_code');
@@ -76,7 +79,7 @@ function logIn(id) {
76
79
 
77
80
  if (error) {
78
81
  var wasInvalid = error && error.code === 'invalid_captcha';
79
- return swapCaptcha(id, wasInvalid, next);
82
+ return (0, _captcha.swapCaptcha)(id, wasInvalid, next);
80
83
  }
81
84
 
82
85
  next();
@@ -113,9 +116,9 @@ function signUp(id) {
113
116
  autoLogin: (0, _index4.shouldAutoLogin)(m)
114
117
  };
115
118
 
116
- var isCaptchaValid = setCaptchaParams(m, params, fields);
119
+ var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, fields);
117
120
  if (!isCaptchaValid) {
118
- return showMissingCaptcha(m, id);
121
+ return (0, _captcha.showMissingCaptcha)(m, id);
119
122
  }
120
123
 
121
124
  if ((0, _index4.databaseConnectionRequiresUsername)(m)) {
@@ -155,7 +158,7 @@ function signUp(id) {
155
158
 
156
159
  var wasInvalidCaptcha = error && error.code === 'invalid_captcha';
157
160
 
158
- swapCaptcha(id, wasInvalidCaptcha, function () {
161
+ (0, _captcha.swapCaptcha)(id, wasInvalidCaptcha, function () {
159
162
  setTimeout(function () {
160
163
  return signUpError(id, error);
161
164
  }, 250);
@@ -255,7 +258,7 @@ function signUpError(id, error) {
255
258
 
256
259
  if (errorKey === 'invalid_captcha') {
257
260
  errorMessage = i18n.html(m, ['error', 'login', errorKey]);
258
- return swapCaptcha(id, true, function () {
261
+ return (0, _captcha.swapCaptcha)(id, true, function () {
259
262
  (0, _index.swap)(_index.updateEntity, 'lock', id, l.setSubmitting, false, errorMessage);
260
263
  });
261
264
  }
@@ -360,64 +363,3 @@ function showLoginMFAActivity(id) {
360
363
 
361
364
  (0, _index.swap)(_index.updateEntity, 'lock', id, _index4.setScreen, 'mfaLogin', fields);
362
365
  }
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');
@@ -34,6 +36,12 @@ var _captcha_pane = require('../../field/captcha/captcha_pane');
34
36
 
35
37
  var _captcha_pane2 = _interopRequireDefault(_captcha_pane);
36
38
 
39
+ var _classic = require('../../engine/classic');
40
+
41
+ var _enterprise = require('../enterprise');
42
+
43
+ var _database = require('../database');
44
+
37
45
  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
46
 
39
47
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -83,6 +91,7 @@ var LoginPane = function (_React$Component) {
83
91
  headerText
84
92
  );
85
93
  var resolver = l.connectionResolver(lock);
94
+ var sso = (0, _classic.isSSOEnabled)(lock);
86
95
 
87
96
  // Should never validate format on login because of custom db connection and import mode.
88
97
  // If a custom resolver is in use, always use UsernamePane without validating format,
@@ -102,8 +111,8 @@ var LoginPane = function (_React$Component) {
102
111
  strictValidation: false
103
112
  });
104
113
 
105
- 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);
114
+ var captchaPane = l.captcha(lock) && l.captcha(lock).get('required') && ((0, _enterprise.isHRDDomain)(lock, (0, _database.databaseUsernameValue)(lock)) || !sso) ? _react2.default.createElement(_captcha_pane2.default, { i18n: i18n, lock: lock, onReload: function onReload() {
115
+ return (0, _captcha.swapCaptcha)(l.id(lock), false);
107
116
  } }) : null;
108
117
 
109
118
  var dontRememberPassword = showForgotPasswordLink && (0, _index.hasScreen)(lock, 'forgotPassword') ? _react2.default.createElement(
@@ -34,6 +34,10 @@ var l = _interopRequireWildcard(_index3);
34
34
 
35
35
  var _index4 = require('../../store/index');
36
36
 
37
+ var _email = require('../../field/email');
38
+
39
+ var _field = require('../../field');
40
+
37
41
  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
42
 
39
43
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -54,6 +58,17 @@ var Component = function Component(_ref) {
54
58
  null,
55
59
  headerText
56
60
  );
61
+ var connectionResolver = l.connectionResolver(model);
62
+
63
+ // When using a custom connection resolver, `usernameStyle` is always 'username' (as opposed to 'email').
64
+ // If the user has entered an email address as the username, and a custom resolver is being used, copy the
65
+ // value from the 'username' field to the 'email' field so that `EmailPane` can render it.
66
+ if (connectionResolver) {
67
+ var field = (0, _field.getField)(model, 'username');
68
+ var value = field.get('value', '');
69
+
70
+ (0, _index4.swap)(_index4.updateEntity, 'lock', l.id(model), _email.setEmail, (0, _email.isEmail)(value, false) ? value : '', false);
71
+ }
57
72
 
58
73
  return _react2.default.createElement(_reset_password_pane2.default, {
59
74
  emailInputPlaceholder: i18n.str('emailInputPlaceholder'),
@@ -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,6 +59,8 @@ 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
@@ -66,6 +70,12 @@ function logIn(id) {
66
70
  return logInSSO(id, ssoConnection, params);
67
71
  }
68
72
 
73
+ var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, fields);
74
+
75
+ if (!isCaptchaValid && !ssoConnection) {
76
+ return (0, _captcha.showMissingCaptcha)(m, id);
77
+ }
78
+
69
79
  logInActiveFlow(id, params);
70
80
  }
71
81
 
package/lib/core/index.js CHANGED
@@ -304,7 +304,8 @@ function extractUIOptions(id, options) {
304
304
  authButtonsTheme: (typeof authButtons === 'undefined' ? 'undefined' : _typeof(authButtons)) === 'object' ? authButtons : {},
305
305
  allowShowPassword: !!options.allowShowPassword,
306
306
  allowPasswordAutocomplete: !!options.allowPasswordAutocomplete,
307
- scrollGlobalMessagesIntoView: undefined === options.scrollGlobalMessagesIntoView ? true : !!options.scrollGlobalMessagesIntoView
307
+ scrollGlobalMessagesIntoView: undefined === options.scrollGlobalMessagesIntoView ? true : !!options.scrollGlobalMessagesIntoView,
308
+ forceAutoHeight: !!options.forceAutoHeight
308
309
  });
309
310
  }
310
311
 
@@ -401,6 +402,9 @@ var ui = exports.ui = {
401
402
  },
402
403
  allowPasswordAutocomplete: function allowPasswordAutocomplete(m) {
403
404
  return tget(m, 'allowPasswordAutocomplete', getUIAttribute(m, 'allowPasswordAutocomplete'));
405
+ },
406
+ forceAutoHeight: function forceAutoHeight(m) {
407
+ return tget(m, 'forceAutoHeight', getUIAttribute(m, 'forceAutoHeight'));
404
408
  }
405
409
  };
406
410
 
@@ -176,5 +176,5 @@ function trimAuthParams() {
176
176
  }
177
177
 
178
178
  function getVersion() {
179
- return '11.30.6';
179
+ return '11.32.1';
180
180
  }
@@ -60,7 +60,8 @@ var Auth0APIClient = function () {
60
60
  _telemetryInfo: telemetry,
61
61
  state: state,
62
62
  nonce: nonce,
63
- scope: scope
63
+ scope: scope,
64
+ legacySameSiteCookie: opts.legacySameSiteCookie
64
65
  });
65
66
 
66
67
  this.authOpt = {