@aws-amplify/auth 4.5.9-auth-hotfix.4 → 4.5.9-unstable.3
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/dist/aws-amplify-auth.js +227 -269
- package/dist/aws-amplify-auth.js.map +1 -1
- package/dist/aws-amplify-auth.min.js +4 -4
- package/dist/aws-amplify-auth.min.js.map +1 -1
- package/lib/Auth.d.ts +0 -3
- package/lib/Auth.js +145 -170
- package/lib/Auth.js.map +1 -1
- package/lib/urlListener.js +2 -2
- package/lib/urlListener.js.map +1 -1
- package/lib-esm/Auth.d.ts +0 -3
- package/lib-esm/Auth.js +146 -171
- package/lib-esm/Auth.js.map +1 -1
- package/lib-esm/urlListener.js +3 -3
- package/lib-esm/urlListener.js.map +1 -1
- package/package.json +5 -5
- package/src/Auth.ts +90 -109
- package/src/urlListener.ts +3 -3
package/lib-esm/Auth.js
CHANGED
|
@@ -74,7 +74,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
74
74
|
return ar;
|
|
75
75
|
};
|
|
76
76
|
import { isUsernamePasswordOpts, isCognitoHostedOpts, isFederatedSignInOptions, isFederatedSignInOptionsCustom, hasCustomState, } from './types';
|
|
77
|
-
import { Amplify, ConsoleLogger as Logger, Credentials, Hub, StorageHelper, Parser,
|
|
77
|
+
import { Amplify, ConsoleLogger as Logger, Credentials, Hub, StorageHelper, Parser, browserOrNode, UniversalStorage, urlSafeDecode, } from '@aws-amplify/core';
|
|
78
78
|
import { CookieStorage, CognitoUserPool, AuthenticationDetails, CognitoUser, CognitoUserSession, CognitoUserAttribute, CognitoIdToken, CognitoRefreshToken, CognitoAccessToken, } from 'amazon-cognito-identity-js';
|
|
79
79
|
import { parse } from 'url';
|
|
80
80
|
import OAuth from './OAuth/OAuth';
|
|
@@ -108,8 +108,6 @@ var AuthClass = /** @class */ (function () {
|
|
|
108
108
|
this.userPool = null;
|
|
109
109
|
this.user = null;
|
|
110
110
|
this.oAuthFlowInProgress = false;
|
|
111
|
-
this.inflightSessionPromise = null;
|
|
112
|
-
this.inflightSession = false;
|
|
113
111
|
this.Credentials = Credentials;
|
|
114
112
|
this.wrapRefreshSessionCallback = function (callback) {
|
|
115
113
|
var wrapped = function (error, data) {
|
|
@@ -1332,10 +1330,10 @@ var AuthClass = /** @class */ (function () {
|
|
|
1332
1330
|
return new Promise(function (res, rej) {
|
|
1333
1331
|
_this._storageSync
|
|
1334
1332
|
.then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1335
|
-
var user,
|
|
1333
|
+
var user, clientMetadata;
|
|
1336
1334
|
var _this = this;
|
|
1337
|
-
return __generator(this, function (
|
|
1338
|
-
switch (
|
|
1335
|
+
return __generator(this, function (_a) {
|
|
1336
|
+
switch (_a.label) {
|
|
1339
1337
|
case 0:
|
|
1340
1338
|
if (!this.isOAuthInProgress()) return [3 /*break*/, 2];
|
|
1341
1339
|
logger.debug('OAuth signIn in progress, waiting for resolution...');
|
|
@@ -1359,8 +1357,8 @@ var AuthClass = /** @class */ (function () {
|
|
|
1359
1357
|
}
|
|
1360
1358
|
})];
|
|
1361
1359
|
case 1:
|
|
1362
|
-
|
|
1363
|
-
|
|
1360
|
+
_a.sent();
|
|
1361
|
+
_a.label = 2;
|
|
1364
1362
|
case 2:
|
|
1365
1363
|
user = this.userPool.getCurrentUser();
|
|
1366
1364
|
if (!user) {
|
|
@@ -1368,77 +1366,96 @@ var AuthClass = /** @class */ (function () {
|
|
|
1368
1366
|
rej('No current user');
|
|
1369
1367
|
return [2 /*return*/];
|
|
1370
1368
|
}
|
|
1371
|
-
_b.label = 3;
|
|
1372
|
-
case 3:
|
|
1373
|
-
_b.trys.push([3, 7, , 8]);
|
|
1374
|
-
return [4 /*yield*/, this._userSession({ user: user })];
|
|
1375
|
-
case 4:
|
|
1376
|
-
session = _b.sent();
|
|
1377
|
-
bypassCache = params ? params.bypassCache : false;
|
|
1378
|
-
if (!bypassCache) return [3 /*break*/, 6];
|
|
1379
|
-
return [4 /*yield*/, this.Credentials.clear()];
|
|
1380
|
-
case 5:
|
|
1381
|
-
_b.sent();
|
|
1382
|
-
_b.label = 6;
|
|
1383
|
-
case 6:
|
|
1384
1369
|
clientMetadata = this._config.clientMetadata;
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1370
|
+
// refresh the session if the session expired.
|
|
1371
|
+
user.getSession(function (err, session) { return __awaiter(_this, void 0, void 0, function () {
|
|
1372
|
+
var cleanUpError_5, bypassCache, clientMetadata, _a, scope;
|
|
1373
|
+
var _this = this;
|
|
1374
|
+
return __generator(this, function (_b) {
|
|
1375
|
+
switch (_b.label) {
|
|
1376
|
+
case 0:
|
|
1377
|
+
if (!err) return [3 /*break*/, 5];
|
|
1378
|
+
logger.debug('Failed to get the user session', err);
|
|
1379
|
+
if (!this.isSessionInvalid(err)) return [3 /*break*/, 4];
|
|
1380
|
+
_b.label = 1;
|
|
1381
|
+
case 1:
|
|
1382
|
+
_b.trys.push([1, 3, , 4]);
|
|
1383
|
+
return [4 /*yield*/, this.cleanUpInvalidSession(user)];
|
|
1384
|
+
case 2:
|
|
1385
|
+
_b.sent();
|
|
1386
|
+
return [3 /*break*/, 4];
|
|
1387
|
+
case 3:
|
|
1388
|
+
cleanUpError_5 = _b.sent();
|
|
1389
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_5.message));
|
|
1390
|
+
return [2 /*return*/];
|
|
1391
|
+
case 4:
|
|
1392
|
+
rej(err);
|
|
1393
|
+
return [2 /*return*/];
|
|
1394
|
+
case 5:
|
|
1395
|
+
bypassCache = params ? params.bypassCache : false;
|
|
1396
|
+
if (!bypassCache) return [3 /*break*/, 7];
|
|
1397
|
+
return [4 /*yield*/, this.Credentials.clear()];
|
|
1398
|
+
case 6:
|
|
1399
|
+
_b.sent();
|
|
1400
|
+
_b.label = 7;
|
|
1401
|
+
case 7:
|
|
1402
|
+
clientMetadata = this._config.clientMetadata;
|
|
1403
|
+
_a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
|
|
1404
|
+
if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
|
|
1405
|
+
user.getUserData(function (err, data) { return __awaiter(_this, void 0, void 0, function () {
|
|
1406
|
+
var cleanUpError_6, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
|
|
1407
|
+
return __generator(this, function (_a) {
|
|
1408
|
+
switch (_a.label) {
|
|
1409
|
+
case 0:
|
|
1410
|
+
if (!err) return [3 /*break*/, 7];
|
|
1411
|
+
logger.debug('getting user data failed', err);
|
|
1412
|
+
if (!this.isSessionInvalid(err)) return [3 /*break*/, 5];
|
|
1413
|
+
_a.label = 1;
|
|
1414
|
+
case 1:
|
|
1415
|
+
_a.trys.push([1, 3, , 4]);
|
|
1416
|
+
return [4 /*yield*/, this.cleanUpInvalidSession(user)];
|
|
1417
|
+
case 2:
|
|
1418
|
+
_a.sent();
|
|
1419
|
+
return [3 /*break*/, 4];
|
|
1420
|
+
case 3:
|
|
1421
|
+
cleanUpError_6 = _a.sent();
|
|
1422
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
|
|
1423
|
+
return [2 /*return*/];
|
|
1424
|
+
case 4:
|
|
1425
|
+
rej(err);
|
|
1426
|
+
return [3 /*break*/, 6];
|
|
1427
|
+
case 5:
|
|
1428
|
+
res(user);
|
|
1429
|
+
_a.label = 6;
|
|
1430
|
+
case 6: return [2 /*return*/];
|
|
1431
|
+
case 7:
|
|
1432
|
+
preferredMFA = data.PreferredMfaSetting || 'NOMFA';
|
|
1433
|
+
attributeList = [];
|
|
1434
|
+
for (i = 0; i < data.UserAttributes.length; i++) {
|
|
1435
|
+
attribute = {
|
|
1436
|
+
Name: data.UserAttributes[i].Name,
|
|
1437
|
+
Value: data.UserAttributes[i].Value,
|
|
1438
|
+
};
|
|
1439
|
+
userAttribute = new CognitoUserAttribute(attribute);
|
|
1440
|
+
attributeList.push(userAttribute);
|
|
1441
|
+
}
|
|
1442
|
+
attributes = this.attributesToObject(attributeList);
|
|
1443
|
+
Object.assign(user, { attributes: attributes, preferredMFA: preferredMFA });
|
|
1444
|
+
return [2 /*return*/, res(user)];
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
}); }, { bypassCache: bypassCache, clientMetadata: clientMetadata });
|
|
1448
|
+
}
|
|
1449
|
+
else {
|
|
1450
|
+
logger.debug("Unable to get the user data because the " + USER_ADMIN_SCOPE + " " +
|
|
1451
|
+
"is not in the scopes of the access token");
|
|
1426
1452
|
return [2 /*return*/, res(user)];
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
"is not in the scopes of the access token");
|
|
1434
|
-
return [2 /*return*/, res(user)];
|
|
1435
|
-
}
|
|
1436
|
-
return [3 /*break*/, 8];
|
|
1437
|
-
case 7:
|
|
1438
|
-
err_1 = _b.sent();
|
|
1439
|
-
rej(err_1);
|
|
1440
|
-
return [3 /*break*/, 8];
|
|
1441
|
-
case 8: return [2 /*return*/];
|
|
1453
|
+
}
|
|
1454
|
+
return [2 /*return*/];
|
|
1455
|
+
}
|
|
1456
|
+
});
|
|
1457
|
+
}); }, { clientMetadata: clientMetadata });
|
|
1458
|
+
return [2 /*return*/];
|
|
1442
1459
|
}
|
|
1443
1460
|
});
|
|
1444
1461
|
}); })
|
|
@@ -1548,92 +1565,50 @@ var AuthClass = /** @class */ (function () {
|
|
|
1548
1565
|
});
|
|
1549
1566
|
});
|
|
1550
1567
|
};
|
|
1551
|
-
AuthClass.prototype._userSession = function (_a) {
|
|
1552
|
-
var _this = this;
|
|
1553
|
-
var user = _a.user, _b = _a.bypassCache, bypassCache = _b === void 0 ? false : _b;
|
|
1554
|
-
if (!user) {
|
|
1555
|
-
logger.debug('the user is null');
|
|
1556
|
-
return this.rejectAuthError(AuthErrorTypes.NoUserSession);
|
|
1557
|
-
}
|
|
1558
|
-
var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
|
|
1559
|
-
return new Promise(function (resolve, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
1560
|
-
var debounceResolver;
|
|
1561
|
-
var _this = this;
|
|
1562
|
-
return __generator(this, function (_a) {
|
|
1563
|
-
switch (_a.label) {
|
|
1564
|
-
case 0:
|
|
1565
|
-
// debugger;
|
|
1566
|
-
logger.debug('Getting the session from this user:', user);
|
|
1567
|
-
if (!this.inflightSession) return [3 /*break*/, 2];
|
|
1568
|
-
logger.debug('Waiting for another userSession call:');
|
|
1569
|
-
return [4 /*yield*/, this.inflightSessionPromise];
|
|
1570
|
-
case 1:
|
|
1571
|
-
_a.sent();
|
|
1572
|
-
logger.debug('Debouncer resolved');
|
|
1573
|
-
return [3 /*break*/, 3];
|
|
1574
|
-
case 2:
|
|
1575
|
-
logger.debug('Debouncer head');
|
|
1576
|
-
this.inflightSession = true;
|
|
1577
|
-
this.inflightSessionPromise = new Promise(function (res) {
|
|
1578
|
-
debounceResolver = function () {
|
|
1579
|
-
logger.debug('Debouncer resolving');
|
|
1580
|
-
_this.inflightSessionPromise = null;
|
|
1581
|
-
_this.inflightSession = false;
|
|
1582
|
-
res();
|
|
1583
|
-
};
|
|
1584
|
-
});
|
|
1585
|
-
_a.label = 3;
|
|
1586
|
-
case 3:
|
|
1587
|
-
user.getSession(function (err, session) { return __awaiter(_this, void 0, void 0, function () {
|
|
1588
|
-
var cleanUpError_6;
|
|
1589
|
-
return __generator(this, function (_a) {
|
|
1590
|
-
switch (_a.label) {
|
|
1591
|
-
case 0:
|
|
1592
|
-
if (!err) return [3 /*break*/, 5];
|
|
1593
|
-
logger.debug('Failed to get the session from user', user);
|
|
1594
|
-
if (!this.isSessionInvalid(err)) return [3 /*break*/, 4];
|
|
1595
|
-
_a.label = 1;
|
|
1596
|
-
case 1:
|
|
1597
|
-
_a.trys.push([1, 3, , 4]);
|
|
1598
|
-
return [4 /*yield*/, this.cleanUpInvalidSession(user)];
|
|
1599
|
-
case 2:
|
|
1600
|
-
_a.sent();
|
|
1601
|
-
return [3 /*break*/, 4];
|
|
1602
|
-
case 3:
|
|
1603
|
-
cleanUpError_6 = _a.sent();
|
|
1604
|
-
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
|
|
1605
|
-
if (debounceResolver) {
|
|
1606
|
-
debounceResolver();
|
|
1607
|
-
}
|
|
1608
|
-
return [2 /*return*/];
|
|
1609
|
-
case 4:
|
|
1610
|
-
rej(err);
|
|
1611
|
-
if (debounceResolver) {
|
|
1612
|
-
debounceResolver();
|
|
1613
|
-
}
|
|
1614
|
-
return [2 /*return*/];
|
|
1615
|
-
case 5:
|
|
1616
|
-
logger.debug('Succeed to get the user session', session);
|
|
1617
|
-
resolve(session);
|
|
1618
|
-
if (debounceResolver) {
|
|
1619
|
-
debounceResolver();
|
|
1620
|
-
}
|
|
1621
|
-
return [2 /*return*/];
|
|
1622
|
-
}
|
|
1623
|
-
});
|
|
1624
|
-
}); }, { clientMetadata: clientMetadata, bypassCache: bypassCache });
|
|
1625
|
-
return [2 /*return*/];
|
|
1626
|
-
}
|
|
1627
|
-
});
|
|
1628
|
-
}); });
|
|
1629
|
-
};
|
|
1630
1568
|
/**
|
|
1631
1569
|
* Get the corresponding user session
|
|
1632
1570
|
* @param {Object} user - The CognitoUser object
|
|
1633
1571
|
* @return - A promise resolves to the session
|
|
1634
1572
|
*/
|
|
1635
1573
|
AuthClass.prototype.userSession = function (user) {
|
|
1636
|
-
|
|
1574
|
+
var _this = this;
|
|
1575
|
+
if (!user) {
|
|
1576
|
+
logger.debug('the user is null');
|
|
1577
|
+
return this.rejectAuthError(AuthErrorTypes.NoUserSession);
|
|
1578
|
+
}
|
|
1579
|
+
var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
|
|
1580
|
+
return new Promise(function (res, rej) {
|
|
1581
|
+
logger.debug('Getting the session from this user:', user);
|
|
1582
|
+
user.getSession(function (err, session) { return __awaiter(_this, void 0, void 0, function () {
|
|
1583
|
+
var cleanUpError_7;
|
|
1584
|
+
return __generator(this, function (_a) {
|
|
1585
|
+
switch (_a.label) {
|
|
1586
|
+
case 0:
|
|
1587
|
+
if (!err) return [3 /*break*/, 5];
|
|
1588
|
+
logger.debug('Failed to get the session from user', user);
|
|
1589
|
+
if (!this.isSessionInvalid(err)) return [3 /*break*/, 4];
|
|
1590
|
+
_a.label = 1;
|
|
1591
|
+
case 1:
|
|
1592
|
+
_a.trys.push([1, 3, , 4]);
|
|
1593
|
+
return [4 /*yield*/, this.cleanUpInvalidSession(user)];
|
|
1594
|
+
case 2:
|
|
1595
|
+
_a.sent();
|
|
1596
|
+
return [3 /*break*/, 4];
|
|
1597
|
+
case 3:
|
|
1598
|
+
cleanUpError_7 = _a.sent();
|
|
1599
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_7.message));
|
|
1600
|
+
return [2 /*return*/];
|
|
1601
|
+
case 4:
|
|
1602
|
+
rej(err);
|
|
1603
|
+
return [2 /*return*/];
|
|
1604
|
+
case 5:
|
|
1605
|
+
logger.debug('Succeed to get the user session', session);
|
|
1606
|
+
res(session);
|
|
1607
|
+
return [2 /*return*/];
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
}); }, { clientMetadata: clientMetadata });
|
|
1611
|
+
});
|
|
1637
1612
|
};
|
|
1638
1613
|
/**
|
|
1639
1614
|
* Get authenticated credentials of current user.
|
|
@@ -1777,7 +1752,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
1777
1752
|
// we must validate the user as an authenticated user by using getSession
|
|
1778
1753
|
var clientMetadata = _this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
|
|
1779
1754
|
user.getSession(function (err, result) { return __awaiter(_this, void 0, void 0, function () {
|
|
1780
|
-
var
|
|
1755
|
+
var cleanUpError_8;
|
|
1781
1756
|
var _this = this;
|
|
1782
1757
|
return __generator(this, function (_a) {
|
|
1783
1758
|
switch (_a.label) {
|
|
@@ -1793,8 +1768,8 @@ var AuthClass = /** @class */ (function () {
|
|
|
1793
1768
|
_a.sent();
|
|
1794
1769
|
return [3 /*break*/, 4];
|
|
1795
1770
|
case 3:
|
|
1796
|
-
|
|
1797
|
-
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " +
|
|
1771
|
+
cleanUpError_8 = _a.sent();
|
|
1772
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_8.message));
|
|
1798
1773
|
return [2 /*return*/];
|
|
1799
1774
|
case 4: return [2 /*return*/, rej(err)];
|
|
1800
1775
|
case 5:
|
|
@@ -1835,7 +1810,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
1835
1810
|
});
|
|
1836
1811
|
};
|
|
1837
1812
|
AuthClass.prototype.oAuthSignOutRedirect = function (resolve, reject) {
|
|
1838
|
-
var isBrowser =
|
|
1813
|
+
var isBrowser = browserOrNode().isBrowser;
|
|
1839
1814
|
if (isBrowser) {
|
|
1840
1815
|
this.oAuthSignOutRedirectOrReject(reject);
|
|
1841
1816
|
}
|
|
@@ -2018,7 +1993,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
2018
1993
|
*/
|
|
2019
1994
|
AuthClass.prototype.currentUserInfo = function () {
|
|
2020
1995
|
return __awaiter(this, void 0, void 0, function () {
|
|
2021
|
-
var source, user, attributes, userAttrs, credentials, e_12, info,
|
|
1996
|
+
var source, user, attributes, userAttrs, credentials, e_12, info, err_1, user;
|
|
2022
1997
|
return __generator(this, function (_a) {
|
|
2023
1998
|
switch (_a.label) {
|
|
2024
1999
|
case 0:
|
|
@@ -2059,8 +2034,8 @@ var AuthClass = /** @class */ (function () {
|
|
|
2059
2034
|
};
|
|
2060
2035
|
return [2 /*return*/, info];
|
|
2061
2036
|
case 8:
|
|
2062
|
-
|
|
2063
|
-
logger.error('currentUserInfo error',
|
|
2037
|
+
err_1 = _a.sent();
|
|
2038
|
+
logger.error('currentUserInfo error', err_1);
|
|
2064
2039
|
return [2 /*return*/, {}];
|
|
2065
2040
|
case 9:
|
|
2066
2041
|
if (source === 'federated') {
|
|
@@ -2141,7 +2116,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
2141
2116
|
*/
|
|
2142
2117
|
AuthClass.prototype._handleAuthResponse = function (URL) {
|
|
2143
2118
|
return __awaiter(this, void 0, void 0, function () {
|
|
2144
|
-
var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState,
|
|
2119
|
+
var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState, err_2;
|
|
2145
2120
|
return __generator(this, function (_b) {
|
|
2146
2121
|
switch (_b.label) {
|
|
2147
2122
|
case 0:
|
|
@@ -2157,7 +2132,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
2157
2132
|
throw new Error("OAuth responses require a User Pool defined in config");
|
|
2158
2133
|
}
|
|
2159
2134
|
dispatchAuthEvent('parsingCallbackUrl', { url: URL }, "The callback url is being parsed");
|
|
2160
|
-
currentUrl = URL || (
|
|
2135
|
+
currentUrl = URL || (browserOrNode().isBrowser ? window.location.href : '');
|
|
2161
2136
|
hasCodeOrError = !!(parse(currentUrl).query || '')
|
|
2162
2137
|
.split('&')
|
|
2163
2138
|
.map(function (entry) { return entry.split('='); })
|
|
@@ -2214,16 +2189,16 @@ var AuthClass = /** @class */ (function () {
|
|
|
2214
2189
|
//#endregion
|
|
2215
2190
|
return [2 /*return*/, credentials];
|
|
2216
2191
|
case 6:
|
|
2217
|
-
|
|
2218
|
-
logger.debug('Error in cognito hosted auth response',
|
|
2192
|
+
err_2 = _b.sent();
|
|
2193
|
+
logger.debug('Error in cognito hosted auth response', err_2);
|
|
2219
2194
|
// Just like a successful handling of `?code`, replace the window history to "dispose" of the `code`.
|
|
2220
2195
|
// Otherwise, reloading the page will throw errors as the `code` has already been spent.
|
|
2221
2196
|
if (window && typeof window.history !== 'undefined') {
|
|
2222
2197
|
window.history.replaceState({}, null, this._config.oauth.redirectSignIn);
|
|
2223
2198
|
}
|
|
2224
|
-
dispatchAuthEvent('signIn_failure',
|
|
2225
|
-
dispatchAuthEvent('cognitoHostedUI_failure',
|
|
2226
|
-
dispatchAuthEvent('customState_failure',
|
|
2199
|
+
dispatchAuthEvent('signIn_failure', err_2, "The OAuth response flow failed");
|
|
2200
|
+
dispatchAuthEvent('cognitoHostedUI_failure', err_2, "A failure occurred when returning to the Cognito Hosted UI");
|
|
2201
|
+
dispatchAuthEvent('customState_failure', err_2, "A failure occurred when returning state");
|
|
2227
2202
|
return [3 /*break*/, 7];
|
|
2228
2203
|
case 7: return [3 /*break*/, 9];
|
|
2229
2204
|
case 8:
|