@jetbrains/ring-ui 5.0.148 → 5.0.149
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/select/select.js +1 -1
- package/dist/_helpers/card.js +5 -5
- package/dist/analytics/analytics__custom-plugin.js +2 -6
- package/dist/analytics/analytics__ga-plugin.js +1 -2
- package/dist/auth/auth__core.js +63 -100
- package/dist/auth/iframe-flow.js +1 -2
- package/dist/auth/landing.js +1 -2
- package/dist/auth/request-builder.js +1 -2
- package/dist/auth/token-validator.js +2 -6
- package/dist/auth/window-flow.js +2 -4
- package/dist/caret/caret.js +13 -16
- package/dist/clipboard/clipboard-fallback.js +3 -3
- package/dist/data-list/data-list.js +3 -6
- package/dist/data-list/item.js +1 -1
- package/dist/date-picker/date-input.js +5 -6
- package/dist/date-picker/date-picker.js +6 -7
- package/dist/date-picker/date-popup.js +2 -3
- package/dist/dialog-ng/dialog-ng.js +2 -3
- package/dist/dropdown/dropdown.js +2 -4
- package/dist/editable-heading/editable-heading.js +2 -2
- package/dist/global/focus-sensor-hoc.js +8 -13
- package/dist/global/normalize-indent.js +2 -2
- package/dist/global/react-render-adapter.js +1 -4
- package/dist/global/rerender-hoc.js +1 -2
- package/dist/global/schedule-raf.js +1 -2
- package/dist/header/profile.js +6 -6
- package/dist/header/smart-profile.js +2 -3
- package/dist/header/smart-services.js +3 -6
- package/dist/http/http.js +7 -13
- package/dist/hub-source/hub-source__user.js +2 -3
- package/dist/input/input.js +4 -7
- package/dist/island/content.js +1 -2
- package/dist/list/list__users-groups-source.js +7 -10
- package/dist/loader/loader.js +1 -2
- package/dist/loader/loader__core.js +1 -2
- package/dist/markdown/code.js +2 -3
- package/dist/message/message.js +6 -8
- package/dist/pager/pager.js +12 -16
- package/dist/permissions/permissions__cache.js +1 -1
- package/dist/popup/popup.js +1 -2
- package/dist/popup/position.js +1 -1
- package/dist/query-assist/query-assist.js +34 -46
- package/dist/select/select.js +11 -18
- package/dist/select/select__popup.js +3 -10
- package/dist/select-ng/select-ng.js +1 -2
- package/dist/select-ng/select-ng__lazy.js +1 -2
- package/dist/shortcuts/core.js +1 -2
- package/dist/tab-trap/tab-trap.js +2 -4
- package/dist/table/header.js +2 -2
- package/dist/table/multitable.js +7 -14
- package/dist/table/row-with-focus-sensor.js +4 -8
- package/dist/table/selection-shortcuts-hoc.js +11 -11
- package/dist/tabs/collapsible-tabs.js +1 -1
- package/dist/tag/tag.js +1 -2
- package/dist/tags-input/tags-input.js +13 -23
- package/dist/tooltip/tooltip.js +2 -4
- package/dist/user-agreement/user-agreement.js +8 -8
- package/package.json +27 -27
|
@@ -442,7 +442,7 @@ export default class Select extends Component {
|
|
|
442
442
|
}
|
|
443
443
|
const shownData = this.getListItems(this.filterValue());
|
|
444
444
|
this.setState({
|
|
445
|
-
showPopup: !!shownData.length || this.
|
|
445
|
+
showPopup: !!shownData.length || !this.props.allowAny,
|
|
446
446
|
shownData
|
|
447
447
|
});
|
|
448
448
|
}
|
package/dist/_helpers/card.js
CHANGED
|
@@ -48,7 +48,7 @@ class UserCard extends PureComponent {
|
|
|
48
48
|
translate
|
|
49
49
|
} = this.context;
|
|
50
50
|
const wording = this.props.translations || this.props.wording;
|
|
51
|
-
clipboard.copyText(this.props.user.email || '', (_wording$copiedToClip = wording
|
|
51
|
+
clipboard.copyText(this.props.user.email || '', (_wording$copiedToClip = wording?.copiedToClipboard) !== null && _wording$copiedToClip !== void 0 ? _wording$copiedToClip : translate('copyToClipboard'), (_wording$copingToClip = wording?.copingToClipboardError) !== null && _wording$copingToClip !== void 0 ? _wording$copingToClip : translate('copingToClipboardError'));
|
|
52
52
|
};
|
|
53
53
|
render() {
|
|
54
54
|
var _wording$online, _wording$offline, _wording$banned, _wording$unverified, _wording$copyToClipbo;
|
|
@@ -89,13 +89,13 @@ class UserCard extends PureComponent {
|
|
|
89
89
|
className: modules_a4196c17.userName
|
|
90
90
|
}, user.name), typeof user.online === 'boolean' && /*#__PURE__*/React.createElement("span", {
|
|
91
91
|
className: userActiveStatusClasses,
|
|
92
|
-
title: user.online ? (_wording$online = wording
|
|
92
|
+
title: user.online ? (_wording$online = wording?.online) !== null && _wording$online !== void 0 ? _wording$online : translate('online') : (_wording$offline = wording?.offline) !== null && _wording$offline !== void 0 ? _wording$offline : translate('offline')
|
|
93
93
|
}), !!info && /*#__PURE__*/React.createElement("span", {
|
|
94
94
|
className: modules_a4196c17.userNameInfo
|
|
95
95
|
}, info), user.banned && /*#__PURE__*/React.createElement("span", {
|
|
96
96
|
className: classNames(modules_6c9187df.badge, modules_6c9187df.invalid),
|
|
97
97
|
title: user.banReason
|
|
98
|
-
}, (_wording$banned = wording
|
|
98
|
+
}, (_wording$banned = wording?.banned) !== null && _wording$banned !== void 0 ? _wording$banned : translate('banned'))), /*#__PURE__*/React.createElement("div", {
|
|
99
99
|
className: modules_a4196c17.userLogin
|
|
100
100
|
}, user.login), user.email && /*#__PURE__*/React.createElement("span", {
|
|
101
101
|
className: modules_a4196c17.userEmailWrapper
|
|
@@ -106,8 +106,8 @@ class UserCard extends PureComponent {
|
|
|
106
106
|
className: modules_a4196c17.userEmail
|
|
107
107
|
}, user.email), user.unverifiedEmail && /*#__PURE__*/React.createElement("span", {
|
|
108
108
|
className: modules_a4196c17.unverifiedLabel
|
|
109
|
-
}, (_wording$unverified = wording
|
|
110
|
-
title: (_wording$copyToClipbo = wording
|
|
109
|
+
}, (_wording$unverified = wording?.unverified) !== null && _wording$unverified !== void 0 ? _wording$unverified : translate('unverified')), /*#__PURE__*/React.createElement(Icon, {
|
|
110
|
+
title: (_wording$copyToClipbo = wording?.copyToClipboard) !== null && _wording$copyToClipbo !== void 0 ? _wording$copyToClipbo : translate('copyToClipboard'),
|
|
111
111
|
className: modules_a4196c17.userCopyIcon,
|
|
112
112
|
onClick: this.copyEmail,
|
|
113
113
|
glyph: copyIcon,
|
|
@@ -33,10 +33,7 @@ class AnalyticsCustomPlugin {
|
|
|
33
33
|
this._processEvent('page', 'view', data);
|
|
34
34
|
}
|
|
35
35
|
_initSendSchedule() {
|
|
36
|
-
window.addEventListener('beforeunload', () =>
|
|
37
|
-
var _this$_flush;
|
|
38
|
-
return (_this$_flush = this._flush) === null || _this$_flush === void 0 ? void 0 : _this$_flush.call(this);
|
|
39
|
-
});
|
|
36
|
+
window.addEventListener('beforeunload', () => this._flush?.());
|
|
40
37
|
if (this._flush != null) {
|
|
41
38
|
setInterval(this._flush, this._flushInterval);
|
|
42
39
|
}
|
|
@@ -63,8 +60,7 @@ class AnalyticsCustomPlugin {
|
|
|
63
60
|
_addDataToFlushingPack(sendingData) {
|
|
64
61
|
this._data.push(sendingData);
|
|
65
62
|
if (this._flushMaxPackSize != null && this._data.length >= this._flushMaxPackSize) {
|
|
66
|
-
|
|
67
|
-
(_this$_flush2 = this._flush) === null || _this$_flush2 === void 0 ? void 0 : _this$_flush2.call(this);
|
|
63
|
+
this._flush?.();
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
get serializeAdditionalInfo() {
|
|
@@ -14,7 +14,6 @@ class AnalyticsGAPlugin {
|
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
((i, s, o, g, r) => {
|
|
17
|
-
var _m$parentNode;
|
|
18
17
|
i.GoogleAnalyticsObject = r;
|
|
19
18
|
i[r] = i[r] || function addArgumentsToQueueForWaitingTheScriptLoading() {
|
|
20
19
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -27,7 +26,7 @@ class AnalyticsGAPlugin {
|
|
|
27
26
|
const m = s.getElementsByTagName(o)[0];
|
|
28
27
|
a.async = true;
|
|
29
28
|
a.src = g;
|
|
30
|
-
|
|
29
|
+
m.parentNode?.insertBefore(a, m);
|
|
31
30
|
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
|
32
31
|
/**
|
|
33
32
|
* UA-57284711-1 - ga key for development purpose
|
package/dist/auth/auth__core.js
CHANGED
|
@@ -208,14 +208,8 @@ class Auth {
|
|
|
208
208
|
}
|
|
209
209
|
});
|
|
210
210
|
if (this.config.cacheCurrentUser) {
|
|
211
|
-
this.addListener(LOGOUT_EVENT, () =>
|
|
212
|
-
|
|
213
|
-
return (_this$_storage = this._storage) === null || _this$_storage === void 0 ? void 0 : _this$_storage.wipeCachedCurrentUser();
|
|
214
|
-
});
|
|
215
|
-
this.addListener(USER_CHANGED_EVENT, () => {
|
|
216
|
-
var _this$_storage2;
|
|
217
|
-
return (_this$_storage2 = this._storage) === null || _this$_storage2 === void 0 ? void 0 : _this$_storage2.onUserChanged();
|
|
218
|
-
});
|
|
211
|
+
this.addListener(LOGOUT_EVENT, () => this._storage?.wipeCachedCurrentUser());
|
|
212
|
+
this.addListener(USER_CHANGED_EVENT, () => this._storage?.onUserChanged());
|
|
219
213
|
}
|
|
220
214
|
this._createInitDeferred();
|
|
221
215
|
this.setUpPreconnect(config.serverUri);
|
|
@@ -255,8 +249,7 @@ class Auth {
|
|
|
255
249
|
* that should be restored after returning back from auth server.
|
|
256
250
|
*/
|
|
257
251
|
async init() {
|
|
258
|
-
|
|
259
|
-
(_this$_storage3 = this._storage) === null || _this$_storage3 === void 0 ? void 0 : _this$_storage3.onTokenChange(async token => {
|
|
252
|
+
this._storage?.onTokenChange(async token => {
|
|
260
253
|
const isGuest = this.user ? this.user.guest : false;
|
|
261
254
|
if (isGuest && !token) {
|
|
262
255
|
return;
|
|
@@ -304,18 +297,16 @@ class Auth {
|
|
|
304
297
|
return new Promise(noop);
|
|
305
298
|
}
|
|
306
299
|
try {
|
|
307
|
-
var _this$_tokenValidator, _this$_initDeferred, _this$_initDeferred$r, _state;
|
|
308
300
|
// Check if there is a valid token
|
|
309
|
-
await
|
|
301
|
+
await this._tokenValidator?.validateToken();
|
|
310
302
|
// Checking if there is a message left by another app on this domain
|
|
311
303
|
const message = await this._domainStorage._messagesStorage.get(`domain-message-${DOMAIN_USER_CHANGED_EVENT}`);
|
|
312
304
|
if (message) {
|
|
313
|
-
var _this$user;
|
|
314
305
|
const {
|
|
315
306
|
userID,
|
|
316
307
|
serviceID
|
|
317
308
|
} = message;
|
|
318
|
-
if (serviceID !== this.config.clientId && (!userID ||
|
|
309
|
+
if (serviceID !== this.config.clientId && (!userID || this.user?.id !== userID)) {
|
|
319
310
|
this.forceTokenUpdate();
|
|
320
311
|
}
|
|
321
312
|
}
|
|
@@ -325,12 +316,11 @@ class Auth {
|
|
|
325
316
|
// Check if we have requested to restore state anyway
|
|
326
317
|
state = await this._checkForStateRestoration();
|
|
327
318
|
}
|
|
328
|
-
|
|
329
|
-
return
|
|
319
|
+
this._initDeferred?.resolve?.(state && state.restoreLocation);
|
|
320
|
+
return state?.restoreLocation;
|
|
330
321
|
} catch (error) {
|
|
331
322
|
if (Auth.storageIsUnavailable) {
|
|
332
|
-
|
|
333
|
-
(_this$_initDeferred2 = this._initDeferred) === null || _this$_initDeferred2 === void 0 ? void 0 : (_this$_initDeferred2$ = _this$_initDeferred2.resolve) === null || _this$_initDeferred2$ === void 0 ? void 0 : _this$_initDeferred2$.call(_this$_initDeferred2); // No way to handle if cookies are disabled
|
|
323
|
+
this._initDeferred?.resolve?.(); // No way to handle if cookies are disabled
|
|
334
324
|
await this.requestUser(); // Someone may expect user to be loaded as a part of token validation
|
|
335
325
|
return null;
|
|
336
326
|
}
|
|
@@ -338,8 +328,7 @@ class Auth {
|
|
|
338
328
|
}
|
|
339
329
|
}
|
|
340
330
|
async sendRedirect(error) {
|
|
341
|
-
|
|
342
|
-
const authRequest = await ((_this$_requestBuilder = this._requestBuilder) === null || _this$_requestBuilder === void 0 ? void 0 : _this$_requestBuilder.prepareAuthRequest());
|
|
331
|
+
const authRequest = await this._requestBuilder?.prepareAuthRequest();
|
|
343
332
|
if (authRequest != null) {
|
|
344
333
|
this._redirectCurrentPage(authRequest.url);
|
|
345
334
|
}
|
|
@@ -352,12 +341,10 @@ class Auth {
|
|
|
352
341
|
async handleInitError(error) {
|
|
353
342
|
if ('stateId' in error && error.stateId) {
|
|
354
343
|
try {
|
|
355
|
-
|
|
356
|
-
const state = await ((_this$_storage4 = this._storage) === null || _this$_storage4 === void 0 ? void 0 : _this$_storage4.getState(error.stateId));
|
|
344
|
+
const state = await this._storage?.getState(error.stateId);
|
|
357
345
|
if (state && state.nonRedirect) {
|
|
358
|
-
var _this$_storage5;
|
|
359
346
|
state.error = error;
|
|
360
|
-
|
|
347
|
+
this._storage?.saveState(error.stateId, state);
|
|
361
348
|
// Return endless promise in the background to avoid service start
|
|
362
349
|
return new Promise(noop);
|
|
363
350
|
}
|
|
@@ -368,8 +355,7 @@ class Auth {
|
|
|
368
355
|
throw error;
|
|
369
356
|
}
|
|
370
357
|
async handleInitValidationError(error) {
|
|
371
|
-
|
|
372
|
-
if ('cause' in error && error.cause instanceof Error && ((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.message) === 'invalid_client') {
|
|
358
|
+
if ('cause' in error && error.cause instanceof Error && error.cause?.message === 'invalid_client') {
|
|
373
359
|
// eslint-disable-next-line no-console
|
|
374
360
|
console.error('RingUI Auth: invalid client detected. Logging out', error);
|
|
375
361
|
await this.logout();
|
|
@@ -382,17 +368,16 @@ class Auth {
|
|
|
382
368
|
// Background flow
|
|
383
369
|
if ('authRedirect' in error && error.authRedirect && !this.config.redirect) {
|
|
384
370
|
try {
|
|
385
|
-
|
|
386
|
-
await
|
|
387
|
-
|
|
388
|
-
(_this$_initDeferred3 = this._initDeferred) === null || _this$_initDeferred3 === void 0 ? void 0 : (_this$_initDeferred3$ = _this$_initDeferred3.resolve) === null || _this$_initDeferred3$ === void 0 ? void 0 : _this$_initDeferred3$.call(_this$_initDeferred3);
|
|
371
|
+
await this._backgroundFlow?.authorize();
|
|
372
|
+
await this._tokenValidator?.validateToken();
|
|
373
|
+
this._initDeferred?.resolve?.();
|
|
389
374
|
return undefined;
|
|
390
375
|
} catch (validationError) {
|
|
391
376
|
// Fallback to redirect flow
|
|
392
377
|
return validationError instanceof Error ? this.sendRedirect(validationError) : undefined;
|
|
393
378
|
}
|
|
394
379
|
}
|
|
395
|
-
|
|
380
|
+
this._initDeferred?.reject?.(error);
|
|
396
381
|
throw error;
|
|
397
382
|
}
|
|
398
383
|
/**
|
|
@@ -405,13 +390,13 @@ class Auth {
|
|
|
405
390
|
throw new Error('You should log in to be able to make requests');
|
|
406
391
|
}
|
|
407
392
|
try {
|
|
408
|
-
var
|
|
409
|
-
await
|
|
393
|
+
var _await$this$_tokenVal;
|
|
394
|
+
await this._initDeferred?.promise;
|
|
410
395
|
if (Auth.storageIsUnavailable) {
|
|
411
396
|
return null; // Forever guest if storage is unavailable
|
|
412
397
|
}
|
|
413
398
|
|
|
414
|
-
return (_await$this$_tokenVal = await
|
|
399
|
+
return (_await$this$_tokenVal = await this._tokenValidator?.validateTokenLocally()) !== null && _await$this$_tokenVal !== void 0 ? _await$this$_tokenVal : null;
|
|
415
400
|
} catch (e) {
|
|
416
401
|
return this.forceTokenUpdate();
|
|
417
402
|
}
|
|
@@ -432,8 +417,8 @@ class Auth {
|
|
|
432
417
|
this._backendCheckPromise = null;
|
|
433
418
|
}
|
|
434
419
|
try {
|
|
435
|
-
var _await$this$_backgrou
|
|
436
|
-
return (_await$this$_backgrou = await
|
|
420
|
+
var _await$this$_backgrou;
|
|
421
|
+
return (_await$this$_backgrou = await this._backgroundFlow?.authorize()) !== null && _await$this$_backgrou !== void 0 ? _await$this$_backgrou : null;
|
|
437
422
|
} catch (error) {
|
|
438
423
|
if (!(error instanceof Error)) {
|
|
439
424
|
return null;
|
|
@@ -442,8 +427,7 @@ class Auth {
|
|
|
442
427
|
return new Promise(resolve => {
|
|
443
428
|
const onTryAgain = async () => {
|
|
444
429
|
try {
|
|
445
|
-
|
|
446
|
-
const result = await ((_this$_backgroundFlow3 = this._backgroundFlow) === null || _this$_backgroundFlow3 === void 0 ? void 0 : _this$_backgroundFlow3.authorize());
|
|
430
|
+
const result = await this._backgroundFlow?.authorize();
|
|
447
431
|
resolve(result !== null && result !== void 0 ? result : null);
|
|
448
432
|
} catch (retryError) {
|
|
449
433
|
if (retryError instanceof Error) {
|
|
@@ -463,8 +447,7 @@ class Auth {
|
|
|
463
447
|
});
|
|
464
448
|
});
|
|
465
449
|
} else {
|
|
466
|
-
|
|
467
|
-
const authRequest = await ((_this$_requestBuilder2 = this._requestBuilder) === null || _this$_requestBuilder2 === void 0 ? void 0 : _this$_requestBuilder2.prepareAuthRequest());
|
|
450
|
+
const authRequest = await this._requestBuilder?.prepareAuthRequest();
|
|
468
451
|
if (authRequest != null) {
|
|
469
452
|
this._redirectCurrentPage(authRequest.url);
|
|
470
453
|
}
|
|
@@ -497,8 +480,7 @@ class Auth {
|
|
|
497
480
|
*/
|
|
498
481
|
getUser(accessToken) {
|
|
499
482
|
if (this.config.cacheCurrentUser) {
|
|
500
|
-
|
|
501
|
-
return (_this$_storage6 = this._storage) === null || _this$_storage6 === void 0 ? void 0 : _this$_storage6.getCachedUser(() => this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams));
|
|
483
|
+
return this._storage?.getCachedUser(() => this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams));
|
|
502
484
|
} else {
|
|
503
485
|
return this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams);
|
|
504
486
|
}
|
|
@@ -520,10 +502,9 @@ class Auth {
|
|
|
520
502
|
return user;
|
|
521
503
|
}
|
|
522
504
|
async updateUser() {
|
|
523
|
-
var _this$_storage7;
|
|
524
505
|
this._setPostponed(false);
|
|
525
506
|
const accessToken = await this.requestToken();
|
|
526
|
-
|
|
507
|
+
this._storage?.wipeCachedCurrentUser();
|
|
527
508
|
const user = await this.getUser(accessToken);
|
|
528
509
|
this.user = user;
|
|
529
510
|
this.listeners.trigger(USER_CHANGED_EVENT, user);
|
|
@@ -564,7 +545,6 @@ class Auth {
|
|
|
564
545
|
this.logout();
|
|
565
546
|
}
|
|
566
547
|
_showAuthDialog() {
|
|
567
|
-
var _this$user2, _this$_authDialogServ, _this$_storage9, _this$_storage10;
|
|
568
548
|
let {
|
|
569
549
|
nonInteractive,
|
|
570
550
|
error,
|
|
@@ -576,14 +556,14 @@ class Auth {
|
|
|
576
556
|
onPostponeLogout,
|
|
577
557
|
translations
|
|
578
558
|
} = this.config;
|
|
579
|
-
const cancelable =
|
|
559
|
+
const cancelable = this.user?.guest || canCancel;
|
|
580
560
|
const actualTranslations = translations !== null && translations !== void 0 ? translations : getTranslations();
|
|
581
561
|
this._createInitDeferred();
|
|
582
562
|
const closeDialog = () => {
|
|
583
563
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
584
|
-
stopTokenListening
|
|
585
|
-
stopMessageListening
|
|
586
|
-
hide
|
|
564
|
+
stopTokenListening?.();
|
|
565
|
+
stopMessageListening?.();
|
|
566
|
+
hide?.();
|
|
587
567
|
/* eslint-enable @typescript-eslint/no-use-before-define */
|
|
588
568
|
};
|
|
589
569
|
|
|
@@ -596,29 +576,26 @@ class Auth {
|
|
|
596
576
|
this._runEmbeddedLogin();
|
|
597
577
|
};
|
|
598
578
|
const onCancel = () => {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
(_this$_storage8 = this._storage) === null || _this$_storage8 === void 0 ? void 0 : _this$_storage8.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
|
|
579
|
+
this._embeddedFlow?.stop();
|
|
580
|
+
this._storage?.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
|
|
602
581
|
closeDialog();
|
|
603
582
|
if (!cancelable) {
|
|
604
|
-
|
|
605
|
-
(_this$_initDeferred6 = this._initDeferred) === null || _this$_initDeferred6 === void 0 ? void 0 : (_this$_initDeferred6$ = _this$_initDeferred6.resolve) === null || _this$_initDeferred6$ === void 0 ? void 0 : _this$_initDeferred6$.call(_this$_initDeferred6);
|
|
583
|
+
this._initDeferred?.resolve?.();
|
|
606
584
|
this.listeners.trigger(LOGOUT_POSTPONED_EVENT);
|
|
607
585
|
onPostponeLogout();
|
|
608
586
|
return;
|
|
609
587
|
}
|
|
610
|
-
if (
|
|
588
|
+
if (this.user?.guest && nonInteractive) {
|
|
611
589
|
this.forceTokenUpdate();
|
|
612
590
|
} else {
|
|
613
|
-
|
|
614
|
-
(_this$_initDeferred7 = this._initDeferred) === null || _this$_initDeferred7 === void 0 ? void 0 : (_this$_initDeferred7$ = _this$_initDeferred7.resolve) === null || _this$_initDeferred7$ === void 0 ? void 0 : _this$_initDeferred7$.call(_this$_initDeferred7);
|
|
591
|
+
this._initDeferred?.resolve?.();
|
|
615
592
|
}
|
|
616
593
|
};
|
|
617
594
|
const onTryAgainClick = async () => {
|
|
618
|
-
await
|
|
595
|
+
await onTryAgain?.();
|
|
619
596
|
closeDialog();
|
|
620
597
|
};
|
|
621
|
-
const hide =
|
|
598
|
+
const hide = this._authDialogService?.({
|
|
622
599
|
...this._service,
|
|
623
600
|
loginCaption: actualTranslations.login,
|
|
624
601
|
loginToCaption: actualTranslations.loginTo,
|
|
@@ -630,20 +607,16 @@ class Auth {
|
|
|
630
607
|
onCancel,
|
|
631
608
|
onTryAgain: onTryAgain ? onTryAgainClick : undefined
|
|
632
609
|
});
|
|
633
|
-
const stopTokenListening =
|
|
610
|
+
const stopTokenListening = this._storage?.onTokenChange(token => {
|
|
634
611
|
if (token) {
|
|
635
|
-
var _this$_initDeferred8, _this$_initDeferred8$;
|
|
636
612
|
closeDialog();
|
|
637
|
-
|
|
613
|
+
this._initDeferred?.resolve?.();
|
|
638
614
|
}
|
|
639
615
|
});
|
|
640
|
-
const stopMessageListening =
|
|
641
|
-
var _this$_embeddedFlow2;
|
|
642
|
-
return (_this$_embeddedFlow2 = this._embeddedFlow) === null || _this$_embeddedFlow2 === void 0 ? void 0 : _this$_embeddedFlow2.stop();
|
|
643
|
-
});
|
|
616
|
+
const stopMessageListening = this._storage?.onMessage(Auth.CLOSE_WINDOW_MESSAGE, () => this._embeddedFlow?.stop());
|
|
644
617
|
}
|
|
645
618
|
_showUserChangedDialog(_ref) {
|
|
646
|
-
var
|
|
619
|
+
var _translations$youHave, _newUser$name, _newUser$name2, _translations$login, _translations$loginTo, _translations$applyCh, _translations$tryAgai, _translations$postpon;
|
|
647
620
|
let {
|
|
648
621
|
newUser,
|
|
649
622
|
onApply,
|
|
@@ -654,19 +627,18 @@ class Auth {
|
|
|
654
627
|
} = this.config;
|
|
655
628
|
this._createInitDeferred();
|
|
656
629
|
const done = () => {
|
|
657
|
-
|
|
658
|
-
(_this$_initDeferred9 = this._initDeferred) === null || _this$_initDeferred9 === void 0 ? void 0 : (_this$_initDeferred9$ = _this$_initDeferred9.resolve) === null || _this$_initDeferred9$ === void 0 ? void 0 : _this$_initDeferred9$.call(_this$_initDeferred9);
|
|
630
|
+
this._initDeferred?.resolve?.();
|
|
659
631
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
660
|
-
hide
|
|
632
|
+
hide?.();
|
|
661
633
|
};
|
|
662
|
-
const hide =
|
|
634
|
+
const hide = this._authDialogService?.({
|
|
663
635
|
...this._service,
|
|
664
|
-
title: (_translations$youHave = translations
|
|
665
|
-
loginCaption: (_translations$login = translations
|
|
666
|
-
loginToCaption: (_translations$loginTo = translations
|
|
667
|
-
confirmLabel: (_translations$applyCh = translations
|
|
668
|
-
tryAgainLabel: (_translations$tryAgai = translations
|
|
669
|
-
cancelLabel: (_translations$postpon = translations
|
|
636
|
+
title: (_translations$youHave = 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 : ''),
|
|
637
|
+
loginCaption: (_translations$login = translations?.login) !== null && _translations$login !== void 0 ? _translations$login : translate('login'),
|
|
638
|
+
loginToCaption: (_translations$loginTo = translations?.loginTo) !== null && _translations$loginTo !== void 0 ? _translations$loginTo : translate('loginTo'),
|
|
639
|
+
confirmLabel: (_translations$applyCh = translations?.applyChange) !== null && _translations$applyCh !== void 0 ? _translations$applyCh : translate('applyChange'),
|
|
640
|
+
tryAgainLabel: (_translations$tryAgai = translations?.tryAgainLabel) !== null && _translations$tryAgai !== void 0 ? _translations$tryAgai : translate('tryAgainLabel'),
|
|
641
|
+
cancelLabel: (_translations$postpon = translations?.postpone) !== null && _translations$postpon !== void 0 ? _translations$postpon : translate('postpone'),
|
|
670
642
|
onConfirm: () => {
|
|
671
643
|
done();
|
|
672
644
|
onApply();
|
|
@@ -706,19 +678,17 @@ class Auth {
|
|
|
706
678
|
const REPEAT_TIMEOUT = 5000;
|
|
707
679
|
let timerId;
|
|
708
680
|
return new Promise((resolve, reject) => {
|
|
709
|
-
var _this$_storage12;
|
|
710
681
|
const done = () => {
|
|
711
|
-
var _this$_storage11;
|
|
712
682
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
713
683
|
hide();
|
|
714
684
|
window.removeEventListener('online', onCheckAgain);
|
|
715
|
-
stopListeningCloseMessage
|
|
685
|
+
stopListeningCloseMessage?.();
|
|
716
686
|
/* eslint-enable @typescript-eslint/no-use-before-define */
|
|
717
|
-
|
|
687
|
+
this._storage?.sendMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, Date.now());
|
|
718
688
|
clearTimeout(timerId);
|
|
719
689
|
};
|
|
720
|
-
const stopListeningCloseMessage =
|
|
721
|
-
stopListeningCloseMessage
|
|
690
|
+
const stopListeningCloseMessage = this._storage?.onMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, () => {
|
|
691
|
+
stopListeningCloseMessage?.();
|
|
722
692
|
done();
|
|
723
693
|
resolve();
|
|
724
694
|
});
|
|
@@ -751,7 +721,6 @@ class Auth {
|
|
|
751
721
|
* Wipe accessToken and redirect to auth page with required authorization
|
|
752
722
|
*/
|
|
753
723
|
async logout(extraParams) {
|
|
754
|
-
var _this$_storage13, _this$_requestBuilder3;
|
|
755
724
|
const requestParams = {
|
|
756
725
|
// eslint-disable-next-line camelcase
|
|
757
726
|
request_credentials: 'required',
|
|
@@ -760,19 +729,17 @@ class Auth {
|
|
|
760
729
|
await this._checkBackendsStatusesIfEnabled();
|
|
761
730
|
await this.listeners.trigger('logout');
|
|
762
731
|
this._updateDomainUser(null);
|
|
763
|
-
await
|
|
764
|
-
const authRequest = await
|
|
732
|
+
await this._storage?.wipeToken();
|
|
733
|
+
const authRequest = await this._requestBuilder?.prepareAuthRequest(requestParams);
|
|
765
734
|
if (authRequest != null) {
|
|
766
735
|
this._redirectCurrentPage(authRequest.url);
|
|
767
736
|
}
|
|
768
737
|
}
|
|
769
738
|
async _runEmbeddedLogin() {
|
|
770
|
-
|
|
771
|
-
(_this$_storage14 = this._storage) === null || _this$_storage14 === void 0 ? void 0 : _this$_storage14.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
|
|
739
|
+
this._storage?.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
|
|
772
740
|
try {
|
|
773
|
-
var _this$_embeddedFlow3;
|
|
774
741
|
this._isLoginWindowOpen = true;
|
|
775
|
-
return await
|
|
742
|
+
return await this._embeddedFlow?.authorize();
|
|
776
743
|
} catch (e) {
|
|
777
744
|
throw e;
|
|
778
745
|
} finally {
|
|
@@ -790,8 +757,7 @@ class Auth {
|
|
|
790
757
|
}
|
|
791
758
|
await this._checkBackendsStatusesIfEnabled();
|
|
792
759
|
try {
|
|
793
|
-
|
|
794
|
-
const accessToken = await ((_this$_backgroundFlow4 = this._backgroundFlow) === null || _this$_backgroundFlow4 === void 0 ? void 0 : _this$_backgroundFlow4.authorize());
|
|
760
|
+
const accessToken = await this._backgroundFlow?.authorize();
|
|
795
761
|
const user = await this.getUser(accessToken);
|
|
796
762
|
if (user.guest) {
|
|
797
763
|
this._beforeLogout();
|
|
@@ -818,7 +784,6 @@ class Auth {
|
|
|
818
784
|
* @private
|
|
819
785
|
*/
|
|
820
786
|
async _checkForAuthResponse() {
|
|
821
|
-
var _this$_storage15;
|
|
822
787
|
// getAuthResponseURL may throw an exception
|
|
823
788
|
const authResponse = this._responseParser.getAuthResponseFromURL();
|
|
824
789
|
const {
|
|
@@ -838,29 +803,27 @@ class Auth {
|
|
|
838
803
|
expiresIn,
|
|
839
804
|
accessToken
|
|
840
805
|
} = authResponse;
|
|
841
|
-
const newState = (await (stateId &&
|
|
806
|
+
const newState = (await (stateId && this._storage?.getState(stateId))) || {};
|
|
842
807
|
const scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
|
|
843
808
|
const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
|
|
844
809
|
const expires = TokenValidator._epoch() + effectiveExpiresIn;
|
|
845
810
|
if (accessToken != null) {
|
|
846
|
-
|
|
847
|
-
await ((_this$_storage16 = this._storage) === null || _this$_storage16 === void 0 ? void 0 : _this$_storage16.saveToken({
|
|
811
|
+
await this._storage?.saveToken({
|
|
848
812
|
accessToken,
|
|
849
813
|
scopes,
|
|
850
814
|
expires,
|
|
851
815
|
lifeTime: effectiveExpiresIn
|
|
852
|
-
})
|
|
816
|
+
});
|
|
853
817
|
}
|
|
854
818
|
return newState;
|
|
855
819
|
}
|
|
856
820
|
async _checkForStateRestoration() {
|
|
857
|
-
var _this$_storage17;
|
|
858
821
|
const authResponse = this._responseParser._authResponse;
|
|
859
822
|
if (authResponse && this.config.cleanHash) {
|
|
860
823
|
this.setHash('');
|
|
861
824
|
}
|
|
862
|
-
const stateId = authResponse
|
|
863
|
-
return (await (stateId &&
|
|
825
|
+
const stateId = authResponse?.restoreAuthState;
|
|
826
|
+
return (await (stateId && this._storage?.getState(stateId))) || {};
|
|
864
827
|
}
|
|
865
828
|
_checkBackendsAreUp() {
|
|
866
829
|
const abortCtrl = new AbortController();
|
package/dist/auth/iframe-flow.js
CHANGED
|
@@ -107,8 +107,7 @@ class IFrameFlow {
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
const cleanUp = () => {
|
|
110
|
-
|
|
111
|
-
(_this$hideDialog = this.hideDialog) === null || _this$hideDialog === void 0 ? void 0 : _this$hideDialog.call(this);
|
|
110
|
+
this.hideDialog?.();
|
|
112
111
|
removeStateListener();
|
|
113
112
|
removeTokenListener();
|
|
114
113
|
};
|
package/dist/auth/landing.js
CHANGED
|
@@ -68,7 +68,6 @@ const parser = new AuthResponseParser();
|
|
|
68
68
|
const authResponse = parser.getAuthResponseFromURL();
|
|
69
69
|
// eslint-disable-next-line consistent-this
|
|
70
70
|
async function parseAndStoreResponse(clientId) {
|
|
71
|
-
var _this$_storage;
|
|
72
71
|
const storage = new AuthStorage({
|
|
73
72
|
messagePrefix: `${clientId}-message-`,
|
|
74
73
|
stateKeyPrefix: `${clientId}-states-`,
|
|
@@ -84,7 +83,7 @@ async function parseAndStoreResponse(clientId) {
|
|
|
84
83
|
expiresIn,
|
|
85
84
|
accessToken
|
|
86
85
|
} = authResponse;
|
|
87
|
-
const newState = (await (stateId &&
|
|
86
|
+
const newState = (await (stateId && this._storage?.getState(stateId))) || {};
|
|
88
87
|
const scopes = scope ? scope.split(' ') : newState.scopes || [];
|
|
89
88
|
const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : DEFAULT_EXPIRES_TIMEOUT;
|
|
90
89
|
const expires = TokenValidator._epoch() + effectiveExpiresIn;
|
|
@@ -60,8 +60,7 @@ class AuthRequestBuilder {
|
|
|
60
60
|
* @private
|
|
61
61
|
*/
|
|
62
62
|
_saveState(id, storedState) {
|
|
63
|
-
|
|
64
|
-
return (_this$storage = this.storage) === null || _this$storage === void 0 ? void 0 : _this$storage.saveState(id, storedState);
|
|
63
|
+
return this.storage?.saveState(id, storedState);
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
|
|
@@ -96,10 +96,7 @@ class TokenValidator {
|
|
|
96
96
|
optionalScopes
|
|
97
97
|
} = this._config;
|
|
98
98
|
const requiredScopes = optionalScopes ? scope.filter(scopeId => !optionalScopes.includes(scopeId)) : scope;
|
|
99
|
-
const hasAllScopes = requiredScopes.every(scopeId =>
|
|
100
|
-
var _storedToken$scopes;
|
|
101
|
-
return (_storedToken$scopes = storedToken.scopes) === null || _storedToken$scopes === void 0 ? void 0 : _storedToken$scopes.includes(scopeId);
|
|
102
|
-
});
|
|
99
|
+
const hasAllScopes = requiredScopes.every(scopeId => storedToken.scopes?.includes(scopeId));
|
|
103
100
|
if (!hasAllScopes) {
|
|
104
101
|
throw new TokenValidator.TokenValidationError('Token doesn\'t match required scopes');
|
|
105
102
|
}
|
|
@@ -130,9 +127,8 @@ class TokenValidator {
|
|
|
130
127
|
// Skip JSON parsing errors
|
|
131
128
|
}
|
|
132
129
|
if (errorResponse.status === CODE.UNAUTHORIZED || TokenValidator.shouldRefreshToken(response.error)) {
|
|
133
|
-
var _errorResponse$data, _errorResponse$data2;
|
|
134
130
|
// Token expired
|
|
135
|
-
throw new TokenValidator.TokenValidationError(response.error || errorResponse.message,
|
|
131
|
+
throw new TokenValidator.TokenValidationError(response.error || errorResponse.message, errorResponse.data?.error ? new Error(errorResponse.data?.error) : undefined);
|
|
136
132
|
}
|
|
137
133
|
// Request unexpectedly failed
|
|
138
134
|
throw errorResponse;
|
package/dist/auth/window-flow.js
CHANGED
|
@@ -45,7 +45,6 @@ class WindowFlow {
|
|
|
45
45
|
this.reject = reject;
|
|
46
46
|
let cleanRun;
|
|
47
47
|
const cleanUp = () => {
|
|
48
|
-
var _this$_loginWindow;
|
|
49
48
|
if (cleanRun) {
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
@@ -54,7 +53,7 @@ class WindowFlow {
|
|
|
54
53
|
removeStateListener();
|
|
55
54
|
removeTokenListener();
|
|
56
55
|
/* eslint-enable @typescript-eslint/no-use-before-define */
|
|
57
|
-
|
|
56
|
+
this._loginWindow?.close();
|
|
58
57
|
clearTimeout(this._timeoutId);
|
|
59
58
|
};
|
|
60
59
|
const removeTokenListener = this._storage.onTokenChange(token => {
|
|
@@ -78,8 +77,7 @@ class WindowFlow {
|
|
|
78
77
|
});
|
|
79
78
|
}
|
|
80
79
|
checkIsClosed = () => {
|
|
81
|
-
|
|
82
|
-
if ((_this$_loginWindow2 = this._loginWindow) !== null && _this$_loginWindow2 !== void 0 && _this$_loginWindow2.closed) {
|
|
80
|
+
if (this._loginWindow?.closed) {
|
|
83
81
|
this.stop();
|
|
84
82
|
return;
|
|
85
83
|
}
|