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

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