@aws-amplify/api 4.0.29-unstable.4 → 4.0.30-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,52 +1057,75 @@ 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
- }
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
+ };
1122
+
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);
1009
1127
  });
1010
1128
 
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
- });
1022
-
1023
- utils.forEach(otherKeys, mergeDeepProperties);
1024
-
1025
1129
  return config;
1026
1130
  };
1027
1131
 
@@ -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":
@@ -9601,7 +9686,7 @@ var __read = undefined && undefined.__read || function (o, n) {
9601
9686
 
9602
9687
  var USER_AGENT_HEADER = 'x-amz-user-agent';
9603
9688
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('GraphQLAPI');
9604
- var graphqlOperation = function graphqlOperation(query, variables, authToken) {
9689
+ var graphqlOperation = function graphqlOperation(query, variables, authToken, userAgentSuffix) {
9605
9690
  if (variables === void 0) {
9606
9691
  variables = {};
9607
9692
  }
@@ -9609,7 +9694,8 @@ var graphqlOperation = function graphqlOperation(query, variables, authToken) {
9609
9694
  return {
9610
9695
  query: query,
9611
9696
  variables: variables,
9612
- authToken: authToken
9697
+ authToken: authToken,
9698
+ userAgentSuffix: userAgentSuffix
9613
9699
  };
9614
9700
  };
9615
9701
  /**
@@ -9889,9 +9975,9 @@ function () {
9889
9975
  /**
9890
9976
  * Executes a GraphQL operation
9891
9977
  *
9892
- * @param {GraphQLOptions} GraphQL Options
9893
- * @param {object} additionalHeaders headers to merge in after any `graphql_headers` set in the config
9894
- * @returns {Promise<GraphQLResult> | Observable<object>}
9978
+ * @param options - GraphQL Options
9979
+ * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
9980
+ * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
9895
9981
  */
9896
9982
 
9897
9983
 
@@ -9900,7 +9986,8 @@ function () {
9900
9986
  _b = _a.variables,
9901
9987
  variables = _b === void 0 ? {} : _b,
9902
9988
  authMode = _a.authMode,
9903
- authToken = _a.authToken;
9989
+ authToken = _a.authToken,
9990
+ userAgentSuffix = _a.userAgentSuffix;
9904
9991
  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));
9905
9992
 
9906
9993
  var _c = __read(query.definitions.filter(function (def) {
@@ -9928,7 +10015,8 @@ function () {
9928
10015
  var responsePromise = this._graphql({
9929
10016
  query: query,
9930
10017
  variables: variables,
9931
- authMode: authMode
10018
+ authMode: authMode,
10019
+ userAgentSuffix: userAgentSuffix
9932
10020
  }, headers, initParams);
9933
10021
 
9934
10022
  this._api.updateRequestToBeCancellable(responsePromise, cancellableToken);
@@ -9941,15 +10029,17 @@ function () {
9941
10029
  variables: variables,
9942
10030
  authMode: authMode
9943
10031
  }, headers);
9944
- }
9945
10032
 
9946
- throw new Error("invalid operation type: " + operationType);
10033
+ default:
10034
+ throw new Error("invalid operation type: " + operationType);
10035
+ }
9947
10036
  };
9948
10037
 
9949
10038
  GraphQLAPIClass.prototype._graphql = function (_a, additionalHeaders, initParams) {
9950
10039
  var query = _a.query,
9951
10040
  variables = _a.variables,
9952
- authMode = _a.authMode;
10041
+ authMode = _a.authMode,
10042
+ userAgentSuffix = _a.userAgentSuffix;
9953
10043
 
9954
10044
  if (additionalHeaders === void 0) {
9955
10045
  additionalHeaders = {};
@@ -10035,7 +10125,7 @@ function () {
10035
10125
  })];
10036
10126
 
10037
10127
  case 9:
10038
- 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)]);
10128
+ 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)]);
10039
10129
  body = {
10040
10130
  query: Object(graphql__WEBPACK_IMPORTED_MODULE_0__["print"])(query),
10041
10131
  variables: variables
@@ -10124,6 +10214,16 @@ function () {
10124
10214
  GraphQLAPIClass.prototype.cancel = function (request, message) {
10125
10215
  return this._api.cancel(request, message);
10126
10216
  };
10217
+ /**
10218
+ * Check if the request has a corresponding cancel token in the WeakMap.
10219
+ * @params request - The request promise
10220
+ * @return if the request has a corresponding cancel token.
10221
+ */
10222
+
10223
+
10224
+ GraphQLAPIClass.prototype.hasCancelToken = function (request) {
10225
+ return this._api.hasCancelToken(request);
10226
+ };
10127
10227
 
10128
10228
  GraphQLAPIClass.prototype._graphqlSubscribe = function (_a, additionalHeaders) {
10129
10229
  var query = _a.query,
@@ -10244,17 +10344,12 @@ __webpack_require__.r(__webpack_exports__);
10244
10344
 
10245
10345
  "use strict";
10246
10346
  __webpack_require__.r(__webpack_exports__);
10247
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return GRAPHQL_AUTH_MODE; });
10248
10347
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GraphQLAuthError", function() { return GraphQLAuthError; });
10249
- var GRAPHQL_AUTH_MODE;
10348
+ /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
10349
+ /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__);
10350
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"]; });
10351
+
10250
10352
 
10251
- (function (GRAPHQL_AUTH_MODE) {
10252
- GRAPHQL_AUTH_MODE["API_KEY"] = "API_KEY";
10253
- GRAPHQL_AUTH_MODE["AWS_IAM"] = "AWS_IAM";
10254
- GRAPHQL_AUTH_MODE["OPENID_CONNECT"] = "OPENID_CONNECT";
10255
- GRAPHQL_AUTH_MODE["AMAZON_COGNITO_USER_POOLS"] = "AMAZON_COGNITO_USER_POOLS";
10256
- GRAPHQL_AUTH_MODE["AWS_LAMBDA"] = "AWS_LAMBDA";
10257
- })(GRAPHQL_AUTH_MODE || (GRAPHQL_AUTH_MODE = {}));
10258
10353
 
10259
10354
  var GraphQLAuthError;
10260
10355
 
@@ -10735,6 +10830,16 @@ function () {
10735
10830
  RestAPIClass.prototype.cancel = function (request, message) {
10736
10831
  return this._api.cancel(request, message);
10737
10832
  };
10833
+ /**
10834
+ * Check if the request has a corresponding cancel token in the WeakMap.
10835
+ * @params request - The request promise
10836
+ * @return if the request has a corresponding cancel token.
10837
+ */
10838
+
10839
+
10840
+ RestAPIClass.prototype.hasCancelToken = function (request) {
10841
+ return this._api.hasCancelToken(request);
10842
+ };
10738
10843
  /**
10739
10844
  * Getting endpoint for API
10740
10845
  * @param {string} apiName - The name of the api
@@ -11300,9 +11405,20 @@ function () {
11300
11405
 
11301
11406
  if (source) {
11302
11407
  source.cancel(message);
11408
+ return true;
11303
11409
  }
11304
11410
 
11305
- return true;
11411
+ return false;
11412
+ };
11413
+ /**
11414
+ * Check if the request has a corresponding cancel token in the WeakMap.
11415
+ * @params request - The request promise
11416
+ * @return if the request has a corresponding cancel token.
11417
+ */
11418
+
11419
+
11420
+ RestClient.prototype.hasCancelToken = function (request) {
11421
+ return this._cancelTokenMap.has(request);
11306
11422
  };
11307
11423
  /**
11308
11424
  * Checks to see if an error thrown is from an api request cancellation
@@ -11712,6 +11828,9 @@ var __spread = undefined && undefined.__spread || function () {
11712
11828
 
11713
11829
 
11714
11830
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('AWSAppSyncProvider');
11831
+ /**
11832
+ * @deprecated Unused, all usecases have migrated to AWSAppSyncRealtimeProvider
11833
+ */
11715
11834
 
11716
11835
  var AWSAppSyncProvider =
11717
11836
  /** @class */
@@ -12018,10 +12137,135 @@ function (_super) {
12018
12137
 
12019
12138
  /***/ }),
12020
12139
 
12021
- /***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js":
12022
- /*!*****************************************************************!*\
12023
- !*** ../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js ***!
12024
- \*****************************************************************/
12140
+ /***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js":
12141
+ /*!***************************************************************************!*\
12142
+ !*** ../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js ***!
12143
+ \***************************************************************************/
12144
+ /*! 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 */
12145
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
12146
+
12147
+ "use strict";
12148
+ __webpack_require__.r(__webpack_exports__);
12149
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
12150
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
12151
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
12152
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
12153
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
12154
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
12155
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
12156
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
12157
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
12158
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
12159
+ var MAX_DELAY_MS = 5000;
12160
+ var NON_RETRYABLE_CODES = [400, 401, 403];
12161
+ var MESSAGE_TYPES;
12162
+
12163
+ (function (MESSAGE_TYPES) {
12164
+ /**
12165
+ * Client -> Server message.
12166
+ * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
12167
+ */
12168
+ MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
12169
+ /**
12170
+ * Server -> Client message
12171
+ * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
12172
+ */
12173
+
12174
+ MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
12175
+ /**
12176
+ * Server -> Client message.
12177
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
12178
+ */
12179
+
12180
+ MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
12181
+ /**
12182
+ * Client -> Server message.
12183
+ * This message type is for register subscriptions with AWS AppSync RealTime
12184
+ */
12185
+
12186
+ MESSAGE_TYPES["GQL_START"] = "start";
12187
+ /**
12188
+ * Server -> Client message.
12189
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
12190
+ */
12191
+
12192
+ MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
12193
+ /**
12194
+ * Server -> Client message.
12195
+ * This message type is for subscription message from AWS AppSync RealTime
12196
+ */
12197
+
12198
+ MESSAGE_TYPES["GQL_DATA"] = "data";
12199
+ /**
12200
+ * Server -> Client message.
12201
+ * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
12202
+ */
12203
+
12204
+ MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
12205
+ /**
12206
+ * Client -> Server message.
12207
+ * This message type is for unregister subscriptions with AWS AppSync RealTime
12208
+ */
12209
+
12210
+ MESSAGE_TYPES["GQL_STOP"] = "stop";
12211
+ /**
12212
+ * Server -> Client message.
12213
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
12214
+ */
12215
+
12216
+ MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
12217
+ /**
12218
+ * Server -> Client message.
12219
+ * This message type is for sending error messages from AWS AppSync RealTime to the client
12220
+ */
12221
+
12222
+ MESSAGE_TYPES["GQL_ERROR"] = "error";
12223
+ })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
12224
+
12225
+ var SUBSCRIPTION_STATUS;
12226
+
12227
+ (function (SUBSCRIPTION_STATUS) {
12228
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
12229
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
12230
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
12231
+ })(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
12232
+
12233
+ var SOCKET_STATUS;
12234
+
12235
+ (function (SOCKET_STATUS) {
12236
+ SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
12237
+ SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
12238
+ SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
12239
+ })(SOCKET_STATUS || (SOCKET_STATUS = {}));
12240
+
12241
+ var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
12242
+ var AWS_APPSYNC_REALTIME_HEADERS = {
12243
+ accept: 'application/json, text/javascript',
12244
+ 'content-encoding': 'amz-1.0',
12245
+ 'content-type': 'application/json; charset=UTF-8'
12246
+ };
12247
+ /**
12248
+ * Time in milleseconds to wait for GQL_CONNECTION_INIT message
12249
+ */
12250
+
12251
+ var CONNECTION_INIT_TIMEOUT = 15000;
12252
+ /**
12253
+ * Time in milleseconds to wait for GQL_START_ACK message
12254
+ */
12255
+
12256
+ var START_ACK_TIMEOUT = 15000;
12257
+ /**
12258
+ * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
12259
+ */
12260
+
12261
+ var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
12262
+
12263
+ /***/ }),
12264
+
12265
+ /***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js":
12266
+ /*!***********************************************************************!*\
12267
+ !*** ../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js ***!
12268
+ \***********************************************************************/
12025
12269
  /*! exports provided: AWSAppSyncRealTimeProvider */
12026
12270
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
12027
12271
 
@@ -12043,8 +12287,9 @@ __webpack_require__.r(__webpack_exports__);
12043
12287
  /* harmony import */ var _aws_amplify_cache__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_cache__WEBPACK_IMPORTED_MODULE_6__);
12044
12288
  /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
12045
12289
  /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__);
12046
- /* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
12047
- /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../index */ "../pubsub/lib-esm/index.js");
12290
+ /* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
12291
+ /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../index */ "../pubsub/lib-esm/index.js");
12292
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./constants */ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js");
12048
12293
  var __extends = undefined && undefined.__extends || function () {
12049
12294
  var _extendStatics = function extendStatics(d, b) {
12050
12295
  _extendStatics = Object.setPrototypeOf || {
@@ -12280,119 +12525,17 @@ var __read = undefined && undefined.__read || function (o, n) {
12280
12525
 
12281
12526
 
12282
12527
 
12528
+
12283
12529
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Logger"]('AWSAppSyncRealTimeProvider');
12284
- var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
12285
12530
 
12286
12531
  var dispatchApiEvent = function dispatchApiEvent(event, data, message) {
12287
12532
  _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Hub"].dispatch('api', {
12288
12533
  event: event,
12289
12534
  data: data,
12290
12535
  message: message
12291
- }, 'PubSub', AMPLIFY_SYMBOL);
12536
+ }, 'PubSub', _constants__WEBPACK_IMPORTED_MODULE_10__["AMPLIFY_SYMBOL"]);
12292
12537
  };
12293
12538
 
12294
- var MAX_DELAY_MS = 5000;
12295
- var NON_RETRYABLE_CODES = [400, 401, 403];
12296
- var MESSAGE_TYPES;
12297
-
12298
- (function (MESSAGE_TYPES) {
12299
- /**
12300
- * Client -> Server message.
12301
- * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
12302
- */
12303
- MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
12304
- /**
12305
- * Server -> Client message
12306
- * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
12307
- */
12308
-
12309
- MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
12310
- /**
12311
- * Server -> Client message.
12312
- * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
12313
- */
12314
-
12315
- MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
12316
- /**
12317
- * Client -> Server message.
12318
- * This message type is for register subscriptions with AWS AppSync RealTime
12319
- */
12320
-
12321
- MESSAGE_TYPES["GQL_START"] = "start";
12322
- /**
12323
- * Server -> Client message.
12324
- * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
12325
- */
12326
-
12327
- MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
12328
- /**
12329
- * Server -> Client message.
12330
- * This message type is for subscription message from AWS AppSync RealTime
12331
- */
12332
-
12333
- MESSAGE_TYPES["GQL_DATA"] = "data";
12334
- /**
12335
- * Server -> Client message.
12336
- * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
12337
- */
12338
-
12339
- MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
12340
- /**
12341
- * Client -> Server message.
12342
- * This message type is for unregister subscriptions with AWS AppSync RealTime
12343
- */
12344
-
12345
- MESSAGE_TYPES["GQL_STOP"] = "stop";
12346
- /**
12347
- * Server -> Client message.
12348
- * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
12349
- */
12350
-
12351
- MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
12352
- /**
12353
- * Server -> Client message.
12354
- * This message type is for sending error messages from AWS AppSync RealTime to the client
12355
- */
12356
-
12357
- MESSAGE_TYPES["GQL_ERROR"] = "error";
12358
- })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
12359
-
12360
- var SUBSCRIPTION_STATUS;
12361
-
12362
- (function (SUBSCRIPTION_STATUS) {
12363
- SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
12364
- SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
12365
- SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
12366
- })(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
12367
-
12368
- var SOCKET_STATUS;
12369
-
12370
- (function (SOCKET_STATUS) {
12371
- SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
12372
- SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
12373
- SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
12374
- })(SOCKET_STATUS || (SOCKET_STATUS = {}));
12375
-
12376
- var AWS_APPSYNC_REALTIME_HEADERS = {
12377
- accept: 'application/json, text/javascript',
12378
- 'content-encoding': 'amz-1.0',
12379
- 'content-type': 'application/json; charset=UTF-8'
12380
- };
12381
- /**
12382
- * Time in milleseconds to wait for GQL_CONNECTION_INIT message
12383
- */
12384
-
12385
- var CONNECTION_INIT_TIMEOUT = 15000;
12386
- /**
12387
- * Time in milleseconds to wait for GQL_START_ACK message
12388
- */
12389
-
12390
- var START_ACK_TIMEOUT = 15000;
12391
- /**
12392
- * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
12393
- */
12394
-
12395
- var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
12396
12539
  var standardDomainPattern = /^https:\/\/\w{26}\.appsync\-api\.\w{2}(?:(?:\-\w{2,})+)\-\d\.amazonaws.com\/graphql$/i;
12397
12540
  var customDomainPath = '/realtime';
12398
12541
 
@@ -12404,13 +12547,17 @@ function (_super) {
12404
12547
  function AWSAppSyncRealTimeProvider() {
12405
12548
  var _this = _super !== null && _super.apply(this, arguments) || this;
12406
12549
 
12407
- _this.socketStatus = SOCKET_STATUS.CLOSED;
12408
- _this.keepAliveTimeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
12550
+ _this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
12551
+ _this.keepAliveTimeout = _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_TIMEOUT"];
12409
12552
  _this.subscriptionObserverMap = new Map();
12410
12553
  _this.promiseArray = [];
12411
12554
  return _this;
12412
12555
  }
12413
12556
 
12557
+ AWSAppSyncRealTimeProvider.prototype.getNewWebSocket = function (url, protocol) {
12558
+ return new WebSocket(url, protocol);
12559
+ };
12560
+
12414
12561
  AWSAppSyncRealTimeProvider.prototype.getProviderName = function () {
12415
12562
  return 'AWSAppSyncRealTimeProvider';
12416
12563
  };
@@ -12435,9 +12582,9 @@ function (_super) {
12435
12582
  AWSAppSyncRealTimeProvider.prototype.subscribe = function (_topics, options) {
12436
12583
  var _this = this;
12437
12584
 
12438
- var appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint;
12585
+ var appSyncGraphqlEndpoint = options === null || options === void 0 ? void 0 : options.appSyncGraphqlEndpoint;
12439
12586
  return new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (observer) {
12440
- if (!appSyncGraphqlEndpoint) {
12587
+ if (!options || !appSyncGraphqlEndpoint) {
12441
12588
  observer.error({
12442
12589
  errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscribe only available for AWS AppSync endpoint"))]
12443
12590
  });
@@ -12482,7 +12629,7 @@ function (_super) {
12482
12629
  ];
12483
12630
  }
12484
12631
 
12485
- if (subscriptionState === SUBSCRIPTION_STATUS.CONNECTED) {
12632
+ if (subscriptionState === _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].CONNECTED) {
12486
12633
  this._sendUnsubscriptionMessage(subscriptionId_1);
12487
12634
  } else {
12488
12635
  throw new Error('Subscription never connected');
@@ -12530,20 +12677,23 @@ function (_super) {
12530
12677
  var options = _a.options,
12531
12678
  observer = _a.observer,
12532
12679
  subscriptionId = _a.subscriptionId;
12680
+
12681
+ var _b, _c;
12682
+
12533
12683
  return __awaiter(this, void 0, void 0, function () {
12534
- 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;
12684
+ 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;
12535
12685
 
12536
- var _h;
12686
+ var _j;
12537
12687
 
12538
12688
  var _this = this;
12539
12689
 
12540
- return __generator(this, function (_j) {
12541
- switch (_j.label) {
12690
+ return __generator(this, function (_k) {
12691
+ switch (_k.label) {
12542
12692
  case 0:
12543
- 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 () {
12693
+ 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 () {
12544
12694
  return {};
12545
- } : _b, _c = options.additionalHeaders, additionalHeaders = _c === void 0 ? {} : _c;
12546
- subscriptionState = SUBSCRIPTION_STATUS.PENDING;
12695
+ } : _d, _e = options.additionalHeaders, additionalHeaders = _e === void 0 ? {} : _e;
12696
+ subscriptionState = _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].PENDING;
12547
12697
  data = {
12548
12698
  query: query,
12549
12699
  variables: variables
@@ -12551,13 +12701,13 @@ function (_super) {
12551
12701
 
12552
12702
  this.subscriptionObserverMap.set(subscriptionId, {
12553
12703
  observer: observer,
12554
- query: query,
12555
- variables: variables,
12704
+ query: query !== null && query !== void 0 ? query : '',
12705
+ variables: variables !== null && variables !== void 0 ? variables : {},
12556
12706
  subscriptionState: subscriptionState,
12557
- startAckTimeoutId: null
12707
+ startAckTimeoutId: undefined
12558
12708
  });
12559
12709
  dataString = JSON.stringify(data);
12560
- _d = [{}];
12710
+ _f = [{}];
12561
12711
  return [4
12562
12712
  /*yield*/
12563
12713
  , this._awsRealTimeHeaderBasedAuth({
@@ -12571,13 +12721,13 @@ function (_super) {
12571
12721
  })];
12572
12722
 
12573
12723
  case 1:
12574
- _e = [__assign.apply(void 0, _d.concat([_j.sent()]))];
12724
+ _g = [__assign.apply(void 0, _f.concat([_k.sent()]))];
12575
12725
  return [4
12576
12726
  /*yield*/
12577
12727
  , graphql_headers()];
12578
12728
 
12579
12729
  case 2:
12580
- 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)]);
12730
+ 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)]);
12581
12731
  subscriptionMessage = {
12582
12732
  id: subscriptionId,
12583
12733
  payload: {
@@ -12586,13 +12736,13 @@ function (_super) {
12586
12736
  authorization: __assign({}, headerObj)
12587
12737
  }
12588
12738
  },
12589
- type: MESSAGE_TYPES.GQL_START
12739
+ type: _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_START
12590
12740
  };
12591
12741
  stringToAWSRealTime = JSON.stringify(subscriptionMessage);
12592
- _j.label = 3;
12742
+ _k.label = 3;
12593
12743
 
12594
12744
  case 3:
12595
- _j.trys.push([3, 5,, 6]);
12745
+ _k.trys.push([3, 5,, 6]);
12596
12746
 
12597
12747
  return [4
12598
12748
  /*yield*/
@@ -12605,18 +12755,18 @@ function (_super) {
12605
12755
  })];
12606
12756
 
12607
12757
  case 4:
12608
- _j.sent();
12758
+ _k.sent();
12609
12759
 
12610
12760
  return [3
12611
12761
  /*break*/
12612
12762
  , 6];
12613
12763
 
12614
12764
  case 5:
12615
- err_2 = _j.sent();
12765
+ err_2 = _k.sent();
12616
12766
  logger.debug({
12617
12767
  err: err_2
12618
12768
  });
12619
- _f = err_2.message, message = _f === void 0 ? '' : _f;
12769
+ message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
12620
12770
  observer.error({
12621
12771
  errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
12622
12772
  });
@@ -12632,18 +12782,18 @@ function (_super) {
12632
12782
  ];
12633
12783
 
12634
12784
  case 6:
12635
- _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
12785
+ _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
12636
12786
 
12637
12787
  this.subscriptionObserverMap.set(subscriptionId, {
12638
12788
  observer: observer,
12639
12789
  subscriptionState: subscriptionState,
12640
- variables: variables,
12641
- query: query,
12790
+ query: query !== null && query !== void 0 ? query : '',
12791
+ variables: variables !== null && variables !== void 0 ? variables : {},
12642
12792
  subscriptionReadyCallback: subscriptionReadyCallback,
12643
12793
  subscriptionFailedCallback: subscriptionFailedCallback,
12644
12794
  startAckTimeoutId: setTimeout(function () {
12645
12795
  _this._timeoutStartSubscriptionAck.call(_this, subscriptionId);
12646
- }, START_ACK_TIMEOUT)
12796
+ }, _constants__WEBPACK_IMPORTED_MODULE_10__["START_ACK_TIMEOUT"])
12647
12797
  });
12648
12798
 
12649
12799
  if (this.awsRealTimeSocket) {
@@ -12661,32 +12811,35 @@ function (_super) {
12661
12811
 
12662
12812
  AWSAppSyncRealTimeProvider.prototype._waitForSubscriptionToBeConnected = function (subscriptionId) {
12663
12813
  return __awaiter(this, void 0, void 0, function () {
12664
- var subscriptionState;
12814
+ var subscriptionObserver, subscriptionState;
12665
12815
 
12666
12816
  var _this = this;
12667
12817
 
12668
12818
  return __generator(this, function (_a) {
12669
- subscriptionState = this.subscriptionObserverMap.get(subscriptionId).subscriptionState; // This in case unsubscribe is invoked before sending start subscription message
12819
+ subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
12670
12820
 
12671
- if (subscriptionState === SUBSCRIPTION_STATUS.PENDING) {
12672
- return [2
12673
- /*return*/
12674
- , new Promise(function (res, rej) {
12675
- var _a = _this.subscriptionObserverMap.get(subscriptionId),
12676
- observer = _a.observer,
12677
- subscriptionState = _a.subscriptionState,
12678
- variables = _a.variables,
12679
- query = _a.query;
12680
-
12681
- _this.subscriptionObserverMap.set(subscriptionId, {
12682
- observer: observer,
12683
- subscriptionState: subscriptionState,
12684
- variables: variables,
12685
- query: query,
12686
- subscriptionReadyCallback: res,
12687
- subscriptionFailedCallback: rej
12688
- });
12689
- })];
12821
+ if (subscriptionObserver) {
12822
+ subscriptionState = subscriptionObserver.subscriptionState; // This in case unsubscribe is invoked before sending start subscription message
12823
+
12824
+ if (subscriptionState === _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].PENDING) {
12825
+ return [2
12826
+ /*return*/
12827
+ , new Promise(function (res, rej) {
12828
+ var observer = subscriptionObserver.observer,
12829
+ subscriptionState = subscriptionObserver.subscriptionState,
12830
+ variables = subscriptionObserver.variables,
12831
+ query = subscriptionObserver.query;
12832
+
12833
+ _this.subscriptionObserverMap.set(subscriptionId, {
12834
+ observer: observer,
12835
+ subscriptionState: subscriptionState,
12836
+ variables: variables,
12837
+ query: query,
12838
+ subscriptionReadyCallback: res,
12839
+ subscriptionFailedCallback: rej
12840
+ });
12841
+ })];
12842
+ }
12690
12843
  }
12691
12844
 
12692
12845
  return [2
@@ -12698,11 +12851,11 @@ function (_super) {
12698
12851
 
12699
12852
  AWSAppSyncRealTimeProvider.prototype._sendUnsubscriptionMessage = function (subscriptionId) {
12700
12853
  try {
12701
- if (this.awsRealTimeSocket && this.awsRealTimeSocket.readyState === WebSocket.OPEN && this.socketStatus === SOCKET_STATUS.READY) {
12854
+ if (this.awsRealTimeSocket && this.awsRealTimeSocket.readyState === WebSocket.OPEN && this.socketStatus === _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].READY) {
12702
12855
  // Preparing unsubscribe message to stop receiving messages for that subscription
12703
12856
  var unsubscribeMessage = {
12704
12857
  id: subscriptionId,
12705
- type: MESSAGE_TYPES.GQL_STOP
12858
+ type: _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_STOP
12706
12859
  };
12707
12860
  var stringToAWSRealTime = JSON.stringify(unsubscribeMessage);
12708
12861
  this.awsRealTimeSocket.send(stringToAWSRealTime);
@@ -12728,7 +12881,7 @@ function (_super) {
12728
12881
  }
12729
12882
 
12730
12883
  if (!this.awsRealTimeSocket) {
12731
- this.socketStatus = SOCKET_STATUS.CLOSED;
12884
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
12732
12885
  return;
12733
12886
  }
12734
12887
 
@@ -12737,14 +12890,14 @@ function (_super) {
12737
12890
  setTimeout(this._closeSocketIfRequired.bind(this), 1000);
12738
12891
  } else {
12739
12892
  logger.debug('closing WebSocket...');
12740
- clearTimeout(this.keepAliveTimeoutId);
12893
+ if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
12741
12894
  var tempSocket = this.awsRealTimeSocket; // Cleaning callbacks to avoid race condition, socket still exists
12742
12895
 
12743
- tempSocket.onclose = undefined;
12744
- tempSocket.onerror = undefined;
12896
+ tempSocket.onclose = null;
12897
+ tempSocket.onerror = null;
12745
12898
  tempSocket.close(1000);
12746
- this.awsRealTimeSocket = null;
12747
- this.socketStatus = SOCKET_STATUS.CLOSED;
12899
+ this.awsRealTimeSocket = undefined;
12900
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
12748
12901
  }
12749
12902
  };
12750
12903
 
@@ -12775,7 +12928,7 @@ function (_super) {
12775
12928
  variables: variables
12776
12929
  });
12777
12930
 
12778
- if (type === MESSAGE_TYPES.GQL_DATA && payload && payload.data) {
12931
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_DATA && payload && payload.data) {
12779
12932
  if (observer) {
12780
12933
  observer.next(payload);
12781
12934
  } else {
@@ -12785,7 +12938,7 @@ function (_super) {
12785
12938
  return;
12786
12939
  }
12787
12940
 
12788
- if (type === MESSAGE_TYPES.GQL_START_ACK) {
12941
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_START_ACK) {
12789
12942
  logger.debug("subscription ready for " + JSON.stringify({
12790
12943
  query: query,
12791
12944
  variables: variables
@@ -12795,50 +12948,57 @@ function (_super) {
12795
12948
  subscriptionReadyCallback();
12796
12949
  }
12797
12950
 
12798
- clearTimeout(startAckTimeoutId);
12951
+ if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
12799
12952
  dispatchApiEvent(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].SUBSCRIPTION_ACK, {
12800
12953
  query: query,
12801
12954
  variables: variables
12802
12955
  }, 'Connection established for subscription');
12803
- var subscriptionState = SUBSCRIPTION_STATUS.CONNECTED;
12804
- this.subscriptionObserverMap.set(id, {
12805
- observer: observer,
12806
- query: query,
12807
- variables: variables,
12808
- startAckTimeoutId: null,
12809
- subscriptionState: subscriptionState,
12810
- subscriptionReadyCallback: subscriptionReadyCallback,
12811
- subscriptionFailedCallback: subscriptionFailedCallback
12812
- }); // TODO: emit event on hub but it requires to store the id first
12956
+ var subscriptionState = _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].CONNECTED;
12957
+
12958
+ if (observer) {
12959
+ this.subscriptionObserverMap.set(id, {
12960
+ observer: observer,
12961
+ query: query,
12962
+ variables: variables,
12963
+ startAckTimeoutId: undefined,
12964
+ subscriptionState: subscriptionState,
12965
+ subscriptionReadyCallback: subscriptionReadyCallback,
12966
+ subscriptionFailedCallback: subscriptionFailedCallback
12967
+ });
12968
+ } // TODO: emit event on hub but it requires to store the id first
12969
+
12813
12970
 
12814
12971
  return;
12815
12972
  }
12816
12973
 
12817
- if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {
12818
- clearTimeout(this.keepAliveTimeoutId);
12974
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_KEEP_ALIVE) {
12975
+ if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
12819
12976
  this.keepAliveTimeoutId = setTimeout(this._errorDisconnect.bind(this, _index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT), this.keepAliveTimeout);
12820
12977
  return;
12821
12978
  }
12822
12979
 
12823
- if (type === MESSAGE_TYPES.GQL_ERROR) {
12824
- var subscriptionState = SUBSCRIPTION_STATUS.FAILED;
12825
- this.subscriptionObserverMap.set(id, {
12826
- observer: observer,
12827
- query: query,
12828
- variables: variables,
12829
- startAckTimeoutId: startAckTimeoutId,
12830
- subscriptionReadyCallback: subscriptionReadyCallback,
12831
- subscriptionFailedCallback: subscriptionFailedCallback,
12832
- subscriptionState: subscriptionState
12833
- });
12834
- observer.error({
12835
- errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
12836
- });
12837
- clearTimeout(startAckTimeoutId);
12838
- observer.complete();
12980
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_ERROR) {
12981
+ var subscriptionState = _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].FAILED;
12839
12982
 
12840
- if (typeof subscriptionFailedCallback === 'function') {
12841
- subscriptionFailedCallback();
12983
+ if (observer) {
12984
+ this.subscriptionObserverMap.set(id, {
12985
+ observer: observer,
12986
+ query: query,
12987
+ variables: variables,
12988
+ startAckTimeoutId: startAckTimeoutId,
12989
+ subscriptionReadyCallback: subscriptionReadyCallback,
12990
+ subscriptionFailedCallback: subscriptionFailedCallback,
12991
+ subscriptionState: subscriptionState
12992
+ });
12993
+ observer.error({
12994
+ errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
12995
+ });
12996
+ if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
12997
+ observer.complete();
12998
+
12999
+ if (typeof subscriptionFailedCallback === 'function') {
13000
+ subscriptionFailedCallback();
13001
+ }
12842
13002
  }
12843
13003
  }
12844
13004
  };
@@ -12860,41 +13020,44 @@ function (_super) {
12860
13020
  this.awsRealTimeSocket.close();
12861
13021
  }
12862
13022
 
12863
- this.socketStatus = SOCKET_STATUS.CLOSED;
13023
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
12864
13024
  };
12865
13025
 
12866
13026
  AWSAppSyncRealTimeProvider.prototype._timeoutStartSubscriptionAck = function (subscriptionId) {
12867
- var _a = this.subscriptionObserverMap.get(subscriptionId) || {},
12868
- observer = _a.observer,
12869
- query = _a.query,
12870
- variables = _a.variables;
13027
+ var subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
12871
13028
 
12872
- if (!observer) {
12873
- return;
12874
- }
13029
+ if (subscriptionObserver) {
13030
+ var observer = subscriptionObserver.observer,
13031
+ query = subscriptionObserver.query,
13032
+ variables = subscriptionObserver.variables;
12875
13033
 
12876
- this.subscriptionObserverMap.set(subscriptionId, {
12877
- observer: observer,
12878
- query: query,
12879
- variables: variables,
12880
- subscriptionState: SUBSCRIPTION_STATUS.FAILED
12881
- });
13034
+ if (!observer) {
13035
+ return;
13036
+ }
12882
13037
 
12883
- if (observer && !observer.closed) {
12884
- observer.error({
12885
- errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
12886
- query: query,
12887
- variables: variables
12888
- })))]
12889
- }); // Cleanup will be automatically executed
13038
+ this.subscriptionObserverMap.set(subscriptionId, {
13039
+ observer: observer,
13040
+ query: query,
13041
+ variables: variables,
13042
+ subscriptionState: _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].FAILED
13043
+ });
12890
13044
 
12891
- observer.complete();
12892
- }
13045
+ if (observer && !observer.closed) {
13046
+ observer.error({
13047
+ errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
13048
+ query: query,
13049
+ variables: variables
13050
+ })))]
13051
+ }); // Cleanup will be automatically executed
12893
13052
 
12894
- logger.debug('timeoutStartSubscription', JSON.stringify({
12895
- query: query,
12896
- variables: variables
12897
- }));
13053
+ observer.complete();
13054
+ }
13055
+
13056
+ logger.debug('timeoutStartSubscription', JSON.stringify({
13057
+ query: query,
13058
+ variables: variables
13059
+ }));
13060
+ }
12898
13061
  };
12899
13062
 
12900
13063
  AWSAppSyncRealTimeProvider.prototype._initializeWebSocketConnection = function (_a) {
@@ -12906,7 +13069,7 @@ function (_super) {
12906
13069
  region = _a.region,
12907
13070
  additionalHeaders = _a.additionalHeaders;
12908
13071
 
12909
- if (this.socketStatus === SOCKET_STATUS.READY) {
13072
+ if (this.socketStatus === _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].READY) {
12910
13073
  return;
12911
13074
  }
12912
13075
 
@@ -12921,7 +13084,7 @@ function (_super) {
12921
13084
  res: res,
12922
13085
  rej: rej
12923
13086
  });
12924
- if (!(this.socketStatus === SOCKET_STATUS.CLOSED)) return [3
13087
+ if (!(this.socketStatus === _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED)) return [3
12925
13088
  /*break*/
12926
13089
  , 5];
12927
13090
  _c.label = 1;
@@ -12929,7 +13092,7 @@ function (_super) {
12929
13092
  case 1:
12930
13093
  _c.trys.push([1, 4,, 5]);
12931
13094
 
12932
- this.socketStatus = SOCKET_STATUS.CONNECTING;
13095
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CONNECTING;
12933
13096
  payloadString = '{}';
12934
13097
  _b = (_a = JSON).stringify;
12935
13098
  return [4
@@ -12948,7 +13111,7 @@ function (_super) {
12948
13111
  headerString = _b.apply(_a, [_c.sent()]);
12949
13112
  headerQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(headerString).toString('base64');
12950
13113
  payloadQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(payloadString).toString('base64');
12951
- discoverableEndpoint = appSyncGraphqlEndpoint;
13114
+ discoverableEndpoint = appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '';
12952
13115
 
12953
13116
  if (this.isCustomDomain(discoverableEndpoint)) {
12954
13117
  discoverableEndpoint = discoverableEndpoint.concat(customDomainPath);
@@ -12961,9 +13124,7 @@ function (_super) {
12961
13124
  awsRealTimeUrl = discoverableEndpoint + "?header=" + headerQs + "&payload=" + payloadQs;
12962
13125
  return [4
12963
13126
  /*yield*/
12964
- , this._initializeRetryableHandshake({
12965
- awsRealTimeUrl: awsRealTimeUrl
12966
- })];
13127
+ , this._initializeRetryableHandshake(awsRealTimeUrl)];
12967
13128
 
12968
13129
  case 3:
12969
13130
  _c.sent();
@@ -12973,7 +13134,7 @@ function (_super) {
12973
13134
  logger.debug('Notifying connection successful');
12974
13135
  res();
12975
13136
  });
12976
- this.socketStatus = SOCKET_STATUS.READY;
13137
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].READY;
12977
13138
  this.promiseArray = [];
12978
13139
  return [3
12979
13140
  /*break*/
@@ -12991,8 +13152,8 @@ function (_super) {
12991
13152
  this.awsRealTimeSocket.close(3001);
12992
13153
  }
12993
13154
 
12994
- this.awsRealTimeSocket = null;
12995
- this.socketStatus = SOCKET_STATUS.CLOSED;
13155
+ this.awsRealTimeSocket = undefined;
13156
+ this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
12996
13157
  return [3
12997
13158
  /*break*/
12998
13159
  , 5];
@@ -13007,21 +13168,18 @@ function (_super) {
13007
13168
  });
13008
13169
  };
13009
13170
 
13010
- AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (_a) {
13011
- var awsRealTimeUrl = _a.awsRealTimeUrl;
13171
+ AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (awsRealTimeUrl) {
13012
13172
  return __awaiter(this, void 0, void 0, function () {
13013
- return __generator(this, function (_b) {
13014
- switch (_b.label) {
13173
+ return __generator(this, function (_a) {
13174
+ switch (_a.label) {
13015
13175
  case 0:
13016
13176
  logger.debug("Initializaling retryable Handshake");
13017
13177
  return [4
13018
13178
  /*yield*/
13019
- , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [{
13020
- awsRealTimeUrl: awsRealTimeUrl
13021
- }], MAX_DELAY_MS)];
13179
+ , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [awsRealTimeUrl], _constants__WEBPACK_IMPORTED_MODULE_10__["MAX_DELAY_MS"])];
13022
13180
 
13023
13181
  case 1:
13024
- _b.sent();
13182
+ _a.sent();
13025
13183
 
13026
13184
  return [2
13027
13185
  /*return*/
@@ -13031,10 +13189,9 @@ function (_super) {
13031
13189
  });
13032
13190
  };
13033
13191
 
13034
- AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (_a) {
13035
- var awsRealTimeUrl = _a.awsRealTimeUrl;
13192
+ AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (awsRealTimeUrl) {
13036
13193
  return __awaiter(this, void 0, void 0, function () {
13037
- var err_4, errorType, errorCode;
13194
+ var err_4, _a, errorType, errorCode;
13038
13195
 
13039
13196
  var _this = this;
13040
13197
 
@@ -13051,7 +13208,7 @@ function (_super) {
13051
13208
  /*yield*/
13052
13209
  , function () {
13053
13210
  return new Promise(function (res, rej) {
13054
- var newSocket = new WebSocket(awsRealTimeUrl, 'graphql-ws');
13211
+ var newSocket = _this.getNewWebSocket(awsRealTimeUrl, 'graphql-ws');
13055
13212
 
13056
13213
  newSocket.onerror = function () {
13057
13214
  logger.debug("WebSocket connection error");
@@ -13076,77 +13233,82 @@ function (_super) {
13076
13233
  /*yield*/
13077
13234
  , function () {
13078
13235
  return new Promise(function (res, rej) {
13079
- var ackOk = false;
13236
+ if (_this.awsRealTimeSocket) {
13237
+ var ackOk_1 = false;
13080
13238
 
13081
- _this.awsRealTimeSocket.onerror = function (error) {
13082
- logger.debug("WebSocket error " + JSON.stringify(error));
13083
- };
13239
+ _this.awsRealTimeSocket.onerror = function (error) {
13240
+ logger.debug("WebSocket error " + JSON.stringify(error));
13241
+ };
13084
13242
 
13085
- _this.awsRealTimeSocket.onclose = function (event) {
13086
- logger.debug("WebSocket closed " + event.reason);
13087
- rej(new Error(JSON.stringify(event)));
13088
- };
13243
+ _this.awsRealTimeSocket.onclose = function (event) {
13244
+ logger.debug("WebSocket closed " + event.reason);
13245
+ rej(new Error(JSON.stringify(event)));
13246
+ };
13089
13247
 
13090
- _this.awsRealTimeSocket.onmessage = function (message) {
13091
- logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
13092
- var data = JSON.parse(message.data);
13093
- var type = data.type,
13094
- _a = data.payload,
13095
- _b = (_a === void 0 ? {} : _a).connectionTimeoutMs,
13096
- connectionTimeoutMs = _b === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _b;
13248
+ _this.awsRealTimeSocket.onmessage = function (message) {
13249
+ logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
13250
+ var data = JSON.parse(message.data);
13251
+ var type = data.type,
13252
+ _a = data.payload,
13253
+ _b = (_a === void 0 ? {} : _a).connectionTimeoutMs,
13254
+ connectionTimeoutMs = _b === void 0 ? _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_TIMEOUT"] : _b;
13097
13255
 
13098
- if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
13099
- ackOk = true;
13100
- _this.keepAliveTimeout = connectionTimeoutMs;
13101
- _this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
13256
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_ACK) {
13257
+ ackOk_1 = true;
13102
13258
 
13103
- _this.awsRealTimeSocket.onerror = function (err) {
13104
- logger.debug(err);
13259
+ if (_this.awsRealTimeSocket) {
13260
+ _this.keepAliveTimeout = connectionTimeoutMs;
13261
+ _this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
13105
13262
 
13106
- _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
13107
- };
13263
+ _this.awsRealTimeSocket.onerror = function (err) {
13264
+ logger.debug(err);
13108
13265
 
13109
- _this.awsRealTimeSocket.onclose = function (event) {
13110
- logger.debug("WebSocket closed " + event.reason);
13266
+ _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
13267
+ };
13111
13268
 
13112
- _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
13113
- };
13269
+ _this.awsRealTimeSocket.onclose = function (event) {
13270
+ logger.debug("WebSocket closed " + event.reason);
13114
13271
 
13115
- res('Cool, connected to AWS AppSyncRealTime');
13116
- return;
13117
- }
13272
+ _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
13273
+ };
13274
+ }
13118
13275
 
13119
- if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
13120
- var _c = data.payload,
13121
- _d = (_c === void 0 ? {} : _c).errors,
13122
- _e = __read(_d === void 0 ? [] : _d, 1),
13123
- _f = _e[0],
13124
- _g = _f === void 0 ? {} : _f,
13125
- _h = _g.errorType,
13126
- errorType = _h === void 0 ? '' : _h,
13127
- _j = _g.errorCode,
13128
- errorCode = _j === void 0 ? 0 : _j;
13129
-
13130
- rej({
13131
- errorType: errorType,
13132
- errorCode: errorCode
13133
- });
13134
- }
13135
- };
13276
+ res('Cool, connected to AWS AppSyncRealTime');
13277
+ return;
13278
+ }
13136
13279
 
13137
- var gqlInit = {
13138
- type: MESSAGE_TYPES.GQL_CONNECTION_INIT
13139
- };
13280
+ if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_ERROR) {
13281
+ var _c = data.payload,
13282
+ _d = (_c === void 0 ? {} : _c).errors,
13283
+ _e = __read(_d === void 0 ? [] : _d, 1),
13284
+ _f = _e[0],
13285
+ _g = _f === void 0 ? {} : _f,
13286
+ _h = _g.errorType,
13287
+ errorType = _h === void 0 ? '' : _h,
13288
+ _j = _g.errorCode,
13289
+ errorCode = _j === void 0 ? 0 : _j;
13290
+
13291
+ rej({
13292
+ errorType: errorType,
13293
+ errorCode: errorCode
13294
+ });
13295
+ }
13296
+ };
13297
+
13298
+ var gqlInit = {
13299
+ type: _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_INIT
13300
+ };
13140
13301
 
13141
- _this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
13302
+ _this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
13303
+
13304
+ setTimeout(checkAckOk.bind(_this, ackOk_1), _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"]);
13305
+ }
13142
13306
 
13143
- function checkAckOk() {
13307
+ function checkAckOk(ackOk) {
13144
13308
  if (!ackOk) {
13145
- rej(new Error("Connection timeout: ack from AWSRealTime was not received on " + CONNECTION_INIT_TIMEOUT + " ms"));
13309
+ rej(new Error("Connection timeout: ack from AWSRealTime was not received on " + _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"] + " ms"));
13146
13310
  }
13147
13311
  }
13148
-
13149
- setTimeout(checkAckOk.bind(_this), CONNECTION_INIT_TIMEOUT);
13150
13312
  });
13151
13313
  }()];
13152
13314
 
@@ -13160,9 +13322,9 @@ function (_super) {
13160
13322
 
13161
13323
  case 4:
13162
13324
  err_4 = _b.sent();
13163
- errorType = err_4.errorType, errorCode = err_4.errorCode;
13325
+ _a = err_4, errorType = _a.errorType, errorCode = _a.errorCode;
13164
13326
 
13165
- if (NON_RETRYABLE_CODES.includes(errorCode)) {
13327
+ if (_constants__WEBPACK_IMPORTED_MODULE_10__["NON_RETRYABLE_CODES"].includes(errorCode)) {
13166
13328
  throw new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["NonRetryableError"](errorType);
13167
13329
  } else if (errorType) {
13168
13330
  throw new Error(errorType);
@@ -13203,16 +13365,18 @@ function (_super) {
13203
13365
  AMAZON_COGNITO_USER_POOLS: this._awsRealTimeCUPHeader.bind(this),
13204
13366
  AWS_LAMBDA: this._customAuthHeader
13205
13367
  };
13206
- handler = headerHandler[authenticationType];
13207
-
13208
- if (typeof handler !== 'function') {
13209
- logger.debug("Authentication type " + authenticationType + " not supported");
13210
- return [2
13211
- /*return*/
13212
- , ''];
13213
- }
13368
+ if (!(!authenticationType || !headerHandler[authenticationType])) return [3
13369
+ /*break*/
13370
+ , 1];
13371
+ logger.debug("Authentication type " + authenticationType + " not supported");
13372
+ return [2
13373
+ /*return*/
13374
+ , ''];
13214
13375
 
13215
- host = url__WEBPACK_IMPORTED_MODULE_2__["parse"](appSyncGraphqlEndpoint).host;
13376
+ case 1:
13377
+ handler = headerHandler[authenticationType];
13378
+ host = url__WEBPACK_IMPORTED_MODULE_2__["parse"](appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
13379
+ logger.debug("Authenticating with " + authenticationType);
13216
13380
  return [4
13217
13381
  /*yield*/
13218
13382
  , handler({
@@ -13225,7 +13389,7 @@ function (_super) {
13225
13389
  additionalHeaders: additionalHeaders
13226
13390
  })];
13227
13391
 
13228
- case 1:
13392
+ case 2:
13229
13393
  result = _b.sent();
13230
13394
  return [2
13231
13395
  /*return*/
@@ -13357,10 +13521,14 @@ function (_super) {
13357
13521
  return [4
13358
13522
  /*yield*/
13359
13523
  , _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Credentials"].get().then(function (credentials) {
13524
+ var _a = credentials,
13525
+ secretAccessKey = _a.secretAccessKey,
13526
+ accessKeyId = _a.accessKeyId,
13527
+ sessionToken = _a.sessionToken;
13360
13528
  return {
13361
- secret_key: credentials.secretAccessKey,
13362
- access_key: credentials.accessKeyId,
13363
- session_token: credentials.sessionToken
13529
+ secret_key: secretAccessKey,
13530
+ access_key: accessKeyId,
13531
+ session_token: sessionToken
13364
13532
  };
13365
13533
  })];
13366
13534
 
@@ -13370,7 +13538,7 @@ function (_super) {
13370
13538
  url: "" + appSyncGraphqlEndpoint + canonicalUri,
13371
13539
  data: payload,
13372
13540
  method: 'POST',
13373
- headers: __assign({}, AWS_APPSYNC_REALTIME_HEADERS)
13541
+ headers: __assign({}, _constants__WEBPACK_IMPORTED_MODULE_10__["AWS_APPSYNC_REALTIME_HEADERS"])
13374
13542
  };
13375
13543
  signed_params = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Signer"].sign(request, creds, endpointInfo);
13376
13544
  return [2
@@ -13385,7 +13553,7 @@ function (_super) {
13385
13553
  var host = _a.host,
13386
13554
  additionalHeaders = _a.additionalHeaders;
13387
13555
 
13388
- if (!additionalHeaders.Authorization) {
13556
+ if (!additionalHeaders || !additionalHeaders['Authorization']) {
13389
13557
  throw new Error('No auth token specified');
13390
13558
  }
13391
13559
 
@@ -13622,8 +13790,12 @@ var AWSIoTProvider =
13622
13790
  function (_super) {
13623
13791
  __extends(AWSIoTProvider, _super);
13624
13792
 
13625
- function AWSIoTProvider() {
13626
- return _super !== null && _super.apply(this, arguments) || this;
13793
+ function AWSIoTProvider(options) {
13794
+ if (options === void 0) {
13795
+ options = {};
13796
+ }
13797
+
13798
+ return _super.call(this, options) || this;
13627
13799
  }
13628
13800
 
13629
13801
  Object.defineProperty(AWSIoTProvider.prototype, "region", {
@@ -13953,21 +14125,27 @@ function () {
13953
14125
 
13954
14126
  ClientsQueue.prototype.get = function (clientId, clientFactory) {
13955
14127
  return __awaiter(this, void 0, void 0, function () {
13956
- var promise;
14128
+ var cachedPromise, newPromise;
13957
14129
  return __generator(this, function (_a) {
13958
- promise = this.promises.get(clientId);
14130
+ cachedPromise = this.promises.get(clientId);
14131
+
14132
+ if (cachedPromise) {
14133
+ return [2
14134
+ /*return*/
14135
+ , cachedPromise];
14136
+ }
13959
14137
 
13960
- if (promise) {
14138
+ if (clientFactory) {
14139
+ newPromise = clientFactory(clientId);
14140
+ this.promises.set(clientId, newPromise);
13961
14141
  return [2
13962
14142
  /*return*/
13963
- , promise];
14143
+ , newPromise];
13964
14144
  }
13965
14145
 
13966
- promise = clientFactory(clientId);
13967
- this.promises.set(clientId, promise);
13968
14146
  return [2
13969
14147
  /*return*/
13970
- , promise];
14148
+ , undefined];
13971
14149
  });
13972
14150
  });
13973
14151
  };
@@ -14059,6 +14237,10 @@ function (_super) {
14059
14237
  }, args), null, 2));
14060
14238
  var topicsToDelete_1 = [];
14061
14239
 
14240
+ if (!clientId) {
14241
+ return;
14242
+ }
14243
+
14062
14244
  var clientIdObservers = this._clientIdObservers.get(clientId);
14063
14245
 
14064
14246
  if (!clientIdObservers) {
@@ -14177,9 +14359,7 @@ function (_super) {
14177
14359
  case 0:
14178
14360
  return [4
14179
14361
  /*yield*/
14180
- , this.clientsQueue.get(clientId, function () {
14181
- return null;
14182
- })];
14362
+ , this.clientsQueue.get(clientId)];
14183
14363
 
14184
14364
  case 1:
14185
14365
  client = _a.sent();
@@ -14358,13 +14538,14 @@ function (_super) {
14358
14538
  })();
14359
14539
 
14360
14540
  return function () {
14541
+ var _a, _b;
14542
+
14361
14543
  logger.debug('Unsubscribing from topic(s)', targetTopics.join(','));
14362
14544
 
14363
14545
  if (client) {
14364
- _this._clientIdObservers.get(clientId)["delete"](observer); // No more observers per client => client not needed anymore
14365
-
14546
+ (_a = _this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
14366
14547
 
14367
- if (_this._clientIdObservers.get(clientId).size === 0) {
14548
+ if (((_b = _this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
14368
14549
  _this.disconnect(clientId);
14369
14550
 
14370
14551
  _this._clientIdObservers["delete"](clientId);
@@ -14481,7 +14662,7 @@ __webpack_require__.r(__webpack_exports__);
14481
14662
  /* harmony import */ var _AWSAppSyncProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AWSAppSyncProvider */ "../pubsub/lib-esm/Providers/AWSAppSyncProvider.js");
14482
14663
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AWSAppSyncProvider", function() { return _AWSAppSyncProvider__WEBPACK_IMPORTED_MODULE_1__["AWSAppSyncProvider"]; });
14483
14664
 
14484
- /* harmony import */ var _AWSAppSyncRealTimeProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./AWSAppSyncRealTimeProvider */ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js");
14665
+ /* harmony import */ var _AWSAppSyncRealTimeProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./AWSAppSyncRealTimeProvider */ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js");
14485
14666
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AWSAppSyncRealTimeProvider", function() { return _AWSAppSyncRealTimeProvider__WEBPACK_IMPORTED_MODULE_2__["AWSAppSyncRealTimeProvider"]; });
14486
14667
 
14487
14668
  /* harmony import */ var _AWSIotProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./AWSIotProvider */ "../pubsub/lib-esm/Providers/AWSIotProvider.js");
@@ -14699,7 +14880,7 @@ function () {
14699
14880
  * @param {PubSubOptions} options - Configuration object for PubSub
14700
14881
  */
14701
14882
  function PubSubClass(options) {
14702
- this._options = options;
14883
+ this._options = options !== null && options !== void 0 ? options : {};
14703
14884
  logger.debug('PubSub Options', this._options);
14704
14885
  this._pluggables = [];
14705
14886
  this.subscribe = this.subscribe.bind(this);
@@ -14888,7 +15069,7 @@ function () {
14888
15069
  }();
14889
15070
 
14890
15071
 
14891
- var PubSub = new PubSubClass(null);
15072
+ var PubSub = new PubSubClass();
14892
15073
  _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
14893
15074
 
14894
15075
  /***/ }),
@@ -15198,10 +15379,10 @@ function () {
15198
15379
  };
15199
15380
  /**
15200
15381
  * Make a GET request
15201
- * @param {string} apiName - The api name of the request
15202
- * @param {string} path - The path of the request
15203
- * @param {json} [init] - Request extra params
15204
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
15382
+ * @param apiName - The api name of the request
15383
+ * @param path - The path of the request
15384
+ * @param [init] - Request extra params
15385
+ * @return A promise that resolves to an object with response status and JSON data, if successful.
15205
15386
  */
15206
15387
 
15207
15388
 
@@ -15210,10 +15391,10 @@ function () {
15210
15391
  };
15211
15392
  /**
15212
15393
  * Make a POST request
15213
- * @param {string} apiName - The api name of the request
15214
- * @param {string} path - The path of the request
15215
- * @param {json} [init] - Request extra params
15216
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
15394
+ * @param apiName - The api name of the request
15395
+ * @param path - The path of the request
15396
+ * @param [init] - Request extra params
15397
+ * @return A promise that resolves to an object with response status and JSON data, if successful.
15217
15398
  */
15218
15399
 
15219
15400
 
@@ -15222,10 +15403,10 @@ function () {
15222
15403
  };
15223
15404
  /**
15224
15405
  * Make a PUT request
15225
- * @param {string} apiName - The api name of the request
15226
- * @param {string} path - The path of the request
15227
- * @param {json} [init] - Request extra params
15228
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
15406
+ * @param apiName - The api name of the request
15407
+ * @param path - The path of the request
15408
+ * @param [init] - Request extra params
15409
+ * @return A promise that resolves to an object with response status and JSON data, if successful.
15229
15410
  */
15230
15411
 
15231
15412
 
@@ -15234,10 +15415,10 @@ function () {
15234
15415
  };
15235
15416
  /**
15236
15417
  * Make a PATCH request
15237
- * @param {string} apiName - The api name of the request
15238
- * @param {string} path - The path of the request
15239
- * @param {json} [init] - Request extra params
15240
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
15418
+ * @param apiName - The api name of the request
15419
+ * @param path - The path of the request
15420
+ * @param [init] - Request extra params
15421
+ * @return A promise that resolves to an object with response status and JSON data, if successful.
15241
15422
  */
15242
15423
 
15243
15424
 
@@ -15246,10 +15427,10 @@ function () {
15246
15427
  };
15247
15428
  /**
15248
15429
  * Make a DEL request
15249
- * @param {string} apiName - The api name of the request
15250
- * @param {string} path - The path of the request
15251
- * @param {json} [init] - Request extra params
15252
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
15430
+ * @param apiName - The api name of the request
15431
+ * @param path - The path of the request
15432
+ * @param [init] - Request extra params
15433
+ * @return A promise that resolves to an object with response status and JSON data, if successful.
15253
15434
  */
15254
15435
 
15255
15436
 
@@ -15258,10 +15439,10 @@ function () {
15258
15439
  };
15259
15440
  /**
15260
15441
  * Make a HEAD request
15261
- * @param {string} apiName - The api name of the request
15262
- * @param {string} path - The path of the request
15263
- * @param {json} [init] - Request extra params
15264
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
15442
+ * @param apiName - The api name of the request
15443
+ * @param path - The path of the request
15444
+ * @param [init] - Request extra params
15445
+ * @return A promise that resolves to an object with response status and JSON data, if successful.
15265
15446
  */
15266
15447
 
15267
15448
 
@@ -15270,8 +15451,8 @@ function () {
15270
15451
  };
15271
15452
  /**
15272
15453
  * Checks to see if an error thrown is from an api request cancellation
15273
- * @param {any} error - Any error
15274
- * @return {boolean} - A boolean indicating if the error was from an api request cancellation
15454
+ * @param error - Any error
15455
+ * @return If the error was from an api request cancellation
15275
15456
  */
15276
15457
 
15277
15458
 
@@ -15279,19 +15460,26 @@ function () {
15279
15460
  return this._restApi.isCancel(error);
15280
15461
  };
15281
15462
  /**
15282
- * Cancels an inflight request
15283
- * @param {any} request - request to cancel
15284
- * @return {boolean} - A boolean indicating if the request was cancelled
15463
+ * Cancels an inflight request for either a GraphQL request or a Rest API request.
15464
+ * @param request - request to cancel
15465
+ * @param [message] - custom error message
15466
+ * @return If the request was cancelled
15285
15467
  */
15286
15468
 
15287
15469
 
15288
15470
  APIClass.prototype.cancel = function (request, message) {
15289
- return this._restApi.cancel(request, message);
15471
+ if (this._restApi.hasCancelToken(request)) {
15472
+ return this._restApi.cancel(request, message);
15473
+ } else if (this._graphqlApi.hasCancelToken(request)) {
15474
+ return this._graphqlApi.cancel(request, message);
15475
+ }
15476
+
15477
+ return false;
15290
15478
  };
15291
15479
  /**
15292
15480
  * Getting endpoint for API
15293
- * @param {string} apiName - The name of the api
15294
- * @return {string} - The endpoint of the api
15481
+ * @param apiName - The name of the api
15482
+ * @return The endpoint of the api
15295
15483
  */
15296
15484
 
15297
15485
 
@@ -15313,14 +15501,6 @@ function () {
15313
15501
  APIClass.prototype.getGraphqlOperationType = function (operation) {
15314
15502
  return this._graphqlApi.getGraphqlOperationType(operation);
15315
15503
  };
15316
- /**
15317
- * Executes a GraphQL operation
15318
- *
15319
- * @param {GraphQLOptions} GraphQL Options
15320
- * @param {object} additionalHeaders headers to merge in after any `graphql_headers` set in the config
15321
- * @returns {Promise<GraphQLResult> | Observable<object>}
15322
- */
15323
-
15324
15504
 
15325
15505
  APIClass.prototype.graphql = function (options, additionalHeaders) {
15326
15506
  return this._graphqlApi.graphql(options, additionalHeaders);