@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
|
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",
|
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
|
-
|
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
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
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
|
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
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
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
|
-
|
1470
|
-
case
|
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 =
|
1467
|
+
_context20.next = 18;
|
1476
1468
|
break;
|
1477
1469
|
}
|
1478
|
-
_context20.next =
|
1479
|
-
return (_this$
|
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
|
1477
|
+
case 18:
|
1486
1478
|
return _context20.abrupt("return", newState);
|
1487
|
-
case
|
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$
|
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$
|
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 =
|
162
|
+
_context.next = 9;
|
163
163
|
break;
|
164
164
|
case 6:
|
165
165
|
_context.prev = 6;
|
166
166
|
_context.t0 = _context["catch"](1);
|
167
|
-
|
168
|
-
|
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(
|
173
|
-
case
|
174
|
+
return _context.finish(9);
|
175
|
+
case 12:
|
174
176
|
case "end":
|
175
177
|
return _context.stop();
|
176
178
|
}
|
177
|
-
}, _callee, null, [[1, 6,
|
179
|
+
}, _callee, null, [[1, 6, 9, 12]]);
|
178
180
|
})));
|
179
181
|
_defineProperty(_this, "logout", function () {
|
180
182
|
return _this.props.auth.logout();
|