auth0-lock 11.35.0 → 12.0.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 (240) hide show
  1. package/.browserslistrc +1 -0
  2. package/.circleci/config.yml +3 -1
  3. package/.shiprc +4 -5
  4. package/CHANGELOG.md +25 -0
  5. package/DEVELOPMENT.md +1 -1
  6. package/README.md +20 -16
  7. package/karma.conf.js +1 -1
  8. package/lib/CSSCore.js +1 -4
  9. package/lib/__tests__/auth_button.js +12 -22
  10. package/lib/__tests__/connection/database/actions.js +48 -49
  11. package/lib/__tests__/connection/database/index.js +22 -28
  12. package/lib/__tests__/connection/database/login_pane.js +24 -47
  13. package/lib/__tests__/connection/database/password_reset_confirmation.js +23 -32
  14. package/lib/__tests__/connection/database/reset_password.js +17 -39
  15. package/lib/__tests__/connection/database/signed_up_confirmation.js +23 -32
  16. package/lib/__tests__/connection/enterprise/actions.js +22 -47
  17. package/lib/__tests__/connection/enterprise/hrd_pane.js +16 -33
  18. package/lib/__tests__/connection/enterprise/hrd_screen.js +26 -40
  19. package/lib/__tests__/connection/enterprise/quick_auth_screen.js +32 -75
  20. package/lib/__tests__/connection/passwordless/ask_vcode.js +29 -51
  21. package/lib/__tests__/connection/passwordless/email_sent_confirmation.js +23 -32
  22. package/lib/__tests__/connection/passwordless/passwordless.js +35 -97
  23. package/lib/__tests__/core/actions.js +23 -46
  24. package/lib/__tests__/core/client/index.js +10 -13
  25. package/lib/__tests__/core/index.js +46 -94
  26. package/lib/__tests__/core/remote_data.js +14 -20
  27. package/lib/__tests__/core/signed_in_confirmation.js +23 -32
  28. package/lib/__tests__/core/sso/last_login_screen.js +27 -50
  29. package/lib/__tests__/core/tenant.js +10 -12
  30. package/lib/__tests__/core/web_api/helper.js +6 -14
  31. package/lib/__tests__/core/web_api/p2_api.js +38 -33
  32. package/lib/__tests__/core/web_api.js +37 -33
  33. package/lib/__tests__/engine/classic/login.js +20 -41
  34. package/lib/__tests__/engine/classic/mfa_login_screen.js +6 -19
  35. package/lib/__tests__/engine/classic/sign_up_pane.js +33 -55
  36. package/lib/__tests__/engine/classic/sign_up_screen.js +18 -45
  37. package/lib/__tests__/engine/classic.js +13 -6
  38. package/lib/__tests__/engine/passwordless/social_or_email_login_screen.js +7 -28
  39. package/lib/__tests__/engine/passwordless/social_or_phone_number_login_screen.js +7 -28
  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 +23 -42
  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 +15 -34
  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 -65
  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 +154 -305
  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 +30 -51
  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 +22 -28
  115. package/lib/core/web_api/p2_api.js +162 -171
  116. package/lib/core/web_api.js +106 -94
  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 +80 -116
  124. package/lib/engine/passwordless/social_or_phone_number_login_screen.js +79 -110
  125. package/lib/engine/passwordless.js +75 -104
  126. package/lib/field/actions.js +11 -17
  127. package/lib/field/captcha/captcha_pane.js +83 -103
  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 +50 -87
  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/package.json +48 -34
  240. package/webpack.config.js +36 -3
@@ -1,25 +1,16 @@
1
- 'use strict';
2
-
3
- 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; };
4
-
5
- var _react = require('react');
6
-
7
- var _react2 = _interopRequireDefault(_react);
8
-
9
- var _enzyme = require('enzyme');
10
-
11
- var _testUtils = require('testUtils');
1
+ "use strict";
12
2
 
3
+ var _react = _interopRequireDefault(require("react"));
4
+ var _enzyme = require("enzyme");
5
+ var _testUtils = require("testUtils");
13
6
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
7
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
15
8
  jest.mock('ui/input/vcode_input', function () {
16
9
  return (0, _testUtils.mockComponent)('vcode_input');
17
10
  });
18
-
19
11
  var getComponent = function getComponent() {
20
12
  return require('field/vcode/vcode_pane').default;
21
13
  };
22
-
23
14
  describe('VcodePane', function () {
24
15
  var defaultProps = {
25
16
  lock: {},
@@ -29,7 +20,6 @@ describe('VcodePane', function () {
29
20
  };
30
21
  beforeEach(function () {
31
22
  jest.resetModules();
32
-
33
23
  jest.mock('field/index', function () {
34
24
  return {
35
25
  vcode: function vcode() {
@@ -40,13 +30,11 @@ describe('VcodePane', function () {
40
30
  }
41
31
  };
42
32
  });
43
-
44
33
  jest.mock('field/phone_number', function () {
45
34
  return {
46
35
  setVcode: 'setVcode'
47
36
  };
48
37
  });
49
-
50
38
  jest.mock('core/index', function () {
51
39
  return {
52
40
  id: function id() {
@@ -60,7 +48,6 @@ describe('VcodePane', function () {
60
48
  }
61
49
  };
62
50
  });
63
-
64
51
  jest.mock('utils/media_utils', function () {
65
52
  return {
66
53
  isSmallScreen: function isSmallScreen() {
@@ -68,7 +55,6 @@ describe('VcodePane', function () {
68
55
  }
69
56
  };
70
57
  });
71
-
72
58
  jest.mock('store/index', function () {
73
59
  return {
74
60
  swap: jest.fn(),
@@ -76,28 +62,22 @@ describe('VcodePane', function () {
76
62
  };
77
63
  });
78
64
  });
79
-
80
65
  it('renders correctly', function () {
81
66
  var VcodePane = getComponent();
82
-
83
- (0, _testUtils.expectComponent)(_react2.default.createElement(VcodePane, defaultProps)).toMatchSnapshot();
67
+ (0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(VcodePane, defaultProps)).toMatchSnapshot();
84
68
  });
85
69
  it('shows header when instructions are available', function () {
86
70
  var VcodePane = getComponent();
87
-
88
- (0, _testUtils.expectComponent)(_react2.default.createElement(VcodePane, _extends({}, defaultProps, { instructions: _react2.default.createElement(
89
- 'span',
90
- null,
91
- 'instructions'
92
- ) }))).toMatchSnapshot();
71
+ (0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(VcodePane, _extends({}, defaultProps, {
72
+ instructions: /*#__PURE__*/_react.default.createElement("span", null, "instructions")
73
+ }))).toMatchSnapshot();
93
74
  });
94
75
  it('disable input when submitting', function () {
95
76
  require('core/index').submitting = function () {
96
77
  return true;
97
78
  };
98
79
  var VcodePane = getComponent();
99
-
100
- (0, _testUtils.expectComponent)(_react2.default.createElement(VcodePane, defaultProps)).toMatchSnapshot();
80
+ (0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(VcodePane, defaultProps)).toMatchSnapshot();
101
81
  });
102
82
  it('sets isValid as true when `isFieldVisiblyInvalid` is false and globalError() is false', function () {
103
83
  require('field/index').isFieldVisiblyInvalid = function () {
@@ -107,38 +87,34 @@ describe('VcodePane', function () {
107
87
  return false;
108
88
  };
109
89
  var VcodePane = getComponent();
110
-
111
- (0, _testUtils.expectComponent)(_react2.default.createElement(VcodePane, defaultProps)).toMatchSnapshot();
90
+ (0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(VcodePane, defaultProps)).toMatchSnapshot();
112
91
  });
113
92
  it('sets autoFocus as true when `isSmallScreen` is false', function () {
114
93
  require('utils/media_utils').isSmallScreen = function () {
115
94
  return false;
116
95
  };
117
96
  var VcodePane = getComponent();
118
-
119
- (0, _testUtils.expectComponent)(_react2.default.createElement(VcodePane, defaultProps)).toMatchSnapshot();
97
+ (0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(VcodePane, defaultProps)).toMatchSnapshot();
120
98
  });
121
99
  it('calls `onRestart` when alternative link is clicked', function () {
122
100
  var VcodePane = getComponent();
123
-
124
- var wrapper = (0, _enzyme.mount)(_react2.default.createElement(VcodePane, defaultProps));
101
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(VcodePane, defaultProps));
125
102
  wrapper.find('.auth0-lock-alternative-link').simulate('click');
126
-
127
103
  var mock = defaultProps.onRestart.mock;
128
-
129
104
  expect(mock.calls.length).toBe(1);
130
105
  expect(mock.calls[0]).toMatchSnapshot();
131
106
  });
132
107
  it('calls `swap` when VcodeInput changes', function () {
133
108
  var VcodePane = getComponent();
134
-
135
- var wrapper = (0, _enzyme.mount)(_react2.default.createElement(VcodePane, defaultProps));
109
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(VcodePane, defaultProps));
136
110
  var props = (0, _testUtils.extractPropsFromWrapper)(wrapper, 1);
137
-
138
- props.onChange({ preventDefault: jest.fn(), target: { value: 'newCode' } });
139
-
111
+ props.onChange({
112
+ preventDefault: jest.fn(),
113
+ target: {
114
+ value: 'newCode'
115
+ }
116
+ });
140
117
  var mock = require('store/index').swap.mock;
141
-
142
118
  expect(mock.calls.length).toBe(1);
143
119
  expect(mock.calls[0]).toMatchSnapshot();
144
120
  });
@@ -1,102 +1,77 @@
1
- 'use strict';
2
-
3
- var _immutable = require('immutable');
4
-
5
- var _immutable2 = _interopRequireDefault(_immutable);
6
-
7
- var _flat = require('flat');
8
-
9
- var _flat2 = _interopRequireDefault(_flat);
10
-
11
- var _en = require('../i18n/en');
12
-
13
- var _en2 = _interopRequireDefault(_en);
14
-
15
- var _es = require('../i18n/es');
16
-
17
- var _es2 = _interopRequireDefault(_es);
18
-
19
- var _sync = require('../sync');
20
-
21
- var sync = _interopRequireWildcard(_sync);
22
-
23
- var _index = require('../core/index');
24
-
25
- var l = _interopRequireWildcard(_index);
26
-
27
- var _sanitizer = require('../sanitizer');
28
-
29
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
30
-
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ var _immutable = _interopRequireDefault(require("immutable"));
5
+ var _flat = _interopRequireDefault(require("flat"));
6
+ var _en = _interopRequireDefault(require("../i18n/en"));
7
+ var _es = _interopRequireDefault(require("../i18n/es"));
8
+ var sync = _interopRequireWildcard(require("../sync"));
9
+ var l = _interopRequireWildcard(require("../core/index"));
10
+ var _sanitizer = require("../sanitizer");
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
-
33
14
  describe('i18n', function () {
34
- var syncSpy = void 0;
35
- var langSpy = void 0;
36
-
15
+ var syncSpy;
16
+ var langSpy;
37
17
  beforeEach(function () {
38
18
  syncSpy = jest.spyOn(sync, 'default');
39
-
40
19
  langSpy = jest.spyOn(l.ui, 'language').mockImplementation(function () {
41
20
  return 'en';
42
21
  });
43
22
  });
44
-
45
23
  afterEach(function () {
46
24
  syncSpy.mockRestore();
47
25
  langSpy.mockRestore();
48
26
  });
49
-
50
27
  describe('load i18n configuration', function () {
51
28
  it('should have a defaultDictionary', function () {
52
29
  var i18n = require('../i18n');
53
30
 
54
31
  // We need to initialize the state
55
- var m = _immutable2.default.fromJS({});
32
+ var m = _immutable.default.fromJS({});
56
33
 
57
34
  // Initialize i18n.
58
35
  var initialized = i18n.initI18n(m);
59
-
60
- var language = (0, _flat2.default)(initialized.getIn(['i18n', 'strings']).toJS());
61
- var en = (0, _flat2.default)(_en2.default);
62
-
36
+ var language = (0, _flat.default)(initialized.getIn(['i18n', 'strings']).toJS());
37
+ var en = (0, _flat.default)(_en.default);
63
38
  expect(language).toEqual(en);
64
39
  });
65
40
  });
66
-
67
41
  describe('when en language is selected', function () {
68
42
  it('should allow check for external en dictionaries', function () {
69
43
  var i18n = require('../i18n');
70
-
71
- i18n.initI18n(_immutable2.default.fromJS({}));
44
+ i18n.initI18n(_immutable.default.fromJS({}));
72
45
  expect(syncSpy).toHaveBeenCalledTimes(1);
73
46
  });
74
47
  });
75
-
76
48
  describe('when html is called', function () {
77
49
  it('should sanitize the input and not allow for javascript to be passed through', function () {
78
50
  var i18n = require('../i18n');
79
51
  var strings = {
80
52
  test: '<img src=1 href=1 onerror="javascript:alert(1)"></img>'
81
53
  };
82
- var m = _immutable2.default.fromJS({ i18n: { strings: strings } });
54
+ var m = _immutable.default.fromJS({
55
+ i18n: {
56
+ strings: strings
57
+ }
58
+ });
83
59
  var html = i18n.html(m, 'test');
84
60
  expect(html.props.dangerouslySetInnerHTML.__html).not.toMatch(/javascript:alert/);
85
61
  expect(html.props.dangerouslySetInnerHTML.__html).toEqual('<img href="1" src="1">');
86
62
  });
87
-
88
63
  it('should allow target=_blank with noopener noreferrer attributes', function () {
89
64
  (0, _sanitizer.initSanitizer)();
90
-
91
65
  var i18n = require('../i18n');
92
-
93
66
  var strings = {
94
67
  test: '<a href="#" target="_blank">link</a>'
95
68
  };
96
-
97
- var m = _immutable2.default.fromJS({ i18n: { strings: strings } });
69
+ var m = _immutable.default.fromJS({
70
+ i18n: {
71
+ strings: strings
72
+ }
73
+ });
98
74
  var html = i18n.html(m, 'test');
99
-
100
75
  expect(html.props.dangerouslySetInnerHTML.__html).toEqual('<a href="#" target="_blank" rel="noopener noreferrer">link</a>');
101
76
  });
102
77
  });
@@ -1,13 +1,11 @@
1
- 'use strict';
2
-
3
- var _actions = require('../../quick-auth/actions');
1
+ "use strict";
4
2
 
3
+ var _actions = require("../../quick-auth/actions");
5
4
  jest.mock('../../core/actions', function () {
6
5
  return {
7
6
  logIn: jest.fn()
8
7
  };
9
8
  });
10
-
11
9
  jest.mock('store/index', function () {
12
10
  return {
13
11
  read: jest.fn(function () {
@@ -18,7 +16,6 @@ jest.mock('store/index', function () {
18
16
  updateEntity: 'updateEntity'
19
17
  };
20
18
  });
21
-
22
19
  jest.mock('../../core/index', function () {
23
20
  return {
24
21
  id: function id() {
@@ -37,12 +34,10 @@ jest.mock('../../core/index', function () {
37
34
  setSuppressSubmitOverlay: jest.fn()
38
35
  };
39
36
  });
40
-
41
37
  describe('quick-auth.actions', function () {
42
38
  beforeEach(function () {
43
39
  jest.clearAllMocks();
44
40
  });
45
-
46
41
  it('calls logIn with the correct parameters', function () {
47
42
  var connection = {
48
43
  get: jest.fn(function (key) {
@@ -54,15 +49,11 @@ describe('quick-auth.actions', function () {
54
49
  }
55
50
  })
56
51
  };
57
-
58
52
  (0, _actions.logIn)('id', connection, 'hint', 'prompt');
59
-
60
53
  var coreActions = require('../../core/actions');
61
-
62
54
  expect(coreActions.logIn.mock.calls.length).toBe(1);
63
55
  expect(coreActions.logIn.mock.calls[0]).toMatchSnapshot();
64
56
  });
65
-
66
57
  it('sets display to "popup" when using facebook and there\'s no redirect', function () {
67
58
  var connection = {
68
59
  get: jest.fn(function (key) {
@@ -74,20 +65,15 @@ describe('quick-auth.actions', function () {
74
65
  }
75
66
  })
76
67
  };
77
-
78
68
  var core = require('../../core/index');
79
69
  core.auth.redirect = jest.fn(function () {
80
70
  return false;
81
71
  });
82
-
83
72
  (0, _actions.logIn)('id', connection);
84
-
85
73
  var coreActions = require('../../core/actions');
86
-
87
74
  expect(coreActions.logIn.mock.calls.length).toBe(1);
88
75
  expect(coreActions.logIn.mock.calls[0]).toMatchSnapshot();
89
76
  });
90
-
91
77
  it('calls setSuppressSubmitOverlay with true when using Apple connection', function () {
92
78
  var connection = {
93
79
  get: jest.fn(function (key) {
@@ -99,19 +85,14 @@ describe('quick-auth.actions', function () {
99
85
  }
100
86
  })
101
87
  };
102
-
103
88
  (0, _actions.logIn)('id', connection);
104
-
105
89
  var _require = require('store/index'),
106
- swap = _require.swap;
107
-
90
+ swap = _require.swap;
108
91
  var l = require('../../core/index');
109
-
110
92
  expect(swap.mock.calls.length).toBe(1);
111
93
  expect(swap.mock.calls[0][3]).toBe(l.setSupressSubmitOverlay);
112
94
  expect(swap.mock.calls[0][4]).toBe(true);
113
95
  });
114
-
115
96
  it('calls setSuppressSubmitOverlay with false when not using Apple connection', function () {
116
97
  var connection = {
117
98
  get: jest.fn(function (key) {
@@ -123,14 +104,10 @@ describe('quick-auth.actions', function () {
123
104
  }
124
105
  })
125
106
  };
126
-
127
107
  (0, _actions.logIn)('id', connection);
128
-
129
108
  var _require2 = require('store/index'),
130
- swap = _require2.swap;
131
-
109
+ swap = _require2.swap;
132
110
  var l = require('../../core/index');
133
-
134
111
  expect(swap.mock.calls.length).toBe(1);
135
112
  expect(swap.mock.calls[0][3]).toBe(l.setSupressSubmitOverlay);
136
113
  expect(swap.mock.calls[0][4]).toBe(false);
@@ -1,15 +1,13 @@
1
- 'use strict';
2
-
3
- var _enzyme = require('enzyme');
4
-
5
- var _enzymeAdapterReact = require('enzyme-adapter-react-15');
6
-
7
- var _enzymeAdapterReact2 = _interopRequireDefault(_enzymeAdapterReact);
1
+ "use strict";
8
2
 
3
+ var _enzyme = require("enzyme");
4
+ var _enzymeAdapterReact = _interopRequireDefault(require("@cfaester/enzyme-adapter-react-18"));
9
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
6
  // setup file
12
- (0, _enzyme.configure)({ adapter: new _enzymeAdapterReact2.default() });
7
+
8
+ (0, _enzyme.configure)({
9
+ adapter: new _enzymeAdapterReact.default()
10
+ });
13
11
 
14
12
  //jest polyfills
15
13
  window.requestAnimationFrame = function (callback) {
@@ -1,52 +1,46 @@
1
- 'use strict';
2
-
3
- exports.__esModule = true;
4
- exports.expectMockToMatch = exports.setURL = exports.extractPropsFromWrapper = exports.mockComponent = exports.renderShallowComponent = exports.expectShallowComponent = exports.expectComponent = undefined;
5
-
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
-
8
- var _react = require('react');
9
-
10
- var _react2 = _interopRequireDefault(_react);
11
-
12
- var _reactTestRenderer = require('react-test-renderer');
13
-
14
- var _reactTestRenderer2 = _interopRequireDefault(_reactTestRenderer);
15
-
16
- var _shallow = require('react-test-renderer/shallow');
17
-
18
- var _shallow2 = _interopRequireDefault(_shallow);
19
-
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.setURL = exports.renderShallowComponent = exports.mockComponent = exports.extractPropsFromWrapper = exports.expectShallowComponent = exports.expectMockToMatch = exports.expectComponent = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
10
+ var _shallow = _interopRequireDefault(require("react-test-renderer/shallow"));
11
+ var _webpack = require("webpack");
12
+ var _excluded = ["children"];
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
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
-
24
-
25
- var expectComponent = exports.expectComponent = function expectComponent(children, opts) {
26
- var component = _reactTestRenderer2.default.create(children, opts);
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+ 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; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
18
+ 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); }
19
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
+ var expectComponent = function expectComponent(children, opts) {
22
+ var component = _reactTestRenderer.default.create(children, opts);
27
23
  return expect(component);
28
24
  };
29
-
30
- var expectShallowComponent = exports.expectShallowComponent = function expectShallowComponent(children) {
25
+ exports.expectComponent = expectComponent;
26
+ var expectShallowComponent = function expectShallowComponent(children) {
31
27
  var component = renderShallowComponent(children);
32
28
  return expect(component);
33
29
  };
34
-
35
- var renderShallowComponent = exports.renderShallowComponent = function renderShallowComponent(children) {
36
- var renderer = new _shallow2.default();
37
-
30
+ exports.expectShallowComponent = expectShallowComponent;
31
+ var renderShallowComponent = function renderShallowComponent(children) {
32
+ var renderer = new _shallow.default();
38
33
  renderer.render(children);
39
34
  return renderer.getRenderOutput();
40
35
  };
41
-
36
+ exports.renderShallowComponent = renderShallowComponent;
42
37
  var addDataToProps = function addDataToProps(props) {
43
38
  var returnedProps = {};
44
39
  Object.keys(props).forEach(function (k) {
45
- return returnedProps['data-' + k] = props[k];
40
+ return returnedProps["data-".concat(k)] = props[k];
46
41
  });
47
42
  return returnedProps;
48
43
  };
49
-
50
44
  var removeDataFromProps = function removeDataFromProps(props) {
51
45
  var returnedProps = {};
52
46
  Object.keys(props).forEach(function (k) {
@@ -54,48 +48,37 @@ var removeDataFromProps = function removeDataFromProps(props) {
54
48
  });
55
49
  return returnedProps;
56
50
  };
57
-
58
51
  var mockComponent = function mockComponent(type) {
59
52
  var domElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'div';
60
53
  return function (_ref) {
61
54
  var children = _ref.children,
62
- props = _objectWithoutProperties(_ref, ['children']);
63
-
64
- return _react2.default.createElement(domElement, _extends({
55
+ props = _objectWithoutProperties(_ref, _excluded);
56
+ return /*#__PURE__*/_react.default.createElement(domElement, _objectSpread({
65
57
  'data-__type': type
66
58
  }, addDataToProps(props)), children);
67
59
  };
68
60
  };
69
-
70
61
  exports.mockComponent = mockComponent;
71
- var extractPropsFromWrapper = exports.extractPropsFromWrapper = function extractPropsFromWrapper(wrapper) {
62
+ var extractPropsFromWrapper = function extractPropsFromWrapper(wrapper) {
72
63
  var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
73
64
  return removeDataFromProps(wrapper.find('div').at(index).props());
74
65
  };
75
66
 
76
- //set urls with jest: https://github.com/facebook/jest/issues/890#issuecomment-298594389
77
- var setURL = exports.setURL = function setURL(url) {
78
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
79
-
80
- var parser = document.createElement('a');
81
- parser.href = url;
82
- ['href', 'protocol', 'host', 'hostname', 'origin', 'port', 'pathname', 'search', 'hash'].forEach(function (prop) {
83
- var value = parser[prop];
84
- if (prop === 'origin' && options.noOrigin) {
85
- value = null;
86
- }
87
- Object.defineProperty(window.location, prop, {
88
- value: value,
89
- writable: true
90
- });
67
+ // Newer (> Jest v22) versions don't allow modification of location.href
68
+ // but can use `jsdom.reconfigure` when `jsdom` is exposed globally.
69
+ // https://www.npmjs.com/package/jest-environment-jsdom-global
70
+ exports.extractPropsFromWrapper = extractPropsFromWrapper;
71
+ var setURL = function setURL(url) {
72
+ jsdom.reconfigure({
73
+ url: url
91
74
  });
92
75
  };
93
-
94
- var expectMockToMatch = exports.expectMockToMatch = function expectMockToMatch(_ref2, numberOfCalls) {
76
+ exports.setURL = setURL;
77
+ var expectMockToMatch = function expectMockToMatch(_ref2, numberOfCalls) {
95
78
  var mock = _ref2.mock;
96
-
97
79
  expect(mock.calls.length).toBe(numberOfCalls);
98
80
  for (var i = 0; i < numberOfCalls; i++) {
99
81
  expect(mock.calls[i]).toMatchSnapshot();
100
82
  }
101
83
  };
84
+ exports.expectMockToMatch = expectMockToMatch;