@aws-amplify/auth 4.5.8-unstable.1 → 4.5.9-auth-hotfix.4
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/CHANGELOG.md +8 -0
- package/dist/aws-amplify-auth.js +265 -223
- 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 +3 -0
- package/lib/Auth.js +168 -143
- package/lib/Auth.js.map +1 -1
- package/lib-esm/Auth.d.ts +3 -0
- package/lib-esm/Auth.js +168 -143
- package/lib-esm/Auth.js.map +1 -1
- package/package.json +5 -5
- package/src/Auth.ts +106 -87
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.5.8](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/auth@4.5.7...@aws-amplify/auth@4.5.8) (2022-06-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-amplify/auth
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [4.5.7](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/auth@4.5.6...@aws-amplify/auth@4.5.7) (2022-06-15)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @aws-amplify/auth
|
package/dist/aws-amplify-auth.js
CHANGED
|
@@ -10727,6 +10727,8 @@ function () {
|
|
|
10727
10727
|
this.userPool = null;
|
|
10728
10728
|
this.user = null;
|
|
10729
10729
|
this.oAuthFlowInProgress = false;
|
|
10730
|
+
this.inflightSessionPromise = null;
|
|
10731
|
+
this.inflightSession = false;
|
|
10730
10732
|
this.Credentials = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Credentials"];
|
|
10731
10733
|
|
|
10732
10734
|
this.wrapRefreshSessionCallback = function (callback) {
|
|
@@ -12354,12 +12356,12 @@ function () {
|
|
|
12354
12356
|
return new Promise(function (res, rej) {
|
|
12355
12357
|
_this._storageSync.then(function () {
|
|
12356
12358
|
return __awaiter(_this, void 0, void 0, function () {
|
|
12357
|
-
var user, clientMetadata;
|
|
12359
|
+
var user, session, bypassCache, clientMetadata, _a, scope, err_1;
|
|
12358
12360
|
|
|
12359
12361
|
var _this = this;
|
|
12360
12362
|
|
|
12361
|
-
return __generator(this, function (
|
|
12362
|
-
switch (
|
|
12363
|
+
return __generator(this, function (_b) {
|
|
12364
|
+
switch (_b.label) {
|
|
12363
12365
|
case 0:
|
|
12364
12366
|
if (!this.isOAuthInProgress()) return [3
|
|
12365
12367
|
/*break*/
|
|
@@ -12389,9 +12391,9 @@ function () {
|
|
|
12389
12391
|
})];
|
|
12390
12392
|
|
|
12391
12393
|
case 1:
|
|
12392
|
-
|
|
12394
|
+
_b.sent();
|
|
12393
12395
|
|
|
12394
|
-
|
|
12396
|
+
_b.label = 2;
|
|
12395
12397
|
|
|
12396
12398
|
case 2:
|
|
12397
12399
|
user = this.userPool.getCurrentUser();
|
|
@@ -12404,167 +12406,135 @@ function () {
|
|
|
12404
12406
|
];
|
|
12405
12407
|
}
|
|
12406
12408
|
|
|
12407
|
-
|
|
12409
|
+
_b.label = 3;
|
|
12408
12410
|
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
var cleanUpError_5, bypassCache, clientMetadata, _a, scope;
|
|
12411
|
+
case 3:
|
|
12412
|
+
_b.trys.push([3, 7,, 8]);
|
|
12412
12413
|
|
|
12413
|
-
|
|
12414
|
+
return [4
|
|
12415
|
+
/*yield*/
|
|
12416
|
+
, this._userSession({
|
|
12417
|
+
user: user
|
|
12418
|
+
})];
|
|
12414
12419
|
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
, 4];
|
|
12425
|
-
_b.label = 1;
|
|
12420
|
+
case 4:
|
|
12421
|
+
session = _b.sent();
|
|
12422
|
+
bypassCache = params ? params.bypassCache : false;
|
|
12423
|
+
if (!bypassCache) return [3
|
|
12424
|
+
/*break*/
|
|
12425
|
+
, 6];
|
|
12426
|
+
return [4
|
|
12427
|
+
/*yield*/
|
|
12428
|
+
, this.Credentials.clear()];
|
|
12426
12429
|
|
|
12427
|
-
|
|
12428
|
-
|
|
12430
|
+
case 5:
|
|
12431
|
+
_b.sent();
|
|
12429
12432
|
|
|
12430
|
-
|
|
12431
|
-
/*yield*/
|
|
12432
|
-
, this.cleanUpInvalidSession(user)];
|
|
12433
|
+
_b.label = 6;
|
|
12433
12434
|
|
|
12434
|
-
|
|
12435
|
-
|
|
12435
|
+
case 6:
|
|
12436
|
+
clientMetadata = this._config.clientMetadata;
|
|
12437
|
+
_a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
|
|
12438
|
+
|
|
12439
|
+
if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
|
|
12440
|
+
user.getUserData(function (err, data) {
|
|
12441
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
12442
|
+
var cleanUpError_5, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
|
|
12443
|
+
return __generator(this, function (_a) {
|
|
12444
|
+
switch (_a.label) {
|
|
12445
|
+
case 0:
|
|
12446
|
+
if (!err) return [3
|
|
12447
|
+
/*break*/
|
|
12448
|
+
, 7];
|
|
12449
|
+
logger.debug('getting user data failed', err);
|
|
12450
|
+
if (!this.isSessionInvalid(err)) return [3
|
|
12451
|
+
/*break*/
|
|
12452
|
+
, 5];
|
|
12453
|
+
_a.label = 1;
|
|
12454
|
+
|
|
12455
|
+
case 1:
|
|
12456
|
+
_a.trys.push([1, 3,, 4]);
|
|
12457
|
+
|
|
12458
|
+
return [4
|
|
12459
|
+
/*yield*/
|
|
12460
|
+
, this.cleanUpInvalidSession(user)];
|
|
12461
|
+
|
|
12462
|
+
case 2:
|
|
12463
|
+
_a.sent();
|
|
12464
|
+
|
|
12465
|
+
return [3
|
|
12466
|
+
/*break*/
|
|
12467
|
+
, 4];
|
|
12468
|
+
|
|
12469
|
+
case 3:
|
|
12470
|
+
cleanUpError_5 = _a.sent();
|
|
12471
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_5.message));
|
|
12472
|
+
return [2
|
|
12473
|
+
/*return*/
|
|
12474
|
+
];
|
|
12436
12475
|
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12476
|
+
case 4:
|
|
12477
|
+
rej(err);
|
|
12478
|
+
return [3
|
|
12479
|
+
/*break*/
|
|
12480
|
+
, 6];
|
|
12440
12481
|
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
return [2
|
|
12445
|
-
/*return*/
|
|
12446
|
-
];
|
|
12482
|
+
case 5:
|
|
12483
|
+
res(user);
|
|
12484
|
+
_a.label = 6;
|
|
12447
12485
|
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
|
|
12451
|
-
|
|
12452
|
-
|
|
12486
|
+
case 6:
|
|
12487
|
+
return [2
|
|
12488
|
+
/*return*/
|
|
12489
|
+
];
|
|
12490
|
+
|
|
12491
|
+
case 7:
|
|
12492
|
+
preferredMFA = data.PreferredMfaSetting || 'NOMFA';
|
|
12493
|
+
attributeList = [];
|
|
12494
|
+
|
|
12495
|
+
for (i = 0; i < data.UserAttributes.length; i++) {
|
|
12496
|
+
attribute = {
|
|
12497
|
+
Name: data.UserAttributes[i].Name,
|
|
12498
|
+
Value: data.UserAttributes[i].Value
|
|
12499
|
+
};
|
|
12500
|
+
userAttribute = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUserAttribute"](attribute);
|
|
12501
|
+
attributeList.push(userAttribute);
|
|
12502
|
+
}
|
|
12453
12503
|
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
12458
|
-
, 7];
|
|
12459
|
-
return [4
|
|
12460
|
-
/*yield*/
|
|
12461
|
-
, this.Credentials.clear()];
|
|
12462
|
-
|
|
12463
|
-
case 6:
|
|
12464
|
-
_b.sent();
|
|
12465
|
-
|
|
12466
|
-
_b.label = 7;
|
|
12467
|
-
|
|
12468
|
-
case 7:
|
|
12469
|
-
clientMetadata = this._config.clientMetadata;
|
|
12470
|
-
_a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
|
|
12471
|
-
|
|
12472
|
-
if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
|
|
12473
|
-
user.getUserData(function (err, data) {
|
|
12474
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
12475
|
-
var cleanUpError_6, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
|
|
12476
|
-
return __generator(this, function (_a) {
|
|
12477
|
-
switch (_a.label) {
|
|
12478
|
-
case 0:
|
|
12479
|
-
if (!err) return [3
|
|
12480
|
-
/*break*/
|
|
12481
|
-
, 7];
|
|
12482
|
-
logger.debug('getting user data failed', err);
|
|
12483
|
-
if (!this.isSessionInvalid(err)) return [3
|
|
12484
|
-
/*break*/
|
|
12485
|
-
, 5];
|
|
12486
|
-
_a.label = 1;
|
|
12487
|
-
|
|
12488
|
-
case 1:
|
|
12489
|
-
_a.trys.push([1, 3,, 4]);
|
|
12490
|
-
|
|
12491
|
-
return [4
|
|
12492
|
-
/*yield*/
|
|
12493
|
-
, this.cleanUpInvalidSession(user)];
|
|
12494
|
-
|
|
12495
|
-
case 2:
|
|
12496
|
-
_a.sent();
|
|
12497
|
-
|
|
12498
|
-
return [3
|
|
12499
|
-
/*break*/
|
|
12500
|
-
, 4];
|
|
12501
|
-
|
|
12502
|
-
case 3:
|
|
12503
|
-
cleanUpError_6 = _a.sent();
|
|
12504
|
-
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
|
|
12505
|
-
return [2
|
|
12506
|
-
/*return*/
|
|
12507
|
-
];
|
|
12508
|
-
|
|
12509
|
-
case 4:
|
|
12510
|
-
rej(err);
|
|
12511
|
-
return [3
|
|
12512
|
-
/*break*/
|
|
12513
|
-
, 6];
|
|
12514
|
-
|
|
12515
|
-
case 5:
|
|
12516
|
-
res(user);
|
|
12517
|
-
_a.label = 6;
|
|
12518
|
-
|
|
12519
|
-
case 6:
|
|
12520
|
-
return [2
|
|
12521
|
-
/*return*/
|
|
12522
|
-
];
|
|
12523
|
-
|
|
12524
|
-
case 7:
|
|
12525
|
-
preferredMFA = data.PreferredMfaSetting || 'NOMFA';
|
|
12526
|
-
attributeList = [];
|
|
12527
|
-
|
|
12528
|
-
for (i = 0; i < data.UserAttributes.length; i++) {
|
|
12529
|
-
attribute = {
|
|
12530
|
-
Name: data.UserAttributes[i].Name,
|
|
12531
|
-
Value: data.UserAttributes[i].Value
|
|
12532
|
-
};
|
|
12533
|
-
userAttribute = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUserAttribute"](attribute);
|
|
12534
|
-
attributeList.push(userAttribute);
|
|
12535
|
-
}
|
|
12536
|
-
|
|
12537
|
-
attributes = this.attributesToObject(attributeList);
|
|
12538
|
-
Object.assign(user, {
|
|
12539
|
-
attributes: attributes,
|
|
12540
|
-
preferredMFA: preferredMFA
|
|
12541
|
-
});
|
|
12542
|
-
return [2
|
|
12543
|
-
/*return*/
|
|
12544
|
-
, res(user)];
|
|
12545
|
-
}
|
|
12546
|
-
});
|
|
12547
|
-
});
|
|
12548
|
-
}, {
|
|
12549
|
-
bypassCache: bypassCache,
|
|
12550
|
-
clientMetadata: clientMetadata
|
|
12504
|
+
attributes = this.attributesToObject(attributeList);
|
|
12505
|
+
Object.assign(user, {
|
|
12506
|
+
attributes: attributes,
|
|
12507
|
+
preferredMFA: preferredMFA
|
|
12551
12508
|
});
|
|
12552
|
-
} else {
|
|
12553
|
-
logger.debug("Unable to get the user data because the " + USER_ADMIN_SCOPE + " " + "is not in the scopes of the access token");
|
|
12554
12509
|
return [2
|
|
12555
12510
|
/*return*/
|
|
12556
12511
|
, res(user)];
|
|
12557
|
-
|
|
12558
|
-
|
|
12559
|
-
return [2
|
|
12560
|
-
/*return*/
|
|
12561
|
-
];
|
|
12562
|
-
}
|
|
12512
|
+
}
|
|
12513
|
+
});
|
|
12563
12514
|
});
|
|
12515
|
+
}, {
|
|
12516
|
+
bypassCache: bypassCache,
|
|
12517
|
+
clientMetadata: clientMetadata
|
|
12564
12518
|
});
|
|
12565
|
-
}
|
|
12566
|
-
|
|
12567
|
-
|
|
12519
|
+
} else {
|
|
12520
|
+
logger.debug("Unable to get the user data because the " + USER_ADMIN_SCOPE + " " + "is not in the scopes of the access token");
|
|
12521
|
+
return [2
|
|
12522
|
+
/*return*/
|
|
12523
|
+
, res(user)];
|
|
12524
|
+
}
|
|
12525
|
+
|
|
12526
|
+
return [3
|
|
12527
|
+
/*break*/
|
|
12528
|
+
, 8];
|
|
12529
|
+
|
|
12530
|
+
case 7:
|
|
12531
|
+
err_1 = _b.sent();
|
|
12532
|
+
rej(err_1);
|
|
12533
|
+
return [3
|
|
12534
|
+
/*break*/
|
|
12535
|
+
, 8];
|
|
12536
|
+
|
|
12537
|
+
case 8:
|
|
12568
12538
|
return [2
|
|
12569
12539
|
/*return*/
|
|
12570
12540
|
];
|
|
@@ -12709,16 +12679,14 @@ function () {
|
|
|
12709
12679
|
});
|
|
12710
12680
|
});
|
|
12711
12681
|
};
|
|
12712
|
-
/**
|
|
12713
|
-
* Get the corresponding user session
|
|
12714
|
-
* @param {Object} user - The CognitoUser object
|
|
12715
|
-
* @return - A promise resolves to the session
|
|
12716
|
-
*/
|
|
12717
12682
|
|
|
12718
|
-
|
|
12719
|
-
AuthClass.prototype.userSession = function (user) {
|
|
12683
|
+
AuthClass.prototype._userSession = function (_a) {
|
|
12720
12684
|
var _this = this;
|
|
12721
12685
|
|
|
12686
|
+
var user = _a.user,
|
|
12687
|
+
_b = _a.bypassCache,
|
|
12688
|
+
bypassCache = _b === void 0 ? false : _b;
|
|
12689
|
+
|
|
12722
12690
|
if (!user) {
|
|
12723
12691
|
logger.debug('the user is null');
|
|
12724
12692
|
return this.rejectAuthError(_types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].NoUserSession);
|
|
@@ -12726,64 +12694,138 @@ function () {
|
|
|
12726
12694
|
|
|
12727
12695
|
var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
|
|
12728
12696
|
|
|
12729
|
-
return new Promise(function (
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12697
|
+
return new Promise(function (resolve, rej) {
|
|
12698
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
12699
|
+
var debounceResolver;
|
|
12700
|
+
|
|
12701
|
+
var _this = this;
|
|
12702
|
+
|
|
12703
|
+
return __generator(this, function (_a) {
|
|
12704
|
+
switch (_a.label) {
|
|
12705
|
+
case 0:
|
|
12706
|
+
// debugger;
|
|
12707
|
+
logger.debug('Getting the session from this user:', user);
|
|
12708
|
+
if (!this.inflightSession) return [3
|
|
12709
|
+
/*break*/
|
|
12710
|
+
, 2];
|
|
12711
|
+
logger.debug('Waiting for another userSession call:');
|
|
12712
|
+
return [4
|
|
12713
|
+
/*yield*/
|
|
12714
|
+
, this.inflightSessionPromise];
|
|
12715
|
+
|
|
12716
|
+
case 1:
|
|
12717
|
+
_a.sent();
|
|
12718
|
+
|
|
12719
|
+
logger.debug('Debouncer resolved');
|
|
12720
|
+
return [3
|
|
12721
|
+
/*break*/
|
|
12722
|
+
, 3];
|
|
12723
|
+
|
|
12724
|
+
case 2:
|
|
12725
|
+
logger.debug('Debouncer head');
|
|
12726
|
+
this.inflightSession = true;
|
|
12727
|
+
this.inflightSessionPromise = new Promise(function (res) {
|
|
12728
|
+
debounceResolver = function debounceResolver() {
|
|
12729
|
+
logger.debug('Debouncer resolving');
|
|
12730
|
+
_this.inflightSessionPromise = null;
|
|
12731
|
+
_this.inflightSession = false;
|
|
12732
|
+
res();
|
|
12733
|
+
};
|
|
12734
|
+
});
|
|
12735
|
+
_a.label = 3;
|
|
12736
|
+
|
|
12737
|
+
case 3:
|
|
12738
|
+
user.getSession(function (err, session) {
|
|
12739
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
12740
|
+
var cleanUpError_6;
|
|
12741
|
+
return __generator(this, function (_a) {
|
|
12742
|
+
switch (_a.label) {
|
|
12743
|
+
case 0:
|
|
12744
|
+
if (!err) return [3
|
|
12745
|
+
/*break*/
|
|
12746
|
+
, 5];
|
|
12747
|
+
logger.debug('Failed to get the session from user', user);
|
|
12748
|
+
if (!this.isSessionInvalid(err)) return [3
|
|
12749
|
+
/*break*/
|
|
12750
|
+
, 4];
|
|
12751
|
+
_a.label = 1;
|
|
12752
|
+
|
|
12753
|
+
case 1:
|
|
12754
|
+
_a.trys.push([1, 3,, 4]);
|
|
12755
|
+
|
|
12756
|
+
return [4
|
|
12757
|
+
/*yield*/
|
|
12758
|
+
, this.cleanUpInvalidSession(user)];
|
|
12759
|
+
|
|
12760
|
+
case 2:
|
|
12761
|
+
_a.sent();
|
|
12762
|
+
|
|
12763
|
+
return [3
|
|
12764
|
+
/*break*/
|
|
12765
|
+
, 4];
|
|
12766
|
+
|
|
12767
|
+
case 3:
|
|
12768
|
+
cleanUpError_6 = _a.sent();
|
|
12769
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
|
|
12770
|
+
|
|
12771
|
+
if (debounceResolver) {
|
|
12772
|
+
debounceResolver();
|
|
12773
|
+
}
|
|
12774
|
+
|
|
12775
|
+
return [2
|
|
12776
|
+
/*return*/
|
|
12777
|
+
];
|
|
12778
|
+
|
|
12779
|
+
case 4:
|
|
12780
|
+
rej(err);
|
|
12781
|
+
|
|
12782
|
+
if (debounceResolver) {
|
|
12783
|
+
debounceResolver();
|
|
12784
|
+
}
|
|
12785
|
+
|
|
12786
|
+
return [2
|
|
12787
|
+
/*return*/
|
|
12788
|
+
];
|
|
12789
|
+
|
|
12790
|
+
case 5:
|
|
12791
|
+
logger.debug('Succeed to get the user session', session);
|
|
12792
|
+
resolve(session);
|
|
12793
|
+
|
|
12794
|
+
if (debounceResolver) {
|
|
12795
|
+
debounceResolver();
|
|
12796
|
+
}
|
|
12797
|
+
|
|
12798
|
+
return [2
|
|
12799
|
+
/*return*/
|
|
12800
|
+
];
|
|
12801
|
+
}
|
|
12802
|
+
});
|
|
12803
|
+
});
|
|
12804
|
+
}, {
|
|
12805
|
+
clientMetadata: clientMetadata,
|
|
12806
|
+
bypassCache: bypassCache
|
|
12807
|
+
});
|
|
12808
|
+
return [2
|
|
12809
|
+
/*return*/
|
|
12810
|
+
];
|
|
12811
|
+
}
|
|
12781
12812
|
});
|
|
12782
|
-
}, {
|
|
12783
|
-
clientMetadata: clientMetadata
|
|
12784
12813
|
});
|
|
12785
12814
|
});
|
|
12786
12815
|
};
|
|
12816
|
+
/**
|
|
12817
|
+
* Get the corresponding user session
|
|
12818
|
+
* @param {Object} user - The CognitoUser object
|
|
12819
|
+
* @return - A promise resolves to the session
|
|
12820
|
+
*/
|
|
12821
|
+
|
|
12822
|
+
|
|
12823
|
+
AuthClass.prototype.userSession = function (user) {
|
|
12824
|
+
return this._userSession({
|
|
12825
|
+
user: user,
|
|
12826
|
+
bypassCache: false
|
|
12827
|
+
});
|
|
12828
|
+
};
|
|
12787
12829
|
/**
|
|
12788
12830
|
* Get authenticated credentials of current user.
|
|
12789
12831
|
* @return - A promise resolves to be current user's credentials
|
|
@@ -12972,7 +13014,7 @@ function () {
|
|
|
12972
13014
|
|
|
12973
13015
|
user.getSession(function (err, result) {
|
|
12974
13016
|
return __awaiter(_this, void 0, void 0, function () {
|
|
12975
|
-
var
|
|
13017
|
+
var cleanUpError_7;
|
|
12976
13018
|
|
|
12977
13019
|
var _this = this;
|
|
12978
13020
|
|
|
@@ -13003,8 +13045,8 @@ function () {
|
|
|
13003
13045
|
, 4];
|
|
13004
13046
|
|
|
13005
13047
|
case 3:
|
|
13006
|
-
|
|
13007
|
-
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " +
|
|
13048
|
+
cleanUpError_7 = _a.sent();
|
|
13049
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_7.message));
|
|
13008
13050
|
return [2
|
|
13009
13051
|
/*return*/
|
|
13010
13052
|
];
|
|
@@ -13308,7 +13350,7 @@ function () {
|
|
|
13308
13350
|
|
|
13309
13351
|
AuthClass.prototype.currentUserInfo = function () {
|
|
13310
13352
|
return __awaiter(this, void 0, void 0, function () {
|
|
13311
|
-
var source, user, attributes, userAttrs, credentials, e_12, info,
|
|
13353
|
+
var source, user, attributes, userAttrs, credentials, e_12, info, err_2, user;
|
|
13312
13354
|
return __generator(this, function (_a) {
|
|
13313
13355
|
switch (_a.label) {
|
|
13314
13356
|
case 0:
|
|
@@ -13377,8 +13419,8 @@ function () {
|
|
|
13377
13419
|
, info];
|
|
13378
13420
|
|
|
13379
13421
|
case 8:
|
|
13380
|
-
|
|
13381
|
-
logger.error('currentUserInfo error',
|
|
13422
|
+
err_2 = _a.sent();
|
|
13423
|
+
logger.error('currentUserInfo error', err_2);
|
|
13382
13424
|
return [2
|
|
13383
13425
|
/*return*/
|
|
13384
13426
|
, {}];
|
|
@@ -13488,7 +13530,7 @@ function () {
|
|
|
13488
13530
|
|
|
13489
13531
|
AuthClass.prototype._handleAuthResponse = function (URL) {
|
|
13490
13532
|
return __awaiter(this, void 0, void 0, function () {
|
|
13491
|
-
var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState,
|
|
13533
|
+
var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState, err_3;
|
|
13492
13534
|
|
|
13493
13535
|
return __generator(this, function (_b) {
|
|
13494
13536
|
switch (_b.label) {
|
|
@@ -13596,17 +13638,17 @@ function () {
|
|
|
13596
13638
|
, credentials];
|
|
13597
13639
|
|
|
13598
13640
|
case 6:
|
|
13599
|
-
|
|
13600
|
-
logger.debug('Error in cognito hosted auth response',
|
|
13641
|
+
err_3 = _b.sent();
|
|
13642
|
+
logger.debug('Error in cognito hosted auth response', err_3); // Just like a successful handling of `?code`, replace the window history to "dispose" of the `code`.
|
|
13601
13643
|
// Otherwise, reloading the page will throw errors as the `code` has already been spent.
|
|
13602
13644
|
|
|
13603
13645
|
if (window && typeof window.history !== 'undefined') {
|
|
13604
13646
|
window.history.replaceState({}, null, this._config.oauth.redirectSignIn);
|
|
13605
13647
|
}
|
|
13606
13648
|
|
|
13607
|
-
dispatchAuthEvent('signIn_failure',
|
|
13608
|
-
dispatchAuthEvent('cognitoHostedUI_failure',
|
|
13609
|
-
dispatchAuthEvent('customState_failure',
|
|
13649
|
+
dispatchAuthEvent('signIn_failure', err_3, "The OAuth response flow failed");
|
|
13650
|
+
dispatchAuthEvent('cognitoHostedUI_failure', err_3, "A failure occurred when returning to the Cognito Hosted UI");
|
|
13651
|
+
dispatchAuthEvent('customState_failure', err_3, "A failure occurred when returning state");
|
|
13610
13652
|
return [3
|
|
13611
13653
|
/*break*/
|
|
13612
13654
|
, 7];
|