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.
Files changed (241) hide show
  1. package/.browserslistrc +1 -0
  2. package/.circleci/config.yml +4 -2
  3. package/.eslintrc.json +5 -5
  4. package/.github/workflows/codeql.yml +41 -0
  5. package/.shiprc +4 -5
  6. package/CHANGELOG.md +26 -0
  7. package/EXAMPLES.md +626 -0
  8. package/README.md +77 -649
  9. package/karma.conf.js +1 -1
  10. package/lib/CSSCore.js +1 -4
  11. package/lib/__tests__/auth_button.js +12 -22
  12. package/lib/__tests__/connection/database/actions.js +48 -49
  13. package/lib/__tests__/connection/database/index.js +22 -28
  14. package/lib/__tests__/connection/database/login_pane.js +20 -41
  15. package/lib/__tests__/connection/database/password_reset_confirmation.js +19 -26
  16. package/lib/__tests__/connection/database/reset_password.js +17 -39
  17. package/lib/__tests__/connection/database/signed_up_confirmation.js +19 -26
  18. package/lib/__tests__/connection/enterprise/actions.js +22 -47
  19. package/lib/__tests__/connection/enterprise/hrd_pane.js +16 -33
  20. package/lib/__tests__/connection/enterprise/hrd_screen.js +26 -40
  21. package/lib/__tests__/connection/enterprise/quick_auth_screen.js +27 -68
  22. package/lib/__tests__/connection/passwordless/ask_vcode.js +29 -51
  23. package/lib/__tests__/connection/passwordless/email_sent_confirmation.js +19 -26
  24. package/lib/__tests__/connection/passwordless/passwordless.js +35 -97
  25. package/lib/__tests__/core/actions.js +23 -46
  26. package/lib/__tests__/core/client/index.js +10 -13
  27. package/lib/__tests__/core/index.js +46 -94
  28. package/lib/__tests__/core/remote_data.js +14 -20
  29. package/lib/__tests__/core/signed_in_confirmation.js +19 -26
  30. package/lib/__tests__/core/sso/last_login_screen.js +27 -50
  31. package/lib/__tests__/core/tenant.js +10 -12
  32. package/lib/__tests__/core/web_api/helper.js +6 -14
  33. package/lib/__tests__/core/web_api/p2_api.js +38 -33
  34. package/lib/__tests__/core/web_api.js +37 -33
  35. package/lib/__tests__/engine/classic/login.js +20 -41
  36. package/lib/__tests__/engine/classic/mfa_login_screen.js +6 -19
  37. package/lib/__tests__/engine/classic/sign_up_pane.js +33 -55
  38. package/lib/__tests__/engine/classic/sign_up_screen.js +18 -45
  39. package/lib/__tests__/engine/classic.js +13 -6
  40. package/lib/__tests__/engine/passwordless.js +2 -5
  41. package/lib/__tests__/field/captcha/recaptcha_enterprise.js +27 -27
  42. package/lib/__tests__/field/captcha/recaptchav2.js +27 -27
  43. package/lib/__tests__/field/captcha.js +39 -51
  44. package/lib/__tests__/field/custom_input.js +23 -47
  45. package/lib/__tests__/field/email.js +2 -3
  46. package/lib/__tests__/field/email_pane.js +25 -48
  47. package/lib/__tests__/field/field.js +9 -13
  48. package/lib/__tests__/field/login_pane.js +30 -34
  49. package/lib/__tests__/field/mfa_code_pane.js +13 -28
  50. package/lib/__tests__/field/option_selection_pane.js +7 -25
  51. package/lib/__tests__/field/password.js +6 -12
  52. package/lib/__tests__/field/password_pane.js +29 -46
  53. package/lib/__tests__/field/phone_number_pane.js +18 -41
  54. package/lib/__tests__/field/social_buttons_pane.js +30 -47
  55. package/lib/__tests__/field/username.js +27 -48
  56. package/lib/__tests__/field/username_pane.js +30 -47
  57. package/lib/__tests__/field/vcode.js +5 -13
  58. package/lib/__tests__/field/vcode_pane.js +20 -44
  59. package/lib/__tests__/i18n.js +28 -53
  60. package/lib/__tests__/quick-auth/actions.js +4 -27
  61. package/lib/__tests__/setup-tests.js +7 -9
  62. package/lib/__tests__/testUtils.js +41 -58
  63. package/lib/__tests__/ui/box/chrome.js +24 -49
  64. package/lib/__tests__/ui/box/confirmation_pane.js +19 -36
  65. package/lib/__tests__/ui/box/container.js +21 -46
  66. package/lib/__tests__/ui/box/global_message.js +60 -37
  67. package/lib/__tests__/ui/input/email_input.js +6 -17
  68. package/lib/__tests__/ui/input/input_wrap.js +6 -19
  69. package/lib/__tests__/ui/input/password/password_strength.js +13 -15
  70. package/lib/__tests__/ui/input/password_input.js +22 -27
  71. package/lib/__tests__/utils/format.js +10 -17
  72. package/lib/__tests__/utils/url_utils.js +2 -5
  73. package/lib/avatar/gravatar_provider.js +13 -28
  74. package/lib/avatar.js +22 -41
  75. package/lib/browser.js +372 -23
  76. package/lib/connection/captcha.js +14 -32
  77. package/lib/connection/database/actions.js +39 -108
  78. package/lib/connection/database/index.js +90 -191
  79. package/lib/connection/database/login_pane.js +107 -147
  80. package/lib/connection/database/login_sign_up_tabs.js +106 -125
  81. package/lib/connection/database/mfa_pane.js +50 -69
  82. package/lib/connection/database/password_reset_confirmation.js +51 -73
  83. package/lib/connection/database/reset_password.js +116 -132
  84. package/lib/connection/database/reset_password_pane.js +45 -56
  85. package/lib/connection/database/sign_up_terms.js +17 -23
  86. package/lib/connection/database/signed_up_confirmation.js +52 -75
  87. package/lib/connection/enterprise/actions.js +23 -52
  88. package/lib/connection/enterprise/hrd_pane.js +60 -76
  89. package/lib/connection/enterprise/hrd_screen.js +60 -75
  90. package/lib/connection/enterprise/kerberos_screen.js +46 -60
  91. package/lib/connection/enterprise/quick_auth_screen.js +46 -64
  92. package/lib/connection/enterprise/single_sign_on_notice.js +14 -26
  93. package/lib/connection/enterprise.js +51 -84
  94. package/lib/connection/passwordless/actions.js +29 -62
  95. package/lib/connection/passwordless/ask_vcode.js +53 -60
  96. package/lib/connection/passwordless/email_sent_confirmation.js +129 -179
  97. package/lib/connection/passwordless/index.js +36 -68
  98. package/lib/connection/social/index.js +12 -15
  99. package/lib/core/actions.js +33 -85
  100. package/lib/core/client/index.js +38 -58
  101. package/lib/core/client/settings.js +12 -20
  102. package/lib/core/error_screen.js +38 -52
  103. package/lib/core/index.js +152 -301
  104. package/lib/core/loading_screen.js +61 -71
  105. package/lib/core/pane_separator.js +10 -10
  106. package/lib/core/remote_data.js +28 -48
  107. package/lib/core/screen.js +85 -79
  108. package/lib/core/signed_in_confirmation.js +51 -73
  109. package/lib/core/sso/data.js +9 -17
  110. package/lib/core/sso/index.js +5 -6
  111. package/lib/core/sso/last_login_screen.js +46 -63
  112. package/lib/core/tenant/index.js +37 -59
  113. package/lib/core/tenant/settings.js +11 -15
  114. package/lib/core/web_api/helper.js +24 -30
  115. package/lib/core/web_api/p2_api.js +156 -165
  116. package/lib/core/web_api.js +101 -90
  117. package/lib/core.js +126 -160
  118. package/lib/engine/classic/login.js +92 -144
  119. package/lib/engine/classic/mfa_login_screen.js +61 -67
  120. package/lib/engine/classic/sign_up_pane.js +89 -123
  121. package/lib/engine/classic/sign_up_screen.js +112 -158
  122. package/lib/engine/classic.js +122 -183
  123. package/lib/engine/passwordless/social_or_email_login_screen.js +71 -106
  124. package/lib/engine/passwordless/social_or_phone_number_login_screen.js +70 -100
  125. package/lib/engine/passwordless.js +75 -104
  126. package/lib/field/actions.js +11 -17
  127. package/lib/field/captcha/captcha_pane.js +82 -102
  128. package/lib/field/captcha/recaptcha.js +140 -145
  129. package/lib/field/captcha.js +7 -10
  130. package/lib/field/custom_input.js +37 -50
  131. package/lib/field/email/email_pane.js +90 -109
  132. package/lib/field/email.js +17 -35
  133. package/lib/field/index.js +51 -88
  134. package/lib/field/mfa-code/mfa_code_pane.js +57 -71
  135. package/lib/field/mfa_code.js +15 -21
  136. package/lib/field/option_selection_pane.js +16 -22
  137. package/lib/field/password/password_pane.js +79 -91
  138. package/lib/field/password.js +8 -14
  139. package/lib/field/phone-number/locations.js +7 -3
  140. package/lib/field/phone-number/phone_number_pane.js +87 -124
  141. package/lib/field/phone_number.js +16 -30
  142. package/lib/field/social/event.js +9 -12
  143. package/lib/field/social/social_buttons_pane.js +93 -121
  144. package/lib/field/username/username_pane.js +105 -123
  145. package/lib/field/username.js +16 -26
  146. package/lib/field/vcode/vcode_pane.js +67 -93
  147. package/lib/field/vcode.js +5 -5
  148. package/lib/i18n/af.js +7 -4
  149. package/lib/i18n/ar.js +7 -4
  150. package/lib/i18n/az.js +7 -4
  151. package/lib/i18n/bg.js +7 -4
  152. package/lib/i18n/ca.js +7 -4
  153. package/lib/i18n/cs.js +7 -4
  154. package/lib/i18n/da.js +7 -4
  155. package/lib/i18n/de.js +7 -3
  156. package/lib/i18n/el.js +7 -4
  157. package/lib/i18n/en.js +9 -4
  158. package/lib/i18n/es.js +7 -3
  159. package/lib/i18n/et.js +7 -4
  160. package/lib/i18n/fa.js +7 -4
  161. package/lib/i18n/fi.js +7 -4
  162. package/lib/i18n/fr.js +7 -4
  163. package/lib/i18n/he.js +7 -4
  164. package/lib/i18n/hr.js +7 -4
  165. package/lib/i18n/hu.js +7 -4
  166. package/lib/i18n/id.js +7 -4
  167. package/lib/i18n/it.js +7 -3
  168. package/lib/i18n/ja.js +7 -4
  169. package/lib/i18n/ko.js +7 -4
  170. package/lib/i18n/lt.js +7 -4
  171. package/lib/i18n/lv.js +7 -4
  172. package/lib/i18n/ms.js +7 -4
  173. package/lib/i18n/nb.js +7 -4
  174. package/lib/i18n/nl.js +7 -4
  175. package/lib/i18n/nn.js +7 -4
  176. package/lib/i18n/no.js +7 -4
  177. package/lib/i18n/pl.js +7 -4
  178. package/lib/i18n/pt-br.js +7 -3
  179. package/lib/i18n/pt.js +7 -4
  180. package/lib/i18n/ro.js +7 -4
  181. package/lib/i18n/ru.js +7 -4
  182. package/lib/i18n/sk.js +7 -4
  183. package/lib/i18n/sl.js +7 -4
  184. package/lib/i18n/sr.js +7 -4
  185. package/lib/i18n/sv.js +7 -4
  186. package/lib/i18n/tr.js +7 -4
  187. package/lib/i18n/ua.js +7 -4
  188. package/lib/i18n/uk.js +7 -4
  189. package/lib/i18n/vi.js +7 -4
  190. package/lib/i18n/zh-tw.js +7 -4
  191. package/lib/i18n/zh.js +7 -4
  192. package/lib/i18n.js +38 -75
  193. package/lib/index.js +14 -17
  194. package/lib/lock.js +29 -32
  195. package/lib/passwordless.js +29 -31
  196. package/lib/quick-auth/actions.js +19 -26
  197. package/lib/quick_auth.js +8 -10
  198. package/lib/sanitizer.js +5 -5
  199. package/lib/store/index.js +22 -42
  200. package/lib/sync.js +21 -42
  201. package/lib/ui/box/button.js +85 -105
  202. package/lib/ui/box/chrome.js +463 -548
  203. package/lib/ui/box/confirmation_pane.js +34 -48
  204. package/lib/ui/box/container.js +305 -339
  205. package/lib/ui/box/global_message.js +51 -60
  206. package/lib/ui/box/header.js +155 -177
  207. package/lib/ui/box/multisize_slide.js +233 -229
  208. package/lib/ui/box/success_pane.js +34 -37
  209. package/lib/ui/box.js +88 -93
  210. package/lib/ui/button/auth_button.js +44 -51
  211. package/lib/ui/input/captcha_input.js +162 -181
  212. package/lib/ui/input/checkbox_input.js +57 -59
  213. package/lib/ui/input/email_input.js +117 -124
  214. package/lib/ui/input/input_wrap.js +65 -80
  215. package/lib/ui/input/location_input.js +130 -150
  216. package/lib/ui/input/mfa_code_input.js +98 -98
  217. package/lib/ui/input/password/password_strength.js +103 -127
  218. package/lib/ui/input/password_input.js +141 -147
  219. package/lib/ui/input/phone_number_input.js +101 -109
  220. package/lib/ui/input/select_input.js +120 -132
  221. package/lib/ui/input/text_input.js +89 -84
  222. package/lib/ui/input/username_input.js +109 -115
  223. package/lib/ui/input/vcode_input.js +110 -118
  224. package/lib/ui/list.js +224 -247
  225. package/lib/ui/pane/quick_auth_pane.js +55 -80
  226. package/lib/utils/atom.js +55 -48
  227. package/lib/utils/cache.js +54 -43
  228. package/lib/utils/cdn_utils.js +17 -31
  229. package/lib/utils/createRef.js +3 -1
  230. package/lib/utils/data_utils.js +10 -16
  231. package/lib/utils/fn_utils.js +5 -4
  232. package/lib/utils/format.js +6 -8
  233. package/lib/utils/id_utils.js +4 -3
  234. package/lib/utils/jsonp_utils.js +20 -17
  235. package/lib/utils/media_utils.js +4 -2
  236. package/lib/utils/preload_utils.js +4 -3
  237. package/lib/utils/string_utils.js +4 -4
  238. package/lib/utils/url_utils.js +4 -3
  239. package/opslevel.yml +6 -0
  240. package/package.json +53 -38
  241. package/webpack.config.js +36 -3
@@ -1,36 +1,28 @@
1
- 'use strict';
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)(_react2.default.createElement(Component, defaultProps)).toMatchSnapshot();
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 _immutable2.default.fromJS({
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)(_react2.default.createElement(Component, defaultProps)).toMatchSnapshot();
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('when strategy is ' + strategy, function () {
116
+ it("when strategy is ".concat(strategy), function () {
133
117
  require('core/sso/index').lastUsedConnection = function () {
134
- return _immutable2.default.fromJS({
118
+ return _immutable.default.fromJS({
135
119
  strategy: strategy
136
120
  });
137
121
  };
138
122
  var Component = getComponent();
139
- (0, _testUtils.expectComponent)(_react2.default.createElement(Component, defaultProps)).toMatchSnapshot();
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 = (_require$STRATEGIES = {}, _require$STRATEGIES[testStrategyName] = 'Test Strategy', _require$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 _immutable2.default.fromJS({
131
+ return _immutable.default.fromJS({
149
132
  name: testStrategyName
150
133
  });
151
134
  };
152
135
  var Component = getComponent();
153
- (0, _testUtils.expectComponent)(_react2.default.createElement(Component, defaultProps)).toMatchSnapshot();
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)(_react2.default.createElement(Component, defaultProps)).toMatchSnapshot();
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)(_react2.default.createElement(Component, defaultProps)).toMatchSnapshot();
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)(_react2.default.createElement(Component, defaultProps));
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)(_react2.default.createElement(Component, defaultProps));
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)(_react2.default.createElement(Component, defaultProps));
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
- 'use strict';
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 = void 0;
18
- var mockDataFns = void 0;
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', //minLength: 6
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: (_clientsConnections = {}, _clientsConnections[CLIENT_ID] = ['test-connection-database'], _clientsConnections)
190
+ clientsConnections: _defineProperty({}, CLIENT_ID, ['test-connection-database'])
193
191
  };
194
192
  runTest(initTenant, mockDataFns, client);
195
193
  });
@@ -1,7 +1,6 @@
1
- 'use strict';
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)({ backgroundColor: 'blue' })).toBe(null);
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 = void 0;
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
- 'use strict';
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 = { name: 'test-sdk', version: '1.0.0', env: { envOverride: true } };
52
- (0, _testUtils.setURL)('https://me.auth0.com/authorize?auth0Client=' + btoa(JSON.stringify(telemetryIn)));
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: { ignored: true }
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)('https://auth.myapp.com/authorize');
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: { name: 'test-sdk', version: '1.0.0', env: { envOverride: true } }
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)('https://auth.myapp.com/authorize');
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)('https://auth.myapp.com/authorize');
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: { 'auth0.js': 'this-will-be-overriden' }
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)('https://auth.myapp.com/authorize');
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)('https://auth.myapp.com/authorize');
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 = void 0;
324
- var callback = void 0;
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 = void 0;
364
- var callback = void 0;
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 = void 0;
397
- var callback = void 0;
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 = void 0;
440
- var callback = void 0;
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 = void 0;
477
- var callback = void 0;
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
  });