@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/Auth.d.ts
CHANGED
|
@@ -15,8 +15,6 @@ export declare class AuthClass {
|
|
|
15
15
|
private _storageSync;
|
|
16
16
|
private oAuthFlowInProgress;
|
|
17
17
|
private pendingSignIn;
|
|
18
|
-
private inflightSessionPromise;
|
|
19
|
-
private inflightSession;
|
|
20
18
|
Credentials: import("@aws-amplify/core").CredentialsClass;
|
|
21
19
|
/**
|
|
22
20
|
* Initialize Auth with AWS configurations
|
|
@@ -194,7 +192,6 @@ export declare class AuthClass {
|
|
|
194
192
|
* @return - A promise resolves to session object if success
|
|
195
193
|
*/
|
|
196
194
|
currentSession(): Promise<CognitoUserSession>;
|
|
197
|
-
private _userSession;
|
|
198
195
|
/**
|
|
199
196
|
* Get the corresponding user session
|
|
200
197
|
* @param {Object} user - The CognitoUser object
|
package/lib/Auth.js
CHANGED
|
@@ -113,8 +113,6 @@ var AuthClass = /** @class */ (function () {
|
|
|
113
113
|
this.userPool = null;
|
|
114
114
|
this.user = null;
|
|
115
115
|
this.oAuthFlowInProgress = false;
|
|
116
|
-
this.inflightSessionPromise = null;
|
|
117
|
-
this.inflightSession = false;
|
|
118
116
|
this.Credentials = core_1.Credentials;
|
|
119
117
|
this.wrapRefreshSessionCallback = function (callback) {
|
|
120
118
|
var wrapped = function (error, data) {
|
|
@@ -1337,10 +1335,10 @@ var AuthClass = /** @class */ (function () {
|
|
|
1337
1335
|
return new Promise(function (res, rej) {
|
|
1338
1336
|
_this._storageSync
|
|
1339
1337
|
.then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1340
|
-
var user,
|
|
1338
|
+
var user, clientMetadata;
|
|
1341
1339
|
var _this = this;
|
|
1342
|
-
return __generator(this, function (
|
|
1343
|
-
switch (
|
|
1340
|
+
return __generator(this, function (_a) {
|
|
1341
|
+
switch (_a.label) {
|
|
1344
1342
|
case 0:
|
|
1345
1343
|
if (!this.isOAuthInProgress()) return [3 /*break*/, 2];
|
|
1346
1344
|
logger.debug('OAuth signIn in progress, waiting for resolution...');
|
|
@@ -1364,8 +1362,8 @@ var AuthClass = /** @class */ (function () {
|
|
|
1364
1362
|
}
|
|
1365
1363
|
})];
|
|
1366
1364
|
case 1:
|
|
1367
|
-
|
|
1368
|
-
|
|
1365
|
+
_a.sent();
|
|
1366
|
+
_a.label = 2;
|
|
1369
1367
|
case 2:
|
|
1370
1368
|
user = this.userPool.getCurrentUser();
|
|
1371
1369
|
if (!user) {
|
|
@@ -1373,77 +1371,96 @@ var AuthClass = /** @class */ (function () {
|
|
|
1373
1371
|
rej('No current user');
|
|
1374
1372
|
return [2 /*return*/];
|
|
1375
1373
|
}
|
|
1376
|
-
_b.label = 3;
|
|
1377
|
-
case 3:
|
|
1378
|
-
_b.trys.push([3, 7, , 8]);
|
|
1379
|
-
return [4 /*yield*/, this._userSession({ user: user })];
|
|
1380
|
-
case 4:
|
|
1381
|
-
session = _b.sent();
|
|
1382
|
-
bypassCache = params ? params.bypassCache : false;
|
|
1383
|
-
if (!bypassCache) return [3 /*break*/, 6];
|
|
1384
|
-
return [4 /*yield*/, this.Credentials.clear()];
|
|
1385
|
-
case 5:
|
|
1386
|
-
_b.sent();
|
|
1387
|
-
_b.label = 6;
|
|
1388
|
-
case 6:
|
|
1389
1374
|
clientMetadata = this._config.clientMetadata;
|
|
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
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1375
|
+
// refresh the session if the session expired.
|
|
1376
|
+
user.getSession(function (err, session) { return __awaiter(_this, void 0, void 0, function () {
|
|
1377
|
+
var cleanUpError_5, bypassCache, clientMetadata, _a, scope;
|
|
1378
|
+
var _this = this;
|
|
1379
|
+
return __generator(this, function (_b) {
|
|
1380
|
+
switch (_b.label) {
|
|
1381
|
+
case 0:
|
|
1382
|
+
if (!err) return [3 /*break*/, 5];
|
|
1383
|
+
logger.debug('Failed to get the user session', err);
|
|
1384
|
+
if (!this.isSessionInvalid(err)) return [3 /*break*/, 4];
|
|
1385
|
+
_b.label = 1;
|
|
1386
|
+
case 1:
|
|
1387
|
+
_b.trys.push([1, 3, , 4]);
|
|
1388
|
+
return [4 /*yield*/, this.cleanUpInvalidSession(user)];
|
|
1389
|
+
case 2:
|
|
1390
|
+
_b.sent();
|
|
1391
|
+
return [3 /*break*/, 4];
|
|
1392
|
+
case 3:
|
|
1393
|
+
cleanUpError_5 = _b.sent();
|
|
1394
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_5.message));
|
|
1395
|
+
return [2 /*return*/];
|
|
1396
|
+
case 4:
|
|
1397
|
+
rej(err);
|
|
1398
|
+
return [2 /*return*/];
|
|
1399
|
+
case 5:
|
|
1400
|
+
bypassCache = params ? params.bypassCache : false;
|
|
1401
|
+
if (!bypassCache) return [3 /*break*/, 7];
|
|
1402
|
+
return [4 /*yield*/, this.Credentials.clear()];
|
|
1403
|
+
case 6:
|
|
1404
|
+
_b.sent();
|
|
1405
|
+
_b.label = 7;
|
|
1406
|
+
case 7:
|
|
1407
|
+
clientMetadata = this._config.clientMetadata;
|
|
1408
|
+
_a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
|
|
1409
|
+
if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
|
|
1410
|
+
user.getUserData(function (err, data) { return __awaiter(_this, void 0, void 0, function () {
|
|
1411
|
+
var cleanUpError_6, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
|
|
1412
|
+
return __generator(this, function (_a) {
|
|
1413
|
+
switch (_a.label) {
|
|
1414
|
+
case 0:
|
|
1415
|
+
if (!err) return [3 /*break*/, 7];
|
|
1416
|
+
logger.debug('getting user data failed', err);
|
|
1417
|
+
if (!this.isSessionInvalid(err)) return [3 /*break*/, 5];
|
|
1418
|
+
_a.label = 1;
|
|
1419
|
+
case 1:
|
|
1420
|
+
_a.trys.push([1, 3, , 4]);
|
|
1421
|
+
return [4 /*yield*/, this.cleanUpInvalidSession(user)];
|
|
1422
|
+
case 2:
|
|
1423
|
+
_a.sent();
|
|
1424
|
+
return [3 /*break*/, 4];
|
|
1425
|
+
case 3:
|
|
1426
|
+
cleanUpError_6 = _a.sent();
|
|
1427
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
|
|
1428
|
+
return [2 /*return*/];
|
|
1429
|
+
case 4:
|
|
1430
|
+
rej(err);
|
|
1431
|
+
return [3 /*break*/, 6];
|
|
1432
|
+
case 5:
|
|
1433
|
+
res(user);
|
|
1434
|
+
_a.label = 6;
|
|
1435
|
+
case 6: return [2 /*return*/];
|
|
1436
|
+
case 7:
|
|
1437
|
+
preferredMFA = data.PreferredMfaSetting || 'NOMFA';
|
|
1438
|
+
attributeList = [];
|
|
1439
|
+
for (i = 0; i < data.UserAttributes.length; i++) {
|
|
1440
|
+
attribute = {
|
|
1441
|
+
Name: data.UserAttributes[i].Name,
|
|
1442
|
+
Value: data.UserAttributes[i].Value,
|
|
1443
|
+
};
|
|
1444
|
+
userAttribute = new amazon_cognito_identity_js_1.CognitoUserAttribute(attribute);
|
|
1445
|
+
attributeList.push(userAttribute);
|
|
1446
|
+
}
|
|
1447
|
+
attributes = this.attributesToObject(attributeList);
|
|
1448
|
+
Object.assign(user, { attributes: attributes, preferredMFA: preferredMFA });
|
|
1449
|
+
return [2 /*return*/, res(user)];
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
}); }, { bypassCache: bypassCache, clientMetadata: clientMetadata });
|
|
1453
|
+
}
|
|
1454
|
+
else {
|
|
1455
|
+
logger.debug("Unable to get the user data because the " + USER_ADMIN_SCOPE + " " +
|
|
1456
|
+
"is not in the scopes of the access token");
|
|
1431
1457
|
return [2 /*return*/, res(user)];
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
"is not in the scopes of the access token");
|
|
1439
|
-
return [2 /*return*/, res(user)];
|
|
1440
|
-
}
|
|
1441
|
-
return [3 /*break*/, 8];
|
|
1442
|
-
case 7:
|
|
1443
|
-
err_1 = _b.sent();
|
|
1444
|
-
rej(err_1);
|
|
1445
|
-
return [3 /*break*/, 8];
|
|
1446
|
-
case 8: return [2 /*return*/];
|
|
1458
|
+
}
|
|
1459
|
+
return [2 /*return*/];
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
}); }, { clientMetadata: clientMetadata });
|
|
1463
|
+
return [2 /*return*/];
|
|
1447
1464
|
}
|
|
1448
1465
|
});
|
|
1449
1466
|
}); })
|
|
@@ -1553,92 +1570,50 @@ var AuthClass = /** @class */ (function () {
|
|
|
1553
1570
|
});
|
|
1554
1571
|
});
|
|
1555
1572
|
};
|
|
1556
|
-
AuthClass.prototype._userSession = function (_a) {
|
|
1557
|
-
var _this = this;
|
|
1558
|
-
var user = _a.user, _b = _a.bypassCache, bypassCache = _b === void 0 ? false : _b;
|
|
1559
|
-
if (!user) {
|
|
1560
|
-
logger.debug('the user is null');
|
|
1561
|
-
return this.rejectAuthError(Auth_1.AuthErrorTypes.NoUserSession);
|
|
1562
|
-
}
|
|
1563
|
-
var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
|
|
1564
|
-
return new Promise(function (resolve, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
1565
|
-
var debounceResolver;
|
|
1566
|
-
var _this = this;
|
|
1567
|
-
return __generator(this, function (_a) {
|
|
1568
|
-
switch (_a.label) {
|
|
1569
|
-
case 0:
|
|
1570
|
-
// debugger;
|
|
1571
|
-
logger.debug('Getting the session from this user:', user);
|
|
1572
|
-
if (!this.inflightSession) return [3 /*break*/, 2];
|
|
1573
|
-
logger.debug('Waiting for another userSession call:');
|
|
1574
|
-
return [4 /*yield*/, this.inflightSessionPromise];
|
|
1575
|
-
case 1:
|
|
1576
|
-
_a.sent();
|
|
1577
|
-
logger.debug('Debouncer resolved');
|
|
1578
|
-
return [3 /*break*/, 3];
|
|
1579
|
-
case 2:
|
|
1580
|
-
logger.debug('Debouncer head');
|
|
1581
|
-
this.inflightSession = true;
|
|
1582
|
-
this.inflightSessionPromise = new Promise(function (res) {
|
|
1583
|
-
debounceResolver = function () {
|
|
1584
|
-
logger.debug('Debouncer resolving');
|
|
1585
|
-
_this.inflightSessionPromise = null;
|
|
1586
|
-
_this.inflightSession = false;
|
|
1587
|
-
res();
|
|
1588
|
-
};
|
|
1589
|
-
});
|
|
1590
|
-
_a.label = 3;
|
|
1591
|
-
case 3:
|
|
1592
|
-
user.getSession(function (err, session) { return __awaiter(_this, void 0, void 0, function () {
|
|
1593
|
-
var cleanUpError_6;
|
|
1594
|
-
return __generator(this, function (_a) {
|
|
1595
|
-
switch (_a.label) {
|
|
1596
|
-
case 0:
|
|
1597
|
-
if (!err) return [3 /*break*/, 5];
|
|
1598
|
-
logger.debug('Failed to get the session from user', user);
|
|
1599
|
-
if (!this.isSessionInvalid(err)) return [3 /*break*/, 4];
|
|
1600
|
-
_a.label = 1;
|
|
1601
|
-
case 1:
|
|
1602
|
-
_a.trys.push([1, 3, , 4]);
|
|
1603
|
-
return [4 /*yield*/, this.cleanUpInvalidSession(user)];
|
|
1604
|
-
case 2:
|
|
1605
|
-
_a.sent();
|
|
1606
|
-
return [3 /*break*/, 4];
|
|
1607
|
-
case 3:
|
|
1608
|
-
cleanUpError_6 = _a.sent();
|
|
1609
|
-
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
|
|
1610
|
-
if (debounceResolver) {
|
|
1611
|
-
debounceResolver();
|
|
1612
|
-
}
|
|
1613
|
-
return [2 /*return*/];
|
|
1614
|
-
case 4:
|
|
1615
|
-
rej(err);
|
|
1616
|
-
if (debounceResolver) {
|
|
1617
|
-
debounceResolver();
|
|
1618
|
-
}
|
|
1619
|
-
return [2 /*return*/];
|
|
1620
|
-
case 5:
|
|
1621
|
-
logger.debug('Succeed to get the user session', session);
|
|
1622
|
-
resolve(session);
|
|
1623
|
-
if (debounceResolver) {
|
|
1624
|
-
debounceResolver();
|
|
1625
|
-
}
|
|
1626
|
-
return [2 /*return*/];
|
|
1627
|
-
}
|
|
1628
|
-
});
|
|
1629
|
-
}); }, { clientMetadata: clientMetadata, bypassCache: bypassCache });
|
|
1630
|
-
return [2 /*return*/];
|
|
1631
|
-
}
|
|
1632
|
-
});
|
|
1633
|
-
}); });
|
|
1634
|
-
};
|
|
1635
1573
|
/**
|
|
1636
1574
|
* Get the corresponding user session
|
|
1637
1575
|
* @param {Object} user - The CognitoUser object
|
|
1638
1576
|
* @return - A promise resolves to the session
|
|
1639
1577
|
*/
|
|
1640
1578
|
AuthClass.prototype.userSession = function (user) {
|
|
1641
|
-
|
|
1579
|
+
var _this = this;
|
|
1580
|
+
if (!user) {
|
|
1581
|
+
logger.debug('the user is null');
|
|
1582
|
+
return this.rejectAuthError(Auth_1.AuthErrorTypes.NoUserSession);
|
|
1583
|
+
}
|
|
1584
|
+
var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
|
|
1585
|
+
return new Promise(function (res, rej) {
|
|
1586
|
+
logger.debug('Getting the session from this user:', user);
|
|
1587
|
+
user.getSession(function (err, session) { return __awaiter(_this, void 0, void 0, function () {
|
|
1588
|
+
var cleanUpError_7;
|
|
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_7 = _a.sent();
|
|
1604
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_7.message));
|
|
1605
|
+
return [2 /*return*/];
|
|
1606
|
+
case 4:
|
|
1607
|
+
rej(err);
|
|
1608
|
+
return [2 /*return*/];
|
|
1609
|
+
case 5:
|
|
1610
|
+
logger.debug('Succeed to get the user session', session);
|
|
1611
|
+
res(session);
|
|
1612
|
+
return [2 /*return*/];
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
}); }, { clientMetadata: clientMetadata });
|
|
1616
|
+
});
|
|
1642
1617
|
};
|
|
1643
1618
|
/**
|
|
1644
1619
|
* Get authenticated credentials of current user.
|
|
@@ -1782,7 +1757,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
1782
1757
|
// we must validate the user as an authenticated user by using getSession
|
|
1783
1758
|
var clientMetadata = _this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
|
|
1784
1759
|
user.getSession(function (err, result) { return __awaiter(_this, void 0, void 0, function () {
|
|
1785
|
-
var
|
|
1760
|
+
var cleanUpError_8;
|
|
1786
1761
|
var _this = this;
|
|
1787
1762
|
return __generator(this, function (_a) {
|
|
1788
1763
|
switch (_a.label) {
|
|
@@ -1798,8 +1773,8 @@ var AuthClass = /** @class */ (function () {
|
|
|
1798
1773
|
_a.sent();
|
|
1799
1774
|
return [3 /*break*/, 4];
|
|
1800
1775
|
case 3:
|
|
1801
|
-
|
|
1802
|
-
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " +
|
|
1776
|
+
cleanUpError_8 = _a.sent();
|
|
1777
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_8.message));
|
|
1803
1778
|
return [2 /*return*/];
|
|
1804
1779
|
case 4: return [2 /*return*/, rej(err)];
|
|
1805
1780
|
case 5:
|
|
@@ -1840,7 +1815,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
1840
1815
|
});
|
|
1841
1816
|
};
|
|
1842
1817
|
AuthClass.prototype.oAuthSignOutRedirect = function (resolve, reject) {
|
|
1843
|
-
var isBrowser = core_1.
|
|
1818
|
+
var isBrowser = core_1.browserOrNode().isBrowser;
|
|
1844
1819
|
if (isBrowser) {
|
|
1845
1820
|
this.oAuthSignOutRedirectOrReject(reject);
|
|
1846
1821
|
}
|
|
@@ -2023,7 +1998,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
2023
1998
|
*/
|
|
2024
1999
|
AuthClass.prototype.currentUserInfo = function () {
|
|
2025
2000
|
return __awaiter(this, void 0, void 0, function () {
|
|
2026
|
-
var source, user, attributes, userAttrs, credentials, e_12, info,
|
|
2001
|
+
var source, user, attributes, userAttrs, credentials, e_12, info, err_1, user;
|
|
2027
2002
|
return __generator(this, function (_a) {
|
|
2028
2003
|
switch (_a.label) {
|
|
2029
2004
|
case 0:
|
|
@@ -2064,8 +2039,8 @@ var AuthClass = /** @class */ (function () {
|
|
|
2064
2039
|
};
|
|
2065
2040
|
return [2 /*return*/, info];
|
|
2066
2041
|
case 8:
|
|
2067
|
-
|
|
2068
|
-
logger.error('currentUserInfo error',
|
|
2042
|
+
err_1 = _a.sent();
|
|
2043
|
+
logger.error('currentUserInfo error', err_1);
|
|
2069
2044
|
return [2 /*return*/, {}];
|
|
2070
2045
|
case 9:
|
|
2071
2046
|
if (source === 'federated') {
|
|
@@ -2146,7 +2121,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
2146
2121
|
*/
|
|
2147
2122
|
AuthClass.prototype._handleAuthResponse = function (URL) {
|
|
2148
2123
|
return __awaiter(this, void 0, void 0, function () {
|
|
2149
|
-
var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState,
|
|
2124
|
+
var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState, err_2;
|
|
2150
2125
|
return __generator(this, function (_b) {
|
|
2151
2126
|
switch (_b.label) {
|
|
2152
2127
|
case 0:
|
|
@@ -2162,7 +2137,7 @@ var AuthClass = /** @class */ (function () {
|
|
|
2162
2137
|
throw new Error("OAuth responses require a User Pool defined in config");
|
|
2163
2138
|
}
|
|
2164
2139
|
dispatchAuthEvent('parsingCallbackUrl', { url: URL }, "The callback url is being parsed");
|
|
2165
|
-
currentUrl = URL || (core_1.
|
|
2140
|
+
currentUrl = URL || (core_1.browserOrNode().isBrowser ? window.location.href : '');
|
|
2166
2141
|
hasCodeOrError = !!(url_1.parse(currentUrl).query || '')
|
|
2167
2142
|
.split('&')
|
|
2168
2143
|
.map(function (entry) { return entry.split('='); })
|
|
@@ -2219,16 +2194,16 @@ var AuthClass = /** @class */ (function () {
|
|
|
2219
2194
|
//#endregion
|
|
2220
2195
|
return [2 /*return*/, credentials];
|
|
2221
2196
|
case 6:
|
|
2222
|
-
|
|
2223
|
-
logger.debug('Error in cognito hosted auth response',
|
|
2197
|
+
err_2 = _b.sent();
|
|
2198
|
+
logger.debug('Error in cognito hosted auth response', err_2);
|
|
2224
2199
|
// Just like a successful handling of `?code`, replace the window history to "dispose" of the `code`.
|
|
2225
2200
|
// Otherwise, reloading the page will throw errors as the `code` has already been spent.
|
|
2226
2201
|
if (window && typeof window.history !== 'undefined') {
|
|
2227
2202
|
window.history.replaceState({}, null, this._config.oauth.redirectSignIn);
|
|
2228
2203
|
}
|
|
2229
|
-
dispatchAuthEvent('signIn_failure',
|
|
2230
|
-
dispatchAuthEvent('cognitoHostedUI_failure',
|
|
2231
|
-
dispatchAuthEvent('customState_failure',
|
|
2204
|
+
dispatchAuthEvent('signIn_failure', err_2, "The OAuth response flow failed");
|
|
2205
|
+
dispatchAuthEvent('cognitoHostedUI_failure', err_2, "A failure occurred when returning to the Cognito Hosted UI");
|
|
2206
|
+
dispatchAuthEvent('customState_failure', err_2, "A failure occurred when returning state");
|
|
2232
2207
|
return [3 /*break*/, 7];
|
|
2233
2208
|
case 7: return [3 /*break*/, 9];
|
|
2234
2209
|
case 8:
|