@aws-amplify/api-graphql 2.2.23-cloud-logging.7 → 2.2.23-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.
@@ -10801,6 +10801,9 @@ var __spread = undefined && undefined.__spread || function () {
10801
10801
 
10802
10802
 
10803
10803
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('AWSAppSyncProvider');
10804
+ /**
10805
+ * @deprecated Unused, all usecases have migrated to AWSAppSyncRealtimeProvider
10806
+ */
10804
10807
 
10805
10808
  var AWSAppSyncProvider =
10806
10809
  /** @class */
@@ -11524,9 +11527,9 @@ function (_super) {
11524
11527
  AWSAppSyncRealTimeProvider.prototype.subscribe = function (_topics, options) {
11525
11528
  var _this = this;
11526
11529
 
11527
- var appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint;
11530
+ var appSyncGraphqlEndpoint = options === null || options === void 0 ? void 0 : options.appSyncGraphqlEndpoint;
11528
11531
  return new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (observer) {
11529
- if (!appSyncGraphqlEndpoint) {
11532
+ if (!options || !appSyncGraphqlEndpoint) {
11530
11533
  observer.error({
11531
11534
  errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscribe only available for AWS AppSync endpoint"))]
11532
11535
  });
@@ -11619,19 +11622,22 @@ function (_super) {
11619
11622
  var options = _a.options,
11620
11623
  observer = _a.observer,
11621
11624
  subscriptionId = _a.subscriptionId;
11625
+
11626
+ var _b, _c;
11627
+
11622
11628
  return __awaiter(this, void 0, void 0, function () {
11623
- var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _b, graphql_headers, _c, additionalHeaders, subscriptionState, data, dataString, headerObj, _d, _e, subscriptionMessage, stringToAWSRealTime, err_2, _f, message, subscriptionFailedCallback_1, _g, subscriptionFailedCallback, subscriptionReadyCallback;
11629
+ var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _d, graphql_headers, _e, additionalHeaders, subscriptionState, data, dataString, headerObj, _f, _g, subscriptionMessage, stringToAWSRealTime, err_2, message, subscriptionFailedCallback_1, _h, subscriptionFailedCallback, subscriptionReadyCallback;
11624
11630
 
11625
- var _h;
11631
+ var _j;
11626
11632
 
11627
11633
  var _this = this;
11628
11634
 
11629
- return __generator(this, function (_j) {
11630
- switch (_j.label) {
11635
+ return __generator(this, function (_k) {
11636
+ switch (_k.label) {
11631
11637
  case 0:
11632
- appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region, _b = options.graphql_headers, graphql_headers = _b === void 0 ? function () {
11638
+ appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region, _d = options.graphql_headers, graphql_headers = _d === void 0 ? function () {
11633
11639
  return {};
11634
- } : _b, _c = options.additionalHeaders, additionalHeaders = _c === void 0 ? {} : _c;
11640
+ } : _d, _e = options.additionalHeaders, additionalHeaders = _e === void 0 ? {} : _e;
11635
11641
  subscriptionState = SUBSCRIPTION_STATUS.PENDING;
11636
11642
  data = {
11637
11643
  query: query,
@@ -11640,13 +11646,13 @@ function (_super) {
11640
11646
 
11641
11647
  this.subscriptionObserverMap.set(subscriptionId, {
11642
11648
  observer: observer,
11643
- query: query,
11644
- variables: variables,
11649
+ query: query !== null && query !== void 0 ? query : '',
11650
+ variables: variables !== null && variables !== void 0 ? variables : {},
11645
11651
  subscriptionState: subscriptionState,
11646
- startAckTimeoutId: null
11652
+ startAckTimeoutId: undefined
11647
11653
  });
11648
11654
  dataString = JSON.stringify(data);
11649
- _d = [{}];
11655
+ _f = [{}];
11650
11656
  return [4
11651
11657
  /*yield*/
11652
11658
  , this._awsRealTimeHeaderBasedAuth({
@@ -11660,13 +11666,13 @@ function (_super) {
11660
11666
  })];
11661
11667
 
11662
11668
  case 1:
11663
- _e = [__assign.apply(void 0, _d.concat([_j.sent()]))];
11669
+ _g = [__assign.apply(void 0, _f.concat([_k.sent()]))];
11664
11670
  return [4
11665
11671
  /*yield*/
11666
11672
  , graphql_headers()];
11667
11673
 
11668
11674
  case 2:
11669
- headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _e.concat([_j.sent()])), additionalHeaders]), (_h = {}, _h[_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["USER_AGENT_HEADER"]] = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Constants"].userAgent, _h)]);
11675
+ headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _g.concat([_k.sent()])), additionalHeaders]), (_j = {}, _j[_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["USER_AGENT_HEADER"]] = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Constants"].userAgent, _j)]);
11670
11676
  subscriptionMessage = {
11671
11677
  id: subscriptionId,
11672
11678
  payload: {
@@ -11678,10 +11684,10 @@ function (_super) {
11678
11684
  type: MESSAGE_TYPES.GQL_START
11679
11685
  };
11680
11686
  stringToAWSRealTime = JSON.stringify(subscriptionMessage);
11681
- _j.label = 3;
11687
+ _k.label = 3;
11682
11688
 
11683
11689
  case 3:
11684
- _j.trys.push([3, 5,, 6]);
11690
+ _k.trys.push([3, 5,, 6]);
11685
11691
 
11686
11692
  return [4
11687
11693
  /*yield*/
@@ -11694,18 +11700,18 @@ function (_super) {
11694
11700
  })];
11695
11701
 
11696
11702
  case 4:
11697
- _j.sent();
11703
+ _k.sent();
11698
11704
 
11699
11705
  return [3
11700
11706
  /*break*/
11701
11707
  , 6];
11702
11708
 
11703
11709
  case 5:
11704
- err_2 = _j.sent();
11710
+ err_2 = _k.sent();
11705
11711
  logger.debug({
11706
11712
  err: err_2
11707
11713
  });
11708
- _f = err_2.message, message = _f === void 0 ? '' : _f;
11714
+ message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
11709
11715
  observer.error({
11710
11716
  errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
11711
11717
  });
@@ -11721,13 +11727,13 @@ function (_super) {
11721
11727
  ];
11722
11728
 
11723
11729
  case 6:
11724
- _g = this.subscriptionObserverMap.get(subscriptionId), subscriptionFailedCallback = _g.subscriptionFailedCallback, subscriptionReadyCallback = _g.subscriptionReadyCallback; // This must be done before sending the message in order to be listening immediately
11730
+ _h = (_c = this.subscriptionObserverMap.get(subscriptionId)) !== null && _c !== void 0 ? _c : {}, subscriptionFailedCallback = _h.subscriptionFailedCallback, subscriptionReadyCallback = _h.subscriptionReadyCallback; // This must be done before sending the message in order to be listening immediately
11725
11731
 
11726
11732
  this.subscriptionObserverMap.set(subscriptionId, {
11727
11733
  observer: observer,
11728
11734
  subscriptionState: subscriptionState,
11729
- variables: variables,
11730
- query: query,
11735
+ query: query !== null && query !== void 0 ? query : '',
11736
+ variables: variables !== null && variables !== void 0 ? variables : {},
11731
11737
  subscriptionReadyCallback: subscriptionReadyCallback,
11732
11738
  subscriptionFailedCallback: subscriptionFailedCallback,
11733
11739
  startAckTimeoutId: setTimeout(function () {
@@ -11750,32 +11756,35 @@ function (_super) {
11750
11756
 
11751
11757
  AWSAppSyncRealTimeProvider.prototype._waitForSubscriptionToBeConnected = function (subscriptionId) {
11752
11758
  return __awaiter(this, void 0, void 0, function () {
11753
- var subscriptionState;
11759
+ var subscriptionObserver, subscriptionState;
11754
11760
 
11755
11761
  var _this = this;
11756
11762
 
11757
11763
  return __generator(this, function (_a) {
11758
- subscriptionState = this.subscriptionObserverMap.get(subscriptionId).subscriptionState; // This in case unsubscribe is invoked before sending start subscription message
11764
+ subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
11759
11765
 
11760
- if (subscriptionState === SUBSCRIPTION_STATUS.PENDING) {
11761
- return [2
11762
- /*return*/
11763
- , new Promise(function (res, rej) {
11764
- var _a = _this.subscriptionObserverMap.get(subscriptionId),
11765
- observer = _a.observer,
11766
- subscriptionState = _a.subscriptionState,
11767
- variables = _a.variables,
11768
- query = _a.query;
11769
-
11770
- _this.subscriptionObserverMap.set(subscriptionId, {
11771
- observer: observer,
11772
- subscriptionState: subscriptionState,
11773
- variables: variables,
11774
- query: query,
11775
- subscriptionReadyCallback: res,
11776
- subscriptionFailedCallback: rej
11777
- });
11778
- })];
11766
+ if (subscriptionObserver) {
11767
+ subscriptionState = subscriptionObserver.subscriptionState; // This in case unsubscribe is invoked before sending start subscription message
11768
+
11769
+ if (subscriptionState === SUBSCRIPTION_STATUS.PENDING) {
11770
+ return [2
11771
+ /*return*/
11772
+ , new Promise(function (res, rej) {
11773
+ var observer = subscriptionObserver.observer,
11774
+ subscriptionState = subscriptionObserver.subscriptionState,
11775
+ variables = subscriptionObserver.variables,
11776
+ query = subscriptionObserver.query;
11777
+
11778
+ _this.subscriptionObserverMap.set(subscriptionId, {
11779
+ observer: observer,
11780
+ subscriptionState: subscriptionState,
11781
+ variables: variables,
11782
+ query: query,
11783
+ subscriptionReadyCallback: res,
11784
+ subscriptionFailedCallback: rej
11785
+ });
11786
+ })];
11787
+ }
11779
11788
  }
11780
11789
 
11781
11790
  return [2
@@ -11826,13 +11835,13 @@ function (_super) {
11826
11835
  setTimeout(this._closeSocketIfRequired.bind(this), 1000);
11827
11836
  } else {
11828
11837
  logger.debug('closing WebSocket...');
11829
- clearTimeout(this.keepAliveTimeoutId);
11838
+ if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
11830
11839
  var tempSocket = this.awsRealTimeSocket; // Cleaning callbacks to avoid race condition, socket still exists
11831
11840
 
11832
- tempSocket.onclose = undefined;
11833
- tempSocket.onerror = undefined;
11841
+ tempSocket.onclose = null;
11842
+ tempSocket.onerror = null;
11834
11843
  tempSocket.close(1000);
11835
- this.awsRealTimeSocket = null;
11844
+ this.awsRealTimeSocket = undefined;
11836
11845
  this.socketStatus = SOCKET_STATUS.CLOSED;
11837
11846
  }
11838
11847
  };
@@ -11897,50 +11906,57 @@ function (_super) {
11897
11906
  subscriptionReadyCallback();
11898
11907
  }
11899
11908
 
11900
- clearTimeout(startAckTimeoutId);
11909
+ if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
11901
11910
  dispatchApiEvent(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].SUBSCRIPTION_ACK, {
11902
11911
  query: query,
11903
11912
  variables: variables
11904
11913
  }, 'Connection established for subscription');
11905
11914
  var subscriptionState = SUBSCRIPTION_STATUS.CONNECTED;
11906
- this.subscriptionObserverMap.set(id, {
11907
- observer: observer,
11908
- query: query,
11909
- variables: variables,
11910
- startAckTimeoutId: null,
11911
- subscriptionState: subscriptionState,
11912
- subscriptionReadyCallback: subscriptionReadyCallback,
11913
- subscriptionFailedCallback: subscriptionFailedCallback
11914
- }); // TODO: emit event on hub but it requires to store the id first
11915
+
11916
+ if (observer) {
11917
+ this.subscriptionObserverMap.set(id, {
11918
+ observer: observer,
11919
+ query: query,
11920
+ variables: variables,
11921
+ startAckTimeoutId: undefined,
11922
+ subscriptionState: subscriptionState,
11923
+ subscriptionReadyCallback: subscriptionReadyCallback,
11924
+ subscriptionFailedCallback: subscriptionFailedCallback
11925
+ });
11926
+ } // TODO: emit event on hub but it requires to store the id first
11927
+
11915
11928
 
11916
11929
  return;
11917
11930
  }
11918
11931
 
11919
11932
  if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {
11920
- clearTimeout(this.keepAliveTimeoutId);
11933
+ if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
11921
11934
  this.keepAliveTimeoutId = setTimeout(this._errorDisconnect.bind(this, _index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT), this.keepAliveTimeout);
11922
11935
  return;
11923
11936
  }
11924
11937
 
11925
11938
  if (type === MESSAGE_TYPES.GQL_ERROR) {
11926
11939
  var subscriptionState = SUBSCRIPTION_STATUS.FAILED;
11927
- this.subscriptionObserverMap.set(id, {
11928
- observer: observer,
11929
- query: query,
11930
- variables: variables,
11931
- startAckTimeoutId: startAckTimeoutId,
11932
- subscriptionReadyCallback: subscriptionReadyCallback,
11933
- subscriptionFailedCallback: subscriptionFailedCallback,
11934
- subscriptionState: subscriptionState
11935
- });
11936
- observer.error({
11937
- errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
11938
- });
11939
- clearTimeout(startAckTimeoutId);
11940
- observer.complete();
11941
11940
 
11942
- if (typeof subscriptionFailedCallback === 'function') {
11943
- subscriptionFailedCallback();
11941
+ if (observer) {
11942
+ this.subscriptionObserverMap.set(id, {
11943
+ observer: observer,
11944
+ query: query,
11945
+ variables: variables,
11946
+ startAckTimeoutId: startAckTimeoutId,
11947
+ subscriptionReadyCallback: subscriptionReadyCallback,
11948
+ subscriptionFailedCallback: subscriptionFailedCallback,
11949
+ subscriptionState: subscriptionState
11950
+ });
11951
+ observer.error({
11952
+ errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
11953
+ });
11954
+ if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
11955
+ observer.complete();
11956
+
11957
+ if (typeof subscriptionFailedCallback === 'function') {
11958
+ subscriptionFailedCallback();
11959
+ }
11944
11960
  }
11945
11961
  }
11946
11962
  };
@@ -11966,37 +11982,40 @@ function (_super) {
11966
11982
  };
11967
11983
 
11968
11984
  AWSAppSyncRealTimeProvider.prototype._timeoutStartSubscriptionAck = function (subscriptionId) {
11969
- var _a = this.subscriptionObserverMap.get(subscriptionId) || {},
11970
- observer = _a.observer,
11971
- query = _a.query,
11972
- variables = _a.variables;
11985
+ var subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
11973
11986
 
11974
- if (!observer) {
11975
- return;
11976
- }
11987
+ if (subscriptionObserver) {
11988
+ var observer = subscriptionObserver.observer,
11989
+ query = subscriptionObserver.query,
11990
+ variables = subscriptionObserver.variables;
11977
11991
 
11978
- this.subscriptionObserverMap.set(subscriptionId, {
11979
- observer: observer,
11980
- query: query,
11981
- variables: variables,
11982
- subscriptionState: SUBSCRIPTION_STATUS.FAILED
11983
- });
11992
+ if (!observer) {
11993
+ return;
11994
+ }
11984
11995
 
11985
- if (observer && !observer.closed) {
11986
- observer.error({
11987
- errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
11988
- query: query,
11989
- variables: variables
11990
- })))]
11991
- }); // Cleanup will be automatically executed
11996
+ this.subscriptionObserverMap.set(subscriptionId, {
11997
+ observer: observer,
11998
+ query: query,
11999
+ variables: variables,
12000
+ subscriptionState: SUBSCRIPTION_STATUS.FAILED
12001
+ });
11992
12002
 
11993
- observer.complete();
11994
- }
12003
+ if (observer && !observer.closed) {
12004
+ observer.error({
12005
+ errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
12006
+ query: query,
12007
+ variables: variables
12008
+ })))]
12009
+ }); // Cleanup will be automatically executed
11995
12010
 
11996
- logger.debug('timeoutStartSubscription', JSON.stringify({
11997
- query: query,
11998
- variables: variables
11999
- }));
12011
+ observer.complete();
12012
+ }
12013
+
12014
+ logger.debug('timeoutStartSubscription', JSON.stringify({
12015
+ query: query,
12016
+ variables: variables
12017
+ }));
12018
+ }
12000
12019
  };
12001
12020
 
12002
12021
  AWSAppSyncRealTimeProvider.prototype._initializeWebSocketConnection = function (_a) {
@@ -12050,7 +12069,7 @@ function (_super) {
12050
12069
  headerString = _b.apply(_a, [_c.sent()]);
12051
12070
  headerQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(headerString).toString('base64');
12052
12071
  payloadQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(payloadString).toString('base64');
12053
- discoverableEndpoint = appSyncGraphqlEndpoint;
12072
+ discoverableEndpoint = appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '';
12054
12073
 
12055
12074
  if (this.isCustomDomain(discoverableEndpoint)) {
12056
12075
  discoverableEndpoint = discoverableEndpoint.concat(customDomainPath);
@@ -12063,9 +12082,7 @@ function (_super) {
12063
12082
  awsRealTimeUrl = discoverableEndpoint + "?header=" + headerQs + "&payload=" + payloadQs;
12064
12083
  return [4
12065
12084
  /*yield*/
12066
- , this._initializeRetryableHandshake({
12067
- awsRealTimeUrl: awsRealTimeUrl
12068
- })];
12085
+ , this._initializeRetryableHandshake(awsRealTimeUrl)];
12069
12086
 
12070
12087
  case 3:
12071
12088
  _c.sent();
@@ -12093,7 +12110,7 @@ function (_super) {
12093
12110
  this.awsRealTimeSocket.close(3001);
12094
12111
  }
12095
12112
 
12096
- this.awsRealTimeSocket = null;
12113
+ this.awsRealTimeSocket = undefined;
12097
12114
  this.socketStatus = SOCKET_STATUS.CLOSED;
12098
12115
  return [3
12099
12116
  /*break*/
@@ -12109,21 +12126,18 @@ function (_super) {
12109
12126
  });
12110
12127
  };
12111
12128
 
12112
- AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (_a) {
12113
- var awsRealTimeUrl = _a.awsRealTimeUrl;
12129
+ AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (awsRealTimeUrl) {
12114
12130
  return __awaiter(this, void 0, void 0, function () {
12115
- return __generator(this, function (_b) {
12116
- switch (_b.label) {
12131
+ return __generator(this, function (_a) {
12132
+ switch (_a.label) {
12117
12133
  case 0:
12118
12134
  logger.debug("Initializaling retryable Handshake");
12119
12135
  return [4
12120
12136
  /*yield*/
12121
- , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [{
12122
- awsRealTimeUrl: awsRealTimeUrl
12123
- }], MAX_DELAY_MS)];
12137
+ , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [awsRealTimeUrl], MAX_DELAY_MS)];
12124
12138
 
12125
12139
  case 1:
12126
- _b.sent();
12140
+ _a.sent();
12127
12141
 
12128
12142
  return [2
12129
12143
  /*return*/
@@ -12133,10 +12147,9 @@ function (_super) {
12133
12147
  });
12134
12148
  };
12135
12149
 
12136
- AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (_a) {
12137
- var awsRealTimeUrl = _a.awsRealTimeUrl;
12150
+ AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (awsRealTimeUrl) {
12138
12151
  return __awaiter(this, void 0, void 0, function () {
12139
- var err_4, errorType, errorCode;
12152
+ var err_4, _a, errorType, errorCode;
12140
12153
 
12141
12154
  var _this = this;
12142
12155
 
@@ -12178,77 +12191,82 @@ function (_super) {
12178
12191
  /*yield*/
12179
12192
  , function () {
12180
12193
  return new Promise(function (res, rej) {
12181
- var ackOk = false;
12194
+ if (_this.awsRealTimeSocket) {
12195
+ var ackOk_1 = false;
12182
12196
 
12183
- _this.awsRealTimeSocket.onerror = function (error) {
12184
- logger.debug("WebSocket error " + JSON.stringify(error));
12185
- };
12197
+ _this.awsRealTimeSocket.onerror = function (error) {
12198
+ logger.debug("WebSocket error " + JSON.stringify(error));
12199
+ };
12186
12200
 
12187
- _this.awsRealTimeSocket.onclose = function (event) {
12188
- logger.debug("WebSocket closed " + event.reason);
12189
- rej(new Error(JSON.stringify(event)));
12190
- };
12201
+ _this.awsRealTimeSocket.onclose = function (event) {
12202
+ logger.debug("WebSocket closed " + event.reason);
12203
+ rej(new Error(JSON.stringify(event)));
12204
+ };
12191
12205
 
12192
- _this.awsRealTimeSocket.onmessage = function (message) {
12193
- logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
12194
- var data = JSON.parse(message.data);
12195
- var type = data.type,
12196
- _a = data.payload,
12197
- _b = (_a === void 0 ? {} : _a).connectionTimeoutMs,
12198
- connectionTimeoutMs = _b === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _b;
12206
+ _this.awsRealTimeSocket.onmessage = function (message) {
12207
+ logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
12208
+ var data = JSON.parse(message.data);
12209
+ var type = data.type,
12210
+ _a = data.payload,
12211
+ _b = (_a === void 0 ? {} : _a).connectionTimeoutMs,
12212
+ connectionTimeoutMs = _b === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _b;
12199
12213
 
12200
- if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
12201
- ackOk = true;
12202
- _this.keepAliveTimeout = connectionTimeoutMs;
12203
- _this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
12214
+ if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
12215
+ ackOk_1 = true;
12204
12216
 
12205
- _this.awsRealTimeSocket.onerror = function (err) {
12206
- logger.debug(err);
12217
+ if (_this.awsRealTimeSocket) {
12218
+ _this.keepAliveTimeout = connectionTimeoutMs;
12219
+ _this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
12207
12220
 
12208
- _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
12209
- };
12221
+ _this.awsRealTimeSocket.onerror = function (err) {
12222
+ logger.debug(err);
12210
12223
 
12211
- _this.awsRealTimeSocket.onclose = function (event) {
12212
- logger.debug("WebSocket closed " + event.reason);
12224
+ _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
12225
+ };
12213
12226
 
12214
- _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
12215
- };
12227
+ _this.awsRealTimeSocket.onclose = function (event) {
12228
+ logger.debug("WebSocket closed " + event.reason);
12216
12229
 
12217
- res('Cool, connected to AWS AppSyncRealTime');
12218
- return;
12219
- }
12230
+ _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
12231
+ };
12232
+ }
12220
12233
 
12221
- if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
12222
- var _c = data.payload,
12223
- _d = (_c === void 0 ? {} : _c).errors,
12224
- _e = __read(_d === void 0 ? [] : _d, 1),
12225
- _f = _e[0],
12226
- _g = _f === void 0 ? {} : _f,
12227
- _h = _g.errorType,
12228
- errorType = _h === void 0 ? '' : _h,
12229
- _j = _g.errorCode,
12230
- errorCode = _j === void 0 ? 0 : _j;
12231
-
12232
- rej({
12233
- errorType: errorType,
12234
- errorCode: errorCode
12235
- });
12236
- }
12237
- };
12234
+ res('Cool, connected to AWS AppSyncRealTime');
12235
+ return;
12236
+ }
12238
12237
 
12239
- var gqlInit = {
12240
- type: MESSAGE_TYPES.GQL_CONNECTION_INIT
12241
- };
12238
+ if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
12239
+ var _c = data.payload,
12240
+ _d = (_c === void 0 ? {} : _c).errors,
12241
+ _e = __read(_d === void 0 ? [] : _d, 1),
12242
+ _f = _e[0],
12243
+ _g = _f === void 0 ? {} : _f,
12244
+ _h = _g.errorType,
12245
+ errorType = _h === void 0 ? '' : _h,
12246
+ _j = _g.errorCode,
12247
+ errorCode = _j === void 0 ? 0 : _j;
12248
+
12249
+ rej({
12250
+ errorType: errorType,
12251
+ errorCode: errorCode
12252
+ });
12253
+ }
12254
+ };
12255
+
12256
+ var gqlInit = {
12257
+ type: MESSAGE_TYPES.GQL_CONNECTION_INIT
12258
+ };
12242
12259
 
12243
- _this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
12260
+ _this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
12261
+
12262
+ setTimeout(checkAckOk.bind(_this, ackOk_1), CONNECTION_INIT_TIMEOUT);
12263
+ }
12244
12264
 
12245
- function checkAckOk() {
12265
+ function checkAckOk(ackOk) {
12246
12266
  if (!ackOk) {
12247
12267
  rej(new Error("Connection timeout: ack from AWSRealTime was not received on " + CONNECTION_INIT_TIMEOUT + " ms"));
12248
12268
  }
12249
12269
  }
12250
-
12251
- setTimeout(checkAckOk.bind(_this), CONNECTION_INIT_TIMEOUT);
12252
12270
  });
12253
12271
  }()];
12254
12272
 
@@ -12262,7 +12280,7 @@ function (_super) {
12262
12280
 
12263
12281
  case 4:
12264
12282
  err_4 = _b.sent();
12265
- errorType = err_4.errorType, errorCode = err_4.errorCode;
12283
+ _a = err_4, errorType = _a.errorType, errorCode = _a.errorCode;
12266
12284
 
12267
12285
  if (NON_RETRYABLE_CODES.includes(errorCode)) {
12268
12286
  throw new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["NonRetryableError"](errorType);
@@ -12305,16 +12323,17 @@ function (_super) {
12305
12323
  AMAZON_COGNITO_USER_POOLS: this._awsRealTimeCUPHeader.bind(this),
12306
12324
  AWS_LAMBDA: this._customAuthHeader
12307
12325
  };
12308
- handler = headerHandler[authenticationType];
12309
-
12310
- if (typeof handler !== 'function') {
12311
- logger.debug("Authentication type " + authenticationType + " not supported");
12312
- return [2
12313
- /*return*/
12314
- , ''];
12315
- }
12326
+ if (!(!authenticationType || !headerHandler[authenticationType])) return [3
12327
+ /*break*/
12328
+ , 1];
12329
+ logger.debug("Authentication type " + authenticationType + " not supported");
12330
+ return [2
12331
+ /*return*/
12332
+ , ''];
12316
12333
 
12317
- host = url__WEBPACK_IMPORTED_MODULE_2__["parse"](appSyncGraphqlEndpoint).host;
12334
+ case 1:
12335
+ handler = headerHandler[authenticationType];
12336
+ host = url__WEBPACK_IMPORTED_MODULE_2__["parse"](appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
12318
12337
  return [4
12319
12338
  /*yield*/
12320
12339
  , handler({
@@ -12327,7 +12346,7 @@ function (_super) {
12327
12346
  additionalHeaders: additionalHeaders
12328
12347
  })];
12329
12348
 
12330
- case 1:
12349
+ case 2:
12331
12350
  result = _b.sent();
12332
12351
  return [2
12333
12352
  /*return*/
@@ -12459,10 +12478,14 @@ function (_super) {
12459
12478
  return [4
12460
12479
  /*yield*/
12461
12480
  , _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Credentials"].get().then(function (credentials) {
12481
+ var _a = credentials,
12482
+ secretAccessKey = _a.secretAccessKey,
12483
+ accessKeyId = _a.accessKeyId,
12484
+ sessionToken = _a.sessionToken;
12462
12485
  return {
12463
- secret_key: credentials.secretAccessKey,
12464
- access_key: credentials.accessKeyId,
12465
- session_token: credentials.sessionToken
12486
+ secret_key: secretAccessKey,
12487
+ access_key: accessKeyId,
12488
+ session_token: sessionToken
12466
12489
  };
12467
12490
  })];
12468
12491
 
@@ -12487,7 +12510,7 @@ function (_super) {
12487
12510
  var host = _a.host,
12488
12511
  additionalHeaders = _a.additionalHeaders;
12489
12512
 
12490
- if (!additionalHeaders.Authorization) {
12513
+ if (!additionalHeaders || !additionalHeaders['Authorization']) {
12491
12514
  throw new Error('No auth token specified');
12492
12515
  }
12493
12516
 
@@ -12724,8 +12747,12 @@ var AWSIoTProvider =
12724
12747
  function (_super) {
12725
12748
  __extends(AWSIoTProvider, _super);
12726
12749
 
12727
- function AWSIoTProvider() {
12728
- return _super !== null && _super.apply(this, arguments) || this;
12750
+ function AWSIoTProvider(options) {
12751
+ if (options === void 0) {
12752
+ options = {};
12753
+ }
12754
+
12755
+ return _super.call(this, options) || this;
12729
12756
  }
12730
12757
 
12731
12758
  Object.defineProperty(AWSIoTProvider.prototype, "region", {
@@ -13055,21 +13082,27 @@ function () {
13055
13082
 
13056
13083
  ClientsQueue.prototype.get = function (clientId, clientFactory) {
13057
13084
  return __awaiter(this, void 0, void 0, function () {
13058
- var promise;
13085
+ var cachedPromise, newPromise;
13059
13086
  return __generator(this, function (_a) {
13060
- promise = this.promises.get(clientId);
13087
+ cachedPromise = this.promises.get(clientId);
13061
13088
 
13062
- if (promise) {
13089
+ if (cachedPromise) {
13063
13090
  return [2
13064
13091
  /*return*/
13065
- , promise];
13092
+ , cachedPromise];
13093
+ }
13094
+
13095
+ if (clientFactory) {
13096
+ newPromise = clientFactory(clientId);
13097
+ this.promises.set(clientId, newPromise);
13098
+ return [2
13099
+ /*return*/
13100
+ , newPromise];
13066
13101
  }
13067
13102
 
13068
- promise = clientFactory(clientId);
13069
- this.promises.set(clientId, promise);
13070
13103
  return [2
13071
13104
  /*return*/
13072
- , promise];
13105
+ , undefined];
13073
13106
  });
13074
13107
  });
13075
13108
  };
@@ -13161,6 +13194,10 @@ function (_super) {
13161
13194
  }, args), null, 2));
13162
13195
  var topicsToDelete_1 = [];
13163
13196
 
13197
+ if (!clientId) {
13198
+ return;
13199
+ }
13200
+
13164
13201
  var clientIdObservers = this._clientIdObservers.get(clientId);
13165
13202
 
13166
13203
  if (!clientIdObservers) {
@@ -13279,9 +13316,7 @@ function (_super) {
13279
13316
  case 0:
13280
13317
  return [4
13281
13318
  /*yield*/
13282
- , this.clientsQueue.get(clientId, function () {
13283
- return null;
13284
- })];
13319
+ , this.clientsQueue.get(clientId)];
13285
13320
 
13286
13321
  case 1:
13287
13322
  client = _a.sent();
@@ -13460,13 +13495,14 @@ function (_super) {
13460
13495
  })();
13461
13496
 
13462
13497
  return function () {
13498
+ var _a, _b;
13499
+
13463
13500
  logger.debug('Unsubscribing from topic(s)', targetTopics.join(','));
13464
13501
 
13465
13502
  if (client) {
13466
- _this._clientIdObservers.get(clientId)["delete"](observer); // No more observers per client => client not needed anymore
13467
-
13503
+ (_a = _this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
13468
13504
 
13469
- if (_this._clientIdObservers.get(clientId).size === 0) {
13505
+ if (((_b = _this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
13470
13506
  _this.disconnect(clientId);
13471
13507
 
13472
13508
  _this._clientIdObservers["delete"](clientId);
@@ -13801,7 +13837,7 @@ function () {
13801
13837
  * @param {PubSubOptions} options - Configuration object for PubSub
13802
13838
  */
13803
13839
  function PubSubClass(options) {
13804
- this._options = options;
13840
+ this._options = options !== null && options !== void 0 ? options : {};
13805
13841
  logger.debug('PubSub Options', this._options);
13806
13842
  this._pluggables = [];
13807
13843
  this.subscribe = this.subscribe.bind(this);
@@ -13990,7 +14026,7 @@ function () {
13990
14026
  }();
13991
14027
 
13992
14028
 
13993
- var PubSub = new PubSubClass(null);
14029
+ var PubSub = new PubSubClass();
13994
14030
  _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
13995
14031
 
13996
14032
  /***/ }),
@@ -14942,17 +14978,12 @@ __webpack_require__.r(__webpack_exports__);
14942
14978
 
14943
14979
  "use strict";
14944
14980
  __webpack_require__.r(__webpack_exports__);
14945
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return GRAPHQL_AUTH_MODE; });
14946
14981
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GraphQLAuthError", function() { return GraphQLAuthError; });
14947
- var GRAPHQL_AUTH_MODE;
14948
-
14949
- (function (GRAPHQL_AUTH_MODE) {
14950
- GRAPHQL_AUTH_MODE["API_KEY"] = "API_KEY";
14951
- GRAPHQL_AUTH_MODE["AWS_IAM"] = "AWS_IAM";
14952
- GRAPHQL_AUTH_MODE["OPENID_CONNECT"] = "OPENID_CONNECT";
14953
- GRAPHQL_AUTH_MODE["AMAZON_COGNITO_USER_POOLS"] = "AMAZON_COGNITO_USER_POOLS";
14954
- GRAPHQL_AUTH_MODE["AWS_LAMBDA"] = "AWS_LAMBDA";
14955
- })(GRAPHQL_AUTH_MODE || (GRAPHQL_AUTH_MODE = {}));
14982
+ /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
14983
+ /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__);
14984
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"]; });
14985
+
14986
+
14956
14987
 
14957
14988
  var GraphQLAuthError;
14958
14989