@jetbrains/ring-ui 5.0.84 → 5.0.86
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/date-picker/date-picker.js +3 -8
- package/components/dropdown/dropdown.d.ts +3 -0
- package/components/dropdown/dropdown.js +12 -1
- package/components/global/get-uid.js +1 -1
- package/components/radio/radio.css +7 -5
- package/components/shortcuts/core.js +1 -1
- package/dist/analytics/analytics__custom-plugin.js +2 -4
- package/dist/analytics/analytics__fus-plugin.js +2 -4
- package/dist/analytics/analytics__ga-plugin.js +1 -2
- package/dist/auth/auth.js +3 -1
- package/dist/auth/auth__core.js +57 -94
- 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/button/button.js +1 -2
- package/dist/caret/caret.js +13 -16
- package/dist/content-layout/content-layout.js +1 -2
- package/dist/data-list/data-list.js +3 -6
- package/dist/data-list/item.js +1 -1
- package/dist/date-picker/date-picker.js +8 -13
- package/dist/date-picker/date-popup.js +1 -2
- package/dist/dialog-ng/dialog-ng.js +2 -3
- package/dist/dropdown/dropdown.d.ts +3 -0
- package/dist/dropdown/dropdown.js +15 -6
- package/dist/editable-heading/editable-heading.js +1 -3
- package/dist/global/focus-sensor-hoc.js +8 -13
- package/dist/global/get-uid.js +1 -1
- 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/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/icon/icon.js +1 -2
- package/dist/input/input.js +3 -6
- 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 +4 -6
- package/dist/pager/pager.js +4 -8
- package/dist/permissions/permissions__cache.js +1 -1
- package/dist/popup/popup.js +2 -4
- package/dist/popup/position.js +2 -3
- package/dist/query-assist/query-assist.js +29 -41
- package/dist/select/select.js +10 -17
- 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 +2 -3
- package/dist/style.css +1 -1
- 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/tabs/dumb-tabs.js +1 -2
- package/dist/tag/tag.js +1 -2
- package/dist/tags-input/tags-input.js +13 -23
- package/dist/tooltip/tooltip.js +2 -4
- package/package.json +15 -17
|
@@ -199,20 +199,15 @@ export default class DatePicker extends PureComponent {
|
|
|
199
199
|
{this.getAnchorText()}
|
|
200
200
|
<Icon glyph={chevronDownIcon} className={styles.chevronDownIcon}/>
|
|
201
201
|
</div>);
|
|
202
|
-
if (this.props.disabled) {
|
|
203
|
-
return (<Button data-test-ring-dropdown-anchor className={styles.anchor} disabled text={false}>
|
|
204
|
-
{anchorContent}
|
|
205
|
-
</Button>);
|
|
206
|
-
}
|
|
207
202
|
const { className, popupClassName, clear, inline, dropdownProps, translations, ...datePopupProps } = this.props;
|
|
208
203
|
const classes = classNames(styles.datePicker, className, styles[`size${this.props.size}`], {
|
|
209
204
|
[styles.inline]: inline
|
|
210
205
|
});
|
|
211
|
-
return (<Dropdown className={classes} anchor={inline
|
|
212
|
-
? (<Link data-test-ring-dropdown-anchor className={styles.anchor} pseudo>
|
|
206
|
+
return (<Dropdown className={classes} disabled={this.props.disabled} anchor={inline
|
|
207
|
+
? (<Link data-test-ring-dropdown-anchor className={styles.anchor} disabled={this.props.disabled ?? false} pseudo>
|
|
213
208
|
{this.getAnchorText()}
|
|
214
209
|
</Link>)
|
|
215
|
-
: (<Button data-test-ring-dropdown-anchor className={styles.anchor} text={false}>
|
|
210
|
+
: (<Button data-test-ring-dropdown-anchor className={styles.anchor} text={false} disabled={this.props.disabled ?? false}>
|
|
216
211
|
{anchorContent}
|
|
217
212
|
</Button>)} {...dropdownProps}>
|
|
218
213
|
<PopupComponent className={popupClassName} popupRef={this.popupRef} onClear={clear ? this.clear : null} datePopupProps={{
|
|
@@ -10,6 +10,7 @@ export interface DropdownProps extends Omit<HTMLAttributes<HTMLElement>, 'childr
|
|
|
10
10
|
anchor: ReactElement | readonly ReactElement[] | string | ((props: AnchorProps) => ReactNode);
|
|
11
11
|
children: ReactElement<PopupAttrs> | ((props: Omit<PopupAttrs, 'children'>) => ReactNode);
|
|
12
12
|
initShown: boolean;
|
|
13
|
+
disabled?: boolean | null | undefined;
|
|
13
14
|
clickMode: boolean;
|
|
14
15
|
hoverMode: boolean;
|
|
15
16
|
hoverShowTimeOut: number;
|
|
@@ -41,6 +42,7 @@ export default class Dropdown extends Component<DropdownProps, DropdownState> {
|
|
|
41
42
|
hoverMode: PropTypes.Requireable<boolean>;
|
|
42
43
|
hoverShowTimeOut: PropTypes.Requireable<number>;
|
|
43
44
|
hoverHideTimeOut: PropTypes.Requireable<number>;
|
|
45
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
44
46
|
onShow: PropTypes.Requireable<(...args: any[]) => any>;
|
|
45
47
|
onHide: PropTypes.Requireable<(...args: any[]) => any>;
|
|
46
48
|
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -53,6 +55,7 @@ export default class Dropdown extends Component<DropdownProps, DropdownState> {
|
|
|
53
55
|
hoverMode: boolean;
|
|
54
56
|
hoverShowTimeOut: number;
|
|
55
57
|
hoverHideTimeOut: number;
|
|
58
|
+
disabled: boolean;
|
|
56
59
|
onShow: () => void;
|
|
57
60
|
onHide: () => void;
|
|
58
61
|
onMouseEnter: () => void;
|
|
@@ -23,6 +23,7 @@ export default class Dropdown extends Component {
|
|
|
23
23
|
hoverMode: PropTypes.bool,
|
|
24
24
|
hoverShowTimeOut: PropTypes.number,
|
|
25
25
|
hoverHideTimeOut: PropTypes.number,
|
|
26
|
+
disabled: PropTypes.bool,
|
|
26
27
|
onShow: PropTypes.func,
|
|
27
28
|
onHide: PropTypes.func,
|
|
28
29
|
onMouseEnter: PropTypes.func,
|
|
@@ -35,6 +36,7 @@ export default class Dropdown extends Component {
|
|
|
35
36
|
hoverMode: false,
|
|
36
37
|
hoverShowTimeOut: 300,
|
|
37
38
|
hoverHideTimeOut: 600,
|
|
39
|
+
disabled: false,
|
|
38
40
|
onShow: () => { },
|
|
39
41
|
onHide: () => { },
|
|
40
42
|
onMouseEnter: () => { },
|
|
@@ -45,6 +47,9 @@ export default class Dropdown extends Component {
|
|
|
45
47
|
pinned: false
|
|
46
48
|
};
|
|
47
49
|
onClick = () => {
|
|
50
|
+
if (this.props.disabled) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
48
53
|
const { show, pinned } = this.state;
|
|
49
54
|
let nextPinned = pinned;
|
|
50
55
|
if (this.props.hoverMode) {
|
|
@@ -70,6 +75,9 @@ export default class Dropdown extends Component {
|
|
|
70
75
|
};
|
|
71
76
|
hoverTimer;
|
|
72
77
|
onMouseEnter = (event) => {
|
|
78
|
+
if (this.props.disabled) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
73
81
|
this._clearTimer();
|
|
74
82
|
this.props.onMouseEnter?.(event);
|
|
75
83
|
this.hoverTimer = window.setTimeout(() => {
|
|
@@ -79,6 +87,9 @@ export default class Dropdown extends Component {
|
|
|
79
87
|
}, this.props.hoverShowTimeOut);
|
|
80
88
|
};
|
|
81
89
|
onMouseLeave = (event) => {
|
|
90
|
+
if (this.props.disabled) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
82
93
|
this.props.onMouseLeave?.(event);
|
|
83
94
|
if (this.state.pinned) {
|
|
84
95
|
return;
|
|
@@ -107,7 +118,7 @@ export default class Dropdown extends Component {
|
|
|
107
118
|
}
|
|
108
119
|
render() {
|
|
109
120
|
const { show, pinned } = this.state;
|
|
110
|
-
const { initShown, onShow, onHide, hoverShowTimeOut, hoverHideTimeOut, children, anchor, className, activeClassName, hoverMode, clickMode, 'data-test': dataTest, ...restProps } = this.props;
|
|
121
|
+
const { initShown, onShow, onHide, hoverShowTimeOut, hoverHideTimeOut, children, anchor, className, activeClassName, hoverMode, clickMode, 'data-test': dataTest, disabled, ...restProps } = this.props;
|
|
111
122
|
const classes = classNames(styles.dropdown, className, {
|
|
112
123
|
[activeClassName ?? '']: activeClassName != null && show
|
|
113
124
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const idCounters = {};
|
|
2
2
|
function generateSalt() {
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
4
|
-
return (
|
|
4
|
+
return (Date.now() * Math.random()).toString(36).substring(0, 4);
|
|
5
5
|
}
|
|
6
6
|
const salt = generateSalt();
|
|
7
7
|
export default function getUID(name) {
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
.radio {
|
|
7
7
|
position: relative;
|
|
8
8
|
|
|
9
|
-
display:
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
|
|
12
|
+
padding: 6px 0;
|
|
10
13
|
|
|
11
14
|
text-align: left;
|
|
12
15
|
|
|
@@ -22,9 +25,9 @@
|
|
|
22
25
|
|
|
23
26
|
.circle {
|
|
24
27
|
position: relative;
|
|
25
|
-
top:
|
|
28
|
+
top: 2px;
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
flex-shrink: 0;
|
|
28
31
|
|
|
29
32
|
box-sizing: border-box;
|
|
30
33
|
width: radio-size;
|
|
@@ -32,7 +35,6 @@
|
|
|
32
35
|
|
|
33
36
|
user-select: none;
|
|
34
37
|
transition: border-color var(--ring-ease), box-shadow var(--ring-ease);
|
|
35
|
-
vertical-align: middle;
|
|
36
38
|
pointer-events: none;
|
|
37
39
|
|
|
38
40
|
border: 1px solid var(--ring-borders-color);
|
|
@@ -119,5 +121,5 @@
|
|
|
119
121
|
.label {
|
|
120
122
|
margin-left: unit;
|
|
121
123
|
|
|
122
|
-
line-height:
|
|
124
|
+
line-height: var(--ring-line-height);
|
|
123
125
|
}
|
|
@@ -162,7 +162,7 @@ class Shortcuts {
|
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
164
|
// stop for input, select, and textarea
|
|
165
|
-
return element.matches('input,select,textarea') || (element.contentEditable === 'true');
|
|
165
|
+
return element.matches('input:not([type=checkbox]),select,textarea') || (element.contentEditable === 'true');
|
|
166
166
|
};
|
|
167
167
|
_getKeyboardEventType(params) {
|
|
168
168
|
if (!params.type && sniffr.os.name === 'windows') {
|
|
@@ -60,9 +60,8 @@ class AnalyticsCustomPlugin {
|
|
|
60
60
|
}
|
|
61
61
|
_initSendSchedule() {
|
|
62
62
|
window.addEventListener('beforeunload', () => {
|
|
63
|
-
var _this$_flush;
|
|
64
63
|
this._trackPageViewAdditionalInfo();
|
|
65
|
-
return
|
|
64
|
+
return this._flush?.();
|
|
66
65
|
});
|
|
67
66
|
if (this._flush != null) {
|
|
68
67
|
setInterval(this._flush, this._flushInterval);
|
|
@@ -98,8 +97,7 @@ class AnalyticsCustomPlugin {
|
|
|
98
97
|
_addDataToFlushingPack(sendingData) {
|
|
99
98
|
this._data.push(sendingData);
|
|
100
99
|
if (this._flushMaxPackSize != null && this._data.length >= this._flushMaxPackSize) {
|
|
101
|
-
|
|
102
|
-
(_this$_flush2 = this._flush) === null || _this$_flush2 === void 0 ? void 0 : _this$_flush2.call(this);
|
|
100
|
+
this._flush?.();
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
103
|
get serializeAdditionalInfo() {
|
|
@@ -17,7 +17,6 @@ import 'sniffr';
|
|
|
17
17
|
*/
|
|
18
18
|
class AnalyticsFUSPlugin {
|
|
19
19
|
constructor(_ref) {
|
|
20
|
-
var _window$fusra, _window;
|
|
21
20
|
let {
|
|
22
21
|
productId,
|
|
23
22
|
productBuild,
|
|
@@ -32,7 +31,6 @@ class AnalyticsFUSPlugin {
|
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
34
33
|
((i, s, o, g, r) => {
|
|
35
|
-
var _firstScript$parentNo;
|
|
36
34
|
i[r] = i[r] || function addArgumentsToQueueForWaitingTheScriptLoading() {
|
|
37
35
|
const fn = i[r];
|
|
38
36
|
if (fn != null) {
|
|
@@ -46,9 +44,9 @@ class AnalyticsFUSPlugin {
|
|
|
46
44
|
script.async = true;
|
|
47
45
|
script.src = g;
|
|
48
46
|
const firstScript = document.getElementsByTagName(o)[0];
|
|
49
|
-
|
|
47
|
+
firstScript.parentNode?.insertBefore(script, firstScript);
|
|
50
48
|
})(window, document, 'script', '//resources.jetbrains.com/storage/fus/api/fus-reporting-api.js', 'fusra');
|
|
51
|
-
|
|
49
|
+
window.fusra?.('init', {
|
|
52
50
|
recorderCode: productId,
|
|
53
51
|
recorderVersion,
|
|
54
52
|
productCode: productId,
|
|
@@ -9,7 +9,6 @@ class AnalyticsGAPlugin {
|
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
((i, s, o, g, r) => {
|
|
12
|
-
var _m$parentNode;
|
|
13
12
|
i.GoogleAnalyticsObject = r;
|
|
14
13
|
i[r] = i[r] || function addArgumentsToQueueForWaitingTheScriptLoading() {
|
|
15
14
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -22,7 +21,7 @@ class AnalyticsGAPlugin {
|
|
|
22
21
|
const m = s.getElementsByTagName(o)[0];
|
|
23
22
|
a.async = true;
|
|
24
23
|
a.src = g;
|
|
25
|
-
|
|
24
|
+
m.parentNode?.insertBefore(a, m);
|
|
26
25
|
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
|
27
26
|
/**
|
|
28
27
|
* UA-57284711-1 - ga key for development purpose
|
package/dist/auth/auth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import WindowFlow from './window-flow.js';
|
|
2
2
|
import onBackendDown from './down-notification.js';
|
|
3
3
|
import Auth from './auth__core.js';
|
|
4
|
-
export { DEFAULT_BACKGROUND_TIMEOUT, DEFAULT_EXPIRES_TIMEOUT, DOMAIN_USER_CHANGED_EVENT, LOGOUT_EVENT, LOGOUT_POSTPONED_EVENT, USER_CHANGED_EVENT, USER_CHANGE_POSTPONED_EVENT
|
|
4
|
+
export { DEFAULT_BACKGROUND_TIMEOUT, DEFAULT_EXPIRES_TIMEOUT, DOMAIN_USER_CHANGED_EVENT, LOGOUT_EVENT, LOGOUT_POSTPONED_EVENT, USER_CHANGED_EVENT, USER_CHANGE_POSTPONED_EVENT } from './auth__core.js';
|
|
5
5
|
import '../_helpers/_rollupPluginBabelHelpers.js';
|
|
6
6
|
import './response-parser.js';
|
|
7
7
|
import 'es6-error';
|
|
@@ -101,3 +101,5 @@ Auth.DEFAULT_CONFIG = {
|
|
|
101
101
|
EmbeddedLoginFlow: WindowFlow,
|
|
102
102
|
onBackendDown: onBackendDown
|
|
103
103
|
};
|
|
104
|
+
|
|
105
|
+
export { Auth as default };
|
package/dist/auth/auth__core.js
CHANGED
|
@@ -211,14 +211,8 @@ class Auth {
|
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
213
|
if (this.config.cacheCurrentUser) {
|
|
214
|
-
this.addListener(LOGOUT_EVENT, () =>
|
|
215
|
-
|
|
216
|
-
return (_this$_storage = this._storage) === null || _this$_storage === void 0 ? void 0 : _this$_storage.wipeCachedCurrentUser();
|
|
217
|
-
});
|
|
218
|
-
this.addListener(USER_CHANGED_EVENT, () => {
|
|
219
|
-
var _this$_storage2;
|
|
220
|
-
return (_this$_storage2 = this._storage) === null || _this$_storage2 === void 0 ? void 0 : _this$_storage2.onUserChanged();
|
|
221
|
-
});
|
|
214
|
+
this.addListener(LOGOUT_EVENT, () => this._storage?.wipeCachedCurrentUser());
|
|
215
|
+
this.addListener(USER_CHANGED_EVENT, () => this._storage?.onUserChanged());
|
|
222
216
|
}
|
|
223
217
|
this._createInitDeferred();
|
|
224
218
|
this.setUpPreconnect(config.serverUri);
|
|
@@ -258,8 +252,7 @@ class Auth {
|
|
|
258
252
|
* that should be restored after returning back from auth server.
|
|
259
253
|
*/
|
|
260
254
|
async init() {
|
|
261
|
-
|
|
262
|
-
(_this$_storage3 = this._storage) === null || _this$_storage3 === void 0 ? void 0 : _this$_storage3.onTokenChange(async token => {
|
|
255
|
+
this._storage?.onTokenChange(async token => {
|
|
263
256
|
const isGuest = this.user ? this.user.guest : false;
|
|
264
257
|
if (isGuest && !token) {
|
|
265
258
|
return;
|
|
@@ -307,18 +300,16 @@ class Auth {
|
|
|
307
300
|
return new Promise(noop);
|
|
308
301
|
}
|
|
309
302
|
try {
|
|
310
|
-
var _this$_tokenValidator, _this$_initDeferred, _this$_initDeferred$r, _state;
|
|
311
303
|
// Check if there is a valid token
|
|
312
|
-
await
|
|
304
|
+
await this._tokenValidator?.validateToken();
|
|
313
305
|
// Checking if there is a message left by another app on this domain
|
|
314
306
|
const message = await this._domainStorage._messagesStorage.get(`domain-message-${DOMAIN_USER_CHANGED_EVENT}`);
|
|
315
307
|
if (message) {
|
|
316
|
-
var _this$user;
|
|
317
308
|
const {
|
|
318
309
|
userID,
|
|
319
310
|
serviceID
|
|
320
311
|
} = message;
|
|
321
|
-
if (serviceID !== this.config.clientId && (!userID ||
|
|
312
|
+
if (serviceID !== this.config.clientId && (!userID || this.user?.id !== userID)) {
|
|
322
313
|
this.forceTokenUpdate();
|
|
323
314
|
}
|
|
324
315
|
}
|
|
@@ -328,12 +319,11 @@ class Auth {
|
|
|
328
319
|
// Check if we have requested to restore state anyway
|
|
329
320
|
state = await this._checkForStateRestoration();
|
|
330
321
|
}
|
|
331
|
-
|
|
332
|
-
return
|
|
322
|
+
this._initDeferred?.resolve?.(state && state.restoreLocation);
|
|
323
|
+
return state?.restoreLocation;
|
|
333
324
|
} catch (error) {
|
|
334
325
|
if (Auth.storageIsUnavailable) {
|
|
335
|
-
|
|
336
|
-
(_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
|
|
326
|
+
this._initDeferred?.resolve?.(); // No way to handle if cookies are disabled
|
|
337
327
|
await this.requestUser(); // Someone may expect user to be loaded as a part of token validation
|
|
338
328
|
return null;
|
|
339
329
|
}
|
|
@@ -341,8 +331,7 @@ class Auth {
|
|
|
341
331
|
}
|
|
342
332
|
}
|
|
343
333
|
async sendRedirect(error) {
|
|
344
|
-
|
|
345
|
-
const authRequest = await ((_this$_requestBuilder = this._requestBuilder) === null || _this$_requestBuilder === void 0 ? void 0 : _this$_requestBuilder.prepareAuthRequest());
|
|
334
|
+
const authRequest = await this._requestBuilder?.prepareAuthRequest();
|
|
346
335
|
if (authRequest != null) {
|
|
347
336
|
this._redirectCurrentPage(authRequest.url);
|
|
348
337
|
}
|
|
@@ -355,12 +344,10 @@ class Auth {
|
|
|
355
344
|
async handleInitError(error) {
|
|
356
345
|
if ('stateId' in error && error.stateId) {
|
|
357
346
|
try {
|
|
358
|
-
|
|
359
|
-
const state = await ((_this$_storage4 = this._storage) === null || _this$_storage4 === void 0 ? void 0 : _this$_storage4.getState(error.stateId));
|
|
347
|
+
const state = await this._storage?.getState(error.stateId);
|
|
360
348
|
if (state && state.nonRedirect) {
|
|
361
|
-
var _this$_storage5;
|
|
362
349
|
state.error = error;
|
|
363
|
-
|
|
350
|
+
this._storage?.saveState(error.stateId, state);
|
|
364
351
|
// Return endless promise in the background to avoid service start
|
|
365
352
|
return new Promise(noop);
|
|
366
353
|
}
|
|
@@ -371,8 +358,7 @@ class Auth {
|
|
|
371
358
|
throw error;
|
|
372
359
|
}
|
|
373
360
|
async handleInitValidationError(error) {
|
|
374
|
-
|
|
375
|
-
if ('cause' in error && error.cause instanceof Error && ((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.message) === 'invalid_client') {
|
|
361
|
+
if ('cause' in error && error.cause instanceof Error && error.cause?.message === 'invalid_client') {
|
|
376
362
|
// eslint-disable-next-line no-console
|
|
377
363
|
console.error('RingUI Auth: invalid client detected. Logging out', error);
|
|
378
364
|
await this.logout();
|
|
@@ -385,17 +371,16 @@ class Auth {
|
|
|
385
371
|
// Background flow
|
|
386
372
|
if ('authRedirect' in error && error.authRedirect && !this.config.redirect) {
|
|
387
373
|
try {
|
|
388
|
-
|
|
389
|
-
await
|
|
390
|
-
|
|
391
|
-
(_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);
|
|
374
|
+
await this._backgroundFlow?.authorize();
|
|
375
|
+
await this._tokenValidator?.validateToken();
|
|
376
|
+
this._initDeferred?.resolve?.();
|
|
392
377
|
return undefined;
|
|
393
378
|
} catch (validationError) {
|
|
394
379
|
// Fallback to redirect flow
|
|
395
380
|
return validationError instanceof Error ? this.sendRedirect(validationError) : undefined;
|
|
396
381
|
}
|
|
397
382
|
}
|
|
398
|
-
|
|
383
|
+
this._initDeferred?.reject?.(error);
|
|
399
384
|
throw error;
|
|
400
385
|
}
|
|
401
386
|
/**
|
|
@@ -408,13 +393,13 @@ class Auth {
|
|
|
408
393
|
throw new Error('You should log in to be able to make requests');
|
|
409
394
|
}
|
|
410
395
|
try {
|
|
411
|
-
var
|
|
412
|
-
await
|
|
396
|
+
var _await$this$_tokenVal;
|
|
397
|
+
await this._initDeferred?.promise;
|
|
413
398
|
if (Auth.storageIsUnavailable) {
|
|
414
399
|
return null; // Forever guest if storage is unavailable
|
|
415
400
|
}
|
|
416
401
|
|
|
417
|
-
return (_await$this$_tokenVal = await
|
|
402
|
+
return (_await$this$_tokenVal = await this._tokenValidator?.validateTokenLocally()) !== null && _await$this$_tokenVal !== void 0 ? _await$this$_tokenVal : null;
|
|
418
403
|
} catch (e) {
|
|
419
404
|
return this.forceTokenUpdate();
|
|
420
405
|
}
|
|
@@ -435,8 +420,8 @@ class Auth {
|
|
|
435
420
|
this._backendCheckPromise = null;
|
|
436
421
|
}
|
|
437
422
|
try {
|
|
438
|
-
var _await$this$_backgrou
|
|
439
|
-
return (_await$this$_backgrou = await
|
|
423
|
+
var _await$this$_backgrou;
|
|
424
|
+
return (_await$this$_backgrou = await this._backgroundFlow?.authorize()) !== null && _await$this$_backgrou !== void 0 ? _await$this$_backgrou : null;
|
|
440
425
|
} catch (error) {
|
|
441
426
|
if (!(error instanceof Error)) {
|
|
442
427
|
return null;
|
|
@@ -445,8 +430,7 @@ class Auth {
|
|
|
445
430
|
return new Promise(resolve => {
|
|
446
431
|
const onTryAgain = async () => {
|
|
447
432
|
try {
|
|
448
|
-
|
|
449
|
-
const result = await ((_this$_backgroundFlow3 = this._backgroundFlow) === null || _this$_backgroundFlow3 === void 0 ? void 0 : _this$_backgroundFlow3.authorize());
|
|
433
|
+
const result = await this._backgroundFlow?.authorize();
|
|
450
434
|
resolve(result !== null && result !== void 0 ? result : null);
|
|
451
435
|
} catch (retryError) {
|
|
452
436
|
if (retryError instanceof Error) {
|
|
@@ -466,8 +450,7 @@ class Auth {
|
|
|
466
450
|
});
|
|
467
451
|
});
|
|
468
452
|
} else {
|
|
469
|
-
|
|
470
|
-
const authRequest = await ((_this$_requestBuilder2 = this._requestBuilder) === null || _this$_requestBuilder2 === void 0 ? void 0 : _this$_requestBuilder2.prepareAuthRequest());
|
|
453
|
+
const authRequest = await this._requestBuilder?.prepareAuthRequest();
|
|
471
454
|
if (authRequest != null) {
|
|
472
455
|
this._redirectCurrentPage(authRequest.url);
|
|
473
456
|
}
|
|
@@ -500,8 +483,7 @@ class Auth {
|
|
|
500
483
|
*/
|
|
501
484
|
getUser(accessToken) {
|
|
502
485
|
if (this.config.cacheCurrentUser) {
|
|
503
|
-
|
|
504
|
-
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));
|
|
486
|
+
return this._storage?.getCachedUser(() => this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams));
|
|
505
487
|
} else {
|
|
506
488
|
return this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams);
|
|
507
489
|
}
|
|
@@ -523,10 +505,9 @@ class Auth {
|
|
|
523
505
|
return user;
|
|
524
506
|
}
|
|
525
507
|
async updateUser() {
|
|
526
|
-
var _this$_storage7;
|
|
527
508
|
this._setPostponed(false);
|
|
528
509
|
const accessToken = await this.requestToken();
|
|
529
|
-
|
|
510
|
+
this._storage?.wipeCachedCurrentUser();
|
|
530
511
|
const user = await this.getUser(accessToken);
|
|
531
512
|
this.user = user;
|
|
532
513
|
this.listeners.trigger(USER_CHANGED_EVENT, user);
|
|
@@ -567,7 +548,6 @@ class Auth {
|
|
|
567
548
|
this.logout();
|
|
568
549
|
}
|
|
569
550
|
_showAuthDialog() {
|
|
570
|
-
var _this$user2, _this$_authDialogServ, _this$_storage9, _this$_storage10;
|
|
571
551
|
let {
|
|
572
552
|
nonInteractive,
|
|
573
553
|
error,
|
|
@@ -579,13 +559,13 @@ class Auth {
|
|
|
579
559
|
onPostponeLogout,
|
|
580
560
|
translations
|
|
581
561
|
} = this.config;
|
|
582
|
-
const cancelable =
|
|
562
|
+
const cancelable = this.user?.guest || canCancel;
|
|
583
563
|
this._createInitDeferred();
|
|
584
564
|
const closeDialog = () => {
|
|
585
565
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
586
|
-
stopTokenListening
|
|
587
|
-
stopMessageListening
|
|
588
|
-
hide
|
|
566
|
+
stopTokenListening?.();
|
|
567
|
+
stopMessageListening?.();
|
|
568
|
+
hide?.();
|
|
589
569
|
/* eslint-enable @typescript-eslint/no-use-before-define */
|
|
590
570
|
};
|
|
591
571
|
|
|
@@ -598,29 +578,26 @@ class Auth {
|
|
|
598
578
|
this._runEmbeddedLogin();
|
|
599
579
|
};
|
|
600
580
|
const onCancel = () => {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
(_this$_storage8 = this._storage) === null || _this$_storage8 === void 0 ? void 0 : _this$_storage8.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
|
|
581
|
+
this._embeddedFlow?.stop();
|
|
582
|
+
this._storage?.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
|
|
604
583
|
closeDialog();
|
|
605
584
|
if (!cancelable) {
|
|
606
|
-
|
|
607
|
-
(_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);
|
|
585
|
+
this._initDeferred?.resolve?.();
|
|
608
586
|
this.listeners.trigger(LOGOUT_POSTPONED_EVENT);
|
|
609
587
|
onPostponeLogout();
|
|
610
588
|
return;
|
|
611
589
|
}
|
|
612
|
-
if (
|
|
590
|
+
if (this.user?.guest && nonInteractive) {
|
|
613
591
|
this.forceTokenUpdate();
|
|
614
592
|
} else {
|
|
615
|
-
|
|
616
|
-
(_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);
|
|
593
|
+
this._initDeferred?.resolve?.();
|
|
617
594
|
}
|
|
618
595
|
};
|
|
619
596
|
const onTryAgainClick = async () => {
|
|
620
|
-
await
|
|
597
|
+
await onTryAgain?.();
|
|
621
598
|
closeDialog();
|
|
622
599
|
};
|
|
623
|
-
const hide =
|
|
600
|
+
const hide = this._authDialogService?.({
|
|
624
601
|
...this._service,
|
|
625
602
|
loginCaption: translations.login,
|
|
626
603
|
loginToCaption: translations.loginTo,
|
|
@@ -632,20 +609,16 @@ class Auth {
|
|
|
632
609
|
onCancel,
|
|
633
610
|
onTryAgain: onTryAgain ? onTryAgainClick : undefined
|
|
634
611
|
});
|
|
635
|
-
const stopTokenListening =
|
|
612
|
+
const stopTokenListening = this._storage?.onTokenChange(token => {
|
|
636
613
|
if (token) {
|
|
637
|
-
var _this$_initDeferred8, _this$_initDeferred8$;
|
|
638
614
|
closeDialog();
|
|
639
|
-
|
|
615
|
+
this._initDeferred?.resolve?.();
|
|
640
616
|
}
|
|
641
617
|
});
|
|
642
|
-
const stopMessageListening =
|
|
643
|
-
var _this$_embeddedFlow2;
|
|
644
|
-
return (_this$_embeddedFlow2 = this._embeddedFlow) === null || _this$_embeddedFlow2 === void 0 ? void 0 : _this$_embeddedFlow2.stop();
|
|
645
|
-
});
|
|
618
|
+
const stopMessageListening = this._storage?.onMessage(Auth.CLOSE_WINDOW_MESSAGE, () => this._embeddedFlow?.stop());
|
|
646
619
|
}
|
|
647
620
|
_showUserChangedDialog(_ref) {
|
|
648
|
-
var
|
|
621
|
+
var _newUser$name;
|
|
649
622
|
let {
|
|
650
623
|
newUser,
|
|
651
624
|
onApply,
|
|
@@ -656,12 +629,11 @@ class Auth {
|
|
|
656
629
|
} = this.config;
|
|
657
630
|
this._createInitDeferred();
|
|
658
631
|
const done = () => {
|
|
659
|
-
|
|
660
|
-
(_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);
|
|
632
|
+
this._initDeferred?.resolve?.();
|
|
661
633
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
662
|
-
hide
|
|
634
|
+
hide?.();
|
|
663
635
|
};
|
|
664
|
-
const hide =
|
|
636
|
+
const hide = this._authDialogService?.({
|
|
665
637
|
...this._service,
|
|
666
638
|
title: translations.youHaveLoggedInAs.replace('%userName%', (_newUser$name = newUser.name) !== null && _newUser$name !== void 0 ? _newUser$name : ''),
|
|
667
639
|
loginCaption: translations.login,
|
|
@@ -708,19 +680,17 @@ class Auth {
|
|
|
708
680
|
const REPEAT_TIMEOUT = 5000;
|
|
709
681
|
let timerId;
|
|
710
682
|
return new Promise((resolve, reject) => {
|
|
711
|
-
var _this$_storage12;
|
|
712
683
|
const done = () => {
|
|
713
|
-
var _this$_storage11;
|
|
714
684
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
715
685
|
hide();
|
|
716
686
|
window.removeEventListener('online', onCheckAgain);
|
|
717
|
-
stopListeningCloseMessage
|
|
687
|
+
stopListeningCloseMessage?.();
|
|
718
688
|
/* eslint-enable @typescript-eslint/no-use-before-define */
|
|
719
|
-
|
|
689
|
+
this._storage?.sendMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, Date.now());
|
|
720
690
|
clearTimeout(timerId);
|
|
721
691
|
};
|
|
722
|
-
const stopListeningCloseMessage =
|
|
723
|
-
stopListeningCloseMessage
|
|
692
|
+
const stopListeningCloseMessage = this._storage?.onMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, () => {
|
|
693
|
+
stopListeningCloseMessage?.();
|
|
724
694
|
done();
|
|
725
695
|
resolve();
|
|
726
696
|
});
|
|
@@ -753,7 +723,6 @@ class Auth {
|
|
|
753
723
|
* Wipe accessToken and redirect to auth page with required authorization
|
|
754
724
|
*/
|
|
755
725
|
async logout(extraParams) {
|
|
756
|
-
var _this$_storage13, _this$_requestBuilder3;
|
|
757
726
|
const requestParams = {
|
|
758
727
|
// eslint-disable-next-line camelcase
|
|
759
728
|
request_credentials: 'required',
|
|
@@ -762,19 +731,17 @@ class Auth {
|
|
|
762
731
|
await this._checkBackendsStatusesIfEnabled();
|
|
763
732
|
await this.listeners.trigger('logout');
|
|
764
733
|
this._updateDomainUser(null);
|
|
765
|
-
await
|
|
766
|
-
const authRequest = await
|
|
734
|
+
await this._storage?.wipeToken();
|
|
735
|
+
const authRequest = await this._requestBuilder?.prepareAuthRequest(requestParams);
|
|
767
736
|
if (authRequest != null) {
|
|
768
737
|
this._redirectCurrentPage(authRequest.url);
|
|
769
738
|
}
|
|
770
739
|
}
|
|
771
740
|
async _runEmbeddedLogin() {
|
|
772
|
-
|
|
773
|
-
(_this$_storage14 = this._storage) === null || _this$_storage14 === void 0 ? void 0 : _this$_storage14.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
|
|
741
|
+
this._storage?.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
|
|
774
742
|
try {
|
|
775
|
-
var _this$_embeddedFlow3;
|
|
776
743
|
this._isLoginWindowOpen = true;
|
|
777
|
-
return await
|
|
744
|
+
return await this._embeddedFlow?.authorize();
|
|
778
745
|
} catch (e) {
|
|
779
746
|
throw e;
|
|
780
747
|
} finally {
|
|
@@ -792,8 +759,7 @@ class Auth {
|
|
|
792
759
|
}
|
|
793
760
|
await this._checkBackendsStatusesIfEnabled();
|
|
794
761
|
try {
|
|
795
|
-
|
|
796
|
-
const accessToken = await ((_this$_backgroundFlow4 = this._backgroundFlow) === null || _this$_backgroundFlow4 === void 0 ? void 0 : _this$_backgroundFlow4.authorize());
|
|
762
|
+
const accessToken = await this._backgroundFlow?.authorize();
|
|
797
763
|
const user = await this.getUser(accessToken);
|
|
798
764
|
if (user.guest) {
|
|
799
765
|
this._beforeLogout();
|
|
@@ -820,7 +786,6 @@ class Auth {
|
|
|
820
786
|
* @private
|
|
821
787
|
*/
|
|
822
788
|
async _checkForAuthResponse() {
|
|
823
|
-
var _this$_storage15;
|
|
824
789
|
// getAuthResponseURL may throw an exception
|
|
825
790
|
const authResponse = this._responseParser.getAuthResponseFromURL();
|
|
826
791
|
const {
|
|
@@ -840,29 +805,27 @@ class Auth {
|
|
|
840
805
|
expiresIn,
|
|
841
806
|
accessToken
|
|
842
807
|
} = authResponse;
|
|
843
|
-
const newState = (await (stateId &&
|
|
808
|
+
const newState = (await (stateId && this._storage?.getState(stateId))) || {};
|
|
844
809
|
const scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
|
|
845
810
|
const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
|
|
846
811
|
const expires = TokenValidator._epoch() + effectiveExpiresIn;
|
|
847
812
|
if (accessToken != null) {
|
|
848
|
-
|
|
849
|
-
await ((_this$_storage16 = this._storage) === null || _this$_storage16 === void 0 ? void 0 : _this$_storage16.saveToken({
|
|
813
|
+
await this._storage?.saveToken({
|
|
850
814
|
accessToken,
|
|
851
815
|
scopes,
|
|
852
816
|
expires,
|
|
853
817
|
lifeTime: effectiveExpiresIn
|
|
854
|
-
})
|
|
818
|
+
});
|
|
855
819
|
}
|
|
856
820
|
return newState;
|
|
857
821
|
}
|
|
858
822
|
async _checkForStateRestoration() {
|
|
859
|
-
var _this$_storage17;
|
|
860
823
|
const authResponse = this._responseParser._authResponse;
|
|
861
824
|
if (authResponse && this.config.cleanHash) {
|
|
862
825
|
this.setHash('');
|
|
863
826
|
}
|
|
864
|
-
const stateId = authResponse
|
|
865
|
-
return (await (stateId &&
|
|
827
|
+
const stateId = authResponse?.restoreAuthState;
|
|
828
|
+
return (await (stateId && this._storage?.getState(stateId))) || {};
|
|
866
829
|
}
|
|
867
830
|
_checkBackendsAreUp() {
|
|
868
831
|
const abortCtrl = new AbortController();
|
package/dist/auth/iframe-flow.js
CHANGED
|
@@ -112,8 +112,7 @@ class IFrameFlow {
|
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
const cleanUp = () => {
|
|
115
|
-
|
|
116
|
-
(_this$hideDialog = this.hideDialog) === null || _this$hideDialog === void 0 ? void 0 : _this$hideDialog.call(this);
|
|
115
|
+
this.hideDialog?.();
|
|
117
116
|
removeStateListener();
|
|
118
117
|
removeTokenListener();
|
|
119
118
|
};
|