auth0-lock 11.34.2 → 12.0.0-beta.0
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/.browserslistrc +1 -0
- package/.circleci/config.yml +4 -2
- package/.eslintrc.json +5 -5
- package/.github/workflows/codeql.yml +41 -0
- package/.shiprc +4 -5
- package/CHANGELOG.md +26 -0
- package/EXAMPLES.md +626 -0
- package/README.md +77 -649
- package/karma.conf.js +1 -1
- package/lib/CSSCore.js +1 -4
- package/lib/__tests__/auth_button.js +12 -22
- package/lib/__tests__/connection/database/actions.js +48 -49
- package/lib/__tests__/connection/database/index.js +22 -28
- package/lib/__tests__/connection/database/login_pane.js +20 -41
- package/lib/__tests__/connection/database/password_reset_confirmation.js +19 -26
- package/lib/__tests__/connection/database/reset_password.js +17 -39
- package/lib/__tests__/connection/database/signed_up_confirmation.js +19 -26
- package/lib/__tests__/connection/enterprise/actions.js +22 -47
- package/lib/__tests__/connection/enterprise/hrd_pane.js +16 -33
- package/lib/__tests__/connection/enterprise/hrd_screen.js +26 -40
- package/lib/__tests__/connection/enterprise/quick_auth_screen.js +27 -68
- package/lib/__tests__/connection/passwordless/ask_vcode.js +29 -51
- package/lib/__tests__/connection/passwordless/email_sent_confirmation.js +19 -26
- package/lib/__tests__/connection/passwordless/passwordless.js +35 -97
- package/lib/__tests__/core/actions.js +23 -46
- package/lib/__tests__/core/client/index.js +10 -13
- package/lib/__tests__/core/index.js +46 -94
- package/lib/__tests__/core/remote_data.js +14 -20
- package/lib/__tests__/core/signed_in_confirmation.js +19 -26
- package/lib/__tests__/core/sso/last_login_screen.js +27 -50
- package/lib/__tests__/core/tenant.js +10 -12
- package/lib/__tests__/core/web_api/helper.js +6 -14
- package/lib/__tests__/core/web_api/p2_api.js +38 -33
- package/lib/__tests__/core/web_api.js +37 -33
- package/lib/__tests__/engine/classic/login.js +20 -41
- package/lib/__tests__/engine/classic/mfa_login_screen.js +6 -19
- package/lib/__tests__/engine/classic/sign_up_pane.js +33 -55
- package/lib/__tests__/engine/classic/sign_up_screen.js +18 -45
- package/lib/__tests__/engine/classic.js +13 -6
- package/lib/__tests__/engine/passwordless.js +2 -5
- package/lib/__tests__/field/captcha/recaptcha_enterprise.js +27 -27
- package/lib/__tests__/field/captcha/recaptchav2.js +27 -27
- package/lib/__tests__/field/captcha.js +39 -51
- package/lib/__tests__/field/custom_input.js +23 -47
- package/lib/__tests__/field/email.js +2 -3
- package/lib/__tests__/field/email_pane.js +25 -48
- package/lib/__tests__/field/field.js +9 -13
- package/lib/__tests__/field/login_pane.js +30 -34
- package/lib/__tests__/field/mfa_code_pane.js +13 -28
- package/lib/__tests__/field/option_selection_pane.js +7 -25
- package/lib/__tests__/field/password.js +6 -12
- package/lib/__tests__/field/password_pane.js +29 -46
- package/lib/__tests__/field/phone_number_pane.js +18 -41
- package/lib/__tests__/field/social_buttons_pane.js +30 -47
- package/lib/__tests__/field/username.js +27 -48
- package/lib/__tests__/field/username_pane.js +30 -47
- package/lib/__tests__/field/vcode.js +5 -13
- package/lib/__tests__/field/vcode_pane.js +20 -44
- package/lib/__tests__/i18n.js +28 -53
- package/lib/__tests__/quick-auth/actions.js +4 -27
- package/lib/__tests__/setup-tests.js +7 -9
- package/lib/__tests__/testUtils.js +41 -58
- package/lib/__tests__/ui/box/chrome.js +24 -49
- package/lib/__tests__/ui/box/confirmation_pane.js +19 -36
- package/lib/__tests__/ui/box/container.js +21 -46
- package/lib/__tests__/ui/box/global_message.js +60 -37
- package/lib/__tests__/ui/input/email_input.js +6 -17
- package/lib/__tests__/ui/input/input_wrap.js +6 -19
- package/lib/__tests__/ui/input/password/password_strength.js +13 -15
- package/lib/__tests__/ui/input/password_input.js +22 -27
- package/lib/__tests__/utils/format.js +10 -17
- package/lib/__tests__/utils/url_utils.js +2 -5
- package/lib/avatar/gravatar_provider.js +13 -28
- package/lib/avatar.js +22 -41
- package/lib/browser.js +372 -23
- package/lib/connection/captcha.js +14 -32
- package/lib/connection/database/actions.js +39 -108
- package/lib/connection/database/index.js +90 -191
- package/lib/connection/database/login_pane.js +107 -147
- package/lib/connection/database/login_sign_up_tabs.js +106 -125
- package/lib/connection/database/mfa_pane.js +50 -69
- package/lib/connection/database/password_reset_confirmation.js +51 -73
- package/lib/connection/database/reset_password.js +116 -132
- package/lib/connection/database/reset_password_pane.js +45 -56
- package/lib/connection/database/sign_up_terms.js +17 -23
- package/lib/connection/database/signed_up_confirmation.js +52 -75
- package/lib/connection/enterprise/actions.js +23 -52
- package/lib/connection/enterprise/hrd_pane.js +60 -76
- package/lib/connection/enterprise/hrd_screen.js +60 -75
- package/lib/connection/enterprise/kerberos_screen.js +46 -60
- package/lib/connection/enterprise/quick_auth_screen.js +46 -64
- package/lib/connection/enterprise/single_sign_on_notice.js +14 -26
- package/lib/connection/enterprise.js +51 -84
- package/lib/connection/passwordless/actions.js +29 -62
- package/lib/connection/passwordless/ask_vcode.js +53 -60
- package/lib/connection/passwordless/email_sent_confirmation.js +129 -179
- package/lib/connection/passwordless/index.js +36 -68
- package/lib/connection/social/index.js +12 -15
- package/lib/core/actions.js +33 -85
- package/lib/core/client/index.js +38 -58
- package/lib/core/client/settings.js +12 -20
- package/lib/core/error_screen.js +38 -52
- package/lib/core/index.js +152 -301
- package/lib/core/loading_screen.js +61 -71
- package/lib/core/pane_separator.js +10 -10
- package/lib/core/remote_data.js +28 -48
- package/lib/core/screen.js +85 -79
- package/lib/core/signed_in_confirmation.js +51 -73
- package/lib/core/sso/data.js +9 -17
- package/lib/core/sso/index.js +5 -6
- package/lib/core/sso/last_login_screen.js +46 -63
- package/lib/core/tenant/index.js +37 -59
- package/lib/core/tenant/settings.js +11 -15
- package/lib/core/web_api/helper.js +24 -30
- package/lib/core/web_api/p2_api.js +156 -165
- package/lib/core/web_api.js +101 -90
- package/lib/core.js +126 -160
- package/lib/engine/classic/login.js +92 -144
- package/lib/engine/classic/mfa_login_screen.js +61 -67
- package/lib/engine/classic/sign_up_pane.js +89 -123
- package/lib/engine/classic/sign_up_screen.js +112 -158
- package/lib/engine/classic.js +122 -183
- package/lib/engine/passwordless/social_or_email_login_screen.js +71 -106
- package/lib/engine/passwordless/social_or_phone_number_login_screen.js +70 -100
- package/lib/engine/passwordless.js +75 -104
- package/lib/field/actions.js +11 -17
- package/lib/field/captcha/captcha_pane.js +82 -102
- package/lib/field/captcha/recaptcha.js +140 -145
- package/lib/field/captcha.js +7 -10
- package/lib/field/custom_input.js +37 -50
- package/lib/field/email/email_pane.js +90 -109
- package/lib/field/email.js +17 -35
- package/lib/field/index.js +51 -88
- package/lib/field/mfa-code/mfa_code_pane.js +57 -71
- package/lib/field/mfa_code.js +15 -21
- package/lib/field/option_selection_pane.js +16 -22
- package/lib/field/password/password_pane.js +79 -91
- package/lib/field/password.js +8 -14
- package/lib/field/phone-number/locations.js +7 -3
- package/lib/field/phone-number/phone_number_pane.js +87 -124
- package/lib/field/phone_number.js +16 -30
- package/lib/field/social/event.js +9 -12
- package/lib/field/social/social_buttons_pane.js +93 -121
- package/lib/field/username/username_pane.js +105 -123
- package/lib/field/username.js +16 -26
- package/lib/field/vcode/vcode_pane.js +67 -93
- package/lib/field/vcode.js +5 -5
- package/lib/i18n/af.js +7 -4
- package/lib/i18n/ar.js +7 -4
- package/lib/i18n/az.js +7 -4
- package/lib/i18n/bg.js +7 -4
- package/lib/i18n/ca.js +7 -4
- package/lib/i18n/cs.js +7 -4
- package/lib/i18n/da.js +7 -4
- package/lib/i18n/de.js +7 -3
- package/lib/i18n/el.js +7 -4
- package/lib/i18n/en.js +9 -4
- package/lib/i18n/es.js +7 -3
- package/lib/i18n/et.js +7 -4
- package/lib/i18n/fa.js +7 -4
- package/lib/i18n/fi.js +7 -4
- package/lib/i18n/fr.js +7 -4
- package/lib/i18n/he.js +7 -4
- package/lib/i18n/hr.js +7 -4
- package/lib/i18n/hu.js +7 -4
- package/lib/i18n/id.js +7 -4
- package/lib/i18n/it.js +7 -3
- package/lib/i18n/ja.js +7 -4
- package/lib/i18n/ko.js +7 -4
- package/lib/i18n/lt.js +7 -4
- package/lib/i18n/lv.js +7 -4
- package/lib/i18n/ms.js +7 -4
- package/lib/i18n/nb.js +7 -4
- package/lib/i18n/nl.js +7 -4
- package/lib/i18n/nn.js +7 -4
- package/lib/i18n/no.js +7 -4
- package/lib/i18n/pl.js +7 -4
- package/lib/i18n/pt-br.js +7 -3
- package/lib/i18n/pt.js +7 -4
- package/lib/i18n/ro.js +7 -4
- package/lib/i18n/ru.js +7 -4
- package/lib/i18n/sk.js +7 -4
- package/lib/i18n/sl.js +7 -4
- package/lib/i18n/sr.js +7 -4
- package/lib/i18n/sv.js +7 -4
- package/lib/i18n/tr.js +7 -4
- package/lib/i18n/ua.js +7 -4
- package/lib/i18n/uk.js +7 -4
- package/lib/i18n/vi.js +7 -4
- package/lib/i18n/zh-tw.js +7 -4
- package/lib/i18n/zh.js +7 -4
- package/lib/i18n.js +38 -75
- package/lib/index.js +14 -17
- package/lib/lock.js +29 -32
- package/lib/passwordless.js +29 -31
- package/lib/quick-auth/actions.js +19 -26
- package/lib/quick_auth.js +8 -10
- package/lib/sanitizer.js +5 -5
- package/lib/store/index.js +22 -42
- package/lib/sync.js +21 -42
- package/lib/ui/box/button.js +85 -105
- package/lib/ui/box/chrome.js +463 -548
- package/lib/ui/box/confirmation_pane.js +34 -48
- package/lib/ui/box/container.js +305 -339
- package/lib/ui/box/global_message.js +51 -60
- package/lib/ui/box/header.js +155 -177
- package/lib/ui/box/multisize_slide.js +233 -229
- package/lib/ui/box/success_pane.js +34 -37
- package/lib/ui/box.js +88 -93
- package/lib/ui/button/auth_button.js +44 -51
- package/lib/ui/input/captcha_input.js +162 -181
- package/lib/ui/input/checkbox_input.js +57 -59
- package/lib/ui/input/email_input.js +117 -124
- package/lib/ui/input/input_wrap.js +65 -80
- package/lib/ui/input/location_input.js +130 -150
- package/lib/ui/input/mfa_code_input.js +98 -98
- package/lib/ui/input/password/password_strength.js +103 -127
- package/lib/ui/input/password_input.js +141 -147
- package/lib/ui/input/phone_number_input.js +101 -109
- package/lib/ui/input/select_input.js +120 -132
- package/lib/ui/input/text_input.js +89 -84
- package/lib/ui/input/username_input.js +109 -115
- package/lib/ui/input/vcode_input.js +110 -118
- package/lib/ui/list.js +224 -247
- package/lib/ui/pane/quick_auth_pane.js +55 -80
- package/lib/utils/atom.js +55 -48
- package/lib/utils/cache.js +54 -43
- package/lib/utils/cdn_utils.js +17 -31
- package/lib/utils/createRef.js +3 -1
- package/lib/utils/data_utils.js +10 -16
- package/lib/utils/fn_utils.js +5 -4
- package/lib/utils/format.js +6 -8
- package/lib/utils/id_utils.js +4 -3
- package/lib/utils/jsonp_utils.js +20 -17
- package/lib/utils/media_utils.js +4 -2
- package/lib/utils/preload_utils.js +4 -3
- package/lib/utils/string_utils.js +4 -4
- package/lib/utils/url_utils.js +4 -3
- package/opslevel.yml +6 -0
- package/package.json +53 -38
- package/webpack.config.js +36 -3
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
exports
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
5
7
|
exports.setCaptchaParams = setCaptchaParams;
|
|
8
|
+
exports.showMissingCaptcha = showMissingCaptcha;
|
|
6
9
|
exports.swapCaptcha = swapCaptcha;
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var
|
|
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
|
-
|
|
10
|
+
var l = _interopRequireWildcard(require("../core/index"));
|
|
11
|
+
var c = _interopRequireWildcard(require("../field/index"));
|
|
12
|
+
var i18n = _interopRequireWildcard(require("../i18n"));
|
|
13
|
+
var _index3 = require("../store/index");
|
|
14
|
+
var _web_api = _interopRequireDefault(require("../core/web_api"));
|
|
26
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; }
|
|
29
|
-
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
30
18
|
/**
|
|
31
19
|
* Display the error message of missing captcha in the header of lock.
|
|
32
20
|
*
|
|
@@ -35,16 +23,12 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
35
23
|
*/
|
|
36
24
|
function showMissingCaptcha(m, id) {
|
|
37
25
|
var captchaConfig = l.captcha(m);
|
|
38
|
-
|
|
39
26
|
var captchaError = captchaConfig.get('provider') === 'recaptcha_v2' ? 'invalid_recaptcha' : 'invalid_captcha';
|
|
40
|
-
|
|
41
27
|
var errorMessage = i18n.html(m, ['error', 'login', captchaError]);
|
|
42
|
-
|
|
43
28
|
(0, _index3.swap)(_index3.updateEntity, 'lock', id, function (m) {
|
|
44
29
|
m = l.setSubmitting(m, false, errorMessage);
|
|
45
30
|
return c.showInvalidField(m, 'captcha');
|
|
46
31
|
});
|
|
47
|
-
|
|
48
32
|
return m;
|
|
49
33
|
}
|
|
50
34
|
|
|
@@ -60,7 +44,6 @@ function showMissingCaptcha(m, id) {
|
|
|
60
44
|
function setCaptchaParams(m, params, fields) {
|
|
61
45
|
var captchaConfig = l.captcha(m);
|
|
62
46
|
var isCaptchaRequired = captchaConfig && l.captcha(m).get('required');
|
|
63
|
-
|
|
64
47
|
if (!isCaptchaRequired) {
|
|
65
48
|
return true;
|
|
66
49
|
}
|
|
@@ -69,7 +52,6 @@ function setCaptchaParams(m, params, fields) {
|
|
|
69
52
|
if (!captcha) {
|
|
70
53
|
return false;
|
|
71
54
|
}
|
|
72
|
-
|
|
73
55
|
params['captcha'] = captcha;
|
|
74
56
|
fields.push('captcha');
|
|
75
57
|
return true;
|
|
@@ -83,7 +65,7 @@ function setCaptchaParams(m, params, fields) {
|
|
|
83
65
|
* @param {Function} [next] A callback.
|
|
84
66
|
*/
|
|
85
67
|
function swapCaptcha(id, wasInvalid, next) {
|
|
86
|
-
return
|
|
68
|
+
return _web_api.default.getChallenge(id, function (err, newCaptcha) {
|
|
87
69
|
if (!err && newCaptcha) {
|
|
88
70
|
(0, _index3.swap)(_index3.updateEntity, 'lock', id, l.setCaptcha, newCaptcha, wasInvalid);
|
|
89
71
|
}
|
|
@@ -1,89 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.cancelMFALogin = cancelMFALogin;
|
|
8
|
+
exports.cancelResetPassword = cancelResetPassword;
|
|
4
9
|
exports.logIn = logIn;
|
|
5
|
-
exports.signUp = signUp;
|
|
6
|
-
exports.signUpError = signUpError;
|
|
7
10
|
exports.resetPassword = resetPassword;
|
|
8
11
|
exports.showLoginActivity = showLoginActivity;
|
|
9
|
-
exports.
|
|
12
|
+
exports.showLoginMFAActivity = showLoginMFAActivity;
|
|
10
13
|
exports.showResetPasswordActivity = showResetPasswordActivity;
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
14
|
+
exports.showSignUpActivity = showSignUpActivity;
|
|
15
|
+
exports.signUp = signUp;
|
|
16
|
+
exports.signUpError = signUpError;
|
|
13
17
|
exports.toggleTermsAcceptance = toggleTermsAcceptance;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
var l = _interopRequireWildcard(_index2);
|
|
27
|
-
|
|
28
|
-
var _index3 = require('../../field/index');
|
|
29
|
-
|
|
30
|
-
var c = _interopRequireWildcard(_index3);
|
|
31
|
-
|
|
32
|
-
var _dompurify = require('dompurify');
|
|
33
|
-
|
|
34
|
-
var _index4 = require('./index');
|
|
35
|
-
|
|
36
|
-
var _i18n = require('../../i18n');
|
|
37
|
-
|
|
38
|
-
var i18n = _interopRequireWildcard(_i18n);
|
|
39
|
-
|
|
40
|
-
var _captcha = require('../captcha');
|
|
41
|
-
|
|
42
|
-
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; } }
|
|
43
|
-
|
|
18
|
+
var _index = require("../../store/index");
|
|
19
|
+
var _web_api = _interopRequireDefault(require("../../core/web_api"));
|
|
20
|
+
var _actions = require("../../core/actions");
|
|
21
|
+
var l = _interopRequireWildcard(require("../../core/index"));
|
|
22
|
+
var c = _interopRequireWildcard(require("../../field/index"));
|
|
23
|
+
var _dompurify = require("dompurify");
|
|
24
|
+
var _index4 = require("./index");
|
|
25
|
+
var i18n = _interopRequireWildcard(require("../../i18n"));
|
|
26
|
+
var _captcha = require("../captcha");
|
|
27
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
44
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
|
-
|
|
46
30
|
function logIn(id) {
|
|
47
31
|
var needsMFA = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
48
|
-
|
|
49
32
|
var m = (0, _index.read)(_index.getEntity, 'lock', id);
|
|
50
33
|
var usernameField = (0, _index4.databaseLogInWithEmail)(m) ? 'email' : 'username';
|
|
51
34
|
var username = c.getFieldValue(m, usernameField);
|
|
52
|
-
|
|
53
35
|
var params = {
|
|
54
36
|
connection: (0, _index4.databaseConnectionName)(m),
|
|
55
37
|
username: username,
|
|
56
38
|
password: c.getFieldValue(m, 'password')
|
|
57
39
|
};
|
|
58
|
-
|
|
59
40
|
var fields = [usernameField, 'password'];
|
|
60
41
|
var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, fields);
|
|
61
|
-
|
|
62
42
|
if (!isCaptchaValid) {
|
|
63
43
|
return (0, _captcha.showMissingCaptcha)(m, id);
|
|
64
44
|
}
|
|
65
|
-
|
|
66
45
|
var mfaCode = c.getFieldValue(m, 'mfa_code');
|
|
67
|
-
|
|
68
46
|
if (needsMFA) {
|
|
69
47
|
params['mfa_code'] = mfaCode;
|
|
70
48
|
fields.push('mfa_code');
|
|
71
49
|
}
|
|
72
|
-
|
|
73
50
|
(0, _actions.logIn)(id, fields, params, function (id, error, fields, next) {
|
|
74
51
|
if (error.error === 'a0.mfa_required') {
|
|
75
52
|
return showLoginMFAActivity(id);
|
|
76
53
|
}
|
|
77
|
-
|
|
78
54
|
if (error) {
|
|
79
55
|
var wasInvalid = error && error.code === 'invalid_captcha';
|
|
80
56
|
return (0, _captcha.swapCaptcha)(id, wasInvalid, next);
|
|
81
57
|
}
|
|
82
|
-
|
|
83
58
|
next();
|
|
84
59
|
});
|
|
85
60
|
}
|
|
86
|
-
|
|
87
61
|
function generateRandomUsername(length) {
|
|
88
62
|
var result = '';
|
|
89
63
|
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
@@ -93,7 +67,6 @@ function generateRandomUsername(length) {
|
|
|
93
67
|
}
|
|
94
68
|
return result;
|
|
95
69
|
}
|
|
96
|
-
|
|
97
70
|
function signUp(id) {
|
|
98
71
|
var m = (0, _index.read)(_index.getEntity, 'lock', id);
|
|
99
72
|
var fields = ['email', 'password'];
|
|
@@ -101,11 +74,9 @@ function signUp(id) {
|
|
|
101
74
|
// Skip the username validation if signUpHideUsernameField option is enabled.
|
|
102
75
|
// We will generate a random username to avoid name collusion before we make the signup API call.
|
|
103
76
|
if ((0, _index4.databaseConnectionRequiresUsername)(m) && !(0, _index4.signUpHideUsernameField)(m)) fields.push('username');
|
|
104
|
-
|
|
105
77
|
(0, _index4.additionalSignUpFields)(m).forEach(function (x) {
|
|
106
78
|
return fields.push(x.get('name'));
|
|
107
79
|
});
|
|
108
|
-
|
|
109
80
|
(0, _actions.validateAndSubmit)(id, fields, function (m) {
|
|
110
81
|
var params = {
|
|
111
82
|
connection: (0, _index4.databaseConnectionName)(m),
|
|
@@ -113,29 +84,29 @@ function signUp(id) {
|
|
|
113
84
|
password: c.getFieldValue(m, 'password'),
|
|
114
85
|
autoLogin: (0, _index4.shouldAutoLogin)(m)
|
|
115
86
|
};
|
|
116
|
-
|
|
117
87
|
var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, fields);
|
|
118
88
|
if (!isCaptchaValid) {
|
|
119
89
|
return (0, _captcha.showMissingCaptcha)(m, id);
|
|
120
90
|
}
|
|
121
|
-
|
|
122
91
|
if ((0, _index4.databaseConnectionRequiresUsername)(m)) {
|
|
123
92
|
if ((0, _index4.signUpHideUsernameField)(m)) {
|
|
124
93
|
var usernameValidation = (0, _index4.databaseConnection)(m).getIn(['validation', 'username']);
|
|
125
|
-
var range = usernameValidation ? usernameValidation.toJS() : {
|
|
94
|
+
var range = usernameValidation ? usernameValidation.toJS() : {
|
|
95
|
+
max: 15
|
|
96
|
+
};
|
|
126
97
|
params.username = generateRandomUsername(range.max);
|
|
127
98
|
} else {
|
|
128
99
|
params.username = c.getFieldValue(m, 'username');
|
|
129
100
|
}
|
|
130
101
|
}
|
|
131
|
-
|
|
132
102
|
if (!(0, _index4.additionalSignUpFields)(m).isEmpty()) {
|
|
133
103
|
params.user_metadata = {};
|
|
134
104
|
(0, _index4.additionalSignUpFields)(m).forEach(function (x) {
|
|
135
105
|
var storage = x.get('storage');
|
|
136
106
|
var fieldName = x.get('name');
|
|
137
|
-
var fieldValue = (0, _dompurify.sanitize)(c.getFieldValue(m, x.get('name')), {
|
|
138
|
-
|
|
107
|
+
var fieldValue = (0, _dompurify.sanitize)(c.getFieldValue(m, x.get('name')), {
|
|
108
|
+
ALLOWED_TAGS: []
|
|
109
|
+
});
|
|
139
110
|
switch (storage) {
|
|
140
111
|
case 'root':
|
|
141
112
|
params[fieldName] = fieldValue;
|
|
@@ -149,36 +120,30 @@ function signUp(id) {
|
|
|
149
120
|
}
|
|
150
121
|
});
|
|
151
122
|
}
|
|
152
|
-
|
|
153
123
|
var errorHandler = function errorHandler(error, popupHandler) {
|
|
154
124
|
if (!!popupHandler) {
|
|
155
125
|
popupHandler._current_popup.kill();
|
|
156
126
|
}
|
|
157
|
-
|
|
158
127
|
var wasInvalidCaptcha = error && error.code === 'invalid_captcha';
|
|
159
|
-
|
|
160
128
|
(0, _captcha.swapCaptcha)(id, wasInvalidCaptcha, function () {
|
|
161
129
|
setTimeout(function () {
|
|
162
130
|
return signUpError(id, error);
|
|
163
131
|
}, 250);
|
|
164
132
|
});
|
|
165
133
|
};
|
|
166
|
-
|
|
167
134
|
try {
|
|
168
135
|
// For now, always pass 'null' for the context as we don't need it yet.
|
|
169
136
|
// If we need it later, it'll save a breaking change in hooks already in use.
|
|
170
137
|
var context = null;
|
|
171
|
-
|
|
172
138
|
l.runHook(m, 'signingUp', context, function () {
|
|
173
|
-
|
|
174
|
-
for (var _len = arguments.length, args = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
175
|
-
args[_key - 3] = arguments[_key];
|
|
176
|
-
}
|
|
177
|
-
|
|
139
|
+
_web_api.default.signUp(id, params, function (error, result, popupHandler) {
|
|
178
140
|
if (error) {
|
|
179
141
|
errorHandler(error, popupHandler);
|
|
180
142
|
} else {
|
|
181
|
-
|
|
143
|
+
for (var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
144
|
+
args[_key - 3] = arguments[_key];
|
|
145
|
+
}
|
|
146
|
+
signUpSuccess.apply(void 0, [id, result, popupHandler].concat(args));
|
|
182
147
|
}
|
|
183
148
|
});
|
|
184
149
|
});
|
|
@@ -187,12 +152,9 @@ function signUp(id) {
|
|
|
187
152
|
}
|
|
188
153
|
});
|
|
189
154
|
}
|
|
190
|
-
|
|
191
155
|
function signUpSuccess(id, result, popupHandler) {
|
|
192
156
|
var lock = (0, _index.read)(_index.getEntity, 'lock', id);
|
|
193
|
-
|
|
194
157
|
l.emitEvent(lock, 'signup success', result);
|
|
195
|
-
|
|
196
158
|
if ((0, _index4.shouldAutoLogin)(lock)) {
|
|
197
159
|
(0, _index.swap)(_index.updateEntity, 'lock', id, function (m) {
|
|
198
160
|
return m.set('signedUp', true);
|
|
@@ -204,28 +166,23 @@ function signUpSuccess(id, result, popupHandler) {
|
|
|
204
166
|
username: c.email(lock),
|
|
205
167
|
password: c.password(lock)
|
|
206
168
|
};
|
|
207
|
-
|
|
208
169
|
if (!!popupHandler) {
|
|
209
170
|
options.popupHandler = popupHandler;
|
|
210
171
|
}
|
|
211
|
-
|
|
212
|
-
return _web_api2.default.logIn(id, options, l.auth.params(lock).toJS(), function (error) {
|
|
213
|
-
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
214
|
-
args[_key2 - 1] = arguments[_key2];
|
|
215
|
-
}
|
|
216
|
-
|
|
172
|
+
return _web_api.default.logIn(id, options, l.auth.params(lock).toJS(), function (error) {
|
|
217
173
|
if (error) {
|
|
218
174
|
setTimeout(function () {
|
|
219
175
|
return autoLogInError(id, error);
|
|
220
176
|
}, 250);
|
|
221
177
|
} else {
|
|
222
|
-
|
|
178
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
179
|
+
args[_key2 - 1] = arguments[_key2];
|
|
180
|
+
}
|
|
181
|
+
_actions.logInSuccess.apply(void 0, [id].concat(args));
|
|
223
182
|
}
|
|
224
183
|
});
|
|
225
184
|
}
|
|
226
|
-
|
|
227
185
|
var autoclose = l.ui.autoclose(lock);
|
|
228
|
-
|
|
229
186
|
if (!autoclose) {
|
|
230
187
|
(0, _index.swap)(_index.updateEntity, 'lock', id, function (lock) {
|
|
231
188
|
return l.setSubmitting(lock, false).set('signedUp', true);
|
|
@@ -234,37 +191,28 @@ function signUpSuccess(id, result, popupHandler) {
|
|
|
234
191
|
(0, _actions.closeLock)(id, false);
|
|
235
192
|
}
|
|
236
193
|
}
|
|
237
|
-
|
|
238
194
|
function signUpError(id, error) {
|
|
239
195
|
var m = (0, _index.read)(_index.getEntity, 'lock', id);
|
|
240
|
-
|
|
241
196
|
var invalidPasswordKeys = {
|
|
242
197
|
PasswordDictionaryError: 'password_dictionary_error',
|
|
243
198
|
PasswordNoUserInfoError: 'password_no_user_info_error',
|
|
244
199
|
PasswordStrengthError: 'password_strength_error'
|
|
245
200
|
};
|
|
246
|
-
|
|
247
201
|
l.emitEvent(m, 'signup error', error);
|
|
248
|
-
|
|
249
202
|
var errorKey = error.code === 'invalid_password' && invalidPasswordKeys[error.name] || error.code;
|
|
250
|
-
|
|
251
203
|
var errorMessage = i18n.html(m, ['error', 'signUp', errorKey]) || i18n.html(m, ['error', 'signUp', 'lock.fallback']);
|
|
252
|
-
|
|
253
204
|
if (error.code === 'hook_error') {
|
|
254
205
|
(0, _index.swap)(_index.updateEntity, 'lock', id, l.setSubmitting, false, error.description || errorMessage);
|
|
255
206
|
return;
|
|
256
207
|
}
|
|
257
|
-
|
|
258
208
|
if (errorKey === 'invalid_captcha') {
|
|
259
209
|
errorMessage = i18n.html(m, ['error', 'login', errorKey]);
|
|
260
210
|
return (0, _captcha.swapCaptcha)(id, true, function () {
|
|
261
211
|
(0, _index.swap)(_index.updateEntity, 'lock', id, l.setSubmitting, false, errorMessage);
|
|
262
212
|
});
|
|
263
213
|
}
|
|
264
|
-
|
|
265
214
|
(0, _index.swap)(_index.updateEntity, 'lock', id, l.setSubmitting, false, errorMessage);
|
|
266
215
|
}
|
|
267
|
-
|
|
268
216
|
function autoLogInError(id, error) {
|
|
269
217
|
(0, _index.swap)(_index.updateEntity, 'lock', id, function (m) {
|
|
270
218
|
var errorMessage = l.loginErrorMessage(m, error);
|
|
@@ -275,15 +223,13 @@ function autoLogInError(id, error) {
|
|
|
275
223
|
}
|
|
276
224
|
});
|
|
277
225
|
}
|
|
278
|
-
|
|
279
226
|
function resetPassword(id) {
|
|
280
227
|
(0, _actions.validateAndSubmit)(id, ['email'], function (m) {
|
|
281
228
|
var params = {
|
|
282
229
|
connection: (0, _index4.databaseConnectionName)(m),
|
|
283
230
|
email: c.getFieldValue(m, 'email')
|
|
284
231
|
};
|
|
285
|
-
|
|
286
|
-
_web_api2.default.resetPassword(id, params, function (error) {
|
|
232
|
+
_web_api.default.resetPassword(id, params, function (error) {
|
|
287
233
|
if (error) {
|
|
288
234
|
setTimeout(function () {
|
|
289
235
|
return resetPasswordError(id, error);
|
|
@@ -294,7 +240,6 @@ function resetPassword(id) {
|
|
|
294
240
|
});
|
|
295
241
|
});
|
|
296
242
|
}
|
|
297
|
-
|
|
298
243
|
function resetPasswordSuccess(id) {
|
|
299
244
|
var m = (0, _index.read)(_index.getEntity, 'lock', id);
|
|
300
245
|
if ((0, _index4.hasScreen)(m, 'login')) {
|
|
@@ -318,47 +263,33 @@ function resetPasswordSuccess(id) {
|
|
|
318
263
|
}
|
|
319
264
|
}
|
|
320
265
|
}
|
|
321
|
-
|
|
322
266
|
function resetPasswordError(id, error) {
|
|
323
267
|
var m = (0, _index.read)(_index.getEntity, 'lock', id);
|
|
324
|
-
|
|
325
268
|
var errorMessage = i18n.html(m, ['error', 'forgotPassword', error.code]) || i18n.html(m, ['error', 'forgotPassword', 'lock.fallback']);
|
|
326
|
-
|
|
327
269
|
(0, _index.swap)(_index.updateEntity, 'lock', id, l.setSubmitting, false, errorMessage);
|
|
328
270
|
}
|
|
329
|
-
|
|
330
271
|
function showLoginActivity(id) {
|
|
331
272
|
var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['password'];
|
|
332
|
-
|
|
333
273
|
(0, _index.swap)(_index.updateEntity, 'lock', id, _index4.setScreen, 'login', fields);
|
|
334
274
|
}
|
|
335
|
-
|
|
336
275
|
function showSignUpActivity(id) {
|
|
337
276
|
var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['password'];
|
|
338
|
-
|
|
339
277
|
(0, _index.swap)(_index.updateEntity, 'lock', id, _index4.setScreen, 'signUp', fields);
|
|
340
278
|
}
|
|
341
|
-
|
|
342
279
|
function showResetPasswordActivity(id) {
|
|
343
280
|
var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['password'];
|
|
344
|
-
|
|
345
281
|
(0, _index.swap)(_index.updateEntity, 'lock', id, _index4.setScreen, 'forgotPassword', fields);
|
|
346
282
|
}
|
|
347
|
-
|
|
348
283
|
function cancelResetPassword(id) {
|
|
349
284
|
return showLoginActivity(id);
|
|
350
285
|
}
|
|
351
|
-
|
|
352
286
|
function cancelMFALogin(id) {
|
|
353
287
|
return showLoginActivity(id);
|
|
354
288
|
}
|
|
355
|
-
|
|
356
289
|
function toggleTermsAcceptance(id) {
|
|
357
290
|
(0, _index.swap)(_index.updateEntity, 'lock', id, _index4.toggleTermsAcceptance);
|
|
358
291
|
}
|
|
359
|
-
|
|
360
292
|
function showLoginMFAActivity(id) {
|
|
361
293
|
var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['mfa_code'];
|
|
362
|
-
|
|
363
294
|
(0, _index.swap)(_index.updateEntity, 'lock', id, _index4.setScreen, 'mfaLogin', fields);
|
|
364
295
|
}
|