@jetbrains/ring-ui-built 6.0.54-beta.0 → 6.0.54

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> | null;
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> | undefined;
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 | null;
200
+ _makeStateFromResponse(authResponse: AuthResponse): AuthState;
201
201
  /**
202
202
  * Check if the hash contains an access token.
203
203
  * If it does, extract the state, compare with
@@ -137,7 +137,7 @@ var Auth = /*#__PURE__*/function () {
137
137
  _defineProperty(this, "listeners", new Listeners());
138
138
  _defineProperty(this, "http", void 0);
139
139
  _defineProperty(this, "_service", {});
140
- _defineProperty(this, "_storage", void 0);
140
+ _defineProperty(this, "_storage", null);
141
141
  _defineProperty(this, "_responseParser", new AuthResponseParser());
142
142
  _defineProperty(this, "_requestBuilder", null);
143
143
  _defineProperty(this, "_backgroundFlow", void 0);
@@ -1402,23 +1402,22 @@ var Auth = /*#__PURE__*/function () {
1402
1402
  value: function _makeStateFromResponse(authResponse) {
1403
1403
  var state = authResponse.state;
1404
1404
  if (!state) {
1405
- throw new Error('No state in AuthResponse');
1405
+ return {};
1406
1406
  }
1407
1407
  var defaultScope = this.config.scope;
1408
- var urlFromState = null;
1409
1408
  try {
1410
- urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
1411
- } catch (_unused2) {
1412
- return null;
1413
- }
1414
- if (urlFromState.origin !== window.location.origin) {
1415
- throw new Error("State contains URL with different origin: \"".concat(state, "\""));
1409
+ var urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
1410
+ if (urlFromState.origin !== window.location.origin) {
1411
+ return {};
1412
+ }
1413
+ return {
1414
+ restoreLocation: state,
1415
+ created: Date.now(),
1416
+ scopes: defaultScope
1417
+ };
1418
+ } catch (e) {
1419
+ return {};
1416
1420
  }
1417
- return {
1418
- restoreLocation: state,
1419
- created: Date.now(),
1420
- scopes: defaultScope
1421
- };
1422
1421
  }
1423
1422
  /**
1424
1423
  * Check if the hash contains an access token.
@@ -1432,7 +1431,8 @@ var Auth = /*#__PURE__*/function () {
1432
1431
  key: "_checkForAuthResponse",
1433
1432
  value: (function () {
1434
1433
  var _checkForAuthResponse2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1435
- var authResponse, _this$config4, defaultScope, defaultExpiresIn, cleanHash, stateId, scope, expiresIn, accessToken, newState, scopes, effectiveExpiresIn, expires, _this$_storage12;
1434
+ var _this$_storage12;
1435
+ var authResponse, _this$config4, defaultScope, defaultExpiresIn, cleanHash, stateId, scope, expiresIn, accessToken, newState, scopes, effectiveExpiresIn, expires, _this$_storage13;
1436
1436
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1437
1437
  while (1) switch (_context20.prev = _context20.next) {
1438
1438
  case 0:
@@ -1449,42 +1449,34 @@ var Auth = /*#__PURE__*/function () {
1449
1449
  return _context20.abrupt("return", undefined);
1450
1450
  case 5:
1451
1451
  stateId = authResponse.state, scope = authResponse.scope, expiresIn = authResponse.expiresIn, accessToken = authResponse.accessToken;
1452
- newState = null;
1453
- if (!stateId) {
1454
- _context20.next = 12;
1455
- break;
1456
- }
1457
- _context20.next = 10;
1458
- return this._storage.getState(stateId);
1459
- case 10:
1460
- newState = _context20.sent;
1461
- if (!newState) {
1462
- newState = this._makeStateFromResponse(authResponse);
1463
- }
1464
- case 12:
1465
- if (newState) {
1466
- _context20.next = 14;
1452
+ _context20.next = 8;
1453
+ return stateId && ((_this$_storage12 = this._storage) === null || _this$_storage12 === void 0 ? void 0 : _this$_storage12.getState(stateId));
1454
+ case 8:
1455
+ _context20.t0 = _context20.sent;
1456
+ if (_context20.t0) {
1457
+ _context20.next = 11;
1467
1458
  break;
1468
1459
  }
1469
- throw new Error("Could not create state where stateId=\"".concat(stateId, "\""));
1470
- case 14:
1460
+ _context20.t0 = this._makeStateFromResponse(authResponse);
1461
+ case 11:
1462
+ newState = _context20.t0;
1471
1463
  scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
1472
1464
  effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
1473
1465
  expires = TokenValidator._epoch() + effectiveExpiresIn;
1474
1466
  if (!(accessToken != null)) {
1475
- _context20.next = 20;
1467
+ _context20.next = 18;
1476
1468
  break;
1477
1469
  }
1478
- _context20.next = 20;
1479
- return (_this$_storage12 = this._storage) === null || _this$_storage12 === void 0 ? void 0 : _this$_storage12.saveToken({
1470
+ _context20.next = 18;
1471
+ return (_this$_storage13 = this._storage) === null || _this$_storage13 === void 0 ? void 0 : _this$_storage13.saveToken({
1480
1472
  accessToken,
1481
1473
  scopes,
1482
1474
  expires,
1483
1475
  lifeTime: effectiveExpiresIn
1484
1476
  });
1485
- case 20:
1477
+ case 18:
1486
1478
  return _context20.abrupt("return", newState);
1487
- case 21:
1479
+ case 19:
1488
1480
  case "end":
1489
1481
  return _context20.stop();
1490
1482
  }
@@ -1499,7 +1491,7 @@ var Auth = /*#__PURE__*/function () {
1499
1491
  key: "_checkForStateRestoration",
1500
1492
  value: function () {
1501
1493
  var _checkForStateRestoration2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1502
- var _this$_storage13;
1494
+ var _this$_storage14;
1503
1495
  var authResponse, stateId;
1504
1496
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1505
1497
  while (1) switch (_context21.prev = _context21.next) {
@@ -1510,7 +1502,7 @@ var Auth = /*#__PURE__*/function () {
1510
1502
  }
1511
1503
  stateId = authResponse === null || authResponse === void 0 ? void 0 : authResponse.restoreAuthState;
1512
1504
  _context21.next = 5;
1513
- return stateId && ((_this$_storage13 = this._storage) === null || _this$_storage13 === void 0 ? void 0 : _this$_storage13.getState(stateId));
1505
+ return stateId && ((_this$_storage14 = this._storage) === null || _this$_storage14 === void 0 ? void 0 : _this$_storage14.getState(stateId));
1514
1506
  case 5:
1515
1507
  _context21.t0 = _context21.sent;
1516
1508
  if (_context21.t0) {
@@ -159,22 +159,24 @@ var SmartProfile = /*#__PURE__*/function (_PureComponent) {
159
159
  _context.next = 4;
160
160
  return _this.props.auth.login();
161
161
  case 4:
162
- _context.next = 8;
162
+ _context.next = 9;
163
163
  break;
164
164
  case 6:
165
165
  _context.prev = 6;
166
166
  _context.t0 = _context["catch"](1);
167
- case 8:
168
- _context.prev = 8;
167
+ // eslint-disable-next-line no-console
168
+ console.debug('Profile login errored', _context.t0);
169
+ case 9:
170
+ _context.prev = 9;
169
171
  _this.setState({
170
172
  loading: false
171
173
  });
172
- return _context.finish(8);
173
- case 11:
174
+ return _context.finish(9);
175
+ case 12:
174
176
  case "end":
175
177
  return _context.stop();
176
178
  }
177
- }, _callee, null, [[1, 6, 8, 11]]);
179
+ }, _callee, null, [[1, 6, 9, 12]]);
178
180
  })));
179
181
  _defineProperty(_this, "logout", function () {
180
182
  return _this.props.auth.logout();
@@ -93,7 +93,9 @@ function showAuthDialog() {
93
93
  show: true
94
94
  }));
95
95
  return function () {
96
- reactRoot.unmount();
96
+ renderLoginDialog(_objectSpread2(_objectSpread2({}, props), {}, {
97
+ show: false
98
+ }));
97
99
  };
98
100
  }
99
101
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui-built",
3
- "version": "6.0.54-beta.0",
3
+ "version": "6.0.54",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",