@aws-amplify/auth 4.4.3-cloud-logging.7 → 4.4.3-cloud-logging.8

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.
@@ -3964,20 +3964,8 @@ module.exports = function(module) {
3964
3964
  __webpack_require__.r(__webpack_exports__);
3965
3965
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return AuthenticationDetails; });
3966
3966
  /*!
3967
- * Copyright 2016 Amazon.com,
3968
- * Inc. or its affiliates. All Rights Reserved.
3969
- *
3970
- * Licensed under the Amazon Software License (the "License").
3971
- * You may not use this file except in compliance with the
3972
- * License. A copy of the License is located at
3973
- *
3974
- * http://aws.amazon.com/asl/
3975
- *
3976
- * or in the "license" file accompanying this file. This file is
3977
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
3978
- * CONDITIONS OF ANY KIND, express or implied. See the License
3979
- * for the specific language governing permissions and
3980
- * limitations under the License.
3967
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3968
+ * SPDX-License-Identifier: Apache-2.0
3981
3969
  */
3982
3970
 
3983
3971
  /** @class */
@@ -4077,20 +4065,8 @@ __webpack_require__.r(__webpack_exports__);
4077
4065
  /* harmony import */ var _utils_WordArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils/WordArray */ "../amazon-cognito-identity-js/es/utils/WordArray.js");
4078
4066
  /* harmony import */ var _BigInteger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./BigInteger */ "../amazon-cognito-identity-js/es/BigInteger.js");
4079
4067
  /*!
4080
- * Copyright 2016 Amazon.com,
4081
- * Inc. or its affiliates. All Rights Reserved.
4082
- *
4083
- * Licensed under the Amazon Software License (the "License").
4084
- * You may not use this file except in compliance with the
4085
- * License. A copy of the License is located at
4086
- *
4087
- * http://aws.amazon.com/asl/
4088
- *
4089
- * or in the "license" file accompanying this file. This file is
4090
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
4091
- * CONDITIONS OF ANY KIND, express or implied. See the License
4092
- * for the specific language governing permissions and
4093
- * limitations under the License.
4068
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4069
+ * SPDX-License-Identifier: Apache-2.0
4094
4070
  */
4095
4071
 
4096
4072
 
@@ -5727,21 +5703,9 @@ function _setPrototypeOf(o, p) {
5727
5703
 
5728
5704
  return _setPrototypeOf(o, p);
5729
5705
  }
5730
- /*
5731
- * Copyright 2016 Amazon.com,
5732
- * Inc. or its affiliates. All Rights Reserved.
5733
- *
5734
- * Licensed under the Amazon Software License (the "License").
5735
- * You may not use this file except in compliance with the
5736
- * License. A copy of the License is located at
5737
- *
5738
- * http://aws.amazon.com/asl/
5739
- *
5740
- * or in the "license" file accompanying this file. This file is
5741
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
5742
- * CONDITIONS OF ANY KIND, express or implied. See the License
5743
- * for the specific language governing permissions and
5744
- * limitations under the License.
5706
+ /*!
5707
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5708
+ * SPDX-License-Identifier: Apache-2.0
5745
5709
  */
5746
5710
 
5747
5711
 
@@ -5797,20 +5761,8 @@ function _setPrototypeOf(o, p) {
5797
5761
  return _setPrototypeOf(o, p);
5798
5762
  }
5799
5763
  /*!
5800
- * Copyright 2016 Amazon.com,
5801
- * Inc. or its affiliates. All Rights Reserved.
5802
- *
5803
- * Licensed under the Amazon Software License (the "License").
5804
- * You may not use this file except in compliance with the
5805
- * License. A copy of the License is located at
5806
- *
5807
- * http://aws.amazon.com/asl/
5808
- *
5809
- * or in the "license" file accompanying this file. This file is
5810
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
5811
- * CONDITIONS OF ANY KIND, express or implied. See the License
5812
- * for the specific language governing permissions and
5813
- * limitations under the License.
5764
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5765
+ * SPDX-License-Identifier: Apache-2.0
5814
5766
  */
5815
5767
 
5816
5768
 
@@ -5852,20 +5804,8 @@ __webpack_require__.r(__webpack_exports__);
5852
5804
  /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js");
5853
5805
  /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__);
5854
5806
  /*!
5855
- * Copyright 2016 Amazon.com,
5856
- * Inc. or its affiliates. All Rights Reserved.
5857
- *
5858
- * Licensed under the Amazon Software License (the "License").
5859
- * You may not use this file except in compliance with the
5860
- * License. A copy of the License is located at
5861
- *
5862
- * http://aws.amazon.com/asl/
5863
- *
5864
- * or in the "license" file accompanying this file. This file is
5865
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
5866
- * CONDITIONS OF ANY KIND, express or implied. See the License
5867
- * for the specific language governing permissions and
5868
- * limitations under the License.
5807
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5808
+ * SPDX-License-Identifier: Apache-2.0
5869
5809
  */
5870
5810
 
5871
5811
  /** @class */
@@ -5939,20 +5879,8 @@ var CognitoJwtToken = /*#__PURE__*/function () {
5939
5879
  __webpack_require__.r(__webpack_exports__);
5940
5880
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CognitoRefreshToken; });
5941
5881
  /*!
5942
- * Copyright 2016 Amazon.com,
5943
- * Inc. or its affiliates. All Rights Reserved.
5944
- *
5945
- * Licensed under the Amazon Software License (the "License").
5946
- * You may not use this file except in compliance with the
5947
- * License. A copy of the License is located at
5948
- *
5949
- * http://aws.amazon.com/asl/
5950
- *
5951
- * or in the "license" file accompanying this file. This file is
5952
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
5953
- * CONDITIONS OF ANY KIND, express or implied. See the License
5954
- * for the specific language governing permissions and
5955
- * limitations under the License.
5882
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5883
+ * SPDX-License-Identifier: Apache-2.0
5956
5884
  */
5957
5885
 
5958
5886
  /** @class */
@@ -6016,20 +5944,8 @@ __webpack_require__.r(__webpack_exports__);
6016
5944
  /* harmony import */ var _CognitoUserAttribute__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./CognitoUserAttribute */ "../amazon-cognito-identity-js/es/CognitoUserAttribute.js");
6017
5945
  /* harmony import */ var _StorageHelper__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./StorageHelper */ "../amazon-cognito-identity-js/es/StorageHelper.js");
6018
5946
  /*!
6019
- * Copyright 2016 Amazon.com,
6020
- * Inc. or its affiliates. All Rights Reserved.
6021
- *
6022
- * Licensed under the Amazon Software License (the "License").
6023
- * You may not use this file except in compliance with the
6024
- * License. A copy of the License is located at
6025
- *
6026
- * http://aws.amazon.com/asl/
6027
- *
6028
- * or in the "license" file accompanying this file. This file is
6029
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
6030
- * CONDITIONS OF ANY KIND, express or implied. See the License
6031
- * for the specific language governing permissions and
6032
- * limitations under the License.
5947
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5948
+ * SPDX-License-Identifier: Apache-2.0
6033
5949
  */
6034
5950
 
6035
5951
 
@@ -8137,20 +8053,8 @@ var CognitoUser = /*#__PURE__*/function () {
8137
8053
  __webpack_require__.r(__webpack_exports__);
8138
8054
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CognitoUserAttribute; });
8139
8055
  /*!
8140
- * Copyright 2016 Amazon.com,
8141
- * Inc. or its affiliates. All Rights Reserved.
8142
- *
8143
- * Licensed under the Amazon Software License (the "License").
8144
- * You may not use this file except in compliance with the
8145
- * License. A copy of the License is located at
8146
- *
8147
- * http://aws.amazon.com/asl/
8148
- *
8149
- * or in the "license" file accompanying this file. This file is
8150
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8151
- * CONDITIONS OF ANY KIND, express or implied. See the License
8152
- * for the specific language governing permissions and
8153
- * limitations under the License.
8056
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8057
+ * SPDX-License-Identifier: Apache-2.0
8154
8058
  */
8155
8059
 
8156
8060
  /** @class */
@@ -8249,20 +8153,8 @@ __webpack_require__.r(__webpack_exports__);
8249
8153
  /* harmony import */ var _CognitoUser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CognitoUser */ "../amazon-cognito-identity-js/es/CognitoUser.js");
8250
8154
  /* harmony import */ var _StorageHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./StorageHelper */ "../amazon-cognito-identity-js/es/StorageHelper.js");
8251
8155
  /*!
8252
- * Copyright 2016 Amazon.com,
8253
- * Inc. or its affiliates. All Rights Reserved.
8254
- *
8255
- * Licensed under the Amazon Software License (the "License").
8256
- * You may not use this file except in compliance with the
8257
- * License. A copy of the License is located at
8258
- *
8259
- * http://aws.amazon.com/asl/
8260
- *
8261
- * or in the "license" file accompanying this file. This file is
8262
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8263
- * CONDITIONS OF ANY KIND, express or implied. See the License
8264
- * for the specific language governing permissions and
8265
- * limitations under the License.
8156
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8157
+ * SPDX-License-Identifier: Apache-2.0
8266
8158
  */
8267
8159
 
8268
8160
 
@@ -8463,20 +8355,8 @@ var CognitoUserPool = /*#__PURE__*/function () {
8463
8355
  __webpack_require__.r(__webpack_exports__);
8464
8356
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CognitoUserSession; });
8465
8357
  /*!
8466
- * Copyright 2016 Amazon.com,
8467
- * Inc. or its affiliates. All Rights Reserved.
8468
- *
8469
- * Licensed under the Amazon Software License (the "License").
8470
- * You may not use this file except in compliance with the
8471
- * License. A copy of the License is located at
8472
- *
8473
- * http://aws.amazon.com/asl/
8474
- *
8475
- * or in the "license" file accompanying this file. This file is
8476
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8477
- * CONDITIONS OF ANY KIND, express or implied. See the License
8478
- * for the specific language governing permissions and
8479
- * limitations under the License.
8358
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8359
+ * SPDX-License-Identifier: Apache-2.0
8480
8360
  */
8481
8361
 
8482
8362
  /** @class */
@@ -8725,20 +8605,8 @@ var CookieStorage = /*#__PURE__*/function () {
8725
8605
  __webpack_require__.r(__webpack_exports__);
8726
8606
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return DateHelper; });
8727
8607
  /*!
8728
- * Copyright 2016 Amazon.com,
8729
- * Inc. or its affiliates. All Rights Reserved.
8730
- *
8731
- * Licensed under the Amazon Software License (the "License").
8732
- * You may not use this file except in compliance with the
8733
- * License. A copy of the License is located at
8734
- *
8735
- * http://aws.amazon.com/asl/
8736
- *
8737
- * or in the "license" file accompanying this file. This file is
8738
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8739
- * CONDITIONS OF ANY KIND, express or implied. See the License
8740
- * for the specific language governing permissions and
8741
- * limitations under the License.
8608
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8609
+ * SPDX-License-Identifier: Apache-2.0
8742
8610
  */
8743
8611
  var monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
8744
8612
  var weekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -8800,17 +8668,9 @@ __webpack_require__.r(__webpack_exports__);
8800
8668
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Platform", function() { return Platform; });
8801
8669
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUserAgent", function() { return getUserAgent; });
8802
8670
  /* harmony import */ var _version__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./version */ "../amazon-cognito-identity-js/es/Platform/version.js");
8803
- /*
8804
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
8805
- *
8806
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
8807
- * the License. A copy of the License is located at
8808
- *
8809
- * http://aws.amazon.com/apache2.0/
8810
- *
8811
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8812
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
8813
- * and limitations under the License.
8671
+ /*!
8672
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8673
+ * SPDX-License-Identifier: Apache-2.0
8814
8674
  */
8815
8675
 
8816
8676
  var BASE_USER_AGENT = "aws-amplify/" + _version__WEBPACK_IMPORTED_MODULE_0__["version"];
@@ -8876,20 +8736,8 @@ __webpack_require__.r(__webpack_exports__);
8876
8736
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MemoryStorage", function() { return MemoryStorage; });
8877
8737
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return StorageHelper; });
8878
8738
  /*!
8879
- * Copyright 2016 Amazon.com,
8880
- * Inc. or its affiliates. All Rights Reserved.
8881
- *
8882
- * Licensed under the Amazon Software License (the "License").
8883
- * You may not use this file except in compliance with the
8884
- * License. A copy of the License is located at
8885
- *
8886
- * http://aws.amazon.com/asl/
8887
- *
8888
- * or in the "license" file accompanying this file. This file is
8889
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8890
- * CONDITIONS OF ANY KIND, express or implied. See the License
8891
- * for the specific language governing permissions and
8892
- * limitations under the License.
8739
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8740
+ * SPDX-License-Identifier: Apache-2.0
8893
8741
  */
8894
8742
  var dataMemory = {};
8895
8743
  /** @class */
@@ -9061,20 +8909,8 @@ __webpack_require__.r(__webpack_exports__);
9061
8909
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WordArray", function() { return _utils_WordArray__WEBPACK_IMPORTED_MODULE_12__["default"]; });
9062
8910
 
9063
8911
  /*!
9064
- * Copyright 2016 Amazon.com,
9065
- * Inc. or its affiliates. All Rights Reserved.
9066
- *
9067
- * Licensed under the Amazon Software License (the "License").
9068
- * You may not use this file except in compliance with the
9069
- * License. A copy of the License is located at
9070
- *
9071
- * http://aws.amazon.com/asl/
9072
- *
9073
- * or in the "license" file accompanying this file. This file is
9074
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9075
- * CONDITIONS OF ANY KIND, express or implied. See the License
9076
- * for the specific language governing permissions and
9077
- * limitations under the License.
8912
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8913
+ * SPDX-License-Identifier: Apache-2.0
9078
8914
  */
9079
8915
 
9080
8916
 
@@ -11487,21 +11323,68 @@ function () {
11487
11323
 
11488
11324
  var bypassCache = params ? params.bypassCache : false;
11489
11325
  user.getUserData(function (err, data) {
11490
- if (err) {
11491
- logger.debug('getting preferred mfa failed', err);
11492
- rej(err);
11493
- return;
11494
- }
11326
+ return __awaiter(_this, void 0, void 0, function () {
11327
+ var cleanUpError_1, mfaType;
11328
+ return __generator(this, function (_a) {
11329
+ switch (_a.label) {
11330
+ case 0:
11331
+ if (!err) return [3
11332
+ /*break*/
11333
+ , 5];
11334
+ logger.debug('getting preferred mfa failed', err);
11335
+ if (!this.isSessionInvalid(err)) return [3
11336
+ /*break*/
11337
+ , 4];
11338
+ _a.label = 1;
11495
11339
 
11496
- var mfaType = that._getMfaTypeFromUserData(data);
11340
+ case 1:
11341
+ _a.trys.push([1, 3,, 4]);
11497
11342
 
11498
- if (!mfaType) {
11499
- rej('invalid MFA Type');
11500
- return;
11501
- } else {
11502
- res(mfaType);
11503
- return;
11504
- }
11343
+ return [4
11344
+ /*yield*/
11345
+ , this.cleanUpInvalidSession(user)];
11346
+
11347
+ case 2:
11348
+ _a.sent();
11349
+
11350
+ return [3
11351
+ /*break*/
11352
+ , 4];
11353
+
11354
+ case 3:
11355
+ cleanUpError_1 = _a.sent();
11356
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_1.message));
11357
+ return [2
11358
+ /*return*/
11359
+ ];
11360
+
11361
+ case 4:
11362
+ rej(err);
11363
+ return [2
11364
+ /*return*/
11365
+ ];
11366
+
11367
+ case 5:
11368
+ mfaType = that._getMfaTypeFromUserData(data);
11369
+
11370
+ if (!mfaType) {
11371
+ rej('invalid MFA Type');
11372
+ return [2
11373
+ /*return*/
11374
+ ];
11375
+ } else {
11376
+ res(mfaType);
11377
+ return [2
11378
+ /*return*/
11379
+ ];
11380
+ }
11381
+
11382
+ return [2
11383
+ /*return*/
11384
+ ];
11385
+ }
11386
+ });
11387
+ });
11505
11388
  }, {
11506
11389
  bypassCache: bypassCache,
11507
11390
  clientMetadata: clientMetadata
@@ -11543,16 +11426,62 @@ function () {
11543
11426
  };
11544
11427
 
11545
11428
  AuthClass.prototype._getUserData = function (user, params) {
11429
+ var _this = this;
11430
+
11546
11431
  return new Promise(function (res, rej) {
11547
11432
  user.getUserData(function (err, data) {
11548
- if (err) {
11549
- logger.debug('getting user data failed', err);
11550
- rej(err);
11551
- return;
11552
- } else {
11553
- res(data);
11554
- return;
11555
- }
11433
+ return __awaiter(_this, void 0, void 0, function () {
11434
+ var cleanUpError_2;
11435
+ return __generator(this, function (_a) {
11436
+ switch (_a.label) {
11437
+ case 0:
11438
+ if (!err) return [3
11439
+ /*break*/
11440
+ , 5];
11441
+ logger.debug('getting user data failed', err);
11442
+ if (!this.isSessionInvalid(err)) return [3
11443
+ /*break*/
11444
+ , 4];
11445
+ _a.label = 1;
11446
+
11447
+ case 1:
11448
+ _a.trys.push([1, 3,, 4]);
11449
+
11450
+ return [4
11451
+ /*yield*/
11452
+ , this.cleanUpInvalidSession(user)];
11453
+
11454
+ case 2:
11455
+ _a.sent();
11456
+
11457
+ return [3
11458
+ /*break*/
11459
+ , 4];
11460
+
11461
+ case 3:
11462
+ cleanUpError_2 = _a.sent();
11463
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_2.message));
11464
+ return [2
11465
+ /*return*/
11466
+ ];
11467
+
11468
+ case 4:
11469
+ rej(err);
11470
+ return [2
11471
+ /*return*/
11472
+ ];
11473
+
11474
+ case 5:
11475
+ res(data);
11476
+ _a.label = 6;
11477
+
11478
+ case 6:
11479
+ return [2
11480
+ /*return*/
11481
+ ];
11482
+ }
11483
+ });
11484
+ });
11556
11485
  }, params);
11557
11486
  });
11558
11487
  };
@@ -11568,6 +11497,8 @@ function () {
11568
11497
  return __awaiter(this, void 0, void 0, function () {
11569
11498
  var clientMetadata, userData, smsMfaSettings, totpMfaSettings, _a, mfaList, currentMFAType, that;
11570
11499
 
11500
+ var _this = this;
11501
+
11571
11502
  return __generator(this, function (_b) {
11572
11503
  switch (_b.label) {
11573
11504
  case 0:
@@ -11707,12 +11638,53 @@ function () {
11707
11638
  logger.debug('Caching the latest user data into local'); // cache the latest result into user data
11708
11639
 
11709
11640
  user.getUserData(function (err, data) {
11710
- if (err) {
11711
- logger.debug('getting user data failed', err);
11712
- return rej(err);
11713
- } else {
11714
- return res(result);
11715
- }
11641
+ return __awaiter(_this, void 0, void 0, function () {
11642
+ var cleanUpError_3;
11643
+ return __generator(this, function (_a) {
11644
+ switch (_a.label) {
11645
+ case 0:
11646
+ if (!err) return [3
11647
+ /*break*/
11648
+ , 5];
11649
+ logger.debug('getting user data failed', err);
11650
+ if (!this.isSessionInvalid(err)) return [3
11651
+ /*break*/
11652
+ , 4];
11653
+ _a.label = 1;
11654
+
11655
+ case 1:
11656
+ _a.trys.push([1, 3,, 4]);
11657
+
11658
+ return [4
11659
+ /*yield*/
11660
+ , this.cleanUpInvalidSession(user)];
11661
+
11662
+ case 2:
11663
+ _a.sent();
11664
+
11665
+ return [3
11666
+ /*break*/
11667
+ , 4];
11668
+
11669
+ case 3:
11670
+ cleanUpError_3 = _a.sent();
11671
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_3.message));
11672
+ return [2
11673
+ /*return*/
11674
+ ];
11675
+
11676
+ case 4:
11677
+ return [2
11678
+ /*return*/
11679
+ , rej(err)];
11680
+
11681
+ case 5:
11682
+ return [2
11683
+ /*return*/
11684
+ , res(result)];
11685
+ }
11686
+ });
11687
+ });
11716
11688
  }, {
11717
11689
  bypassCache: true,
11718
11690
  clientMetadata: clientMetadata
@@ -12101,44 +12073,80 @@ function () {
12101
12073
  } else {
12102
12074
  user_1.getSession(function (err, session) {
12103
12075
  return __awaiter(_this, void 0, void 0, function () {
12076
+ var cleanUpError_4;
12077
+
12104
12078
  var _this = this;
12105
12079
 
12106
12080
  return __generator(this, function (_a) {
12107
- if (err) {
12108
- logger.debug('Failed to get the user session', err);
12109
- return [2
12110
- /*return*/
12111
- , rej(err)];
12112
- } else {
12113
- user_1.deleteUser(function (err, result) {
12114
- if (err) {
12115
- rej(err);
12116
- } else {
12117
- dispatchAuthEvent('userDeleted', result, 'The authenticated user has been deleted.');
12118
- user_1.signOut();
12119
- _this.user = null;
12120
-
12121
- try {
12122
- _this.cleanCachedItems(); // clean aws credentials
12123
-
12124
- } catch (e) {
12125
- // TODO: change to rejects in refactor
12126
- logger.debug('failed to clear cached items');
12127
- }
12128
-
12129
- if (isSignedInHostedUI) {
12130
- _this.oAuthSignOutRedirect(res, rej);
12081
+ switch (_a.label) {
12082
+ case 0:
12083
+ if (!err) return [3
12084
+ /*break*/
12085
+ , 5];
12086
+ logger.debug('Failed to get the user session', err);
12087
+ if (!this.isSessionInvalid(err)) return [3
12088
+ /*break*/
12089
+ , 4];
12090
+ _a.label = 1;
12091
+
12092
+ case 1:
12093
+ _a.trys.push([1, 3,, 4]);
12094
+
12095
+ return [4
12096
+ /*yield*/
12097
+ , this.cleanUpInvalidSession(user_1)];
12098
+
12099
+ case 2:
12100
+ _a.sent();
12101
+
12102
+ return [3
12103
+ /*break*/
12104
+ , 4];
12105
+
12106
+ case 3:
12107
+ cleanUpError_4 = _a.sent();
12108
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_4.message));
12109
+ return [2
12110
+ /*return*/
12111
+ ];
12112
+
12113
+ case 4:
12114
+ return [2
12115
+ /*return*/
12116
+ , rej(err)];
12117
+
12118
+ case 5:
12119
+ user_1.deleteUser(function (err, result) {
12120
+ if (err) {
12121
+ rej(err);
12131
12122
  } else {
12132
- dispatchAuthEvent('signOut', _this.user, "A user has been signed out");
12133
- res(result);
12123
+ dispatchAuthEvent('userDeleted', result, 'The authenticated user has been deleted.');
12124
+ user_1.signOut();
12125
+ _this.user = null;
12126
+
12127
+ try {
12128
+ _this.cleanCachedItems(); // clean aws credentials
12129
+
12130
+ } catch (e) {
12131
+ // TODO: change to rejects in refactor
12132
+ logger.debug('failed to clear cached items');
12133
+ }
12134
+
12135
+ if (isSignedInHostedUI) {
12136
+ _this.oAuthSignOutRedirect(res, rej);
12137
+ } else {
12138
+ dispatchAuthEvent('signOut', _this.user, "A user has been signed out");
12139
+ res(result);
12140
+ }
12134
12141
  }
12135
- }
12136
- });
12137
- }
12142
+ });
12143
+ _a.label = 6;
12138
12144
 
12139
- return [2
12140
- /*return*/
12141
- ];
12145
+ case 6:
12146
+ return [2
12147
+ /*return*/
12148
+ ];
12149
+ }
12142
12150
  });
12143
12151
  });
12144
12152
  });
@@ -12246,6 +12254,93 @@ function () {
12246
12254
  };
12247
12255
  });
12248
12256
  };
12257
+
12258
+ AuthClass.prototype.isErrorWithMessage = function (err) {
12259
+ return _typeof(err) === 'object' && Object.prototype.hasOwnProperty.call(err, 'message');
12260
+ }; // Session revoked by another app
12261
+
12262
+
12263
+ AuthClass.prototype.isTokenRevokedError = function (err) {
12264
+ return this.isErrorWithMessage(err) && err.message === 'Access Token has been revoked';
12265
+ };
12266
+
12267
+ AuthClass.prototype.isRefreshTokenRevokedError = function (err) {
12268
+ return this.isErrorWithMessage(err) && err.message === 'Refresh Token has been revoked';
12269
+ };
12270
+
12271
+ AuthClass.prototype.isUserDisabledError = function (err) {
12272
+ return this.isErrorWithMessage(err) && err.message === 'User is disabled.';
12273
+ };
12274
+
12275
+ AuthClass.prototype.isUserDoesNotExistError = function (err) {
12276
+ return this.isErrorWithMessage(err) && err.message === 'User does not exist.';
12277
+ };
12278
+
12279
+ AuthClass.prototype.isRefreshTokenExpiredError = function (err) {
12280
+ return this.isErrorWithMessage(err) && err.message === 'Refresh Token has expired';
12281
+ };
12282
+
12283
+ AuthClass.prototype.isSignedInHostedUI = function () {
12284
+ return this._oAuthHandler && this._storage.getItem('amplify-signin-with-hostedUI') === 'true';
12285
+ };
12286
+
12287
+ AuthClass.prototype.isSessionInvalid = function (err) {
12288
+ return this.isUserDisabledError(err) || this.isUserDoesNotExistError(err) || this.isTokenRevokedError(err) || this.isRefreshTokenRevokedError(err) || this.isRefreshTokenExpiredError(err);
12289
+ };
12290
+
12291
+ AuthClass.prototype.cleanUpInvalidSession = function (user) {
12292
+ return __awaiter(this, void 0, void 0, function () {
12293
+ var e_6;
12294
+
12295
+ var _this = this;
12296
+
12297
+ return __generator(this, function (_a) {
12298
+ switch (_a.label) {
12299
+ case 0:
12300
+ user.signOut();
12301
+ this.user = null;
12302
+ _a.label = 1;
12303
+
12304
+ case 1:
12305
+ _a.trys.push([1, 3,, 4]);
12306
+
12307
+ return [4
12308
+ /*yield*/
12309
+ , this.cleanCachedItems()];
12310
+
12311
+ case 2:
12312
+ _a.sent(); // clean aws credentials
12313
+
12314
+
12315
+ return [3
12316
+ /*break*/
12317
+ , 4];
12318
+
12319
+ case 3:
12320
+ e_6 = _a.sent();
12321
+ logger.debug('failed to clear cached items');
12322
+ return [3
12323
+ /*break*/
12324
+ , 4];
12325
+
12326
+ case 4:
12327
+ if (this.isSignedInHostedUI()) {
12328
+ return [2
12329
+ /*return*/
12330
+ , new Promise(function (res, rej) {
12331
+ _this.oAuthSignOutRedirect(res, rej);
12332
+ })];
12333
+ } else {
12334
+ dispatchAuthEvent('signOut', this.user, "A user has been signed out");
12335
+ }
12336
+
12337
+ return [2
12338
+ /*return*/
12339
+ ];
12340
+ }
12341
+ });
12342
+ });
12343
+ };
12249
12344
  /**
12250
12345
  * Get current authenticated user
12251
12346
  * @return - A promise resolves to current authenticated CognitoUser if success
@@ -12316,74 +12411,143 @@ function () {
12316
12411
 
12317
12412
  user.getSession(function (err, session) {
12318
12413
  return __awaiter(_this, void 0, void 0, function () {
12319
- var bypassCache, clientMetadata, _a, scope;
12414
+ var cleanUpError_5, bypassCache, clientMetadata, _a, scope;
12320
12415
 
12321
12416
  var _this = this;
12322
12417
 
12323
12418
  return __generator(this, function (_b) {
12324
12419
  switch (_b.label) {
12325
12420
  case 0:
12326
- if (err) {
12327
- logger.debug('Failed to get the user session', err);
12328
- rej(err);
12329
- return [2
12330
- /*return*/
12331
- ];
12332
- }
12421
+ if (!err) return [3
12422
+ /*break*/
12423
+ , 5];
12424
+ logger.debug('Failed to get the user session', err);
12425
+ if (!this.isSessionInvalid(err)) return [3
12426
+ /*break*/
12427
+ , 4];
12428
+ _b.label = 1;
12429
+
12430
+ case 1:
12431
+ _b.trys.push([1, 3,, 4]);
12432
+
12433
+ return [4
12434
+ /*yield*/
12435
+ , this.cleanUpInvalidSession(user)];
12436
+
12437
+ case 2:
12438
+ _b.sent();
12439
+
12440
+ return [3
12441
+ /*break*/
12442
+ , 4];
12443
+
12444
+ case 3:
12445
+ cleanUpError_5 = _b.sent();
12446
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_5.message));
12447
+ return [2
12448
+ /*return*/
12449
+ ];
12450
+
12451
+ case 4:
12452
+ rej(err);
12453
+ return [2
12454
+ /*return*/
12455
+ ];
12333
12456
 
12457
+ case 5:
12334
12458
  bypassCache = params ? params.bypassCache : false;
12335
12459
  if (!bypassCache) return [3
12336
12460
  /*break*/
12337
- , 2];
12461
+ , 7];
12338
12462
  return [4
12339
12463
  /*yield*/
12340
12464
  , this.Credentials.clear()];
12341
12465
 
12342
- case 1:
12466
+ case 6:
12343
12467
  _b.sent();
12344
12468
 
12345
- _b.label = 2;
12469
+ _b.label = 7;
12346
12470
 
12347
- case 2:
12471
+ case 7:
12348
12472
  clientMetadata = this._config.clientMetadata;
12349
12473
  _a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
12350
12474
 
12351
12475
  if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
12352
12476
  user.getUserData(function (err, data) {
12353
- if (err) {
12354
- logger.debug('getting user data failed', err); // Make sure the user is still valid
12355
-
12356
- if (err.message === 'User is disabled.' || err.message === 'User does not exist.' || err.message === 'Access Token has been revoked' // Session revoked by another app
12357
- ) {
12358
- rej(err);
12359
- } else {
12360
- // the error may also be thrown when lack of permissions to get user info etc
12361
- // in that case we just bypass the error
12362
- res(user);
12363
- }
12364
-
12365
- return;
12366
- }
12367
-
12368
- var preferredMFA = data.PreferredMfaSetting || 'NOMFA';
12369
- var attributeList = [];
12370
-
12371
- for (var i = 0; i < data.UserAttributes.length; i++) {
12372
- var attribute = {
12373
- Name: data.UserAttributes[i].Name,
12374
- Value: data.UserAttributes[i].Value
12375
- };
12376
- var userAttribute = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUserAttribute"](attribute);
12377
- attributeList.push(userAttribute);
12378
- }
12379
-
12380
- var attributes = _this.attributesToObject(attributeList);
12381
-
12382
- Object.assign(user, {
12383
- attributes: attributes,
12384
- preferredMFA: preferredMFA
12477
+ return __awaiter(_this, void 0, void 0, function () {
12478
+ var cleanUpError_6, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
12479
+ return __generator(this, function (_a) {
12480
+ switch (_a.label) {
12481
+ case 0:
12482
+ if (!err) return [3
12483
+ /*break*/
12484
+ , 7];
12485
+ logger.debug('getting user data failed', err);
12486
+ if (!this.isSessionInvalid(err)) return [3
12487
+ /*break*/
12488
+ , 5];
12489
+ _a.label = 1;
12490
+
12491
+ case 1:
12492
+ _a.trys.push([1, 3,, 4]);
12493
+
12494
+ return [4
12495
+ /*yield*/
12496
+ , this.cleanUpInvalidSession(user)];
12497
+
12498
+ case 2:
12499
+ _a.sent();
12500
+
12501
+ return [3
12502
+ /*break*/
12503
+ , 4];
12504
+
12505
+ case 3:
12506
+ cleanUpError_6 = _a.sent();
12507
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
12508
+ return [2
12509
+ /*return*/
12510
+ ];
12511
+
12512
+ case 4:
12513
+ rej(err);
12514
+ return [3
12515
+ /*break*/
12516
+ , 6];
12517
+
12518
+ case 5:
12519
+ res(user);
12520
+ _a.label = 6;
12521
+
12522
+ case 6:
12523
+ return [2
12524
+ /*return*/
12525
+ ];
12526
+
12527
+ case 7:
12528
+ preferredMFA = data.PreferredMfaSetting || 'NOMFA';
12529
+ attributeList = [];
12530
+
12531
+ for (i = 0; i < data.UserAttributes.length; i++) {
12532
+ attribute = {
12533
+ Name: data.UserAttributes[i].Name,
12534
+ Value: data.UserAttributes[i].Value
12535
+ };
12536
+ userAttribute = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUserAttribute"](attribute);
12537
+ attributeList.push(userAttribute);
12538
+ }
12539
+
12540
+ attributes = this.attributesToObject(attributeList);
12541
+ Object.assign(user, {
12542
+ attributes: attributes,
12543
+ preferredMFA: preferredMFA
12544
+ });
12545
+ return [2
12546
+ /*return*/
12547
+ , res(user)];
12548
+ }
12549
+ });
12385
12550
  });
12386
- return res(user);
12387
12551
  }, {
12388
12552
  bypassCache: bypassCache,
12389
12553
  clientMetadata: clientMetadata
@@ -12429,7 +12593,7 @@ function () {
12429
12593
 
12430
12594
  AuthClass.prototype.currentAuthenticatedUser = function (params) {
12431
12595
  return __awaiter(this, void 0, void 0, function () {
12432
- var federatedUser, e_6, federatedInfo, user, e_7;
12596
+ var federatedUser, e_7, federatedInfo, user, e_8;
12433
12597
  return __generator(this, function (_a) {
12434
12598
  switch (_a.label) {
12435
12599
  case 0:
@@ -12452,9 +12616,9 @@ function () {
12452
12616
  , 4];
12453
12617
 
12454
12618
  case 3:
12455
- e_6 = _a.sent();
12456
- logger.debug('Failed to sync cache info into memory', e_6);
12457
- throw e_6;
12619
+ e_7 = _a.sent();
12620
+ logger.debug('Failed to sync cache info into memory', e_7);
12621
+ throw e_7;
12458
12622
 
12459
12623
  case 4:
12460
12624
  try {
@@ -12497,13 +12661,13 @@ function () {
12497
12661
  , 9];
12498
12662
 
12499
12663
  case 8:
12500
- e_7 = _a.sent();
12664
+ e_8 = _a.sent();
12501
12665
 
12502
- if (e_7 === 'No userPool') {
12666
+ if (e_8 === 'No userPool') {
12503
12667
  logger.error('Cannot get the current user because the user pool is missing. ' + 'Please make sure the Auth module is configured with a valid Cognito User Pool ID');
12504
12668
  }
12505
12669
 
12506
- logger.debug('The user is not authenticated by the error', e_7);
12670
+ logger.debug('The user is not authenticated by the error', e_8);
12507
12671
  return [2
12508
12672
  /*return*/
12509
12673
  , Promise.reject('The user is not authenticated')];
@@ -12528,7 +12692,7 @@ function () {
12528
12692
  logger.debug('Getting current session'); // Purposely not calling the reject method here because we don't need a console error
12529
12693
 
12530
12694
  if (!this.userPool) {
12531
- return Promise.reject();
12695
+ return this.rejectNoUserPool();
12532
12696
  }
12533
12697
 
12534
12698
  return new Promise(function (res, rej) {
@@ -12556,6 +12720,8 @@ function () {
12556
12720
 
12557
12721
 
12558
12722
  AuthClass.prototype.userSession = function (user) {
12723
+ var _this = this;
12724
+
12559
12725
  if (!user) {
12560
12726
  logger.debug('the user is null');
12561
12727
  return this.rejectAuthError(_types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].NoUserSession);
@@ -12563,18 +12729,59 @@ function () {
12563
12729
 
12564
12730
  var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
12565
12731
 
12566
- return new Promise(function (resolve, reject) {
12732
+ return new Promise(function (res, rej) {
12567
12733
  logger.debug('Getting the session from this user:', user);
12568
12734
  user.getSession(function (err, session) {
12569
- if (err) {
12570
- logger.debug('Failed to get the session from user', user);
12571
- reject(err);
12572
- return;
12573
- } else {
12574
- logger.debug('Succeed to get the user session', session);
12575
- resolve(session);
12576
- return;
12577
- }
12735
+ return __awaiter(_this, void 0, void 0, function () {
12736
+ var cleanUpError_7;
12737
+ return __generator(this, function (_a) {
12738
+ switch (_a.label) {
12739
+ case 0:
12740
+ if (!err) return [3
12741
+ /*break*/
12742
+ , 5];
12743
+ logger.debug('Failed to get the session from user', user);
12744
+ if (!this.isSessionInvalid(err)) return [3
12745
+ /*break*/
12746
+ , 4];
12747
+ _a.label = 1;
12748
+
12749
+ case 1:
12750
+ _a.trys.push([1, 3,, 4]);
12751
+
12752
+ return [4
12753
+ /*yield*/
12754
+ , this.cleanUpInvalidSession(user)];
12755
+
12756
+ case 2:
12757
+ _a.sent();
12758
+
12759
+ return [3
12760
+ /*break*/
12761
+ , 4];
12762
+
12763
+ case 3:
12764
+ cleanUpError_7 = _a.sent();
12765
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_7.message));
12766
+ return [2
12767
+ /*return*/
12768
+ ];
12769
+
12770
+ case 4:
12771
+ rej(err);
12772
+ return [2
12773
+ /*return*/
12774
+ ];
12775
+
12776
+ case 5:
12777
+ logger.debug('Succeed to get the user session', session);
12778
+ res(session);
12779
+ return [2
12780
+ /*return*/
12781
+ ];
12782
+ }
12783
+ });
12784
+ });
12578
12785
  }, {
12579
12786
  clientMetadata: clientMetadata
12580
12787
  });
@@ -12588,7 +12795,7 @@ function () {
12588
12795
 
12589
12796
  AuthClass.prototype.currentUserCredentials = function () {
12590
12797
  return __awaiter(this, void 0, void 0, function () {
12591
- var e_8, federatedInfo;
12798
+ var e_9, federatedInfo;
12592
12799
 
12593
12800
  var _this = this;
12594
12801
 
@@ -12613,9 +12820,9 @@ function () {
12613
12820
  , 4];
12614
12821
 
12615
12822
  case 3:
12616
- e_8 = _a.sent();
12617
- logger.debug('Failed to sync cache info into memory', e_8);
12618
- throw e_8;
12823
+ e_9 = _a.sent();
12824
+ logger.debug('Failed to sync cache info into memory', e_9);
12825
+ throw e_9;
12619
12826
 
12620
12827
  case 4:
12621
12828
  federatedInfo = null;
@@ -12637,8 +12844,8 @@ function () {
12637
12844
  , this.currentSession().then(function (session) {
12638
12845
  logger.debug('getting session success', session);
12639
12846
  return _this.Credentials.set(session, 'session');
12640
- })["catch"](function (error) {
12641
- logger.debug('getting session failed', error);
12847
+ })["catch"](function () {
12848
+ logger.debug('getting guest credentials');
12642
12849
  return _this.Credentials.set(null, 'guest');
12643
12850
  })];
12644
12851
  }
@@ -12730,7 +12937,7 @@ function () {
12730
12937
 
12731
12938
  AuthClass.prototype.cognitoIdentitySignOut = function (opts, user) {
12732
12939
  return __awaiter(this, void 0, void 0, function () {
12733
- var e_9, isSignedInHostedUI;
12940
+ var e_10, isSignedInHostedUI;
12734
12941
 
12735
12942
  var _this = this;
12736
12943
 
@@ -12751,9 +12958,9 @@ function () {
12751
12958
  , 3];
12752
12959
 
12753
12960
  case 2:
12754
- e_9 = _a.sent();
12755
- logger.debug('Failed to sync cache info into memory', e_9);
12756
- throw e_9;
12961
+ e_10 = _a.sent();
12962
+ logger.debug('Failed to sync cache info into memory', e_10);
12963
+ throw e_10;
12757
12964
 
12758
12965
  case 3:
12759
12966
  isSignedInHostedUI = this._oAuthHandler && this._storage.getItem('amplify-signin-with-hostedUI') === 'true';
@@ -12767,25 +12974,70 @@ function () {
12767
12974
  var clientMetadata = _this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
12768
12975
 
12769
12976
  user.getSession(function (err, result) {
12770
- if (err) {
12771
- logger.debug('failed to get the user session', err);
12772
- return rej(err);
12773
- }
12977
+ return __awaiter(_this, void 0, void 0, function () {
12978
+ var cleanUpError_8;
12979
+
12980
+ var _this = this;
12981
+
12982
+ return __generator(this, function (_a) {
12983
+ switch (_a.label) {
12984
+ case 0:
12985
+ if (!err) return [3
12986
+ /*break*/
12987
+ , 5];
12988
+ logger.debug('failed to get the user session', err);
12989
+ if (!this.isSessionInvalid(err)) return [3
12990
+ /*break*/
12991
+ , 4];
12992
+ _a.label = 1;
12993
+
12994
+ case 1:
12995
+ _a.trys.push([1, 3,, 4]);
12996
+
12997
+ return [4
12998
+ /*yield*/
12999
+ , this.cleanUpInvalidSession(user)];
13000
+
13001
+ case 2:
13002
+ _a.sent();
13003
+
13004
+ return [3
13005
+ /*break*/
13006
+ , 4];
13007
+
13008
+ case 3:
13009
+ cleanUpError_8 = _a.sent();
13010
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_8.message));
13011
+ return [2
13012
+ /*return*/
13013
+ ];
13014
+
13015
+ case 4:
13016
+ return [2
13017
+ /*return*/
13018
+ , rej(err)];
12774
13019
 
12775
- user.globalSignOut({
12776
- onSuccess: function onSuccess(data) {
12777
- logger.debug('global sign out success');
13020
+ case 5:
13021
+ user.globalSignOut({
13022
+ onSuccess: function onSuccess(data) {
13023
+ logger.debug('global sign out success');
12778
13024
 
12779
- if (isSignedInHostedUI) {
12780
- _this.oAuthSignOutRedirect(res, rej);
12781
- } else {
12782
- return res();
13025
+ if (isSignedInHostedUI) {
13026
+ _this.oAuthSignOutRedirect(res, rej);
13027
+ } else {
13028
+ return res();
13029
+ }
13030
+ },
13031
+ onFailure: function onFailure(err) {
13032
+ logger.debug('global sign out failed', err);
13033
+ return rej(err);
13034
+ }
13035
+ });
13036
+ return [2
13037
+ /*return*/
13038
+ ];
12783
13039
  }
12784
- },
12785
- onFailure: function onFailure(err) {
12786
- logger.debug('global sign out failed', err);
12787
- return rej(err);
12788
- }
13040
+ });
12789
13041
  });
12790
13042
  }, {
12791
13043
  clientMetadata: clientMetadata
@@ -12828,7 +13080,7 @@ function () {
12828
13080
 
12829
13081
 
12830
13082
  setTimeout(function () {
12831
- return reject('Signout timeout fail');
13083
+ return reject(Error('Signout timeout fail'));
12832
13084
  }, 3000);
12833
13085
  };
12834
13086
  /**
@@ -12840,7 +13092,7 @@ function () {
12840
13092
 
12841
13093
  AuthClass.prototype.signOut = function (opts) {
12842
13094
  return __awaiter(this, void 0, void 0, function () {
12843
- var e_10, user;
13095
+ var e_11, user;
12844
13096
  return __generator(this, function (_a) {
12845
13097
  switch (_a.label) {
12846
13098
  case 0:
@@ -12858,7 +13110,7 @@ function () {
12858
13110
  , 3];
12859
13111
 
12860
13112
  case 2:
12861
- e_10 = _a.sent();
13113
+ e_11 = _a.sent();
12862
13114
  logger.debug('failed to clear cached items');
12863
13115
  return [3
12864
13116
  /*break*/
@@ -12893,7 +13145,7 @@ function () {
12893
13145
  , 8];
12894
13146
 
12895
13147
  case 7:
12896
- logger.debug('no Congito User pool');
13148
+ logger.debug('no Cognito User pool');
12897
13149
  _a.label = 8;
12898
13150
 
12899
13151
  case 8:
@@ -13059,7 +13311,7 @@ function () {
13059
13311
 
13060
13312
  AuthClass.prototype.currentUserInfo = function () {
13061
13313
  return __awaiter(this, void 0, void 0, function () {
13062
- var source, user, attributes, userAttrs, credentials, e_11, info, err_1, user;
13314
+ var source, user, attributes, userAttrs, credentials, e_12, info, err_1, user;
13063
13315
  return __generator(this, function (_a) {
13064
13316
  switch (_a.label) {
13065
13317
  case 0:
@@ -13111,8 +13363,8 @@ function () {
13111
13363
  , 7];
13112
13364
 
13113
13365
  case 6:
13114
- e_11 = _a.sent();
13115
- logger.debug('Failed to retrieve credentials while getting current user info', e_11);
13366
+ e_12 = _a.sent();
13367
+ logger.debug('Failed to retrieve credentials while getting current user info', e_12);
13116
13368
  return [3
13117
13369
  /*break*/
13118
13370
  , 7];
@@ -14512,7 +14764,7 @@ var AuthErrorStrings;
14512
14764
  /*!**************************!*\
14513
14765
  !*** ./lib-esm/index.js ***!
14514
14766
  \**************************/
14515
- /*! exports provided: default, Auth, CognitoUser, CookieStorage, CognitoHostedUIIdentityProvider, appendToCognitoUserAgent, AuthErrorStrings */
14767
+ /*! exports provided: default, Auth, CognitoUser, CookieStorage, CognitoHostedUIIdentityProvider, appendToCognitoUserAgent, AuthErrorStrings, GRAPHQL_AUTH_MODE */
14516
14768
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
14517
14769
 
14518
14770
  "use strict";
@@ -14523,6 +14775,8 @@ __webpack_require__.r(__webpack_exports__);
14523
14775
  /* harmony import */ var _types_Auth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types/Auth */ "./lib-esm/types/Auth.js");
14524
14776
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CognitoHostedUIIdentityProvider", function() { return _types_Auth__WEBPACK_IMPORTED_MODULE_1__["CognitoHostedUIIdentityProvider"]; });
14525
14777
 
14778
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return _types_Auth__WEBPACK_IMPORTED_MODULE_1__["GRAPHQL_AUTH_MODE"]; });
14779
+
14526
14780
  /* harmony import */ var amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! amazon-cognito-identity-js */ "../amazon-cognito-identity-js/es/index.js");
14527
14781
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CognitoUser", function() { return amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUser"]; });
14528
14782
 
@@ -14562,7 +14816,7 @@ __webpack_require__.r(__webpack_exports__);
14562
14816
  /*!*******************************!*\
14563
14817
  !*** ./lib-esm/types/Auth.js ***!
14564
14818
  \*******************************/
14565
- /*! exports provided: CognitoHostedUIIdentityProvider, isFederatedSignInOptions, isFederatedSignInOptionsCustom, hasCustomState, isCognitoHostedOpts, AuthErrorTypes, isUsernamePasswordOpts */
14819
+ /*! exports provided: CognitoHostedUIIdentityProvider, isFederatedSignInOptions, isFederatedSignInOptionsCustom, hasCustomState, isCognitoHostedOpts, AuthErrorTypes, isUsernamePasswordOpts, GRAPHQL_AUTH_MODE */
14566
14820
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
14567
14821
 
14568
14822
  "use strict";
@@ -14574,6 +14828,7 @@ __webpack_require__.r(__webpack_exports__);
14574
14828
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isCognitoHostedOpts", function() { return isCognitoHostedOpts; });
14575
14829
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AuthErrorTypes", function() { return AuthErrorTypes; });
14576
14830
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isUsernamePasswordOpts", function() { return isUsernamePasswordOpts; });
14831
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return GRAPHQL_AUTH_MODE; });
14577
14832
  /*
14578
14833
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
14579
14834
  *
@@ -14639,6 +14894,15 @@ var AuthErrorTypes;
14639
14894
  function isUsernamePasswordOpts(obj) {
14640
14895
  return !!obj.username;
14641
14896
  }
14897
+ var GRAPHQL_AUTH_MODE;
14898
+
14899
+ (function (GRAPHQL_AUTH_MODE) {
14900
+ GRAPHQL_AUTH_MODE["API_KEY"] = "API_KEY";
14901
+ GRAPHQL_AUTH_MODE["AWS_IAM"] = "AWS_IAM";
14902
+ GRAPHQL_AUTH_MODE["OPENID_CONNECT"] = "OPENID_CONNECT";
14903
+ GRAPHQL_AUTH_MODE["AMAZON_COGNITO_USER_POOLS"] = "AMAZON_COGNITO_USER_POOLS";
14904
+ GRAPHQL_AUTH_MODE["AWS_LAMBDA"] = "AWS_LAMBDA";
14905
+ })(GRAPHQL_AUTH_MODE || (GRAPHQL_AUTH_MODE = {}));
14642
14906
 
14643
14907
  /***/ }),
14644
14908
 
@@ -14646,7 +14910,7 @@ function isUsernamePasswordOpts(obj) {
14646
14910
  /*!********************************!*\
14647
14911
  !*** ./lib-esm/types/index.js ***!
14648
14912
  \********************************/
14649
- /*! exports provided: CognitoHostedUIIdentityProvider, isFederatedSignInOptions, isFederatedSignInOptionsCustom, hasCustomState, isCognitoHostedOpts, AuthErrorTypes, isUsernamePasswordOpts */
14913
+ /*! exports provided: CognitoHostedUIIdentityProvider, isFederatedSignInOptions, isFederatedSignInOptionsCustom, hasCustomState, isCognitoHostedOpts, AuthErrorTypes, isUsernamePasswordOpts, GRAPHQL_AUTH_MODE */
14650
14914
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
14651
14915
 
14652
14916
  "use strict";
@@ -14666,6 +14930,8 @@ __webpack_require__.r(__webpack_exports__);
14666
14930
 
14667
14931
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isUsernamePasswordOpts", function() { return _Auth__WEBPACK_IMPORTED_MODULE_0__["isUsernamePasswordOpts"]; });
14668
14932
 
14933
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return _Auth__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"]; });
14934
+
14669
14935
  /*
14670
14936
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
14671
14937
  *