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,23 +1,15 @@
1
- 'use strict';
2
-
3
- var _react = require('react');
4
-
5
- var _react2 = _interopRequireDefault(_react);
6
-
7
- var _enzyme = require('enzyme');
8
-
9
- var _password_strength = require('../../../../ui/input/password/password_strength');
10
-
11
- var _password_strength2 = _interopRequireDefault(_password_strength);
1
+ "use strict";
12
2
 
3
+ var _react = _interopRequireDefault(require("react"));
4
+ var _enzyme = require("enzyme");
5
+ var _password_strength = _interopRequireDefault(require("../../../../ui/input/password/password_strength"));
13
6
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
7
  describe('PasswordStrength', function () {
16
8
  beforeEach(function () {
17
9
  jest.resetModules();
18
10
  });
19
11
  describe('validatePassword()', function () {
20
- it('validates password correctly with invalid password', function () {
12
+ it("validates password correctly with invalid password", function () {
21
13
  var policy = {
22
14
  toJS: function toJS() {
23
15
  return {
@@ -27,8 +19,14 @@ describe('PasswordStrength', function () {
27
19
  };
28
20
  }
29
21
  };
30
- var messages = { foo: 'the-message' };
31
- var wrapper = (0, _enzyme.mount)(_react2.default.createElement(_password_strength2.default, { policy: policy, password: 'the-password', messages: messages }));
22
+ var messages = {
23
+ foo: 'the-message'
24
+ };
25
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_password_strength.default, {
26
+ policy: policy,
27
+ password: "the-password",
28
+ messages: messages
29
+ }));
32
30
  expect(wrapper.html()).toMatchSnapshot();
33
31
  });
34
32
  });
@@ -1,28 +1,17 @@
1
- 'use strict';
2
-
3
- var _react = require('react');
4
-
5
- var _react2 = _interopRequireDefault(_react);
6
-
7
- var _enzyme = require('enzyme');
8
-
9
- var _testUtils = require('testUtils');
10
-
11
- var _testUtils2 = require('../../testUtils');
12
-
13
- var _input_wrap = require('../../../ui/input/input_wrap');
14
-
15
- var _input_wrap2 = _interopRequireDefault(_input_wrap);
1
+ "use strict";
16
2
 
3
+ var _react = _interopRequireDefault(require("react"));
4
+ var _enzyme = require("enzyme");
5
+ var _testUtils = require("testUtils");
6
+ var _testUtils2 = require("../../testUtils");
7
+ var _input_wrap = _interopRequireDefault(require("../../../ui/input/input_wrap"));
17
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
9
  jest.mock('ui/input/input_wrap', function () {
20
10
  return (0, _testUtils.mockComponent)('input_wrap');
21
11
  });
22
12
  jest.mock('ui/input/password/password_strength', function () {
23
13
  return (0, _testUtils.mockComponent)('password_strength');
24
14
  });
25
-
26
15
  jest.mock('core/index', function () {
27
16
  return {
28
17
  ui: {
@@ -35,11 +24,9 @@ jest.mock('core/index', function () {
35
24
  })
36
25
  };
37
26
  });
38
-
39
27
  var getComponent = function getComponent() {
40
28
  return require('ui/input/password_input').default;
41
29
  };
42
-
43
30
  describe('PasswordInput', function () {
44
31
  var defaultProps = {
45
32
  invalidHint: 'invalidHint',
@@ -47,19 +34,27 @@ describe('PasswordInput', function () {
47
34
  isValid: true,
48
35
  onChange: jest.fn(),
49
36
  policy: 'policy',
50
- strengthMessages: { strengthMessages: 'strengthMessages' },
37
+ strengthMessages: {
38
+ strengthMessages: 'strengthMessages'
39
+ },
51
40
  value: 'value',
52
41
  showPassword: false,
53
42
  lock: {}
54
43
  };
55
44
  test('sends PasswordStrength as the `after` param', function () {
56
45
  var Input = getComponent();
57
- var wrapper = (0, _enzyme.mount)(_react2.default.createElement(Input, defaultProps));
46
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(Input, defaultProps));
58
47
  wrapper.find('input').simulate('focus');
59
- wrapper.find('input').simulate('change', { target: { value: 'pass' } });
48
+ wrapper.find('input').simulate('change', {
49
+ target: {
50
+ value: 'pass'
51
+ }
52
+ });
60
53
  var props = (0, _testUtils2.extractPropsFromWrapper)(wrapper);
61
54
  expect(props.after.props).toEqual({
62
- messages: { strengthMessages: 'strengthMessages' },
55
+ messages: {
56
+ strengthMessages: 'strengthMessages'
57
+ },
63
58
  password: 'value',
64
59
  policy: 'policy'
65
60
  });
@@ -69,7 +64,7 @@ describe('PasswordInput', function () {
69
64
  return true;
70
65
  };
71
66
  var Input = getComponent();
72
- var wrapper = (0, _enzyme.mount)(_react2.default.createElement(Input, defaultProps));
67
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(Input, defaultProps));
73
68
  expect(wrapper.find('input').props().autoComplete).toBe('on');
74
69
  });
75
70
  test('`allowPasswordAutocomplete=false` sets `autoComplete` as off', function () {
@@ -77,12 +72,12 @@ describe('PasswordInput', function () {
77
72
  return false;
78
73
  };
79
74
  var Input = getComponent();
80
- var wrapper = (0, _enzyme.mount)(_react2.default.createElement(Input, defaultProps));
75
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(Input, defaultProps));
81
76
  expect(wrapper.find('input').props().autoComplete).toBe('off');
82
77
  });
83
78
  test('shows invalid Hint', function () {
84
79
  var Input = getComponent();
85
- var wrapper = (0, _enzyme.mount)(_react2.default.createElement(Input, defaultProps));
86
- expect(wrapper.find(_input_wrap2.default).props().invalidHint).toBe('invalidHint');
80
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(Input, defaultProps));
81
+ expect(wrapper.find(_input_wrap.default).props().invalidHint).toBe('invalidHint');
87
82
  });
88
83
  });
@@ -1,33 +1,26 @@
1
- 'use strict';
2
-
3
- var _format = require('../../utils/format');
4
-
5
- var _format2 = _interopRequireDefault(_format);
1
+ "use strict";
6
2
 
3
+ var _format = _interopRequireDefault(require("../../utils/format"));
7
4
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
5
  describe('format', function () {
10
6
  it('can format a string', function () {
11
- expect((0, _format2.default)('a string')).toEqual('a string');
7
+ expect((0, _format.default)('a string')).toEqual('a string');
12
8
  });
13
-
14
9
  it('can replace a string', function () {
15
- expect((0, _format2.default)('%s', 'test')).toEqual('test');
10
+ expect((0, _format.default)('%s', 'test')).toEqual('test');
16
11
  });
17
-
18
12
  it('can replace a string inside a string', function () {
19
- expect((0, _format2.default)('a string: %s', 'test')).toEqual('a string: test');
13
+ expect((0, _format.default)('a string: %s', 'test')).toEqual('a string: test');
20
14
  });
21
-
22
15
  it('can replace multiple strings', function () {
23
- expect((0, _format2.default)('%s:%s', 'a', 'b')).toEqual('a:b');
16
+ expect((0, _format.default)('%s:%s', 'a', 'b')).toEqual('a:b');
24
17
  });
25
-
26
18
  it('can replace with a number', function () {
27
- expect((0, _format2.default)('%d', 12)).toEqual('12');
19
+ expect((0, _format.default)('%d', 12)).toEqual('12');
28
20
  });
29
-
30
21
  it('can format an object', function () {
31
- expect((0, _format2.default)('%j', { key: 'value' })).toEqual('{"key":"value"}');
22
+ expect((0, _format.default)('%j', {
23
+ key: 'value'
24
+ })).toEqual('{"key":"value"}');
32
25
  });
33
26
  });
@@ -1,7 +1,6 @@
1
- 'use strict';
2
-
3
- var _url_utils = require('../../utils/url_utils');
1
+ "use strict";
4
2
 
3
+ var _url_utils = require("../../utils/url_utils");
5
4
  describe('url utils', function () {
6
5
  describe('getOriginFromUrl', function () {
7
6
  it('should return undefined if there is no url', function () {
@@ -78,13 +77,11 @@ describe('url utils', function () {
78
77
  hash: '#/foo/access_token=foo'
79
78
  }
80
79
  };
81
-
82
80
  var _loop = function _loop(url) {
83
81
  it('should map urls correctly: ' + url, function () {
84
82
  expect((0, _url_utils.getLocationFromUrl)(url)).toMatchObject(mapping[url]);
85
83
  });
86
84
  };
87
-
88
85
  for (var url in mapping) {
89
86
  _loop(url);
90
87
  }
@@ -1,37 +1,24 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- exports.__esModule = true;
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
4
6
  exports.displayName = displayName;
5
7
  exports.url = url;
6
-
7
- var _blueimpMd = require('blueimp-md5');
8
-
9
- var _blueimpMd2 = _interopRequireDefault(_blueimpMd);
10
-
11
- var _trim = require('trim');
12
-
13
- var _trim2 = _interopRequireDefault(_trim);
14
-
15
- var _jsonp_utils = require('../utils/jsonp_utils');
16
-
17
- var _jsonp_utils2 = _interopRequireDefault(_jsonp_utils);
18
-
19
- var _email = require('../field/email');
20
-
8
+ var _blueimpMd = _interopRequireDefault(require("blueimp-md5"));
9
+ var _trim = _interopRequireDefault(require("trim"));
10
+ var _jsonp_utils = _interopRequireDefault(require("../utils/jsonp_utils"));
11
+ var _email = require("../field/email");
21
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
-
23
- var md5 = _blueimpMd2.default.md5 || _blueimpMd2.default;
24
-
13
+ var md5 = _blueimpMd.default.md5 || _blueimpMd.default;
25
14
  function normalize(str) {
26
- return typeof str === 'string' ? (0, _trim2.default)(str.toLowerCase()) : '';
15
+ return typeof str === 'string' ? (0, _trim.default)(str.toLowerCase()) : '';
27
16
  }
28
-
29
17
  function displayName(email, cb) {
30
18
  email = normalize(email);
31
19
  if (!(0, _email.validateEmail)(email)) return cb({});
32
-
33
- var url = 'https://secure.gravatar.com/' + md5(email) + '.json';
34
- _jsonp_utils2.default.get(url, function (error, result) {
20
+ var url = "https://secure.gravatar.com/".concat(md5(email), ".json");
21
+ _jsonp_utils.default.get(url, function (error, result) {
35
22
  if (!error && result && result.entry && result.entry[0]) {
36
23
  cb(null, result.entry[0].displayName);
37
24
  } else {
@@ -39,10 +26,8 @@ function displayName(email, cb) {
39
26
  }
40
27
  });
41
28
  }
42
-
43
29
  function url(email, cb) {
44
30
  email = normalize(email);
45
31
  if (!(0, _email.validateEmail)(email)) return cb({});
46
-
47
- cb(null, 'https://secure.gravatar.com/avatar/' + md5(email) + '?d=404&s=160');
32
+ cb(null, "https://secure.gravatar.com/avatar/".concat(md5(email), "?d=404&s=160"));
48
33
  }
package/lib/avatar.js CHANGED
@@ -1,76 +1,58 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- exports.__esModule = true;
4
- exports.debouncedRequestAvatar = undefined;
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.debouncedRequestAvatar = void 0;
5
8
  exports.requestAvatar = requestAvatar;
6
-
7
- var _index = require('./store/index');
8
-
9
- var _data_utils = require('./utils/data_utils');
10
-
11
- var _preload_utils = require('./utils/preload_utils');
12
-
13
- var preload = _interopRequireWildcard(_preload_utils);
14
-
15
- var _fn_utils = require('./utils/fn_utils');
16
-
17
- var f = _interopRequireWildcard(_fn_utils);
18
-
19
- var _index2 = require('./core/index');
20
-
21
- var l = _interopRequireWildcard(_index2);
22
-
23
- 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; } }
24
-
9
+ var _index = require("./store/index");
10
+ var _data_utils = require("./utils/data_utils");
11
+ var preload = _interopRequireWildcard(require("./utils/preload_utils"));
12
+ var f = _interopRequireWildcard(require("./utils/fn_utils"));
13
+ var l = _interopRequireWildcard(require("./core/index"));
14
+ 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); }
15
+ 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; }
25
16
  var _dataFns = (0, _data_utils.dataFns)(['avatar']),
26
- tget = _dataFns.tget,
27
- tset = _dataFns.tset;
28
-
17
+ tget = _dataFns.tget,
18
+ tset = _dataFns.tset;
29
19
  var cache = {};
30
-
31
20
  function requestAvatar(id, src) {
32
21
  if (cache[src]) {
33
22
  return update(id, src, cache[src].url, cache[src].displayName, true);
34
23
  }
35
-
36
24
  var provider = l.ui.avatarProvider((0, _index.read)(_index.getEntity, 'lock', id)).toJS();
37
-
38
25
  (0, _index.swap)(_index.updateEntity, 'lock', id, function (m) {
39
26
  m = tset(m, 'syncStatus', 'loading');
40
27
  m = tset(m, 'src', src);
41
28
  return m;
42
29
  });
43
-
44
- var url = void 0,
45
- displayName = void 0;
46
-
30
+ var url, displayName;
47
31
  provider.url(src, function (error, str) {
48
32
  if (error) return handleError(id, src);
49
-
50
33
  preload.img(str, function (error, img) {
51
34
  if (error) return handleError(id, src);
52
35
  url = img.src;
53
36
  if (displayName !== undefined) handleSuccess(id, src, url, displayName);
54
37
  });
55
38
  });
56
-
57
39
  provider.displayName(src, function (error, str) {
58
40
  if (error) return handleError(id);
59
41
  displayName = str;
60
42
  if (url !== undefined) handleSuccess(id, src, url, displayName);
61
43
  });
62
44
  }
63
-
64
- var debouncedRequestAvatar = exports.debouncedRequestAvatar = f.debounce(requestAvatar, 300);
65
-
45
+ var debouncedRequestAvatar = f.debounce(requestAvatar, 300);
46
+ exports.debouncedRequestAvatar = debouncedRequestAvatar;
66
47
  function handleSuccess(id, src, url, displayName) {
67
- cache[src] = { url: url, displayName: displayName };
48
+ cache[src] = {
49
+ url: url,
50
+ displayName: displayName
51
+ };
68
52
  update(id, src, url, displayName);
69
53
  }
70
-
71
54
  function update(id, src, url, displayName) {
72
55
  var force = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
73
-
74
56
  (0, _index.swap)(_index.updateEntity, 'lock', id, function (m) {
75
57
  if (force || tget(m, 'src') === src) {
76
58
  m = tset(m, 'syncStatus', 'ok');
@@ -81,7 +63,6 @@ function update(id, src, url, displayName) {
81
63
  return m;
82
64
  });
83
65
  }
84
-
85
66
  function handleError(id, src) {
86
67
  (0, _index.swap)(_index.updateEntity, 'lock', id, function (m) {
87
68
  return tget(m, 'src') === 'src' ? tset(m, 'syncStatus', 'error') : m;