@aws-amplify/auth 4.5.8-unstable.7 → 4.5.9-auth-hotfix.5
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 +20 -0
- package/dist/aws-amplify-auth.js +242 -231
- package/dist/aws-amplify-auth.js.map +1 -1
- package/dist/aws-amplify-auth.min.js +7 -7
- package/dist/aws-amplify-auth.min.js.map +1 -1
- package/lib/Auth.d.ts +2 -0
- package/lib/Auth.js +151 -145
- 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 +2 -0
- package/lib-esm/Auth.js +152 -146
- 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 +116 -114
- package/src/urlListener.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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.9](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/auth@4.5.8...@aws-amplify/auth@4.5.9) (2022-07-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **amazon-cognito-identity-js:** Missing cognito user challenge name … ([#10047](https://github.com/aws-amplify/amplify-js/issues/10047)) ([de0441b](https://github.com/aws-amplify/amplify-js/commit/de0441b4fa67409ccbc630c42890e2c58ee779fb)), closes [#6974](https://github.com/aws-amplify/amplify-js/issues/6974)
|
|
12
|
+
* Update Auth to import JS using named export ([#10033](https://github.com/aws-amplify/amplify-js/issues/10033)) ([11b537c](https://github.com/aws-amplify/amplify-js/commit/11b537c62fee74c04e4e3b72ba43a353ba5152c9))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [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)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @aws-amplify/auth
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
## [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
27
|
|
|
8
28
|
**Note:** Version bump only for package @aws-amplify/auth
|
package/dist/aws-amplify-auth.js
CHANGED
|
@@ -10727,6 +10727,7 @@ function () {
|
|
|
10727
10727
|
this.userPool = null;
|
|
10728
10728
|
this.user = null;
|
|
10729
10729
|
this.oAuthFlowInProgress = false;
|
|
10730
|
+
this.inflightSessionPromise = null;
|
|
10730
10731
|
this.Credentials = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Credentials"];
|
|
10731
10732
|
|
|
10732
10733
|
this.wrapRefreshSessionCallback = function (callback) {
|
|
@@ -12354,12 +12355,12 @@ function () {
|
|
|
12354
12355
|
return new Promise(function (res, rej) {
|
|
12355
12356
|
_this._storageSync.then(function () {
|
|
12356
12357
|
return __awaiter(_this, void 0, void 0, function () {
|
|
12357
|
-
var user, clientMetadata;
|
|
12358
|
+
var user, session, bypassCache, clientMetadata, _a, scope, err_1;
|
|
12358
12359
|
|
|
12359
12360
|
var _this = this;
|
|
12360
12361
|
|
|
12361
|
-
return __generator(this, function (
|
|
12362
|
-
switch (
|
|
12362
|
+
return __generator(this, function (_b) {
|
|
12363
|
+
switch (_b.label) {
|
|
12363
12364
|
case 0:
|
|
12364
12365
|
if (!this.isOAuthInProgress()) return [3
|
|
12365
12366
|
/*break*/
|
|
@@ -12389,9 +12390,9 @@ function () {
|
|
|
12389
12390
|
})];
|
|
12390
12391
|
|
|
12391
12392
|
case 1:
|
|
12392
|
-
|
|
12393
|
+
_b.sent();
|
|
12393
12394
|
|
|
12394
|
-
|
|
12395
|
+
_b.label = 2;
|
|
12395
12396
|
|
|
12396
12397
|
case 2:
|
|
12397
12398
|
user = this.userPool.getCurrentUser();
|
|
@@ -12404,167 +12405,135 @@ function () {
|
|
|
12404
12405
|
];
|
|
12405
12406
|
}
|
|
12406
12407
|
|
|
12407
|
-
|
|
12408
|
+
_b.label = 3;
|
|
12408
12409
|
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
var cleanUpError_5, bypassCache, clientMetadata, _a, scope;
|
|
12410
|
+
case 3:
|
|
12411
|
+
_b.trys.push([3, 7,, 8]);
|
|
12412
12412
|
|
|
12413
|
-
|
|
12413
|
+
return [4
|
|
12414
|
+
/*yield*/
|
|
12415
|
+
, this._userSession({
|
|
12416
|
+
user: user
|
|
12417
|
+
})];
|
|
12414
12418
|
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
, 4];
|
|
12425
|
-
_b.label = 1;
|
|
12419
|
+
case 4:
|
|
12420
|
+
session = _b.sent();
|
|
12421
|
+
bypassCache = params ? params.bypassCache : false;
|
|
12422
|
+
if (!bypassCache) return [3
|
|
12423
|
+
/*break*/
|
|
12424
|
+
, 6];
|
|
12425
|
+
return [4
|
|
12426
|
+
/*yield*/
|
|
12427
|
+
, this.Credentials.clear()];
|
|
12426
12428
|
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
+
case 5:
|
|
12430
|
+
_b.sent();
|
|
12429
12431
|
|
|
12430
|
-
|
|
12431
|
-
/*yield*/
|
|
12432
|
-
, this.cleanUpInvalidSession(user)];
|
|
12432
|
+
_b.label = 6;
|
|
12433
12433
|
|
|
12434
|
-
|
|
12435
|
-
|
|
12434
|
+
case 6:
|
|
12435
|
+
clientMetadata = this._config.clientMetadata;
|
|
12436
|
+
_a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
|
|
12437
|
+
|
|
12438
|
+
if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
|
|
12439
|
+
user.getUserData(function (err, data) {
|
|
12440
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
12441
|
+
var cleanUpError_5, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
|
|
12442
|
+
return __generator(this, function (_a) {
|
|
12443
|
+
switch (_a.label) {
|
|
12444
|
+
case 0:
|
|
12445
|
+
if (!err) return [3
|
|
12446
|
+
/*break*/
|
|
12447
|
+
, 7];
|
|
12448
|
+
logger.debug('getting user data failed', err);
|
|
12449
|
+
if (!this.isSessionInvalid(err)) return [3
|
|
12450
|
+
/*break*/
|
|
12451
|
+
, 5];
|
|
12452
|
+
_a.label = 1;
|
|
12453
|
+
|
|
12454
|
+
case 1:
|
|
12455
|
+
_a.trys.push([1, 3,, 4]);
|
|
12456
|
+
|
|
12457
|
+
return [4
|
|
12458
|
+
/*yield*/
|
|
12459
|
+
, this.cleanUpInvalidSession(user)];
|
|
12460
|
+
|
|
12461
|
+
case 2:
|
|
12462
|
+
_a.sent();
|
|
12463
|
+
|
|
12464
|
+
return [3
|
|
12465
|
+
/*break*/
|
|
12466
|
+
, 4];
|
|
12467
|
+
|
|
12468
|
+
case 3:
|
|
12469
|
+
cleanUpError_5 = _a.sent();
|
|
12470
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_5.message));
|
|
12471
|
+
return [2
|
|
12472
|
+
/*return*/
|
|
12473
|
+
];
|
|
12436
12474
|
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12475
|
+
case 4:
|
|
12476
|
+
rej(err);
|
|
12477
|
+
return [3
|
|
12478
|
+
/*break*/
|
|
12479
|
+
, 6];
|
|
12440
12480
|
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
return [2
|
|
12445
|
-
/*return*/
|
|
12446
|
-
];
|
|
12481
|
+
case 5:
|
|
12482
|
+
res(user);
|
|
12483
|
+
_a.label = 6;
|
|
12447
12484
|
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
|
|
12451
|
-
|
|
12452
|
-
|
|
12485
|
+
case 6:
|
|
12486
|
+
return [2
|
|
12487
|
+
/*return*/
|
|
12488
|
+
];
|
|
12489
|
+
|
|
12490
|
+
case 7:
|
|
12491
|
+
preferredMFA = data.PreferredMfaSetting || 'NOMFA';
|
|
12492
|
+
attributeList = [];
|
|
12493
|
+
|
|
12494
|
+
for (i = 0; i < data.UserAttributes.length; i++) {
|
|
12495
|
+
attribute = {
|
|
12496
|
+
Name: data.UserAttributes[i].Name,
|
|
12497
|
+
Value: data.UserAttributes[i].Value
|
|
12498
|
+
};
|
|
12499
|
+
userAttribute = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUserAttribute"](attribute);
|
|
12500
|
+
attributeList.push(userAttribute);
|
|
12501
|
+
}
|
|
12453
12502
|
|
|
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
|
|
12503
|
+
attributes = this.attributesToObject(attributeList);
|
|
12504
|
+
Object.assign(user, {
|
|
12505
|
+
attributes: attributes,
|
|
12506
|
+
preferredMFA: preferredMFA
|
|
12551
12507
|
});
|
|
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
12508
|
return [2
|
|
12555
12509
|
/*return*/
|
|
12556
12510
|
, res(user)];
|
|
12557
|
-
|
|
12558
|
-
|
|
12559
|
-
return [2
|
|
12560
|
-
/*return*/
|
|
12561
|
-
];
|
|
12562
|
-
}
|
|
12511
|
+
}
|
|
12512
|
+
});
|
|
12563
12513
|
});
|
|
12514
|
+
}, {
|
|
12515
|
+
bypassCache: bypassCache,
|
|
12516
|
+
clientMetadata: clientMetadata
|
|
12564
12517
|
});
|
|
12565
|
-
}
|
|
12566
|
-
|
|
12567
|
-
|
|
12518
|
+
} else {
|
|
12519
|
+
logger.debug("Unable to get the user data because the " + USER_ADMIN_SCOPE + " " + "is not in the scopes of the access token");
|
|
12520
|
+
return [2
|
|
12521
|
+
/*return*/
|
|
12522
|
+
, res(user)];
|
|
12523
|
+
}
|
|
12524
|
+
|
|
12525
|
+
return [3
|
|
12526
|
+
/*break*/
|
|
12527
|
+
, 8];
|
|
12528
|
+
|
|
12529
|
+
case 7:
|
|
12530
|
+
err_1 = _b.sent();
|
|
12531
|
+
rej(err_1);
|
|
12532
|
+
return [3
|
|
12533
|
+
/*break*/
|
|
12534
|
+
, 8];
|
|
12535
|
+
|
|
12536
|
+
case 8:
|
|
12568
12537
|
return [2
|
|
12569
12538
|
/*return*/
|
|
12570
12539
|
];
|
|
@@ -12709,79 +12678,121 @@ function () {
|
|
|
12709
12678
|
});
|
|
12710
12679
|
});
|
|
12711
12680
|
};
|
|
12712
|
-
/**
|
|
12713
|
-
* Get the corresponding user session
|
|
12714
|
-
* @param {Object} user - The CognitoUser object
|
|
12715
|
-
* @return - A promise resolves to the session
|
|
12716
|
-
*/
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
AuthClass.prototype.userSession = function (user) {
|
|
12720
|
-
var _this = this;
|
|
12721
|
-
|
|
12722
|
-
if (!user) {
|
|
12723
|
-
logger.debug('the user is null');
|
|
12724
|
-
return this.rejectAuthError(_types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].NoUserSession);
|
|
12725
|
-
}
|
|
12726
|
-
|
|
12727
|
-
var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
|
|
12728
12681
|
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
switch (_a.label) {
|
|
12736
|
-
case 0:
|
|
12737
|
-
if (!err) return [3
|
|
12738
|
-
/*break*/
|
|
12739
|
-
, 5];
|
|
12740
|
-
logger.debug('Failed to get the session from user', user);
|
|
12741
|
-
if (!this.isSessionInvalid(err)) return [3
|
|
12742
|
-
/*break*/
|
|
12743
|
-
, 4];
|
|
12744
|
-
_a.label = 1;
|
|
12682
|
+
AuthClass.prototype._userSession = function (_a) {
|
|
12683
|
+
var user = _a.user,
|
|
12684
|
+
_b = _a.bypassCache,
|
|
12685
|
+
bypassCache = _b === void 0 ? false : _b;
|
|
12686
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12687
|
+
var clientMetadata;
|
|
12745
12688
|
|
|
12746
|
-
|
|
12747
|
-
_a.trys.push([1, 3,, 4]);
|
|
12689
|
+
var _this = this;
|
|
12748
12690
|
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12691
|
+
return __generator(this, function (_c) {
|
|
12692
|
+
switch (_c.label) {
|
|
12693
|
+
case 0:
|
|
12694
|
+
if (!user) {
|
|
12695
|
+
logger.debug('the user is null');
|
|
12696
|
+
return [2
|
|
12697
|
+
/*return*/
|
|
12698
|
+
, this.rejectAuthError(_types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].NoUserSession)];
|
|
12699
|
+
}
|
|
12752
12700
|
|
|
12753
|
-
|
|
12754
|
-
|
|
12701
|
+
clientMetadata = this._config.clientMetadata;
|
|
12702
|
+
if (!this.inflightSessionPromise) return [3
|
|
12703
|
+
/*break*/
|
|
12704
|
+
, 2];
|
|
12705
|
+
return [4
|
|
12706
|
+
/*yield*/
|
|
12707
|
+
, this.inflightSessionPromise];
|
|
12755
12708
|
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12709
|
+
case 1:
|
|
12710
|
+
return [2
|
|
12711
|
+
/*return*/
|
|
12712
|
+
, _c.sent()];
|
|
12759
12713
|
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
return
|
|
12764
|
-
|
|
12765
|
-
|
|
12714
|
+
case 2:
|
|
12715
|
+
this.inflightSessionPromise = new Promise(function (resolve, rej) {
|
|
12716
|
+
user.getSession(function (err, session) {
|
|
12717
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
12718
|
+
var cleanUpError_6;
|
|
12719
|
+
return __generator(this, function (_a) {
|
|
12720
|
+
switch (_a.label) {
|
|
12721
|
+
case 0:
|
|
12722
|
+
if (!err) return [3
|
|
12723
|
+
/*break*/
|
|
12724
|
+
, 5];
|
|
12725
|
+
logger.debug('Failed to get the session from user', user);
|
|
12726
|
+
if (!this.isSessionInvalid(err)) return [3
|
|
12727
|
+
/*break*/
|
|
12728
|
+
, 4];
|
|
12729
|
+
_a.label = 1;
|
|
12730
|
+
|
|
12731
|
+
case 1:
|
|
12732
|
+
_a.trys.push([1, 3,, 4]);
|
|
12733
|
+
|
|
12734
|
+
return [4
|
|
12735
|
+
/*yield*/
|
|
12736
|
+
, this.cleanUpInvalidSession(user)];
|
|
12737
|
+
|
|
12738
|
+
case 2:
|
|
12739
|
+
_a.sent();
|
|
12740
|
+
|
|
12741
|
+
return [3
|
|
12742
|
+
/*break*/
|
|
12743
|
+
, 4];
|
|
12744
|
+
|
|
12745
|
+
case 3:
|
|
12746
|
+
cleanUpError_6 = _a.sent();
|
|
12747
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
|
|
12748
|
+
return [2
|
|
12749
|
+
/*return*/
|
|
12750
|
+
];
|
|
12751
|
+
|
|
12752
|
+
case 4:
|
|
12753
|
+
rej(err);
|
|
12754
|
+
return [2
|
|
12755
|
+
/*return*/
|
|
12756
|
+
];
|
|
12757
|
+
|
|
12758
|
+
case 5:
|
|
12759
|
+
logger.debug('Succeed to get the user session', session);
|
|
12760
|
+
resolve(session);
|
|
12761
|
+
return [2
|
|
12762
|
+
/*return*/
|
|
12763
|
+
];
|
|
12764
|
+
}
|
|
12765
|
+
});
|
|
12766
|
+
});
|
|
12767
|
+
}, {
|
|
12768
|
+
clientMetadata: clientMetadata,
|
|
12769
|
+
bypassCache: bypassCache
|
|
12770
|
+
});
|
|
12771
|
+
}).then(function (session) {
|
|
12772
|
+
_this.inflightSessionPromise = null;
|
|
12773
|
+
return session;
|
|
12774
|
+
})["catch"](function (err) {
|
|
12775
|
+
_this.inflightSessionPromise = null;
|
|
12776
|
+
throw err;
|
|
12777
|
+
});
|
|
12778
|
+
return [2
|
|
12779
|
+
/*return*/
|
|
12780
|
+
, this.inflightSessionPromise];
|
|
12781
|
+
}
|
|
12782
|
+
});
|
|
12783
|
+
});
|
|
12784
|
+
};
|
|
12785
|
+
/**
|
|
12786
|
+
* Get the corresponding user session
|
|
12787
|
+
* @param {Object} user - The CognitoUser object
|
|
12788
|
+
* @return - A promise resolves to the session
|
|
12789
|
+
*/
|
|
12766
12790
|
|
|
12767
|
-
case 4:
|
|
12768
|
-
rej(err);
|
|
12769
|
-
return [2
|
|
12770
|
-
/*return*/
|
|
12771
|
-
];
|
|
12772
12791
|
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
/*return*/
|
|
12778
|
-
];
|
|
12779
|
-
}
|
|
12780
|
-
});
|
|
12781
|
-
});
|
|
12782
|
-
}, {
|
|
12783
|
-
clientMetadata: clientMetadata
|
|
12784
|
-
});
|
|
12792
|
+
AuthClass.prototype.userSession = function (user) {
|
|
12793
|
+
return this._userSession({
|
|
12794
|
+
user: user,
|
|
12795
|
+
bypassCache: false
|
|
12785
12796
|
});
|
|
12786
12797
|
};
|
|
12787
12798
|
/**
|
|
@@ -12972,7 +12983,7 @@ function () {
|
|
|
12972
12983
|
|
|
12973
12984
|
user.getSession(function (err, result) {
|
|
12974
12985
|
return __awaiter(_this, void 0, void 0, function () {
|
|
12975
|
-
var
|
|
12986
|
+
var cleanUpError_7;
|
|
12976
12987
|
|
|
12977
12988
|
var _this = this;
|
|
12978
12989
|
|
|
@@ -13003,8 +13014,8 @@ function () {
|
|
|
13003
13014
|
, 4];
|
|
13004
13015
|
|
|
13005
13016
|
case 3:
|
|
13006
|
-
|
|
13007
|
-
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " +
|
|
13017
|
+
cleanUpError_7 = _a.sent();
|
|
13018
|
+
rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_7.message));
|
|
13008
13019
|
return [2
|
|
13009
13020
|
/*return*/
|
|
13010
13021
|
];
|
|
@@ -13056,7 +13067,7 @@ function () {
|
|
|
13056
13067
|
};
|
|
13057
13068
|
|
|
13058
13069
|
AuthClass.prototype.oAuthSignOutRedirect = function (resolve, reject) {
|
|
13059
|
-
var isBrowser = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["
|
|
13070
|
+
var isBrowser = Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["browserOrNode"])().isBrowser;
|
|
13060
13071
|
|
|
13061
13072
|
if (isBrowser) {
|
|
13062
13073
|
this.oAuthSignOutRedirectOrReject(reject);
|
|
@@ -13308,7 +13319,7 @@ function () {
|
|
|
13308
13319
|
|
|
13309
13320
|
AuthClass.prototype.currentUserInfo = function () {
|
|
13310
13321
|
return __awaiter(this, void 0, void 0, function () {
|
|
13311
|
-
var source, user, attributes, userAttrs, credentials, e_12, info,
|
|
13322
|
+
var source, user, attributes, userAttrs, credentials, e_12, info, err_2, user;
|
|
13312
13323
|
return __generator(this, function (_a) {
|
|
13313
13324
|
switch (_a.label) {
|
|
13314
13325
|
case 0:
|
|
@@ -13377,8 +13388,8 @@ function () {
|
|
|
13377
13388
|
, info];
|
|
13378
13389
|
|
|
13379
13390
|
case 8:
|
|
13380
|
-
|
|
13381
|
-
logger.error('currentUserInfo error',
|
|
13391
|
+
err_2 = _a.sent();
|
|
13392
|
+
logger.error('currentUserInfo error', err_2);
|
|
13382
13393
|
return [2
|
|
13383
13394
|
/*return*/
|
|
13384
13395
|
, {}];
|
|
@@ -13488,7 +13499,7 @@ function () {
|
|
|
13488
13499
|
|
|
13489
13500
|
AuthClass.prototype._handleAuthResponse = function (URL) {
|
|
13490
13501
|
return __awaiter(this, void 0, void 0, function () {
|
|
13491
|
-
var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState,
|
|
13502
|
+
var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState, err_3;
|
|
13492
13503
|
|
|
13493
13504
|
return __generator(this, function (_b) {
|
|
13494
13505
|
switch (_b.label) {
|
|
@@ -13514,7 +13525,7 @@ function () {
|
|
|
13514
13525
|
dispatchAuthEvent('parsingCallbackUrl', {
|
|
13515
13526
|
url: URL
|
|
13516
13527
|
}, "The callback url is being parsed");
|
|
13517
|
-
currentUrl = URL || (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["
|
|
13528
|
+
currentUrl = URL || (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["browserOrNode"])().isBrowser ? window.location.href : '');
|
|
13518
13529
|
hasCodeOrError = !!(Object(url__WEBPACK_IMPORTED_MODULE_3__["parse"])(currentUrl).query || '').split('&').map(function (entry) {
|
|
13519
13530
|
return entry.split('=');
|
|
13520
13531
|
}).find(function (_a) {
|
|
@@ -13596,17 +13607,17 @@ function () {
|
|
|
13596
13607
|
, credentials];
|
|
13597
13608
|
|
|
13598
13609
|
case 6:
|
|
13599
|
-
|
|
13600
|
-
logger.debug('Error in cognito hosted auth response',
|
|
13610
|
+
err_3 = _b.sent();
|
|
13611
|
+
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
13612
|
// Otherwise, reloading the page will throw errors as the `code` has already been spent.
|
|
13602
13613
|
|
|
13603
13614
|
if (window && typeof window.history !== 'undefined') {
|
|
13604
13615
|
window.history.replaceState({}, null, this._config.oauth.redirectSignIn);
|
|
13605
13616
|
}
|
|
13606
13617
|
|
|
13607
|
-
dispatchAuthEvent('signIn_failure',
|
|
13608
|
-
dispatchAuthEvent('cognitoHostedUI_failure',
|
|
13609
|
-
dispatchAuthEvent('customState_failure',
|
|
13618
|
+
dispatchAuthEvent('signIn_failure', err_3, "The OAuth response flow failed");
|
|
13619
|
+
dispatchAuthEvent('cognitoHostedUI_failure', err_3, "A failure occurred when returning to the Cognito Hosted UI");
|
|
13620
|
+
dispatchAuthEvent('customState_failure', err_3, "A failure occurred when returning state");
|
|
13610
13621
|
return [3
|
|
13611
13622
|
/*break*/
|
|
13612
13623
|
, 7];
|
|
@@ -14970,12 +14981,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
14970
14981
|
*/
|
|
14971
14982
|
|
|
14972
14983
|
/* harmony default export */ __webpack_exports__["default"] = (function (callback) {
|
|
14973
|
-
if (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["
|
|
14984
|
+
if (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["browserOrNode"])().isBrowser && window.location) {
|
|
14974
14985
|
var url = window.location.href;
|
|
14975
14986
|
callback({
|
|
14976
14987
|
url: url
|
|
14977
14988
|
});
|
|
14978
|
-
} else if (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["
|
|
14989
|
+
} else if (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["browserOrNode"])().isNode) {
|
|
14979
14990
|
// continue building on ssr
|
|
14980
14991
|
(function () {}); // noop
|
|
14981
14992
|
|