@jetbrains/ring-ui 4.2.4 → 4.2.5

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 (315) hide show
  1. package/package.json +2 -2
  2. package/dist/_helpers/_rollupPluginBabelHelpers.js +0 -34
  3. package/dist/_helpers/anchor.js +0 -33
  4. package/dist/_helpers/badge.js +0 -3
  5. package/dist/_helpers/button-group.js +0 -3
  6. package/dist/_helpers/button-set.js +0 -3
  7. package/dist/_helpers/button-toolbar.js +0 -3
  8. package/dist/_helpers/button__classes.js +0 -39
  9. package/dist/_helpers/card.js +0 -75
  10. package/dist/_helpers/checkbox.js +0 -3
  11. package/dist/_helpers/date-picker.js +0 -3
  12. package/dist/_helpers/dialog__body-scroll-preventer.js +0 -58
  13. package/dist/_helpers/error-message.js +0 -3
  14. package/dist/_helpers/footer.js +0 -121
  15. package/dist/_helpers/grid.js +0 -3
  16. package/dist/_helpers/group.js +0 -3
  17. package/dist/_helpers/header.js +0 -3
  18. package/dist/_helpers/icon.js +0 -3
  19. package/dist/_helpers/inject-styles.js +0 -22
  20. package/dist/_helpers/input.js +0 -3
  21. package/dist/_helpers/island.js +0 -3
  22. package/dist/_helpers/link.js +0 -3
  23. package/dist/_helpers/list.js +0 -3
  24. package/dist/_helpers/loader-screen.js +0 -3
  25. package/dist/_helpers/panel.js +0 -3
  26. package/dist/_helpers/query-assist__suggestions.js +0 -95
  27. package/dist/_helpers/radio.js +0 -3
  28. package/dist/_helpers/select__filter.js +0 -77
  29. package/dist/_helpers/services-link.js +0 -40
  30. package/dist/_helpers/sidebar.js +0 -126
  31. package/dist/_helpers/table.js +0 -3
  32. package/dist/_helpers/tabs.js +0 -3
  33. package/dist/_helpers/title.js +0 -100
  34. package/dist/alert/alert.js +0 -262
  35. package/dist/alert/container.js +0 -48
  36. package/dist/alert-service/alert-service.js +0 -173
  37. package/dist/analytics/analytics.js +0 -118
  38. package/dist/analytics/analytics__custom-plugin.js +0 -128
  39. package/dist/analytics/analytics__fus-plugin.js +0 -102
  40. package/dist/analytics/analytics__ga-plugin.js +0 -75
  41. package/dist/analytics/analytics__plugin-utils.js +0 -80
  42. package/dist/analytics-ng/analytics-ng.js +0 -95
  43. package/dist/auth/auth.js +0 -96
  44. package/dist/auth/auth__core.js +0 -1059
  45. package/dist/auth/background-flow.js +0 -123
  46. package/dist/auth/down-notification.js +0 -117
  47. package/dist/auth/iframe-flow.js +0 -153
  48. package/dist/auth/landing-entry.js +0 -5
  49. package/dist/auth/landing.js +0 -90
  50. package/dist/auth/request-builder.js +0 -76
  51. package/dist/auth/response-parser.js +0 -118
  52. package/dist/auth/storage.js +0 -283
  53. package/dist/auth/token-validator.js +0 -178
  54. package/dist/auth/window-flow.js +0 -134
  55. package/dist/auth-dialog/auth-dialog.js +0 -180
  56. package/dist/auth-dialog-service/auth-dialog-service.js +0 -71
  57. package/dist/auth-ng/auth-ng.js +0 -206
  58. package/dist/auth-ng/auth-ng.mock.js +0 -33
  59. package/dist/autofocus-ng/autofocus-ng.js +0 -51
  60. package/dist/avatar/avatar-example-datauri.js +0 -4
  61. package/dist/avatar/avatar.js +0 -163
  62. package/dist/avatar/fallback-avatar.js +0 -142
  63. package/dist/avatar-editor-ng/avatar-editor-ng.js +0 -167
  64. package/dist/avatar-editor-ng/avatar-editor-ng__template.js +0 -3
  65. package/dist/avatar-ng/avatar-ng.js +0 -21
  66. package/dist/badge/badge.js +0 -51
  67. package/dist/badge-ng/badge-ng.js +0 -18
  68. package/dist/breadcrumb-ng/breadcrumb-ng.js +0 -37
  69. package/dist/button/button.js +0 -125
  70. package/dist/button/button__classes.js +0 -5
  71. package/dist/button-group/button-group.js +0 -30
  72. package/dist/button-group/caption.js +0 -24
  73. package/dist/button-group-ng/button-group-ng.js +0 -39
  74. package/dist/button-ng/button-ng.js +0 -217
  75. package/dist/button-set/button-set.js +0 -26
  76. package/dist/button-set-ng/button-set-ng.js +0 -19
  77. package/dist/button-toolbar/button-toolbar.js +0 -29
  78. package/dist/button-toolbar-ng/button-toolbar-ng.js +0 -24
  79. package/dist/caret/caret.js +0 -266
  80. package/dist/checkbox/checkbox.js +0 -110
  81. package/dist/checkbox-ng/checkbox-ng.js +0 -38
  82. package/dist/code/code.js +0 -137
  83. package/dist/compiler-ng/compiler-ng.js +0 -53
  84. package/dist/confirm/confirm.js +0 -127
  85. package/dist/confirm-ng/confirm-ng.js +0 -69
  86. package/dist/confirm-service/confirm-service.js +0 -117
  87. package/dist/content-layout/content-layout.js +0 -66
  88. package/dist/content-layout/sidebar.js +0 -7
  89. package/dist/contenteditable/contenteditable.js +0 -78
  90. package/dist/data-list/data-list.js +0 -208
  91. package/dist/data-list/data-list.mock.js +0 -191
  92. package/dist/data-list/item.js +0 -229
  93. package/dist/data-list/selection.js +0 -102
  94. package/dist/data-list/title.js +0 -20
  95. package/dist/data-list-ng/data-list-ng.js +0 -62
  96. package/dist/date-picker/consts.js +0 -69
  97. package/dist/date-picker/date-input.js +0 -175
  98. package/dist/date-picker/date-picker.js +0 -367
  99. package/dist/date-picker/date-popup.js +0 -483
  100. package/dist/date-picker/day.js +0 -120
  101. package/dist/date-picker/formats.js +0 -3
  102. package/dist/date-picker/month-names.js +0 -100
  103. package/dist/date-picker/month-slider.js +0 -84
  104. package/dist/date-picker/month.js +0 -55
  105. package/dist/date-picker/months.js +0 -122
  106. package/dist/date-picker/weekdays.js +0 -32
  107. package/dist/date-picker/years.js +0 -110
  108. package/dist/dialog/dialog.js +0 -202
  109. package/dist/dialog/dialog__body-scroll-preventer.js +0 -3
  110. package/dist/dialog-ng/dialog-ng.js +0 -604
  111. package/dist/dialog-ng/dialog-ng__template.js +0 -3
  112. package/dist/docked-panel-ng/docked-panel-ng.js +0 -171
  113. package/dist/dropdown/anchor.js +0 -19
  114. package/dist/dropdown/dropdown.js +0 -236
  115. package/dist/dropdown-menu/dropdown-menu.js +0 -177
  116. package/dist/error-bubble/error-bubble.js +0 -59
  117. package/dist/error-message/error-message.js +0 -57
  118. package/dist/error-message-ng/error-message-ng.js +0 -35
  119. package/dist/footer/footer.js +0 -12
  120. package/dist/footer-ng/footer-ng.js +0 -64
  121. package/dist/form-ng/form-ng.js +0 -167
  122. package/dist/global/angular-component-factory.js +0 -84
  123. package/dist/global/compose.js +0 -9
  124. package/dist/global/composeRefs.js +0 -15
  125. package/dist/global/conic-gradient.js +0 -35
  126. package/dist/global/create-stateful-context.js +0 -55
  127. package/dist/global/data-tests.js +0 -24
  128. package/dist/global/dom.js +0 -125
  129. package/dist/global/focus-sensor-hoc.js +0 -146
  130. package/dist/global/fuzzy-highlight.js +0 -67
  131. package/dist/global/get-event-key.js +0 -111
  132. package/dist/global/get-uid.js +0 -15
  133. package/dist/global/inject-styles.js +0 -15
  134. package/dist/global/linear-function.js +0 -17
  135. package/dist/global/listeners.js +0 -44
  136. package/dist/global/memoize.js +0 -20
  137. package/dist/global/normalize-indent.js +0 -30
  138. package/dist/global/promise-with-timeout.js +0 -17
  139. package/dist/global/radial-gradient-mask.js +0 -38
  140. package/dist/global/react-dom-renderer.js +0 -46
  141. package/dist/global/react-render-adapter.js +0 -41
  142. package/dist/global/rerender-hoc.js +0 -55
  143. package/dist/global/ring-angular-component.js +0 -24
  144. package/dist/global/schedule-raf.js +0 -31
  145. package/dist/global/sniffer.js +0 -6
  146. package/dist/global/supports-css.js +0 -22
  147. package/dist/global/theme.js +0 -54
  148. package/dist/global/trivial-template-tag.js +0 -17
  149. package/dist/global/url.js +0 -165
  150. package/dist/global/variables_dark.js +0 -57
  151. package/dist/grid/col.js +0 -60
  152. package/dist/grid/grid.js +0 -33
  153. package/dist/grid/row.js +0 -64
  154. package/dist/group/group.js +0 -31
  155. package/dist/group-ng/group-ng.js +0 -11
  156. package/dist/header/header.js +0 -150
  157. package/dist/header/logo.js +0 -40
  158. package/dist/header/profile.js +0 -219
  159. package/dist/header/services-link.js +0 -12
  160. package/dist/header/services.js +0 -138
  161. package/dist/header/smart-profile.js +0 -233
  162. package/dist/header/smart-services.js +0 -163
  163. package/dist/header/tray-icon.js +0 -47
  164. package/dist/header/tray.js +0 -31
  165. package/dist/heading/heading.js +0 -73
  166. package/dist/http/http.js +0 -218
  167. package/dist/http/http.mock.js +0 -67
  168. package/dist/hub-source/hub-source.js +0 -130
  169. package/dist/hub-source/hub-source__user.js +0 -30
  170. package/dist/hub-source/hub-source__users-groups.js +0 -63
  171. package/dist/icon/icon.js +0 -105
  172. package/dist/icon/icon__constants.js +0 -33
  173. package/dist/icon/icon__svg.js +0 -83
  174. package/dist/icon/index.js +0 -12
  175. package/dist/icon-ng/icon-ng.js +0 -91
  176. package/dist/input/input.js +0 -230
  177. package/dist/input-ng/input-ng.js +0 -111
  178. package/dist/island/adaptive-island-hoc.js +0 -48
  179. package/dist/island/content.js +0 -160
  180. package/dist/island/header.js +0 -84
  181. package/dist/island/island.js +0 -51
  182. package/dist/island-legacy/content-legacy.js +0 -26
  183. package/dist/island-legacy/header-legacy.js +0 -28
  184. package/dist/island-legacy/island-legacy.js +0 -28
  185. package/dist/island-ng/island-content-ng.js +0 -42
  186. package/dist/island-ng/island-header-ng.js +0 -26
  187. package/dist/island-ng/island-ng-class-fixer.js +0 -11
  188. package/dist/island-ng/island-ng.js +0 -25
  189. package/dist/link/clickableLink.js +0 -64
  190. package/dist/link/link.js +0 -115
  191. package/dist/link-ng/link-ng.js +0 -22
  192. package/dist/list/consts.js +0 -26
  193. package/dist/list/list.js +0 -818
  194. package/dist/list/list__custom.js +0 -86
  195. package/dist/list/list__hint.js +0 -26
  196. package/dist/list/list__item.js +0 -206
  197. package/dist/list/list__link.js +0 -65
  198. package/dist/list/list__separator.js +0 -30
  199. package/dist/list/list__title.js +0 -39
  200. package/dist/list/list__users-groups-source.js +0 -130
  201. package/dist/loader/loader.js +0 -71
  202. package/dist/loader/loader__core.js +0 -273
  203. package/dist/loader-inline/inject-styles.js +0 -13
  204. package/dist/loader-inline/loader-inline.js +0 -58
  205. package/dist/loader-inline-ng/loader-inline-ng.js +0 -44
  206. package/dist/loader-ng/loader-ng.js +0 -44
  207. package/dist/loader-screen/loader-screen.js +0 -44
  208. package/dist/loader-screen-ng/loader-screen-ng.js +0 -95
  209. package/dist/login-dialog/login-dialog.js +0 -188
  210. package/dist/login-dialog/service.js +0 -72
  211. package/dist/markdown/code.js +0 -31
  212. package/dist/markdown/heading.js +0 -23
  213. package/dist/markdown/link.js +0 -31
  214. package/dist/markdown/markdown.js +0 -74
  215. package/dist/message/message.js +0 -235
  216. package/dist/message-bundle-ng/message-bundle-ng.js +0 -111
  217. package/dist/old-browsers-message/old-browsers-message.js +0 -101
  218. package/dist/old-browsers-message/old-browsers-message__stop.js +0 -5
  219. package/dist/old-browsers-message/white-list.js +0 -34
  220. package/dist/pager/pager.js +0 -365
  221. package/dist/pager-ng/pager-ng.js +0 -100
  222. package/dist/panel/panel.js +0 -31
  223. package/dist/panel-ng/panel-ng.js +0 -17
  224. package/dist/permissions/permissions.js +0 -200
  225. package/dist/permissions/permissions__cache.js +0 -272
  226. package/dist/permissions-ng/permissions-ng.js +0 -277
  227. package/dist/place-under-ng/place-under-ng.js +0 -158
  228. package/dist/popup/popup.consts.js +0 -41
  229. package/dist/popup/popup.js +0 -396
  230. package/dist/popup/popup.target.js +0 -26
  231. package/dist/popup/position.js +0 -280
  232. package/dist/popup-menu/popup-menu.js +0 -117
  233. package/dist/progress-bar/progress-bar.js +0 -114
  234. package/dist/progress-bar-ng/progress-bar-ng.js +0 -17
  235. package/dist/promised-click-ng/promised-click-ng.js +0 -128
  236. package/dist/proxy-attrs/proxy-attrs.js +0 -21
  237. package/dist/query-assist/query-assist.js +0 -1096
  238. package/dist/query-assist/query-assist__suggestions.js +0 -49
  239. package/dist/query-assist-ng/query-assist-ng.js +0 -86
  240. package/dist/radio/radio.js +0 -42
  241. package/dist/radio/radio__item.js +0 -78
  242. package/dist/radio-ng/radio-ng.js +0 -47
  243. package/dist/save-field-ng/save-field-ng.js +0 -337
  244. package/dist/save-field-ng/save-field-ng__template.js +0 -3
  245. package/dist/select/select.js +0 -1357
  246. package/dist/select/select__filter.js +0 -56
  247. package/dist/select/select__popup.js +0 -553
  248. package/dist/select-ng/select-ng.js +0 -637
  249. package/dist/select-ng/select-ng__lazy.js +0 -169
  250. package/dist/select-ng/select-ng__options.js +0 -145
  251. package/dist/shortcuts/core.js +0 -245
  252. package/dist/shortcuts/shortcut-title.js +0 -51
  253. package/dist/shortcuts/shortcuts-hoc.js +0 -42
  254. package/dist/shortcuts/shortcuts.js +0 -72
  255. package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +0 -123
  256. package/dist/shortcuts-hint-ng/shortcuts-hint-ng__template.js +0 -3
  257. package/dist/shortcuts-ng/shortcuts-ng.js +0 -262
  258. package/dist/sidebar-ng/sidebar-ng.js +0 -113
  259. package/dist/sidebar-ng/sidebar-ng__button-template.js +0 -3
  260. package/dist/sidebar-ng/sidebar-ng__template.js +0 -3
  261. package/dist/storage/storage.js +0 -59
  262. package/dist/storage/storage__fallback.js +0 -215
  263. package/dist/storage/storage__local.js +0 -154
  264. package/dist/style.css +0 -1
  265. package/dist/tab-trap/tab-trap.js +0 -177
  266. package/dist/table/cell.js +0 -26
  267. package/dist/table/disable-hover-hoc.js +0 -54
  268. package/dist/table/header-cell.js +0 -92
  269. package/dist/table/header.js +0 -193
  270. package/dist/table/multitable.js +0 -141
  271. package/dist/table/row-with-focus-sensor.js +0 -83
  272. package/dist/table/row.js +0 -273
  273. package/dist/table/selection-adapter.js +0 -16
  274. package/dist/table/selection-shortcuts-hoc.js +0 -215
  275. package/dist/table/selection.js +0 -223
  276. package/dist/table/smart-table.js +0 -125
  277. package/dist/table/table.js +0 -406
  278. package/dist/table-legacy-ng/table-legacy-ng.js +0 -468
  279. package/dist/table-legacy-ng/table-legacy-ng__pager.js +0 -120
  280. package/dist/table-legacy-ng/table-legacy-ng__selection-navigate-actions.js +0 -123
  281. package/dist/table-legacy-ng/table-legacy-ng__selection.js +0 -179
  282. package/dist/table-legacy-ng/table-legacy-ng__toolbar.js +0 -57
  283. package/dist/table-ng/smart-table-ng.js +0 -68
  284. package/dist/table-ng/table-ng.js +0 -67
  285. package/dist/tabs/collapsible-more.js +0 -198
  286. package/dist/tabs/collapsible-tab.js +0 -91
  287. package/dist/tabs/collapsible-tabs.js +0 -362
  288. package/dist/tabs/custom-item.js +0 -13
  289. package/dist/tabs/dumb-tabs.js +0 -164
  290. package/dist/tabs/smart-tabs.js +0 -106
  291. package/dist/tabs/tab-link.js +0 -42
  292. package/dist/tabs/tab.js +0 -33
  293. package/dist/tabs/tabs.js +0 -71
  294. package/dist/tabs-ng/tabs-ng.js +0 -194
  295. package/dist/tabs-ng/tabs-ng__template.js +0 -3
  296. package/dist/tag/tag.js +0 -197
  297. package/dist/tags-input/tags-input.js +0 -482
  298. package/dist/tags-input-ng/tags-input-ng.js +0 -93
  299. package/dist/tags-list/tags-list.js +0 -95
  300. package/dist/template-ng/template-ng.js +0 -71
  301. package/dist/text/text.js +0 -36
  302. package/dist/theme-ng/theme-ng.js +0 -45
  303. package/dist/title-ng/title-ng.js +0 -114
  304. package/dist/toggle/toggle.js +0 -78
  305. package/dist/toggle-ng/toggle-ng.js +0 -18
  306. package/dist/tooltip/tooltip.js +0 -209
  307. package/dist/tooltip-ng/tooltip-ng.js +0 -104
  308. package/dist/user-agreement/service.js +0 -412
  309. package/dist/user-agreement/toolbox.eula.js +0 -3
  310. package/dist/user-agreement/user-agreement.js +0 -169
  311. package/dist/user-card/card.js +0 -19
  312. package/dist/user-card/smart-user-card-tooltip.js +0 -114
  313. package/dist/user-card/tooltip.js +0 -95
  314. package/dist/user-card/user-card.js +0 -51
  315. package/dist/user-card-ng/user-card-ng.js +0 -62
@@ -1,1059 +0,0 @@
1
- import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
2
- import 'core-js/modules/web.dom-collections.iterator.js';
3
- import 'core-js/modules/es.string.replace.js';
4
- import { getAbsoluteBaseURL, fixUrl } from '../global/url.js';
5
- import Listeners from '../global/listeners.js';
6
- import HTTP from '../http/http.js';
7
- import promiseWithTimeout from '../global/promise-with-timeout.js';
8
- import AuthStorage from './storage.js';
9
- import AuthResponseParser from './response-parser.js';
10
- import AuthRequestBuilder from './request-builder.js';
11
- import BackgroundFlow from './background-flow.js';
12
- import TokenValidator from './token-validator.js';
13
- import 'es6-error';
14
- import '../storage/storage.js';
15
- import '../storage/storage__local.js';
16
- import '../alert-service/alert-service.js';
17
- import 'react';
18
- import '../global/react-render-adapter.js';
19
- import 'react-dom';
20
- import '../global/get-uid.js';
21
- import '../alert/alert.js';
22
- import 'classnames';
23
- import 'prop-types';
24
- import '@jetbrains/icons/exception';
25
- import '@jetbrains/icons/checkmark';
26
- import '@jetbrains/icons/warning';
27
- import '@jetbrains/icons/close';
28
- import '../icon/icon.js';
29
- import 'util-deprecate';
30
- import '../icon/icon__constants.js';
31
- import '../_helpers/icon.js';
32
- import '../icon/icon__svg.js';
33
- import '../global/memoize.js';
34
- import '../loader-inline/loader-inline.js';
35
- import '../global/theme.js';
36
- import '../global/data-tests.js';
37
- import '../_helpers/inject-styles.js';
38
- import '../global/conic-gradient.js';
39
- import 'conic-gradient';
40
- import '../global/supports-css.js';
41
- import '../global/inject-styles.js';
42
- import '../global/radial-gradient-mask.js';
43
- import '../global/dom.js';
44
- import '../alert/container.js';
45
- import '../storage/storage__fallback.js';
46
- import 'deep-equal';
47
- import 'simply-uuid';
48
-
49
- /* eslint-disable no-magic-numbers */
50
-
51
- const DEFAULT_EXPIRES_TIMEOUT = 40 * 60;
52
- const DEFAULT_BACKGROUND_TIMEOUT = 10 * 1000;
53
- const DEFAULT_BACKEND_CHECK_TIMEOUT = 10 * 1000;
54
- const BACKGROUND_REDIRECT_TIMEOUT = 20 * 1000;
55
- const DEFAULT_WAIT_FOR_REDIRECT_TIMEOUT = 5 * 1000;
56
- /* eslint-enable no-magic-numbers */
57
-
58
- const USER_CHANGED_EVENT = 'userChange';
59
- const DOMAIN_USER_CHANGED_EVENT = 'domainUser';
60
- const LOGOUT_EVENT = 'logout';
61
- const LOGOUT_POSTPONED_EVENT = 'logoutPostponed';
62
- const USER_CHANGE_POSTPONED_EVENT = 'changePostponed';
63
-
64
- function noop() {}
65
-
66
- const DEFAULT_CONFIG = {
67
- cacheCurrentUser: false,
68
- reloadOnUserChange: true,
69
- embeddedLogin: false,
70
- EmbeddedLoginFlow: null,
71
- clientId: '0-0-0-0-0',
72
- redirectUri: getAbsoluteBaseURL(),
73
- redirect: false,
74
- requestCredentials: 'default',
75
- backgroundRefreshTimeout: null,
76
- scope: [],
77
- userFields: ['guest', 'id', 'name', 'login', 'profile/avatar/url'],
78
- cleanHash: true,
79
- onLogout: noop,
80
- onPostponeChangedUser: () => {},
81
- onPostponeLogout: () => {},
82
- enableBackendStatusCheck: true,
83
- backendCheckTimeout: DEFAULT_BACKEND_CHECK_TIMEOUT,
84
- checkBackendIsUp: () => Promise.resolve(null),
85
- onBackendDown: () => {},
86
- defaultExpiresIn: DEFAULT_EXPIRES_TIMEOUT,
87
- waitForRedirectTimeout: DEFAULT_WAIT_FOR_REDIRECT_TIMEOUT,
88
- translations: {
89
- login: 'Log in',
90
- loginTo: 'Log in to %serviceName%',
91
- cancel: 'Cancel',
92
- tryAgainLabel: 'Try again',
93
- postpone: 'Postpone',
94
- youHaveLoggedInAs: 'You have logged in as another user: %userName%',
95
- applyChange: 'Apply change',
96
- backendIsNotAvailable: 'Connection lost',
97
- checkAgain: 'try again',
98
- nothingHappensLink: 'Click here if nothing happens',
99
- errorMessage: 'There may be a problem with your network connection. Make sure that you are online and'
100
- }
101
- };
102
- class Auth {
103
- constructor(config) {
104
- _defineProperty(this, "config", {});
105
-
106
- _defineProperty(this, "listeners", new Listeners());
107
-
108
- _defineProperty(this, "http", null);
109
-
110
- _defineProperty(this, "_service", {});
111
-
112
- _defineProperty(this, "_storage", null);
113
-
114
- _defineProperty(this, "_responseParser", new AuthResponseParser());
115
-
116
- _defineProperty(this, "_requestBuilder", null);
117
-
118
- _defineProperty(this, "_backgroundFlow", null);
119
-
120
- _defineProperty(this, "_embeddedFlow", null);
121
-
122
- _defineProperty(this, "_tokenValidator", null);
123
-
124
- _defineProperty(this, "_postponed", false);
125
-
126
- _defineProperty(this, "_backendCheckPromise", null);
127
-
128
- _defineProperty(this, "_authDialogService", undefined);
129
-
130
- if (!config) {
131
- throw new Error('Config is required');
132
- }
133
-
134
- if (config.serverUri == null) {
135
- throw new Error('\"serverUri\" property is required');
136
- }
137
-
138
- const unsupportedParams = ['redirect_uri', 'request_credentials', 'client_id'].filter(param => config.hasOwnProperty(param));
139
-
140
- if (unsupportedParams.length !== 0) {
141
- throw new Error("The following parameters are no longer supported: ".concat(unsupportedParams.join(', '), ". Please change them from snake_case to camelCase."));
142
- }
143
-
144
- config.userFields = config.userFields || [];
145
- this.config = { ...Auth.DEFAULT_CONFIG,
146
- ...config
147
- };
148
- const {
149
- clientId,
150
- redirect,
151
- redirectUri,
152
- requestCredentials,
153
- scope
154
- } = this.config;
155
- const serverUriLength = this.config.serverUri.length;
156
-
157
- if (serverUriLength > 0 && this.config.serverUri.charAt(serverUriLength - 1) !== '/') {
158
- this.config.serverUri += '/';
159
- }
160
-
161
- this.config.userParams = {
162
- query: {
163
- fields: [...new Set(Auth.DEFAULT_CONFIG.userFields.concat(config.userFields))].join()
164
- }
165
- };
166
-
167
- if (!scope.includes(Auth.DEFAULT_CONFIG.clientId)) {
168
- scope.push(Auth.DEFAULT_CONFIG.clientId);
169
- }
170
-
171
- this._storage = new AuthStorage({
172
- messagePrefix: "".concat(clientId, "-message-"),
173
- stateKeyPrefix: "".concat(clientId, "-states-"),
174
- tokenKey: "".concat(clientId, "-token"),
175
- userKey: "".concat(clientId, "-user-")
176
- });
177
- this._domainStorage = new AuthStorage({
178
- messagePrefix: 'domain-message-'
179
- });
180
- this._requestBuilder = new AuthRequestBuilder({
181
- authorization: this.config.serverUri + Auth.API_PATH + Auth.API_AUTH_PATH,
182
- clientId,
183
- redirect,
184
- redirectUri,
185
- requestCredentials,
186
- scopes: scope
187
- }, this._storage);
188
- let {
189
- backgroundRefreshTimeout
190
- } = this.config;
191
-
192
- if (!backgroundRefreshTimeout) {
193
- backgroundRefreshTimeout = this.config.embeddedLogin ? DEFAULT_BACKGROUND_TIMEOUT : BACKGROUND_REDIRECT_TIMEOUT;
194
- }
195
-
196
- this._backgroundFlow = new BackgroundFlow(this._requestBuilder, this._storage, backgroundRefreshTimeout);
197
-
198
- if (this.config.EmbeddedLoginFlow) {
199
- this._embeddedFlow = new this.config.EmbeddedLoginFlow(this._requestBuilder, this._storage, this.config.translations);
200
- }
201
-
202
- const API_BASE = this.config.serverUri + Auth.API_PATH;
203
- const fetchConfig = config.fetchCredentials ? {
204
- credentials: config.fetchCredentials
205
- } : undefined;
206
- this.http = new HTTP(this, API_BASE, fetchConfig);
207
-
208
- const getUser = async token => {
209
- const user = await this.getUser(token);
210
- this.user = user;
211
- return user;
212
- };
213
-
214
- this._tokenValidator = new TokenValidator(this.config, getUser, this._storage);
215
-
216
- if (this.config.onLogout) {
217
- this.addListener(LOGOUT_EVENT, this.config.onLogout);
218
- }
219
-
220
- if (this.config.reloadOnUserChange === true) {
221
- this.addListener(USER_CHANGED_EVENT, () => this._reloadCurrentPage());
222
- }
223
-
224
- this.addListener(LOGOUT_POSTPONED_EVENT, () => this._setPostponed(true));
225
- this.addListener(USER_CHANGE_POSTPONED_EVENT, () => this._setPostponed(true));
226
- this.addListener(USER_CHANGED_EVENT, () => this._setPostponed(false));
227
- this.addListener(USER_CHANGED_EVENT, user => user && this._updateDomainUser(user.id));
228
-
229
- if (this.config.cacheCurrentUser) {
230
- this.addListener(LOGOUT_EVENT, () => this._storage.wipeCachedCurrentUser());
231
- this.addListener(USER_CHANGED_EVENT, () => this._storage.onUserChanged());
232
- }
233
-
234
- this._createInitDeferred();
235
-
236
- this.setUpPreconnect(config.serverUri);
237
- }
238
-
239
- _setPostponed() {
240
- let postponed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
241
- this._postponed = postponed;
242
- }
243
-
244
- _updateDomainUser(userID) {
245
- this._domainStorage.sendMessage(DOMAIN_USER_CHANGED_EVENT, {
246
- userID,
247
- serviceID: this.config.clientId
248
- });
249
- }
250
-
251
- addListener(event, handler) {
252
- this.listeners.add(event, handler);
253
- }
254
-
255
- removeListener(event, handler) {
256
- this.listeners.remove(event, handler);
257
- }
258
-
259
- setAuthDialogService(authDialogService) {
260
- this._authDialogService = authDialogService;
261
- }
262
-
263
- setCurrentService(service) {
264
- this._service = service;
265
- }
266
-
267
- _createInitDeferred() {
268
- this._initDeferred = {};
269
- this._initDeferred.promise = new Promise((resolve, reject) => {
270
- this._initDeferred.resolve = resolve;
271
- this._initDeferred.reject = reject;
272
- });
273
- }
274
- /**
275
- * @return {Promise.<string>} absolute URL promise that is resolved to a URL
276
- * that should be restored after returning back from auth server.
277
- */
278
-
279
-
280
- async init() {
281
- this._storage.onTokenChange(async token => {
282
- const isGuest = this.user ? this.user.guest : false;
283
-
284
- if (isGuest && !token) {
285
- return;
286
- }
287
-
288
- if (!token) {
289
- this.logout();
290
- } else {
291
- try {
292
- await this._detectUserChange(token.accessToken);
293
- } catch (error) {
294
- if (this._canShowDialogs()) {
295
- this._showAuthDialog({
296
- nonInteractive: true,
297
- error
298
- });
299
- }
300
- }
301
- }
302
- });
303
-
304
- this._domainStorage.onMessage(DOMAIN_USER_CHANGED_EVENT, _ref => {
305
- let {
306
- userID,
307
- serviceID
308
- } = _ref;
309
-
310
- if (serviceID === this.config.clientId) {
311
- return;
312
- }
313
-
314
- if (this.user && userID === this.user.id) {
315
- return;
316
- }
317
-
318
- this.forceTokenUpdate();
319
- });
320
-
321
- let state;
322
-
323
- try {
324
- // Look for token or error in hash
325
- state = await this._checkForAuthResponse();
326
- } catch (error) {
327
- return this.handleInitError(error);
328
- } // Return endless promise in the background to avoid service start
329
-
330
-
331
- if (state && state.nonRedirect) {
332
- return new Promise(noop);
333
- }
334
-
335
- try {
336
- var _state;
337
-
338
- // Check if there is a valid token
339
- await this._tokenValidator.validateToken(); // Checking if there is a message left by another app on this domain
340
-
341
- const message = await this._domainStorage._messagesStorage.get("domain-message-".concat(DOMAIN_USER_CHANGED_EVENT));
342
-
343
- if (message) {
344
- const {
345
- userID,
346
- serviceID
347
- } = message;
348
-
349
- if (serviceID !== this.config.clientId && (!userID || this.user.id !== userID)) {
350
- this.forceTokenUpdate();
351
- }
352
- } // Access token appears to be valid.
353
- // We may resolve restoreLocation URL now
354
-
355
-
356
- if (!state) {
357
- // Check if we have requested to restore state anyway
358
- state = await this._checkForStateRestoration();
359
- }
360
-
361
- this._initDeferred.resolve(state && state.restoreLocation);
362
-
363
- return (_state = state) === null || _state === void 0 ? void 0 : _state.restoreLocation;
364
- } catch (error) {
365
- if (Auth.storageIsUnavailable) {
366
- this._initDeferred.resolve(); // No way to handle if cookies are disabled
367
-
368
-
369
- await this.requestUser(); // Someone may expect user to be loaded as a part of token validation
370
-
371
- return null;
372
- }
373
-
374
- return this.handleInitValidationError(error);
375
- }
376
- }
377
-
378
- async sendRedirect(error) {
379
- const authRequest = await this._requestBuilder.prepareAuthRequest();
380
-
381
- this._redirectCurrentPage(authRequest.url); // HUB-10867 Since we already redirecting the page, there is no actual need to throw an error
382
- // and scare user with flashing error
383
- // But let's keep it just in case redirect was not successful
384
-
385
-
386
- await new Promise(resolve => setTimeout(resolve, this.config.waitForRedirectTimeout));
387
- throw error;
388
- }
389
-
390
- async handleInitError(error) {
391
- if (error.stateId) {
392
- try {
393
- const state = await this._storage.getState(error.stateId);
394
-
395
- if (state && state.nonRedirect) {
396
- state.error = error;
397
-
398
- this._storage.saveState(error.stateId, state); // Return endless promise in the background to avoid service start
399
-
400
-
401
- return new Promise(noop);
402
- }
403
- } catch (e) {// Throw the orginal error instead below
404
- }
405
- }
406
-
407
- throw error;
408
- }
409
-
410
- async handleInitValidationError(error) {
411
- // Redirect flow
412
- if (error.authRedirect && this.config.redirect) {
413
- return this.sendRedirect(error);
414
- } // Background flow
415
-
416
-
417
- if (error.authRedirect && !this.config.redirect) {
418
- try {
419
- await this._backgroundFlow.authorize();
420
- await this._tokenValidator.validateToken();
421
-
422
- this._initDeferred.resolve();
423
-
424
- return undefined;
425
- } catch (validationError) {
426
- // Fallback to redirect flow
427
- return this.sendRedirect(validationError);
428
- }
429
- }
430
-
431
- this._initDeferred.reject(error);
432
-
433
- throw error;
434
- }
435
- /**
436
- * Get token from local storage or request it if necessary.
437
- * Can redirect to login page.
438
- * @return {Promise.<string>}
439
- */
440
-
441
-
442
- async requestToken() {
443
- if (this._postponed) {
444
- throw new Error('You should log in to be able to make requests');
445
- }
446
-
447
- try {
448
- await this._initDeferred.promise;
449
-
450
- if (Auth.storageIsUnavailable) {
451
- return null; // Forever guest if storage is unavailable
452
- }
453
-
454
- return await this._tokenValidator.validateTokenLocally();
455
- } catch (e) {
456
- return this.forceTokenUpdate();
457
- }
458
- }
459
- /**
460
- * Get new token in the background or redirect to the login page.
461
- * @return {Promise.<string>}
462
- */
463
-
464
-
465
- async forceTokenUpdate() {
466
- try {
467
- if (!this._backendCheckPromise) {
468
- this._backendCheckPromise = this._checkBackendsStatusesIfEnabled();
469
- }
470
-
471
- await this._backendCheckPromise;
472
- } catch (e) {
473
- throw new Error('Cannot refresh token: backend is not available. Postponed by user.');
474
- } finally {
475
- this._backendCheckPromise = null;
476
- }
477
-
478
- try {
479
- return await this._backgroundFlow.authorize();
480
- } catch (error) {
481
- if (this._canShowDialogs()) {
482
- return new Promise(resolve => {
483
- const onTryAgain = async () => {
484
- try {
485
- const result = await this._backgroundFlow.authorize();
486
- resolve(result);
487
- } catch (retryError) {
488
- this._showAuthDialog({
489
- nonInteractive: true,
490
- error: retryError,
491
- onTryAgain
492
- });
493
-
494
- throw retryError;
495
- }
496
- };
497
-
498
- this._showAuthDialog({
499
- nonInteractive: true,
500
- error,
501
- onTryAgain
502
- });
503
- });
504
- } else {
505
- const authRequest = await this._requestBuilder.prepareAuthRequest();
506
-
507
- this._redirectCurrentPage(authRequest.url);
508
- }
509
-
510
- throw new TokenValidator.TokenValidationError(error.message);
511
- }
512
- }
513
-
514
- async loadCurrentService() {
515
- if (this._service.serviceName) {
516
- return;
517
- }
518
-
519
- try {
520
- const {
521
- serviceName,
522
- iconUrl: serviceImage
523
- } = (await this.http.get("oauth2/interactive/login/settings?client_id=".concat(this.config.clientId))) || {};
524
- this.setCurrentService({
525
- serviceImage,
526
- serviceName
527
- });
528
- } catch (e) {// noop
529
- }
530
- }
531
-
532
- getAPIPath() {
533
- return this.config.serverUri + Auth.API_PATH;
534
- }
535
- /**
536
- * @return {Promise.<object>}
537
- */
538
-
539
-
540
- getUser(accessToken) {
541
- if (this.config.cacheCurrentUser) {
542
- return this._storage.getCachedUser(() => this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams));
543
- } else {
544
- return this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams);
545
- }
546
- }
547
- /**
548
- * @return {Promise.<object>}
549
- */
550
-
551
-
552
- async requestUser() {
553
- if (this.user) {
554
- return this.user;
555
- }
556
-
557
- const accessToken = await this.requestToken(); // If user was fetched during token request
558
-
559
- if (this.user) {
560
- return this.user;
561
- }
562
-
563
- const user = await this.getUser(accessToken);
564
- this.user = user;
565
- return user;
566
- }
567
-
568
- async updateUser() {
569
- this._setPostponed(false);
570
-
571
- const accessToken = await this.requestToken();
572
-
573
- this._storage.wipeCachedCurrentUser();
574
-
575
- const user = await this.getUser(accessToken);
576
- this.user = user;
577
- this.listeners.trigger(USER_CHANGED_EVENT, user);
578
- }
579
-
580
- async _detectUserChange(accessToken) {
581
- const windowWasOpen = this._isLoginWindowOpen;
582
- const user = await this.getUser(accessToken);
583
-
584
- const onApply = () => {
585
- this.user = user;
586
- this.listeners.trigger(USER_CHANGED_EVENT, user);
587
- };
588
-
589
- if (user && this.user && this.user.id !== user.id) {
590
- if (!this._canShowDialogs() || this.user.guest || windowWasOpen) {
591
- onApply();
592
- return;
593
- }
594
-
595
- if (user.guest) {
596
- this._showAuthDialog({
597
- nonInteractive: true
598
- });
599
-
600
- return;
601
- }
602
-
603
- await this._showUserChangedDialog({
604
- newUser: user,
605
- onApply,
606
- onPostpone: () => {
607
- this.listeners.trigger(USER_CHANGE_POSTPONED_EVENT);
608
- this.config.onPostponeChangedUser(this.user, user);
609
- }
610
- });
611
- }
612
- }
613
-
614
- _beforeLogout(params) {
615
- if (this._canShowDialogs()) {
616
- this._showAuthDialog(params);
617
-
618
- return;
619
- }
620
-
621
- this.logout();
622
- }
623
-
624
- _showAuthDialog() {
625
- let {
626
- nonInteractive,
627
- error,
628
- canCancel,
629
- onTryAgain
630
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
631
- const {
632
- embeddedLogin,
633
- onPostponeLogout,
634
- translations
635
- } = this.config;
636
- const cancelable = this.user.guest || canCancel;
637
-
638
- this._createInitDeferred();
639
-
640
- const closeDialog = () => {
641
- /* eslint-disable no-use-before-define */
642
- stopTokenListening();
643
- stopMessageListening();
644
- hide();
645
- /* eslint-enable no-use-before-define */
646
- };
647
-
648
- const onConfirm = () => {
649
- if (embeddedLogin !== true) {
650
- closeDialog();
651
- this.logout();
652
- return;
653
- }
654
-
655
- this._runEmbeddedLogin();
656
- };
657
-
658
- const onCancel = () => {
659
- this._embeddedFlow.stop();
660
-
661
- this._storage.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
662
-
663
- closeDialog();
664
-
665
- if (!cancelable) {
666
- this._initDeferred.resolve();
667
-
668
- this.listeners.trigger(LOGOUT_POSTPONED_EVENT);
669
- onPostponeLogout();
670
- return;
671
- }
672
-
673
- if (this.user.guest && nonInteractive) {
674
- this.forceTokenUpdate();
675
- } else {
676
- this._initDeferred.resolve();
677
- }
678
- };
679
-
680
- const onTryAgainClick = async () => {
681
- await onTryAgain();
682
- closeDialog();
683
- };
684
-
685
- const hide = this._authDialogService({ ...this._service,
686
- loginCaption: translations.login,
687
- loginToCaption: translations.loginTo,
688
- confirmLabel: translations.login,
689
- tryAgainLabel: translations.tryAgainLabel,
690
- cancelLabel: cancelable ? translations.cancel : translations.postpone,
691
- errorMessage: this._extractErrorMessage(error, true),
692
- onConfirm,
693
- onCancel,
694
- onTryAgain: onTryAgain ? onTryAgainClick : null
695
- });
696
-
697
- const stopTokenListening = this._storage.onTokenChange(token => {
698
- if (token) {
699
- closeDialog();
700
-
701
- this._initDeferred.resolve();
702
- }
703
- });
704
-
705
- const stopMessageListening = this._storage.onMessage(Auth.CLOSE_WINDOW_MESSAGE, () => this._embeddedFlow.stop());
706
- }
707
-
708
- _showUserChangedDialog() {
709
- let {
710
- newUser,
711
- onApply,
712
- onPostpone
713
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
714
- const {
715
- translations
716
- } = this.config;
717
-
718
- this._createInitDeferred();
719
-
720
- const done = () => {
721
- this._initDeferred.resolve(); // eslint-disable-next-line no-use-before-define
722
-
723
-
724
- hide();
725
- };
726
-
727
- const hide = this._authDialogService({ ...this._service,
728
- title: translations.youHaveLoggedInAs.replace('%userName%', newUser.name),
729
- loginCaption: translations.login,
730
- loginToCaption: translations.loginTo,
731
- confirmLabel: translations.applyChange,
732
- cancelLabel: translations.postpone,
733
- onConfirm: () => {
734
- done();
735
- onApply();
736
- },
737
- onCancel: () => {
738
- done();
739
- onPostpone();
740
- }
741
- });
742
- }
743
-
744
- _extractErrorMessage(error) {
745
- let logError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
746
-
747
- if (!error) {
748
- return null;
749
- }
750
-
751
- if (logError) {
752
- // eslint-disable-next-line no-console
753
- console.error('RingUI Auth error', error);
754
- }
755
-
756
- try {
757
- // We've got some error from this list
758
- // https://www.jetbrains.com/help/youtrack/devportal/OAuth-2.0-Errors.html
759
- if (error.code && typeof error.code.code === 'string') {
760
- const readableCode = error.code.code.split('_').join(' ');
761
- return "Authorization error: ".concat(readableCode);
762
- }
763
- } catch {// noop
764
- }
765
-
766
- return error.toString ? error.toString() : null;
767
- }
768
-
769
- _showBackendDownDialog(backendError) {
770
- const {
771
- onBackendDown,
772
- translations
773
- } = this.config;
774
- const REPEAT_TIMEOUT = 5000;
775
- let timerId = null;
776
- return new Promise((resolve, reject) => {
777
- const done = () => {
778
- /* eslint-disable no-use-before-define */
779
- hide();
780
- window.removeEventListener('online', onCheckAgain);
781
- stopListeningCloseMessage();
782
- /* eslint-enable no-use-before-define */
783
-
784
- this._storage.sendMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, Date.now());
785
-
786
- this._awaitingForBackendPromise = null;
787
- clearTimeout(timerId);
788
- };
789
-
790
- const stopListeningCloseMessage = this._storage.onMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, () => {
791
- stopListeningCloseMessage();
792
- done();
793
- resolve();
794
- });
795
-
796
- const onCheckAgain = async () => {
797
- await this._checkBackendsAreUp();
798
- done();
799
- resolve();
800
- };
801
-
802
- const onPostpone = () => {
803
- done();
804
- reject(new Error('Auth(@jetbrains/ring-ui): postponed by user'));
805
- };
806
-
807
- const hide = onBackendDown({
808
- onCheckAgain,
809
- onPostpone,
810
- backendError,
811
- translations
812
- });
813
- window.addEventListener('online', onCheckAgain);
814
-
815
- function networkWatchdog() {
816
- if (navigator && navigator.onLine) {
817
- onCheckAgain();
818
- }
819
-
820
- timerId = setTimeout(networkWatchdog, REPEAT_TIMEOUT);
821
- }
822
-
823
- timerId = setTimeout(networkWatchdog, REPEAT_TIMEOUT);
824
- });
825
- }
826
- /**
827
- * Wipe accessToken and redirect to auth page with required authorization
828
- */
829
-
830
-
831
- async logout(extraParams) {
832
- const requestParams = {
833
- // eslint-disable-next-line camelcase
834
- request_credentials: 'required',
835
- ...extraParams
836
- };
837
- await this._checkBackendsStatusesIfEnabled();
838
- await this.listeners.trigger(LOGOUT_EVENT);
839
-
840
- this._updateDomainUser(null);
841
-
842
- await this._storage.wipeToken();
843
- const authRequest = await this._requestBuilder.prepareAuthRequest(requestParams);
844
-
845
- this._redirectCurrentPage(authRequest.url);
846
- }
847
-
848
- async _runEmbeddedLogin() {
849
- this._storage.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
850
-
851
- try {
852
- this._isLoginWindowOpen = true;
853
- return await this._embeddedFlow.authorize();
854
- } catch (e) {
855
- throw e;
856
- } finally {
857
- this._isLoginWindowOpen = false;
858
- }
859
- }
860
- /**
861
- * Wipe accessToken and redirect to auth page to obtain authorization data
862
- * if user is logged in or log her in otherwise
863
- */
864
-
865
-
866
- async login() {
867
- if (this.config.embeddedLogin) {
868
- await this._runEmbeddedLogin();
869
- return;
870
- }
871
-
872
- await this._checkBackendsStatusesIfEnabled();
873
-
874
- try {
875
- const accessToken = await this._backgroundFlow.authorize();
876
- const user = await this.getUser(accessToken);
877
-
878
- if (user.guest) {
879
- this._beforeLogout();
880
- } else {
881
- this.user = user;
882
- this.listeners.trigger(USER_CHANGED_EVENT, user);
883
- }
884
- } catch (e) {
885
- this._beforeLogout();
886
- }
887
- }
888
-
889
- async switchUser() {
890
- if (!this.config.embeddedLogin) {
891
- throw new Error('Auth: switchUser only supported for "embeddedLogin" mode');
892
- }
893
-
894
- await this._runEmbeddedLogin();
895
- }
896
- /**
897
- * Check if the hash contains an access token.
898
- * If it does, extract the state, compare with
899
- * config, and store the auth response for later use.
900
- *
901
- * @return {Promise} promise that is resolved to restoreLocation URL, or rejected
902
- * @private
903
- */
904
-
905
-
906
- async _checkForAuthResponse() {
907
- // getAuthResponseURL may throw an exception
908
- const authResponse = this._responseParser.getAuthResponseFromURL();
909
-
910
- const {
911
- scope: defaultScope,
912
- defaultExpiresIn,
913
- cleanHash
914
- } = this.config;
915
-
916
- if (authResponse && cleanHash) {
917
- this.setHash('');
918
- }
919
-
920
- if (!authResponse) {
921
- return undefined;
922
- }
923
-
924
- const {
925
- state: stateId,
926
- scope,
927
- expiresIn,
928
- accessToken
929
- } = authResponse;
930
- const newState = (await (stateId && this._storage.getState(stateId))) || {};
931
- const scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
932
- const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
933
- const expires = TokenValidator._epoch() + effectiveExpiresIn;
934
- await this._storage.saveToken({
935
- accessToken,
936
- scopes,
937
- expires,
938
- lifeTime: effectiveExpiresIn
939
- });
940
- return newState;
941
- }
942
-
943
- async _checkForStateRestoration() {
944
- const authResponse = this._responseParser._authResponse;
945
-
946
- if (authResponse && this.config.cleanHash) {
947
- this.setHash('');
948
- }
949
-
950
- const stateId = authResponse === null || authResponse === void 0 ? void 0 : authResponse.restoreAuthState;
951
- return (await (stateId && this._storage.getState(stateId))) || {};
952
- }
953
-
954
- _checkBackendsAreUp() {
955
- const abortCtrl = new AbortController();
956
- const {
957
- backendCheckTimeout
958
- } = this.config;
959
- return Promise.all([promiseWithTimeout(this.http.fetch('settings/public?fields=id', {
960
- signal: abortCtrl.signal
961
- }), backendCheckTimeout, {
962
- error: new Error('The authorization server is taking too long to respond. Please try again later.'),
963
- onTimeout: () => abortCtrl.abort()
964
- }), this.config.checkBackendIsUp()]).catch(err => {
965
- if (err instanceof TypeError) {
966
- throw new TypeError('Could not connect to the server due to network error. Please check your connection and try again.');
967
- }
968
-
969
- throw err;
970
- });
971
- }
972
-
973
- async _checkBackendsStatusesIfEnabled() {
974
- if (!this.config.enableBackendStatusCheck) {
975
- return;
976
- }
977
-
978
- try {
979
- await this._checkBackendsAreUp();
980
- } catch (backendDownErr) {
981
- await this._showBackendDownDialog(backendDownErr);
982
- }
983
- }
984
- /**
985
- * Adds preconnect tag to help browser to establish connection to URL.
986
- * See https://w3c.github.io/resource-hints/
987
- * @param url Url to preconnect to.
988
- */
989
-
990
-
991
- setUpPreconnect(url) {
992
- const linkNode = document.createElement('link');
993
- linkNode.rel = 'preconnect';
994
- linkNode.href = url;
995
- linkNode.pr = '1.0';
996
- linkNode.crossorigin = 'use-credentials';
997
- document.head.appendChild(linkNode);
998
- }
999
- /**
1000
- * Redirects current page to the given URL
1001
- * @param {string} url
1002
- * @private
1003
- */
1004
-
1005
-
1006
- _redirectCurrentPage(url) {
1007
- window.location = fixUrl(url);
1008
- }
1009
- /**
1010
- * Reloads current page
1011
- */
1012
-
1013
-
1014
- _reloadCurrentPage() {
1015
- this._redirectCurrentPage(window.location.href);
1016
- }
1017
-
1018
- _canShowDialogs() {
1019
- return this.config.embeddedLogin && this._authDialogService;
1020
- }
1021
- /**
1022
- * Sets the location hash
1023
- * @param {string} hash
1024
- */
1025
-
1026
-
1027
- setHash(hash) {
1028
- if (history.replaceState) {
1029
- // NB! History.replaceState is used here, because Firefox saves
1030
- // a record in history.
1031
- // NB! URL to redirect is formed manually because baseURI could be messed up,
1032
- // in which case it's not obvious where redirect will lead.
1033
- const cleanedUrl = [window.location.pathname, window.location.search].join('');
1034
- const hashIfExist = hash ? "#".concat(hash) : '';
1035
- history.replaceState(undefined, undefined, "".concat(cleanedUrl).concat(hashIfExist));
1036
- } else {
1037
- window.location.hash = hash;
1038
- }
1039
- }
1040
-
1041
- }
1042
-
1043
- _defineProperty(Auth, "DEFAULT_CONFIG", DEFAULT_CONFIG);
1044
-
1045
- _defineProperty(Auth, "API_PATH", 'api/rest/');
1046
-
1047
- _defineProperty(Auth, "API_AUTH_PATH", 'oauth2/auth');
1048
-
1049
- _defineProperty(Auth, "API_PROFILE_PATH", 'users/me');
1050
-
1051
- _defineProperty(Auth, "CLOSE_BACKEND_DOWN_MESSAGE", 'backend-check-succeeded');
1052
-
1053
- _defineProperty(Auth, "CLOSE_WINDOW_MESSAGE", 'close-login-window');
1054
-
1055
- _defineProperty(Auth, "shouldRefreshToken", TokenValidator.shouldRefreshToken);
1056
-
1057
- _defineProperty(Auth, "storageIsUnavailable", !navigator.cookieEnabled);
1058
-
1059
- export { DEFAULT_BACKGROUND_TIMEOUT, DEFAULT_EXPIRES_TIMEOUT, DOMAIN_USER_CHANGED_EVENT, LOGOUT_EVENT, LOGOUT_POSTPONED_EVENT, USER_CHANGED_EVENT, USER_CHANGE_POSTPONED_EVENT, Auth as default };