@aws-amplify/api-graphql 2.2.18 → 2.2.19-custom-pk.79

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.
@@ -125,12 +125,24 @@ var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "../../node
125
125
  var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "../../node_modules/axios/lib/helpers/parseHeaders.js");
126
126
  var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "../../node_modules/axios/lib/helpers/isURLSameOrigin.js");
127
127
  var createError = __webpack_require__(/*! ../core/createError */ "../../node_modules/axios/lib/core/createError.js");
128
+ var defaults = __webpack_require__(/*! ../defaults */ "../../node_modules/axios/lib/defaults.js");
129
+ var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "../../node_modules/axios/lib/cancel/Cancel.js");
128
130
 
129
131
  module.exports = function xhrAdapter(config) {
130
132
  return new Promise(function dispatchXhrRequest(resolve, reject) {
131
133
  var requestData = config.data;
132
134
  var requestHeaders = config.headers;
133
135
  var responseType = config.responseType;
136
+ var onCanceled;
137
+ function done() {
138
+ if (config.cancelToken) {
139
+ config.cancelToken.unsubscribe(onCanceled);
140
+ }
141
+
142
+ if (config.signal) {
143
+ config.signal.removeEventListener('abort', onCanceled);
144
+ }
145
+ }
134
146
 
135
147
  if (utils.isFormData(requestData)) {
136
148
  delete requestHeaders['Content-Type']; // Let the browser set it
@@ -168,7 +180,13 @@ module.exports = function xhrAdapter(config) {
168
180
  request: request
169
181
  };
170
182
 
171
- settle(resolve, reject, response);
183
+ settle(function _resolve(value) {
184
+ resolve(value);
185
+ done();
186
+ }, function _reject(err) {
187
+ reject(err);
188
+ done();
189
+ }, response);
172
190
 
173
191
  // Clean up request
174
192
  request = null;
@@ -221,14 +239,15 @@ module.exports = function xhrAdapter(config) {
221
239
 
222
240
  // Handle timeout
223
241
  request.ontimeout = function handleTimeout() {
224
- var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
242
+ var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
243
+ var transitional = config.transitional || defaults.transitional;
225
244
  if (config.timeoutErrorMessage) {
226
245
  timeoutErrorMessage = config.timeoutErrorMessage;
227
246
  }
228
247
  reject(createError(
229
248
  timeoutErrorMessage,
230
249
  config,
231
- config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
250
+ transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
232
251
  request));
233
252
 
234
253
  // Clean up request
@@ -282,18 +301,22 @@ module.exports = function xhrAdapter(config) {
282
301
  request.upload.addEventListener('progress', config.onUploadProgress);
283
302
  }
284
303
 
285
- if (config.cancelToken) {
304
+ if (config.cancelToken || config.signal) {
286
305
  // Handle cancellation
287
- config.cancelToken.promise.then(function onCanceled(cancel) {
306
+ // eslint-disable-next-line func-names
307
+ onCanceled = function(cancel) {
288
308
  if (!request) {
289
309
  return;
290
310
  }
291
-
311
+ reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
292
312
  request.abort();
293
- reject(cancel);
294
- // Clean up request
295
313
  request = null;
296
- });
314
+ };
315
+
316
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
317
+ if (config.signal) {
318
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
319
+ }
297
320
  }
298
321
 
299
322
  if (!requestData) {
@@ -340,6 +363,11 @@ function createInstance(defaultConfig) {
340
363
  // Copy context to instance
341
364
  utils.extend(instance, context);
342
365
 
366
+ // Factory for creating new instances
367
+ instance.create = function create(instanceConfig) {
368
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
369
+ };
370
+
343
371
  return instance;
344
372
  }
345
373
 
@@ -349,15 +377,11 @@ var axios = createInstance(defaults);
349
377
  // Expose Axios class to allow class inheritance
350
378
  axios.Axios = Axios;
351
379
 
352
- // Factory for creating new instances
353
- axios.create = function create(instanceConfig) {
354
- return createInstance(mergeConfig(axios.defaults, instanceConfig));
355
- };
356
-
357
380
  // Expose Cancel & CancelToken
358
381
  axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "../../node_modules/axios/lib/cancel/Cancel.js");
359
382
  axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "../../node_modules/axios/lib/cancel/CancelToken.js");
360
383
  axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "../../node_modules/axios/lib/cancel/isCancel.js");
384
+ axios.VERSION = __webpack_require__(/*! ./env/data */ "../../node_modules/axios/lib/env/data.js").version;
361
385
 
362
386
  // Expose all/spread
363
387
  axios.all = function all(promises) {
@@ -431,11 +455,42 @@ function CancelToken(executor) {
431
455
  }
432
456
 
433
457
  var resolvePromise;
458
+
434
459
  this.promise = new Promise(function promiseExecutor(resolve) {
435
460
  resolvePromise = resolve;
436
461
  });
437
462
 
438
463
  var token = this;
464
+
465
+ // eslint-disable-next-line func-names
466
+ this.promise.then(function(cancel) {
467
+ if (!token._listeners) return;
468
+
469
+ var i;
470
+ var l = token._listeners.length;
471
+
472
+ for (i = 0; i < l; i++) {
473
+ token._listeners[i](cancel);
474
+ }
475
+ token._listeners = null;
476
+ });
477
+
478
+ // eslint-disable-next-line func-names
479
+ this.promise.then = function(onfulfilled) {
480
+ var _resolve;
481
+ // eslint-disable-next-line func-names
482
+ var promise = new Promise(function(resolve) {
483
+ token.subscribe(resolve);
484
+ _resolve = resolve;
485
+ }).then(onfulfilled);
486
+
487
+ promise.cancel = function reject() {
488
+ token.unsubscribe(_resolve);
489
+ };
490
+
491
+ return promise;
492
+ };
493
+
439
494
  executor(function cancel(message) {
440
495
  if (token.reason) {
441
496
  // Cancellation has already been requested
@@ -456,6 +511,37 @@ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
456
511
  }
457
512
  };
458
513
 
514
+ /**
515
+ * Subscribe to the cancel signal
516
+ */
517
+
518
+ CancelToken.prototype.subscribe = function subscribe(listener) {
519
+ if (this.reason) {
520
+ listener(this.reason);
521
+ return;
522
+ }
523
+
524
+ if (this._listeners) {
525
+ this._listeners.push(listener);
526
+ } else {
527
+ this._listeners = [listener];
528
+ }
529
+ };
530
+
531
+ /**
532
+ * Unsubscribe from the cancel signal
533
+ */
534
+
535
+ CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
536
+ if (!this._listeners) {
537
+ return;
538
+ }
539
+ var index = this._listeners.indexOf(listener);
540
+ if (index !== -1) {
541
+ this._listeners.splice(index, 1);
542
+ }
543
+ };
544
+
459
545
  /**
460
546
  * Returns an object that contains a new `CancelToken` and a function that, when called,
461
547
  * cancels the `CancelToken`.
@@ -529,14 +615,14 @@ function Axios(instanceConfig) {
529
615
  *
530
616
  * @param {Object} config The config specific for this request (merged with this.defaults)
531
617
  */
532
- Axios.prototype.request = function request(config) {
618
+ Axios.prototype.request = function request(configOrUrl, config) {
533
619
  /*eslint no-param-reassign:0*/
534
620
  // Allow for axios('example/url'[, config]) a la fetch API
535
- if (typeof config === 'string') {
536
- config = arguments[1] || {};
537
- config.url = arguments[0];
538
- } else {
621
+ if (typeof configOrUrl === 'string') {
539
622
  config = config || {};
623
+ config.url = configOrUrl;
624
+ } else {
625
+ config = configOrUrl || {};
540
626
  }
541
627
 
542
628
  config = mergeConfig(this.defaults, config);
@@ -554,9 +640,9 @@ Axios.prototype.request = function request(config) {
554
640
 
555
641
  if (transitional !== undefined) {
556
642
  validator.assertOptions(transitional, {
557
- silentJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
558
- forcedJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
559
- clarifyTimeoutError: validators.transitional(validators.boolean, '1.0.0')
643
+ silentJSONParsing: validators.transitional(validators.boolean),
644
+ forcedJSONParsing: validators.transitional(validators.boolean),
645
+ clarifyTimeoutError: validators.transitional(validators.boolean)
560
646
  }, false);
561
647
  }
562
648
 
@@ -795,6 +881,7 @@ var utils = __webpack_require__(/*! ./../utils */ "../../node_modules/axios/lib/
795
881
  var transformData = __webpack_require__(/*! ./transformData */ "../../node_modules/axios/lib/core/transformData.js");
796
882
  var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "../../node_modules/axios/lib/cancel/isCancel.js");
797
883
  var defaults = __webpack_require__(/*! ../defaults */ "../../node_modules/axios/lib/defaults.js");
884
+ var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "../../node_modules/axios/lib/cancel/Cancel.js");
798
885
 
799
886
  /**
800
887
  * Throws a `Cancel` if cancellation has been requested.
@@ -803,6 +890,10 @@ function throwIfCancellationRequested(config) {
803
890
  if (config.cancelToken) {
804
891
  config.cancelToken.throwIfRequested();
805
892
  }
893
+
894
+ if (config.signal && config.signal.aborted) {
895
+ throw new Cancel('canceled');
896
+ }
806
897
  }
807
898
 
808
899
  /**
@@ -920,7 +1011,8 @@ module.exports = function enhanceError(error, config, code, request, response) {
920
1011
  stack: this.stack,
921
1012
  // Axios
922
1013
  config: this.config,
923
- code: this.code
1014
+ code: this.code,
1015
+ status: this.response && this.response.status ? this.response.status : null
924
1016
  };
925
1017
  };
926
1018
  return error;
@@ -954,17 +1046,6 @@ module.exports = function mergeConfig(config1, config2) {
954
1046
  config2 = config2 || {};
955
1047
  var config = {};
956
1048
 
957
- var valueFromConfig2Keys = ['url', 'method', 'data'];
958
- var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
959
- var defaultToConfig2Keys = [
960
- 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
961
- 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
962
- 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
963
- 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
964
- 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
965
- ];
966
- var directMergeKeys = ['validateStatus'];
967
-
968
1049
  function getMergedValue(target, source) {
969
1050
  if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
970
1051
  return utils.merge(target, source);
@@ -976,51 +1057,74 @@ module.exports = function mergeConfig(config1, config2) {
976
1057
  return source;
977
1058
  }
978
1059
 
1060
+ // eslint-disable-next-line consistent-return
979
1061
  function mergeDeepProperties(prop) {
980
1062
  if (!utils.isUndefined(config2[prop])) {
981
- config[prop] = getMergedValue(config1[prop], config2[prop]);
1063
+ return getMergedValue(config1[prop], config2[prop]);
982
1064
  } else if (!utils.isUndefined(config1[prop])) {
983
- config[prop] = getMergedValue(undefined, config1[prop]);
1065
+ return getMergedValue(undefined, config1[prop]);
984
1066
  }
985
1067
  }
986
1068
 
987
- utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
1069
+ // eslint-disable-next-line consistent-return
1070
+ function valueFromConfig2(prop) {
988
1071
  if (!utils.isUndefined(config2[prop])) {
989
- config[prop] = getMergedValue(undefined, config2[prop]);
1072
+ return getMergedValue(undefined, config2[prop]);
990
1073
  }
991
- });
992
-
993
- utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
1074
+ }
994
1075
 
995
- utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
1076
+ // eslint-disable-next-line consistent-return
1077
+ function defaultToConfig2(prop) {
996
1078
  if (!utils.isUndefined(config2[prop])) {
997
- config[prop] = getMergedValue(undefined, config2[prop]);
1079
+ return getMergedValue(undefined, config2[prop]);
998
1080
  } else if (!utils.isUndefined(config1[prop])) {
999
- config[prop] = getMergedValue(undefined, config1[prop]);
1081
+ return getMergedValue(undefined, config1[prop]);
1000
1082
  }
1001
- });
1083
+ }
1002
1084
 
1003
- utils.forEach(directMergeKeys, function merge(prop) {
1085
+ // eslint-disable-next-line consistent-return
1086
+ function mergeDirectKeys(prop) {
1004
1087
  if (prop in config2) {
1005
- config[prop] = getMergedValue(config1[prop], config2[prop]);
1088
+ return getMergedValue(config1[prop], config2[prop]);
1006
1089
  } else if (prop in config1) {
1007
- config[prop] = getMergedValue(undefined, config1[prop]);
1008
- }
1009
- });
1010
-
1011
- var axiosKeys = valueFromConfig2Keys
1012
- .concat(mergeDeepPropertiesKeys)
1013
- .concat(defaultToConfig2Keys)
1014
- .concat(directMergeKeys);
1015
-
1016
- var otherKeys = Object
1017
- .keys(config1)
1018
- .concat(Object.keys(config2))
1019
- .filter(function filterAxiosKeys(key) {
1020
- return axiosKeys.indexOf(key) === -1;
1021
- });
1090
+ return getMergedValue(undefined, config1[prop]);
1091
+ }
1092
+ }
1093
+
1094
+ var mergeMap = {
1095
+ 'url': valueFromConfig2,
1096
+ 'method': valueFromConfig2,
1097
+ 'data': valueFromConfig2,
1098
+ 'baseURL': defaultToConfig2,
1099
+ 'transformRequest': defaultToConfig2,
1100
+ 'transformResponse': defaultToConfig2,
1101
+ 'paramsSerializer': defaultToConfig2,
1102
+ 'timeout': defaultToConfig2,
1103
+ 'timeoutMessage': defaultToConfig2,
1104
+ 'withCredentials': defaultToConfig2,
1105
+ 'adapter': defaultToConfig2,
1106
+ 'responseType': defaultToConfig2,
1107
+ 'xsrfCookieName': defaultToConfig2,
1108
+ 'xsrfHeaderName': defaultToConfig2,
1109
+ 'onUploadProgress': defaultToConfig2,
1110
+ 'onDownloadProgress': defaultToConfig2,
1111
+ 'decompress': defaultToConfig2,
1112
+ 'maxContentLength': defaultToConfig2,
1113
+ 'maxBodyLength': defaultToConfig2,
1114
+ 'transport': defaultToConfig2,
1115
+ 'httpAgent': defaultToConfig2,
1116
+ 'httpsAgent': defaultToConfig2,
1117
+ 'cancelToken': defaultToConfig2,
1118
+ 'socketPath': defaultToConfig2,
1119
+ 'responseEncoding': defaultToConfig2,
1120
+ 'validateStatus': mergeDirectKeys
1121
+ };
1022
1122
 
1023
- utils.forEach(otherKeys, mergeDeepProperties);
1123
+ utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
1124
+ var merge = mergeMap[prop] || mergeDeepProperties;
1125
+ var configValue = merge(prop);
1126
+ (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
1127
+ });
1024
1128
 
1025
1129
  return config;
1026
1130
  };
@@ -1188,7 +1292,7 @@ var defaults = {
1188
1292
  }],
1189
1293
 
1190
1294
  transformResponse: [function transformResponse(data) {
1191
- var transitional = this.transitional;
1295
+ var transitional = this.transitional || defaults.transitional;
1192
1296
  var silentJSONParsing = transitional && transitional.silentJSONParsing;
1193
1297
  var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1194
1298
  var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
@@ -1223,12 +1327,12 @@ var defaults = {
1223
1327
 
1224
1328
  validateStatus: function validateStatus(status) {
1225
1329
  return status >= 200 && status < 300;
1226
- }
1227
- };
1330
+ },
1228
1331
 
1229
- defaults.headers = {
1230
- common: {
1231
- 'Accept': 'application/json, text/plain, */*'
1332
+ headers: {
1333
+ common: {
1334
+ 'Accept': 'application/json, text/plain, */*'
1335
+ }
1232
1336
  }
1233
1337
  };
1234
1338
 
@@ -1246,6 +1350,19 @@ module.exports = defaults;
1246
1350
 
1247
1351
  /***/ }),
1248
1352
 
1353
+ /***/ "../../node_modules/axios/lib/env/data.js":
1354
+ /*!***********************************************************!*\
1355
+ !*** /root/amplify-js/node_modules/axios/lib/env/data.js ***!
1356
+ \***********************************************************/
1357
+ /*! no static exports found */
1358
+ /***/ (function(module, exports) {
1359
+
1360
+ module.exports = {
1361
+ "version": "0.26.0"
1362
+ };
1363
+
1364
+ /***/ }),
1365
+
1249
1366
  /***/ "../../node_modules/axios/lib/helpers/bind.js":
1250
1367
  /*!***************************************************************!*\
1251
1368
  !*** /root/amplify-js/node_modules/axios/lib/helpers/bind.js ***!
@@ -1462,7 +1579,7 @@ module.exports = function isAbsoluteURL(url) {
1462
1579
  // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1463
1580
  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1464
1581
  // by any combination of letters, digits, plus, period, or hyphen.
1465
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
1582
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1466
1583
  };
1467
1584
 
1468
1585
 
@@ -1478,6 +1595,8 @@ module.exports = function isAbsoluteURL(url) {
1478
1595
  "use strict";
1479
1596
 
1480
1597
 
1598
+ var utils = __webpack_require__(/*! ./../utils */ "../../node_modules/axios/lib/utils.js");
1599
+
1481
1600
  /**
1482
1601
  * Determines whether the payload is an error thrown by Axios
1483
1602
  *
@@ -1485,7 +1604,7 @@ module.exports = function isAbsoluteURL(url) {
1485
1604
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
1486
1605
  */
1487
1606
  module.exports = function isAxiosError(payload) {
1488
- return (typeof payload === 'object') && (payload.isAxiosError === true);
1607
+ return utils.isObject(payload) && (payload.isAxiosError === true);
1489
1608
  };
1490
1609
 
1491
1610
 
@@ -1709,7 +1828,7 @@ module.exports = function spread(callback) {
1709
1828
  "use strict";
1710
1829
 
1711
1830
 
1712
- var pkg = __webpack_require__(/*! ./../../package.json */ "../../node_modules/axios/package.json");
1831
+ var VERSION = __webpack_require__(/*! ../env/data */ "../../node_modules/axios/lib/env/data.js").version;
1713
1832
 
1714
1833
  var validators = {};
1715
1834
 
@@ -1721,48 +1840,26 @@ var validators = {};
1721
1840
  });
1722
1841
 
1723
1842
  var deprecatedWarnings = {};
1724
- var currentVerArr = pkg.version.split('.');
1725
-
1726
- /**
1727
- * Compare package versions
1728
- * @param {string} version
1729
- * @param {string?} thanVersion
1730
- * @returns {boolean}
1731
- */
1732
- function isOlderVersion(version, thanVersion) {
1733
- var pkgVersionArr = thanVersion ? thanVersion.split('.') : currentVerArr;
1734
- var destVer = version.split('.');
1735
- for (var i = 0; i < 3; i++) {
1736
- if (pkgVersionArr[i] > destVer[i]) {
1737
- return true;
1738
- } else if (pkgVersionArr[i] < destVer[i]) {
1739
- return false;
1740
- }
1741
- }
1742
- return false;
1743
- }
1744
1843
 
1745
1844
  /**
1746
1845
  * Transitional option validator
1747
- * @param {function|boolean?} validator
1748
- * @param {string?} version
1749
- * @param {string} message
1846
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
1847
+ * @param {string?} version - deprecated version / removed since version
1848
+ * @param {string?} message - some message with additional info
1750
1849
  * @returns {function}
1751
1850
  */
1752
1851
  validators.transitional = function transitional(validator, version, message) {
1753
- var isDeprecated = version && isOlderVersion(version);
1754
-
1755
1852
  function formatMessage(opt, desc) {
1756
- return '[Axios v' + pkg.version + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
1853
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
1757
1854
  }
1758
1855
 
1759
1856
  // eslint-disable-next-line func-names
1760
1857
  return function(value, opt, opts) {
1761
1858
  if (validator === false) {
1762
- throw new Error(formatMessage(opt, ' has been removed in ' + version));
1859
+ throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
1763
1860
  }
1764
1861
 
1765
- if (isDeprecated && !deprecatedWarnings[opt]) {
1862
+ if (version && !deprecatedWarnings[opt]) {
1766
1863
  deprecatedWarnings[opt] = true;
1767
1864
  // eslint-disable-next-line no-console
1768
1865
  console.warn(
@@ -1808,7 +1905,6 @@ function assertOptions(options, schema, allowUnknown) {
1808
1905
  }
1809
1906
 
1810
1907
  module.exports = {
1811
- isOlderVersion: isOlderVersion,
1812
1908
  assertOptions: assertOptions,
1813
1909
  validators: validators
1814
1910
  };
@@ -1839,7 +1935,7 @@ var toString = Object.prototype.toString;
1839
1935
  * @returns {boolean} True if value is an Array, otherwise false
1840
1936
  */
1841
1937
  function isArray(val) {
1842
- return toString.call(val) === '[object Array]';
1938
+ return Array.isArray(val);
1843
1939
  }
1844
1940
 
1845
1941
  /**
@@ -1880,7 +1976,7 @@ function isArrayBuffer(val) {
1880
1976
  * @returns {boolean} True if value is an FormData, otherwise false
1881
1977
  */
1882
1978
  function isFormData(val) {
1883
- return (typeof FormData !== 'undefined') && (val instanceof FormData);
1979
+ return toString.call(val) === '[object FormData]';
1884
1980
  }
1885
1981
 
1886
1982
  /**
@@ -1894,7 +1990,7 @@ function isArrayBufferView(val) {
1894
1990
  if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
1895
1991
  result = ArrayBuffer.isView(val);
1896
1992
  } else {
1897
- result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
1993
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
1898
1994
  }
1899
1995
  return result;
1900
1996
  }
@@ -2001,7 +2097,7 @@ function isStream(val) {
2001
2097
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
2002
2098
  */
2003
2099
  function isURLSearchParams(val) {
2004
- return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
2100
+ return toString.call(val) === '[object URLSearchParams]';
2005
2101
  }
2006
2102
 
2007
2103
  /**
@@ -2175,17 +2271,6 @@ module.exports = {
2175
2271
  };
2176
2272
 
2177
2273
 
2178
- /***/ }),
2179
-
2180
- /***/ "../../node_modules/axios/package.json":
2181
- /*!********************************************************!*\
2182
- !*** /root/amplify-js/node_modules/axios/package.json ***!
2183
- \********************************************************/
2184
- /*! exports provided: name, version, description, main, scripts, repository, keywords, author, license, bugs, homepage, devDependencies, browser, jsdelivr, unpkg, typings, dependencies, bundlesize, default */
2185
- /***/ (function(module) {
2186
-
2187
- module.exports = JSON.parse("{\"name\":\"axios\",\"version\":\"0.21.4\",\"description\":\"Promise based HTTP client for the browser and node.js\",\"main\":\"index.js\",\"scripts\":{\"test\":\"grunt test\",\"start\":\"node ./sandbox/server.js\",\"build\":\"NODE_ENV=production grunt build\",\"preversion\":\"npm test\",\"version\":\"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json\",\"postversion\":\"git push && git push --tags\",\"examples\":\"node ./examples/server.js\",\"coveralls\":\"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js\",\"fix\":\"eslint --fix lib/**/*.js\"},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/axios/axios.git\"},\"keywords\":[\"xhr\",\"http\",\"ajax\",\"promise\",\"node\"],\"author\":\"Matt Zabriskie\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://github.com/axios/axios/issues\"},\"homepage\":\"https://axios-http.com\",\"devDependencies\":{\"coveralls\":\"^3.0.0\",\"es6-promise\":\"^4.2.4\",\"grunt\":\"^1.3.0\",\"grunt-banner\":\"^0.6.0\",\"grunt-cli\":\"^1.2.0\",\"grunt-contrib-clean\":\"^1.1.0\",\"grunt-contrib-watch\":\"^1.0.0\",\"grunt-eslint\":\"^23.0.0\",\"grunt-karma\":\"^4.0.0\",\"grunt-mocha-test\":\"^0.13.3\",\"grunt-ts\":\"^6.0.0-beta.19\",\"grunt-webpack\":\"^4.0.2\",\"istanbul-instrumenter-loader\":\"^1.0.0\",\"jasmine-core\":\"^2.4.1\",\"karma\":\"^6.3.2\",\"karma-chrome-launcher\":\"^3.1.0\",\"karma-firefox-launcher\":\"^2.1.0\",\"karma-jasmine\":\"^1.1.1\",\"karma-jasmine-ajax\":\"^0.1.13\",\"karma-safari-launcher\":\"^1.0.0\",\"karma-sauce-launcher\":\"^4.3.6\",\"karma-sinon\":\"^1.0.5\",\"karma-sourcemap-loader\":\"^0.3.8\",\"karma-webpack\":\"^4.0.2\",\"load-grunt-tasks\":\"^3.5.2\",\"minimist\":\"^1.2.0\",\"mocha\":\"^8.2.1\",\"sinon\":\"^4.5.0\",\"terser-webpack-plugin\":\"^4.2.3\",\"typescript\":\"^4.0.5\",\"url-search-params\":\"^0.10.0\",\"webpack\":\"^4.44.2\",\"webpack-dev-server\":\"^3.11.0\"},\"browser\":{\"./lib/adapters/http.js\":\"./lib/adapters/xhr.js\"},\"jsdelivr\":\"dist/axios.min.js\",\"unpkg\":\"dist/axios.min.js\",\"typings\":\"./index.d.ts\",\"dependencies\":{\"follow-redirects\":\"^1.14.0\"},\"bundlesize\":[{\"path\":\"./dist/axios.min.js\",\"threshold\":\"5kB\"}]}");
2188
-
2189
2274
  /***/ }),
2190
2275
 
2191
2276
  /***/ "../../node_modules/base64-js/index.js":
@@ -9824,6 +9909,16 @@ function () {
9824
9909
  RestAPIClass.prototype.cancel = function (request, message) {
9825
9910
  return this._api.cancel(request, message);
9826
9911
  };
9912
+ /**
9913
+ * Check if the request has a corresponding cancel token in the WeakMap.
9914
+ * @params request - The request promise
9915
+ * @return if the request has a corresponding cancel token.
9916
+ */
9917
+
9918
+
9919
+ RestAPIClass.prototype.hasCancelToken = function (request) {
9920
+ return this._api.hasCancelToken(request);
9921
+ };
9827
9922
  /**
9828
9923
  * Getting endpoint for API
9829
9924
  * @param {string} apiName - The name of the api
@@ -10389,9 +10484,20 @@ function () {
10389
10484
 
10390
10485
  if (source) {
10391
10486
  source.cancel(message);
10487
+ return true;
10392
10488
  }
10393
10489
 
10394
- return true;
10490
+ return false;
10491
+ };
10492
+ /**
10493
+ * Check if the request has a corresponding cancel token in the WeakMap.
10494
+ * @params request - The request promise
10495
+ * @return if the request has a corresponding cancel token.
10496
+ */
10497
+
10498
+
10499
+ RestClient.prototype.hasCancelToken = function (request) {
10500
+ return this._cancelTokenMap.has(request);
10395
10501
  };
10396
10502
  /**
10397
10503
  * Checks to see if an error thrown is from an api request cancellation
@@ -10801,6 +10907,9 @@ var __spread = undefined && undefined.__spread || function () {
10801
10907
 
10802
10908
 
10803
10909
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('AWSAppSyncProvider');
10910
+ /**
10911
+ * @deprecated Unused, all usecases have migrated to AWSAppSyncRealtimeProvider
10912
+ */
10804
10913
 
10805
10914
  var AWSAppSyncProvider =
10806
10915
  /** @class */
@@ -11107,10 +11216,135 @@ function (_super) {
11107
11216
 
11108
11217
  /***/ }),
11109
11218
 
11110
- /***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js":
11111
- /*!*****************************************************************!*\
11112
- !*** ../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js ***!
11113
- \*****************************************************************/
11219
+ /***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js":
11220
+ /*!***************************************************************************!*\
11221
+ !*** ../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js ***!
11222
+ \***************************************************************************/
11223
+ /*! exports provided: MAX_DELAY_MS, NON_RETRYABLE_CODES, MESSAGE_TYPES, SUBSCRIPTION_STATUS, SOCKET_STATUS, AMPLIFY_SYMBOL, AWS_APPSYNC_REALTIME_HEADERS, CONNECTION_INIT_TIMEOUT, START_ACK_TIMEOUT, DEFAULT_KEEP_ALIVE_TIMEOUT */
11224
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
11225
+
11226
+ "use strict";
11227
+ __webpack_require__.r(__webpack_exports__);
11228
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
11229
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
11230
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
11231
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
11232
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
11233
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
11234
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
11235
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
11236
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
11237
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
11238
+ var MAX_DELAY_MS = 5000;
11239
+ var NON_RETRYABLE_CODES = [400, 401, 403];
11240
+ var MESSAGE_TYPES;
11241
+
11242
+ (function (MESSAGE_TYPES) {
11243
+ /**
11244
+ * Client -> Server message.
11245
+ * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
11246
+ */
11247
+ MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
11248
+ /**
11249
+ * Server -> Client message
11250
+ * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
11251
+ */
11252
+
11253
+ MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
11254
+ /**
11255
+ * Server -> Client message.
11256
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
11257
+ */
11258
+
11259
+ MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
11260
+ /**
11261
+ * Client -> Server message.
11262
+ * This message type is for register subscriptions with AWS AppSync RealTime
11263
+ */
11264
+
11265
+ MESSAGE_TYPES["GQL_START"] = "start";
11266
+ /**
11267
+ * Server -> Client message.
11268
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
11269
+ */
11270
+
11271
+ MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
11272
+ /**
11273
+ * Server -> Client message.
11274
+ * This message type is for subscription message from AWS AppSync RealTime
11275
+ */
11276
+
11277
+ MESSAGE_TYPES["GQL_DATA"] = "data";
11278
+ /**
11279
+ * Server -> Client message.
11280
+ * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
11281
+ */
11282
+
11283
+ MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
11284
+ /**
11285
+ * Client -> Server message.
11286
+ * This message type is for unregister subscriptions with AWS AppSync RealTime
11287
+ */
11288
+
11289
+ MESSAGE_TYPES["GQL_STOP"] = "stop";
11290
+ /**
11291
+ * Server -> Client message.
11292
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
11293
+ */
11294
+
11295
+ MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
11296
+ /**
11297
+ * Server -> Client message.
11298
+ * This message type is for sending error messages from AWS AppSync RealTime to the client
11299
+ */
11300
+
11301
+ MESSAGE_TYPES["GQL_ERROR"] = "error";
11302
+ })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
11303
+
11304
+ var SUBSCRIPTION_STATUS;
11305
+
11306
+ (function (SUBSCRIPTION_STATUS) {
11307
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
11308
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
11309
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
11310
+ })(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
11311
+
11312
+ var SOCKET_STATUS;
11313
+
11314
+ (function (SOCKET_STATUS) {
11315
+ SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
11316
+ SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
11317
+ SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
11318
+ })(SOCKET_STATUS || (SOCKET_STATUS = {}));
11319
+
11320
+ var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
11321
+ var AWS_APPSYNC_REALTIME_HEADERS = {
11322
+ accept: 'application/json, text/javascript',
11323
+ 'content-encoding': 'amz-1.0',
11324
+ 'content-type': 'application/json; charset=UTF-8'
11325
+ };
11326
+ /**
11327
+ * Time in milleseconds to wait for GQL_CONNECTION_INIT message
11328
+ */
11329
+
11330
+ var CONNECTION_INIT_TIMEOUT = 15000;
11331
+ /**
11332
+ * Time in milleseconds to wait for GQL_START_ACK message
11333
+ */
11334
+
11335
+ var START_ACK_TIMEOUT = 15000;
11336
+ /**
11337
+ * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
11338
+ */
11339
+
11340
+ var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
11341
+
11342
+ /***/ }),
11343
+
11344
+ /***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js":
11345
+ /*!***********************************************************************!*\
11346
+ !*** ../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js ***!
11347
+ \***********************************************************************/
11114
11348
  /*! exports provided: AWSAppSyncRealTimeProvider */
11115
11349
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
11116
11350
 
@@ -11132,8 +11366,9 @@ __webpack_require__.r(__webpack_exports__);
11132
11366
  /* harmony import */ var _aws_amplify_cache__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_cache__WEBPACK_IMPORTED_MODULE_6__);
11133
11367
  /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
11134
11368
  /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__);
11135
- /* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
11136
- /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../index */ "../pubsub/lib-esm/index.js");
11369
+ /* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
11370
+ /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../index */ "../pubsub/lib-esm/index.js");
11371
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./constants */ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js");
11137
11372
  var __extends = undefined && undefined.__extends || function () {
11138
11373
  var _extendStatics = function extendStatics(d, b) {
11139
11374
  _extendStatics = Object.setPrototypeOf || {
@@ -11369,119 +11604,17 @@ var __read = undefined && undefined.__read || function (o, n) {
11369
11604
 
11370
11605
 
11371
11606
 
11607
+
11372
11608
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Logger"]('AWSAppSyncRealTimeProvider');
11373
- var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
11374
11609
 
11375
11610
  var dispatchApiEvent = function dispatchApiEvent(event, data, message) {
11376
11611
  _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Hub"].dispatch('api', {
11377
11612
  event: event,
11378
11613
  data: data,
11379
11614
  message: message
11380
- }, 'PubSub', AMPLIFY_SYMBOL);
11615
+ }, 'PubSub', _constants__WEBPACK_IMPORTED_MODULE_10__["AMPLIFY_SYMBOL"]);
11381
11616
  };
11382
11617
 
11383
- var MAX_DELAY_MS = 5000;
11384
- var NON_RETRYABLE_CODES = [400, 401, 403];
11385
- var MESSAGE_TYPES;
11386
-
11387
- (function (MESSAGE_TYPES) {
11388
- /**
11389
- * Client -> Server message.
11390
- * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
11391
- */
11392
- MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
11393
- /**
11394
- * Server -> Client message
11395
- * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
11396
- */
11397
-
11398
- MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
11399
- /**
11400
- * Server -> Client message.
11401
- * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
11402
- */
11403
-
11404
- MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
11405
- /**
11406
- * Client -> Server message.
11407
- * This message type is for register subscriptions with AWS AppSync RealTime
11408
- */
11409
-
11410
- MESSAGE_TYPES["GQL_START"] = "start";
11411
- /**
11412
- * Server -> Client message.
11413
- * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
11414
- */
11415
-
11416
- MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
11417
- /**
11418
- * Server -> Client message.
11419
- * This message type is for subscription message from AWS AppSync RealTime
11420
- */
11421
-
11422
- MESSAGE_TYPES["GQL_DATA"] = "data";
11423
- /**
11424
- * Server -> Client message.
11425
- * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
11426
- */
11427
-
11428
- MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
11429
- /**
11430
- * Client -> Server message.
11431
- * This message type is for unregister subscriptions with AWS AppSync RealTime
11432
- */
11433
-
11434
- MESSAGE_TYPES["GQL_STOP"] = "stop";
11435
- /**
11436
- * Server -> Client message.
11437
- * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
11438
- */
11439
-
11440
- MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
11441
- /**
11442
- * Server -> Client message.
11443
- * This message type is for sending error messages from AWS AppSync RealTime to the client
11444
- */
11445
-
11446
- MESSAGE_TYPES["GQL_ERROR"] = "error";
11447
- })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
11448
-
11449
- var SUBSCRIPTION_STATUS;
11450
-
11451
- (function (SUBSCRIPTION_STATUS) {
11452
- SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
11453
- SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
11454
- SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
11455
- })(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
11456
-
11457
- var SOCKET_STATUS;
11458
-
11459
- (function (SOCKET_STATUS) {
11460
- SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
11461
- SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
11462
- SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
11463
- })(SOCKET_STATUS || (SOCKET_STATUS = {}));
11464
-
11465
- var AWS_APPSYNC_REALTIME_HEADERS = {
11466
- accept: 'application/json, text/javascript',
11467
- 'content-encoding': 'amz-1.0',
11468
- 'content-type': 'application/json; charset=UTF-8'
11469
- };
11470
- /**
11471
- * Time in milleseconds to wait for GQL_CONNECTION_INIT message
11472
- */
11473
-
11474
- var CONNECTION_INIT_TIMEOUT = 15000;
11475
- /**
11476
- * Time in milleseconds to wait for GQL_START_ACK message
11477
- */
11478
-
11479
- var START_ACK_TIMEOUT = 15000;
11480
- /**
11481
- * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
11482
- */
11483
-
11484
- var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
11485
11618
  var standardDomainPattern = /^https:\/\/\w{26}\.appsync\-api\.\w{2}(?:(?:\-\w{2,})+)\-\d\.amazonaws.com\/graphql$/i;
11486
11619
  var customDomainPath = '/realtime';
11487
11620
 
@@ -11493,13 +11626,17 @@ function (_super) {
11493
11626
  function AWSAppSyncRealTimeProvider() {
11494
11627
  var _this = _super !== null && _super.apply(this, arguments) || this;
11495
11628
 
11496
- _this.socketStatus = SOCKET_STATUS.CLOSED;
11497
- _this.keepAliveTimeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
11629
+ _this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
11630
+ _this.keepAliveTimeout = _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_TIMEOUT"];
11498
11631
  _this.subscriptionObserverMap = new Map();
11499
11632
  _this.promiseArray = [];
11500
11633
  return _this;
11501
11634
  }
11502
11635
 
11636
+ AWSAppSyncRealTimeProvider.prototype.getNewWebSocket = function (url, protocol) {
11637
+ return new WebSocket(url, protocol);
11638
+ };
11639
+
11503
11640
  AWSAppSyncRealTimeProvider.prototype.getProviderName = function () {
11504
11641
  return 'AWSAppSyncRealTimeProvider';
11505
11642
  };
@@ -11524,9 +11661,9 @@ function (_super) {
11524
11661
  AWSAppSyncRealTimeProvider.prototype.subscribe = function (_topics, options) {
11525
11662
  var _this = this;
11526
11663
 
11527
- var appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint;
11664
+ var appSyncGraphqlEndpoint = options === null || options === void 0 ? void 0 : options.appSyncGraphqlEndpoint;
11528
11665
  return new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (observer) {
11529
- if (!appSyncGraphqlEndpoint) {
11666
+ if (!options || !appSyncGraphqlEndpoint) {
11530
11667
  observer.error({
11531
11668
  errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscribe only available for AWS AppSync endpoint"))]
11532
11669
  });
@@ -11571,7 +11708,7 @@ function (_super) {
11571
11708
  ];
11572
11709
  }
11573
11710
 
11574
- if (subscriptionState === SUBSCRIPTION_STATUS.CONNECTED) {
11711
+ if (subscriptionState === _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].CONNECTED) {
11575
11712
  this._sendUnsubscriptionMessage(subscriptionId_1);
11576
11713
  } else {
11577
11714
  throw new Error('Subscription never connected');
@@ -11619,20 +11756,23 @@ function (_super) {
11619
11756
  var options = _a.options,
11620
11757
  observer = _a.observer,
11621
11758
  subscriptionId = _a.subscriptionId;
11759
+
11760
+ var _b, _c;
11761
+
11622
11762
  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;
11763
+ 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
11764
 
11625
- var _h;
11765
+ var _j;
11626
11766
 
11627
11767
  var _this = this;
11628
11768
 
11629
- return __generator(this, function (_j) {
11630
- switch (_j.label) {
11769
+ return __generator(this, function (_k) {
11770
+ switch (_k.label) {
11631
11771
  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 () {
11772
+ 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
11773
  return {};
11634
- } : _b, _c = options.additionalHeaders, additionalHeaders = _c === void 0 ? {} : _c;
11635
- subscriptionState = SUBSCRIPTION_STATUS.PENDING;
11774
+ } : _d, _e = options.additionalHeaders, additionalHeaders = _e === void 0 ? {} : _e;
11775
+ subscriptionState = _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].PENDING;
11636
11776
  data = {
11637
11777
  query: query,
11638
11778
  variables: variables
@@ -11640,13 +11780,13 @@ function (_super) {
11640
11780
 
11641
11781
  this.subscriptionObserverMap.set(subscriptionId, {
11642
11782
  observer: observer,
11643
- query: query,
11644
- variables: variables,
11783
+ query: query !== null && query !== void 0 ? query : '',
11784
+ variables: variables !== null && variables !== void 0 ? variables : {},
11645
11785
  subscriptionState: subscriptionState,
11646
- startAckTimeoutId: null
11786
+ startAckTimeoutId: undefined
11647
11787
  });
11648
11788
  dataString = JSON.stringify(data);
11649
- _d = [{}];
11789
+ _f = [{}];
11650
11790
  return [4
11651
11791
  /*yield*/
11652
11792
  , this._awsRealTimeHeaderBasedAuth({
@@ -11660,13 +11800,13 @@ function (_super) {
11660
11800
  })];
11661
11801
 
11662
11802
  case 1:
11663
- _e = [__assign.apply(void 0, _d.concat([_j.sent()]))];
11803
+ _g = [__assign.apply(void 0, _f.concat([_k.sent()]))];
11664
11804
  return [4
11665
11805
  /*yield*/
11666
11806
  , graphql_headers()];
11667
11807
 
11668
11808
  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)]);
11809
+ 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
11810
  subscriptionMessage = {
11671
11811
  id: subscriptionId,
11672
11812
  payload: {
@@ -11675,13 +11815,13 @@ function (_super) {
11675
11815
  authorization: __assign({}, headerObj)
11676
11816
  }
11677
11817
  },
11678
- type: MESSAGE_TYPES.GQL_START
11818
+ type: _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_START
11679
11819
  };
11680
11820
  stringToAWSRealTime = JSON.stringify(subscriptionMessage);
11681
- _j.label = 3;
11821
+ _k.label = 3;
11682
11822
 
11683
11823
  case 3:
11684
- _j.trys.push([3, 5,, 6]);
11824
+ _k.trys.push([3, 5,, 6]);
11685
11825
 
11686
11826
  return [4
11687
11827
  /*yield*/
@@ -11694,18 +11834,18 @@ function (_super) {
11694
11834
  })];
11695
11835
 
11696
11836
  case 4:
11697
- _j.sent();
11837
+ _k.sent();
11698
11838
 
11699
11839
  return [3
11700
11840
  /*break*/
11701
11841
  , 6];
11702
11842
 
11703
11843
  case 5:
11704
- err_2 = _j.sent();
11844
+ err_2 = _k.sent();
11705
11845
  logger.debug({
11706
11846
  err: err_2
11707
11847
  });
11708
- _f = err_2.message, message = _f === void 0 ? '' : _f;
11848
+ message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
11709
11849
  observer.error({
11710
11850
  errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
11711
11851
  });
@@ -11721,18 +11861,18 @@ function (_super) {
11721
11861
  ];
11722
11862
 
11723
11863
  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
11864
+ _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
11865
 
11726
11866
  this.subscriptionObserverMap.set(subscriptionId, {
11727
11867
  observer: observer,
11728
11868
  subscriptionState: subscriptionState,
11729
- variables: variables,
11730
- query: query,
11869
+ query: query !== null && query !== void 0 ? query : '',
11870
+ variables: variables !== null && variables !== void 0 ? variables : {},
11731
11871
  subscriptionReadyCallback: subscriptionReadyCallback,
11732
11872
  subscriptionFailedCallback: subscriptionFailedCallback,
11733
11873
  startAckTimeoutId: setTimeout(function () {
11734
11874
  _this._timeoutStartSubscriptionAck.call(_this, subscriptionId);
11735
- }, START_ACK_TIMEOUT)
11875
+ }, _constants__WEBPACK_IMPORTED_MODULE_10__["START_ACK_TIMEOUT"])
11736
11876
  });
11737
11877
 
11738
11878
  if (this.awsRealTimeSocket) {
@@ -11750,32 +11890,35 @@ function (_super) {
11750
11890
 
11751
11891
  AWSAppSyncRealTimeProvider.prototype._waitForSubscriptionToBeConnected = function (subscriptionId) {
11752
11892
  return __awaiter(this, void 0, void 0, function () {
11753
- var subscriptionState;
11893
+ var subscriptionObserver, subscriptionState;
11754
11894
 
11755
11895
  var _this = this;
11756
11896
 
11757
11897
  return __generator(this, function (_a) {
11758
- subscriptionState = this.subscriptionObserverMap.get(subscriptionId).subscriptionState; // This in case unsubscribe is invoked before sending start subscription message
11898
+ subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
11759
11899
 
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
- })];
11900
+ if (subscriptionObserver) {
11901
+ subscriptionState = subscriptionObserver.subscriptionState; // This in case unsubscribe is invoked before sending start subscription message
11902
+
11903
+ if (subscriptionState === _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].PENDING) {
11904
+ return [2
11905
+ /*return*/
11906
+ , new Promise(function (res, rej) {
11907
+ var observer = subscriptionObserver.observer,
11908
+ subscriptionState = subscriptionObserver.subscriptionState,
11909
+ variables = subscriptionObserver.variables,
11910
+ query = subscriptionObserver.query;
11911
+
11912
+ _this.subscriptionObserverMap.set(subscriptionId, {
11913
+ observer: observer,
11914
+ subscriptionState: subscriptionState,
11915
+ variables: variables,
11916
+ query: query,
11917
+ subscriptionReadyCallback: res,
11918
+ subscriptionFailedCallback: rej
11919
+ });
11920
+ })];
11921
+ }
11779
11922
  }
11780
11923
 
11781
11924
  return [2
@@ -11787,11 +11930,11 @@ function (_super) {
11787
11930
 
11788
11931
  AWSAppSyncRealTimeProvider.prototype._sendUnsubscriptionMessage = function (subscriptionId) {
11789
11932
  try {
11790
- if (this.awsRealTimeSocket && this.awsRealTimeSocket.readyState === WebSocket.OPEN && this.socketStatus === SOCKET_STATUS.READY) {
11933
+ if (this.awsRealTimeSocket && this.awsRealTimeSocket.readyState === WebSocket.OPEN && this.socketStatus === _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].READY) {
11791
11934
  // Preparing unsubscribe message to stop receiving messages for that subscription
11792
11935
  var unsubscribeMessage = {
11793
11936
  id: subscriptionId,
11794
- type: MESSAGE_TYPES.GQL_STOP
11937
+ type: _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_STOP
11795
11938
  };
11796
11939
  var stringToAWSRealTime = JSON.stringify(unsubscribeMessage);
11797
11940
  this.awsRealTimeSocket.send(stringToAWSRealTime);
@@ -11817,7 +11960,7 @@ function (_super) {
11817
11960
  }
11818
11961
 
11819
11962
  if (!this.awsRealTimeSocket) {
11820
- this.socketStatus = SOCKET_STATUS.CLOSED;
11963
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
11821
11964
  return;
11822
11965
  }
11823
11966
 
@@ -11826,14 +11969,14 @@ function (_super) {
11826
11969
  setTimeout(this._closeSocketIfRequired.bind(this), 1000);
11827
11970
  } else {
11828
11971
  logger.debug('closing WebSocket...');
11829
- clearTimeout(this.keepAliveTimeoutId);
11972
+ if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
11830
11973
  var tempSocket = this.awsRealTimeSocket; // Cleaning callbacks to avoid race condition, socket still exists
11831
11974
 
11832
- tempSocket.onclose = undefined;
11833
- tempSocket.onerror = undefined;
11975
+ tempSocket.onclose = null;
11976
+ tempSocket.onerror = null;
11834
11977
  tempSocket.close(1000);
11835
- this.awsRealTimeSocket = null;
11836
- this.socketStatus = SOCKET_STATUS.CLOSED;
11978
+ this.awsRealTimeSocket = undefined;
11979
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
11837
11980
  }
11838
11981
  };
11839
11982
 
@@ -11864,7 +12007,7 @@ function (_super) {
11864
12007
  variables: variables
11865
12008
  });
11866
12009
 
11867
- if (type === MESSAGE_TYPES.GQL_DATA && payload && payload.data) {
12010
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_DATA && payload && payload.data) {
11868
12011
  if (observer) {
11869
12012
  observer.next(payload);
11870
12013
  } else {
@@ -11874,7 +12017,7 @@ function (_super) {
11874
12017
  return;
11875
12018
  }
11876
12019
 
11877
- if (type === MESSAGE_TYPES.GQL_START_ACK) {
12020
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_START_ACK) {
11878
12021
  logger.debug("subscription ready for " + JSON.stringify({
11879
12022
  query: query,
11880
12023
  variables: variables
@@ -11884,50 +12027,57 @@ function (_super) {
11884
12027
  subscriptionReadyCallback();
11885
12028
  }
11886
12029
 
11887
- clearTimeout(startAckTimeoutId);
12030
+ if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
11888
12031
  dispatchApiEvent(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].SUBSCRIPTION_ACK, {
11889
12032
  query: query,
11890
12033
  variables: variables
11891
12034
  }, 'Connection established for subscription');
11892
- var subscriptionState = SUBSCRIPTION_STATUS.CONNECTED;
11893
- this.subscriptionObserverMap.set(id, {
11894
- observer: observer,
11895
- query: query,
11896
- variables: variables,
11897
- startAckTimeoutId: null,
11898
- subscriptionState: subscriptionState,
11899
- subscriptionReadyCallback: subscriptionReadyCallback,
11900
- subscriptionFailedCallback: subscriptionFailedCallback
11901
- }); // TODO: emit event on hub but it requires to store the id first
12035
+ var subscriptionState = _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].CONNECTED;
12036
+
12037
+ if (observer) {
12038
+ this.subscriptionObserverMap.set(id, {
12039
+ observer: observer,
12040
+ query: query,
12041
+ variables: variables,
12042
+ startAckTimeoutId: undefined,
12043
+ subscriptionState: subscriptionState,
12044
+ subscriptionReadyCallback: subscriptionReadyCallback,
12045
+ subscriptionFailedCallback: subscriptionFailedCallback
12046
+ });
12047
+ } // TODO: emit event on hub but it requires to store the id first
12048
+
11902
12049
 
11903
12050
  return;
11904
12051
  }
11905
12052
 
11906
- if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {
11907
- clearTimeout(this.keepAliveTimeoutId);
12053
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_KEEP_ALIVE) {
12054
+ if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
11908
12055
  this.keepAliveTimeoutId = setTimeout(this._errorDisconnect.bind(this, _index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT), this.keepAliveTimeout);
11909
12056
  return;
11910
12057
  }
11911
12058
 
11912
- if (type === MESSAGE_TYPES.GQL_ERROR) {
11913
- var subscriptionState = SUBSCRIPTION_STATUS.FAILED;
11914
- this.subscriptionObserverMap.set(id, {
11915
- observer: observer,
11916
- query: query,
11917
- variables: variables,
11918
- startAckTimeoutId: startAckTimeoutId,
11919
- subscriptionReadyCallback: subscriptionReadyCallback,
11920
- subscriptionFailedCallback: subscriptionFailedCallback,
11921
- subscriptionState: subscriptionState
11922
- });
11923
- observer.error({
11924
- errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
11925
- });
11926
- clearTimeout(startAckTimeoutId);
11927
- observer.complete();
12059
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_ERROR) {
12060
+ var subscriptionState = _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].FAILED;
12061
+
12062
+ if (observer) {
12063
+ this.subscriptionObserverMap.set(id, {
12064
+ observer: observer,
12065
+ query: query,
12066
+ variables: variables,
12067
+ startAckTimeoutId: startAckTimeoutId,
12068
+ subscriptionReadyCallback: subscriptionReadyCallback,
12069
+ subscriptionFailedCallback: subscriptionFailedCallback,
12070
+ subscriptionState: subscriptionState
12071
+ });
12072
+ observer.error({
12073
+ errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
12074
+ });
12075
+ if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
12076
+ observer.complete();
11928
12077
 
11929
- if (typeof subscriptionFailedCallback === 'function') {
11930
- subscriptionFailedCallback();
12078
+ if (typeof subscriptionFailedCallback === 'function') {
12079
+ subscriptionFailedCallback();
12080
+ }
11931
12081
  }
11932
12082
  }
11933
12083
  };
@@ -11949,41 +12099,44 @@ function (_super) {
11949
12099
  this.awsRealTimeSocket.close();
11950
12100
  }
11951
12101
 
11952
- this.socketStatus = SOCKET_STATUS.CLOSED;
12102
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
11953
12103
  };
11954
12104
 
11955
12105
  AWSAppSyncRealTimeProvider.prototype._timeoutStartSubscriptionAck = function (subscriptionId) {
11956
- var _a = this.subscriptionObserverMap.get(subscriptionId) || {},
11957
- observer = _a.observer,
11958
- query = _a.query,
11959
- variables = _a.variables;
12106
+ var subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
11960
12107
 
11961
- if (!observer) {
11962
- return;
11963
- }
12108
+ if (subscriptionObserver) {
12109
+ var observer = subscriptionObserver.observer,
12110
+ query = subscriptionObserver.query,
12111
+ variables = subscriptionObserver.variables;
11964
12112
 
11965
- this.subscriptionObserverMap.set(subscriptionId, {
11966
- observer: observer,
11967
- query: query,
11968
- variables: variables,
11969
- subscriptionState: SUBSCRIPTION_STATUS.FAILED
11970
- });
12113
+ if (!observer) {
12114
+ return;
12115
+ }
11971
12116
 
11972
- if (observer && !observer.closed) {
11973
- observer.error({
11974
- errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
11975
- query: query,
11976
- variables: variables
11977
- })))]
11978
- }); // Cleanup will be automatically executed
12117
+ this.subscriptionObserverMap.set(subscriptionId, {
12118
+ observer: observer,
12119
+ query: query,
12120
+ variables: variables,
12121
+ subscriptionState: _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].FAILED
12122
+ });
11979
12123
 
11980
- observer.complete();
11981
- }
12124
+ if (observer && !observer.closed) {
12125
+ observer.error({
12126
+ errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
12127
+ query: query,
12128
+ variables: variables
12129
+ })))]
12130
+ }); // Cleanup will be automatically executed
11982
12131
 
11983
- logger.debug('timeoutStartSubscription', JSON.stringify({
11984
- query: query,
11985
- variables: variables
11986
- }));
12132
+ observer.complete();
12133
+ }
12134
+
12135
+ logger.debug('timeoutStartSubscription', JSON.stringify({
12136
+ query: query,
12137
+ variables: variables
12138
+ }));
12139
+ }
11987
12140
  };
11988
12141
 
11989
12142
  AWSAppSyncRealTimeProvider.prototype._initializeWebSocketConnection = function (_a) {
@@ -11995,7 +12148,7 @@ function (_super) {
11995
12148
  region = _a.region,
11996
12149
  additionalHeaders = _a.additionalHeaders;
11997
12150
 
11998
- if (this.socketStatus === SOCKET_STATUS.READY) {
12151
+ if (this.socketStatus === _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].READY) {
11999
12152
  return;
12000
12153
  }
12001
12154
 
@@ -12010,7 +12163,7 @@ function (_super) {
12010
12163
  res: res,
12011
12164
  rej: rej
12012
12165
  });
12013
- if (!(this.socketStatus === SOCKET_STATUS.CLOSED)) return [3
12166
+ if (!(this.socketStatus === _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED)) return [3
12014
12167
  /*break*/
12015
12168
  , 5];
12016
12169
  _c.label = 1;
@@ -12018,7 +12171,7 @@ function (_super) {
12018
12171
  case 1:
12019
12172
  _c.trys.push([1, 4,, 5]);
12020
12173
 
12021
- this.socketStatus = SOCKET_STATUS.CONNECTING;
12174
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CONNECTING;
12022
12175
  payloadString = '{}';
12023
12176
  _b = (_a = JSON).stringify;
12024
12177
  return [4
@@ -12037,7 +12190,7 @@ function (_super) {
12037
12190
  headerString = _b.apply(_a, [_c.sent()]);
12038
12191
  headerQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(headerString).toString('base64');
12039
12192
  payloadQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(payloadString).toString('base64');
12040
- discoverableEndpoint = appSyncGraphqlEndpoint;
12193
+ discoverableEndpoint = appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '';
12041
12194
 
12042
12195
  if (this.isCustomDomain(discoverableEndpoint)) {
12043
12196
  discoverableEndpoint = discoverableEndpoint.concat(customDomainPath);
@@ -12050,9 +12203,7 @@ function (_super) {
12050
12203
  awsRealTimeUrl = discoverableEndpoint + "?header=" + headerQs + "&payload=" + payloadQs;
12051
12204
  return [4
12052
12205
  /*yield*/
12053
- , this._initializeRetryableHandshake({
12054
- awsRealTimeUrl: awsRealTimeUrl
12055
- })];
12206
+ , this._initializeRetryableHandshake(awsRealTimeUrl)];
12056
12207
 
12057
12208
  case 3:
12058
12209
  _c.sent();
@@ -12062,7 +12213,7 @@ function (_super) {
12062
12213
  logger.debug('Notifying connection successful');
12063
12214
  res();
12064
12215
  });
12065
- this.socketStatus = SOCKET_STATUS.READY;
12216
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].READY;
12066
12217
  this.promiseArray = [];
12067
12218
  return [3
12068
12219
  /*break*/
@@ -12080,8 +12231,8 @@ function (_super) {
12080
12231
  this.awsRealTimeSocket.close(3001);
12081
12232
  }
12082
12233
 
12083
- this.awsRealTimeSocket = null;
12084
- this.socketStatus = SOCKET_STATUS.CLOSED;
12234
+ this.awsRealTimeSocket = undefined;
12235
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
12085
12236
  return [3
12086
12237
  /*break*/
12087
12238
  , 5];
@@ -12096,21 +12247,18 @@ function (_super) {
12096
12247
  });
12097
12248
  };
12098
12249
 
12099
- AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (_a) {
12100
- var awsRealTimeUrl = _a.awsRealTimeUrl;
12250
+ AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (awsRealTimeUrl) {
12101
12251
  return __awaiter(this, void 0, void 0, function () {
12102
- return __generator(this, function (_b) {
12103
- switch (_b.label) {
12252
+ return __generator(this, function (_a) {
12253
+ switch (_a.label) {
12104
12254
  case 0:
12105
12255
  logger.debug("Initializaling retryable Handshake");
12106
12256
  return [4
12107
12257
  /*yield*/
12108
- , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [{
12109
- awsRealTimeUrl: awsRealTimeUrl
12110
- }], MAX_DELAY_MS)];
12258
+ , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [awsRealTimeUrl], _constants__WEBPACK_IMPORTED_MODULE_10__["MAX_DELAY_MS"])];
12111
12259
 
12112
12260
  case 1:
12113
- _b.sent();
12261
+ _a.sent();
12114
12262
 
12115
12263
  return [2
12116
12264
  /*return*/
@@ -12120,10 +12268,9 @@ function (_super) {
12120
12268
  });
12121
12269
  };
12122
12270
 
12123
- AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (_a) {
12124
- var awsRealTimeUrl = _a.awsRealTimeUrl;
12271
+ AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (awsRealTimeUrl) {
12125
12272
  return __awaiter(this, void 0, void 0, function () {
12126
- var err_4, errorType, errorCode;
12273
+ var err_4, _a, errorType, errorCode;
12127
12274
 
12128
12275
  var _this = this;
12129
12276
 
@@ -12140,7 +12287,7 @@ function (_super) {
12140
12287
  /*yield*/
12141
12288
  , function () {
12142
12289
  return new Promise(function (res, rej) {
12143
- var newSocket = new WebSocket(awsRealTimeUrl, 'graphql-ws');
12290
+ var newSocket = _this.getNewWebSocket(awsRealTimeUrl, 'graphql-ws');
12144
12291
 
12145
12292
  newSocket.onerror = function () {
12146
12293
  logger.debug("WebSocket connection error");
@@ -12165,77 +12312,82 @@ function (_super) {
12165
12312
  /*yield*/
12166
12313
  , function () {
12167
12314
  return new Promise(function (res, rej) {
12168
- var ackOk = false;
12315
+ if (_this.awsRealTimeSocket) {
12316
+ var ackOk_1 = false;
12169
12317
 
12170
- _this.awsRealTimeSocket.onerror = function (error) {
12171
- logger.debug("WebSocket error " + JSON.stringify(error));
12172
- };
12318
+ _this.awsRealTimeSocket.onerror = function (error) {
12319
+ logger.debug("WebSocket error " + JSON.stringify(error));
12320
+ };
12173
12321
 
12174
- _this.awsRealTimeSocket.onclose = function (event) {
12175
- logger.debug("WebSocket closed " + event.reason);
12176
- rej(new Error(JSON.stringify(event)));
12177
- };
12322
+ _this.awsRealTimeSocket.onclose = function (event) {
12323
+ logger.debug("WebSocket closed " + event.reason);
12324
+ rej(new Error(JSON.stringify(event)));
12325
+ };
12178
12326
 
12179
- _this.awsRealTimeSocket.onmessage = function (message) {
12180
- logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
12181
- var data = JSON.parse(message.data);
12182
- var type = data.type,
12183
- _a = data.payload,
12184
- _b = (_a === void 0 ? {} : _a).connectionTimeoutMs,
12185
- connectionTimeoutMs = _b === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _b;
12327
+ _this.awsRealTimeSocket.onmessage = function (message) {
12328
+ logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
12329
+ var data = JSON.parse(message.data);
12330
+ var type = data.type,
12331
+ _a = data.payload,
12332
+ _b = (_a === void 0 ? {} : _a).connectionTimeoutMs,
12333
+ connectionTimeoutMs = _b === void 0 ? _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_TIMEOUT"] : _b;
12186
12334
 
12187
- if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
12188
- ackOk = true;
12189
- _this.keepAliveTimeout = connectionTimeoutMs;
12190
- _this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
12335
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_ACK) {
12336
+ ackOk_1 = true;
12191
12337
 
12192
- _this.awsRealTimeSocket.onerror = function (err) {
12193
- logger.debug(err);
12338
+ if (_this.awsRealTimeSocket) {
12339
+ _this.keepAliveTimeout = connectionTimeoutMs;
12340
+ _this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
12194
12341
 
12195
- _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
12196
- };
12342
+ _this.awsRealTimeSocket.onerror = function (err) {
12343
+ logger.debug(err);
12197
12344
 
12198
- _this.awsRealTimeSocket.onclose = function (event) {
12199
- logger.debug("WebSocket closed " + event.reason);
12345
+ _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
12346
+ };
12200
12347
 
12201
- _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
12202
- };
12348
+ _this.awsRealTimeSocket.onclose = function (event) {
12349
+ logger.debug("WebSocket closed " + event.reason);
12203
12350
 
12204
- res('Cool, connected to AWS AppSyncRealTime');
12205
- return;
12206
- }
12351
+ _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
12352
+ };
12353
+ }
12207
12354
 
12208
- if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
12209
- var _c = data.payload,
12210
- _d = (_c === void 0 ? {} : _c).errors,
12211
- _e = __read(_d === void 0 ? [] : _d, 1),
12212
- _f = _e[0],
12213
- _g = _f === void 0 ? {} : _f,
12214
- _h = _g.errorType,
12215
- errorType = _h === void 0 ? '' : _h,
12216
- _j = _g.errorCode,
12217
- errorCode = _j === void 0 ? 0 : _j;
12218
-
12219
- rej({
12220
- errorType: errorType,
12221
- errorCode: errorCode
12222
- });
12223
- }
12224
- };
12355
+ res('Cool, connected to AWS AppSyncRealTime');
12356
+ return;
12357
+ }
12225
12358
 
12226
- var gqlInit = {
12227
- type: MESSAGE_TYPES.GQL_CONNECTION_INIT
12228
- };
12359
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_ERROR) {
12360
+ var _c = data.payload,
12361
+ _d = (_c === void 0 ? {} : _c).errors,
12362
+ _e = __read(_d === void 0 ? [] : _d, 1),
12363
+ _f = _e[0],
12364
+ _g = _f === void 0 ? {} : _f,
12365
+ _h = _g.errorType,
12366
+ errorType = _h === void 0 ? '' : _h,
12367
+ _j = _g.errorCode,
12368
+ errorCode = _j === void 0 ? 0 : _j;
12369
+
12370
+ rej({
12371
+ errorType: errorType,
12372
+ errorCode: errorCode
12373
+ });
12374
+ }
12375
+ };
12376
+
12377
+ var gqlInit = {
12378
+ type: _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_INIT
12379
+ };
12229
12380
 
12230
- _this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
12381
+ _this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
12231
12382
 
12232
- function checkAckOk() {
12383
+ setTimeout(checkAckOk.bind(_this, ackOk_1), _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"]);
12384
+ }
12385
+
12386
+ function checkAckOk(ackOk) {
12233
12387
  if (!ackOk) {
12234
- rej(new Error("Connection timeout: ack from AWSRealTime was not received on " + CONNECTION_INIT_TIMEOUT + " ms"));
12388
+ rej(new Error("Connection timeout: ack from AWSRealTime was not received on " + _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"] + " ms"));
12235
12389
  }
12236
12390
  }
12237
-
12238
- setTimeout(checkAckOk.bind(_this), CONNECTION_INIT_TIMEOUT);
12239
12391
  });
12240
12392
  }()];
12241
12393
 
@@ -12249,9 +12401,9 @@ function (_super) {
12249
12401
 
12250
12402
  case 4:
12251
12403
  err_4 = _b.sent();
12252
- errorType = err_4.errorType, errorCode = err_4.errorCode;
12404
+ _a = err_4, errorType = _a.errorType, errorCode = _a.errorCode;
12253
12405
 
12254
- if (NON_RETRYABLE_CODES.includes(errorCode)) {
12406
+ if (_constants__WEBPACK_IMPORTED_MODULE_10__["NON_RETRYABLE_CODES"].includes(errorCode)) {
12255
12407
  throw new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["NonRetryableError"](errorType);
12256
12408
  } else if (errorType) {
12257
12409
  throw new Error(errorType);
@@ -12292,16 +12444,18 @@ function (_super) {
12292
12444
  AMAZON_COGNITO_USER_POOLS: this._awsRealTimeCUPHeader.bind(this),
12293
12445
  AWS_LAMBDA: this._customAuthHeader
12294
12446
  };
12295
- handler = headerHandler[authenticationType];
12296
-
12297
- if (typeof handler !== 'function') {
12298
- logger.debug("Authentication type " + authenticationType + " not supported");
12299
- return [2
12300
- /*return*/
12301
- , ''];
12302
- }
12447
+ if (!(!authenticationType || !headerHandler[authenticationType])) return [3
12448
+ /*break*/
12449
+ , 1];
12450
+ logger.debug("Authentication type " + authenticationType + " not supported");
12451
+ return [2
12452
+ /*return*/
12453
+ , ''];
12303
12454
 
12304
- host = url__WEBPACK_IMPORTED_MODULE_2__["parse"](appSyncGraphqlEndpoint).host;
12455
+ case 1:
12456
+ handler = headerHandler[authenticationType];
12457
+ host = url__WEBPACK_IMPORTED_MODULE_2__["parse"](appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
12458
+ logger.debug("Authenticating with " + authenticationType);
12305
12459
  return [4
12306
12460
  /*yield*/
12307
12461
  , handler({
@@ -12314,7 +12468,7 @@ function (_super) {
12314
12468
  additionalHeaders: additionalHeaders
12315
12469
  })];
12316
12470
 
12317
- case 1:
12471
+ case 2:
12318
12472
  result = _b.sent();
12319
12473
  return [2
12320
12474
  /*return*/
@@ -12446,10 +12600,14 @@ function (_super) {
12446
12600
  return [4
12447
12601
  /*yield*/
12448
12602
  , _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Credentials"].get().then(function (credentials) {
12603
+ var _a = credentials,
12604
+ secretAccessKey = _a.secretAccessKey,
12605
+ accessKeyId = _a.accessKeyId,
12606
+ sessionToken = _a.sessionToken;
12449
12607
  return {
12450
- secret_key: credentials.secretAccessKey,
12451
- access_key: credentials.accessKeyId,
12452
- session_token: credentials.sessionToken
12608
+ secret_key: secretAccessKey,
12609
+ access_key: accessKeyId,
12610
+ session_token: sessionToken
12453
12611
  };
12454
12612
  })];
12455
12613
 
@@ -12459,7 +12617,7 @@ function (_super) {
12459
12617
  url: "" + appSyncGraphqlEndpoint + canonicalUri,
12460
12618
  data: payload,
12461
12619
  method: 'POST',
12462
- headers: __assign({}, AWS_APPSYNC_REALTIME_HEADERS)
12620
+ headers: __assign({}, _constants__WEBPACK_IMPORTED_MODULE_10__["AWS_APPSYNC_REALTIME_HEADERS"])
12463
12621
  };
12464
12622
  signed_params = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Signer"].sign(request, creds, endpointInfo);
12465
12623
  return [2
@@ -12474,7 +12632,7 @@ function (_super) {
12474
12632
  var host = _a.host,
12475
12633
  additionalHeaders = _a.additionalHeaders;
12476
12634
 
12477
- if (!additionalHeaders.Authorization) {
12635
+ if (!additionalHeaders || !additionalHeaders['Authorization']) {
12478
12636
  throw new Error('No auth token specified');
12479
12637
  }
12480
12638
 
@@ -12711,8 +12869,12 @@ var AWSIoTProvider =
12711
12869
  function (_super) {
12712
12870
  __extends(AWSIoTProvider, _super);
12713
12871
 
12714
- function AWSIoTProvider() {
12715
- return _super !== null && _super.apply(this, arguments) || this;
12872
+ function AWSIoTProvider(options) {
12873
+ if (options === void 0) {
12874
+ options = {};
12875
+ }
12876
+
12877
+ return _super.call(this, options) || this;
12716
12878
  }
12717
12879
 
12718
12880
  Object.defineProperty(AWSIoTProvider.prototype, "region", {
@@ -13042,21 +13204,27 @@ function () {
13042
13204
 
13043
13205
  ClientsQueue.prototype.get = function (clientId, clientFactory) {
13044
13206
  return __awaiter(this, void 0, void 0, function () {
13045
- var promise;
13207
+ var cachedPromise, newPromise;
13046
13208
  return __generator(this, function (_a) {
13047
- promise = this.promises.get(clientId);
13209
+ cachedPromise = this.promises.get(clientId);
13048
13210
 
13049
- if (promise) {
13211
+ if (cachedPromise) {
13050
13212
  return [2
13051
13213
  /*return*/
13052
- , promise];
13214
+ , cachedPromise];
13215
+ }
13216
+
13217
+ if (clientFactory) {
13218
+ newPromise = clientFactory(clientId);
13219
+ this.promises.set(clientId, newPromise);
13220
+ return [2
13221
+ /*return*/
13222
+ , newPromise];
13053
13223
  }
13054
13224
 
13055
- promise = clientFactory(clientId);
13056
- this.promises.set(clientId, promise);
13057
13225
  return [2
13058
13226
  /*return*/
13059
- , promise];
13227
+ , undefined];
13060
13228
  });
13061
13229
  });
13062
13230
  };
@@ -13148,6 +13316,10 @@ function (_super) {
13148
13316
  }, args), null, 2));
13149
13317
  var topicsToDelete_1 = [];
13150
13318
 
13319
+ if (!clientId) {
13320
+ return;
13321
+ }
13322
+
13151
13323
  var clientIdObservers = this._clientIdObservers.get(clientId);
13152
13324
 
13153
13325
  if (!clientIdObservers) {
@@ -13266,9 +13438,7 @@ function (_super) {
13266
13438
  case 0:
13267
13439
  return [4
13268
13440
  /*yield*/
13269
- , this.clientsQueue.get(clientId, function () {
13270
- return null;
13271
- })];
13441
+ , this.clientsQueue.get(clientId)];
13272
13442
 
13273
13443
  case 1:
13274
13444
  client = _a.sent();
@@ -13447,13 +13617,14 @@ function (_super) {
13447
13617
  })();
13448
13618
 
13449
13619
  return function () {
13620
+ var _a, _b;
13621
+
13450
13622
  logger.debug('Unsubscribing from topic(s)', targetTopics.join(','));
13451
13623
 
13452
13624
  if (client) {
13453
- _this._clientIdObservers.get(clientId)["delete"](observer); // No more observers per client => client not needed anymore
13454
-
13625
+ (_a = _this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
13455
13626
 
13456
- if (_this._clientIdObservers.get(clientId).size === 0) {
13627
+ if (((_b = _this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
13457
13628
  _this.disconnect(clientId);
13458
13629
 
13459
13630
  _this._clientIdObservers["delete"](clientId);
@@ -13570,7 +13741,7 @@ __webpack_require__.r(__webpack_exports__);
13570
13741
  /* harmony import */ var _AWSAppSyncProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AWSAppSyncProvider */ "../pubsub/lib-esm/Providers/AWSAppSyncProvider.js");
13571
13742
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AWSAppSyncProvider", function() { return _AWSAppSyncProvider__WEBPACK_IMPORTED_MODULE_1__["AWSAppSyncProvider"]; });
13572
13743
 
13573
- /* harmony import */ var _AWSAppSyncRealTimeProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./AWSAppSyncRealTimeProvider */ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js");
13744
+ /* harmony import */ var _AWSAppSyncRealTimeProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./AWSAppSyncRealTimeProvider */ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js");
13574
13745
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AWSAppSyncRealTimeProvider", function() { return _AWSAppSyncRealTimeProvider__WEBPACK_IMPORTED_MODULE_2__["AWSAppSyncRealTimeProvider"]; });
13575
13746
 
13576
13747
  /* harmony import */ var _AWSIotProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./AWSIotProvider */ "../pubsub/lib-esm/Providers/AWSIotProvider.js");
@@ -13788,7 +13959,7 @@ function () {
13788
13959
  * @param {PubSubOptions} options - Configuration object for PubSub
13789
13960
  */
13790
13961
  function PubSubClass(options) {
13791
- this._options = options;
13962
+ this._options = options !== null && options !== void 0 ? options : {};
13792
13963
  logger.debug('PubSub Options', this._options);
13793
13964
  this._pluggables = [];
13794
13965
  this.subscribe = this.subscribe.bind(this);
@@ -13977,7 +14148,7 @@ function () {
13977
14148
  }();
13978
14149
 
13979
14150
 
13980
- var PubSub = new PubSubClass(null);
14151
+ var PubSub = new PubSubClass();
13981
14152
  _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
13982
14153
 
13983
14154
  /***/ }),
@@ -14285,7 +14456,7 @@ var __read = undefined && undefined.__read || function (o, n) {
14285
14456
 
14286
14457
  var USER_AGENT_HEADER = 'x-amz-user-agent';
14287
14458
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('GraphQLAPI');
14288
- var graphqlOperation = function graphqlOperation(query, variables, authToken) {
14459
+ var graphqlOperation = function graphqlOperation(query, variables, authToken, userAgentSuffix) {
14289
14460
  if (variables === void 0) {
14290
14461
  variables = {};
14291
14462
  }
@@ -14293,7 +14464,8 @@ var graphqlOperation = function graphqlOperation(query, variables, authToken) {
14293
14464
  return {
14294
14465
  query: query,
14295
14466
  variables: variables,
14296
- authToken: authToken
14467
+ authToken: authToken,
14468
+ userAgentSuffix: userAgentSuffix
14297
14469
  };
14298
14470
  };
14299
14471
  /**
@@ -14573,9 +14745,9 @@ function () {
14573
14745
  /**
14574
14746
  * Executes a GraphQL operation
14575
14747
  *
14576
- * @param {GraphQLOptions} GraphQL Options
14577
- * @param {object} additionalHeaders headers to merge in after any `graphql_headers` set in the config
14578
- * @returns {Promise<GraphQLResult> | Observable<object>}
14748
+ * @param options - GraphQL Options
14749
+ * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
14750
+ * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
14579
14751
  */
14580
14752
 
14581
14753
 
@@ -14584,7 +14756,8 @@ function () {
14584
14756
  _b = _a.variables,
14585
14757
  variables = _b === void 0 ? {} : _b,
14586
14758
  authMode = _a.authMode,
14587
- authToken = _a.authToken;
14759
+ authToken = _a.authToken,
14760
+ userAgentSuffix = _a.userAgentSuffix;
14588
14761
  var query = typeof paramQuery === 'string' ? Object(graphql__WEBPACK_IMPORTED_MODULE_0__["parse"])(paramQuery) : Object(graphql__WEBPACK_IMPORTED_MODULE_0__["parse"])(Object(graphql__WEBPACK_IMPORTED_MODULE_0__["print"])(paramQuery));
14589
14762
 
14590
14763
  var _c = __read(query.definitions.filter(function (def) {
@@ -14612,7 +14785,8 @@ function () {
14612
14785
  var responsePromise = this._graphql({
14613
14786
  query: query,
14614
14787
  variables: variables,
14615
- authMode: authMode
14788
+ authMode: authMode,
14789
+ userAgentSuffix: userAgentSuffix
14616
14790
  }, headers, initParams);
14617
14791
 
14618
14792
  this._api.updateRequestToBeCancellable(responsePromise, cancellableToken);
@@ -14625,15 +14799,17 @@ function () {
14625
14799
  variables: variables,
14626
14800
  authMode: authMode
14627
14801
  }, headers);
14628
- }
14629
14802
 
14630
- throw new Error("invalid operation type: " + operationType);
14803
+ default:
14804
+ throw new Error("invalid operation type: " + operationType);
14805
+ }
14631
14806
  };
14632
14807
 
14633
14808
  GraphQLAPIClass.prototype._graphql = function (_a, additionalHeaders, initParams) {
14634
14809
  var query = _a.query,
14635
14810
  variables = _a.variables,
14636
- authMode = _a.authMode;
14811
+ authMode = _a.authMode,
14812
+ userAgentSuffix = _a.userAgentSuffix;
14637
14813
 
14638
14814
  if (additionalHeaders === void 0) {
14639
14815
  additionalHeaders = {};
@@ -14719,7 +14895,7 @@ function () {
14719
14895
  })];
14720
14896
 
14721
14897
  case 9:
14722
- headers = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _j.concat([_l.sent()])), additionalHeaders]), !customGraphqlEndpoint && (_k = {}, _k[USER_AGENT_HEADER] = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Constants"].userAgent, _k)]);
14898
+ headers = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _j.concat([_l.sent()])), additionalHeaders]), !customGraphqlEndpoint && (_k = {}, _k[USER_AGENT_HEADER] = Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["getAmplifyUserAgent"])(userAgentSuffix), _k)]);
14723
14899
  body = {
14724
14900
  query: Object(graphql__WEBPACK_IMPORTED_MODULE_0__["print"])(query),
14725
14901
  variables: variables
@@ -14808,6 +14984,16 @@ function () {
14808
14984
  GraphQLAPIClass.prototype.cancel = function (request, message) {
14809
14985
  return this._api.cancel(request, message);
14810
14986
  };
14987
+ /**
14988
+ * Check if the request has a corresponding cancel token in the WeakMap.
14989
+ * @params request - The request promise
14990
+ * @return if the request has a corresponding cancel token.
14991
+ */
14992
+
14993
+
14994
+ GraphQLAPIClass.prototype.hasCancelToken = function (request) {
14995
+ return this._api.hasCancelToken(request);
14996
+ };
14811
14997
 
14812
14998
  GraphQLAPIClass.prototype._graphqlSubscribe = function (_a, additionalHeaders) {
14813
14999
  var query = _a.query,
@@ -14928,17 +15114,12 @@ __webpack_require__.r(__webpack_exports__);
14928
15114
 
14929
15115
  "use strict";
14930
15116
  __webpack_require__.r(__webpack_exports__);
14931
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return GRAPHQL_AUTH_MODE; });
14932
15117
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GraphQLAuthError", function() { return GraphQLAuthError; });
14933
- var GRAPHQL_AUTH_MODE;
14934
-
14935
- (function (GRAPHQL_AUTH_MODE) {
14936
- GRAPHQL_AUTH_MODE["API_KEY"] = "API_KEY";
14937
- GRAPHQL_AUTH_MODE["AWS_IAM"] = "AWS_IAM";
14938
- GRAPHQL_AUTH_MODE["OPENID_CONNECT"] = "OPENID_CONNECT";
14939
- GRAPHQL_AUTH_MODE["AMAZON_COGNITO_USER_POOLS"] = "AMAZON_COGNITO_USER_POOLS";
14940
- GRAPHQL_AUTH_MODE["AWS_LAMBDA"] = "AWS_LAMBDA";
14941
- })(GRAPHQL_AUTH_MODE || (GRAPHQL_AUTH_MODE = {}));
15118
+ /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
15119
+ /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__);
15120
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"]; });
15121
+
15122
+
14942
15123
 
14943
15124
  var GraphQLAuthError;
14944
15125