@jetbrains/ring-ui 6.0.52 → 6.0.54-beta.0
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.
|
@@ -129,7 +129,7 @@ export default class Auth implements HTTPAuth {
|
|
|
129
129
|
listeners: Listeners<AuthPayloadMap>;
|
|
130
130
|
http: HTTP;
|
|
131
131
|
private _service;
|
|
132
|
-
readonly _storage: AuthStorage<number
|
|
132
|
+
readonly _storage: AuthStorage<number>;
|
|
133
133
|
private _responseParser;
|
|
134
134
|
private readonly _requestBuilder;
|
|
135
135
|
_backgroundFlow: BackgroundFlow | null;
|
|
@@ -174,7 +174,7 @@ export default class Auth implements HTTPAuth {
|
|
|
174
174
|
/**
|
|
175
175
|
* @return {Promise.<object>}
|
|
176
176
|
*/
|
|
177
|
-
getUser(accessToken?: string | null | undefined): Promise<any
|
|
177
|
+
getUser(accessToken?: string | null | undefined): Promise<any>;
|
|
178
178
|
/**
|
|
179
179
|
* @return {Promise.<object>}
|
|
180
180
|
*/
|
|
@@ -197,7 +197,7 @@ export default class Auth implements HTTPAuth {
|
|
|
197
197
|
*/
|
|
198
198
|
login(): Promise<void>;
|
|
199
199
|
switchUser(): Promise<void>;
|
|
200
|
-
_makeStateFromResponse(authResponse: AuthResponse): AuthState;
|
|
200
|
+
_makeStateFromResponse(authResponse: AuthResponse): AuthState | null;
|
|
201
201
|
/**
|
|
202
202
|
* Check if the hash contains an access token.
|
|
203
203
|
* If it does, extract the state, compare with
|
|
@@ -58,7 +58,7 @@ export default class Auth {
|
|
|
58
58
|
listeners = new Listeners();
|
|
59
59
|
http;
|
|
60
60
|
_service = {};
|
|
61
|
-
_storage
|
|
61
|
+
_storage;
|
|
62
62
|
_responseParser = new AuthResponseParser();
|
|
63
63
|
_requestBuilder = null;
|
|
64
64
|
_backgroundFlow;
|
|
@@ -694,23 +694,24 @@ export default class Auth {
|
|
|
694
694
|
_makeStateFromResponse(authResponse) {
|
|
695
695
|
const { state } = authResponse;
|
|
696
696
|
if (!state) {
|
|
697
|
-
|
|
697
|
+
throw new Error('No state in AuthResponse');
|
|
698
698
|
}
|
|
699
699
|
const { scope: defaultScope } = this.config;
|
|
700
|
+
let urlFromState = null;
|
|
700
701
|
try {
|
|
701
|
-
|
|
702
|
-
if (urlFromState.origin !== window.location.origin) {
|
|
703
|
-
return {};
|
|
704
|
-
}
|
|
705
|
-
return {
|
|
706
|
-
restoreLocation: state,
|
|
707
|
-
created: Date.now(),
|
|
708
|
-
scopes: defaultScope
|
|
709
|
-
};
|
|
702
|
+
urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
|
|
710
703
|
}
|
|
711
|
-
catch
|
|
712
|
-
return
|
|
704
|
+
catch {
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
if (urlFromState.origin !== window.location.origin) {
|
|
708
|
+
throw new Error(`State contains URL with different origin: "${state}"`);
|
|
713
709
|
}
|
|
710
|
+
return {
|
|
711
|
+
restoreLocation: state,
|
|
712
|
+
created: Date.now(),
|
|
713
|
+
scopes: defaultScope
|
|
714
|
+
};
|
|
714
715
|
}
|
|
715
716
|
/**
|
|
716
717
|
* Check if the hash contains an access token.
|
|
@@ -731,8 +732,16 @@ export default class Auth {
|
|
|
731
732
|
return undefined;
|
|
732
733
|
}
|
|
733
734
|
const { state: stateId, scope, expiresIn, accessToken } = authResponse;
|
|
734
|
-
|
|
735
|
-
|
|
735
|
+
let newState = null;
|
|
736
|
+
if (stateId) {
|
|
737
|
+
newState = await this._storage.getState(stateId);
|
|
738
|
+
if (!newState) {
|
|
739
|
+
newState = this._makeStateFromResponse(authResponse);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
if (!newState) {
|
|
743
|
+
throw new Error(`Could not create state where stateId="${stateId}"`);
|
|
744
|
+
}
|
|
736
745
|
const scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
|
|
737
746
|
const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
|
|
738
747
|
const expires = TokenValidator._epoch() + effectiveExpiresIn;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { PureComponent } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import deprecate from 'util-deprecate';
|
|
5
4
|
import dataTests from '../global/data-tests';
|
|
6
5
|
import style from './badge.css';
|
|
7
|
-
const warn = deprecate(() => { }, 'Badge is deprecated and will be removed in RingUI 7.0. Use Tag instead.');
|
|
8
6
|
/**
|
|
9
7
|
* @name Badge
|
|
10
8
|
*/
|
|
@@ -20,7 +18,6 @@ export default class Badge extends PureComponent {
|
|
|
20
18
|
'data-test': PropTypes.string
|
|
21
19
|
};
|
|
22
20
|
render() {
|
|
23
|
-
warn();
|
|
24
21
|
const {
|
|
25
22
|
// Modifiers
|
|
26
23
|
gray, valid, invalid, disabled,
|
|
@@ -7,6 +7,7 @@ declare enum Theme {
|
|
|
7
7
|
export declare const ThemeContext: import("react").Context<{
|
|
8
8
|
theme: Theme.LIGHT | Theme.DARK;
|
|
9
9
|
}>;
|
|
10
|
+
export declare const GLOBAL_DARK_CLASS_NAME = "ring-ui-theme-dark";
|
|
10
11
|
export declare function useTheme(): Theme.LIGHT | Theme.DARK;
|
|
11
12
|
export declare function useThemeClasses(theme: Theme): string;
|
|
12
13
|
export interface WithThemeClassesProps {
|
|
@@ -13,7 +13,7 @@ var Theme;
|
|
|
13
13
|
Theme["DARK"] = "dark";
|
|
14
14
|
})(Theme || (Theme = {}));
|
|
15
15
|
export const ThemeContext = createContext({ theme: Theme.LIGHT });
|
|
16
|
-
const GLOBAL_DARK_CLASS_NAME = 'ring-ui-theme-dark';
|
|
16
|
+
export const GLOBAL_DARK_CLASS_NAME = 'ring-ui-theme-dark';
|
|
17
17
|
const darkMatcher = window.matchMedia('(prefers-color-scheme: dark)');
|
|
18
18
|
export function useTheme() {
|
|
19
19
|
const [dark, setDark] = useState(darkMatcher.matches);
|
|
@@ -156,9 +156,9 @@ class Shortcuts {
|
|
|
156
156
|
!(element instanceof HTMLElement) ||
|
|
157
157
|
key == null ||
|
|
158
158
|
element.matches(this.ALLOW_SHORTCUTS_SELECTOR) ||
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
element.closest(this.ALLOW_SHORTCUTS_SELECTOR) != null ||
|
|
160
|
+
(element.dataset.enabledShortcuts != null &&
|
|
161
|
+
element.dataset.enabledShortcuts.split(',').includes(key))) {
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
164
|
const elementContentEditableAttribute = element.contentEditable;
|