@aws-amplify/datastore 3.7.8-cloud-logging.7 → 3.7.8-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.
Files changed (56) hide show
  1. package/CHANGELOG.md +28 -55
  2. package/README.md +154 -0
  3. package/dist/aws-amplify-datastore.js +706 -370
  4. package/dist/aws-amplify-datastore.js.map +1 -1
  5. package/dist/aws-amplify-datastore.min.js +23 -79
  6. package/dist/aws-amplify-datastore.min.js.map +1 -1
  7. package/lib/datastore/datastore.js +16 -0
  8. package/lib/datastore/datastore.js.map +1 -1
  9. package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
  10. package/lib/storage/storage.d.ts +2 -2
  11. package/lib/storage/storage.js +17 -4
  12. package/lib/storage/storage.js.map +1 -1
  13. package/lib/sync/merger.js +1 -0
  14. package/lib/sync/merger.js.map +1 -1
  15. package/lib/sync/outbox.js +1 -0
  16. package/lib/sync/outbox.js.map +1 -1
  17. package/lib/sync/processors/mutation.d.ts +17 -0
  18. package/lib/sync/processors/mutation.js +27 -2
  19. package/lib/sync/processors/mutation.js.map +1 -1
  20. package/lib/sync/processors/subscription.js +1 -2
  21. package/lib/sync/processors/subscription.js.map +1 -1
  22. package/lib/sync/processors/sync.js.map +1 -1
  23. package/lib/sync/utils.js.map +1 -1
  24. package/lib/types.d.ts +3 -1
  25. package/lib/types.js.map +1 -1
  26. package/lib-esm/datastore/datastore.js +16 -0
  27. package/lib-esm/datastore/datastore.js.map +1 -1
  28. package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
  29. package/lib-esm/storage/storage.d.ts +2 -2
  30. package/lib-esm/storage/storage.js +17 -4
  31. package/lib-esm/storage/storage.js.map +1 -1
  32. package/lib-esm/sync/merger.js +1 -0
  33. package/lib-esm/sync/merger.js.map +1 -1
  34. package/lib-esm/sync/outbox.js +1 -0
  35. package/lib-esm/sync/outbox.js.map +1 -1
  36. package/lib-esm/sync/processors/mutation.d.ts +17 -0
  37. package/lib-esm/sync/processors/mutation.js +28 -3
  38. package/lib-esm/sync/processors/mutation.js.map +1 -1
  39. package/lib-esm/sync/processors/subscription.js +1 -2
  40. package/lib-esm/sync/processors/subscription.js.map +1 -1
  41. package/lib-esm/sync/processors/sync.js.map +1 -1
  42. package/lib-esm/sync/utils.js.map +1 -1
  43. package/lib-esm/types.d.ts +3 -1
  44. package/lib-esm/types.js.map +1 -1
  45. package/package.json +7 -7
  46. package/src/datastore/datastore.ts +20 -0
  47. package/src/storage/adapter/IndexedDBAdapter.ts +1 -0
  48. package/src/storage/storage.ts +20 -7
  49. package/src/sync/merger.ts +2 -0
  50. package/src/sync/outbox.ts +1 -0
  51. package/src/sync/processors/mutation.ts +38 -3
  52. package/src/sync/processors/subscription.ts +18 -20
  53. package/src/sync/processors/sync.ts +5 -4
  54. package/src/sync/utils.ts +3 -5
  55. package/src/types.ts +7 -1
  56. package/ssr/package.json +1 -1
@@ -51312,20 +51312,8 @@ module.exports = PushStream;
51312
51312
  __webpack_require__.r(__webpack_exports__);
51313
51313
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return AuthenticationDetails; });
51314
51314
  /*!
51315
- * Copyright 2016 Amazon.com,
51316
- * Inc. or its affiliates. All Rights Reserved.
51317
- *
51318
- * Licensed under the Amazon Software License (the "License").
51319
- * You may not use this file except in compliance with the
51320
- * License. A copy of the License is located at
51321
- *
51322
- * http://aws.amazon.com/asl/
51323
- *
51324
- * or in the "license" file accompanying this file. This file is
51325
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
51326
- * CONDITIONS OF ANY KIND, express or implied. See the License
51327
- * for the specific language governing permissions and
51328
- * limitations under the License.
51315
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
51316
+ * SPDX-License-Identifier: Apache-2.0
51329
51317
  */
51330
51318
 
51331
51319
  /** @class */
@@ -51425,20 +51413,8 @@ __webpack_require__.r(__webpack_exports__);
51425
51413
  /* harmony import */ var _utils_WordArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils/WordArray */ "../amazon-cognito-identity-js/es/utils/WordArray.js");
51426
51414
  /* harmony import */ var _BigInteger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./BigInteger */ "../amazon-cognito-identity-js/es/BigInteger.js");
51427
51415
  /*!
51428
- * Copyright 2016 Amazon.com,
51429
- * Inc. or its affiliates. All Rights Reserved.
51430
- *
51431
- * Licensed under the Amazon Software License (the "License").
51432
- * You may not use this file except in compliance with the
51433
- * License. A copy of the License is located at
51434
- *
51435
- * http://aws.amazon.com/asl/
51436
- *
51437
- * or in the "license" file accompanying this file. This file is
51438
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
51439
- * CONDITIONS OF ANY KIND, express or implied. See the License
51440
- * for the specific language governing permissions and
51441
- * limitations under the License.
51416
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
51417
+ * SPDX-License-Identifier: Apache-2.0
51442
51418
  */
51443
51419
 
51444
51420
 
@@ -53075,21 +53051,9 @@ function _setPrototypeOf(o, p) {
53075
53051
 
53076
53052
  return _setPrototypeOf(o, p);
53077
53053
  }
53078
- /*
53079
- * Copyright 2016 Amazon.com,
53080
- * Inc. or its affiliates. All Rights Reserved.
53081
- *
53082
- * Licensed under the Amazon Software License (the "License").
53083
- * You may not use this file except in compliance with the
53084
- * License. A copy of the License is located at
53085
- *
53086
- * http://aws.amazon.com/asl/
53087
- *
53088
- * or in the "license" file accompanying this file. This file is
53089
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
53090
- * CONDITIONS OF ANY KIND, express or implied. See the License
53091
- * for the specific language governing permissions and
53092
- * limitations under the License.
53054
+ /*!
53055
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
53056
+ * SPDX-License-Identifier: Apache-2.0
53093
53057
  */
53094
53058
 
53095
53059
 
@@ -53145,20 +53109,8 @@ function _setPrototypeOf(o, p) {
53145
53109
  return _setPrototypeOf(o, p);
53146
53110
  }
53147
53111
  /*!
53148
- * Copyright 2016 Amazon.com,
53149
- * Inc. or its affiliates. All Rights Reserved.
53150
- *
53151
- * Licensed under the Amazon Software License (the "License").
53152
- * You may not use this file except in compliance with the
53153
- * License. A copy of the License is located at
53154
- *
53155
- * http://aws.amazon.com/asl/
53156
- *
53157
- * or in the "license" file accompanying this file. This file is
53158
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
53159
- * CONDITIONS OF ANY KIND, express or implied. See the License
53160
- * for the specific language governing permissions and
53161
- * limitations under the License.
53112
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
53113
+ * SPDX-License-Identifier: Apache-2.0
53162
53114
  */
53163
53115
 
53164
53116
 
@@ -53200,20 +53152,8 @@ __webpack_require__.r(__webpack_exports__);
53200
53152
  /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js");
53201
53153
  /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__);
53202
53154
  /*!
53203
- * Copyright 2016 Amazon.com,
53204
- * Inc. or its affiliates. All Rights Reserved.
53205
- *
53206
- * Licensed under the Amazon Software License (the "License").
53207
- * You may not use this file except in compliance with the
53208
- * License. A copy of the License is located at
53209
- *
53210
- * http://aws.amazon.com/asl/
53211
- *
53212
- * or in the "license" file accompanying this file. This file is
53213
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
53214
- * CONDITIONS OF ANY KIND, express or implied. See the License
53215
- * for the specific language governing permissions and
53216
- * limitations under the License.
53155
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
53156
+ * SPDX-License-Identifier: Apache-2.0
53217
53157
  */
53218
53158
 
53219
53159
  /** @class */
@@ -53287,20 +53227,8 @@ var CognitoJwtToken = /*#__PURE__*/function () {
53287
53227
  __webpack_require__.r(__webpack_exports__);
53288
53228
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CognitoRefreshToken; });
53289
53229
  /*!
53290
- * Copyright 2016 Amazon.com,
53291
- * Inc. or its affiliates. All Rights Reserved.
53292
- *
53293
- * Licensed under the Amazon Software License (the "License").
53294
- * You may not use this file except in compliance with the
53295
- * License. A copy of the License is located at
53296
- *
53297
- * http://aws.amazon.com/asl/
53298
- *
53299
- * or in the "license" file accompanying this file. This file is
53300
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
53301
- * CONDITIONS OF ANY KIND, express or implied. See the License
53302
- * for the specific language governing permissions and
53303
- * limitations under the License.
53230
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
53231
+ * SPDX-License-Identifier: Apache-2.0
53304
53232
  */
53305
53233
 
53306
53234
  /** @class */
@@ -53364,20 +53292,8 @@ __webpack_require__.r(__webpack_exports__);
53364
53292
  /* harmony import */ var _CognitoUserAttribute__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./CognitoUserAttribute */ "../amazon-cognito-identity-js/es/CognitoUserAttribute.js");
53365
53293
  /* harmony import */ var _StorageHelper__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./StorageHelper */ "../amazon-cognito-identity-js/es/StorageHelper.js");
53366
53294
  /*!
53367
- * Copyright 2016 Amazon.com,
53368
- * Inc. or its affiliates. All Rights Reserved.
53369
- *
53370
- * Licensed under the Amazon Software License (the "License").
53371
- * You may not use this file except in compliance with the
53372
- * License. A copy of the License is located at
53373
- *
53374
- * http://aws.amazon.com/asl/
53375
- *
53376
- * or in the "license" file accompanying this file. This file is
53377
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
53378
- * CONDITIONS OF ANY KIND, express or implied. See the License
53379
- * for the specific language governing permissions and
53380
- * limitations under the License.
53295
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
53296
+ * SPDX-License-Identifier: Apache-2.0
53381
53297
  */
53382
53298
 
53383
53299
 
@@ -55485,20 +55401,8 @@ var CognitoUser = /*#__PURE__*/function () {
55485
55401
  __webpack_require__.r(__webpack_exports__);
55486
55402
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CognitoUserAttribute; });
55487
55403
  /*!
55488
- * Copyright 2016 Amazon.com,
55489
- * Inc. or its affiliates. All Rights Reserved.
55490
- *
55491
- * Licensed under the Amazon Software License (the "License").
55492
- * You may not use this file except in compliance with the
55493
- * License. A copy of the License is located at
55494
- *
55495
- * http://aws.amazon.com/asl/
55496
- *
55497
- * or in the "license" file accompanying this file. This file is
55498
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
55499
- * CONDITIONS OF ANY KIND, express or implied. See the License
55500
- * for the specific language governing permissions and
55501
- * limitations under the License.
55404
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
55405
+ * SPDX-License-Identifier: Apache-2.0
55502
55406
  */
55503
55407
 
55504
55408
  /** @class */
@@ -55597,20 +55501,8 @@ __webpack_require__.r(__webpack_exports__);
55597
55501
  /* harmony import */ var _CognitoUser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CognitoUser */ "../amazon-cognito-identity-js/es/CognitoUser.js");
55598
55502
  /* harmony import */ var _StorageHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./StorageHelper */ "../amazon-cognito-identity-js/es/StorageHelper.js");
55599
55503
  /*!
55600
- * Copyright 2016 Amazon.com,
55601
- * Inc. or its affiliates. All Rights Reserved.
55602
- *
55603
- * Licensed under the Amazon Software License (the "License").
55604
- * You may not use this file except in compliance with the
55605
- * License. A copy of the License is located at
55606
- *
55607
- * http://aws.amazon.com/asl/
55608
- *
55609
- * or in the "license" file accompanying this file. This file is
55610
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
55611
- * CONDITIONS OF ANY KIND, express or implied. See the License
55612
- * for the specific language governing permissions and
55613
- * limitations under the License.
55504
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
55505
+ * SPDX-License-Identifier: Apache-2.0
55614
55506
  */
55615
55507
 
55616
55508
 
@@ -55811,20 +55703,8 @@ var CognitoUserPool = /*#__PURE__*/function () {
55811
55703
  __webpack_require__.r(__webpack_exports__);
55812
55704
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CognitoUserSession; });
55813
55705
  /*!
55814
- * Copyright 2016 Amazon.com,
55815
- * Inc. or its affiliates. All Rights Reserved.
55816
- *
55817
- * Licensed under the Amazon Software License (the "License").
55818
- * You may not use this file except in compliance with the
55819
- * License. A copy of the License is located at
55820
- *
55821
- * http://aws.amazon.com/asl/
55822
- *
55823
- * or in the "license" file accompanying this file. This file is
55824
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
55825
- * CONDITIONS OF ANY KIND, express or implied. See the License
55826
- * for the specific language governing permissions and
55827
- * limitations under the License.
55706
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
55707
+ * SPDX-License-Identifier: Apache-2.0
55828
55708
  */
55829
55709
 
55830
55710
  /** @class */
@@ -56073,20 +55953,8 @@ var CookieStorage = /*#__PURE__*/function () {
56073
55953
  __webpack_require__.r(__webpack_exports__);
56074
55954
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return DateHelper; });
56075
55955
  /*!
56076
- * Copyright 2016 Amazon.com,
56077
- * Inc. or its affiliates. All Rights Reserved.
56078
- *
56079
- * Licensed under the Amazon Software License (the "License").
56080
- * You may not use this file except in compliance with the
56081
- * License. A copy of the License is located at
56082
- *
56083
- * http://aws.amazon.com/asl/
56084
- *
56085
- * or in the "license" file accompanying this file. This file is
56086
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
56087
- * CONDITIONS OF ANY KIND, express or implied. See the License
56088
- * for the specific language governing permissions and
56089
- * limitations under the License.
55956
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
55957
+ * SPDX-License-Identifier: Apache-2.0
56090
55958
  */
56091
55959
  var monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
56092
55960
  var weekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -56148,17 +56016,9 @@ __webpack_require__.r(__webpack_exports__);
56148
56016
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Platform", function() { return Platform; });
56149
56017
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUserAgent", function() { return getUserAgent; });
56150
56018
  /* harmony import */ var _version__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./version */ "../amazon-cognito-identity-js/es/Platform/version.js");
56151
- /*
56152
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
56153
- *
56154
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
56155
- * the License. A copy of the License is located at
56156
- *
56157
- * http://aws.amazon.com/apache2.0/
56158
- *
56159
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
56160
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
56161
- * and limitations under the License.
56019
+ /*!
56020
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
56021
+ * SPDX-License-Identifier: Apache-2.0
56162
56022
  */
56163
56023
 
56164
56024
  var BASE_USER_AGENT = "aws-amplify/" + _version__WEBPACK_IMPORTED_MODULE_0__["version"];
@@ -56224,20 +56084,8 @@ __webpack_require__.r(__webpack_exports__);
56224
56084
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MemoryStorage", function() { return MemoryStorage; });
56225
56085
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return StorageHelper; });
56226
56086
  /*!
56227
- * Copyright 2016 Amazon.com,
56228
- * Inc. or its affiliates. All Rights Reserved.
56229
- *
56230
- * Licensed under the Amazon Software License (the "License").
56231
- * You may not use this file except in compliance with the
56232
- * License. A copy of the License is located at
56233
- *
56234
- * http://aws.amazon.com/asl/
56235
- *
56236
- * or in the "license" file accompanying this file. This file is
56237
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
56238
- * CONDITIONS OF ANY KIND, express or implied. See the License
56239
- * for the specific language governing permissions and
56240
- * limitations under the License.
56087
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
56088
+ * SPDX-License-Identifier: Apache-2.0
56241
56089
  */
56242
56090
  var dataMemory = {};
56243
56091
  /** @class */
@@ -56409,20 +56257,8 @@ __webpack_require__.r(__webpack_exports__);
56409
56257
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WordArray", function() { return _utils_WordArray__WEBPACK_IMPORTED_MODULE_12__["default"]; });
56410
56258
 
56411
56259
  /*!
56412
- * Copyright 2016 Amazon.com,
56413
- * Inc. or its affiliates. All Rights Reserved.
56414
- *
56415
- * Licensed under the Amazon Software License (the "License").
56416
- * You may not use this file except in compliance with the
56417
- * License. A copy of the License is located at
56418
- *
56419
- * http://aws.amazon.com/asl/
56420
- *
56421
- * or in the "license" file accompanying this file. This file is
56422
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
56423
- * CONDITIONS OF ANY KIND, express or implied. See the License
56424
- * for the specific language governing permissions and
56425
- * limitations under the License.
56260
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
56261
+ * SPDX-License-Identifier: Apache-2.0
56426
56262
  */
56427
56263
 
56428
56264
 
@@ -58854,17 +58690,11 @@ __webpack_require__.r(__webpack_exports__);
58854
58690
 
58855
58691
  "use strict";
58856
58692
  __webpack_require__.r(__webpack_exports__);
58857
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return GRAPHQL_AUTH_MODE; });
58858
58693
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GraphQLAuthError", function() { return GraphQLAuthError; });
58859
- var GRAPHQL_AUTH_MODE;
58694
+ /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/auth */ "../auth/lib-esm/index.js");
58695
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"]; });
58696
+
58860
58697
 
58861
- (function (GRAPHQL_AUTH_MODE) {
58862
- GRAPHQL_AUTH_MODE["API_KEY"] = "API_KEY";
58863
- GRAPHQL_AUTH_MODE["AWS_IAM"] = "AWS_IAM";
58864
- GRAPHQL_AUTH_MODE["OPENID_CONNECT"] = "OPENID_CONNECT";
58865
- GRAPHQL_AUTH_MODE["AMAZON_COGNITO_USER_POOLS"] = "AMAZON_COGNITO_USER_POOLS";
58866
- GRAPHQL_AUTH_MODE["AWS_LAMBDA"] = "AWS_LAMBDA";
58867
- })(GRAPHQL_AUTH_MODE || (GRAPHQL_AUTH_MODE = {}));
58868
58698
 
58869
58699
  var GraphQLAuthError;
58870
58700
 
@@ -61367,21 +61197,68 @@ function () {
61367
61197
 
61368
61198
  var bypassCache = params ? params.bypassCache : false;
61369
61199
  user.getUserData(function (err, data) {
61370
- if (err) {
61371
- logger.debug('getting preferred mfa failed', err);
61372
- rej(err);
61373
- return;
61374
- }
61200
+ return __awaiter(_this, void 0, void 0, function () {
61201
+ var cleanUpError_1, mfaType;
61202
+ return __generator(this, function (_a) {
61203
+ switch (_a.label) {
61204
+ case 0:
61205
+ if (!err) return [3
61206
+ /*break*/
61207
+ , 5];
61208
+ logger.debug('getting preferred mfa failed', err);
61209
+ if (!this.isSessionInvalid(err)) return [3
61210
+ /*break*/
61211
+ , 4];
61212
+ _a.label = 1;
61375
61213
 
61376
- var mfaType = that._getMfaTypeFromUserData(data);
61214
+ case 1:
61215
+ _a.trys.push([1, 3,, 4]);
61377
61216
 
61378
- if (!mfaType) {
61379
- rej('invalid MFA Type');
61380
- return;
61381
- } else {
61382
- res(mfaType);
61383
- return;
61384
- }
61217
+ return [4
61218
+ /*yield*/
61219
+ , this.cleanUpInvalidSession(user)];
61220
+
61221
+ case 2:
61222
+ _a.sent();
61223
+
61224
+ return [3
61225
+ /*break*/
61226
+ , 4];
61227
+
61228
+ case 3:
61229
+ cleanUpError_1 = _a.sent();
61230
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_1.message));
61231
+ return [2
61232
+ /*return*/
61233
+ ];
61234
+
61235
+ case 4:
61236
+ rej(err);
61237
+ return [2
61238
+ /*return*/
61239
+ ];
61240
+
61241
+ case 5:
61242
+ mfaType = that._getMfaTypeFromUserData(data);
61243
+
61244
+ if (!mfaType) {
61245
+ rej('invalid MFA Type');
61246
+ return [2
61247
+ /*return*/
61248
+ ];
61249
+ } else {
61250
+ res(mfaType);
61251
+ return [2
61252
+ /*return*/
61253
+ ];
61254
+ }
61255
+
61256
+ return [2
61257
+ /*return*/
61258
+ ];
61259
+ }
61260
+ });
61261
+ });
61385
61262
  }, {
61386
61263
  bypassCache: bypassCache,
61387
61264
  clientMetadata: clientMetadata
@@ -61423,16 +61300,62 @@ function () {
61423
61300
  };
61424
61301
 
61425
61302
  AuthClass.prototype._getUserData = function (user, params) {
61303
+ var _this = this;
61304
+
61426
61305
  return new Promise(function (res, rej) {
61427
61306
  user.getUserData(function (err, data) {
61428
- if (err) {
61429
- logger.debug('getting user data failed', err);
61430
- rej(err);
61431
- return;
61432
- } else {
61433
- res(data);
61434
- return;
61435
- }
61307
+ return __awaiter(_this, void 0, void 0, function () {
61308
+ var cleanUpError_2;
61309
+ return __generator(this, function (_a) {
61310
+ switch (_a.label) {
61311
+ case 0:
61312
+ if (!err) return [3
61313
+ /*break*/
61314
+ , 5];
61315
+ logger.debug('getting user data failed', err);
61316
+ if (!this.isSessionInvalid(err)) return [3
61317
+ /*break*/
61318
+ , 4];
61319
+ _a.label = 1;
61320
+
61321
+ case 1:
61322
+ _a.trys.push([1, 3,, 4]);
61323
+
61324
+ return [4
61325
+ /*yield*/
61326
+ , this.cleanUpInvalidSession(user)];
61327
+
61328
+ case 2:
61329
+ _a.sent();
61330
+
61331
+ return [3
61332
+ /*break*/
61333
+ , 4];
61334
+
61335
+ case 3:
61336
+ cleanUpError_2 = _a.sent();
61337
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_2.message));
61338
+ return [2
61339
+ /*return*/
61340
+ ];
61341
+
61342
+ case 4:
61343
+ rej(err);
61344
+ return [2
61345
+ /*return*/
61346
+ ];
61347
+
61348
+ case 5:
61349
+ res(data);
61350
+ _a.label = 6;
61351
+
61352
+ case 6:
61353
+ return [2
61354
+ /*return*/
61355
+ ];
61356
+ }
61357
+ });
61358
+ });
61436
61359
  }, params);
61437
61360
  });
61438
61361
  };
@@ -61448,6 +61371,8 @@ function () {
61448
61371
  return __awaiter(this, void 0, void 0, function () {
61449
61372
  var clientMetadata, userData, smsMfaSettings, totpMfaSettings, _a, mfaList, currentMFAType, that;
61450
61373
 
61374
+ var _this = this;
61375
+
61451
61376
  return __generator(this, function (_b) {
61452
61377
  switch (_b.label) {
61453
61378
  case 0:
@@ -61587,12 +61512,53 @@ function () {
61587
61512
  logger.debug('Caching the latest user data into local'); // cache the latest result into user data
61588
61513
 
61589
61514
  user.getUserData(function (err, data) {
61590
- if (err) {
61591
- logger.debug('getting user data failed', err);
61592
- return rej(err);
61593
- } else {
61594
- return res(result);
61595
- }
61515
+ return __awaiter(_this, void 0, void 0, function () {
61516
+ var cleanUpError_3;
61517
+ return __generator(this, function (_a) {
61518
+ switch (_a.label) {
61519
+ case 0:
61520
+ if (!err) return [3
61521
+ /*break*/
61522
+ , 5];
61523
+ logger.debug('getting user data failed', err);
61524
+ if (!this.isSessionInvalid(err)) return [3
61525
+ /*break*/
61526
+ , 4];
61527
+ _a.label = 1;
61528
+
61529
+ case 1:
61530
+ _a.trys.push([1, 3,, 4]);
61531
+
61532
+ return [4
61533
+ /*yield*/
61534
+ , this.cleanUpInvalidSession(user)];
61535
+
61536
+ case 2:
61537
+ _a.sent();
61538
+
61539
+ return [3
61540
+ /*break*/
61541
+ , 4];
61542
+
61543
+ case 3:
61544
+ cleanUpError_3 = _a.sent();
61545
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_3.message));
61546
+ return [2
61547
+ /*return*/
61548
+ ];
61549
+
61550
+ case 4:
61551
+ return [2
61552
+ /*return*/
61553
+ , rej(err)];
61554
+
61555
+ case 5:
61556
+ return [2
61557
+ /*return*/
61558
+ , res(result)];
61559
+ }
61560
+ });
61561
+ });
61596
61562
  }, {
61597
61563
  bypassCache: true,
61598
61564
  clientMetadata: clientMetadata
@@ -61981,44 +61947,80 @@ function () {
61981
61947
  } else {
61982
61948
  user_1.getSession(function (err, session) {
61983
61949
  return __awaiter(_this, void 0, void 0, function () {
61950
+ var cleanUpError_4;
61951
+
61984
61952
  var _this = this;
61985
61953
 
61986
61954
  return __generator(this, function (_a) {
61987
- if (err) {
61988
- logger.debug('Failed to get the user session', err);
61989
- return [2
61990
- /*return*/
61991
- , rej(err)];
61992
- } else {
61993
- user_1.deleteUser(function (err, result) {
61994
- if (err) {
61995
- rej(err);
61996
- } else {
61997
- dispatchAuthEvent('userDeleted', result, 'The authenticated user has been deleted.');
61998
- user_1.signOut();
61999
- _this.user = null;
62000
-
62001
- try {
62002
- _this.cleanCachedItems(); // clean aws credentials
62003
-
62004
- } catch (e) {
62005
- // TODO: change to rejects in refactor
62006
- logger.debug('failed to clear cached items');
62007
- }
61955
+ switch (_a.label) {
61956
+ case 0:
61957
+ if (!err) return [3
61958
+ /*break*/
61959
+ , 5];
61960
+ logger.debug('Failed to get the user session', err);
61961
+ if (!this.isSessionInvalid(err)) return [3
61962
+ /*break*/
61963
+ , 4];
61964
+ _a.label = 1;
61965
+
61966
+ case 1:
61967
+ _a.trys.push([1, 3,, 4]);
61968
+
61969
+ return [4
61970
+ /*yield*/
61971
+ , this.cleanUpInvalidSession(user_1)];
61972
+
61973
+ case 2:
61974
+ _a.sent();
61975
+
61976
+ return [3
61977
+ /*break*/
61978
+ , 4];
61979
+
61980
+ case 3:
61981
+ cleanUpError_4 = _a.sent();
61982
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_4.message));
61983
+ return [2
61984
+ /*return*/
61985
+ ];
61986
+
61987
+ case 4:
61988
+ return [2
61989
+ /*return*/
61990
+ , rej(err)];
62008
61991
 
62009
- if (isSignedInHostedUI) {
62010
- _this.oAuthSignOutRedirect(res, rej);
61992
+ case 5:
61993
+ user_1.deleteUser(function (err, result) {
61994
+ if (err) {
61995
+ rej(err);
62011
61996
  } else {
62012
- dispatchAuthEvent('signOut', _this.user, "A user has been signed out");
62013
- res(result);
61997
+ dispatchAuthEvent('userDeleted', result, 'The authenticated user has been deleted.');
61998
+ user_1.signOut();
61999
+ _this.user = null;
62000
+
62001
+ try {
62002
+ _this.cleanCachedItems(); // clean aws credentials
62003
+
62004
+ } catch (e) {
62005
+ // TODO: change to rejects in refactor
62006
+ logger.debug('failed to clear cached items');
62007
+ }
62008
+
62009
+ if (isSignedInHostedUI) {
62010
+ _this.oAuthSignOutRedirect(res, rej);
62011
+ } else {
62012
+ dispatchAuthEvent('signOut', _this.user, "A user has been signed out");
62013
+ res(result);
62014
+ }
62014
62015
  }
62015
- }
62016
- });
62017
- }
62016
+ });
62017
+ _a.label = 6;
62018
62018
 
62019
- return [2
62020
- /*return*/
62021
- ];
62019
+ case 6:
62020
+ return [2
62021
+ /*return*/
62022
+ ];
62023
+ }
62022
62024
  });
62023
62025
  });
62024
62026
  });
@@ -62126,6 +62128,93 @@ function () {
62126
62128
  };
62127
62129
  });
62128
62130
  };
62131
+
62132
+ AuthClass.prototype.isErrorWithMessage = function (err) {
62133
+ return _typeof(err) === 'object' && Object.prototype.hasOwnProperty.call(err, 'message');
62134
+ }; // Session revoked by another app
62135
+
62136
+
62137
+ AuthClass.prototype.isTokenRevokedError = function (err) {
62138
+ return this.isErrorWithMessage(err) && err.message === 'Access Token has been revoked';
62139
+ };
62140
+
62141
+ AuthClass.prototype.isRefreshTokenRevokedError = function (err) {
62142
+ return this.isErrorWithMessage(err) && err.message === 'Refresh Token has been revoked';
62143
+ };
62144
+
62145
+ AuthClass.prototype.isUserDisabledError = function (err) {
62146
+ return this.isErrorWithMessage(err) && err.message === 'User is disabled.';
62147
+ };
62148
+
62149
+ AuthClass.prototype.isUserDoesNotExistError = function (err) {
62150
+ return this.isErrorWithMessage(err) && err.message === 'User does not exist.';
62151
+ };
62152
+
62153
+ AuthClass.prototype.isRefreshTokenExpiredError = function (err) {
62154
+ return this.isErrorWithMessage(err) && err.message === 'Refresh Token has expired';
62155
+ };
62156
+
62157
+ AuthClass.prototype.isSignedInHostedUI = function () {
62158
+ return this._oAuthHandler && this._storage.getItem('amplify-signin-with-hostedUI') === 'true';
62159
+ };
62160
+
62161
+ AuthClass.prototype.isSessionInvalid = function (err) {
62162
+ return this.isUserDisabledError(err) || this.isUserDoesNotExistError(err) || this.isTokenRevokedError(err) || this.isRefreshTokenRevokedError(err) || this.isRefreshTokenExpiredError(err);
62163
+ };
62164
+
62165
+ AuthClass.prototype.cleanUpInvalidSession = function (user) {
62166
+ return __awaiter(this, void 0, void 0, function () {
62167
+ var e_6;
62168
+
62169
+ var _this = this;
62170
+
62171
+ return __generator(this, function (_a) {
62172
+ switch (_a.label) {
62173
+ case 0:
62174
+ user.signOut();
62175
+ this.user = null;
62176
+ _a.label = 1;
62177
+
62178
+ case 1:
62179
+ _a.trys.push([1, 3,, 4]);
62180
+
62181
+ return [4
62182
+ /*yield*/
62183
+ , this.cleanCachedItems()];
62184
+
62185
+ case 2:
62186
+ _a.sent(); // clean aws credentials
62187
+
62188
+
62189
+ return [3
62190
+ /*break*/
62191
+ , 4];
62192
+
62193
+ case 3:
62194
+ e_6 = _a.sent();
62195
+ logger.debug('failed to clear cached items');
62196
+ return [3
62197
+ /*break*/
62198
+ , 4];
62199
+
62200
+ case 4:
62201
+ if (this.isSignedInHostedUI()) {
62202
+ return [2
62203
+ /*return*/
62204
+ , new Promise(function (res, rej) {
62205
+ _this.oAuthSignOutRedirect(res, rej);
62206
+ })];
62207
+ } else {
62208
+ dispatchAuthEvent('signOut', this.user, "A user has been signed out");
62209
+ }
62210
+
62211
+ return [2
62212
+ /*return*/
62213
+ ];
62214
+ }
62215
+ });
62216
+ });
62217
+ };
62129
62218
  /**
62130
62219
  * Get current authenticated user
62131
62220
  * @return - A promise resolves to current authenticated CognitoUser if success
@@ -62196,74 +62285,143 @@ function () {
62196
62285
 
62197
62286
  user.getSession(function (err, session) {
62198
62287
  return __awaiter(_this, void 0, void 0, function () {
62199
- var bypassCache, clientMetadata, _a, scope;
62288
+ var cleanUpError_5, bypassCache, clientMetadata, _a, scope;
62200
62289
 
62201
62290
  var _this = this;
62202
62291
 
62203
62292
  return __generator(this, function (_b) {
62204
62293
  switch (_b.label) {
62205
62294
  case 0:
62206
- if (err) {
62207
- logger.debug('Failed to get the user session', err);
62208
- rej(err);
62209
- return [2
62210
- /*return*/
62211
- ];
62212
- }
62295
+ if (!err) return [3
62296
+ /*break*/
62297
+ , 5];
62298
+ logger.debug('Failed to get the user session', err);
62299
+ if (!this.isSessionInvalid(err)) return [3
62300
+ /*break*/
62301
+ , 4];
62302
+ _b.label = 1;
62303
+
62304
+ case 1:
62305
+ _b.trys.push([1, 3,, 4]);
62306
+
62307
+ return [4
62308
+ /*yield*/
62309
+ , this.cleanUpInvalidSession(user)];
62310
+
62311
+ case 2:
62312
+ _b.sent();
62313
+
62314
+ return [3
62315
+ /*break*/
62316
+ , 4];
62317
+
62318
+ case 3:
62319
+ cleanUpError_5 = _b.sent();
62320
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_5.message));
62321
+ return [2
62322
+ /*return*/
62323
+ ];
62324
+
62325
+ case 4:
62326
+ rej(err);
62327
+ return [2
62328
+ /*return*/
62329
+ ];
62213
62330
 
62331
+ case 5:
62214
62332
  bypassCache = params ? params.bypassCache : false;
62215
62333
  if (!bypassCache) return [3
62216
62334
  /*break*/
62217
- , 2];
62335
+ , 7];
62218
62336
  return [4
62219
62337
  /*yield*/
62220
62338
  , this.Credentials.clear()];
62221
62339
 
62222
- case 1:
62340
+ case 6:
62223
62341
  _b.sent();
62224
62342
 
62225
- _b.label = 2;
62343
+ _b.label = 7;
62226
62344
 
62227
- case 2:
62345
+ case 7:
62228
62346
  clientMetadata = this._config.clientMetadata;
62229
62347
  _a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
62230
62348
 
62231
62349
  if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
62232
62350
  user.getUserData(function (err, data) {
62233
- if (err) {
62234
- logger.debug('getting user data failed', err); // Make sure the user is still valid
62235
-
62236
- if (err.message === 'User is disabled.' || err.message === 'User does not exist.' || err.message === 'Access Token has been revoked' // Session revoked by another app
62237
- ) {
62238
- rej(err);
62239
- } else {
62240
- // the error may also be thrown when lack of permissions to get user info etc
62241
- // in that case we just bypass the error
62242
- res(user);
62243
- }
62351
+ return __awaiter(_this, void 0, void 0, function () {
62352
+ var cleanUpError_6, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
62353
+ return __generator(this, function (_a) {
62354
+ switch (_a.label) {
62355
+ case 0:
62356
+ if (!err) return [3
62357
+ /*break*/
62358
+ , 7];
62359
+ logger.debug('getting user data failed', err);
62360
+ if (!this.isSessionInvalid(err)) return [3
62361
+ /*break*/
62362
+ , 5];
62363
+ _a.label = 1;
62244
62364
 
62245
- return;
62246
- }
62365
+ case 1:
62366
+ _a.trys.push([1, 3,, 4]);
62367
+
62368
+ return [4
62369
+ /*yield*/
62370
+ , this.cleanUpInvalidSession(user)];
62247
62371
 
62248
- var preferredMFA = data.PreferredMfaSetting || 'NOMFA';
62249
- var attributeList = [];
62372
+ case 2:
62373
+ _a.sent();
62250
62374
 
62251
- for (var i = 0; i < data.UserAttributes.length; i++) {
62252
- var attribute = {
62253
- Name: data.UserAttributes[i].Name,
62254
- Value: data.UserAttributes[i].Value
62255
- };
62256
- var userAttribute = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUserAttribute"](attribute);
62257
- attributeList.push(userAttribute);
62258
- }
62375
+ return [3
62376
+ /*break*/
62377
+ , 4];
62378
+
62379
+ case 3:
62380
+ cleanUpError_6 = _a.sent();
62381
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
62382
+ return [2
62383
+ /*return*/
62384
+ ];
62259
62385
 
62260
- var attributes = _this.attributesToObject(attributeList);
62386
+ case 4:
62387
+ rej(err);
62388
+ return [3
62389
+ /*break*/
62390
+ , 6];
62391
+
62392
+ case 5:
62393
+ res(user);
62394
+ _a.label = 6;
62395
+
62396
+ case 6:
62397
+ return [2
62398
+ /*return*/
62399
+ ];
62400
+
62401
+ case 7:
62402
+ preferredMFA = data.PreferredMfaSetting || 'NOMFA';
62403
+ attributeList = [];
62404
+
62405
+ for (i = 0; i < data.UserAttributes.length; i++) {
62406
+ attribute = {
62407
+ Name: data.UserAttributes[i].Name,
62408
+ Value: data.UserAttributes[i].Value
62409
+ };
62410
+ userAttribute = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUserAttribute"](attribute);
62411
+ attributeList.push(userAttribute);
62412
+ }
62261
62413
 
62262
- Object.assign(user, {
62263
- attributes: attributes,
62264
- preferredMFA: preferredMFA
62414
+ attributes = this.attributesToObject(attributeList);
62415
+ Object.assign(user, {
62416
+ attributes: attributes,
62417
+ preferredMFA: preferredMFA
62418
+ });
62419
+ return [2
62420
+ /*return*/
62421
+ , res(user)];
62422
+ }
62423
+ });
62265
62424
  });
62266
- return res(user);
62267
62425
  }, {
62268
62426
  bypassCache: bypassCache,
62269
62427
  clientMetadata: clientMetadata
@@ -62309,7 +62467,7 @@ function () {
62309
62467
 
62310
62468
  AuthClass.prototype.currentAuthenticatedUser = function (params) {
62311
62469
  return __awaiter(this, void 0, void 0, function () {
62312
- var federatedUser, e_6, federatedInfo, user, e_7;
62470
+ var federatedUser, e_7, federatedInfo, user, e_8;
62313
62471
  return __generator(this, function (_a) {
62314
62472
  switch (_a.label) {
62315
62473
  case 0:
@@ -62332,9 +62490,9 @@ function () {
62332
62490
  , 4];
62333
62491
 
62334
62492
  case 3:
62335
- e_6 = _a.sent();
62336
- logger.debug('Failed to sync cache info into memory', e_6);
62337
- throw e_6;
62493
+ e_7 = _a.sent();
62494
+ logger.debug('Failed to sync cache info into memory', e_7);
62495
+ throw e_7;
62338
62496
 
62339
62497
  case 4:
62340
62498
  try {
@@ -62377,13 +62535,13 @@ function () {
62377
62535
  , 9];
62378
62536
 
62379
62537
  case 8:
62380
- e_7 = _a.sent();
62538
+ e_8 = _a.sent();
62381
62539
 
62382
- if (e_7 === 'No userPool') {
62540
+ if (e_8 === 'No userPool') {
62383
62541
  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');
62384
62542
  }
62385
62543
 
62386
- logger.debug('The user is not authenticated by the error', e_7);
62544
+ logger.debug('The user is not authenticated by the error', e_8);
62387
62545
  return [2
62388
62546
  /*return*/
62389
62547
  , Promise.reject('The user is not authenticated')];
@@ -62408,7 +62566,7 @@ function () {
62408
62566
  logger.debug('Getting current session'); // Purposely not calling the reject method here because we don't need a console error
62409
62567
 
62410
62568
  if (!this.userPool) {
62411
- return Promise.reject();
62569
+ return this.rejectNoUserPool();
62412
62570
  }
62413
62571
 
62414
62572
  return new Promise(function (res, rej) {
@@ -62436,6 +62594,8 @@ function () {
62436
62594
 
62437
62595
 
62438
62596
  AuthClass.prototype.userSession = function (user) {
62597
+ var _this = this;
62598
+
62439
62599
  if (!user) {
62440
62600
  logger.debug('the user is null');
62441
62601
  return this.rejectAuthError(_types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].NoUserSession);
@@ -62443,18 +62603,59 @@ function () {
62443
62603
 
62444
62604
  var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
62445
62605
 
62446
- return new Promise(function (resolve, reject) {
62606
+ return new Promise(function (res, rej) {
62447
62607
  logger.debug('Getting the session from this user:', user);
62448
62608
  user.getSession(function (err, session) {
62449
- if (err) {
62450
- logger.debug('Failed to get the session from user', user);
62451
- reject(err);
62452
- return;
62453
- } else {
62454
- logger.debug('Succeed to get the user session', session);
62455
- resolve(session);
62456
- return;
62457
- }
62609
+ return __awaiter(_this, void 0, void 0, function () {
62610
+ var cleanUpError_7;
62611
+ return __generator(this, function (_a) {
62612
+ switch (_a.label) {
62613
+ case 0:
62614
+ if (!err) return [3
62615
+ /*break*/
62616
+ , 5];
62617
+ logger.debug('Failed to get the session from user', user);
62618
+ if (!this.isSessionInvalid(err)) return [3
62619
+ /*break*/
62620
+ , 4];
62621
+ _a.label = 1;
62622
+
62623
+ case 1:
62624
+ _a.trys.push([1, 3,, 4]);
62625
+
62626
+ return [4
62627
+ /*yield*/
62628
+ , this.cleanUpInvalidSession(user)];
62629
+
62630
+ case 2:
62631
+ _a.sent();
62632
+
62633
+ return [3
62634
+ /*break*/
62635
+ , 4];
62636
+
62637
+ case 3:
62638
+ cleanUpError_7 = _a.sent();
62639
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_7.message));
62640
+ return [2
62641
+ /*return*/
62642
+ ];
62643
+
62644
+ case 4:
62645
+ rej(err);
62646
+ return [2
62647
+ /*return*/
62648
+ ];
62649
+
62650
+ case 5:
62651
+ logger.debug('Succeed to get the user session', session);
62652
+ res(session);
62653
+ return [2
62654
+ /*return*/
62655
+ ];
62656
+ }
62657
+ });
62658
+ });
62458
62659
  }, {
62459
62660
  clientMetadata: clientMetadata
62460
62661
  });
@@ -62468,7 +62669,7 @@ function () {
62468
62669
 
62469
62670
  AuthClass.prototype.currentUserCredentials = function () {
62470
62671
  return __awaiter(this, void 0, void 0, function () {
62471
- var e_8, federatedInfo;
62672
+ var e_9, federatedInfo;
62472
62673
 
62473
62674
  var _this = this;
62474
62675
 
@@ -62493,9 +62694,9 @@ function () {
62493
62694
  , 4];
62494
62695
 
62495
62696
  case 3:
62496
- e_8 = _a.sent();
62497
- logger.debug('Failed to sync cache info into memory', e_8);
62498
- throw e_8;
62697
+ e_9 = _a.sent();
62698
+ logger.debug('Failed to sync cache info into memory', e_9);
62699
+ throw e_9;
62499
62700
 
62500
62701
  case 4:
62501
62702
  federatedInfo = null;
@@ -62517,8 +62718,8 @@ function () {
62517
62718
  , this.currentSession().then(function (session) {
62518
62719
  logger.debug('getting session success', session);
62519
62720
  return _this.Credentials.set(session, 'session');
62520
- })["catch"](function (error) {
62521
- logger.debug('getting session failed', error);
62721
+ })["catch"](function () {
62722
+ logger.debug('getting guest credentials');
62522
62723
  return _this.Credentials.set(null, 'guest');
62523
62724
  })];
62524
62725
  }
@@ -62610,7 +62811,7 @@ function () {
62610
62811
 
62611
62812
  AuthClass.prototype.cognitoIdentitySignOut = function (opts, user) {
62612
62813
  return __awaiter(this, void 0, void 0, function () {
62613
- var e_9, isSignedInHostedUI;
62814
+ var e_10, isSignedInHostedUI;
62614
62815
 
62615
62816
  var _this = this;
62616
62817
 
@@ -62631,9 +62832,9 @@ function () {
62631
62832
  , 3];
62632
62833
 
62633
62834
  case 2:
62634
- e_9 = _a.sent();
62635
- logger.debug('Failed to sync cache info into memory', e_9);
62636
- throw e_9;
62835
+ e_10 = _a.sent();
62836
+ logger.debug('Failed to sync cache info into memory', e_10);
62837
+ throw e_10;
62637
62838
 
62638
62839
  case 3:
62639
62840
  isSignedInHostedUI = this._oAuthHandler && this._storage.getItem('amplify-signin-with-hostedUI') === 'true';
@@ -62647,25 +62848,70 @@ function () {
62647
62848
  var clientMetadata = _this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
62648
62849
 
62649
62850
  user.getSession(function (err, result) {
62650
- if (err) {
62651
- logger.debug('failed to get the user session', err);
62652
- return rej(err);
62653
- }
62851
+ return __awaiter(_this, void 0, void 0, function () {
62852
+ var cleanUpError_8;
62654
62853
 
62655
- user.globalSignOut({
62656
- onSuccess: function onSuccess(data) {
62657
- logger.debug('global sign out success');
62854
+ var _this = this;
62658
62855
 
62659
- if (isSignedInHostedUI) {
62660
- _this.oAuthSignOutRedirect(res, rej);
62661
- } else {
62662
- return res();
62856
+ return __generator(this, function (_a) {
62857
+ switch (_a.label) {
62858
+ case 0:
62859
+ if (!err) return [3
62860
+ /*break*/
62861
+ , 5];
62862
+ logger.debug('failed to get the user session', err);
62863
+ if (!this.isSessionInvalid(err)) return [3
62864
+ /*break*/
62865
+ , 4];
62866
+ _a.label = 1;
62867
+
62868
+ case 1:
62869
+ _a.trys.push([1, 3,, 4]);
62870
+
62871
+ return [4
62872
+ /*yield*/
62873
+ , this.cleanUpInvalidSession(user)];
62874
+
62875
+ case 2:
62876
+ _a.sent();
62877
+
62878
+ return [3
62879
+ /*break*/
62880
+ , 4];
62881
+
62882
+ case 3:
62883
+ cleanUpError_8 = _a.sent();
62884
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_8.message));
62885
+ return [2
62886
+ /*return*/
62887
+ ];
62888
+
62889
+ case 4:
62890
+ return [2
62891
+ /*return*/
62892
+ , rej(err)];
62893
+
62894
+ case 5:
62895
+ user.globalSignOut({
62896
+ onSuccess: function onSuccess(data) {
62897
+ logger.debug('global sign out success');
62898
+
62899
+ if (isSignedInHostedUI) {
62900
+ _this.oAuthSignOutRedirect(res, rej);
62901
+ } else {
62902
+ return res();
62903
+ }
62904
+ },
62905
+ onFailure: function onFailure(err) {
62906
+ logger.debug('global sign out failed', err);
62907
+ return rej(err);
62908
+ }
62909
+ });
62910
+ return [2
62911
+ /*return*/
62912
+ ];
62663
62913
  }
62664
- },
62665
- onFailure: function onFailure(err) {
62666
- logger.debug('global sign out failed', err);
62667
- return rej(err);
62668
- }
62914
+ });
62669
62915
  });
62670
62916
  }, {
62671
62917
  clientMetadata: clientMetadata
@@ -62708,7 +62954,7 @@ function () {
62708
62954
 
62709
62955
 
62710
62956
  setTimeout(function () {
62711
- return reject('Signout timeout fail');
62957
+ return reject(Error('Signout timeout fail'));
62712
62958
  }, 3000);
62713
62959
  };
62714
62960
  /**
@@ -62720,7 +62966,7 @@ function () {
62720
62966
 
62721
62967
  AuthClass.prototype.signOut = function (opts) {
62722
62968
  return __awaiter(this, void 0, void 0, function () {
62723
- var e_10, user;
62969
+ var e_11, user;
62724
62970
  return __generator(this, function (_a) {
62725
62971
  switch (_a.label) {
62726
62972
  case 0:
@@ -62738,7 +62984,7 @@ function () {
62738
62984
  , 3];
62739
62985
 
62740
62986
  case 2:
62741
- e_10 = _a.sent();
62987
+ e_11 = _a.sent();
62742
62988
  logger.debug('failed to clear cached items');
62743
62989
  return [3
62744
62990
  /*break*/
@@ -62773,7 +63019,7 @@ function () {
62773
63019
  , 8];
62774
63020
 
62775
63021
  case 7:
62776
- logger.debug('no Congito User pool');
63022
+ logger.debug('no Cognito User pool');
62777
63023
  _a.label = 8;
62778
63024
 
62779
63025
  case 8:
@@ -62939,7 +63185,7 @@ function () {
62939
63185
 
62940
63186
  AuthClass.prototype.currentUserInfo = function () {
62941
63187
  return __awaiter(this, void 0, void 0, function () {
62942
- var source, user, attributes, userAttrs, credentials, e_11, info, err_1, user;
63188
+ var source, user, attributes, userAttrs, credentials, e_12, info, err_1, user;
62943
63189
  return __generator(this, function (_a) {
62944
63190
  switch (_a.label) {
62945
63191
  case 0:
@@ -62991,8 +63237,8 @@ function () {
62991
63237
  , 7];
62992
63238
 
62993
63239
  case 6:
62994
- e_11 = _a.sent();
62995
- logger.debug('Failed to retrieve credentials while getting current user info', e_11);
63240
+ e_12 = _a.sent();
63241
+ logger.debug('Failed to retrieve credentials while getting current user info', e_12);
62996
63242
  return [3
62997
63243
  /*break*/
62998
63244
  , 7];
@@ -64390,7 +64636,7 @@ var AuthErrorStrings;
64390
64636
  /*!********************************!*\
64391
64637
  !*** ../auth/lib-esm/index.js ***!
64392
64638
  \********************************/
64393
- /*! exports provided: default, Auth, CognitoUser, CookieStorage, CognitoHostedUIIdentityProvider, appendToCognitoUserAgent, AuthErrorStrings */
64639
+ /*! exports provided: default, Auth, CognitoUser, CookieStorage, CognitoHostedUIIdentityProvider, appendToCognitoUserAgent, AuthErrorStrings, GRAPHQL_AUTH_MODE */
64394
64640
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
64395
64641
 
64396
64642
  "use strict";
@@ -64401,6 +64647,8 @@ __webpack_require__.r(__webpack_exports__);
64401
64647
  /* harmony import */ var _types_Auth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types/Auth */ "../auth/lib-esm/types/Auth.js");
64402
64648
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CognitoHostedUIIdentityProvider", function() { return _types_Auth__WEBPACK_IMPORTED_MODULE_1__["CognitoHostedUIIdentityProvider"]; });
64403
64649
 
64650
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return _types_Auth__WEBPACK_IMPORTED_MODULE_1__["GRAPHQL_AUTH_MODE"]; });
64651
+
64404
64652
  /* harmony import */ var amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! amazon-cognito-identity-js */ "../amazon-cognito-identity-js/es/index.js");
64405
64653
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CognitoUser", function() { return amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUser"]; });
64406
64654
 
@@ -64440,7 +64688,7 @@ __webpack_require__.r(__webpack_exports__);
64440
64688
  /*!*************************************!*\
64441
64689
  !*** ../auth/lib-esm/types/Auth.js ***!
64442
64690
  \*************************************/
64443
- /*! exports provided: CognitoHostedUIIdentityProvider, isFederatedSignInOptions, isFederatedSignInOptionsCustom, hasCustomState, isCognitoHostedOpts, AuthErrorTypes, isUsernamePasswordOpts */
64691
+ /*! exports provided: CognitoHostedUIIdentityProvider, isFederatedSignInOptions, isFederatedSignInOptionsCustom, hasCustomState, isCognitoHostedOpts, AuthErrorTypes, isUsernamePasswordOpts, GRAPHQL_AUTH_MODE */
64444
64692
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
64445
64693
 
64446
64694
  "use strict";
@@ -64452,6 +64700,7 @@ __webpack_require__.r(__webpack_exports__);
64452
64700
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isCognitoHostedOpts", function() { return isCognitoHostedOpts; });
64453
64701
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AuthErrorTypes", function() { return AuthErrorTypes; });
64454
64702
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isUsernamePasswordOpts", function() { return isUsernamePasswordOpts; });
64703
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return GRAPHQL_AUTH_MODE; });
64455
64704
  /*
64456
64705
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
64457
64706
  *
@@ -64517,6 +64766,15 @@ var AuthErrorTypes;
64517
64766
  function isUsernamePasswordOpts(obj) {
64518
64767
  return !!obj.username;
64519
64768
  }
64769
+ var GRAPHQL_AUTH_MODE;
64770
+
64771
+ (function (GRAPHQL_AUTH_MODE) {
64772
+ GRAPHQL_AUTH_MODE["API_KEY"] = "API_KEY";
64773
+ GRAPHQL_AUTH_MODE["AWS_IAM"] = "AWS_IAM";
64774
+ GRAPHQL_AUTH_MODE["OPENID_CONNECT"] = "OPENID_CONNECT";
64775
+ GRAPHQL_AUTH_MODE["AMAZON_COGNITO_USER_POOLS"] = "AMAZON_COGNITO_USER_POOLS";
64776
+ GRAPHQL_AUTH_MODE["AWS_LAMBDA"] = "AWS_LAMBDA";
64777
+ })(GRAPHQL_AUTH_MODE || (GRAPHQL_AUTH_MODE = {}));
64520
64778
 
64521
64779
  /***/ }),
64522
64780
 
@@ -64524,7 +64782,7 @@ function isUsernamePasswordOpts(obj) {
64524
64782
  /*!**************************************!*\
64525
64783
  !*** ../auth/lib-esm/types/index.js ***!
64526
64784
  \**************************************/
64527
- /*! exports provided: CognitoHostedUIIdentityProvider, isFederatedSignInOptions, isFederatedSignInOptionsCustom, hasCustomState, isCognitoHostedOpts, AuthErrorTypes, isUsernamePasswordOpts */
64785
+ /*! exports provided: CognitoHostedUIIdentityProvider, isFederatedSignInOptions, isFederatedSignInOptionsCustom, hasCustomState, isCognitoHostedOpts, AuthErrorTypes, isUsernamePasswordOpts, GRAPHQL_AUTH_MODE */
64528
64786
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
64529
64787
 
64530
64788
  "use strict";
@@ -64544,6 +64802,8 @@ __webpack_require__.r(__webpack_exports__);
64544
64802
 
64545
64803
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isUsernamePasswordOpts", function() { return _Auth__WEBPACK_IMPORTED_MODULE_0__["isUsernamePasswordOpts"]; });
64546
64804
 
64805
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return _Auth__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"]; });
64806
+
64547
64807
  /*
64548
64808
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
64549
64809
  *
@@ -70936,7 +71196,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
70936
71196
  __webpack_require__.r(__webpack_exports__);
70937
71197
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
70938
71198
  // generated by genversion
70939
- var version = '4.4.0';
71199
+ var version = '4.5.2';
70940
71200
 
70941
71201
  /***/ }),
70942
71202
 
@@ -73399,13 +73659,14 @@ function () {
73399
73659
  /*!*************************************!*\
73400
73660
  !*** ../core/lib-esm/Util/Retry.js ***!
73401
73661
  \*************************************/
73402
- /*! exports provided: NonRetryableError, retry, jitteredExponentialRetry */
73662
+ /*! exports provided: NonRetryableError, retry, jitteredBackoff, jitteredExponentialRetry */
73403
73663
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73404
73664
 
73405
73665
  "use strict";
73406
73666
  __webpack_require__.r(__webpack_exports__);
73407
73667
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NonRetryableError", function() { return NonRetryableError; });
73408
73668
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "retry", function() { return retry; });
73669
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "jitteredBackoff", function() { return jitteredBackoff; });
73409
73670
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "jitteredExponentialRetry", function() { return jitteredExponentialRetry; });
73410
73671
  /* harmony import */ var _Logger_ConsoleLogger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Logger/ConsoleLogger */ "../core/lib-esm/Logger/ConsoleLogger.js");
73411
73672
  var __extends = undefined && undefined.__extends || function () {
@@ -73720,8 +73981,16 @@ function retry(functionToRetry, args, delayFn, attempt) {
73720
73981
  });
73721
73982
  }
73722
73983
  var MAX_DELAY_MS = 5 * 60 * 1000;
73984
+ /**
73985
+ * @private
73986
+ * Internal use of Amplify only
73987
+ */
73723
73988
 
73724
73989
  function jitteredBackoff(maxDelayMs) {
73990
+ if (maxDelayMs === void 0) {
73991
+ maxDelayMs = MAX_DELAY_MS;
73992
+ }
73993
+
73725
73994
  var BASE_TIME_MS = 100;
73726
73995
  var JITTER_FACTOR = 100;
73727
73996
  return function (attempt) {
@@ -73734,7 +74003,6 @@ function jitteredBackoff(maxDelayMs) {
73734
74003
  * Internal use of Amplify only
73735
74004
  */
73736
74005
 
73737
-
73738
74006
  var jitteredExponentialRetry = function jitteredExponentialRetry(functionToRetry, args, maxDelayMs) {
73739
74007
  if (maxDelayMs === void 0) {
73740
74008
  maxDelayMs = MAX_DELAY_MS;
@@ -73773,7 +74041,7 @@ function urlSafeDecode(hex) {
73773
74041
  /*!*************************************!*\
73774
74042
  !*** ../core/lib-esm/Util/index.js ***!
73775
74043
  \*************************************/
73776
- /*! exports provided: NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY */
74044
+ /*! exports provided: NonRetryableError, retry, jitteredBackoff, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY */
73777
74045
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73778
74046
 
73779
74047
  "use strict";
@@ -73783,6 +74051,8 @@ __webpack_require__.r(__webpack_exports__);
73783
74051
 
73784
74052
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "retry", function() { return _Retry__WEBPACK_IMPORTED_MODULE_0__["retry"]; });
73785
74053
 
74054
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "jitteredBackoff", function() { return _Retry__WEBPACK_IMPORTED_MODULE_0__["jitteredBackoff"]; });
74055
+
73786
74056
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "jitteredExponentialRetry", function() { return _Retry__WEBPACK_IMPORTED_MODULE_0__["jitteredExponentialRetry"]; });
73787
74057
 
73788
74058
  /* harmony import */ var _Mutex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Mutex */ "../core/lib-esm/Util/Mutex.js");
@@ -73857,6 +74127,10 @@ __webpack_require__.r(__webpack_exports__);
73857
74127
  * is used for AppSync/GraphQL subscriptions in the API category.
73858
74128
  */
73859
74129
  var hasSymbol = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function';
74130
+ /**
74131
+ * @deprecated Unused, all usecases have migrated to INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER
74132
+ */
74133
+
73860
74134
  var INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER = hasSymbol ? Symbol["for"]('INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER') : '@@INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER';
73861
74135
  var INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER = hasSymbol ? Symbol["for"]('INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER') : '@@INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER';
73862
74136
  var USER_AGENT_HEADER = 'x-amz-user-agent';
@@ -73867,7 +74141,7 @@ var USER_AGENT_HEADER = 'x-amz-user-agent';
73867
74141
  /*!********************************!*\
73868
74142
  !*** ../core/lib-esm/index.js ***!
73869
74143
  \********************************/
73870
- /*! exports provided: AmplifyClass, ClientDevice, ConsoleLogger, Logger, missingConfig, invalidParameter, Hub, I18n, isEmpty, sortByField, objectLessAttributes, filenameToContentType, isTextFile, generateRandomString, makeQuerablePromise, isWebWorker, browserOrNode, transferKeyToLowerCase, transferKeyToUpperCase, isStrictObject, JS, Signer, parseMobileHubConfig, Parser, AWSCloudWatchProvider, FacebookOAuth, GoogleOAuth, Linking, AppState, AsyncStorage, Credentials, CredentialsClass, ServiceWorker, StorageHelper, MemoryStorage, UniversalStorage, Platform, getAmplifyUserAgent, INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER, INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, Constants, NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY, Amplify, default */
74144
+ /*! exports provided: AmplifyClass, ClientDevice, ConsoleLogger, Logger, missingConfig, invalidParameter, Hub, I18n, isEmpty, sortByField, objectLessAttributes, filenameToContentType, isTextFile, generateRandomString, makeQuerablePromise, isWebWorker, browserOrNode, transferKeyToLowerCase, transferKeyToUpperCase, isStrictObject, JS, Signer, parseMobileHubConfig, Parser, AWSCloudWatchProvider, FacebookOAuth, GoogleOAuth, Linking, AppState, AsyncStorage, Credentials, CredentialsClass, ServiceWorker, StorageHelper, MemoryStorage, UniversalStorage, Platform, getAmplifyUserAgent, INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER, INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, Constants, NonRetryableError, retry, jitteredBackoff, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY, Amplify, default */
73871
74145
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73872
74146
 
73873
74147
  "use strict";
@@ -73980,6 +74254,8 @@ __webpack_require__.r(__webpack_exports__);
73980
74254
 
73981
74255
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "retry", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["retry"]; });
73982
74256
 
74257
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "jitteredBackoff", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["jitteredBackoff"]; });
74258
+
73983
74259
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "jitteredExponentialRetry", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["jitteredExponentialRetry"]; });
73984
74260
 
73985
74261
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mutex", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["Mutex"]; });
@@ -82875,11 +83151,30 @@ function () {
82875
83151
  , this.start()];
82876
83152
 
82877
83153
  case 1:
82878
- _a.sent();
83154
+ _a.sent(); // Filter the events returned by Storage according to namespace,
83155
+ // append original element data, and subscribe to the observable
83156
+
82879
83157
 
82880
83158
  handle = this.storage.observe(modelConstructor, predicate).filter(function (_a) {
82881
83159
  var model = _a.model;
82882
83160
  return namespaceResolver(model) === _util__WEBPACK_IMPORTED_MODULE_9__["USER"];
83161
+ }).map(function (event) {
83162
+ // The `element` returned by storage only contains updated fields.
83163
+ // Intercept the event to send the `savedElement` so that the first
83164
+ // snapshot returned to the consumer contains all fields.
83165
+ // In the event of a delete we return `element`, as `savedElement`
83166
+ // here is undefined.
83167
+ var opType = event.opType,
83168
+ model = event.model,
83169
+ condition = event.condition,
83170
+ element = event.element,
83171
+ savedElement = event.savedElement;
83172
+ return {
83173
+ opType: opType,
83174
+ element: savedElement || element,
83175
+ model: model,
83176
+ condition: condition
83177
+ };
82883
83178
  }).subscribe(observer);
82884
83179
  return [2
82885
83180
  /*return*/
@@ -89159,7 +89454,7 @@ function () {
89159
89454
  result = _a.sent();
89160
89455
  result.forEach(function (r) {
89161
89456
  var _a = __read(r, 2),
89162
- originalElement = _a[0],
89457
+ savedElement = _a[0],
89163
89458
  opType = _a[1]; // truthy when save is called by the Merger
89164
89459
 
89165
89460
 
@@ -89168,7 +89463,18 @@ function () {
89168
89463
  // is called by Merger, i.e., when processing an AppSync response
89169
89464
 
89170
89465
  if (opType === _types__WEBPACK_IMPORTED_MODULE_3__["OpType"].UPDATE && !syncResponse) {
89171
- updateMutationInput = _this.getUpdateMutationInput(model, originalElement, patchesTuple); // // an update without changed user fields
89466
+ //
89467
+ // TODO: LOOK!!!
89468
+ // the `model` used here is in effect regardless of what model
89469
+ // comes back from adapter.save().
89470
+ // Prior to fix, SQLite adapter had been returning two models
89471
+ // of different types, resulting in invalid outbox entries.
89472
+ //
89473
+ // the bug is essentially fixed in SQLite adapter.
89474
+ // leaving as-is, because it's currently unclear whether anything
89475
+ // depends on this remaining as-is.
89476
+ //
89477
+ updateMutationInput = _this.getUpdateMutationInput(model, savedElement, patchesTuple); // // an update without changed user fields
89172
89478
  // => don't create mutationEvent
89173
89479
 
89174
89480
  if (updateMutationInput === null) {
@@ -89176,15 +89482,16 @@ function () {
89176
89482
  }
89177
89483
  }
89178
89484
 
89179
- var element = updateMutationInput || originalElement;
89180
- var modelConstructor = Object.getPrototypeOf(originalElement).constructor;
89485
+ var element = updateMutationInput || savedElement;
89486
+ var modelConstructor = Object.getPrototypeOf(savedElement).constructor;
89181
89487
 
89182
89488
  _this.pushStream.next({
89183
89489
  model: modelConstructor,
89184
89490
  opType: opType,
89185
89491
  element: element,
89186
89492
  mutator: mutator,
89187
- condition: _predicates__WEBPACK_IMPORTED_MODULE_2__["ModelPredicateCreator"].getPredicates(condition, false)
89493
+ condition: _predicates__WEBPACK_IMPORTED_MODULE_2__["ModelPredicateCreator"].getPredicates(condition, false),
89494
+ savedElement: savedElement
89188
89495
  });
89189
89496
  });
89190
89497
  return [2
@@ -91375,7 +91682,7 @@ var __spread = undefined && undefined.__spread || function () {
91375
91682
  return ar;
91376
91683
  };
91377
91684
 
91378
-
91685
+ // https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#merger
91379
91686
 
91380
91687
  var ModelMerger =
91381
91688
  /** @class */
@@ -91704,6 +92011,7 @@ var __read = undefined && undefined.__read || function (o, n) {
91704
92011
 
91705
92012
 
91706
92013
  // TODO: Persist deleted ids
92014
+ // https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#outbox
91707
92015
 
91708
92016
  var MutationEventOutbox =
91709
92017
  /** @class */
@@ -92134,11 +92442,12 @@ function () {
92134
92442
  /*!*********************************************!*\
92135
92443
  !*** ./lib-esm/sync/processors/mutation.js ***!
92136
92444
  \*********************************************/
92137
- /*! exports provided: MutationProcessor */
92445
+ /*! exports provided: safeJitteredBackoff, MutationProcessor */
92138
92446
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
92139
92447
 
92140
92448
  "use strict";
92141
92449
  __webpack_require__.r(__webpack_exports__);
92450
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeJitteredBackoff", function() { return safeJitteredBackoff; });
92142
92451
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MutationProcessor", function() { return MutationProcessor; });
92143
92452
  /* harmony import */ var _aws_amplify_api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/api */ "../api/lib-esm/index.js");
92144
92453
  /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @aws-amplify/core */ "../core/lib-esm/index.js");
@@ -92692,7 +93001,7 @@ function () {
92692
93001
  case 0:
92693
93002
  return [4
92694
93003
  /*yield*/
92695
- , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["jitteredExponentialRetry"])(function (model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent) {
93004
+ , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["retry"])(function (model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent) {
92696
93005
  return __awaiter(_this, void 0, void 0, function () {
92697
93006
  var _a, query, variables, graphQLCondition, opName, modelDefinition, authToken, tryWith, attempt, opType, result, err_1, _b, error, _c, _d, code, retryWith, err_2, _e, _f, opName_1, query_1, authToken_1, serverData, namespace, updatedMutation, err_3;
92698
93007
 
@@ -92898,7 +93207,7 @@ function () {
92898
93207
  }
92899
93208
  });
92900
93209
  });
92901
- }, [model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent])];
93210
+ }, [model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent], safeJitteredBackoff)];
92902
93211
 
92903
93212
  case 1:
92904
93213
  return [2
@@ -93040,6 +93349,33 @@ function () {
93040
93349
  return MutationProcessor;
93041
93350
  }();
93042
93351
 
93352
+ var MAX_RETRY_DELAY_MS = 5 * 60 * 1000;
93353
+ var originalJitteredBackoff = Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["jitteredBackoff"])(MAX_RETRY_DELAY_MS);
93354
+ /**
93355
+ * @private
93356
+ * Internal use of Amplify only.
93357
+ *
93358
+ * Wraps the jittered backoff calculation to retry Network Errors indefinitely.
93359
+ * Backs off according to original jittered retry logic until the original retry
93360
+ * logic hits its max. After this occurs, if the error is a Network Error, we
93361
+ * ignore the attempt count and return MAX_RETRY_DELAY_MS to retry forever (until
93362
+ * the request succeeds).
93363
+ *
93364
+ * @param attempt ignored
93365
+ * @param _args ignored
93366
+ * @param error tested to see if `.message` is 'Network Error'
93367
+ * @returns number | false :
93368
+ */
93369
+
93370
+ var safeJitteredBackoff = function safeJitteredBackoff(attempt, _args, error) {
93371
+ var attemptResult = originalJitteredBackoff(attempt); // If this is the last attempt and it is a network error, we retry indefinitively every 5 minutes
93372
+
93373
+ if (attemptResult === false && (error === null || error === void 0 ? void 0 : error.message) === 'Network Error') {
93374
+ return MAX_RETRY_DELAY_MS;
93375
+ }
93376
+
93377
+ return attemptResult;
93378
+ };
93043
93379
 
93044
93380
 
93045
93381
  /***/ }),