@aws-amplify/datastore 3.12.2-auth-hotfix.4 → 3.12.2-auth-hotfix.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.12.2](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.1...@aws-amplify/datastore@3.12.2) (2022-07-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * decrease error handler verbosity on self recovering errors ([#10030](https://github.com/aws-amplify/amplify-js/issues/10030)) ([fb1f02c](https://github.com/aws-amplify/amplify-js/commit/fb1f02cfa914b81fe0411e8f4d654c69aed22385))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [3.12.1](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.0...@aws-amplify/datastore@3.12.1) (2022-06-18)
7
18
 
8
19
 
@@ -60726,7 +60726,6 @@ function () {
60726
60726
  this.user = null;
60727
60727
  this.oAuthFlowInProgress = false;
60728
60728
  this.inflightSessionPromise = null;
60729
- this.inflightSession = false;
60730
60729
  this.Credentials = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Credentials"];
60731
60730
 
60732
60731
  this.wrapRefreshSessionCallback = function (callback) {
@@ -62679,60 +62678,39 @@ function () {
62679
62678
  };
62680
62679
 
62681
62680
  AuthClass.prototype._userSession = function (_a) {
62682
- var _this = this;
62683
-
62684
62681
  var user = _a.user,
62685
62682
  _b = _a.bypassCache,
62686
62683
  bypassCache = _b === void 0 ? false : _b;
62684
+ return __awaiter(this, void 0, void 0, function () {
62685
+ var clientMetadata;
62687
62686
 
62688
- if (!user) {
62689
- logger.debug('the user is null');
62690
- return this.rejectAuthError(_types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].NoUserSession);
62691
- }
62692
-
62693
- var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
62694
-
62695
- return new Promise(function (resolve, rej) {
62696
- return __awaiter(_this, void 0, void 0, function () {
62697
- var debounceResolver;
62698
-
62699
- var _this = this;
62700
-
62701
- return __generator(this, function (_a) {
62702
- switch (_a.label) {
62703
- case 0:
62704
- // debugger;
62705
- logger.debug('Getting the session from this user:', user);
62706
- if (!this.inflightSession) return [3
62707
- /*break*/
62708
- , 2];
62709
- logger.debug('Waiting for another userSession call:');
62710
- return [4
62711
- /*yield*/
62712
- , this.inflightSessionPromise];
62687
+ var _this = this;
62713
62688
 
62714
- case 1:
62715
- _a.sent();
62689
+ return __generator(this, function (_c) {
62690
+ switch (_c.label) {
62691
+ case 0:
62692
+ if (!user) {
62693
+ logger.debug('the user is null');
62694
+ return [2
62695
+ /*return*/
62696
+ , this.rejectAuthError(_types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].NoUserSession)];
62697
+ }
62716
62698
 
62717
- logger.debug('Debouncer resolved');
62718
- return [3
62719
- /*break*/
62720
- , 3];
62699
+ clientMetadata = this._config.clientMetadata;
62700
+ if (!this.inflightSessionPromise) return [3
62701
+ /*break*/
62702
+ , 2];
62703
+ return [4
62704
+ /*yield*/
62705
+ , this.inflightSessionPromise];
62721
62706
 
62722
- case 2:
62723
- logger.debug('Debouncer head');
62724
- this.inflightSession = true;
62725
- this.inflightSessionPromise = new Promise(function (res) {
62726
- debounceResolver = function debounceResolver() {
62727
- logger.debug('Debouncer resolving');
62728
- _this.inflightSessionPromise = null;
62729
- _this.inflightSession = false;
62730
- res();
62731
- };
62732
- });
62733
- _a.label = 3;
62707
+ case 1:
62708
+ return [2
62709
+ /*return*/
62710
+ , _c.sent()];
62734
62711
 
62735
- case 3:
62712
+ case 2:
62713
+ this.inflightSessionPromise = new Promise(function (resolve, rej) {
62736
62714
  user.getSession(function (err, session) {
62737
62715
  return __awaiter(_this, void 0, void 0, function () {
62738
62716
  var cleanUpError_6;
@@ -62765,22 +62743,12 @@ function () {
62765
62743
  case 3:
62766
62744
  cleanUpError_6 = _a.sent();
62767
62745
  rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
62768
-
62769
- if (debounceResolver) {
62770
- debounceResolver();
62771
- }
62772
-
62773
62746
  return [2
62774
62747
  /*return*/
62775
62748
  ];
62776
62749
 
62777
62750
  case 4:
62778
62751
  rej(err);
62779
-
62780
- if (debounceResolver) {
62781
- debounceResolver();
62782
- }
62783
-
62784
62752
  return [2
62785
62753
  /*return*/
62786
62754
  ];
@@ -62788,11 +62756,6 @@ function () {
62788
62756
  case 5:
62789
62757
  logger.debug('Succeed to get the user session', session);
62790
62758
  resolve(session);
62791
-
62792
- if (debounceResolver) {
62793
- debounceResolver();
62794
- }
62795
-
62796
62759
  return [2
62797
62760
  /*return*/
62798
62761
  ];
@@ -62803,11 +62766,17 @@ function () {
62803
62766
  clientMetadata: clientMetadata,
62804
62767
  bypassCache: bypassCache
62805
62768
  });
62806
- return [2
62807
- /*return*/
62808
- ];
62809
- }
62810
- });
62769
+ }).then(function (session) {
62770
+ _this.inflightSessionPromise = null;
62771
+ return session;
62772
+ })["catch"](function (err) {
62773
+ _this.inflightSessionPromise = null;
62774
+ throw err;
62775
+ });
62776
+ return [2
62777
+ /*return*/
62778
+ , this.inflightSessionPromise];
62779
+ }
62811
62780
  });
62812
62781
  });
62813
62782
  };
@@ -63096,7 +63065,7 @@ function () {
63096
63065
  };
63097
63066
 
63098
63067
  AuthClass.prototype.oAuthSignOutRedirect = function (resolve, reject) {
63099
- var isBrowser = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["JS"].browserOrNode().isBrowser;
63068
+ var isBrowser = Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["browserOrNode"])().isBrowser;
63100
63069
 
63101
63070
  if (isBrowser) {
63102
63071
  this.oAuthSignOutRedirectOrReject(reject);
@@ -63554,7 +63523,7 @@ function () {
63554
63523
  dispatchAuthEvent('parsingCallbackUrl', {
63555
63524
  url: URL
63556
63525
  }, "The callback url is being parsed");
63557
- currentUrl = URL || (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["JS"].browserOrNode().isBrowser ? window.location.href : '');
63526
+ currentUrl = URL || (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["browserOrNode"])().isBrowser ? window.location.href : '');
63558
63527
  hasCodeOrError = !!(Object(url__WEBPACK_IMPORTED_MODULE_3__["parse"])(currentUrl).query || '').split('&').map(function (entry) {
63559
63528
  return entry.split('=');
63560
63529
  }).find(function (_a) {
@@ -65007,12 +64976,12 @@ __webpack_require__.r(__webpack_exports__);
65007
64976
  */
65008
64977
 
65009
64978
  /* harmony default export */ __webpack_exports__["default"] = (function (callback) {
65010
- if (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["JS"].browserOrNode().isBrowser && window.location) {
64979
+ if (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["browserOrNode"])().isBrowser && window.location) {
65011
64980
  var url = window.location.href;
65012
64981
  callback({
65013
64982
  url: url
65014
64983
  });
65015
- } else if (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["JS"].browserOrNode().isNode) {
64984
+ } else if (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["browserOrNode"])().isNode) {
65016
64985
  // continue building on ssr
65017
64986
  (function () {}); // noop
65018
64987
 
@@ -71287,7 +71256,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
71287
71256
  __webpack_require__.r(__webpack_exports__);
71288
71257
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
71289
71258
  // generated by genversion
71290
- var version = '4.5.8';
71259
+ var version = '4.5.9';
71291
71260
 
71292
71261
  /***/ }),
71293
71262
 
@@ -94306,6 +94275,32 @@ function () {
94306
94275
  _a = subscriptionError.error, _b = __read((_a === void 0 ? {
94307
94276
  errors: []
94308
94277
  } : _a).errors, 1), _c = _b[0], _d = (_c === void 0 ? {} : _c).message, message = _d === void 0 ? '' : _d;
94278
+
94279
+ if (message.includes(_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR) || message.includes(_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__["CONTROL_MSG"].CONNECTION_FAILED)) {
94280
+ // Unsubscribe and clear subscription array for model/operation
94281
+ subscriptions[modelDefinition.name][transformerMutationType].forEach(function (subscription) {
94282
+ return subscription.unsubscribe();
94283
+ });
94284
+ subscriptions[modelDefinition.name][transformerMutationType] = [];
94285
+ operationAuthModeAttempts[operation]++;
94286
+
94287
+ if (operationAuthModeAttempts[operation] >= readAuthModes.length) {
94288
+ // last auth mode retry. Continue with error
94289
+ logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1]);
94290
+ } else {
94291
+ // retry with different auth mode. Do not trigger
94292
+ // observer error or error handler
94293
+ logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1] + ". Retrying with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
94294
+
94295
+ _authModeRetry(operation);
94296
+
94297
+ return [2
94298
+ /*return*/
94299
+ ];
94300
+ }
94301
+ }
94302
+
94303
+ logger.warn('subscriptionError', message);
94309
94304
  _e.label = 1;
94310
94305
 
94311
94306
  case 1:
@@ -94334,39 +94329,12 @@ function () {
94334
94329
 
94335
94330
  case 3:
94336
94331
  e_1 = _e.sent();
94337
- logger.error('Sync error handler failed with:', e_1);
94332
+ logger.error('Subscription error handler failed with:', e_1);
94338
94333
  return [3
94339
94334
  /*break*/
94340
94335
  , 4];
94341
94336
 
94342
94337
  case 4:
94343
- if (message.includes(_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR) || message.includes(_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__["CONTROL_MSG"].CONNECTION_FAILED)) {
94344
- // Unsubscribe and clear subscription array for model/operation
94345
- subscriptions[modelDefinition.name][transformerMutationType].forEach(function (subscription) {
94346
- return subscription.unsubscribe();
94347
- });
94348
- subscriptions[modelDefinition.name][transformerMutationType] = [];
94349
- operationAuthModeAttempts[operation]++;
94350
-
94351
- if (operationAuthModeAttempts[operation] >= readAuthModes.length) {
94352
- logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1]);
94353
- logger.warn('subscriptionError', message);
94354
- return [2
94355
- /*return*/
94356
- ];
94357
- } else {
94358
- logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1] + ". Retrying with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
94359
-
94360
- _authModeRetry(operation);
94361
-
94362
- return [2
94363
- /*return*/
94364
- ];
94365
- }
94366
- }
94367
-
94368
- logger.warn('subscriptionError', message);
94369
-
94370
94338
  if (typeof subscriptionReadyCallback === 'function') {
94371
94339
  subscriptionReadyCallback();
94372
94340
  }