@aws-amplify/datastore 3.12.2-auth-hotfix.4 → 3.12.2-unstable.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.
@@ -60725,8 +60725,6 @@ function () {
60725
60725
  this.userPool = null;
60726
60726
  this.user = null;
60727
60727
  this.oAuthFlowInProgress = false;
60728
- this.inflightSessionPromise = null;
60729
- this.inflightSession = false;
60730
60728
  this.Credentials = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Credentials"];
60731
60729
 
60732
60730
  this.wrapRefreshSessionCallback = function (callback) {
@@ -62354,12 +62352,12 @@ function () {
62354
62352
  return new Promise(function (res, rej) {
62355
62353
  _this._storageSync.then(function () {
62356
62354
  return __awaiter(_this, void 0, void 0, function () {
62357
- var user, session, bypassCache, clientMetadata, _a, scope, err_1;
62355
+ var user, clientMetadata;
62358
62356
 
62359
62357
  var _this = this;
62360
62358
 
62361
- return __generator(this, function (_b) {
62362
- switch (_b.label) {
62359
+ return __generator(this, function (_a) {
62360
+ switch (_a.label) {
62363
62361
  case 0:
62364
62362
  if (!this.isOAuthInProgress()) return [3
62365
62363
  /*break*/
@@ -62389,9 +62387,9 @@ function () {
62389
62387
  })];
62390
62388
 
62391
62389
  case 1:
62392
- _b.sent();
62390
+ _a.sent();
62393
62391
 
62394
- _b.label = 2;
62392
+ _a.label = 2;
62395
62393
 
62396
62394
  case 2:
62397
62395
  user = this.userPool.getCurrentUser();
@@ -62404,135 +62402,167 @@ function () {
62404
62402
  ];
62405
62403
  }
62406
62404
 
62407
- _b.label = 3;
62405
+ clientMetadata = this._config.clientMetadata; // refresh the session if the session expired.
62408
62406
 
62409
- case 3:
62410
- _b.trys.push([3, 7,, 8]);
62407
+ user.getSession(function (err, session) {
62408
+ return __awaiter(_this, void 0, void 0, function () {
62409
+ var cleanUpError_5, bypassCache, clientMetadata, _a, scope;
62411
62410
 
62412
- return [4
62413
- /*yield*/
62414
- , this._userSession({
62415
- user: user
62416
- })];
62411
+ var _this = this;
62417
62412
 
62418
- case 4:
62419
- session = _b.sent();
62420
- bypassCache = params ? params.bypassCache : false;
62421
- if (!bypassCache) return [3
62422
- /*break*/
62423
- , 6];
62424
- return [4
62425
- /*yield*/
62426
- , this.Credentials.clear()];
62413
+ return __generator(this, function (_b) {
62414
+ switch (_b.label) {
62415
+ case 0:
62416
+ if (!err) return [3
62417
+ /*break*/
62418
+ , 5];
62419
+ logger.debug('Failed to get the user session', err);
62420
+ if (!this.isSessionInvalid(err)) return [3
62421
+ /*break*/
62422
+ , 4];
62423
+ _b.label = 1;
62427
62424
 
62428
- case 5:
62429
- _b.sent();
62425
+ case 1:
62426
+ _b.trys.push([1, 3,, 4]);
62430
62427
 
62431
- _b.label = 6;
62428
+ return [4
62429
+ /*yield*/
62430
+ , this.cleanUpInvalidSession(user)];
62432
62431
 
62433
- case 6:
62434
- clientMetadata = this._config.clientMetadata;
62435
- _a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
62432
+ case 2:
62433
+ _b.sent();
62436
62434
 
62437
- if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
62438
- user.getUserData(function (err, data) {
62439
- return __awaiter(_this, void 0, void 0, function () {
62440
- var cleanUpError_5, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
62441
- return __generator(this, function (_a) {
62442
- switch (_a.label) {
62443
- case 0:
62444
- if (!err) return [3
62445
- /*break*/
62446
- , 7];
62447
- logger.debug('getting user data failed', err);
62448
- if (!this.isSessionInvalid(err)) return [3
62449
- /*break*/
62450
- , 5];
62451
- _a.label = 1;
62435
+ return [3
62436
+ /*break*/
62437
+ , 4];
62452
62438
 
62453
- case 1:
62454
- _a.trys.push([1, 3,, 4]);
62439
+ case 3:
62440
+ cleanUpError_5 = _b.sent();
62441
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_5.message));
62442
+ return [2
62443
+ /*return*/
62444
+ ];
62455
62445
 
62456
- return [4
62457
- /*yield*/
62458
- , this.cleanUpInvalidSession(user)];
62446
+ case 4:
62447
+ rej(err);
62448
+ return [2
62449
+ /*return*/
62450
+ ];
62459
62451
 
62460
- case 2:
62461
- _a.sent();
62452
+ case 5:
62453
+ bypassCache = params ? params.bypassCache : false;
62454
+ if (!bypassCache) return [3
62455
+ /*break*/
62456
+ , 7];
62457
+ return [4
62458
+ /*yield*/
62459
+ , this.Credentials.clear()];
62462
62460
 
62463
- return [3
62464
- /*break*/
62465
- , 4];
62461
+ case 6:
62462
+ _b.sent();
62466
62463
 
62467
- case 3:
62468
- cleanUpError_5 = _a.sent();
62469
- rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_5.message));
62470
- return [2
62471
- /*return*/
62472
- ];
62464
+ _b.label = 7;
62473
62465
 
62474
- case 4:
62475
- rej(err);
62476
- return [3
62477
- /*break*/
62478
- , 6];
62466
+ case 7:
62467
+ clientMetadata = this._config.clientMetadata;
62468
+ _a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
62479
62469
 
62480
- case 5:
62481
- res(user);
62482
- _a.label = 6;
62470
+ if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
62471
+ user.getUserData(function (err, data) {
62472
+ return __awaiter(_this, void 0, void 0, function () {
62473
+ var cleanUpError_6, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
62474
+ return __generator(this, function (_a) {
62475
+ switch (_a.label) {
62476
+ case 0:
62477
+ if (!err) return [3
62478
+ /*break*/
62479
+ , 7];
62480
+ logger.debug('getting user data failed', err);
62481
+ if (!this.isSessionInvalid(err)) return [3
62482
+ /*break*/
62483
+ , 5];
62484
+ _a.label = 1;
62483
62485
 
62484
- case 6:
62485
- return [2
62486
- /*return*/
62487
- ];
62486
+ case 1:
62487
+ _a.trys.push([1, 3,, 4]);
62488
62488
 
62489
- case 7:
62490
- preferredMFA = data.PreferredMfaSetting || 'NOMFA';
62491
- attributeList = [];
62492
-
62493
- for (i = 0; i < data.UserAttributes.length; i++) {
62494
- attribute = {
62495
- Name: data.UserAttributes[i].Name,
62496
- Value: data.UserAttributes[i].Value
62497
- };
62498
- userAttribute = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUserAttribute"](attribute);
62499
- attributeList.push(userAttribute);
62500
- }
62489
+ return [4
62490
+ /*yield*/
62491
+ , this.cleanUpInvalidSession(user)];
62492
+
62493
+ case 2:
62494
+ _a.sent();
62495
+
62496
+ return [3
62497
+ /*break*/
62498
+ , 4];
62499
+
62500
+ case 3:
62501
+ cleanUpError_6 = _a.sent();
62502
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_6.message));
62503
+ return [2
62504
+ /*return*/
62505
+ ];
62506
+
62507
+ case 4:
62508
+ rej(err);
62509
+ return [3
62510
+ /*break*/
62511
+ , 6];
62512
+
62513
+ case 5:
62514
+ res(user);
62515
+ _a.label = 6;
62501
62516
 
62502
- attributes = this.attributesToObject(attributeList);
62503
- Object.assign(user, {
62504
- attributes: attributes,
62505
- preferredMFA: preferredMFA
62517
+ case 6:
62518
+ return [2
62519
+ /*return*/
62520
+ ];
62521
+
62522
+ case 7:
62523
+ preferredMFA = data.PreferredMfaSetting || 'NOMFA';
62524
+ attributeList = [];
62525
+
62526
+ for (i = 0; i < data.UserAttributes.length; i++) {
62527
+ attribute = {
62528
+ Name: data.UserAttributes[i].Name,
62529
+ Value: data.UserAttributes[i].Value
62530
+ };
62531
+ userAttribute = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["CognitoUserAttribute"](attribute);
62532
+ attributeList.push(userAttribute);
62533
+ }
62534
+
62535
+ attributes = this.attributesToObject(attributeList);
62536
+ Object.assign(user, {
62537
+ attributes: attributes,
62538
+ preferredMFA: preferredMFA
62539
+ });
62540
+ return [2
62541
+ /*return*/
62542
+ , res(user)];
62543
+ }
62544
+ });
62545
+ });
62546
+ }, {
62547
+ bypassCache: bypassCache,
62548
+ clientMetadata: clientMetadata
62506
62549
  });
62550
+ } else {
62551
+ logger.debug("Unable to get the user data because the " + USER_ADMIN_SCOPE + " " + "is not in the scopes of the access token");
62507
62552
  return [2
62508
62553
  /*return*/
62509
62554
  , res(user)];
62510
- }
62511
- });
62555
+ }
62556
+
62557
+ return [2
62558
+ /*return*/
62559
+ ];
62560
+ }
62512
62561
  });
62513
- }, {
62514
- bypassCache: bypassCache,
62515
- clientMetadata: clientMetadata
62516
62562
  });
62517
- } else {
62518
- logger.debug("Unable to get the user data because the " + USER_ADMIN_SCOPE + " " + "is not in the scopes of the access token");
62519
- return [2
62520
- /*return*/
62521
- , res(user)];
62522
- }
62523
-
62524
- return [3
62525
- /*break*/
62526
- , 8];
62527
-
62528
- case 7:
62529
- err_1 = _b.sent();
62530
- rej(err_1);
62531
- return [3
62532
- /*break*/
62533
- , 8];
62534
-
62535
- case 8:
62563
+ }, {
62564
+ clientMetadata: clientMetadata
62565
+ });
62536
62566
  return [2
62537
62567
  /*return*/
62538
62568
  ];
@@ -62677,13 +62707,15 @@ function () {
62677
62707
  });
62678
62708
  });
62679
62709
  };
62710
+ /**
62711
+ * Get the corresponding user session
62712
+ * @param {Object} user - The CognitoUser object
62713
+ * @return - A promise resolves to the session
62714
+ */
62680
62715
 
62681
- AuthClass.prototype._userSession = function (_a) {
62682
- var _this = this;
62683
62716
 
62684
- var user = _a.user,
62685
- _b = _a.bypassCache,
62686
- bypassCache = _b === void 0 ? false : _b;
62717
+ AuthClass.prototype.userSession = function (user) {
62718
+ var _this = this;
62687
62719
 
62688
62720
  if (!user) {
62689
62721
  logger.debug('the user is null');
@@ -62692,138 +62724,64 @@ function () {
62692
62724
 
62693
62725
  var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
62694
62726
 
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];
62713
-
62714
- case 1:
62715
- _a.sent();
62716
-
62717
- logger.debug('Debouncer resolved');
62718
- return [3
62719
- /*break*/
62720
- , 3];
62721
-
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;
62734
-
62735
- case 3:
62736
- user.getSession(function (err, session) {
62737
- return __awaiter(_this, void 0, void 0, function () {
62738
- var cleanUpError_6;
62739
- return __generator(this, function (_a) {
62740
- switch (_a.label) {
62741
- case 0:
62742
- if (!err) return [3
62743
- /*break*/
62744
- , 5];
62745
- logger.debug('Failed to get the session from user', user);
62746
- if (!this.isSessionInvalid(err)) return [3
62747
- /*break*/
62748
- , 4];
62749
- _a.label = 1;
62750
-
62751
- case 1:
62752
- _a.trys.push([1, 3,, 4]);
62753
-
62754
- return [4
62755
- /*yield*/
62756
- , this.cleanUpInvalidSession(user)];
62757
-
62758
- case 2:
62759
- _a.sent();
62760
-
62761
- return [3
62762
- /*break*/
62763
- , 4];
62764
-
62765
- case 3:
62766
- cleanUpError_6 = _a.sent();
62767
- 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
- }
62727
+ return new Promise(function (res, rej) {
62728
+ logger.debug('Getting the session from this user:', user);
62729
+ user.getSession(function (err, session) {
62730
+ return __awaiter(_this, void 0, void 0, function () {
62731
+ var cleanUpError_7;
62732
+ return __generator(this, function (_a) {
62733
+ switch (_a.label) {
62734
+ case 0:
62735
+ if (!err) return [3
62736
+ /*break*/
62737
+ , 5];
62738
+ logger.debug('Failed to get the session from user', user);
62739
+ if (!this.isSessionInvalid(err)) return [3
62740
+ /*break*/
62741
+ , 4];
62742
+ _a.label = 1;
62772
62743
 
62773
- return [2
62774
- /*return*/
62775
- ];
62744
+ case 1:
62745
+ _a.trys.push([1, 3,, 4]);
62776
62746
 
62777
- case 4:
62778
- rej(err);
62747
+ return [4
62748
+ /*yield*/
62749
+ , this.cleanUpInvalidSession(user)];
62779
62750
 
62780
- if (debounceResolver) {
62781
- debounceResolver();
62782
- }
62751
+ case 2:
62752
+ _a.sent();
62783
62753
 
62784
- return [2
62785
- /*return*/
62786
- ];
62754
+ return [3
62755
+ /*break*/
62756
+ , 4];
62787
62757
 
62788
- case 5:
62789
- logger.debug('Succeed to get the user session', session);
62790
- resolve(session);
62758
+ case 3:
62759
+ cleanUpError_7 = _a.sent();
62760
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_7.message));
62761
+ return [2
62762
+ /*return*/
62763
+ ];
62791
62764
 
62792
- if (debounceResolver) {
62793
- debounceResolver();
62794
- }
62765
+ case 4:
62766
+ rej(err);
62767
+ return [2
62768
+ /*return*/
62769
+ ];
62795
62770
 
62796
- return [2
62797
- /*return*/
62798
- ];
62799
- }
62800
- });
62801
- });
62802
- }, {
62803
- clientMetadata: clientMetadata,
62804
- bypassCache: bypassCache
62805
- });
62806
- return [2
62807
- /*return*/
62808
- ];
62809
- }
62771
+ case 5:
62772
+ logger.debug('Succeed to get the user session', session);
62773
+ res(session);
62774
+ return [2
62775
+ /*return*/
62776
+ ];
62777
+ }
62778
+ });
62810
62779
  });
62780
+ }, {
62781
+ clientMetadata: clientMetadata
62811
62782
  });
62812
62783
  });
62813
62784
  };
62814
- /**
62815
- * Get the corresponding user session
62816
- * @param {Object} user - The CognitoUser object
62817
- * @return - A promise resolves to the session
62818
- */
62819
-
62820
-
62821
- AuthClass.prototype.userSession = function (user) {
62822
- return this._userSession({
62823
- user: user,
62824
- bypassCache: false
62825
- });
62826
- };
62827
62785
  /**
62828
62786
  * Get authenticated credentials of current user.
62829
62787
  * @return - A promise resolves to be current user's credentials
@@ -63012,7 +62970,7 @@ function () {
63012
62970
 
63013
62971
  user.getSession(function (err, result) {
63014
62972
  return __awaiter(_this, void 0, void 0, function () {
63015
- var cleanUpError_7;
62973
+ var cleanUpError_8;
63016
62974
 
63017
62975
  var _this = this;
63018
62976
 
@@ -63043,8 +63001,8 @@ function () {
63043
63001
  , 4];
63044
63002
 
63045
63003
  case 3:
63046
- cleanUpError_7 = _a.sent();
63047
- rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_7.message));
63004
+ cleanUpError_8 = _a.sent();
63005
+ rej(new Error("Session is invalid due to: " + err.message + " and failed to clean up invalid session: " + cleanUpError_8.message));
63048
63006
  return [2
63049
63007
  /*return*/
63050
63008
  ];
@@ -63096,7 +63054,7 @@ function () {
63096
63054
  };
63097
63055
 
63098
63056
  AuthClass.prototype.oAuthSignOutRedirect = function (resolve, reject) {
63099
- var isBrowser = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["JS"].browserOrNode().isBrowser;
63057
+ var isBrowser = Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["browserOrNode"])().isBrowser;
63100
63058
 
63101
63059
  if (isBrowser) {
63102
63060
  this.oAuthSignOutRedirectOrReject(reject);
@@ -63348,7 +63306,7 @@ function () {
63348
63306
 
63349
63307
  AuthClass.prototype.currentUserInfo = function () {
63350
63308
  return __awaiter(this, void 0, void 0, function () {
63351
- var source, user, attributes, userAttrs, credentials, e_12, info, err_2, user;
63309
+ var source, user, attributes, userAttrs, credentials, e_12, info, err_1, user;
63352
63310
  return __generator(this, function (_a) {
63353
63311
  switch (_a.label) {
63354
63312
  case 0:
@@ -63417,8 +63375,8 @@ function () {
63417
63375
  , info];
63418
63376
 
63419
63377
  case 8:
63420
- err_2 = _a.sent();
63421
- logger.error('currentUserInfo error', err_2);
63378
+ err_1 = _a.sent();
63379
+ logger.error('currentUserInfo error', err_1);
63422
63380
  return [2
63423
63381
  /*return*/
63424
63382
  , {}];
@@ -63528,7 +63486,7 @@ function () {
63528
63486
 
63529
63487
  AuthClass.prototype._handleAuthResponse = function (URL) {
63530
63488
  return __awaiter(this, void 0, void 0, function () {
63531
- var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState, err_3;
63489
+ var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState, err_2;
63532
63490
 
63533
63491
  return __generator(this, function (_b) {
63534
63492
  switch (_b.label) {
@@ -63554,7 +63512,7 @@ function () {
63554
63512
  dispatchAuthEvent('parsingCallbackUrl', {
63555
63513
  url: URL
63556
63514
  }, "The callback url is being parsed");
63557
- currentUrl = URL || (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["JS"].browserOrNode().isBrowser ? window.location.href : '');
63515
+ currentUrl = URL || (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["browserOrNode"])().isBrowser ? window.location.href : '');
63558
63516
  hasCodeOrError = !!(Object(url__WEBPACK_IMPORTED_MODULE_3__["parse"])(currentUrl).query || '').split('&').map(function (entry) {
63559
63517
  return entry.split('=');
63560
63518
  }).find(function (_a) {
@@ -63636,17 +63594,17 @@ function () {
63636
63594
  , credentials];
63637
63595
 
63638
63596
  case 6:
63639
- err_3 = _b.sent();
63640
- logger.debug('Error in cognito hosted auth response', err_3); // Just like a successful handling of `?code`, replace the window history to "dispose" of the `code`.
63597
+ err_2 = _b.sent();
63598
+ logger.debug('Error in cognito hosted auth response', err_2); // Just like a successful handling of `?code`, replace the window history to "dispose" of the `code`.
63641
63599
  // Otherwise, reloading the page will throw errors as the `code` has already been spent.
63642
63600
 
63643
63601
  if (window && typeof window.history !== 'undefined') {
63644
63602
  window.history.replaceState({}, null, this._config.oauth.redirectSignIn);
63645
63603
  }
63646
63604
 
63647
- dispatchAuthEvent('signIn_failure', err_3, "The OAuth response flow failed");
63648
- dispatchAuthEvent('cognitoHostedUI_failure', err_3, "A failure occurred when returning to the Cognito Hosted UI");
63649
- dispatchAuthEvent('customState_failure', err_3, "A failure occurred when returning state");
63605
+ dispatchAuthEvent('signIn_failure', err_2, "The OAuth response flow failed");
63606
+ dispatchAuthEvent('cognitoHostedUI_failure', err_2, "A failure occurred when returning to the Cognito Hosted UI");
63607
+ dispatchAuthEvent('customState_failure', err_2, "A failure occurred when returning state");
63650
63608
  return [3
63651
63609
  /*break*/
63652
63610
  , 7];
@@ -65007,12 +64965,12 @@ __webpack_require__.r(__webpack_exports__);
65007
64965
  */
65008
64966
 
65009
64967
  /* harmony default export */ __webpack_exports__["default"] = (function (callback) {
65010
- if (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["JS"].browserOrNode().isBrowser && window.location) {
64968
+ if (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["browserOrNode"])().isBrowser && window.location) {
65011
64969
  var url = window.location.href;
65012
64970
  callback({
65013
64971
  url: url
65014
64972
  });
65015
- } else if (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["JS"].browserOrNode().isNode) {
64973
+ } else if (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["browserOrNode"])().isNode) {
65016
64974
  // continue building on ssr
65017
64975
  (function () {}); // noop
65018
64976
 
@@ -94306,6 +94264,32 @@ function () {
94306
94264
  _a = subscriptionError.error, _b = __read((_a === void 0 ? {
94307
94265
  errors: []
94308
94266
  } : _a).errors, 1), _c = _b[0], _d = (_c === void 0 ? {} : _c).message, message = _d === void 0 ? '' : _d;
94267
+
94268
+ 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)) {
94269
+ // Unsubscribe and clear subscription array for model/operation
94270
+ subscriptions[modelDefinition.name][transformerMutationType].forEach(function (subscription) {
94271
+ return subscription.unsubscribe();
94272
+ });
94273
+ subscriptions[modelDefinition.name][transformerMutationType] = [];
94274
+ operationAuthModeAttempts[operation]++;
94275
+
94276
+ if (operationAuthModeAttempts[operation] >= readAuthModes.length) {
94277
+ // last auth mode retry. Continue with error
94278
+ logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1]);
94279
+ } else {
94280
+ // retry with different auth mode. Do not trigger
94281
+ // observer error or error handler
94282
+ logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1] + ". Retrying with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
94283
+
94284
+ _authModeRetry(operation);
94285
+
94286
+ return [2
94287
+ /*return*/
94288
+ ];
94289
+ }
94290
+ }
94291
+
94292
+ logger.warn('subscriptionError', message);
94309
94293
  _e.label = 1;
94310
94294
 
94311
94295
  case 1:
@@ -94334,39 +94318,12 @@ function () {
94334
94318
 
94335
94319
  case 3:
94336
94320
  e_1 = _e.sent();
94337
- logger.error('Sync error handler failed with:', e_1);
94321
+ logger.error('Subscription error handler failed with:', e_1);
94338
94322
  return [3
94339
94323
  /*break*/
94340
94324
  , 4];
94341
94325
 
94342
94326
  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
94327
  if (typeof subscriptionReadyCallback === 'function') {
94371
94328
  subscriptionReadyCallback();
94372
94329
  }