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
package/lib/field/index.js
CHANGED
|
@@ -1,165 +1,138 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.setField = setField;
|
|
8
|
-
exports.registerOptionField = registerOptionField;
|
|
9
|
-
exports.setOptionField = setOptionField;
|
|
10
|
-
exports.isFieldValid = isFieldValid;
|
|
11
|
-
exports.getFieldInvalidHint = getFieldInvalidHint;
|
|
12
|
-
exports.isFieldVisiblyInvalid = isFieldVisiblyInvalid;
|
|
13
|
-
exports.showInvalidField = showInvalidField;
|
|
14
|
-
exports.hideInvalidFields = hideInvalidFields;
|
|
15
|
-
exports.setFieldShowInvalid = setFieldShowInvalid;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
16
6
|
exports.clearFields = clearFields;
|
|
7
|
+
exports.email = email;
|
|
17
8
|
exports.getField = getField;
|
|
18
|
-
exports.
|
|
9
|
+
exports.getFieldInvalidHint = getFieldInvalidHint;
|
|
19
10
|
exports.getFieldLabel = getFieldLabel;
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.username = username;
|
|
25
|
-
exports.mfaCode = mfaCode;
|
|
11
|
+
exports.getFieldValue = getFieldValue;
|
|
12
|
+
exports.hideInvalidFields = hideInvalidFields;
|
|
13
|
+
exports.isFieldValid = isFieldValid;
|
|
14
|
+
exports.isFieldVisiblyInvalid = isFieldVisiblyInvalid;
|
|
26
15
|
exports.isSelecting = isSelecting;
|
|
16
|
+
exports.mfaCode = mfaCode;
|
|
17
|
+
exports.password = password;
|
|
18
|
+
exports.phoneNumber = phoneNumber;
|
|
19
|
+
exports.registerOptionField = registerOptionField;
|
|
27
20
|
exports.renderOptionSelection = renderOptionSelection;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
var _option_selection_pane2 = _interopRequireDefault(_option_selection_pane);
|
|
42
|
-
|
|
43
|
-
var _index = require('../core/index');
|
|
44
|
-
|
|
45
|
-
var l = _interopRequireWildcard(_index);
|
|
46
|
-
|
|
47
|
-
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; } }
|
|
48
|
-
|
|
21
|
+
exports.setField = setField;
|
|
22
|
+
exports.setFieldShowInvalid = setFieldShowInvalid;
|
|
23
|
+
exports.setOptionField = setOptionField;
|
|
24
|
+
exports.showInvalidField = showInvalidField;
|
|
25
|
+
exports.username = username;
|
|
26
|
+
exports.vcode = vcode;
|
|
27
|
+
var _react = _interopRequireDefault(require("react"));
|
|
28
|
+
var _immutable = require("immutable");
|
|
29
|
+
var _trim = _interopRequireDefault(require("trim"));
|
|
30
|
+
var _option_selection_pane = _interopRequireDefault(require("./option_selection_pane"));
|
|
31
|
+
var l = _interopRequireWildcard(require("../core/index"));
|
|
32
|
+
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); }
|
|
33
|
+
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; }
|
|
49
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
50
|
-
|
|
35
|
+
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); }
|
|
51
36
|
var minMax = function minMax(value, min, max) {
|
|
52
37
|
return value.length >= min && value.length <= max;
|
|
53
38
|
};
|
|
54
|
-
|
|
55
39
|
var getDefaultValidator = function getDefaultValidator(field) {
|
|
56
40
|
switch (field) {
|
|
57
41
|
case 'family_name':
|
|
58
42
|
case 'given_name':
|
|
59
43
|
return function (str) {
|
|
60
|
-
return minMax((0,
|
|
44
|
+
return minMax((0, _trim.default)(str), 1, 150);
|
|
61
45
|
};
|
|
62
46
|
case 'name':
|
|
63
47
|
return function (str) {
|
|
64
|
-
return minMax((0,
|
|
48
|
+
return minMax((0, _trim.default)(str), 1, 300);
|
|
65
49
|
};
|
|
66
50
|
case 'nickname':
|
|
67
51
|
return function (str) {
|
|
68
|
-
return minMax((0,
|
|
52
|
+
return minMax((0, _trim.default)(str), 1, 300);
|
|
69
53
|
};
|
|
70
|
-
|
|
71
54
|
default:
|
|
72
55
|
return function (str) {
|
|
73
|
-
return (0,
|
|
56
|
+
return (0, _trim.default)(str).length > 0;
|
|
74
57
|
};
|
|
75
58
|
}
|
|
76
59
|
};
|
|
77
|
-
|
|
78
60
|
function setField(m, field, value) {
|
|
79
61
|
var validator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : getDefaultValidator(field);
|
|
80
|
-
|
|
81
62
|
var prevValue = m.getIn(['field', field, 'value']);
|
|
82
63
|
var prevShowInvalid = m.getIn(['field', field, 'showInvalid'], false);
|
|
83
|
-
|
|
84
|
-
for (var _len = arguments.length, args = Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
|
|
64
|
+
for (var _len = arguments.length, args = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
|
|
85
65
|
args[_key - 4] = arguments[_key];
|
|
86
66
|
}
|
|
87
|
-
|
|
88
|
-
var validation = validate.apply(undefined, [validator, value].concat(args));
|
|
67
|
+
var validation = validate.apply(void 0, [validator, value].concat(args));
|
|
89
68
|
return m.mergeIn(['field', field], validation.merge({
|
|
90
69
|
value: value,
|
|
91
70
|
showInvalid: prevShowInvalid && prevValue === value
|
|
92
71
|
}));
|
|
93
72
|
}
|
|
94
|
-
|
|
95
73
|
function validate(validator, value) {
|
|
96
|
-
if (typeof validator != 'function') return (0, _immutable.Map)({
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
if (typeof validator != 'function') return (0, _immutable.Map)({
|
|
75
|
+
valid: true
|
|
76
|
+
});
|
|
77
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
99
78
|
args[_key2 - 2] = arguments[_key2];
|
|
100
79
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
80
|
+
var validation = validator.apply(void 0, [value].concat(args));
|
|
81
|
+
return validation && _typeof(validation) === 'object' ? (0, _immutable.Map)({
|
|
82
|
+
valid: validation.valid,
|
|
83
|
+
invalidHint: validation.hint
|
|
84
|
+
}) : (0, _immutable.Map)({
|
|
85
|
+
valid: !!validation
|
|
86
|
+
});
|
|
104
87
|
}
|
|
105
88
|
|
|
106
89
|
// TODO: this should handle icons, and everything.
|
|
107
90
|
// TODO: also there should be a similar fn for regular fields.
|
|
108
91
|
function registerOptionField(m, field, options, initialValue) {
|
|
109
92
|
var valid = true,
|
|
110
|
-
|
|
111
|
-
|
|
93
|
+
hasInitial = !initialValue,
|
|
94
|
+
initialOption;
|
|
112
95
|
options.forEach(function (x) {
|
|
113
96
|
valid = valid && x.get('label') && typeof x.get('label') === 'string' && x.get('value') && typeof x.get('value') === 'string';
|
|
114
|
-
|
|
115
97
|
if (!hasInitial && x.get('value') === initialValue) {
|
|
116
98
|
initialOption = x;
|
|
117
99
|
hasInitial = true;
|
|
118
100
|
}
|
|
119
101
|
});
|
|
120
|
-
|
|
121
102
|
if (!valid || !options.size) {
|
|
122
|
-
var stopError = new Error(
|
|
103
|
+
var stopError = new Error("The options provided for the \"".concat(field, "\" field are invalid, they must have the following format: {label: \"non-empty string\", value: \"non-empty string\"} and there has to be at least one option."));
|
|
123
104
|
stopError.code = 'invalid_select_field';
|
|
124
105
|
// TODO: in the future we might want to return the result of the
|
|
125
|
-
// operation along with the model
|
|
106
|
+
// operation along with the model instead of stopping the
|
|
126
107
|
// rendering, like [false, m] in the case of failure and [true, m]
|
|
127
108
|
// in the case of success.
|
|
128
109
|
return l.stop(m, stopError);
|
|
129
110
|
}
|
|
130
|
-
|
|
131
111
|
if (!initialOption) initialOption = (0, _immutable.Map)({});
|
|
132
|
-
|
|
133
112
|
return m.mergeIn(['field', field], initialOption, (0, _immutable.Map)({
|
|
134
113
|
options: options,
|
|
135
114
|
showInvalid: false,
|
|
136
115
|
valid: !initialOption.isEmpty()
|
|
137
116
|
}));
|
|
138
117
|
}
|
|
139
|
-
|
|
140
118
|
function setOptionField(m, field, option) {
|
|
141
119
|
return m.mergeIn(['field', field], option.merge((0, _immutable.Map)({
|
|
142
120
|
valid: true,
|
|
143
121
|
showInvalid: false
|
|
144
122
|
})));
|
|
145
123
|
}
|
|
146
|
-
|
|
147
124
|
function isFieldValid(m, field) {
|
|
148
125
|
return m.getIn(['field', field, 'valid']);
|
|
149
126
|
}
|
|
150
|
-
|
|
151
127
|
function getFieldInvalidHint(m, field) {
|
|
152
128
|
return m.getIn(['field', field, 'invalidHint'], '');
|
|
153
129
|
}
|
|
154
|
-
|
|
155
130
|
function isFieldVisiblyInvalid(m, field) {
|
|
156
131
|
return m.getIn(['field', field, 'showInvalid'], false) && !m.getIn(['field', field, 'valid']);
|
|
157
132
|
}
|
|
158
|
-
|
|
159
133
|
function showInvalidField(m, field) {
|
|
160
134
|
return m.setIn(['field', field, 'showInvalid'], !isFieldValid(m, field));
|
|
161
135
|
}
|
|
162
|
-
|
|
163
136
|
function hideInvalidFields(m) {
|
|
164
137
|
return m.update('field', function (fields) {
|
|
165
138
|
return fields && fields.map(function (field) {
|
|
@@ -173,10 +146,8 @@ function hideInvalidFields(m) {
|
|
|
173
146
|
function setFieldShowInvalid(m, field, value) {
|
|
174
147
|
return m.setIn(['field', field, 'showInvalid'], value);
|
|
175
148
|
}
|
|
176
|
-
|
|
177
149
|
function clearFields(m, fields) {
|
|
178
|
-
var keyPaths
|
|
179
|
-
|
|
150
|
+
var keyPaths;
|
|
180
151
|
if (!fields || fields.length === 0) {
|
|
181
152
|
keyPaths = [['field']];
|
|
182
153
|
} else {
|
|
@@ -184,27 +155,20 @@ function clearFields(m, fields) {
|
|
|
184
155
|
return ['field', x];
|
|
185
156
|
});
|
|
186
157
|
}
|
|
187
|
-
|
|
188
158
|
return keyPaths.reduce(function (r, v) {
|
|
189
159
|
return r.removeIn(v);
|
|
190
160
|
}, m);
|
|
191
161
|
}
|
|
192
|
-
|
|
193
162
|
function getField(m, field) {
|
|
194
163
|
var notFound = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new _immutable.Map({});
|
|
195
|
-
|
|
196
164
|
return m.getIn(['field', field], notFound);
|
|
197
165
|
}
|
|
198
|
-
|
|
199
166
|
function getFieldValue(m, field) {
|
|
200
167
|
var notFound = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
201
|
-
|
|
202
168
|
return getField(m, field).get('value', notFound);
|
|
203
169
|
}
|
|
204
|
-
|
|
205
170
|
function getFieldLabel(m, field) {
|
|
206
171
|
var notFound = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
207
|
-
|
|
208
172
|
return getField(m, field).get('label', notFound);
|
|
209
173
|
}
|
|
210
174
|
|
|
@@ -249,10 +213,9 @@ function mfaCode(m) {
|
|
|
249
213
|
function isSelecting(m) {
|
|
250
214
|
return !!m.getIn(['field', 'selecting']);
|
|
251
215
|
}
|
|
252
|
-
|
|
253
216
|
function renderOptionSelection(m) {
|
|
254
217
|
var name = m.getIn(['field', 'selecting', 'name']);
|
|
255
|
-
return isSelecting(m) ?
|
|
218
|
+
return isSelecting(m) ? /*#__PURE__*/_react.default.createElement(_option_selection_pane.default, {
|
|
256
219
|
model: m,
|
|
257
220
|
name: name,
|
|
258
221
|
icon: m.getIn(['field', 'selecting', 'icon']),
|
|
@@ -1,81 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _react = require(
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
var _index = require('../index');
|
|
18
|
-
|
|
19
|
-
var c = _interopRequireWildcard(_index);
|
|
20
|
-
|
|
21
|
-
var _index2 = require('../../store/index');
|
|
22
|
-
|
|
23
|
-
var _index3 = require('../../core/index');
|
|
24
|
-
|
|
25
|
-
var l = _interopRequireWildcard(_index3);
|
|
26
|
-
|
|
27
|
-
var _mfa_code = require('../mfa_code');
|
|
28
|
-
|
|
29
|
-
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; } }
|
|
30
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
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.default = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _mfa_code_input = _interopRequireDefault(require("../../ui/input/mfa_code_input"));
|
|
11
|
+
var c = _interopRequireWildcard(require("../index"));
|
|
12
|
+
var _index2 = require("../../store/index");
|
|
13
|
+
var l = _interopRequireWildcard(require("../../core/index"));
|
|
14
|
+
var _mfa_code = require("../mfa_code");
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
31
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
|
-
|
|
33
18
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
34
|
-
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
20
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
22
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
|
+
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
24
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
26
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
27
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
+
var MFACodePane = /*#__PURE__*/function (_React$Component) {
|
|
40
31
|
_inherits(MFACodePane, _React$Component);
|
|
41
|
-
|
|
32
|
+
var _super = _createSuper(MFACodePane);
|
|
42
33
|
function MFACodePane() {
|
|
43
34
|
_classCallCheck(this, MFACodePane);
|
|
44
|
-
|
|
45
|
-
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
|
35
|
+
return _super.apply(this, arguments);
|
|
46
36
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
37
|
+
_createClass(MFACodePane, [{
|
|
38
|
+
key: "handleChange",
|
|
39
|
+
value: function handleChange(e) {
|
|
40
|
+
var lock = this.props.lock;
|
|
41
|
+
(0, _index2.swap)(_index2.updateEntity, 'lock', l.id(lock), _mfa_code.setMFACode, e.target.value);
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "render",
|
|
45
|
+
value: function render() {
|
|
46
|
+
var _this$props = this.props,
|
|
47
|
+
i18n = _this$props.i18n,
|
|
48
|
+
lock = _this$props.lock,
|
|
49
|
+
placeholder = _this$props.placeholder;
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_mfa_code_input.default, {
|
|
51
|
+
lockId: l.id(lock),
|
|
52
|
+
value: c.getFieldValue(lock, 'mfa_code'),
|
|
53
|
+
invalidHint: i18n.str('mfaCodeErrorHint', (0, _mfa_code.getMFACodeValidation)().length),
|
|
54
|
+
isValid: !c.isFieldVisiblyInvalid(lock, 'mfa_code'),
|
|
55
|
+
onChange: this.handleChange.bind(this),
|
|
56
|
+
placeholder: placeholder
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}]);
|
|
71
60
|
return MFACodePane;
|
|
72
|
-
}(
|
|
73
|
-
|
|
61
|
+
}(_react.default.Component);
|
|
74
62
|
exports.default = MFACodePane;
|
|
75
|
-
|
|
76
|
-
|
|
77
63
|
MFACodePane.propTypes = {
|
|
78
|
-
i18n:
|
|
79
|
-
lock:
|
|
80
|
-
placeholder:
|
|
64
|
+
i18n: _propTypes.default.object.isRequired,
|
|
65
|
+
lock: _propTypes.default.object.isRequired,
|
|
66
|
+
placeholder: _propTypes.default.string.isRequired
|
|
81
67
|
};
|
package/lib/field/mfa_code.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
5
6
|
exports.getMFACodeValidation = getMFACodeValidation;
|
|
6
|
-
|
|
7
|
-
var _index = require(
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
var _database = require('../connection/database');
|
|
12
|
-
|
|
13
|
-
var _trim = require('trim');
|
|
14
|
-
|
|
15
|
-
var _trim2 = _interopRequireDefault(_trim);
|
|
16
|
-
|
|
7
|
+
exports.setMFACode = setMFACode;
|
|
8
|
+
var _index = require("./index");
|
|
9
|
+
var _email = require("./email");
|
|
10
|
+
var _database = require("../connection/database");
|
|
11
|
+
var _trim = _interopRequireDefault(require("trim"));
|
|
17
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
var DEFAULT_VALIDATION = {
|
|
14
|
+
mfa_code: {
|
|
15
|
+
length: 6
|
|
16
|
+
}
|
|
17
|
+
};
|
|
20
18
|
var regExp = /^[0-9]+$/;
|
|
21
|
-
|
|
22
19
|
function validateMFACode(str) {
|
|
23
20
|
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VALIDATION.mfa_code;
|
|
24
|
-
|
|
25
|
-
var value = (0, _trim2.default)(str);
|
|
21
|
+
var value = (0, _trim.default)(str);
|
|
26
22
|
|
|
27
23
|
// check min value matched
|
|
28
24
|
if (value.length < settings.length) {
|
|
@@ -38,11 +34,9 @@ function validateMFACode(str) {
|
|
|
38
34
|
var result = regExp.exec(value);
|
|
39
35
|
return result && result[0];
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
function setMFACode(m, str) {
|
|
43
38
|
return (0, _index.setField)(m, 'mfa_code', str, validateMFACode);
|
|
44
39
|
}
|
|
45
|
-
|
|
46
40
|
function getMFACodeValidation(m) {
|
|
47
41
|
return DEFAULT_VALIDATION.mfa_code;
|
|
48
42
|
}
|
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
var _list2 = _interopRequireDefault(_list);
|
|
12
|
-
|
|
13
|
-
var _actions = require('./actions');
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _list = _interopRequireDefault(require("../ui/list"));
|
|
9
|
+
var _actions = require("./actions");
|
|
15
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
11
|
// TODO: these actions should be passed as props
|
|
18
|
-
|
|
19
|
-
exports.default = function (_ref) {
|
|
12
|
+
var _default = function _default(_ref) {
|
|
20
13
|
var icon = _ref.icon,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
14
|
+
iconUrl = _ref.iconUrl,
|
|
15
|
+
model = _ref.model,
|
|
16
|
+
name = _ref.name,
|
|
17
|
+
items = _ref.items;
|
|
18
|
+
return /*#__PURE__*/_react.default.createElement(_list.default, {
|
|
26
19
|
model: model,
|
|
27
20
|
icon: icon,
|
|
28
21
|
iconUrl: iconUrl,
|
|
@@ -35,3 +28,4 @@ exports.default = function (_ref) {
|
|
|
35
28
|
}
|
|
36
29
|
});
|
|
37
30
|
};
|
|
31
|
+
exports.default = _default;
|