@jetbrains/ring-ui 6.0.4-beta.0 → 6.0.4

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 (552) hide show
  1. package/README.md +10 -6
  2. package/components/alert/alert.css +12 -13
  3. package/components/alert/container.css +4 -6
  4. package/components/alert-service/alert-service.stories.css +0 -3
  5. package/components/auth/down-notification.css +2 -4
  6. package/components/auth/request-builder.d.ts +1 -0
  7. package/components/auth-dialog/auth-dialog.css +10 -12
  8. package/components/badge/badge.css +1 -3
  9. package/components/button/button.css +13 -14
  10. package/components/button-group/button-group.css +6 -5
  11. package/components/button-set/button-set.css +1 -2
  12. package/components/button-toolbar/button-toolbar.css +1 -2
  13. package/components/checkbox/checkbox.css +3 -4
  14. package/components/code/code.css +3 -5
  15. package/components/code/code.d.ts +1 -0
  16. package/components/collapse/collapse-content.d.ts +11 -0
  17. package/components/collapse/collapse-content.js +72 -0
  18. package/components/collapse/collapse-context.d.ts +10 -0
  19. package/components/collapse/collapse-context.js +10 -0
  20. package/components/collapse/collapse-control.d.ts +11 -0
  21. package/components/collapse/collapse-control.js +22 -0
  22. package/components/collapse/collapse.css +40 -0
  23. package/components/collapse/collapse.d.ts +12 -0
  24. package/components/collapse/collapse.js +26 -0
  25. package/components/collapse/collapse.stories.css +25 -0
  26. package/components/collapse/consts.d.ts +4 -0
  27. package/components/collapse/consts.js +4 -0
  28. package/components/collapse/utils.d.ts +1 -0
  29. package/components/collapse/utils.js +1 -0
  30. package/components/confirm/confirm.css +1 -3
  31. package/components/content-layout/content-layout.css +7 -7
  32. package/components/data-list/data-list.css +4 -5
  33. package/components/date-picker/consts.js +1 -1
  34. package/components/date-picker/date-picker.css +40 -41
  35. package/components/date-picker/date-picker.js +7 -7
  36. package/components/date-picker/date-popup.js +4 -4
  37. package/components/date-picker/day.js +9 -9
  38. package/components/date-picker/month-names.js +6 -6
  39. package/components/date-picker/month-slider.js +3 -3
  40. package/components/date-picker/month.js +5 -5
  41. package/components/date-picker/months.js +6 -6
  42. package/components/date-picker/weekdays.js +4 -4
  43. package/components/date-picker/years.js +8 -8
  44. package/components/dialog/dialog.css +12 -13
  45. package/components/editable-heading/editable-heading.css +25 -20
  46. package/components/editable-heading/editable-heading.d.ts +1 -1
  47. package/components/editable-heading/editable-heading.js +42 -27
  48. package/components/error-bubble/error-bubble-legacy.css +6 -8
  49. package/components/error-bubble/error-bubble.css +6 -8
  50. package/components/footer/footer.css +6 -8
  51. package/components/form/form.css +31 -33
  52. package/components/global/global.css +1 -7
  53. package/components/global/variables_dark.css +2 -2
  54. package/components/grid/grid.css +6 -6
  55. package/components/grid/row.js +3 -3
  56. package/components/group/group.css +1 -3
  57. package/components/header/header.css +12 -14
  58. package/components/header/profile.js +1 -1
  59. package/components/header/services.css +12 -14
  60. package/components/icon/icon.css +2 -4
  61. package/components/input/input-legacy.css +2 -4
  62. package/components/input/input.css +8 -10
  63. package/components/input-size/input-size.css +4 -6
  64. package/components/island/header.js +1 -1
  65. package/components/island/island.css +6 -7
  66. package/components/island-legacy/island-legacy.css +6 -8
  67. package/components/line/line.css +1 -3
  68. package/components/link/link.css +1 -1
  69. package/components/link/link.d.ts +2 -2
  70. package/components/link/link.js +1 -1
  71. package/components/list/list.css +17 -20
  72. package/components/list/list.d.ts +0 -1
  73. package/components/list/list.js +5 -6
  74. package/components/loader/loader.css +1 -3
  75. package/components/loader/loader__core.js +6 -6
  76. package/components/loader-inline/loader-inline.css +5 -6
  77. package/components/login-dialog/login-dialog.css +1 -3
  78. package/components/markdown/markdown.css +2 -3
  79. package/components/message/message.css +5 -8
  80. package/components/old-browsers-message/old-browsers-message.css +2 -4
  81. package/components/pager/pager.css +2 -4
  82. package/components/panel/panel.css +3 -5
  83. package/components/popup/popup.js +3 -3
  84. package/components/progress-bar/progress-bar.css +9 -4
  85. package/components/progress-bar/progress-bar.d.ts +6 -0
  86. package/components/progress-bar/progress-bar.js +9 -3
  87. package/components/query-assist/query-assist.css +3 -4
  88. package/components/query-assist/query-assist.js +1 -1
  89. package/components/radio/radio.css +7 -10
  90. package/components/select/select-popup.css +13 -11
  91. package/components/select/select.css +13 -14
  92. package/components/select/select.js +21 -21
  93. package/components/sidebar/sidebar.css +13 -15
  94. package/components/table/table.css +15 -17
  95. package/components/table-legacy/table-legacy.css +22 -24
  96. package/components/table-legacy/table-legacy__toolbar.css +2 -4
  97. package/components/tabs/tabs.css +3 -4
  98. package/components/tag/tag.css +12 -13
  99. package/components/tags-input/tags-input.css +1 -2
  100. package/components/toggle/toggle.css +21 -22
  101. package/components/tooltip/tooltip.css +3 -5
  102. package/components/user-agreement/user-agreement.css +2 -2
  103. package/components/user-card/user-card.css +3 -5
  104. package/package.json +74 -77
  105. package/typings.d.ts +0 -54
  106. package/webpack.config.js +1 -24
  107. package/components/auth/landing-entry.d.ts +0 -3
  108. package/components/auth/landing-entry.js +0 -2
  109. package/components/auth/landing.d.ts +0 -2
  110. package/components/auth/landing.html +0 -12
  111. package/components/auth/landing.js +0 -26
  112. package/dist/_helpers/_rollupPluginBabelHelpers.js +0 -648
  113. package/dist/_helpers/anchor.js +0 -31
  114. package/dist/_helpers/badge.js +0 -3
  115. package/dist/_helpers/button__classes.js +0 -34
  116. package/dist/_helpers/caption.js +0 -31
  117. package/dist/_helpers/card.js +0 -132
  118. package/dist/_helpers/date-picker.js +0 -3
  119. package/dist/_helpers/dialog__body-scroll-preventer.js +0 -54
  120. package/dist/_helpers/grid.js +0 -3
  121. package/dist/_helpers/header.js +0 -3
  122. package/dist/_helpers/heading.js +0 -3
  123. package/dist/_helpers/icon__svg.js +0 -75
  124. package/dist/_helpers/input.js +0 -235
  125. package/dist/_helpers/island.js +0 -3
  126. package/dist/_helpers/link.js +0 -3
  127. package/dist/_helpers/list.js +0 -3
  128. package/dist/_helpers/query-assist__suggestions.js +0 -102
  129. package/dist/_helpers/select__filter.js +0 -94
  130. package/dist/_helpers/services-link.js +0 -48
  131. package/dist/_helpers/sidebar.js +0 -123
  132. package/dist/_helpers/tab-link.js +0 -34
  133. package/dist/_helpers/table.js +0 -3
  134. package/dist/_helpers/theme.js +0 -95
  135. package/dist/_helpers/title.js +0 -103
  136. package/dist/alert/alert.d.ts +0 -113
  137. package/dist/alert/alert.js +0 -292
  138. package/dist/alert/container.d.ts +0 -15
  139. package/dist/alert/container.js +0 -52
  140. package/dist/alert-service/alert-service.d.ts +0 -36
  141. package/dist/alert-service/alert-service.js +0 -218
  142. package/dist/analytics/analytics.d.ts +0 -18
  143. package/dist/analytics/analytics.js +0 -31
  144. package/dist/analytics/analytics__custom-plugin.d.ts +0 -28
  145. package/dist/analytics/analytics__custom-plugin.js +0 -90
  146. package/dist/auth/auth.d.ts +0 -3
  147. package/dist/auth/auth.js +0 -130
  148. package/dist/auth/auth__core.d.ts +0 -236
  149. package/dist/auth/auth__core.js +0 -1650
  150. package/dist/auth/background-flow.d.ts +0 -31
  151. package/dist/auth/background-flow.js +0 -146
  152. package/dist/auth/down-notification.d.ts +0 -15
  153. package/dist/auth/down-notification.js +0 -155
  154. package/dist/auth/iframe-flow.d.ts +0 -20
  155. package/dist/auth/iframe-flow.js +0 -192
  156. package/dist/auth/landing-entry.d.ts +0 -3
  157. package/dist/auth/landing-entry.js +0 -5
  158. package/dist/auth/landing.d.ts +0 -2
  159. package/dist/auth/landing.js +0 -152
  160. package/dist/auth/request-builder.d.ts +0 -47
  161. package/dist/auth/request-builder.js +0 -101
  162. package/dist/auth/response-parser.d.ts +0 -70
  163. package/dist/auth/response-parser.js +0 -137
  164. package/dist/auth/storage.d.ts +0 -112
  165. package/dist/auth/storage.js +0 -422
  166. package/dist/auth/token-validator.d.ts +0 -93
  167. package/dist/auth/token-validator.js +0 -267
  168. package/dist/auth/window-flow.d.ts +0 -26
  169. package/dist/auth/window-flow.js +0 -153
  170. package/dist/auth-dialog/auth-dialog.d.ts +0 -60
  171. package/dist/auth-dialog/auth-dialog.js +0 -219
  172. package/dist/auth-dialog-service/auth-dialog-service.d.ts +0 -6
  173. package/dist/auth-dialog-service/auth-dialog-service.js +0 -90
  174. package/dist/avatar/avatar-example-datauri.d.ts +0 -1
  175. package/dist/avatar/avatar-example-datauri.js +0 -4
  176. package/dist/avatar/avatar.d.ts +0 -52
  177. package/dist/avatar/avatar.js +0 -180
  178. package/dist/avatar/fallback-avatar.d.ts +0 -17
  179. package/dist/avatar/fallback-avatar.js +0 -150
  180. package/dist/badge/badge.d.ts +0 -24
  181. package/dist/badge/badge.js +0 -59
  182. package/dist/button/button.d.ts +0 -67
  183. package/dist/button/button.js +0 -131
  184. package/dist/button/button__classes.d.ts +0 -2
  185. package/dist/button/button__classes.js +0 -2
  186. package/dist/button-group/button-group.d.ts +0 -18
  187. package/dist/button-group/button-group.js +0 -48
  188. package/dist/button-group/caption.d.ts +0 -8
  189. package/dist/button-group/caption.js +0 -5
  190. package/dist/button-set/button-set.d.ts +0 -16
  191. package/dist/button-set/button-set.js +0 -47
  192. package/dist/button-toolbar/button-toolbar.d.ts +0 -16
  193. package/dist/button-toolbar/button-toolbar.js +0 -46
  194. package/dist/caret/caret.d.ts +0 -66
  195. package/dist/caret/caret.js +0 -258
  196. package/dist/checkbox/checkbox.d.ts +0 -45
  197. package/dist/checkbox/checkbox.js +0 -130
  198. package/dist/clipboard/clipboard-fallback.d.ts +0 -2
  199. package/dist/clipboard/clipboard-fallback.js +0 -42
  200. package/dist/clipboard/clipboard.d.ts +0 -5
  201. package/dist/clipboard/clipboard.js +0 -183
  202. package/dist/code/code.d.ts +0 -43
  203. package/dist/code/code.js +0 -192
  204. package/dist/confirm/confirm.d.ts +0 -48
  205. package/dist/confirm/confirm.js +0 -151
  206. package/dist/confirm-service/confirm-service.d.ts +0 -21
  207. package/dist/confirm-service/confirm-service.js +0 -139
  208. package/dist/content-layout/content-layout.d.ts +0 -26
  209. package/dist/content-layout/content-layout.js +0 -79
  210. package/dist/content-layout/sidebar.d.ts +0 -31
  211. package/dist/content-layout/sidebar.js +0 -7
  212. package/dist/contenteditable/contenteditable.d.ts +0 -47
  213. package/dist/contenteditable/contenteditable.js +0 -84
  214. package/dist/control-label/control-label.d.ts +0 -11
  215. package/dist/control-label/control-label.js +0 -36
  216. package/dist/data-list/data-list.d.ts +0 -85
  217. package/dist/data-list/data-list.js +0 -246
  218. package/dist/data-list/data-list.mock.d.ts +0 -16
  219. package/dist/data-list/data-list.mock.js +0 -192
  220. package/dist/data-list/item.d.ts +0 -50
  221. package/dist/data-list/item.js +0 -234
  222. package/dist/data-list/selection.d.ts +0 -16
  223. package/dist/data-list/selection.js +0 -146
  224. package/dist/data-list/title.d.ts +0 -26
  225. package/dist/data-list/title.js +0 -28
  226. package/dist/date-picker/consts.d.ts +0 -98
  227. package/dist/date-picker/consts.js +0 -46
  228. package/dist/date-picker/date-input.d.ts +0 -47
  229. package/dist/date-picker/date-input.js +0 -177
  230. package/dist/date-picker/date-picker.d.ts +0 -77
  231. package/dist/date-picker/date-picker.js +0 -402
  232. package/dist/date-picker/date-popup.d.ts +0 -55
  233. package/dist/date-picker/date-popup.js +0 -488
  234. package/dist/date-picker/day.d.ts +0 -30
  235. package/dist/date-picker/day.js +0 -133
  236. package/dist/date-picker/formats.d.ts +0 -2
  237. package/dist/date-picker/formats.js +0 -3
  238. package/dist/date-picker/month-names.d.ts +0 -13
  239. package/dist/date-picker/month-names.js +0 -110
  240. package/dist/date-picker/month-slider.d.ts +0 -29
  241. package/dist/date-picker/month-slider.js +0 -93
  242. package/dist/date-picker/month.d.ts +0 -14
  243. package/dist/date-picker/month.js +0 -58
  244. package/dist/date-picker/months.d.ts +0 -11
  245. package/dist/date-picker/months.js +0 -133
  246. package/dist/date-picker/weekdays.d.ts +0 -13
  247. package/dist/date-picker/weekdays.js +0 -39
  248. package/dist/date-picker/years.d.ts +0 -25
  249. package/dist/date-picker/years.js +0 -134
  250. package/dist/dialog/dialog.d.ts +0 -64
  251. package/dist/dialog/dialog.js +0 -238
  252. package/dist/dialog/dialog__body-scroll-preventer.d.ts +0 -9
  253. package/dist/dialog/dialog__body-scroll-preventer.js +0 -6
  254. package/dist/dropdown/anchor.d.ts +0 -11
  255. package/dist/dropdown/anchor.js +0 -24
  256. package/dist/dropdown/dropdown.d.ts +0 -87
  257. package/dist/dropdown/dropdown.js +0 -247
  258. package/dist/dropdown-menu/dropdown-menu.d.ts +0 -36
  259. package/dist/dropdown-menu/dropdown-menu.js +0 -194
  260. package/dist/editable-heading/editable-heading.d.ts +0 -32
  261. package/dist/editable-heading/editable-heading.js +0 -245
  262. package/dist/error-bubble/error-bubble.d.ts +0 -18
  263. package/dist/error-bubble/error-bubble.js +0 -86
  264. package/dist/error-message/error-message.d.ts +0 -27
  265. package/dist/error-message/error-message.js +0 -78
  266. package/dist/footer/footer.d.ts +0 -28
  267. package/dist/footer/footer.js +0 -118
  268. package/dist/global/compose.d.ts +0 -7
  269. package/dist/global/compose.js +0 -17
  270. package/dist/global/composeRefs.d.ts +0 -3
  271. package/dist/global/composeRefs.js +0 -19
  272. package/dist/global/controls-height.d.ts +0 -9
  273. package/dist/global/controls-height.js +0 -19
  274. package/dist/global/create-stateful-context.d.ts +0 -27
  275. package/dist/global/create-stateful-context.js +0 -49
  276. package/dist/global/data-tests.d.ts +0 -3
  277. package/dist/global/data-tests.js +0 -30
  278. package/dist/global/dom.d.ts +0 -37
  279. package/dist/global/dom.js +0 -150
  280. package/dist/global/focus-sensor-hoc.d.ts +0 -19
  281. package/dist/global/focus-sensor-hoc.js +0 -165
  282. package/dist/global/fuzzy-highlight.d.ts +0 -11
  283. package/dist/global/fuzzy-highlight.js +0 -90
  284. package/dist/global/get-event-key.d.ts +0 -2
  285. package/dist/global/get-event-key.js +0 -101
  286. package/dist/global/get-uid.d.ts +0 -1
  287. package/dist/global/get-uid.js +0 -22
  288. package/dist/global/inject-styles.d.ts +0 -3
  289. package/dist/global/inject-styles.js +0 -22
  290. package/dist/global/linear-function.d.ts +0 -6
  291. package/dist/global/linear-function.js +0 -15
  292. package/dist/global/listeners.d.ts +0 -8
  293. package/dist/global/listeners.js +0 -58
  294. package/dist/global/memoize.d.ts +0 -1
  295. package/dist/global/memoize.js +0 -23
  296. package/dist/global/normalize-indent.d.ts +0 -1
  297. package/dist/global/normalize-indent.js +0 -61
  298. package/dist/global/promise-with-timeout.d.ts +0 -5
  299. package/dist/global/promise-with-timeout.js +0 -19
  300. package/dist/global/prop-types.d.ts +0 -4
  301. package/dist/global/prop-types.js +0 -9
  302. package/dist/global/react-dom-renderer.d.ts +0 -16
  303. package/dist/global/react-dom-renderer.js +0 -53
  304. package/dist/global/react-render-adapter.d.ts +0 -1
  305. package/dist/global/react-render-adapter.js +0 -6
  306. package/dist/global/rerender-hoc.d.ts +0 -10
  307. package/dist/global/rerender-hoc.js +0 -46
  308. package/dist/global/schedule-raf.d.ts +0 -1
  309. package/dist/global/schedule-raf.js +0 -28
  310. package/dist/global/sniffer.d.ts +0 -3
  311. package/dist/global/sniffer.js +0 -6
  312. package/dist/global/theme.d.ts +0 -21
  313. package/dist/global/theme.js +0 -40
  314. package/dist/global/trivial-template-tag.d.ts +0 -1
  315. package/dist/global/trivial-template-tag.js +0 -21
  316. package/dist/global/typescript-utils.d.ts +0 -2
  317. package/dist/global/typescript-utils.js +0 -8
  318. package/dist/global/url.d.ts +0 -57
  319. package/dist/global/url.js +0 -141
  320. package/dist/global/use-event-callback.d.ts +0 -1
  321. package/dist/global/use-event-callback.js +0 -17
  322. package/dist/global/variables.d.ts +0 -89
  323. package/dist/global/variables.js +0 -1
  324. package/dist/grid/col.d.ts +0 -31
  325. package/dist/grid/col.js +0 -81
  326. package/dist/grid/grid.d.ts +0 -14
  327. package/dist/grid/grid.js +0 -47
  328. package/dist/grid/row.d.ts +0 -40
  329. package/dist/grid/row.js +0 -70
  330. package/dist/group/group.d.ts +0 -12
  331. package/dist/group/group.js +0 -39
  332. package/dist/header/header.d.ts +0 -34
  333. package/dist/header/header.js +0 -184
  334. package/dist/header/logo.d.ts +0 -14
  335. package/dist/header/logo.js +0 -51
  336. package/dist/header/profile.d.ts +0 -75
  337. package/dist/header/profile.js +0 -252
  338. package/dist/header/services-link.d.ts +0 -25
  339. package/dist/header/services-link.js +0 -13
  340. package/dist/header/services.d.ts +0 -33
  341. package/dist/header/services.js +0 -172
  342. package/dist/header/smart-profile.d.ts +0 -36
  343. package/dist/header/smart-profile.js +0 -298
  344. package/dist/header/smart-services.d.ts +0 -26
  345. package/dist/header/smart-services.js +0 -189
  346. package/dist/header/tray-icon.d.ts +0 -32
  347. package/dist/header/tray-icon.js +0 -57
  348. package/dist/header/tray.d.ts +0 -9
  349. package/dist/header/tray.js +0 -41
  350. package/dist/heading/heading.d.ts +0 -25
  351. package/dist/heading/heading.js +0 -69
  352. package/dist/http/http.d.ts +0 -61
  353. package/dist/http/http.js +0 -385
  354. package/dist/http/http.mock.d.ts +0 -20
  355. package/dist/http/http.mock.js +0 -112
  356. package/dist/hub-source/hub-source.d.ts +0 -44
  357. package/dist/hub-source/hub-source.js +0 -215
  358. package/dist/hub-source/hub-source__user.d.ts +0 -4
  359. package/dist/hub-source/hub-source__user.js +0 -59
  360. package/dist/hub-source/hub-source__users-groups.d.ts +0 -24
  361. package/dist/hub-source/hub-source__users-groups.js +0 -84
  362. package/dist/i18n/i18n-context.d.ts +0 -13
  363. package/dist/i18n/i18n-context.js +0 -27
  364. package/dist/i18n/i18n.d.ts +0 -59
  365. package/dist/i18n/i18n.js +0 -139
  366. package/dist/icon/icon.d.ts +0 -43
  367. package/dist/icon/icon.js +0 -109
  368. package/dist/icon/icon__constants.d.ts +0 -30
  369. package/dist/icon/icon__constants.js +0 -34
  370. package/dist/icon/icon__svg.d.ts +0 -15
  371. package/dist/icon/icon__svg.js +0 -14
  372. package/dist/icon/index.d.ts +0 -2
  373. package/dist/icon/index.js +0 -17
  374. package/dist/input/input.d.ts +0 -77
  375. package/dist/input/input.js +0 -35
  376. package/dist/island/adaptive-island-hoc.d.ts +0 -61
  377. package/dist/island/adaptive-island-hoc.js +0 -53
  378. package/dist/island/content.d.ts +0 -43
  379. package/dist/island/content.js +0 -151
  380. package/dist/island/header.d.ts +0 -8
  381. package/dist/island/header.js +0 -99
  382. package/dist/island/island.d.ts +0 -78
  383. package/dist/island/island.js +0 -60
  384. package/dist/island-legacy/content-legacy.d.ts +0 -10
  385. package/dist/island-legacy/content-legacy.js +0 -34
  386. package/dist/island-legacy/header-legacy.d.ts +0 -10
  387. package/dist/island-legacy/header-legacy.js +0 -36
  388. package/dist/island-legacy/island-legacy.d.ts +0 -12
  389. package/dist/island-legacy/island-legacy.js +0 -36
  390. package/dist/link/clickableLink.d.ts +0 -20
  391. package/dist/link/clickableLink.js +0 -69
  392. package/dist/link/link.d.ts +0 -138
  393. package/dist/link/link.js +0 -86
  394. package/dist/list/consts.d.ts +0 -77
  395. package/dist/list/consts.js +0 -27
  396. package/dist/list/list.d.ts +0 -206
  397. package/dist/list/list.js +0 -795
  398. package/dist/list/list__custom.d.ts +0 -6
  399. package/dist/list/list__custom.js +0 -92
  400. package/dist/list/list__hint.d.ts +0 -15
  401. package/dist/list/list__hint.js +0 -33
  402. package/dist/list/list__item.d.ts +0 -8
  403. package/dist/list/list__item.js +0 -234
  404. package/dist/list/list__link.d.ts +0 -9
  405. package/dist/list/list__link.js +0 -76
  406. package/dist/list/list__separator.d.ts +0 -5
  407. package/dist/list/list__separator.js +0 -39
  408. package/dist/list/list__title.d.ts +0 -5
  409. package/dist/list/list__title.js +0 -48
  410. package/dist/list/list__users-groups-source.d.ts +0 -27
  411. package/dist/list/list__users-groups-source.js +0 -190
  412. package/dist/loader/loader.d.ts +0 -28
  413. package/dist/loader/loader.js +0 -91
  414. package/dist/loader/loader__core.d.ts +0 -75
  415. package/dist/loader/loader__core.js +0 -313
  416. package/dist/loader-inline/loader-inline.d.ts +0 -18
  417. package/dist/loader-inline/loader-inline.js +0 -50
  418. package/dist/loader-screen/loader-screen.d.ts +0 -17
  419. package/dist/loader-screen/loader-screen.js +0 -62
  420. package/dist/login-dialog/login-dialog.d.ts +0 -47
  421. package/dist/login-dialog/login-dialog.js +0 -212
  422. package/dist/login-dialog/service.d.ts +0 -2
  423. package/dist/login-dialog/service.js +0 -94
  424. package/dist/markdown/markdown.d.ts +0 -12
  425. package/dist/markdown/markdown.js +0 -43
  426. package/dist/message/message.d.ts +0 -55
  427. package/dist/message/message.js +0 -265
  428. package/dist/old-browsers-message/old-browsers-message.d.ts +0 -2
  429. package/dist/old-browsers-message/old-browsers-message.js +0 -92
  430. package/dist/old-browsers-message/old-browsers-message__stop.d.ts +0 -1
  431. package/dist/old-browsers-message/old-browsers-message__stop.js +0 -11
  432. package/dist/old-browsers-message/white-list.d.ts +0 -2
  433. package/dist/old-browsers-message/white-list.js +0 -37
  434. package/dist/pager/pager.d.ts +0 -78
  435. package/dist/pager/pager.js +0 -385
  436. package/dist/panel/panel.d.ts +0 -12
  437. package/dist/panel/panel.js +0 -39
  438. package/dist/permissions/permissions.d.ts +0 -111
  439. package/dist/permissions/permissions.js +0 -220
  440. package/dist/permissions/permissions__cache.d.ts +0 -93
  441. package/dist/permissions/permissions__cache.js +0 -257
  442. package/dist/popup/popup.consts.d.ts +0 -37
  443. package/dist/popup/popup.consts.js +0 -44
  444. package/dist/popup/popup.d.ts +0 -147
  445. package/dist/popup/popup.js +0 -419
  446. package/dist/popup/popup.target.d.ts +0 -7
  447. package/dist/popup/popup.target.js +0 -24
  448. package/dist/popup/position.d.ts +0 -30
  449. package/dist/popup/position.js +0 -270
  450. package/dist/popup-menu/popup-menu.d.ts +0 -80
  451. package/dist/popup-menu/popup-menu.js +0 -136
  452. package/dist/progress-bar/progress-bar.d.ts +0 -58
  453. package/dist/progress-bar/progress-bar.js +0 -113
  454. package/dist/query-assist/query-assist.d.ts +0 -306
  455. package/dist/query-assist/query-assist.js +0 -1092
  456. package/dist/query-assist/query-assist__suggestions.d.ts +0 -29
  457. package/dist/query-assist/query-assist__suggestions.js +0 -70
  458. package/dist/radio/radio.d.ts +0 -18
  459. package/dist/radio/radio.js +0 -48
  460. package/dist/radio/radio__item.d.ts +0 -28
  461. package/dist/radio/radio__item.js +0 -88
  462. package/dist/select/select.d.ts +0 -276
  463. package/dist/select/select.js +0 -1285
  464. package/dist/select/select__filter.d.ts +0 -19
  465. package/dist/select/select__filter.js +0 -80
  466. package/dist/select/select__popup.d.ts +0 -166
  467. package/dist/select/select__popup.js +0 -626
  468. package/dist/shortcuts/core.d.ts +0 -74
  469. package/dist/shortcuts/core.js +0 -247
  470. package/dist/shortcuts/shortcut-title.d.ts +0 -1
  471. package/dist/shortcuts/shortcut-title.js +0 -56
  472. package/dist/shortcuts/shortcuts-hoc.d.ts +0 -65
  473. package/dist/shortcuts/shortcuts-hoc.js +0 -59
  474. package/dist/shortcuts/shortcuts.d.ts +0 -28
  475. package/dist/shortcuts/shortcuts.js +0 -90
  476. package/dist/storage/storage.d.ts +0 -18
  477. package/dist/storage/storage.js +0 -89
  478. package/dist/storage/storage__fallback.d.ts +0 -79
  479. package/dist/storage/storage__fallback.js +0 -251
  480. package/dist/storage/storage__local.d.ts +0 -38
  481. package/dist/storage/storage__local.js +0 -215
  482. package/dist/style.css +0 -1
  483. package/dist/tab-trap/tab-trap.d.ts +0 -43
  484. package/dist/tab-trap/tab-trap.js +0 -179
  485. package/dist/table/cell.d.ts +0 -13
  486. package/dist/table/cell.js +0 -37
  487. package/dist/table/disable-hover-hoc.d.ts +0 -64
  488. package/dist/table/disable-hover-hoc.js +0 -62
  489. package/dist/table/header-cell.d.ts +0 -43
  490. package/dist/table/header-cell.js +0 -109
  491. package/dist/table/header.d.ts +0 -56
  492. package/dist/table/header.js +0 -151
  493. package/dist/table/multitable.d.ts +0 -25
  494. package/dist/table/multitable.js +0 -139
  495. package/dist/table/row-with-focus-sensor.d.ts +0 -18
  496. package/dist/table/row-with-focus-sensor.js +0 -115
  497. package/dist/table/row.d.ts +0 -59
  498. package/dist/table/row.js +0 -297
  499. package/dist/table/selection-adapter.d.ts +0 -5
  500. package/dist/table/selection-adapter.js +0 -14
  501. package/dist/table/selection-shortcuts-hoc.d.ts +0 -17
  502. package/dist/table/selection-shortcuts-hoc.js +0 -204
  503. package/dist/table/selection.d.ts +0 -47
  504. package/dist/table/selection.js +0 -256
  505. package/dist/table/smart-table.d.ts +0 -64
  506. package/dist/table/smart-table.js +0 -145
  507. package/dist/table/table.d.ts +0 -159
  508. package/dist/table/table.js +0 -459
  509. package/dist/tabs/collapsible-more.d.ts +0 -29
  510. package/dist/tabs/collapsible-more.js +0 -217
  511. package/dist/tabs/collapsible-tab.d.ts +0 -16
  512. package/dist/tabs/collapsible-tab.js +0 -88
  513. package/dist/tabs/collapsible-tabs.d.ts +0 -43
  514. package/dist/tabs/collapsible-tabs.js +0 -349
  515. package/dist/tabs/custom-item.d.ts +0 -9
  516. package/dist/tabs/custom-item.js +0 -11
  517. package/dist/tabs/dumb-tabs.d.ts +0 -35
  518. package/dist/tabs/dumb-tabs.js +0 -184
  519. package/dist/tabs/smart-tabs.d.ts +0 -20
  520. package/dist/tabs/smart-tabs.js +0 -136
  521. package/dist/tabs/tab-link.d.ts +0 -18
  522. package/dist/tabs/tab-link.js +0 -13
  523. package/dist/tabs/tab.d.ts +0 -27
  524. package/dist/tabs/tab.js +0 -41
  525. package/dist/tabs/tabs.d.ts +0 -7
  526. package/dist/tabs/tabs.js +0 -94
  527. package/dist/tag/tag.d.ts +0 -64
  528. package/dist/tag/tag.js +0 -213
  529. package/dist/tags-input/tags-input.d.ts +0 -138
  530. package/dist/tags-input/tags-input.js +0 -529
  531. package/dist/tags-list/tags-list.d.ts +0 -46
  532. package/dist/tags-list/tags-list.js +0 -102
  533. package/dist/text/text.d.ts +0 -23
  534. package/dist/text/text.js +0 -57
  535. package/dist/toggle/toggle.d.ts +0 -39
  536. package/dist/toggle/toggle.js +0 -86
  537. package/dist/tooltip/tooltip.d.ts +0 -65
  538. package/dist/tooltip/tooltip.js +0 -227
  539. package/dist/user-agreement/service.d.ts +0 -69
  540. package/dist/user-agreement/service.js +0 -484
  541. package/dist/user-agreement/toolbox.eula.d.ts +0 -2
  542. package/dist/user-agreement/toolbox.eula.js +0 -3
  543. package/dist/user-agreement/user-agreement.d.ts +0 -60
  544. package/dist/user-agreement/user-agreement.js +0 -170
  545. package/dist/user-card/card.d.ts +0 -70
  546. package/dist/user-card/card.js +0 -76
  547. package/dist/user-card/smart-user-card-tooltip.d.ts +0 -20
  548. package/dist/user-card/smart-user-card-tooltip.js +0 -168
  549. package/dist/user-card/tooltip.d.ts +0 -36
  550. package/dist/user-card/tooltip.js +0 -140
  551. package/dist/user-card/user-card.d.ts +0 -11
  552. package/dist/user-card/user-card.js +0 -81
@@ -1,1650 +0,0 @@
1
- import { _ as _defineProperty, d as _createClass, g as _objectSpread2, c as _classCallCheck, l as _toConsumableArray, h as _asyncToGenerator, i as _regeneratorRuntime } from '../_helpers/_rollupPluginBabelHelpers.js';
2
- import 'core-js/modules/es.object.to-string.js';
3
- import 'core-js/modules/es.promise.js';
4
- import 'core-js/modules/es.array.filter.js';
5
- import 'core-js/modules/es.array.iterator.js';
6
- import 'core-js/modules/es.set.js';
7
- import 'core-js/modules/web.dom-collections.iterator.js';
8
- import 'core-js/modules/es.array.concat.js';
9
- import 'core-js/modules/es.array.includes.js';
10
- import 'core-js/modules/es.string.includes.js';
11
- import 'core-js/modules/es.regexp.exec.js';
12
- import 'core-js/modules/es.string.replace.js';
13
- import 'core-js/modules/es.regexp.to-string.js';
14
- import 'core-js/modules/web.url.js';
15
- import 'core-js/modules/web.url-search-params.js';
16
- import 'core-js/modules/es.string.search.js';
17
- import { getAbsoluteBaseURL, fixUrl } from '../global/url.js';
18
- import Listeners from '../global/listeners.js';
19
- import HTTP from '../http/http.js';
20
- import promiseWithTimeout from '../global/promise-with-timeout.js';
21
- import { translate, getTranslationsWithFallback, getTranslations } from '../i18n/i18n.js';
22
- import AuthStorage from './storage.js';
23
- import AuthResponseParser from './response-parser.js';
24
- import AuthRequestBuilder from './request-builder.js';
25
- import BackgroundFlow from './background-flow.js';
26
- import TokenValidator from './token-validator.js';
27
- import 'core-js/modules/es.string.match.js';
28
- import 'core-js/modules/es.map.js';
29
- import 'core-js/modules/es.array.map.js';
30
- import 'core-js/modules/es.weak-map.js';
31
- import 'core-js/modules/web.dom-collections.for-each.js';
32
- import 'core-js/modules/es.object.entries.js';
33
- import 'core-js/modules/es.reflect.delete-property.js';
34
- import 'es6-error';
35
- import 'core-js/modules/es.array.reduce.js';
36
- import 'core-js/modules/es.array.sort.js';
37
- import '../storage/storage.js';
38
- import '../storage/storage__local.js';
39
- import '../alert-service/alert-service.js';
40
- import 'react';
41
- import 'react-dom/client';
42
- import '../global/get-uid.js';
43
- import '../alert/alert.js';
44
- import 'core-js/modules/es.object.values.js';
45
- import 'classnames';
46
- import 'prop-types';
47
- import '@jetbrains/icons/exception';
48
- import '@jetbrains/icons/checkmark';
49
- import '@jetbrains/icons/warning';
50
- import '@jetbrains/icons/close';
51
- import '../icon/icon.js';
52
- import 'util-deprecate';
53
- import '../icon/icon__constants.js';
54
- import '../_helpers/icon__svg.js';
55
- import 'core-js/modules/es.string.starts-with.js';
56
- import '../global/memoize.js';
57
- import '../loader-inline/loader-inline.js';
58
- import '../global/data-tests.js';
59
- import '../global/dom.js';
60
- import 'core-js/modules/es.string.split.js';
61
- import '../button/button.js';
62
- import '@jetbrains/icons/chevron-10px';
63
- import '../link/clickableLink.js';
64
- import '../global/controls-height.js';
65
- import '../_helpers/button__classes.js';
66
- import '../_helpers/theme.js';
67
- import 'react-dom';
68
- import '../popup/popup.target.js';
69
- import '../popup/popup.js';
70
- import '../global/schedule-raf.js';
71
- import '../shortcuts/shortcuts.js';
72
- import '../shortcuts/core.js';
73
- import 'core-js/modules/es.array.slice.js';
74
- import 'core-js/modules/es.array.splice.js';
75
- import 'combokeys';
76
- import '../global/sniffer.js';
77
- import 'sniffr';
78
- import '../tab-trap/tab-trap.js';
79
- import '../popup/position.js';
80
- import '../popup/popup.consts.js';
81
- import '../alert/container.js';
82
- import '../storage/storage__fallback.js';
83
- import 'deep-equal';
84
- import 'simply-uuid';
85
-
86
- /* eslint-disable @typescript-eslint/no-magic-numbers */
87
- var DEFAULT_EXPIRES_TIMEOUT = 40 * 60;
88
- var DEFAULT_BACKGROUND_TIMEOUT = 10 * 1000;
89
- var DEFAULT_BACKEND_CHECK_TIMEOUT = 10 * 1000;
90
- var BACKGROUND_REDIRECT_TIMEOUT = 20 * 1000;
91
- var DEFAULT_WAIT_FOR_REDIRECT_TIMEOUT = 5 * 1000;
92
- /* eslint-enable @typescript-eslint/no-magic-numbers */
93
- var USER_CHANGED_EVENT = 'userChange';
94
- var DOMAIN_USER_CHANGED_EVENT = 'domainUser';
95
- var LOGOUT_EVENT = 'logout';
96
- var LOGOUT_POSTPONED_EVENT = 'logoutPostponed';
97
- var USER_CHANGE_POSTPONED_EVENT = 'changePostponed';
98
- function noop() {}
99
- var DEFAULT_CONFIG = {
100
- cacheCurrentUser: false,
101
- reloadOnUserChange: true,
102
- embeddedLogin: false,
103
- EmbeddedLoginFlow: null,
104
- clientId: '0-0-0-0-0',
105
- redirectUri: getAbsoluteBaseURL(),
106
- redirect: false,
107
- requestCredentials: 'default',
108
- backgroundRefreshTimeout: null,
109
- scope: [],
110
- userFields: ['guest', 'id', 'name', 'login', 'profile/avatar/url'],
111
- cleanHash: true,
112
- onLogout: noop,
113
- onPostponeChangedUser: function onPostponeChangedUser() {},
114
- onPostponeLogout: function onPostponeLogout() {},
115
- enableBackendStatusCheck: true,
116
- backendCheckTimeout: DEFAULT_BACKEND_CHECK_TIMEOUT,
117
- checkBackendIsUp: function checkBackendIsUp() {
118
- return Promise.resolve(null);
119
- },
120
- onBackendDown: function onBackendDown() {
121
- return function () {};
122
- },
123
- defaultExpiresIn: DEFAULT_EXPIRES_TIMEOUT,
124
- waitForRedirectTimeout: DEFAULT_WAIT_FOR_REDIRECT_TIMEOUT,
125
- translations: null
126
- };
127
- var Auth = /*#__PURE__*/function () {
128
- function Auth(config) {
129
- var _this = this;
130
- _classCallCheck(this, Auth);
131
- _defineProperty(this, "config", void 0);
132
- _defineProperty(this, "listeners", new Listeners());
133
- _defineProperty(this, "http", void 0);
134
- _defineProperty(this, "_service", {});
135
- _defineProperty(this, "_storage", null);
136
- _defineProperty(this, "_responseParser", new AuthResponseParser());
137
- _defineProperty(this, "_requestBuilder", null);
138
- _defineProperty(this, "_backgroundFlow", void 0);
139
- _defineProperty(this, "_embeddedFlow", null);
140
- _defineProperty(this, "_tokenValidator", null);
141
- _defineProperty(this, "_postponed", false);
142
- _defineProperty(this, "_backendCheckPromise", null);
143
- _defineProperty(this, "_authDialogService", undefined);
144
- _defineProperty(this, "_domainStorage", void 0);
145
- _defineProperty(this, "user", null);
146
- _defineProperty(this, "_initDeferred", void 0);
147
- _defineProperty(this, "_isLoginWindowOpen", void 0);
148
- if (!config) {
149
- throw new Error('Config is required');
150
- }
151
- if (config.serverUri == null) {
152
- throw new Error('\"serverUri\" property is required');
153
- }
154
- var unsupportedParams = ['redirect_uri', 'request_credentials', 'client_id'].filter(function (param) {
155
- return config.hasOwnProperty(param);
156
- });
157
- if (unsupportedParams.length !== 0) {
158
- throw new Error("The following parameters are no longer supported: ".concat(unsupportedParams.join(', '), ". Please change them from snake_case to camelCase."));
159
- }
160
- config.userFields = config.userFields || [];
161
- this.config = _objectSpread2(_objectSpread2({}, Auth.DEFAULT_CONFIG), config);
162
- var _this$config = this.config,
163
- clientId = _this$config.clientId,
164
- redirect = _this$config.redirect,
165
- redirectUri = _this$config.redirectUri,
166
- requestCredentials = _this$config.requestCredentials,
167
- scope = _this$config.scope;
168
- var serverUriLength = this.config.serverUri.length;
169
- if (serverUriLength > 0 && this.config.serverUri.charAt(serverUriLength - 1) !== '/') {
170
- this.config.serverUri += '/';
171
- }
172
- this.config.userParams = {
173
- query: {
174
- fields: _toConsumableArray(new Set(Auth.DEFAULT_CONFIG.userFields.concat(config.userFields))).join()
175
- }
176
- };
177
- if (!scope.includes(Auth.DEFAULT_CONFIG.clientId)) {
178
- scope.push(Auth.DEFAULT_CONFIG.clientId);
179
- }
180
- this._storage = new AuthStorage({
181
- messagePrefix: "".concat(clientId, "-message-"),
182
- stateKeyPrefix: "".concat(clientId, "-states-"),
183
- tokenKey: "".concat(clientId, "-token"),
184
- userKey: "".concat(clientId, "-user-")
185
- });
186
- this._domainStorage = new AuthStorage({
187
- messagePrefix: 'domain-message-'
188
- });
189
- this._requestBuilder = new AuthRequestBuilder({
190
- authorization: this.config.serverUri + Auth.API_PATH + Auth.API_AUTH_PATH,
191
- clientId,
192
- redirect,
193
- redirectUri,
194
- requestCredentials,
195
- scopes: scope
196
- }, this._storage);
197
- var backgroundRefreshTimeout = this.config.backgroundRefreshTimeout;
198
- if (!backgroundRefreshTimeout) {
199
- backgroundRefreshTimeout = this.config.embeddedLogin ? DEFAULT_BACKGROUND_TIMEOUT : BACKGROUND_REDIRECT_TIMEOUT;
200
- }
201
- this._backgroundFlow = new BackgroundFlow(this._requestBuilder, this._storage, backgroundRefreshTimeout);
202
- if (this.config.EmbeddedLoginFlow) {
203
- var _this$config$translat;
204
- this._embeddedFlow = new this.config.EmbeddedLoginFlow(this._requestBuilder, this._storage, (_this$config$translat = this.config.translations) !== null && _this$config$translat !== void 0 ? _this$config$translat : getTranslationsWithFallback());
205
- }
206
- var API_BASE = this.config.serverUri + Auth.API_PATH;
207
- var fetchConfig = config.fetchCredentials ? {
208
- credentials: config.fetchCredentials
209
- } : undefined;
210
- this.http = new HTTP(this, API_BASE, fetchConfig);
211
- var getUser = /*#__PURE__*/function () {
212
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(token) {
213
- var user;
214
- return _regeneratorRuntime().wrap(function _callee$(_context) {
215
- while (1) switch (_context.prev = _context.next) {
216
- case 0:
217
- _context.next = 2;
218
- return _this.getUser(token);
219
- case 2:
220
- user = _context.sent;
221
- _this.user = user;
222
- return _context.abrupt("return", user);
223
- case 5:
224
- case "end":
225
- return _context.stop();
226
- }
227
- }, _callee);
228
- }));
229
- return function getUser(_x) {
230
- return _ref.apply(this, arguments);
231
- };
232
- }();
233
- this._tokenValidator = new TokenValidator(this.config, getUser, this._storage);
234
- if (this.config.onLogout) {
235
- this.addListener(LOGOUT_EVENT, this.config.onLogout);
236
- }
237
- if (this.config.reloadOnUserChange) {
238
- this.addListener(USER_CHANGED_EVENT, function () {
239
- return _this._reloadCurrentPage();
240
- });
241
- }
242
- this.addListener(LOGOUT_POSTPONED_EVENT, function () {
243
- return _this._setPostponed(true);
244
- });
245
- this.addListener(USER_CHANGE_POSTPONED_EVENT, function () {
246
- return _this._setPostponed(true);
247
- });
248
- this.addListener(USER_CHANGED_EVENT, function () {
249
- return _this._setPostponed(false);
250
- });
251
- this.addListener(USER_CHANGED_EVENT, function (user) {
252
- if (user) {
253
- _this._updateDomainUser(user.id);
254
- }
255
- });
256
- if (this.config.cacheCurrentUser) {
257
- this.addListener(LOGOUT_EVENT, function () {
258
- var _this$_storage;
259
- return (_this$_storage = _this._storage) === null || _this$_storage === void 0 ? void 0 : _this$_storage.wipeCachedCurrentUser();
260
- });
261
- this.addListener(USER_CHANGED_EVENT, function () {
262
- var _this$_storage2;
263
- return (_this$_storage2 = _this._storage) === null || _this$_storage2 === void 0 ? void 0 : _this$_storage2.onUserChanged();
264
- });
265
- }
266
- this._createInitDeferred();
267
- this.setUpPreconnect(config.serverUri);
268
- }
269
- _createClass(Auth, [{
270
- key: "_setPostponed",
271
- value: function _setPostponed() {
272
- var postponed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
273
- this._postponed = postponed;
274
- }
275
- }, {
276
- key: "_updateDomainUser",
277
- value: function _updateDomainUser(userID) {
278
- this._domainStorage.sendMessage(DOMAIN_USER_CHANGED_EVENT, {
279
- userID,
280
- serviceID: this.config.clientId
281
- });
282
- }
283
- }, {
284
- key: "addListener",
285
- value: function addListener(event, handler) {
286
- this.listeners.add(event, handler);
287
- }
288
- }, {
289
- key: "removeListener",
290
- value: function removeListener(event, handler) {
291
- this.listeners.remove(event, handler);
292
- }
293
- }, {
294
- key: "setAuthDialogService",
295
- value: function setAuthDialogService(authDialogService) {
296
- this._authDialogService = authDialogService;
297
- }
298
- }, {
299
- key: "setCurrentService",
300
- value: function setCurrentService(service) {
301
- this._service = service;
302
- }
303
- }, {
304
- key: "_createInitDeferred",
305
- value: function _createInitDeferred() {
306
- var deferred = {};
307
- deferred.promise = new Promise(function (resolve, reject) {
308
- deferred.resolve = resolve;
309
- deferred.reject = reject;
310
- });
311
- this._initDeferred = deferred;
312
- }
313
- /**
314
- * @return {Promise.<string>} absolute URL promise that is resolved to a URL
315
- * that should be restored after returning back from auth server.
316
- */
317
- }, {
318
- key: "init",
319
- value: function () {
320
- var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
321
- var _this$_storage3,
322
- _this2 = this;
323
- var state, _this$_tokenValidator, _this$_initDeferred, _this$_initDeferred$r, _state, message, _this$user, userID, serviceID, _this$_initDeferred2, _this$_initDeferred2$;
324
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
325
- while (1) switch (_context3.prev = _context3.next) {
326
- case 0:
327
- (_this$_storage3 = this._storage) === null || _this$_storage3 === void 0 ? void 0 : _this$_storage3.onTokenChange( /*#__PURE__*/function () {
328
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(token) {
329
- var isGuest;
330
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
331
- while (1) switch (_context2.prev = _context2.next) {
332
- case 0:
333
- isGuest = _this2.user ? _this2.user.guest : false;
334
- if (!(isGuest && !token)) {
335
- _context2.next = 3;
336
- break;
337
- }
338
- return _context2.abrupt("return");
339
- case 3:
340
- if (token) {
341
- _context2.next = 7;
342
- break;
343
- }
344
- _this2.logout();
345
- _context2.next = 17;
346
- break;
347
- case 7:
348
- _context2.prev = 7;
349
- _context2.next = 10;
350
- return _this2._detectUserChange(token.accessToken);
351
- case 10:
352
- _context2.next = 17;
353
- break;
354
- case 12:
355
- _context2.prev = 12;
356
- _context2.t0 = _context2["catch"](7);
357
- if (_context2.t0 instanceof Error) {
358
- _context2.next = 16;
359
- break;
360
- }
361
- throw _context2.t0;
362
- case 16:
363
- if (_this2._canShowDialogs()) {
364
- _this2._showAuthDialog({
365
- nonInteractive: true,
366
- error: _context2.t0
367
- });
368
- }
369
- case 17:
370
- case "end":
371
- return _context2.stop();
372
- }
373
- }, _callee2, null, [[7, 12]]);
374
- }));
375
- return function (_x2) {
376
- return _ref2.apply(this, arguments);
377
- };
378
- }());
379
- this._domainStorage.onMessage(DOMAIN_USER_CHANGED_EVENT, function (message) {
380
- var _ref3 = message || {},
381
- userID = _ref3.userID,
382
- serviceID = _ref3.serviceID;
383
- if (serviceID === _this2.config.clientId) {
384
- return;
385
- }
386
- if (_this2.user && userID === _this2.user.id) {
387
- return;
388
- }
389
- _this2.forceTokenUpdate();
390
- });
391
- _context3.prev = 2;
392
- _context3.next = 5;
393
- return this._checkForAuthResponse();
394
- case 5:
395
- state = _context3.sent;
396
- _context3.next = 11;
397
- break;
398
- case 8:
399
- _context3.prev = 8;
400
- _context3.t0 = _context3["catch"](2);
401
- return _context3.abrupt("return", _context3.t0 instanceof Error ? this.handleInitError(_context3.t0) : undefined);
402
- case 11:
403
- if (!(state && state.nonRedirect)) {
404
- _context3.next = 13;
405
- break;
406
- }
407
- return _context3.abrupt("return", new Promise(noop));
408
- case 13:
409
- _context3.prev = 13;
410
- _context3.next = 16;
411
- return (_this$_tokenValidator = this._tokenValidator) === null || _this$_tokenValidator === void 0 ? void 0 : _this$_tokenValidator.validateToken();
412
- case 16:
413
- _context3.next = 18;
414
- return this._domainStorage._messagesStorage.get("domain-message-".concat(DOMAIN_USER_CHANGED_EVENT));
415
- case 18:
416
- message = _context3.sent;
417
- if (message) {
418
- userID = message.userID, serviceID = message.serviceID;
419
- if (serviceID !== this.config.clientId && (!userID || ((_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user.id) !== userID)) {
420
- this.forceTokenUpdate();
421
- }
422
- }
423
- // Access token appears to be valid.
424
- // We may resolve restoreLocation URL now
425
- if (state) {
426
- _context3.next = 24;
427
- break;
428
- }
429
- _context3.next = 23;
430
- return this._checkForStateRestoration();
431
- case 23:
432
- state = _context3.sent;
433
- case 24:
434
- (_this$_initDeferred = this._initDeferred) === null || _this$_initDeferred === void 0 || (_this$_initDeferred$r = _this$_initDeferred.resolve) === null || _this$_initDeferred$r === void 0 ? void 0 : _this$_initDeferred$r.call(_this$_initDeferred, state && state.restoreLocation);
435
- return _context3.abrupt("return", (_state = state) === null || _state === void 0 ? void 0 : _state.restoreLocation);
436
- case 28:
437
- _context3.prev = 28;
438
- _context3.t1 = _context3["catch"](13);
439
- if (!Auth.storageIsUnavailable) {
440
- _context3.next = 35;
441
- break;
442
- }
443
- (_this$_initDeferred2 = this._initDeferred) === null || _this$_initDeferred2 === void 0 || (_this$_initDeferred2$ = _this$_initDeferred2.resolve) === null || _this$_initDeferred2$ === void 0 ? void 0 : _this$_initDeferred2$.call(_this$_initDeferred2); // No way to handle if cookies are disabled
444
- _context3.next = 34;
445
- return this.requestUser();
446
- case 34:
447
- return _context3.abrupt("return", null);
448
- case 35:
449
- return _context3.abrupt("return", _context3.t1 instanceof Error ? this.handleInitValidationError(_context3.t1) : undefined);
450
- case 36:
451
- case "end":
452
- return _context3.stop();
453
- }
454
- }, _callee3, this, [[2, 8], [13, 28]]);
455
- }));
456
- function init() {
457
- return _init.apply(this, arguments);
458
- }
459
- return init;
460
- }()
461
- }, {
462
- key: "sendRedirect",
463
- value: function () {
464
- var _sendRedirect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(error) {
465
- var _this$_requestBuilder,
466
- _this3 = this;
467
- var authRequest;
468
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
469
- while (1) switch (_context4.prev = _context4.next) {
470
- case 0:
471
- _context4.next = 2;
472
- return (_this$_requestBuilder = this._requestBuilder) === null || _this$_requestBuilder === void 0 ? void 0 : _this$_requestBuilder.prepareAuthRequest();
473
- case 2:
474
- authRequest = _context4.sent;
475
- if (authRequest != null) {
476
- this._redirectCurrentPage(authRequest.url);
477
- }
478
- // HUB-10867 Since we already redirecting the page, there is no actual need to throw an error
479
- // and scare user with flashing error
480
- // But let's keep it just in case redirect was not successful
481
- _context4.next = 6;
482
- return new Promise(function (resolve) {
483
- return setTimeout(resolve, _this3.config.waitForRedirectTimeout);
484
- });
485
- case 6:
486
- throw error;
487
- case 7:
488
- case "end":
489
- return _context4.stop();
490
- }
491
- }, _callee4, this);
492
- }));
493
- function sendRedirect(_x3) {
494
- return _sendRedirect.apply(this, arguments);
495
- }
496
- return sendRedirect;
497
- }()
498
- }, {
499
- key: "handleInitError",
500
- value: function () {
501
- var _handleInitError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(error) {
502
- var _this$_storage4, state, _this$_storage5;
503
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
504
- while (1) switch (_context5.prev = _context5.next) {
505
- case 0:
506
- if (!('stateId' in error && error.stateId)) {
507
- _context5.next = 13;
508
- break;
509
- }
510
- _context5.prev = 1;
511
- _context5.next = 4;
512
- return (_this$_storage4 = this._storage) === null || _this$_storage4 === void 0 ? void 0 : _this$_storage4.getState(error.stateId);
513
- case 4:
514
- state = _context5.sent;
515
- if (!(state && state.nonRedirect)) {
516
- _context5.next = 9;
517
- break;
518
- }
519
- state.error = error;
520
- (_this$_storage5 = this._storage) === null || _this$_storage5 === void 0 ? void 0 : _this$_storage5.saveState(error.stateId, state);
521
- // Return endless promise in the background to avoid service start
522
- return _context5.abrupt("return", new Promise(noop));
523
- case 9:
524
- _context5.next = 13;
525
- break;
526
- case 11:
527
- _context5.prev = 11;
528
- _context5.t0 = _context5["catch"](1);
529
- case 13:
530
- throw error;
531
- case 14:
532
- case "end":
533
- return _context5.stop();
534
- }
535
- }, _callee5, this, [[1, 11]]);
536
- }));
537
- function handleInitError(_x4) {
538
- return _handleInitError.apply(this, arguments);
539
- }
540
- return handleInitError;
541
- }()
542
- }, {
543
- key: "handleInitValidationError",
544
- value: function () {
545
- var _handleInitValidationError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(error) {
546
- var _error$cause, _this$_initDeferred4, _this$_initDeferred4$;
547
- var _this$_backgroundFlow, _this$_tokenValidator2, _this$_initDeferred3, _this$_initDeferred3$;
548
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
549
- while (1) switch (_context6.prev = _context6.next) {
550
- case 0:
551
- if (!('cause' in error && error.cause instanceof Error && ((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.message) === 'invalid_client')) {
552
- _context6.next = 5;
553
- break;
554
- }
555
- // eslint-disable-next-line no-console
556
- console.error('RingUI Auth: invalid client detected. Logging out', error);
557
- _context6.next = 4;
558
- return this.logout();
559
- case 4:
560
- return _context6.abrupt("return", undefined);
561
- case 5:
562
- if (!('authRedirect' in error && error.authRedirect && this.config.redirect)) {
563
- _context6.next = 7;
564
- break;
565
- }
566
- return _context6.abrupt("return", this.sendRedirect(error));
567
- case 7:
568
- if (!('authRedirect' in error && error.authRedirect && !this.config.redirect)) {
569
- _context6.next = 20;
570
- break;
571
- }
572
- _context6.prev = 8;
573
- _context6.next = 11;
574
- return (_this$_backgroundFlow = this._backgroundFlow) === null || _this$_backgroundFlow === void 0 ? void 0 : _this$_backgroundFlow.authorize();
575
- case 11:
576
- _context6.next = 13;
577
- return (_this$_tokenValidator2 = this._tokenValidator) === null || _this$_tokenValidator2 === void 0 ? void 0 : _this$_tokenValidator2.validateToken();
578
- case 13:
579
- (_this$_initDeferred3 = this._initDeferred) === null || _this$_initDeferred3 === void 0 || (_this$_initDeferred3$ = _this$_initDeferred3.resolve) === null || _this$_initDeferred3$ === void 0 ? void 0 : _this$_initDeferred3$.call(_this$_initDeferred3);
580
- return _context6.abrupt("return", undefined);
581
- case 17:
582
- _context6.prev = 17;
583
- _context6.t0 = _context6["catch"](8);
584
- return _context6.abrupt("return", _context6.t0 instanceof Error ? this.sendRedirect(_context6.t0) : undefined);
585
- case 20:
586
- (_this$_initDeferred4 = this._initDeferred) === null || _this$_initDeferred4 === void 0 || (_this$_initDeferred4$ = _this$_initDeferred4.reject) === null || _this$_initDeferred4$ === void 0 ? void 0 : _this$_initDeferred4$.call(_this$_initDeferred4, error);
587
- throw error;
588
- case 22:
589
- case "end":
590
- return _context6.stop();
591
- }
592
- }, _callee6, this, [[8, 17]]);
593
- }));
594
- function handleInitValidationError(_x5) {
595
- return _handleInitValidationError.apply(this, arguments);
596
- }
597
- return handleInitValidationError;
598
- }()
599
- /**
600
- * Get token from local storage or request it if necessary.
601
- * Can redirect to login page.
602
- * @return {Promise.<string>}
603
- */
604
- }, {
605
- key: "requestToken",
606
- value: function () {
607
- var _requestToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
608
- var _this$_initDeferred5, _yield$this$_tokenVal, _this$_tokenValidator3;
609
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
610
- while (1) switch (_context7.prev = _context7.next) {
611
- case 0:
612
- if (!this._postponed) {
613
- _context7.next = 2;
614
- break;
615
- }
616
- throw new Error('You should log in to be able to make requests');
617
- case 2:
618
- _context7.prev = 2;
619
- _context7.next = 5;
620
- return (_this$_initDeferred5 = this._initDeferred) === null || _this$_initDeferred5 === void 0 ? void 0 : _this$_initDeferred5.promise;
621
- case 5:
622
- if (!Auth.storageIsUnavailable) {
623
- _context7.next = 7;
624
- break;
625
- }
626
- return _context7.abrupt("return", null);
627
- case 7:
628
- _context7.next = 9;
629
- return (_this$_tokenValidator3 = this._tokenValidator) === null || _this$_tokenValidator3 === void 0 ? void 0 : _this$_tokenValidator3.validateTokenLocally();
630
- case 9:
631
- _context7.t1 = _yield$this$_tokenVal = _context7.sent;
632
- _context7.t0 = _context7.t1 !== null;
633
- if (!_context7.t0) {
634
- _context7.next = 13;
635
- break;
636
- }
637
- _context7.t0 = _yield$this$_tokenVal !== void 0;
638
- case 13:
639
- if (!_context7.t0) {
640
- _context7.next = 17;
641
- break;
642
- }
643
- _context7.t2 = _yield$this$_tokenVal;
644
- _context7.next = 18;
645
- break;
646
- case 17:
647
- _context7.t2 = null;
648
- case 18:
649
- return _context7.abrupt("return", _context7.t2);
650
- case 21:
651
- _context7.prev = 21;
652
- _context7.t3 = _context7["catch"](2);
653
- return _context7.abrupt("return", this.forceTokenUpdate());
654
- case 24:
655
- case "end":
656
- return _context7.stop();
657
- }
658
- }, _callee7, this, [[2, 21]]);
659
- }));
660
- function requestToken() {
661
- return _requestToken.apply(this, arguments);
662
- }
663
- return requestToken;
664
- }()
665
- /**
666
- * Get new token in the background or redirect to the login page.
667
- * @return {Promise.<string>}
668
- */
669
- }, {
670
- key: "forceTokenUpdate",
671
- value: function () {
672
- var _forceTokenUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
673
- var _this4 = this;
674
- var _yield$this$_backgrou, _this$_backgroundFlow2, _this$_requestBuilder2, authRequest;
675
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
676
- while (1) switch (_context9.prev = _context9.next) {
677
- case 0:
678
- _context9.prev = 0;
679
- if (!this._backendCheckPromise) {
680
- this._backendCheckPromise = this._checkBackendsStatusesIfEnabled();
681
- }
682
- _context9.next = 4;
683
- return this._backendCheckPromise;
684
- case 4:
685
- _context9.next = 9;
686
- break;
687
- case 6:
688
- _context9.prev = 6;
689
- _context9.t0 = _context9["catch"](0);
690
- throw new Error('Cannot refresh token: backend is not available. Postponed by user.');
691
- case 9:
692
- _context9.prev = 9;
693
- this._backendCheckPromise = null;
694
- return _context9.finish(9);
695
- case 12:
696
- _context9.prev = 12;
697
- _context9.next = 15;
698
- return (_this$_backgroundFlow2 = this._backgroundFlow) === null || _this$_backgroundFlow2 === void 0 ? void 0 : _this$_backgroundFlow2.authorize();
699
- case 15:
700
- _context9.t2 = _yield$this$_backgrou = _context9.sent;
701
- _context9.t1 = _context9.t2 !== null;
702
- if (!_context9.t1) {
703
- _context9.next = 19;
704
- break;
705
- }
706
- _context9.t1 = _yield$this$_backgrou !== void 0;
707
- case 19:
708
- if (!_context9.t1) {
709
- _context9.next = 23;
710
- break;
711
- }
712
- _context9.t3 = _yield$this$_backgrou;
713
- _context9.next = 24;
714
- break;
715
- case 23:
716
- _context9.t3 = null;
717
- case 24:
718
- return _context9.abrupt("return", _context9.t3);
719
- case 27:
720
- _context9.prev = 27;
721
- _context9.t4 = _context9["catch"](12);
722
- if (_context9.t4 instanceof Error) {
723
- _context9.next = 31;
724
- break;
725
- }
726
- return _context9.abrupt("return", null);
727
- case 31:
728
- if (!this._canShowDialogs()) {
729
- _context9.next = 35;
730
- break;
731
- }
732
- return _context9.abrupt("return", new Promise(function (resolve) {
733
- var onTryAgain = /*#__PURE__*/function () {
734
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
735
- var _this4$_backgroundFlo, result;
736
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
737
- while (1) switch (_context8.prev = _context8.next) {
738
- case 0:
739
- _context8.prev = 0;
740
- _context8.next = 3;
741
- return (_this4$_backgroundFlo = _this4._backgroundFlow) === null || _this4$_backgroundFlo === void 0 ? void 0 : _this4$_backgroundFlo.authorize();
742
- case 3:
743
- result = _context8.sent;
744
- resolve(result !== null && result !== void 0 ? result : null);
745
- _context8.next = 11;
746
- break;
747
- case 7:
748
- _context8.prev = 7;
749
- _context8.t0 = _context8["catch"](0);
750
- if (_context8.t0 instanceof Error) {
751
- _this4._showAuthDialog({
752
- nonInteractive: true,
753
- error: _context8.t0,
754
- onTryAgain
755
- });
756
- }
757
- throw _context8.t0;
758
- case 11:
759
- case "end":
760
- return _context8.stop();
761
- }
762
- }, _callee8, null, [[0, 7]]);
763
- }));
764
- return function onTryAgain() {
765
- return _ref4.apply(this, arguments);
766
- };
767
- }();
768
- _this4._showAuthDialog({
769
- nonInteractive: true,
770
- error: _context9.t4,
771
- onTryAgain
772
- });
773
- }));
774
- case 35:
775
- _context9.next = 37;
776
- return (_this$_requestBuilder2 = this._requestBuilder) === null || _this$_requestBuilder2 === void 0 ? void 0 : _this$_requestBuilder2.prepareAuthRequest();
777
- case 37:
778
- authRequest = _context9.sent;
779
- if (authRequest != null) {
780
- this._redirectCurrentPage(authRequest.url);
781
- }
782
- case 39:
783
- throw new TokenValidator.TokenValidationError(_context9.t4.message);
784
- case 40:
785
- case "end":
786
- return _context9.stop();
787
- }
788
- }, _callee9, this, [[0, 6, 9, 12], [12, 27]]);
789
- }));
790
- function forceTokenUpdate() {
791
- return _forceTokenUpdate.apply(this, arguments);
792
- }
793
- return forceTokenUpdate;
794
- }()
795
- }, {
796
- key: "loadCurrentService",
797
- value: function () {
798
- var _loadCurrentService = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
799
- var _ref5, serviceName, serviceImage;
800
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
801
- while (1) switch (_context10.prev = _context10.next) {
802
- case 0:
803
- if (!this._service.serviceName) {
804
- _context10.next = 2;
805
- break;
806
- }
807
- return _context10.abrupt("return");
808
- case 2:
809
- _context10.prev = 2;
810
- _context10.next = 5;
811
- return this.http.get("oauth2/interactive/login/settings?client_id=".concat(this.config.clientId));
812
- case 5:
813
- _context10.t0 = _context10.sent;
814
- if (_context10.t0) {
815
- _context10.next = 8;
816
- break;
817
- }
818
- _context10.t0 = {};
819
- case 8:
820
- _ref5 = _context10.t0;
821
- serviceName = _ref5.serviceName;
822
- serviceImage = _ref5.iconUrl;
823
- this.setCurrentService({
824
- serviceImage,
825
- serviceName
826
- });
827
- _context10.next = 16;
828
- break;
829
- case 14:
830
- _context10.prev = 14;
831
- _context10.t1 = _context10["catch"](2);
832
- case 16:
833
- case "end":
834
- return _context10.stop();
835
- }
836
- }, _callee10, this, [[2, 14]]);
837
- }));
838
- function loadCurrentService() {
839
- return _loadCurrentService.apply(this, arguments);
840
- }
841
- return loadCurrentService;
842
- }()
843
- }, {
844
- key: "getAPIPath",
845
- value: function getAPIPath() {
846
- return this.config.serverUri + Auth.API_PATH;
847
- }
848
- /**
849
- * @return {Promise.<object>}
850
- */
851
- }, {
852
- key: "getUser",
853
- value: function getUser(accessToken) {
854
- var _this5 = this;
855
- if (this.config.cacheCurrentUser) {
856
- var _this$_storage6;
857
- return (_this$_storage6 = this._storage) === null || _this$_storage6 === void 0 ? void 0 : _this$_storage6.getCachedUser(function () {
858
- return _this5.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, _this5.config.userParams);
859
- });
860
- } else {
861
- return this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams);
862
- }
863
- }
864
- /**
865
- * @return {Promise.<object>}
866
- */
867
- }, {
868
- key: "requestUser",
869
- value: function () {
870
- var _requestUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
871
- var accessToken, user;
872
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
873
- while (1) switch (_context11.prev = _context11.next) {
874
- case 0:
875
- if (!this.user) {
876
- _context11.next = 2;
877
- break;
878
- }
879
- return _context11.abrupt("return", this.user);
880
- case 2:
881
- _context11.next = 4;
882
- return this.requestToken();
883
- case 4:
884
- accessToken = _context11.sent;
885
- if (!this.user) {
886
- _context11.next = 7;
887
- break;
888
- }
889
- return _context11.abrupt("return", this.user);
890
- case 7:
891
- _context11.next = 9;
892
- return this.getUser(accessToken);
893
- case 9:
894
- user = _context11.sent;
895
- this.user = user;
896
- return _context11.abrupt("return", user);
897
- case 12:
898
- case "end":
899
- return _context11.stop();
900
- }
901
- }, _callee11, this);
902
- }));
903
- function requestUser() {
904
- return _requestUser.apply(this, arguments);
905
- }
906
- return requestUser;
907
- }()
908
- }, {
909
- key: "updateUser",
910
- value: function () {
911
- var _updateUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
912
- var _this$_storage7;
913
- var accessToken, user;
914
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
915
- while (1) switch (_context12.prev = _context12.next) {
916
- case 0:
917
- this._setPostponed(false);
918
- _context12.next = 3;
919
- return this.requestToken();
920
- case 3:
921
- accessToken = _context12.sent;
922
- (_this$_storage7 = this._storage) === null || _this$_storage7 === void 0 ? void 0 : _this$_storage7.wipeCachedCurrentUser();
923
- _context12.next = 7;
924
- return this.getUser(accessToken);
925
- case 7:
926
- user = _context12.sent;
927
- this.user = user;
928
- this.listeners.trigger(USER_CHANGED_EVENT, user);
929
- case 10:
930
- case "end":
931
- return _context12.stop();
932
- }
933
- }, _callee12, this);
934
- }));
935
- function updateUser() {
936
- return _updateUser.apply(this, arguments);
937
- }
938
- return updateUser;
939
- }()
940
- }, {
941
- key: "_detectUserChange",
942
- value: function () {
943
- var _detectUserChange2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(accessToken) {
944
- var _this6 = this;
945
- var windowWasOpen, user, onApply;
946
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
947
- while (1) switch (_context13.prev = _context13.next) {
948
- case 0:
949
- windowWasOpen = this._isLoginWindowOpen;
950
- _context13.next = 3;
951
- return this.getUser(accessToken);
952
- case 3:
953
- user = _context13.sent;
954
- onApply = function onApply() {
955
- _this6.user = user;
956
- _this6.listeners.trigger(USER_CHANGED_EVENT, user);
957
- };
958
- if (!(user && this.user && this.user.id !== user.id)) {
959
- _context13.next = 14;
960
- break;
961
- }
962
- if (!(!this._canShowDialogs() || this.user.guest || windowWasOpen)) {
963
- _context13.next = 9;
964
- break;
965
- }
966
- onApply();
967
- return _context13.abrupt("return");
968
- case 9:
969
- if (!user.guest) {
970
- _context13.next = 12;
971
- break;
972
- }
973
- this._showAuthDialog({
974
- nonInteractive: true
975
- });
976
- return _context13.abrupt("return");
977
- case 12:
978
- _context13.next = 14;
979
- return this._showUserChangedDialog({
980
- newUser: user,
981
- onApply,
982
- onPostpone: function onPostpone() {
983
- _this6.listeners.trigger(USER_CHANGE_POSTPONED_EVENT);
984
- _this6.config.onPostponeChangedUser(_this6.user, user);
985
- }
986
- });
987
- case 14:
988
- case "end":
989
- return _context13.stop();
990
- }
991
- }, _callee13, this);
992
- }));
993
- function _detectUserChange(_x6) {
994
- return _detectUserChange2.apply(this, arguments);
995
- }
996
- return _detectUserChange;
997
- }()
998
- }, {
999
- key: "_beforeLogout",
1000
- value: function _beforeLogout(params) {
1001
- if (this._canShowDialogs()) {
1002
- this._showAuthDialog(params);
1003
- return;
1004
- }
1005
- this.logout();
1006
- }
1007
- }, {
1008
- key: "_showAuthDialog",
1009
- value: function _showAuthDialog() {
1010
- var _this$user2,
1011
- _this7 = this,
1012
- _this$_authDialogServ,
1013
- _this$_storage8,
1014
- _this$_storage9;
1015
- var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1016
- nonInteractive = _ref6.nonInteractive,
1017
- error = _ref6.error,
1018
- canCancel = _ref6.canCancel,
1019
- onTryAgain = _ref6.onTryAgain;
1020
- var _this$config2 = this.config,
1021
- embeddedLogin = _this$config2.embeddedLogin,
1022
- onPostponeLogout = _this$config2.onPostponeLogout,
1023
- translations = _this$config2.translations;
1024
- var cancelable = ((_this$user2 = this.user) === null || _this$user2 === void 0 ? void 0 : _this$user2.guest) || canCancel;
1025
- var actualTranslations = translations !== null && translations !== void 0 ? translations : getTranslations();
1026
- this._createInitDeferred();
1027
- var closeDialog = function closeDialog() {
1028
- /* eslint-disable @typescript-eslint/no-use-before-define */
1029
- stopTokenListening === null || stopTokenListening === void 0 ? void 0 : stopTokenListening();
1030
- stopMessageListening === null || stopMessageListening === void 0 ? void 0 : stopMessageListening();
1031
- hide === null || hide === void 0 ? void 0 : hide();
1032
- /* eslint-enable @typescript-eslint/no-use-before-define */
1033
- };
1034
-
1035
- var onConfirm = function onConfirm() {
1036
- if (!embeddedLogin) {
1037
- closeDialog();
1038
- _this7.logout();
1039
- return;
1040
- }
1041
- _this7._runEmbeddedLogin();
1042
- };
1043
- var onCancel = function onCancel() {
1044
- var _this7$_embeddedFlow, _this7$_storage, _this7$user;
1045
- (_this7$_embeddedFlow = _this7._embeddedFlow) === null || _this7$_embeddedFlow === void 0 ? void 0 : _this7$_embeddedFlow.stop();
1046
- (_this7$_storage = _this7._storage) === null || _this7$_storage === void 0 ? void 0 : _this7$_storage.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
1047
- closeDialog();
1048
- if (!cancelable) {
1049
- var _this7$_initDeferred, _this7$_initDeferred$;
1050
- (_this7$_initDeferred = _this7._initDeferred) === null || _this7$_initDeferred === void 0 || (_this7$_initDeferred$ = _this7$_initDeferred.resolve) === null || _this7$_initDeferred$ === void 0 ? void 0 : _this7$_initDeferred$.call(_this7$_initDeferred);
1051
- _this7.listeners.trigger(LOGOUT_POSTPONED_EVENT);
1052
- onPostponeLogout();
1053
- return;
1054
- }
1055
- if ((_this7$user = _this7.user) !== null && _this7$user !== void 0 && _this7$user.guest && nonInteractive) {
1056
- _this7.forceTokenUpdate();
1057
- } else {
1058
- var _this7$_initDeferred2, _this7$_initDeferred3;
1059
- (_this7$_initDeferred2 = _this7._initDeferred) === null || _this7$_initDeferred2 === void 0 || (_this7$_initDeferred3 = _this7$_initDeferred2.resolve) === null || _this7$_initDeferred3 === void 0 ? void 0 : _this7$_initDeferred3.call(_this7$_initDeferred2);
1060
- }
1061
- };
1062
- var onTryAgainClick = /*#__PURE__*/function () {
1063
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1064
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1065
- while (1) switch (_context14.prev = _context14.next) {
1066
- case 0:
1067
- _context14.next = 2;
1068
- return onTryAgain === null || onTryAgain === void 0 ? void 0 : onTryAgain();
1069
- case 2:
1070
- closeDialog();
1071
- case 3:
1072
- case "end":
1073
- return _context14.stop();
1074
- }
1075
- }, _callee14);
1076
- }));
1077
- return function onTryAgainClick() {
1078
- return _ref7.apply(this, arguments);
1079
- };
1080
- }();
1081
- var hide = (_this$_authDialogServ = this._authDialogService) === null || _this$_authDialogServ === void 0 ? void 0 : _this$_authDialogServ.call(this, _objectSpread2(_objectSpread2({}, this._service), {}, {
1082
- loginCaption: actualTranslations.login,
1083
- loginToCaption: actualTranslations.loginTo,
1084
- confirmLabel: actualTranslations.login,
1085
- tryAgainLabel: actualTranslations.tryAgainLabel,
1086
- cancelLabel: cancelable ? actualTranslations.cancel : actualTranslations.postpone,
1087
- errorMessage: this._extractErrorMessage(error, true),
1088
- onConfirm,
1089
- onCancel,
1090
- onTryAgain: onTryAgain ? onTryAgainClick : undefined
1091
- }));
1092
- var stopTokenListening = (_this$_storage8 = this._storage) === null || _this$_storage8 === void 0 ? void 0 : _this$_storage8.onTokenChange(function (token) {
1093
- if (token) {
1094
- var _this7$_initDeferred4, _this7$_initDeferred5;
1095
- closeDialog();
1096
- (_this7$_initDeferred4 = _this7._initDeferred) === null || _this7$_initDeferred4 === void 0 || (_this7$_initDeferred5 = _this7$_initDeferred4.resolve) === null || _this7$_initDeferred5 === void 0 ? void 0 : _this7$_initDeferred5.call(_this7$_initDeferred4);
1097
- }
1098
- });
1099
- var stopMessageListening = (_this$_storage9 = this._storage) === null || _this$_storage9 === void 0 ? void 0 : _this$_storage9.onMessage(Auth.CLOSE_WINDOW_MESSAGE, function () {
1100
- var _this7$_embeddedFlow2;
1101
- return (_this7$_embeddedFlow2 = _this7._embeddedFlow) === null || _this7$_embeddedFlow2 === void 0 ? void 0 : _this7$_embeddedFlow2.stop();
1102
- });
1103
- }
1104
- }, {
1105
- key: "_showUserChangedDialog",
1106
- value: function _showUserChangedDialog(_ref8) {
1107
- var _this8 = this,
1108
- _this$_authDialogServ2,
1109
- _translations$youHave,
1110
- _newUser$name,
1111
- _newUser$name2,
1112
- _translations$login,
1113
- _translations$loginTo,
1114
- _translations$applyCh,
1115
- _translations$tryAgai,
1116
- _translations$postpon;
1117
- var newUser = _ref8.newUser,
1118
- onApply = _ref8.onApply,
1119
- onPostpone = _ref8.onPostpone;
1120
- var translations = this.config.translations;
1121
- this._createInitDeferred();
1122
- var done = function done() {
1123
- var _this8$_initDeferred, _this8$_initDeferred$;
1124
- (_this8$_initDeferred = _this8._initDeferred) === null || _this8$_initDeferred === void 0 || (_this8$_initDeferred$ = _this8$_initDeferred.resolve) === null || _this8$_initDeferred$ === void 0 ? void 0 : _this8$_initDeferred$.call(_this8$_initDeferred);
1125
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
1126
- hide === null || hide === void 0 ? void 0 : hide();
1127
- };
1128
- var hide = (_this$_authDialogServ2 = this._authDialogService) === null || _this$_authDialogServ2 === void 0 ? void 0 : _this$_authDialogServ2.call(this, _objectSpread2(_objectSpread2({}, this._service), {}, {
1129
- title: (_translations$youHave = translations === null || translations === void 0 ? void 0 : translations.youHaveLoggedInAs) !== null && _translations$youHave !== void 0 ? _translations$youHave : translate('youHaveLoggedInAs').replace('%userName%', (_newUser$name = newUser.name) !== null && _newUser$name !== void 0 ? _newUser$name : '').replace('{{userName}}', (_newUser$name2 = newUser.name) !== null && _newUser$name2 !== void 0 ? _newUser$name2 : ''),
1130
- loginCaption: (_translations$login = translations === null || translations === void 0 ? void 0 : translations.login) !== null && _translations$login !== void 0 ? _translations$login : translate('login'),
1131
- loginToCaption: (_translations$loginTo = translations === null || translations === void 0 ? void 0 : translations.loginTo) !== null && _translations$loginTo !== void 0 ? _translations$loginTo : translate('loginTo'),
1132
- confirmLabel: (_translations$applyCh = translations === null || translations === void 0 ? void 0 : translations.applyChange) !== null && _translations$applyCh !== void 0 ? _translations$applyCh : translate('applyChange'),
1133
- tryAgainLabel: (_translations$tryAgai = translations === null || translations === void 0 ? void 0 : translations.tryAgainLabel) !== null && _translations$tryAgai !== void 0 ? _translations$tryAgai : translate('tryAgainLabel'),
1134
- cancelLabel: (_translations$postpon = translations === null || translations === void 0 ? void 0 : translations.postpone) !== null && _translations$postpon !== void 0 ? _translations$postpon : translate('postpone'),
1135
- onConfirm: function onConfirm() {
1136
- done();
1137
- onApply();
1138
- },
1139
- onCancel: function onCancel() {
1140
- done();
1141
- onPostpone();
1142
- }
1143
- }));
1144
- }
1145
- }, {
1146
- key: "_extractErrorMessage",
1147
- value: function _extractErrorMessage(error) {
1148
- var logError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1149
- if (!error) {
1150
- return null;
1151
- }
1152
- if (logError) {
1153
- // eslint-disable-next-line no-console
1154
- console.error('RingUI Auth error', error);
1155
- }
1156
- try {
1157
- // We've got some error from this list
1158
- // https://www.jetbrains.com/help/youtrack/devportal/OAuth-2.0-Errors.html
1159
- if ('code' in error && error.code && typeof error.code === 'object' && 'code' in error.code && typeof error.code.code === 'string') {
1160
- var readableCode = error.code.code.split('_').join(' ');
1161
- return "Authorization error: ".concat(readableCode);
1162
- }
1163
- } catch (_unused) {
1164
- // noop
1165
- }
1166
- return error.toString ? error.toString() : null;
1167
- }
1168
- }, {
1169
- key: "_showBackendDownDialog",
1170
- value: function _showBackendDownDialog(backendError) {
1171
- var _this9 = this;
1172
- var _this$config3 = this.config,
1173
- onBackendDown = _this$config3.onBackendDown,
1174
- translations = _this$config3.translations;
1175
- var REPEAT_TIMEOUT = 5000;
1176
- var timerId;
1177
- return new Promise(function (resolve, reject) {
1178
- var _this9$_storage2;
1179
- var done = function done() {
1180
- var _this9$_storage;
1181
- /* eslint-disable @typescript-eslint/no-use-before-define */
1182
- hide();
1183
- window.removeEventListener('online', onCheckAgain);
1184
- stopListeningCloseMessage === null || stopListeningCloseMessage === void 0 ? void 0 : stopListeningCloseMessage();
1185
- /* eslint-enable @typescript-eslint/no-use-before-define */
1186
- (_this9$_storage = _this9._storage) === null || _this9$_storage === void 0 ? void 0 : _this9$_storage.sendMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, Date.now());
1187
- clearTimeout(timerId);
1188
- };
1189
- var stopListeningCloseMessage = (_this9$_storage2 = _this9._storage) === null || _this9$_storage2 === void 0 ? void 0 : _this9$_storage2.onMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, function () {
1190
- stopListeningCloseMessage === null || stopListeningCloseMessage === void 0 ? void 0 : stopListeningCloseMessage();
1191
- done();
1192
- resolve();
1193
- });
1194
- var onCheckAgain = /*#__PURE__*/function () {
1195
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1196
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1197
- while (1) switch (_context15.prev = _context15.next) {
1198
- case 0:
1199
- _context15.next = 2;
1200
- return _this9._checkBackendsAreUp();
1201
- case 2:
1202
- done();
1203
- resolve();
1204
- case 4:
1205
- case "end":
1206
- return _context15.stop();
1207
- }
1208
- }, _callee15);
1209
- }));
1210
- return function onCheckAgain() {
1211
- return _ref9.apply(this, arguments);
1212
- };
1213
- }();
1214
- var onPostpone = function onPostpone() {
1215
- done();
1216
- reject(new Error('Auth(@jetbrains/ring-ui): postponed by user'));
1217
- };
1218
- var hide = onBackendDown({
1219
- onCheckAgain,
1220
- onPostpone,
1221
- backendError,
1222
- translations: translations !== null && translations !== void 0 ? translations : getTranslationsWithFallback()
1223
- });
1224
- window.addEventListener('online', onCheckAgain);
1225
- function networkWatchdog() {
1226
- if (navigator && navigator.onLine) {
1227
- onCheckAgain();
1228
- }
1229
- timerId = window.setTimeout(networkWatchdog, REPEAT_TIMEOUT);
1230
- }
1231
- timerId = window.setTimeout(networkWatchdog, REPEAT_TIMEOUT);
1232
- });
1233
- }
1234
- /**
1235
- * Wipe accessToken and redirect to auth page with required authorization
1236
- */
1237
- }, {
1238
- key: "logout",
1239
- value: function () {
1240
- var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(extraParams) {
1241
- var _this$_storage10, _this$_requestBuilder3;
1242
- var requestParams, authRequest;
1243
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1244
- while (1) switch (_context16.prev = _context16.next) {
1245
- case 0:
1246
- requestParams = _objectSpread2({
1247
- // eslint-disable-next-line camelcase
1248
- request_credentials: 'required'
1249
- }, extraParams);
1250
- _context16.next = 3;
1251
- return this._checkBackendsStatusesIfEnabled();
1252
- case 3:
1253
- _context16.next = 5;
1254
- return this.listeners.trigger('logout');
1255
- case 5:
1256
- this._updateDomainUser(null);
1257
- _context16.next = 8;
1258
- return (_this$_storage10 = this._storage) === null || _this$_storage10 === void 0 ? void 0 : _this$_storage10.wipeToken();
1259
- case 8:
1260
- _context16.next = 10;
1261
- return (_this$_requestBuilder3 = this._requestBuilder) === null || _this$_requestBuilder3 === void 0 ? void 0 : _this$_requestBuilder3.prepareAuthRequest(requestParams);
1262
- case 10:
1263
- authRequest = _context16.sent;
1264
- if (authRequest != null) {
1265
- this._redirectCurrentPage(authRequest.url);
1266
- }
1267
- case 12:
1268
- case "end":
1269
- return _context16.stop();
1270
- }
1271
- }, _callee16, this);
1272
- }));
1273
- function logout(_x7) {
1274
- return _logout.apply(this, arguments);
1275
- }
1276
- return logout;
1277
- }()
1278
- }, {
1279
- key: "_runEmbeddedLogin",
1280
- value: function () {
1281
- var _runEmbeddedLogin2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1282
- var _this$_storage11;
1283
- var _this$_embeddedFlow;
1284
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1285
- while (1) switch (_context17.prev = _context17.next) {
1286
- case 0:
1287
- (_this$_storage11 = this._storage) === null || _this$_storage11 === void 0 ? void 0 : _this$_storage11.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
1288
- _context17.prev = 1;
1289
- this._isLoginWindowOpen = true;
1290
- _context17.next = 5;
1291
- return (_this$_embeddedFlow = this._embeddedFlow) === null || _this$_embeddedFlow === void 0 ? void 0 : _this$_embeddedFlow.authorize();
1292
- case 5:
1293
- return _context17.abrupt("return", _context17.sent);
1294
- case 8:
1295
- _context17.prev = 8;
1296
- _context17.t0 = _context17["catch"](1);
1297
- throw _context17.t0;
1298
- case 11:
1299
- _context17.prev = 11;
1300
- this._isLoginWindowOpen = false;
1301
- return _context17.finish(11);
1302
- case 14:
1303
- case "end":
1304
- return _context17.stop();
1305
- }
1306
- }, _callee17, this, [[1, 8, 11, 14]]);
1307
- }));
1308
- function _runEmbeddedLogin() {
1309
- return _runEmbeddedLogin2.apply(this, arguments);
1310
- }
1311
- return _runEmbeddedLogin;
1312
- }()
1313
- /**
1314
- * Wipe accessToken and redirect to auth page to obtain authorization data
1315
- * if user is logged in or log her in otherwise
1316
- */
1317
- }, {
1318
- key: "login",
1319
- value: function () {
1320
- var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1321
- var _this$_backgroundFlow3, accessToken, _user;
1322
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1323
- while (1) switch (_context18.prev = _context18.next) {
1324
- case 0:
1325
- if (!this.config.embeddedLogin) {
1326
- _context18.next = 4;
1327
- break;
1328
- }
1329
- _context18.next = 3;
1330
- return this._runEmbeddedLogin();
1331
- case 3:
1332
- return _context18.abrupt("return");
1333
- case 4:
1334
- _context18.next = 6;
1335
- return this._checkBackendsStatusesIfEnabled();
1336
- case 6:
1337
- _context18.prev = 6;
1338
- _context18.next = 9;
1339
- return (_this$_backgroundFlow3 = this._backgroundFlow) === null || _this$_backgroundFlow3 === void 0 ? void 0 : _this$_backgroundFlow3.authorize();
1340
- case 9:
1341
- accessToken = _context18.sent;
1342
- _context18.next = 12;
1343
- return this.getUser(accessToken);
1344
- case 12:
1345
- _user = _context18.sent;
1346
- if (_user.guest) {
1347
- this._beforeLogout();
1348
- } else {
1349
- this.user = _user;
1350
- this.listeners.trigger(USER_CHANGED_EVENT, _user);
1351
- }
1352
- _context18.next = 19;
1353
- break;
1354
- case 16:
1355
- _context18.prev = 16;
1356
- _context18.t0 = _context18["catch"](6);
1357
- this._beforeLogout();
1358
- case 19:
1359
- case "end":
1360
- return _context18.stop();
1361
- }
1362
- }, _callee18, this, [[6, 16]]);
1363
- }));
1364
- function login() {
1365
- return _login.apply(this, arguments);
1366
- }
1367
- return login;
1368
- }()
1369
- }, {
1370
- key: "switchUser",
1371
- value: function () {
1372
- var _switchUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1373
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1374
- while (1) switch (_context19.prev = _context19.next) {
1375
- case 0:
1376
- if (this.config.embeddedLogin) {
1377
- _context19.next = 2;
1378
- break;
1379
- }
1380
- throw new Error('Auth: switchUser only supported for "embeddedLogin" mode');
1381
- case 2:
1382
- _context19.next = 4;
1383
- return this._runEmbeddedLogin();
1384
- case 4:
1385
- case "end":
1386
- return _context19.stop();
1387
- }
1388
- }, _callee19, this);
1389
- }));
1390
- function switchUser() {
1391
- return _switchUser.apply(this, arguments);
1392
- }
1393
- return switchUser;
1394
- }()
1395
- }, {
1396
- key: "_makeStateFromResponse",
1397
- value: function _makeStateFromResponse(authResponse) {
1398
- var state = authResponse.state;
1399
- if (!state) {
1400
- return {};
1401
- }
1402
- var defaultScope = this.config.scope;
1403
- try {
1404
- var urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
1405
- if (urlFromState.origin !== window.location.origin) {
1406
- return {};
1407
- }
1408
- return {
1409
- restoreLocation: state,
1410
- created: Date.now(),
1411
- scopes: defaultScope
1412
- };
1413
- } catch (e) {
1414
- return {};
1415
- }
1416
- }
1417
- /**
1418
- * Check if the hash contains an access token.
1419
- * If it does, extract the state, compare with
1420
- * config, and store the auth response for later use.
1421
- *
1422
- * @return {Promise} promise that is resolved to restoreLocation URL, or rejected
1423
- * @private
1424
- */
1425
- }, {
1426
- key: "_checkForAuthResponse",
1427
- value: function () {
1428
- var _checkForAuthResponse2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1429
- var _this$_storage12;
1430
- var authResponse, _this$config4, defaultScope, defaultExpiresIn, cleanHash, stateId, scope, expiresIn, accessToken, newState, scopes, effectiveExpiresIn, expires, _this$_storage13;
1431
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1432
- while (1) switch (_context20.prev = _context20.next) {
1433
- case 0:
1434
- // getAuthResponseURL may throw an exception
1435
- authResponse = this._responseParser.getAuthResponseFromURL();
1436
- _this$config4 = this.config, defaultScope = _this$config4.scope, defaultExpiresIn = _this$config4.defaultExpiresIn, cleanHash = _this$config4.cleanHash;
1437
- if (authResponse && cleanHash) {
1438
- this.setHash('');
1439
- }
1440
- if (authResponse) {
1441
- _context20.next = 5;
1442
- break;
1443
- }
1444
- return _context20.abrupt("return", undefined);
1445
- case 5:
1446
- stateId = authResponse.state, scope = authResponse.scope, expiresIn = authResponse.expiresIn, accessToken = authResponse.accessToken;
1447
- _context20.next = 8;
1448
- return stateId && ((_this$_storage12 = this._storage) === null || _this$_storage12 === void 0 ? void 0 : _this$_storage12.getState(stateId));
1449
- case 8:
1450
- _context20.t0 = _context20.sent;
1451
- if (_context20.t0) {
1452
- _context20.next = 11;
1453
- break;
1454
- }
1455
- _context20.t0 = this._makeStateFromResponse(authResponse);
1456
- case 11:
1457
- newState = _context20.t0;
1458
- scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
1459
- effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
1460
- expires = TokenValidator._epoch() + effectiveExpiresIn;
1461
- if (!(accessToken != null)) {
1462
- _context20.next = 18;
1463
- break;
1464
- }
1465
- _context20.next = 18;
1466
- return (_this$_storage13 = this._storage) === null || _this$_storage13 === void 0 ? void 0 : _this$_storage13.saveToken({
1467
- accessToken,
1468
- scopes,
1469
- expires,
1470
- lifeTime: effectiveExpiresIn
1471
- });
1472
- case 18:
1473
- return _context20.abrupt("return", newState);
1474
- case 19:
1475
- case "end":
1476
- return _context20.stop();
1477
- }
1478
- }, _callee20, this);
1479
- }));
1480
- function _checkForAuthResponse() {
1481
- return _checkForAuthResponse2.apply(this, arguments);
1482
- }
1483
- return _checkForAuthResponse;
1484
- }()
1485
- }, {
1486
- key: "_checkForStateRestoration",
1487
- value: function () {
1488
- var _checkForStateRestoration2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1489
- var _this$_storage14;
1490
- var authResponse, stateId;
1491
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1492
- while (1) switch (_context21.prev = _context21.next) {
1493
- case 0:
1494
- authResponse = this._responseParser._authResponse;
1495
- if (authResponse && this.config.cleanHash) {
1496
- this.setHash('');
1497
- }
1498
- stateId = authResponse === null || authResponse === void 0 ? void 0 : authResponse.restoreAuthState;
1499
- _context21.next = 5;
1500
- return stateId && ((_this$_storage14 = this._storage) === null || _this$_storage14 === void 0 ? void 0 : _this$_storage14.getState(stateId));
1501
- case 5:
1502
- _context21.t0 = _context21.sent;
1503
- if (_context21.t0) {
1504
- _context21.next = 8;
1505
- break;
1506
- }
1507
- _context21.t0 = {};
1508
- case 8:
1509
- return _context21.abrupt("return", _context21.t0);
1510
- case 9:
1511
- case "end":
1512
- return _context21.stop();
1513
- }
1514
- }, _callee21, this);
1515
- }));
1516
- function _checkForStateRestoration() {
1517
- return _checkForStateRestoration2.apply(this, arguments);
1518
- }
1519
- return _checkForStateRestoration;
1520
- }()
1521
- }, {
1522
- key: "_checkBackendsAreUp",
1523
- value: function _checkBackendsAreUp() {
1524
- var abortCtrl = new AbortController();
1525
- var backendCheckTimeout = this.config.backendCheckTimeout;
1526
- return Promise.all([promiseWithTimeout(this.http.fetch('settings/public?fields=id', {
1527
- signal: abortCtrl.signal
1528
- }), backendCheckTimeout, {
1529
- error: new Error('The authorization server is taking too long to respond. Please try again later.'),
1530
- onTimeout: function onTimeout() {
1531
- return abortCtrl.abort();
1532
- }
1533
- }), this.config.checkBackendIsUp()]).catch(function (err) {
1534
- if (err instanceof TypeError) {
1535
- throw new TypeError('Could not connect to the server due to network error. Please check your connection and try again.');
1536
- }
1537
- throw err;
1538
- });
1539
- }
1540
- }, {
1541
- key: "_checkBackendsStatusesIfEnabled",
1542
- value: function () {
1543
- var _checkBackendsStatusesIfEnabled2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1544
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1545
- while (1) switch (_context22.prev = _context22.next) {
1546
- case 0:
1547
- if (this.config.enableBackendStatusCheck) {
1548
- _context22.next = 2;
1549
- break;
1550
- }
1551
- return _context22.abrupt("return");
1552
- case 2:
1553
- _context22.prev = 2;
1554
- _context22.next = 5;
1555
- return this._checkBackendsAreUp();
1556
- case 5:
1557
- _context22.next = 12;
1558
- break;
1559
- case 7:
1560
- _context22.prev = 7;
1561
- _context22.t0 = _context22["catch"](2);
1562
- if (!(_context22.t0 instanceof Error)) {
1563
- _context22.next = 12;
1564
- break;
1565
- }
1566
- _context22.next = 12;
1567
- return this._showBackendDownDialog(_context22.t0);
1568
- case 12:
1569
- case "end":
1570
- return _context22.stop();
1571
- }
1572
- }, _callee22, this, [[2, 7]]);
1573
- }));
1574
- function _checkBackendsStatusesIfEnabled() {
1575
- return _checkBackendsStatusesIfEnabled2.apply(this, arguments);
1576
- }
1577
- return _checkBackendsStatusesIfEnabled;
1578
- }()
1579
- /**
1580
- * Adds preconnect tag to help browser to establish connection to URL.
1581
- * See https://w3c.github.io/resource-hints/
1582
- * @param url Url to preconnect to.
1583
- */
1584
- }, {
1585
- key: "setUpPreconnect",
1586
- value: function setUpPreconnect(url) {
1587
- var linkNode = document.createElement('link');
1588
- linkNode.rel = 'preconnect';
1589
- linkNode.href = url;
1590
- linkNode.pr = '1.0';
1591
- linkNode.crossOrigin = 'use-credentials';
1592
- document.head.appendChild(linkNode);
1593
- }
1594
- /**
1595
- * Redirects current page to the given URL
1596
- * @param {string} url
1597
- * @private
1598
- */
1599
- }, {
1600
- key: "_redirectCurrentPage",
1601
- value: function _redirectCurrentPage(url) {
1602
- {
1603
- window.location.href = fixUrl(url);
1604
- }
1605
- }
1606
- /**
1607
- * Reloads current page
1608
- */
1609
- }, {
1610
- key: "_reloadCurrentPage",
1611
- value: function _reloadCurrentPage() {
1612
- this._redirectCurrentPage(window.location.href);
1613
- }
1614
- }, {
1615
- key: "_canShowDialogs",
1616
- value: function _canShowDialogs() {
1617
- return this.config.embeddedLogin && this._authDialogService;
1618
- }
1619
- /**
1620
- * Sets the location hash
1621
- * @param {string} hash
1622
- */
1623
- }, {
1624
- key: "setHash",
1625
- value: function setHash(hash) {
1626
- if (history.replaceState) {
1627
- // NB! History.replaceState is used here, because Firefox saves
1628
- // a record in history.
1629
- // NB! URL to redirect is formed manually because baseURI could be messed up,
1630
- // in which case it's not obvious where redirect will lead.
1631
- var cleanedUrl = [window.location.pathname, window.location.search].join('');
1632
- var hashIfExist = hash ? "#".concat(hash) : '';
1633
- history.replaceState(undefined, '', "".concat(cleanedUrl).concat(hashIfExist));
1634
- } else {
1635
- window.location.hash = hash;
1636
- }
1637
- }
1638
- }]);
1639
- return Auth;
1640
- }();
1641
- _defineProperty(Auth, "DEFAULT_CONFIG", DEFAULT_CONFIG);
1642
- _defineProperty(Auth, "API_PATH", 'api/rest/');
1643
- _defineProperty(Auth, "API_AUTH_PATH", 'oauth2/auth');
1644
- _defineProperty(Auth, "API_PROFILE_PATH", 'users/me');
1645
- _defineProperty(Auth, "CLOSE_BACKEND_DOWN_MESSAGE", 'backend-check-succeeded');
1646
- _defineProperty(Auth, "CLOSE_WINDOW_MESSAGE", 'close-login-window');
1647
- _defineProperty(Auth, "shouldRefreshToken", TokenValidator.shouldRefreshToken);
1648
- _defineProperty(Auth, "storageIsUnavailable", !navigator.cookieEnabled);
1649
-
1650
- 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 };