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