auth0-lock 11.30.6 → 11.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.shiprc CHANGED
@@ -3,5 +3,5 @@
3
3
  "bower.json": [],
4
4
  "README.md": []
5
5
  },
6
- "postbump": "yarn dist build && git add -f build/"
6
+ "postbump": "yarn dist build"
7
7
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # Change Log
2
2
 
3
+ ## [v11.32.1](https://github.com/auth0/lock/tree/v11.32.1) (2022-01-27)
4
+ [Full Changelog](https://github.com/auth0/lock/compare/v11.32.0...v11.32.1)
5
+
6
+ **Changed**
7
+ - Update auth0-js and support legacySameSiteCookie option [\#2089](https://github.com/auth0/lock/pull/2089) ([stevehobbsdev](https://github.com/stevehobbsdev))
8
+
9
+ **Security**
10
+ - Bump log4js from 6.3.0 to 6.4.0 [\#2087](https://github.com/auth0/lock/pull/2087) ([dependabot[bot]](https://github.com/apps/dependabot))
11
+ - Security upgrade node-fetch to 2.6.7 [\#2085](https://github.com/auth0/lock/pull/2085) ([evansims](https://github.com/evansims))
12
+ - [Snyk] Upgrade prop-types from 15.7.2 to 15.8.0 [\#2083](https://github.com/auth0/lock/pull/2083) ([snyk-bot](https://github.com/snyk-bot))
13
+ - Bump engine.io from 4.1.1 to 4.1.2 [\#2082](https://github.com/auth0/lock/pull/2082) ([dependabot[bot]](https://github.com/apps/dependabot))
14
+ - Bump follow-redirects from 1.14.4 to 1.14.7 [\#2081](https://github.com/auth0/lock/pull/2081) ([dependabot[bot]](https://github.com/apps/dependabot))
15
+
16
+ ## [v11.32.0](https://github.com/auth0/lock/tree/v11.32.0) (2022-01-07)
17
+ [Full Changelog](https://github.com/auth0/lock/compare/v11.31.1...v11.32.0)
18
+
19
+ **Fixed**
20
+ - [SDK-2970] Remove captcha for enterprise SSO connections [\#2071](https://github.com/auth0/lock/pull/2071) ([stevehobbsdev](https://github.com/stevehobbsdev))
21
+ - Add ID attributes to password field + submit button [\#2072](https://github.com/auth0/lock/pull/2072) ([stevehobbsdev](https://github.com/stevehobbsdev))
22
+
23
+ ## [v11.31.1](https://github.com/auth0/lock/tree/v11.31.1) (2021-11-02)
24
+
25
+ [Full Changelog](https://github.com/auth0/lock/compare/v11.31.0...v11.31.1)
26
+
27
+ **Fixed**
28
+
29
+ - Guard references to window on module load [\#2057](https://github.com/auth0/lock/pull/2057) ([stevehobbsdev](https://github.com/stevehobbsdev))
30
+ - Ensure Captcha is completed before authenticating with enterprise SSO connection [\#2060](https://github.com/auth0/lock/pull/2060) ([stevehobbsdev](https://github.com/stevehobbsdev))
31
+
32
+ ## [v11.31.0](https://github.com/auth0/lock/tree/v11.31.0) (2021-10-15)
33
+
34
+ [Full Changelog](https://github.com/auth0/lock/compare/v11.30.6...v11.31.0)
35
+
36
+ **Added**
37
+
38
+ - [SDK-2295] Add forceAutoHeight property to UI config [\#2050](https://github.com/auth0/lock/pull/2050) ([stevehobbsdev](https://github.com/stevehobbsdev))
39
+
40
+ **Fixed**
41
+
42
+ - [SDK-2823] Fix password reset when using custom connection resolver [\#2048](https://github.com/auth0/lock/pull/2048) ([stevehobbsdev](https://github.com/stevehobbsdev))
43
+
3
44
  ## [v11.30.6](https://github.com/auth0/lock/tree/v11.30.6) (2021-09-27)
4
45
 
5
46
  [Full Changelog](https://github.com/auth0/lock/compare/v11.30.5...v11.30.6)
package/README.md CHANGED
@@ -25,7 +25,7 @@ From CDN
25
25
 
26
26
  ```html
27
27
  <!-- Latest patch release (recommended for production) -->
28
- <script src="https://cdn.auth0.com/js/lock/11.30.6/lock.min.js"></script>
28
+ <script src="https://cdn.auth0.com/js/lock/11.32.1/lock.min.js"></script>
29
29
  ```
30
30
 
31
31
  From [npm](https://npmjs.org)
@@ -272,6 +272,7 @@ The appearance of the widget and the mechanics of authentication can be customiz
272
272
  - **allowShowPassword {Boolean}**: Determines whether or not add a checkbox to show the password when typing it. Defaults to `false`.
273
273
  - **allowPasswordAutocomplete {Boolean}**: Determines whether the password field will allow autocomplete; setting this to `true` is required for password manager support and to avoid many cases of adverse behavior. Defaults to `false`.
274
274
  - **preferConnectionDisplayName {Boolean}**: If true, Lock will try to use the connection display name as configured in the manage dashboard, if available.
275
+ - **forceAutoHeight {Boolean}**: If true, Lock will use the `height: auto!important` style on the wrapping div, which may be useful in some circumstances where `height: 100vh` is undesirable (see [\#1963](https://github.com/auth0/lock/issues/1963)). Defaults to `false`.
275
276
 
276
277
  #### Theming options
277
278
 
@@ -414,14 +415,15 @@ Specify your hooks using a new `hooks` configuration item when setting up the li
414
415
  ```js
415
416
  new Auth0Lock('client ID', 'domain', {
416
417
  hooks: {
417
- loggingIn: function(context, cb) {
418
+ loggingIn: function (context, cb) {
418
419
  console.log('Hello from the login hook!');
419
420
  cb();
420
421
  },
421
- signingUp: function(context, cb) {
422
+ signingUp: function (context, cb) {
422
423
  console.log('Hello from the sign-up hook!');
423
424
  cb();
424
425
  }
426
+ }
425
427
  });
426
428
  ```
427
429
 
@@ -432,13 +434,14 @@ The developer can throw an error to block the login or sign-up process. The deve
432
434
  ```js
433
435
  new Auth0Lock('client ID', 'domain', {
434
436
  hooks: {
435
- loggingIn: function(context, cb) {
437
+ loggingIn: function (context, cb) {
436
438
  // Throw an object with code: `hook_error` to display this on the Login screen
437
439
  throw { code: 'hook_error', description: 'There was an error in the login hook!' };
438
440
 
439
441
  // Throw something generic to show a fallback error message
440
- throw "Some error happened";
441
- },
442
+ throw 'Some error happened';
443
+ }
444
+ }
442
445
  });
443
446
  ```
444
447
 
@@ -450,6 +453,7 @@ new Auth0Lock('client ID', 'domain', {
450
453
  - **languageBaseUrl {String}**: Overrides the language source URL for Auth0's provided translations. By default it uses to Auth0's CDN URL `https://cdn.auth0.com`.
451
454
  - **hashCleanup {Boolean}**: When enabled, it will remove the hash part of the callback URL after the user authentication. Defaults to `true`.
452
455
  - **connectionResolver {Function}**: When in use, provides an extensibility point to make it possible to choose which connection to use based on the username information. Has `username`, `context`, and `callback` as parameters. The callback expects an object like: `{type: 'database', name: 'connection name'}`. **This only works for database connections.** Keep in mind that this resolver will run in the form's `onSubmit` event, so keep it simple and fast. **This is a beta feature. If you find a bug, please open a GitHub [issue](https://github.com/auth0/lock/issues/new).**
456
+ - **legacySameSiteCookie**: If `false`, no compatibility cookies will be created for those browsers that do not understand the `SameSite` attribute. Defaults to `true`
453
457
 
454
458
  ```js
455
459
  var options = {
package/karma.conf.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = function(config) {
1
+ module.exports = function (config) {
2
2
  process.env.CHROME_BIN = require('puppeteer').executablePath();
3
3
 
4
4
  config.set({
@@ -52,9 +52,9 @@ module.exports = function(config) {
52
52
 
53
53
  browserNoActivityTimeout: 60000,
54
54
 
55
- browserDisconnectTimeout: 20000,
55
+ browserDisconnectTimeout: 30000,
56
56
 
57
- browserDisconnectTolerance: 3,
57
+ browserDisconnectTolerance: 10,
58
58
 
59
59
  // level of logging
60
60
  logLevel: config.LOG_INFO,
@@ -118,12 +118,6 @@ module.exports = function(config) {
118
118
  }
119
119
  },
120
120
 
121
- browsers: [
122
- 'bs_chrome_windows',
123
- 'bs_firefox_windows',
124
- 'bs_safari',
125
- 'bs_ie11_windows',
126
- 'bs_edge_windows'
127
- ]
121
+ browsers: ['bs_chrome_windows']
128
122
  });
129
123
  };
@@ -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 _enzyme = require('enzyme');
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 { str: function str(_, keys) {
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 () {
@@ -4,8 +4,6 @@ var _react = require('react');
4
4
 
5
5
  var _react2 = _interopRequireDefault(_react);
6
6
 
7
- var _enzyme = require('enzyme');
8
-
9
7
  var _testUtils = require('testUtils');
10
8
 
11
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -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
  });
@@ -29,7 +29,10 @@ jest.mock('core/index', function () {
29
29
  allowPasswordAutocomplete: function allowPasswordAutocomplete() {
30
30
  return false;
31
31
  }
32
- }
32
+ },
33
+ id: jest.fn(function () {
34
+ return 'lock';
35
+ })
33
36
  };
34
37
  });
35
38
 
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.define == 'function' && window.define.amd) {
23
- window.define('auth0Lock', function () {
24
- return _index2.default;
25
- });
26
- window.define('auth0LockPasswordless', function () {
27
- return _passwordless2.default;
28
- });
29
- } else if (window.window) {
30
- window.Auth0Lock = _index2.default;
31
- window.Auth0LockPasswordless = _passwordless2.default;
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
  }