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