@jetbrains/ring-ui 5.0.163 → 5.0.165

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.
@@ -1,8 +1,8 @@
1
1
  import Listeners, { Handler } from '../global/listeners';
2
2
  import HTTP, { HTTPAuth, RequestParams } from '../http/http';
3
3
  import AuthDialogService from '../auth-dialog-service/auth-dialog-service';
4
- import AuthStorage from './storage';
5
- import { AuthError } from './response-parser';
4
+ import AuthStorage, { AuthState } from './storage';
5
+ import { AuthError, AuthResponse } from './response-parser';
6
6
  import AuthRequestBuilder from './request-builder';
7
7
  import BackgroundFlow from './background-flow';
8
8
  import TokenValidator, { TokenValidationError, TokenValidatorConfig } from './token-validator';
@@ -197,6 +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
201
  /**
201
202
  * Check if the hash contains an access token.
202
203
  * If it does, extract the state, compare with
@@ -691,6 +691,27 @@ export default class Auth {
691
691
  }
692
692
  await this._runEmbeddedLogin();
693
693
  }
694
+ _makeStateFromResponse(authResponse) {
695
+ const { state } = authResponse;
696
+ if (!state) {
697
+ return {};
698
+ }
699
+ const { scope: defaultScope } = this.config;
700
+ try {
701
+ const urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
702
+ if (urlFromState.origin !== window.location.origin) {
703
+ return {};
704
+ }
705
+ return {
706
+ restoreLocation: state,
707
+ created: Date.now(),
708
+ scopes: defaultScope
709
+ };
710
+ }
711
+ catch (e) {
712
+ return {};
713
+ }
714
+ }
694
715
  /**
695
716
  * Check if the hash contains an access token.
696
717
  * If it does, extract the state, compare with
@@ -710,7 +731,8 @@ export default class Auth {
710
731
  return undefined;
711
732
  }
712
733
  const { state: stateId, scope, expiresIn, accessToken } = authResponse;
713
- const newState = await (stateId && this._storage?.getState(stateId)) || {};
734
+ const newState = await (stateId && this._storage?.getState(stateId)) ||
735
+ this._makeStateFromResponse(authResponse);
714
736
  const scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
715
737
  const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
716
738
  const expires = TokenValidator._epoch() + effectiveExpiresIn;
@@ -79,8 +79,6 @@
79
79
  padding-top: unit;
80
80
  padding-bottom: 6px;
81
81
 
82
- text-transform: capitalize;
83
-
84
82
  color: var(--ring-text-color);
85
83
  border-bottom: none;
86
84
 
@@ -152,7 +152,10 @@ function _regeneratorRuntime() {
152
152
  if ("executing" === state) throw new Error("Generator is already running");
153
153
  if ("completed" === state) {
154
154
  if ("throw" === method) throw arg;
155
- return doneResult();
155
+ return {
156
+ value: void 0,
157
+ done: !0
158
+ };
156
159
  }
157
160
  for (context.method = method, context.arg = arg;;) {
158
161
  var delegate = context.delegate;
@@ -205,7 +208,7 @@ function _regeneratorRuntime() {
205
208
  }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
206
209
  }
207
210
  function values(iterable) {
208
- if (iterable) {
211
+ if (iterable || "" === iterable) {
209
212
  var iteratorMethod = iterable[iteratorSymbol];
210
213
  if (iteratorMethod) return iteratorMethod.call(iterable);
211
214
  if ("function" == typeof iterable.next) return iterable;
@@ -218,15 +221,7 @@ function _regeneratorRuntime() {
218
221
  return next.next = next;
219
222
  }
220
223
  }
221
- return {
222
- next: doneResult
223
- };
224
- }
225
- function doneResult() {
226
- return {
227
- value: undefined,
228
- done: !0
229
- };
224
+ throw new TypeError(typeof iterable + " is not iterable");
230
225
  }
231
226
  return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
232
227
  value: GeneratorFunctionPrototype,
package/dist/auth/auth.js CHANGED
@@ -80,6 +80,8 @@ import '../link/link.js';
80
80
  import '../_helpers/link.js';
81
81
  import '../group/group.js';
82
82
  import '../_helpers/group.js';
83
+ import 'core-js/modules/web.url.js';
84
+ import 'core-js/modules/web.url-search-params.js';
83
85
  import 'core-js/modules/es.parse-int.js';
84
86
  import 'core-js/modules/es.string.search.js';
85
87
  import '../global/listeners.js';
@@ -1,8 +1,8 @@
1
1
  import Listeners, { Handler } from '../global/listeners';
2
2
  import HTTP, { HTTPAuth, RequestParams } from '../http/http';
3
3
  import AuthDialogService from '../auth-dialog-service/auth-dialog-service';
4
- import AuthStorage from './storage';
5
- import { AuthError } from './response-parser';
4
+ import AuthStorage, { AuthState } from './storage';
5
+ import { AuthError, AuthResponse } from './response-parser';
6
6
  import AuthRequestBuilder from './request-builder';
7
7
  import BackgroundFlow from './background-flow';
8
8
  import TokenValidator, { TokenValidationError, TokenValidatorConfig } from './token-validator';
@@ -197,6 +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
201
  /**
201
202
  * Check if the hash contains an access token.
202
203
  * If it does, extract the state, compare with
@@ -12,6 +12,8 @@ import 'core-js/modules/es.string.includes.js';
12
12
  import 'core-js/modules/es.regexp.exec.js';
13
13
  import 'core-js/modules/es.string.replace.js';
14
14
  import 'core-js/modules/es.regexp.to-string.js';
15
+ import 'core-js/modules/web.url.js';
16
+ import 'core-js/modules/web.url-search-params.js';
15
17
  import 'core-js/modules/es.parse-int.js';
16
18
  import 'core-js/modules/es.string.search.js';
17
19
  import { getAbsoluteBaseURL, fixUrl } from '../global/url.js';
@@ -1398,6 +1400,28 @@ var Auth = /*#__PURE__*/function () {
1398
1400
  }
1399
1401
  return switchUser;
1400
1402
  }()
1403
+ }, {
1404
+ key: "_makeStateFromResponse",
1405
+ value: function _makeStateFromResponse(authResponse) {
1406
+ var state = authResponse.state;
1407
+ if (!state) {
1408
+ return {};
1409
+ }
1410
+ var defaultScope = this.config.scope;
1411
+ try {
1412
+ var urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
1413
+ if (urlFromState.origin !== window.location.origin) {
1414
+ return {};
1415
+ }
1416
+ return {
1417
+ restoreLocation: state,
1418
+ created: Date.now(),
1419
+ scopes: defaultScope
1420
+ };
1421
+ } catch (e) {
1422
+ return {};
1423
+ }
1424
+ }
1401
1425
  /**
1402
1426
  * Check if the hash contains an access token.
1403
1427
  * If it does, extract the state, compare with
@@ -1436,7 +1460,7 @@ var Auth = /*#__PURE__*/function () {
1436
1460
  _context20.next = 11;
1437
1461
  break;
1438
1462
  }
1439
- _context20.t0 = {};
1463
+ _context20.t0 = this._makeStateFromResponse(authResponse);
1440
1464
  case 11:
1441
1465
  newState = _context20.t0;
1442
1466
  scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
@@ -85,6 +85,8 @@ import '../link/link.js';
85
85
  import '../_helpers/link.js';
86
86
  import '../group/group.js';
87
87
  import '../_helpers/group.js';
88
+ import 'core-js/modules/web.url.js';
89
+ import 'core-js/modules/web.url-search-params.js';
88
90
  import 'core-js/modules/es.string.search.js';
89
91
  import '../global/listeners.js';
90
92
  import '../global/promise-with-timeout.js';
@@ -81,6 +81,8 @@ import '../link/link.js';
81
81
  import '../_helpers/link.js';
82
82
  import '../group/group.js';
83
83
  import '../_helpers/group.js';
84
+ import 'core-js/modules/web.url.js';
85
+ import 'core-js/modules/web.url-search-params.js';
84
86
  import 'core-js/modules/es.parse-int.js';
85
87
  import 'core-js/modules/es.string.search.js';
86
88
  import '../global/listeners.js';
@@ -125,6 +125,8 @@ import '../alert/container.js';
125
125
  import '../group/group.js';
126
126
  import '../_helpers/group.js';
127
127
  import '../auth/auth__core.js';
128
+ import 'core-js/modules/web.url.js';
129
+ import 'core-js/modules/web.url-search-params.js';
128
130
  import 'core-js/modules/es.parse-int.js';
129
131
  import 'core-js/modules/es.string.search.js';
130
132
  import '../global/listeners.js';
@@ -81,6 +81,8 @@ import '../_helpers/link.js';
81
81
  import '../group/group.js';
82
82
  import '../_helpers/group.js';
83
83
  import '../global/react-render-adapter.js';
84
+ import 'core-js/modules/web.url.js';
85
+ import 'core-js/modules/web.url-search-params.js';
84
86
  import 'core-js/modules/es.parse-int.js';
85
87
  import 'core-js/modules/es.string.search.js';
86
88
  import '../global/listeners.js';
@@ -82,6 +82,8 @@ import '../link/link.js';
82
82
  import '../_helpers/link.js';
83
83
  import '../group/group.js';
84
84
  import '../_helpers/group.js';
85
+ import 'core-js/modules/web.url.js';
86
+ import 'core-js/modules/web.url-search-params.js';
85
87
  import 'core-js/modules/es.parse-int.js';
86
88
  import 'core-js/modules/es.string.search.js';
87
89
  import '../global/listeners.js';
@@ -12,11 +12,11 @@ var MAJOR_VERSION_INDEX = 0;
12
12
  /**
13
13
  * SUPPORTED_BROWSERS are defined by Babel plugin, see babel config
14
14
  */
15
- if (!["and_chr 114", "and_uc 15.5", "chrome 114", "chrome 113", "chrome 109", "edge 114", "firefox 114", "ios_saf 16.5", "ios_saf 16.4", "ios_saf 16.3", "ios_saf 16.1", "opera 99", "safari 16.5", "samsung 21"]) {
15
+ if (!["and_chr 115", "and_uc 15.5", "chrome 115", "chrome 114", "chrome 109", "edge 114", "firefox 115", "ios_saf 16.5", "ios_saf 16.3", "ios_saf 16.1", "op_mini all", "opera 99", "safari 16.5", "samsung 21"]) {
16
16
  // eslint-disable-next-line no-console
17
17
  console.warn('Ring UI: no SUPPORTED_BROWSERS passed. Please check babel config.');
18
18
  }
19
- var SUPPORTED = ["and_chr 114", "and_uc 15.5", "chrome 114", "chrome 113", "chrome 109", "edge 114", "firefox 114", "ios_saf 16.5", "ios_saf 16.4", "ios_saf 16.3", "ios_saf 16.1", "opera 99", "safari 16.5", "samsung 21"] || [];
19
+ var SUPPORTED = ["and_chr 115", "and_uc 15.5", "chrome 115", "chrome 114", "chrome 109", "edge 114", "firefox 115", "ios_saf 16.5", "ios_saf 16.3", "ios_saf 16.1", "op_mini all", "opera 99", "safari 16.5", "samsung 21"] || [];
20
20
  var WHITE_LISTED_BROWSERS = ['chrome', 'firefox', 'safari', 'edge'];
21
21
  var WHITE_LIST = SUPPORTED.reduce(function (acc, item) {
22
22
  var _item$match;
@@ -84,6 +84,8 @@ import '../_helpers/link.js';
84
84
  import '../group/group.js';
85
85
  import '../_helpers/group.js';
86
86
  import '../auth/auth__core.js';
87
+ import 'core-js/modules/web.url.js';
88
+ import 'core-js/modules/web.url-search-params.js';
87
89
  import 'core-js/modules/es.parse-int.js';
88
90
  import 'core-js/modules/es.string.search.js';
89
91
  import '../global/listeners.js';