@jetbrains/ring-ui 4.1.4 → 5.0.0-beta.1

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