auth0-lock 11.34.1 → 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 +32 -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,36 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _react = require('react');
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(_react);
|
|
6
|
-
|
|
7
|
-
var _enzyme = require('enzyme');
|
|
8
|
-
|
|
9
|
-
var _immutable = require('immutable');
|
|
10
|
-
|
|
11
|
-
var _immutable2 = _interopRequireDefault(_immutable);
|
|
12
|
-
|
|
13
|
-
var _testUtils = require('testUtils');
|
|
1
|
+
"use strict";
|
|
14
2
|
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _enzyme = require("enzyme");
|
|
5
|
+
var _immutable = _interopRequireDefault(require("immutable"));
|
|
6
|
+
var _testUtils = require("testUtils");
|
|
15
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
8
|
+
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); }
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
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); }
|
|
17
12
|
jest.mock('ui/pane/quick_auth_pane', function () {
|
|
18
13
|
return (0, _testUtils.mockComponent)('quick_auth_pane');
|
|
19
14
|
});
|
|
20
15
|
|
|
21
16
|
//there's a circular dependency with this module, so we need to mock it
|
|
22
17
|
jest.mock('engine/classic');
|
|
23
|
-
|
|
24
18
|
var getComponent = function getComponent() {
|
|
25
19
|
var LastLoginScreen = require('core/sso/last_login_screen').default;
|
|
26
20
|
var screen = new LastLoginScreen();
|
|
27
21
|
return screen.render();
|
|
28
22
|
};
|
|
29
|
-
|
|
30
23
|
describe('LastLoginScreen', function () {
|
|
31
24
|
beforeEach(function () {
|
|
32
25
|
jest.resetModules();
|
|
33
|
-
|
|
34
26
|
jest.mock('quick-auth/actions', function () {
|
|
35
27
|
return {
|
|
36
28
|
logIn: jest.fn(),
|
|
@@ -38,7 +30,6 @@ describe('LastLoginScreen', function () {
|
|
|
38
30
|
skipQuickAuth: jest.fn()
|
|
39
31
|
};
|
|
40
32
|
});
|
|
41
|
-
|
|
42
33
|
jest.mock('core/index', function () {
|
|
43
34
|
return {
|
|
44
35
|
id: function id() {
|
|
@@ -49,7 +40,6 @@ describe('LastLoginScreen', function () {
|
|
|
49
40
|
}
|
|
50
41
|
};
|
|
51
42
|
});
|
|
52
|
-
|
|
53
43
|
jest.mock('core/sso/index', function () {
|
|
54
44
|
return {
|
|
55
45
|
lastUsedConnection: function lastUsedConnection() {
|
|
@@ -64,7 +54,6 @@ describe('LastLoginScreen', function () {
|
|
|
64
54
|
}
|
|
65
55
|
};
|
|
66
56
|
});
|
|
67
|
-
|
|
68
57
|
jest.mock('connection/social/index', function () {
|
|
69
58
|
return {
|
|
70
59
|
STRATEGIES: {
|
|
@@ -83,24 +72,21 @@ describe('LastLoginScreen', function () {
|
|
|
83
72
|
var defaultProps = {
|
|
84
73
|
i18n: {
|
|
85
74
|
str: function str() {
|
|
86
|
-
for (var _len = arguments.length, keys = Array(_len), _key = 0; _key < _len; _key++) {
|
|
75
|
+
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
87
76
|
keys[_key] = arguments[_key];
|
|
88
77
|
}
|
|
89
|
-
|
|
90
78
|
return keys.join(',');
|
|
91
79
|
},
|
|
92
80
|
group: function group() {
|
|
93
|
-
for (var _len2 = arguments.length, keys = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
81
|
+
for (var _len2 = arguments.length, keys = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
94
82
|
keys[_key2] = arguments[_key2];
|
|
95
83
|
}
|
|
96
|
-
|
|
97
84
|
return keys.join(',');
|
|
98
85
|
},
|
|
99
86
|
html: function html() {
|
|
100
|
-
for (var _len3 = arguments.length, keys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
87
|
+
for (var _len3 = arguments.length, keys = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
101
88
|
keys[_key3] = arguments[_key3];
|
|
102
89
|
}
|
|
103
|
-
|
|
104
90
|
return keys.join(',');
|
|
105
91
|
}
|
|
106
92
|
},
|
|
@@ -108,13 +94,13 @@ describe('LastLoginScreen', function () {
|
|
|
108
94
|
};
|
|
109
95
|
it('renders correctly', function () {
|
|
110
96
|
var Component = getComponent();
|
|
111
|
-
(0, _testUtils.expectComponent)(
|
|
97
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Component, defaultProps)).toMatchSnapshot();
|
|
112
98
|
});
|
|
113
99
|
it('renders with custom connection theme', function () {
|
|
114
100
|
require('connection/social/index').authButtonsTheme = function () {
|
|
115
101
|
return {
|
|
116
102
|
get: function get() {
|
|
117
|
-
return
|
|
103
|
+
return _immutable.default.fromJS({
|
|
118
104
|
primaryColor: 'primaryColor',
|
|
119
105
|
foregroundColor: 'foregroundColor',
|
|
120
106
|
icon: 'icon'
|
|
@@ -123,34 +109,31 @@ describe('LastLoginScreen', function () {
|
|
|
123
109
|
};
|
|
124
110
|
};
|
|
125
111
|
var Component = getComponent();
|
|
126
|
-
(0, _testUtils.expectComponent)(
|
|
112
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Component, defaultProps)).toMatchSnapshot();
|
|
127
113
|
});
|
|
128
114
|
describe('renders correct icon', function () {
|
|
129
|
-
var _require$STRATEGIES;
|
|
130
|
-
|
|
131
115
|
var testStrategy = function testStrategy(strategy) {
|
|
132
|
-
it(
|
|
116
|
+
it("when strategy is ".concat(strategy), function () {
|
|
133
117
|
require('core/sso/index').lastUsedConnection = function () {
|
|
134
|
-
return
|
|
118
|
+
return _immutable.default.fromJS({
|
|
135
119
|
strategy: strategy
|
|
136
120
|
});
|
|
137
121
|
};
|
|
138
122
|
var Component = getComponent();
|
|
139
|
-
(0, _testUtils.expectComponent)(
|
|
123
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Component, defaultProps)).toMatchSnapshot();
|
|
140
124
|
});
|
|
141
125
|
};
|
|
142
126
|
var testStrategyName = 'this-strategy-exists';
|
|
143
|
-
require('connection/social/index').STRATEGIES = (
|
|
127
|
+
require('connection/social/index').STRATEGIES = _defineProperty({}, testStrategyName, 'Test Strategy');
|
|
144
128
|
var strategies = [testStrategyName, 'google-apps', 'adfs', 'office365', 'waad', 'some-other-strategy'].forEach(testStrategy);
|
|
145
|
-
|
|
146
|
-
it('when strategy is empty, use name instead', function () {
|
|
129
|
+
it("when strategy is empty, use name instead", function () {
|
|
147
130
|
require('core/sso/index').lastUsedConnection = function () {
|
|
148
|
-
return
|
|
131
|
+
return _immutable.default.fromJS({
|
|
149
132
|
name: testStrategyName
|
|
150
133
|
});
|
|
151
134
|
};
|
|
152
135
|
var Component = getComponent();
|
|
153
|
-
(0, _testUtils.expectComponent)(
|
|
136
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Component, defaultProps)).toMatchSnapshot();
|
|
154
137
|
});
|
|
155
138
|
});
|
|
156
139
|
describe('renders correct buttonLabel', function () {
|
|
@@ -166,25 +149,23 @@ describe('LastLoginScreen', function () {
|
|
|
166
149
|
return undefined;
|
|
167
150
|
};
|
|
168
151
|
var Component = getComponent();
|
|
169
|
-
(0, _testUtils.expectComponent)(
|
|
152
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Component, defaultProps)).toMatchSnapshot();
|
|
170
153
|
});
|
|
171
154
|
it('uses lastUsedConnectionName when there is not a lastUsedUsername and no SOCIAL_STRATEGY mapping', function () {
|
|
172
155
|
require('core/sso/index').lastUsedUsername = function () {
|
|
173
156
|
return undefined;
|
|
174
157
|
};
|
|
175
158
|
var Component = getComponent();
|
|
176
|
-
(0, _testUtils.expectComponent)(
|
|
159
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Component, defaultProps)).toMatchSnapshot();
|
|
177
160
|
});
|
|
178
161
|
});
|
|
179
162
|
it('calls checkSession in the buttonClickHandler when outside of the universal login page', function () {
|
|
180
163
|
(0, _testUtils.setURL)('https://other-url.auth0.com');
|
|
181
164
|
var Component = getComponent();
|
|
182
|
-
var wrapper = (0, _enzyme.mount)(
|
|
165
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(Component, defaultProps));
|
|
183
166
|
var props = (0, _testUtils.extractPropsFromWrapper)(wrapper);
|
|
184
167
|
props.buttonClickHandler();
|
|
185
|
-
|
|
186
168
|
var mock = require('quick-auth/actions').checkSession.mock;
|
|
187
|
-
|
|
188
169
|
expect(mock.calls.length).toBe(1);
|
|
189
170
|
expect(mock.calls[0][0]).toBe('id');
|
|
190
171
|
expect(mock.calls[0][1].get()).toBe('lastUsedConnection');
|
|
@@ -193,12 +174,10 @@ describe('LastLoginScreen', function () {
|
|
|
193
174
|
it('calls logIn in the buttonClickHandler when inside of the universal login page', function () {
|
|
194
175
|
(0, _testUtils.setURL)('https://me.auth0.com');
|
|
195
176
|
var Component = getComponent();
|
|
196
|
-
var wrapper = (0, _enzyme.mount)(
|
|
177
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(Component, defaultProps));
|
|
197
178
|
var props = (0, _testUtils.extractPropsFromWrapper)(wrapper);
|
|
198
179
|
props.buttonClickHandler();
|
|
199
|
-
|
|
200
180
|
var mock = require('quick-auth/actions').logIn.mock;
|
|
201
|
-
|
|
202
181
|
expect(mock.calls.length).toBe(1);
|
|
203
182
|
expect(mock.calls[0][0]).toBe('id');
|
|
204
183
|
expect(mock.calls[0][1].get()).toBe('lastUsedConnection');
|
|
@@ -206,12 +185,10 @@ describe('LastLoginScreen', function () {
|
|
|
206
185
|
});
|
|
207
186
|
it('calls skipQuickAuth in the alternativeClickHandler', function () {
|
|
208
187
|
var Component = getComponent();
|
|
209
|
-
var wrapper = (0, _enzyme.mount)(
|
|
188
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(Component, defaultProps));
|
|
210
189
|
var props = (0, _testUtils.extractPropsFromWrapper)(wrapper);
|
|
211
190
|
props.alternativeClickHandler();
|
|
212
|
-
|
|
213
191
|
var mock = require('quick-auth/actions').skipQuickAuth.mock;
|
|
214
|
-
|
|
215
192
|
expect(mock.calls.length).toBe(1);
|
|
216
193
|
expect(mock.calls[0][0]).toBe('id');
|
|
217
194
|
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
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
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
3
7
|
var getInitTenant = function getInitTenant() {
|
|
4
8
|
return require('core/tenant/index').initTenant;
|
|
5
9
|
};
|
|
6
|
-
|
|
7
10
|
var CLIENT_ID = 'client_id';
|
|
8
|
-
|
|
9
11
|
var runTest = function runTest(initTenant, mockDataFns, client) {
|
|
10
12
|
initTenant({}, CLIENT_ID, client);
|
|
11
13
|
expect(mockDataFns.initNS.mock.calls.length).toBe(1);
|
|
12
14
|
var tenantInfo = mockDataFns.initNS.mock.calls[0][1].toJS();
|
|
13
15
|
expect(tenantInfo).toMatchSnapshot();
|
|
14
16
|
};
|
|
15
|
-
|
|
16
17
|
describe('initTenant()', function () {
|
|
17
|
-
var initTenant
|
|
18
|
-
var mockDataFns
|
|
18
|
+
var initTenant;
|
|
19
|
+
var mockDataFns;
|
|
19
20
|
beforeEach(function () {
|
|
20
21
|
jest.resetModules();
|
|
21
|
-
|
|
22
22
|
mockDataFns = {
|
|
23
23
|
initNS: jest.fn(),
|
|
24
24
|
get: jest.fn()
|
|
@@ -30,7 +30,6 @@ describe('initTenant()', function () {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
|
-
|
|
34
33
|
jest.mock('core/index', function () {
|
|
35
34
|
return {
|
|
36
35
|
findConnection: jest.fn()
|
|
@@ -80,7 +79,8 @@ describe('initTenant()', function () {
|
|
|
80
79
|
requiresUsername: true,
|
|
81
80
|
strategy: 'auth0',
|
|
82
81
|
validation: {
|
|
83
|
-
passwordPolicy: 'low',
|
|
82
|
+
passwordPolicy: 'low',
|
|
83
|
+
//minLength: 6
|
|
84
84
|
username: {
|
|
85
85
|
min: 4,
|
|
86
86
|
max: 5
|
|
@@ -177,8 +177,6 @@ describe('initTenant()', function () {
|
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
179
|
test('filters clientConnections', function () {
|
|
180
|
-
var _clientsConnections;
|
|
181
|
-
|
|
182
180
|
var client = {
|
|
183
181
|
connections: {
|
|
184
182
|
database: [{
|
|
@@ -189,7 +187,7 @@ describe('initTenant()', function () {
|
|
|
189
187
|
strategy: 'auth0'
|
|
190
188
|
}]
|
|
191
189
|
},
|
|
192
|
-
clientsConnections: (
|
|
190
|
+
clientsConnections: _defineProperty({}, CLIENT_ID, ['test-connection-database'])
|
|
193
191
|
};
|
|
194
192
|
runTest(initTenant, mockDataFns, client);
|
|
195
193
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _helper = require('core/web_api/helper');
|
|
1
|
+
"use strict";
|
|
4
2
|
|
|
3
|
+
var _helper = require("core/web_api/helper");
|
|
5
4
|
describe('webAuthOverrides', function () {
|
|
6
5
|
it('should return overrides if any field is compatible with WebAuth', function () {
|
|
7
6
|
expect((0, _helper.webAuthOverrides)({
|
|
@@ -10,7 +9,6 @@ describe('webAuthOverrides', function () {
|
|
|
10
9
|
__jwks_uri: 'https://jwks.com'
|
|
11
10
|
})).toMatchSnapshot();
|
|
12
11
|
});
|
|
13
|
-
|
|
14
12
|
it('should omit overrides that are not compatible with WebAuth', function () {
|
|
15
13
|
expect((0, _helper.webAuthOverrides)({
|
|
16
14
|
__tenant: 'tenant1',
|
|
@@ -19,18 +17,17 @@ describe('webAuthOverrides', function () {
|
|
|
19
17
|
backgroundColor: 'blue'
|
|
20
18
|
})).toMatchSnapshot();
|
|
21
19
|
});
|
|
22
|
-
|
|
23
20
|
it('should return null if no fields are compatible with WebAuth', function () {
|
|
24
|
-
expect((0, _helper.webAuthOverrides)({
|
|
21
|
+
expect((0, _helper.webAuthOverrides)({
|
|
22
|
+
backgroundColor: 'blue'
|
|
23
|
+
})).toBe(null);
|
|
25
24
|
});
|
|
26
25
|
});
|
|
27
|
-
|
|
28
26
|
describe('normalizeError', function () {
|
|
29
27
|
it('does nothing when there is no error', function () {
|
|
30
28
|
var normalized = (0, _helper.normalizeError)(undefined);
|
|
31
29
|
expect(normalized).toBe(undefined);
|
|
32
30
|
});
|
|
33
|
-
|
|
34
31
|
describe('access_denied to invalid_user_password mapping', function () {
|
|
35
32
|
var domainMock = 'domainMock';
|
|
36
33
|
var errorObjWithError = {
|
|
@@ -41,8 +38,7 @@ describe('normalizeError', function () {
|
|
|
41
38
|
code: 'access_denied',
|
|
42
39
|
description: 'foobar'
|
|
43
40
|
};
|
|
44
|
-
var currentWindowObj
|
|
45
|
-
|
|
41
|
+
var currentWindowObj;
|
|
46
42
|
beforeAll(function () {
|
|
47
43
|
currentWindowObj = window.window;
|
|
48
44
|
window.window = {
|
|
@@ -51,11 +47,9 @@ describe('normalizeError', function () {
|
|
|
51
47
|
}
|
|
52
48
|
};
|
|
53
49
|
});
|
|
54
|
-
|
|
55
50
|
afterAll(function () {
|
|
56
51
|
window.window = currentWindowObj;
|
|
57
52
|
});
|
|
58
|
-
|
|
59
53
|
describe('domain is undefined', function () {
|
|
60
54
|
it('should map access_denied error to invalid_user_password when error.error === access_denied', function () {
|
|
61
55
|
var actualError = (0, _helper.normalizeError)(errorObjWithError);
|
|
@@ -66,7 +60,6 @@ describe('normalizeError', function () {
|
|
|
66
60
|
expect(actualError).toMatchSnapshot();
|
|
67
61
|
});
|
|
68
62
|
});
|
|
69
|
-
|
|
70
63
|
describe("domain doesn't match current host", function () {
|
|
71
64
|
it('should map access_denied error to invalid_user_password when error.error === access_denied', function () {
|
|
72
65
|
var actualError = (0, _helper.normalizeError)(errorObjWithError, 'loremIpsum');
|
|
@@ -77,7 +70,6 @@ describe('normalizeError', function () {
|
|
|
77
70
|
expect(actualError).toMatchSnapshot();
|
|
78
71
|
});
|
|
79
72
|
});
|
|
80
|
-
|
|
81
73
|
describe('domain match current host', function () {
|
|
82
74
|
it('should not map access_denied error to invalid_user_password when error.error === access_denied', function () {
|
|
83
75
|
var actualError = (0, _helper.normalizeError)(errorObjWithError, domainMock);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _testUtils = require('testUtils');
|
|
1
|
+
"use strict";
|
|
4
2
|
|
|
3
|
+
var _testUtils = require("testUtils");
|
|
5
4
|
jest.mock('auth0-js');
|
|
6
|
-
|
|
7
5
|
var getClient = function getClient() {
|
|
8
6
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9
|
-
|
|
10
7
|
var lockId = 'lockId';
|
|
11
8
|
var clientId = 'cid';
|
|
12
9
|
var domain = 'me.auth0.com';
|
|
@@ -27,7 +24,6 @@ var getClient = function getClient() {
|
|
|
27
24
|
};
|
|
28
25
|
return client;
|
|
29
26
|
};
|
|
30
|
-
|
|
31
27
|
var getAuth0ClientMock = function getAuth0ClientMock() {
|
|
32
28
|
return require('auth0-js');
|
|
33
29
|
};
|
|
@@ -48,43 +44,57 @@ describe('Auth0APIClient', function () {
|
|
|
48
44
|
describe('init', function () {
|
|
49
45
|
describe('with overrides', function () {
|
|
50
46
|
it('always uses telemetry set in the `auth0Client` query param and inside the ULP', function () {
|
|
51
|
-
var telemetryIn = {
|
|
52
|
-
|
|
47
|
+
var telemetryIn = {
|
|
48
|
+
name: 'test-sdk',
|
|
49
|
+
version: '1.0.0',
|
|
50
|
+
env: {
|
|
51
|
+
envOverride: true
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
(0, _testUtils.setURL)("https://me.auth0.com/authorize?auth0Client=".concat(btoa(JSON.stringify(telemetryIn))));
|
|
53
55
|
var options = {
|
|
54
56
|
audience: 'foo',
|
|
55
57
|
redirectUrl: '//localhost:8080/login/callback',
|
|
56
58
|
responseMode: 'query',
|
|
57
59
|
responseType: 'code',
|
|
58
60
|
leeway: 30,
|
|
59
|
-
_telemetryInfo: {
|
|
61
|
+
_telemetryInfo: {
|
|
62
|
+
ignored: true
|
|
63
|
+
}
|
|
60
64
|
};
|
|
61
65
|
getClient(options);
|
|
62
66
|
var mock = getAuth0ClientMock();
|
|
63
67
|
expect(mock.WebAuth.mock.calls[0][0]._telemetryInfo).toMatchSnapshot();
|
|
64
68
|
});
|
|
65
69
|
it('overrides telemetry when outside the ULP', function () {
|
|
66
|
-
(0, _testUtils.setURL)(
|
|
70
|
+
(0, _testUtils.setURL)("https://auth.myapp.com/authorize");
|
|
67
71
|
var options = {
|
|
68
72
|
audience: 'foo',
|
|
69
73
|
redirectUrl: '//localhost:8080/login/callback',
|
|
70
74
|
responseMode: 'query',
|
|
71
75
|
responseType: 'code',
|
|
72
76
|
leeway: 30,
|
|
73
|
-
_telemetryInfo: {
|
|
77
|
+
_telemetryInfo: {
|
|
78
|
+
name: 'test-sdk',
|
|
79
|
+
version: '1.0.0',
|
|
80
|
+
env: {
|
|
81
|
+
envOverride: true
|
|
82
|
+
}
|
|
83
|
+
}
|
|
74
84
|
};
|
|
75
85
|
getClient(options);
|
|
76
86
|
var mock = getAuth0ClientMock();
|
|
77
87
|
expect(mock.WebAuth.mock.calls[0][0]._telemetryInfo).toMatchSnapshot();
|
|
78
88
|
});
|
|
79
89
|
it('uses default telemetry key when outside the ULP', function () {
|
|
80
|
-
(0, _testUtils.setURL)(
|
|
90
|
+
(0, _testUtils.setURL)("https://auth.myapp.com/authorize");
|
|
81
91
|
getClient();
|
|
82
92
|
var mock = getAuth0ClientMock();
|
|
83
93
|
expect(mock.WebAuth.mock.calls[0][0]._telemetryInfo.name).toEqual('lock.js');
|
|
84
94
|
expect(Object.keys(mock.WebAuth.mock.calls[0][0]._telemetryInfo.env)).toContain('auth0.js');
|
|
85
95
|
});
|
|
86
96
|
it('overrides auth0.js telemetry key', function () {
|
|
87
|
-
(0, _testUtils.setURL)(
|
|
97
|
+
(0, _testUtils.setURL)("https://auth.myapp.com/authorize");
|
|
88
98
|
var options = {
|
|
89
99
|
audience: 'foo',
|
|
90
100
|
redirectUrl: '//localhost:8080/login/callback',
|
|
@@ -94,7 +104,9 @@ describe('Auth0APIClient', function () {
|
|
|
94
104
|
_telemetryInfo: {
|
|
95
105
|
name: 'test-sdk',
|
|
96
106
|
version: '1.0.0',
|
|
97
|
-
env: {
|
|
107
|
+
env: {
|
|
108
|
+
'auth0.js': 'this-will-be-overriden'
|
|
109
|
+
}
|
|
98
110
|
}
|
|
99
111
|
};
|
|
100
112
|
getClient(options);
|
|
@@ -109,7 +121,7 @@ describe('Auth0APIClient', function () {
|
|
|
109
121
|
expect(Object.keys(mock.WebAuth.mock.calls[0][0]._telemetryInfo.env)).toContain('auth0.js-ulp');
|
|
110
122
|
});
|
|
111
123
|
it('forwards options to WebAuth', function () {
|
|
112
|
-
(0, _testUtils.setURL)(
|
|
124
|
+
(0, _testUtils.setURL)("https://auth.myapp.com/authorize");
|
|
113
125
|
var options = {
|
|
114
126
|
audience: 'foo',
|
|
115
127
|
redirectUrl: '//localhost:8080/login/callback',
|
|
@@ -134,9 +146,8 @@ describe('Auth0APIClient', function () {
|
|
|
134
146
|
var mock = getAuth0ClientMock();
|
|
135
147
|
expect(mock.WebAuth.mock.calls[0][0]).toMatchSnapshot();
|
|
136
148
|
});
|
|
137
|
-
|
|
138
149
|
it('forwards options to WebAuth with a default leeway', function () {
|
|
139
|
-
(0, _testUtils.setURL)(
|
|
150
|
+
(0, _testUtils.setURL)("https://auth.myapp.com/authorize");
|
|
140
151
|
var options = {
|
|
141
152
|
audience: 'foo',
|
|
142
153
|
redirectUrl: '//localhost:8080/login/callback',
|
|
@@ -161,7 +172,6 @@ describe('Auth0APIClient', function () {
|
|
|
161
172
|
expect(mock.WebAuth.mock.calls[0][0]).toMatchSnapshot();
|
|
162
173
|
});
|
|
163
174
|
});
|
|
164
|
-
|
|
165
175
|
describe('should set authOpt according options', function () {
|
|
166
176
|
it('should set sso:true when inside the universal login page', function () {
|
|
167
177
|
(0, _testUtils.setURL)('https://me.auth0.com/');
|
|
@@ -320,8 +330,8 @@ describe('Auth0APIClient', function () {
|
|
|
320
330
|
});
|
|
321
331
|
});
|
|
322
332
|
describe('should trim spaces in', function () {
|
|
323
|
-
var client
|
|
324
|
-
var callback
|
|
333
|
+
var client;
|
|
334
|
+
var callback;
|
|
325
335
|
var getMock = function getMock() {
|
|
326
336
|
return getAuth0ClientMock().WebAuth.mock.instances[0].login.mock;
|
|
327
337
|
};
|
|
@@ -360,8 +370,8 @@ describe('Auth0APIClient', function () {
|
|
|
360
370
|
});
|
|
361
371
|
describe('signUp', function () {
|
|
362
372
|
describe('should trim spaces in', function () {
|
|
363
|
-
var client
|
|
364
|
-
var callback
|
|
373
|
+
var client;
|
|
374
|
+
var callback;
|
|
365
375
|
var getMock = function getMock() {
|
|
366
376
|
return getAuth0ClientMock().WebAuth.mock.instances[0].signup.mock;
|
|
367
377
|
};
|
|
@@ -393,8 +403,8 @@ describe('Auth0APIClient', function () {
|
|
|
393
403
|
});
|
|
394
404
|
describe('resetPassword', function () {
|
|
395
405
|
describe('should trim spaces in', function () {
|
|
396
|
-
var client
|
|
397
|
-
var callback
|
|
406
|
+
var client;
|
|
407
|
+
var callback;
|
|
398
408
|
var getMock = function getMock() {
|
|
399
409
|
return getAuth0ClientMock().WebAuth.mock.instances[0].changePassword.mock;
|
|
400
410
|
};
|
|
@@ -431,13 +441,12 @@ describe('Auth0APIClient', function () {
|
|
|
431
441
|
foo: 'bar'
|
|
432
442
|
}, function () {});
|
|
433
443
|
var mock = client.client.passwordlessStart.mock;
|
|
434
|
-
|
|
435
444
|
expect(mock.calls.length).toBe(1);
|
|
436
445
|
expect(mock.calls[0]).toMatchSnapshot();
|
|
437
446
|
});
|
|
438
447
|
describe('should trim spaces in', function () {
|
|
439
|
-
var client
|
|
440
|
-
var callback
|
|
448
|
+
var client;
|
|
449
|
+
var callback;
|
|
441
450
|
var getMock = function getMock() {
|
|
442
451
|
return getAuth0ClientMock().WebAuth.mock.instances[0].passwordlessStart.mock;
|
|
443
452
|
};
|
|
@@ -468,13 +477,12 @@ describe('Auth0APIClient', function () {
|
|
|
468
477
|
foo: 'bar'
|
|
469
478
|
}, function () {});
|
|
470
479
|
var mock = client.client.passwordlessLogin.mock;
|
|
471
|
-
|
|
472
480
|
expect(mock.calls.length).toBe(1);
|
|
473
481
|
expect(mock.calls[0]).toMatchSnapshot();
|
|
474
482
|
});
|
|
475
483
|
describe('should trim spaces in', function () {
|
|
476
|
-
var client
|
|
477
|
-
var callback
|
|
484
|
+
var client;
|
|
485
|
+
var callback;
|
|
478
486
|
var getMock = function getMock() {
|
|
479
487
|
return getAuth0ClientMock().WebAuth.mock.instances[0].passwordlessLogin.mock;
|
|
480
488
|
};
|
|
@@ -498,12 +506,10 @@ describe('Auth0APIClient', function () {
|
|
|
498
506
|
});
|
|
499
507
|
});
|
|
500
508
|
});
|
|
501
|
-
|
|
502
509
|
it('getUserCountry should call getUserCountry', function () {
|
|
503
510
|
var client = getClient({});
|
|
504
511
|
client.getUserCountry('cb');
|
|
505
512
|
var mock = client.client.client.getUserCountry.mock;
|
|
506
|
-
|
|
507
513
|
expect(mock.calls.length).toBe(1);
|
|
508
514
|
expect(mock.calls[0]).toMatchSnapshot();
|
|
509
515
|
});
|
|
@@ -511,7 +517,6 @@ describe('Auth0APIClient', function () {
|
|
|
511
517
|
var client = getClient({});
|
|
512
518
|
client.getSSOData(true, function () {});
|
|
513
519
|
var mock = client.client.client.getSSOData.mock;
|
|
514
|
-
|
|
515
520
|
expect(mock.calls.length).toBe(1);
|
|
516
521
|
expect(mock.calls[0]).toMatchSnapshot();
|
|
517
522
|
});
|