auth0-lock 11.30.5 → 11.32.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/.circleci/config.yml +11 -7
- package/.eslintrc.json +9 -2
- package/.prettierignore +1 -0
- package/.prettierrc.yaml +5 -0
- package/.shiprc +2 -1
- package/CHANGELOG.md +389 -210
- package/README.md +162 -140
- package/karma.conf.js +4 -10
- package/lib/__tests__/connection/database/login_pane.js +93 -0
- package/lib/__tests__/connection/database/reset_password.js +82 -4
- package/lib/__tests__/connection/enterprise/actions.js +25 -2
- package/lib/__tests__/engine/classic/login.js +0 -2
- package/lib/__tests__/engine/classic/sign_up_pane.js +67 -2
- package/lib/__tests__/testUtils.js +17 -1
- package/lib/__tests__/ui/box/chrome.js +18 -2
- package/lib/__tests__/ui/input/password_input.js +4 -1
- package/lib/browser.js +12 -10
- package/lib/connection/captcha.js +94 -0
- package/lib/connection/database/actions.js +11 -69
- package/lib/connection/database/login_pane.js +11 -2
- package/lib/connection/database/reset_password.js +15 -0
- package/lib/connection/enterprise/actions.js +10 -0
- package/lib/core/index.js +5 -1
- package/lib/core/web_api/helper.js +1 -1
- package/lib/core.js +1 -1
- package/lib/engine/classic/login.js +2 -2
- package/lib/engine/classic/sign_up_pane.js +8 -3
- package/lib/field/captcha/captcha_pane.js +0 -4
- package/lib/i18n.js +7 -5
- package/lib/lock.js +1 -1
- package/lib/passwordless.js +1 -1
- package/lib/ui/box/chrome.js +20 -5
- package/lib/ui/box/container.js +2 -2
- package/lib/ui/box/header.js +5 -0
- package/lib/ui/input/password_input.js +1 -0
- package/lib/utils/cdn_utils.js +1 -1
- package/package.json +20 -23
- package/local.log +0 -8
- package/yarn-error.log +0 -11514
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _react = require('react');
|
|
4
|
+
|
|
5
|
+
var _react2 = _interopRequireDefault(_react);
|
|
6
|
+
|
|
7
|
+
var _immutable = require('immutable');
|
|
8
|
+
|
|
9
|
+
var _immutable2 = _interopRequireDefault(_immutable);
|
|
10
|
+
|
|
11
|
+
var _testUtils = require('testUtils');
|
|
12
|
+
|
|
13
|
+
var _login_pane = require('../../../connection/database/login_pane');
|
|
14
|
+
|
|
15
|
+
var _login_pane2 = _interopRequireDefault(_login_pane);
|
|
16
|
+
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
|
|
19
|
+
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
|
20
|
+
|
|
21
|
+
var lock = _immutable2.default.fromJS({ id: '__lock-id__' });
|
|
22
|
+
|
|
23
|
+
jest.mock('core/index');
|
|
24
|
+
|
|
25
|
+
jest.mock('engine/classic');
|
|
26
|
+
jest.mock('connection/enterprise');
|
|
27
|
+
|
|
28
|
+
describe('LoginPane', function () {
|
|
29
|
+
var defaultProps = {
|
|
30
|
+
emailInputPlaceholder: '',
|
|
31
|
+
forgotPasswordAction: '',
|
|
32
|
+
i18n: {},
|
|
33
|
+
passwordInputPlaceholder: '',
|
|
34
|
+
showForgotPasswordLink: true,
|
|
35
|
+
showPassword: true,
|
|
36
|
+
usernameInputPlaceholder: '',
|
|
37
|
+
lock: lock
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
beforeEach(function () {
|
|
41
|
+
jest.resetAllMocks();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('renders correctly', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
45
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
46
|
+
while (1) {
|
|
47
|
+
switch (_context.prev = _context.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
(0, _testUtils.expectShallowComponent)(_react2.default.createElement(_login_pane2.default, defaultProps)).toMatchSnapshot();
|
|
50
|
+
|
|
51
|
+
case 1:
|
|
52
|
+
case 'end':
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, _callee, undefined);
|
|
57
|
+
})));
|
|
58
|
+
|
|
59
|
+
it('renders a captcha', function () {
|
|
60
|
+
require('core/index').captcha.mockReturnValue({
|
|
61
|
+
get: function get() {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
(0, _testUtils.expectShallowComponent)(_react2.default.createElement(_login_pane2.default, defaultProps)).toMatchSnapshot();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('hides the captcha for SSO connections', function () {
|
|
70
|
+
require('core/index').captcha.mockReturnValue({
|
|
71
|
+
get: function get() {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
require('engine/classic').isSSOEnabled.mockReturnValue(true);
|
|
77
|
+
|
|
78
|
+
(0, _testUtils.expectShallowComponent)(_react2.default.createElement(_login_pane2.default, defaultProps)).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('shows the captcha for SSO (ADFS) connections', function () {
|
|
82
|
+
require('core/index').captcha.mockReturnValue({
|
|
83
|
+
get: function get() {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
require('engine/classic').isSSOEnabled.mockReturnValue(true);
|
|
89
|
+
require('connection/enterprise').isHRDDomain.mockReturnValue(true);
|
|
90
|
+
|
|
91
|
+
(0, _testUtils.expectShallowComponent)(_react2.default.createElement(_login_pane2.default, defaultProps)).toMatchSnapshot();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -4,15 +4,30 @@ var _react = require('react');
|
|
|
4
4
|
|
|
5
5
|
var _react2 = _interopRequireDefault(_react);
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _testUtils = require('testUtils');
|
|
8
|
+
|
|
9
|
+
var _immutable = require('immutable');
|
|
10
|
+
|
|
11
|
+
var _immutable2 = _interopRequireDefault(_immutable);
|
|
12
|
+
|
|
13
|
+
var _field = require('../../../field');
|
|
8
14
|
|
|
9
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
16
|
|
|
17
|
+
jest.mock('connection/database/reset_password_pane', function () {
|
|
18
|
+
return (0, _testUtils.mockComponent)('reset_password_pane');
|
|
19
|
+
});
|
|
20
|
+
|
|
11
21
|
var getScreen = function getScreen() {
|
|
12
22
|
var ResetPasswordScreen = require('connection/database/reset_password').default;
|
|
13
23
|
return new ResetPasswordScreen();
|
|
14
24
|
};
|
|
15
25
|
|
|
26
|
+
var getComponent = function getComponent() {
|
|
27
|
+
var screen = getScreen();
|
|
28
|
+
return screen.render();
|
|
29
|
+
};
|
|
30
|
+
|
|
16
31
|
describe('ResetPasswordScreen', function () {
|
|
17
32
|
beforeEach(function () {
|
|
18
33
|
jest.resetModules();
|
|
@@ -35,9 +50,11 @@ describe('ResetPasswordScreen', function () {
|
|
|
35
50
|
});
|
|
36
51
|
|
|
37
52
|
jest.mock('i18n', function () {
|
|
38
|
-
return {
|
|
53
|
+
return {
|
|
54
|
+
str: function str(_, keys) {
|
|
39
55
|
return keys.join(',');
|
|
40
|
-
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
41
58
|
});
|
|
42
59
|
|
|
43
60
|
jest.mock('core/index', function () {
|
|
@@ -46,7 +63,16 @@ describe('ResetPasswordScreen', function () {
|
|
|
46
63
|
return 'id';
|
|
47
64
|
},
|
|
48
65
|
setGlobalError: 'setGlobalError',
|
|
49
|
-
clearGlobalError: 'clearGlobalError'
|
|
66
|
+
clearGlobalError: 'clearGlobalError',
|
|
67
|
+
connectionResolver: jest.fn().mockReturnValue(undefined),
|
|
68
|
+
ui: {
|
|
69
|
+
allowAutocomplete: function allowAutocomplete() {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
submitting: function submitting() {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
50
76
|
};
|
|
51
77
|
});
|
|
52
78
|
|
|
@@ -57,6 +83,7 @@ describe('ResetPasswordScreen', function () {
|
|
|
57
83
|
};
|
|
58
84
|
});
|
|
59
85
|
});
|
|
86
|
+
|
|
60
87
|
it('isSubmitDisabled returns true when `isEnterpriseDomain` is true', function () {
|
|
61
88
|
jest.useFakeTimers();
|
|
62
89
|
require('connection/enterprise').isEnterpriseDomain = function () {
|
|
@@ -67,6 +94,7 @@ describe('ResetPasswordScreen', function () {
|
|
|
67
94
|
jest.runTimersToTime(50);
|
|
68
95
|
expect(require('store/index').swap.mock.calls[0]).toMatchSnapshot();
|
|
69
96
|
});
|
|
97
|
+
|
|
70
98
|
it('isSubmitDisabled returns false when `isEnterpriseDomain` is false', function () {
|
|
71
99
|
require('connection/enterprise').isEnterpriseDomain = function () {
|
|
72
100
|
return false;
|
|
@@ -75,4 +103,54 @@ describe('ResetPasswordScreen', function () {
|
|
|
75
103
|
expect(screen.isSubmitDisabled()).toBe(false);
|
|
76
104
|
expect(require('store/index').swap.mock.calls[0]).toMatchSnapshot();
|
|
77
105
|
});
|
|
106
|
+
|
|
107
|
+
describe('a custom connection resolver is being used', function () {
|
|
108
|
+
var lock = void 0;
|
|
109
|
+
var i18n = void 0;
|
|
110
|
+
|
|
111
|
+
beforeEach(function () {
|
|
112
|
+
lock = _immutable2.default.fromJS({
|
|
113
|
+
id: '__lock-id__'
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
i18n = {
|
|
117
|
+
html: jest.fn(),
|
|
118
|
+
str: jest.fn()
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('copies the username to the email field if an email address was entered', function () {
|
|
123
|
+
require('core/index').connectionResolver.mockReturnValue(function () {
|
|
124
|
+
return function () {
|
|
125
|
+
return true;
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
var store = require('store/index');
|
|
129
|
+
var Component = getComponent();
|
|
130
|
+
|
|
131
|
+
// Set a field on Lock to set the username field, then check it was set as the email
|
|
132
|
+
var l = (0, _field.setField)(lock, 'username', 'test@test.com');
|
|
133
|
+
|
|
134
|
+
(0, _testUtils.expectComponent)(_react2.default.createElement(Component, { i18n: i18n, model: l })).toMatchSnapshot();
|
|
135
|
+
|
|
136
|
+
expect(store.swap).toHaveBeenCalledWith('updateEntity', 'lock', 'id', expect.anything(), 'test@test.com', false);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('sets the email field to a blank value if username is not an email address', function () {
|
|
140
|
+
require('core/index').connectionResolver.mockReturnValue(function () {
|
|
141
|
+
return function () {
|
|
142
|
+
return true;
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
var store = require('store/index');
|
|
146
|
+
var Component = getComponent();
|
|
147
|
+
|
|
148
|
+
// Set a field on Lock to set the username field, then check it was set as the email
|
|
149
|
+
var l = (0, _field.setField)(lock, 'username', 'some-username');
|
|
150
|
+
|
|
151
|
+
(0, _testUtils.expectComponent)(_react2.default.createElement(Component, { i18n: i18n, model: l })).toMatchSnapshot();
|
|
152
|
+
|
|
153
|
+
expect(store.swap).toHaveBeenCalledWith('updateEntity', 'lock', 'id', expect.anything(), '', false);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
78
156
|
});
|
|
@@ -20,7 +20,8 @@ jest.mock('connection/database/index', function () {
|
|
|
20
20
|
return {
|
|
21
21
|
databaseLogInWithEmail: jest.fn(function () {
|
|
22
22
|
return true;
|
|
23
|
-
})
|
|
23
|
+
}),
|
|
24
|
+
databaseUsernameValue: jest.fn()
|
|
24
25
|
};
|
|
25
26
|
});
|
|
26
27
|
|
|
@@ -39,7 +40,8 @@ jest.mock('connection/enterprise', function () {
|
|
|
39
40
|
return {
|
|
40
41
|
matchConnection: jest.fn(),
|
|
41
42
|
enterpriseActiveFlowConnection: jest.fn(),
|
|
42
|
-
isHRDActive: jest.fn()
|
|
43
|
+
isHRDActive: jest.fn(),
|
|
44
|
+
isEnterpriseDomain: jest.fn()
|
|
43
45
|
};
|
|
44
46
|
});
|
|
45
47
|
|
|
@@ -87,6 +89,27 @@ describe('Login with connection scopes', function () {
|
|
|
87
89
|
login_hint: 'test@test.com'
|
|
88
90
|
});
|
|
89
91
|
});
|
|
92
|
+
|
|
93
|
+
it('should not throw an error if the captcha was not completed', function () {
|
|
94
|
+
lock = l.setup('__lock__', 'client', 'domain', {});
|
|
95
|
+
lock = (0, _index2.setField)(lock, 'email', 'test@test.com');
|
|
96
|
+
|
|
97
|
+
// This will be specified in the response from the /challenge endpoint if the
|
|
98
|
+
// dashboard settings have Captcha as 'required', regardless of connection being used.
|
|
99
|
+
lock = l.setCaptcha(lock, {
|
|
100
|
+
required: true,
|
|
101
|
+
provider: 'recaptcha_v2'
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
require('store/index').read.mockReturnValue(lock);
|
|
105
|
+
|
|
106
|
+
require('connection/enterprise').matchConnection.mockReturnValue(_immutable2.default.fromJS({ name: 'sso-connection' }));
|
|
107
|
+
|
|
108
|
+
var coreActions = require('core/actions');
|
|
109
|
+
|
|
110
|
+
(0, _actions.logIn)('__lock__');
|
|
111
|
+
expect(coreActions.logIn).toHaveBeenCalled();
|
|
112
|
+
});
|
|
90
113
|
});
|
|
91
114
|
|
|
92
115
|
describe('for a non-SSO connection', function () {
|
|
@@ -6,10 +6,10 @@ var _react = require('react');
|
|
|
6
6
|
|
|
7
7
|
var _react2 = _interopRequireDefault(_react);
|
|
8
8
|
|
|
9
|
-
var _enzyme = require('enzyme');
|
|
10
|
-
|
|
11
9
|
var _testUtils = require('testUtils');
|
|
12
10
|
|
|
11
|
+
var _testUtils2 = require('../../testUtils');
|
|
12
|
+
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
|
|
15
15
|
jest.mock('field/email/email_pane', function () {
|
|
@@ -25,6 +25,24 @@ jest.mock('field/custom_input', function () {
|
|
|
25
25
|
return (0, _testUtils.mockComponent)('custom_input');
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
jest.mock('core/index', function () {
|
|
29
|
+
return {
|
|
30
|
+
captcha: jest.fn()
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
jest.mock('engine/classic', function () {
|
|
35
|
+
return {
|
|
36
|
+
isSSOEnabled: jest.fn()
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
jest.mock('connection/enterprise', function () {
|
|
41
|
+
return {
|
|
42
|
+
isHRDDomain: jest.fn()
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
28
46
|
var getComponent = function getComponent() {
|
|
29
47
|
return require('engine/classic/sign_up_pane').default;
|
|
30
48
|
};
|
|
@@ -46,6 +64,9 @@ describe('SignUpPane', function () {
|
|
|
46
64
|
},
|
|
47
65
|
signUpFieldsStrictValidation: function signUpFieldsStrictValidation() {
|
|
48
66
|
return true;
|
|
67
|
+
},
|
|
68
|
+
databaseUsernameValue: function databaseUsernameValue() {
|
|
69
|
+
return null;
|
|
49
70
|
}
|
|
50
71
|
};
|
|
51
72
|
});
|
|
@@ -85,6 +106,50 @@ describe('SignUpPane', function () {
|
|
|
85
106
|
|
|
86
107
|
(0, _testUtils.expectComponent)(_react2.default.createElement(Component, _extends({}, defaultProps, { instructions: 'instructions' }))).toMatchSnapshot();
|
|
87
108
|
});
|
|
109
|
+
|
|
110
|
+
it('shows the Captcha pane', function () {
|
|
111
|
+
require('core/index').captcha.mockReturnValue({
|
|
112
|
+
get: function get() {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
require('engine/classic').isSSOEnabled.mockReturnValue(false);
|
|
118
|
+
|
|
119
|
+
var Component = getComponent();
|
|
120
|
+
|
|
121
|
+
(0, _testUtils2.expectShallowComponent)(_react2.default.createElement(Component, defaultProps)).toMatchSnapshot();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('hides the Captcha pane for SSO connections', function () {
|
|
125
|
+
require('core/index').captcha.mockReturnValue({
|
|
126
|
+
get: function get() {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
require('engine/classic').isSSOEnabled.mockReturnValue(true);
|
|
132
|
+
|
|
133
|
+
var Component = getComponent();
|
|
134
|
+
|
|
135
|
+
(0, _testUtils2.expectShallowComponent)(_react2.default.createElement(Component, defaultProps)).toMatchSnapshot();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('shows the Captcha pane for SSO (ADFS) connections', function () {
|
|
139
|
+
require('core/index').captcha.mockReturnValue({
|
|
140
|
+
get: function get() {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
require('engine/classic').isSSOEnabled.mockReturnValue(true);
|
|
146
|
+
require('connection/enterprise').isHRDDomain.mockReturnValue(true);
|
|
147
|
+
|
|
148
|
+
var Component = getComponent();
|
|
149
|
+
|
|
150
|
+
(0, _testUtils2.expectShallowComponent)(_react2.default.createElement(Component, defaultProps)).toMatchSnapshot();
|
|
151
|
+
});
|
|
152
|
+
|
|
88
153
|
describe('onlyEmail is false', function () {
|
|
89
154
|
it('shows PasswordPane', function () {
|
|
90
155
|
var Component = getComponent();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.expectMockToMatch = exports.setURL = exports.extractPropsFromWrapper = exports.mockComponent = exports.expectComponent = undefined;
|
|
4
|
+
exports.expectMockToMatch = exports.setURL = exports.extractPropsFromWrapper = exports.mockComponent = exports.renderShallowComponent = exports.expectShallowComponent = exports.expectComponent = undefined;
|
|
5
5
|
|
|
6
6
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
7
7
|
|
|
@@ -13,6 +13,10 @@ var _reactTestRenderer = require('react-test-renderer');
|
|
|
13
13
|
|
|
14
14
|
var _reactTestRenderer2 = _interopRequireDefault(_reactTestRenderer);
|
|
15
15
|
|
|
16
|
+
var _shallow = require('react-test-renderer/shallow');
|
|
17
|
+
|
|
18
|
+
var _shallow2 = _interopRequireDefault(_shallow);
|
|
19
|
+
|
|
16
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
21
|
|
|
18
22
|
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } // eslint-disable-line
|
|
@@ -23,6 +27,18 @@ var expectComponent = exports.expectComponent = function expectComponent(childre
|
|
|
23
27
|
return expect(component);
|
|
24
28
|
};
|
|
25
29
|
|
|
30
|
+
var expectShallowComponent = exports.expectShallowComponent = function expectShallowComponent(children) {
|
|
31
|
+
var component = renderShallowComponent(children);
|
|
32
|
+
return expect(component);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var renderShallowComponent = exports.renderShallowComponent = function renderShallowComponent(children) {
|
|
36
|
+
var renderer = new _shallow2.default();
|
|
37
|
+
|
|
38
|
+
renderer.render(children);
|
|
39
|
+
return renderer.getRenderOutput();
|
|
40
|
+
};
|
|
41
|
+
|
|
26
42
|
var addDataToProps = function addDataToProps(props) {
|
|
27
43
|
var returnedProps = {};
|
|
28
44
|
Object.keys(props).forEach(function (k) {
|
|
@@ -10,8 +10,6 @@ var _immutable = require('immutable');
|
|
|
10
10
|
|
|
11
11
|
var _immutable2 = _interopRequireDefault(_immutable);
|
|
12
12
|
|
|
13
|
-
var _reactTestRenderer = require('react-test-renderer');
|
|
14
|
-
|
|
15
13
|
var _testUtils = require('testUtils');
|
|
16
14
|
|
|
17
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -44,6 +42,12 @@ jest.mock('core/index', function () {
|
|
|
44
42
|
return {
|
|
45
43
|
handleEvent: jest.fn(function (_, event, fn) {
|
|
46
44
|
mockEventRegister[event] = fn;
|
|
45
|
+
}),
|
|
46
|
+
ui: {
|
|
47
|
+
forceAutoHeight: jest.fn().mockReturnValue(false)
|
|
48
|
+
},
|
|
49
|
+
id: jest.fn(function () {
|
|
50
|
+
return 'lock';
|
|
47
51
|
})
|
|
48
52
|
};
|
|
49
53
|
});
|
|
@@ -113,4 +117,16 @@ describe('Chrome', function () {
|
|
|
113
117
|
|
|
114
118
|
(0, _testUtils.expectComponent)(_react2.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
115
119
|
});
|
|
120
|
+
|
|
121
|
+
it('adds the auto-height class when forceAutoHeight UI prop is true', function () {
|
|
122
|
+
require('core/index').ui.forceAutoHeight.mockReturnValue(true);
|
|
123
|
+
|
|
124
|
+
var props = _extends({}, defaultProps, {
|
|
125
|
+
info: 'This is an information message',
|
|
126
|
+
success: 'This is a success message',
|
|
127
|
+
error: 'There is an error'
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
(0, _testUtils.expectComponent)(_react2.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
131
|
+
});
|
|
116
132
|
});
|
package/lib/browser.js
CHANGED
|
@@ -19,14 +19,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
19
|
* the package.json file points to index.js.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
if (typeof window
|
|
23
|
-
window.define
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
window.
|
|
31
|
-
|
|
22
|
+
if (typeof window !== 'undefined') {
|
|
23
|
+
if (typeof window.define == 'function' && window.define.amd) {
|
|
24
|
+
window.define('auth0Lock', function () {
|
|
25
|
+
return _index2.default;
|
|
26
|
+
});
|
|
27
|
+
window.define('auth0LockPasswordless', function () {
|
|
28
|
+
return _passwordless2.default;
|
|
29
|
+
});
|
|
30
|
+
} else if (window.window) {
|
|
31
|
+
window.Auth0Lock = _index2.default;
|
|
32
|
+
window.Auth0LockPasswordless = _passwordless2.default;
|
|
33
|
+
}
|
|
32
34
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.showMissingCaptcha = showMissingCaptcha;
|
|
5
|
+
exports.setCaptchaParams = setCaptchaParams;
|
|
6
|
+
exports.swapCaptcha = swapCaptcha;
|
|
7
|
+
|
|
8
|
+
var _index = require('../core/index');
|
|
9
|
+
|
|
10
|
+
var l = _interopRequireWildcard(_index);
|
|
11
|
+
|
|
12
|
+
var _index2 = require('../field/index');
|
|
13
|
+
|
|
14
|
+
var c = _interopRequireWildcard(_index2);
|
|
15
|
+
|
|
16
|
+
var _i18n = require('../i18n');
|
|
17
|
+
|
|
18
|
+
var i18n = _interopRequireWildcard(_i18n);
|
|
19
|
+
|
|
20
|
+
var _index3 = require('../store/index');
|
|
21
|
+
|
|
22
|
+
var _web_api = require('../core/web_api');
|
|
23
|
+
|
|
24
|
+
var _web_api2 = _interopRequireDefault(_web_api);
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Display the error message of missing captcha in the header of lock.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} m model
|
|
34
|
+
* @param {Number} id
|
|
35
|
+
*/
|
|
36
|
+
function showMissingCaptcha(m, id) {
|
|
37
|
+
var captchaConfig = l.captcha(m);
|
|
38
|
+
|
|
39
|
+
var captchaError = captchaConfig.get('provider') === 'recaptcha_v2' ? 'invalid_recaptcha' : 'invalid_captcha';
|
|
40
|
+
|
|
41
|
+
var errorMessage = i18n.html(m, ['error', 'login', captchaError]);
|
|
42
|
+
|
|
43
|
+
(0, _index3.swap)(_index3.updateEntity, 'lock', id, function (m) {
|
|
44
|
+
m = l.setSubmitting(m, false, errorMessage);
|
|
45
|
+
return c.showInvalidField(m, 'captcha');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return m;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Set the captcha value in the fields object before sending the request.
|
|
53
|
+
*
|
|
54
|
+
* @param {Object} m model
|
|
55
|
+
* @param {Object} params
|
|
56
|
+
* @param {Object} fields
|
|
57
|
+
*
|
|
58
|
+
* @returns {Boolean} returns true if is required and missing the response from the user
|
|
59
|
+
*/
|
|
60
|
+
function setCaptchaParams(m, params, fields) {
|
|
61
|
+
var captchaConfig = l.captcha(m);
|
|
62
|
+
var isCaptchaRequired = captchaConfig && l.captcha(m).get('required');
|
|
63
|
+
|
|
64
|
+
if (!isCaptchaRequired) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
var captcha = c.getFieldValue(m, 'captcha');
|
|
68
|
+
//captcha required and missing
|
|
69
|
+
if (!captcha) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
params['captcha'] = captcha;
|
|
74
|
+
fields.push('captcha');
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get a new challenge and display the new captcha image.
|
|
80
|
+
*
|
|
81
|
+
* @param {number} id The id of the Lock instance.
|
|
82
|
+
* @param {boolean} wasInvalid A boolean indicating if the previous captcha was invalid.
|
|
83
|
+
* @param {Function} [next] A callback.
|
|
84
|
+
*/
|
|
85
|
+
function swapCaptcha(id, wasInvalid, next) {
|
|
86
|
+
return _web_api2.default.getChallenge(id, function (err, newCaptcha) {
|
|
87
|
+
if (!err && newCaptcha) {
|
|
88
|
+
(0, _index3.swap)(_index3.updateEntity, 'lock', id, l.setCaptcha, newCaptcha, wasInvalid);
|
|
89
|
+
}
|
|
90
|
+
if (next) {
|
|
91
|
+
next();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|