@aws-amplify/core 4.3.14 → 4.3.15-cloud-logging.10

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.
Files changed (46) hide show
  1. package/dist/aws-amplify-core.js +571 -391
  2. package/dist/aws-amplify-core.js.map +1 -1
  3. package/dist/aws-amplify-core.min.js +6 -6
  4. package/dist/aws-amplify-core.min.js.map +1 -1
  5. package/lib/Hub.js +1 -0
  6. package/lib/Hub.js.map +1 -1
  7. package/lib/Logger/ConsoleLogger.d.ts +6 -0
  8. package/lib/Logger/ConsoleLogger.js +118 -43
  9. package/lib/Logger/ConsoleLogger.js.map +1 -1
  10. package/lib/Platform/version.d.ts +1 -1
  11. package/lib/Platform/version.js +1 -1
  12. package/lib/Providers/AWSCloudWatchProvider.d.ts +11 -3
  13. package/lib/Providers/AWSCloudWatchProvider.js +97 -37
  14. package/lib/Providers/AWSCloudWatchProvider.js.map +1 -1
  15. package/lib/Providers/AmazonKinesisLoggingProvider.d.ts +13 -0
  16. package/lib/Providers/AmazonKinesisLoggingProvider.js +30 -0
  17. package/lib/Providers/AmazonKinesisLoggingProvider.js.map +1 -0
  18. package/lib/Util/Constants.d.ts +3 -1
  19. package/lib/Util/Constants.js +5 -0
  20. package/lib/Util/Constants.js.map +1 -1
  21. package/lib/types/types.d.ts +13 -0
  22. package/lib-esm/Hub.js +1 -0
  23. package/lib-esm/Hub.js.map +1 -1
  24. package/lib-esm/Logger/ConsoleLogger.d.ts +6 -0
  25. package/lib-esm/Logger/ConsoleLogger.js +118 -43
  26. package/lib-esm/Logger/ConsoleLogger.js.map +1 -1
  27. package/lib-esm/Platform/version.d.ts +1 -1
  28. package/lib-esm/Platform/version.js +1 -1
  29. package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +11 -3
  30. package/lib-esm/Providers/AWSCloudWatchProvider.js +97 -37
  31. package/lib-esm/Providers/AWSCloudWatchProvider.js.map +1 -1
  32. package/lib-esm/Providers/AmazonKinesisLoggingProvider.d.ts +13 -0
  33. package/lib-esm/Providers/AmazonKinesisLoggingProvider.js +28 -0
  34. package/lib-esm/Providers/AmazonKinesisLoggingProvider.js.map +1 -0
  35. package/lib-esm/Util/Constants.d.ts +3 -1
  36. package/lib-esm/Util/Constants.js +4 -1
  37. package/lib-esm/Util/Constants.js.map +1 -1
  38. package/lib-esm/types/types.d.ts +13 -0
  39. package/package.json +4 -3
  40. package/src/Hub.ts +1 -0
  41. package/src/Logger/ConsoleLogger.ts +119 -34
  42. package/src/Platform/version.ts +1 -1
  43. package/src/Providers/AWSCloudWatchProvider.ts +112 -18
  44. package/src/Providers/AmazonKinesisLoggingProvider.ts +43 -0
  45. package/src/Util/Constants.ts +7 -0
  46. package/src/types/types.ts +79 -62
@@ -25767,6 +25767,238 @@ function isnan (val) {
25767
25767
 
25768
25768
  /***/ }),
25769
25769
 
25770
+ /***/ "../../node_modules/cookie/index.js":
25771
+ /*!*****************************************************!*\
25772
+ !*** /root/amplify-js/node_modules/cookie/index.js ***!
25773
+ \*****************************************************/
25774
+ /*! no static exports found */
25775
+ /***/ (function(module, exports, __webpack_require__) {
25776
+
25777
+ "use strict";
25778
+ /*!
25779
+ * cookie
25780
+ * Copyright(c) 2012-2014 Roman Shtylman
25781
+ * Copyright(c) 2015 Douglas Christopher Wilson
25782
+ * MIT Licensed
25783
+ */
25784
+
25785
+
25786
+
25787
+ /**
25788
+ * Module exports.
25789
+ * @public
25790
+ */
25791
+
25792
+ exports.parse = parse;
25793
+ exports.serialize = serialize;
25794
+
25795
+ /**
25796
+ * Module variables.
25797
+ * @private
25798
+ */
25799
+
25800
+ var decode = decodeURIComponent;
25801
+ var encode = encodeURIComponent;
25802
+
25803
+ /**
25804
+ * RegExp to match field-content in RFC 7230 sec 3.2
25805
+ *
25806
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
25807
+ * field-vchar = VCHAR / obs-text
25808
+ * obs-text = %x80-FF
25809
+ */
25810
+
25811
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
25812
+
25813
+ /**
25814
+ * Parse a cookie header.
25815
+ *
25816
+ * Parse the given cookie header string into an object
25817
+ * The object has the various cookies as keys(names) => values
25818
+ *
25819
+ * @param {string} str
25820
+ * @param {object} [options]
25821
+ * @return {object}
25822
+ * @public
25823
+ */
25824
+
25825
+ function parse(str, options) {
25826
+ if (typeof str !== 'string') {
25827
+ throw new TypeError('argument str must be a string');
25828
+ }
25829
+
25830
+ var obj = {}
25831
+ var opt = options || {};
25832
+ var pairs = str.split(';')
25833
+ var dec = opt.decode || decode;
25834
+
25835
+ for (var i = 0; i < pairs.length; i++) {
25836
+ var pair = pairs[i];
25837
+ var index = pair.indexOf('=')
25838
+
25839
+ // skip things that don't look like key=value
25840
+ if (index < 0) {
25841
+ continue;
25842
+ }
25843
+
25844
+ var key = pair.substring(0, index).trim()
25845
+
25846
+ // only assign once
25847
+ if (undefined == obj[key]) {
25848
+ var val = pair.substring(index + 1, pair.length).trim()
25849
+
25850
+ // quoted values
25851
+ if (val[0] === '"') {
25852
+ val = val.slice(1, -1)
25853
+ }
25854
+
25855
+ obj[key] = tryDecode(val, dec);
25856
+ }
25857
+ }
25858
+
25859
+ return obj;
25860
+ }
25861
+
25862
+ /**
25863
+ * Serialize data into a cookie header.
25864
+ *
25865
+ * Serialize the a name value pair into a cookie string suitable for
25866
+ * http headers. An optional options object specified cookie parameters.
25867
+ *
25868
+ * serialize('foo', 'bar', { httpOnly: true })
25869
+ * => "foo=bar; httpOnly"
25870
+ *
25871
+ * @param {string} name
25872
+ * @param {string} val
25873
+ * @param {object} [options]
25874
+ * @return {string}
25875
+ * @public
25876
+ */
25877
+
25878
+ function serialize(name, val, options) {
25879
+ var opt = options || {};
25880
+ var enc = opt.encode || encode;
25881
+
25882
+ if (typeof enc !== 'function') {
25883
+ throw new TypeError('option encode is invalid');
25884
+ }
25885
+
25886
+ if (!fieldContentRegExp.test(name)) {
25887
+ throw new TypeError('argument name is invalid');
25888
+ }
25889
+
25890
+ var value = enc(val);
25891
+
25892
+ if (value && !fieldContentRegExp.test(value)) {
25893
+ throw new TypeError('argument val is invalid');
25894
+ }
25895
+
25896
+ var str = name + '=' + value;
25897
+
25898
+ if (null != opt.maxAge) {
25899
+ var maxAge = opt.maxAge - 0;
25900
+
25901
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
25902
+ throw new TypeError('option maxAge is invalid')
25903
+ }
25904
+
25905
+ str += '; Max-Age=' + Math.floor(maxAge);
25906
+ }
25907
+
25908
+ if (opt.domain) {
25909
+ if (!fieldContentRegExp.test(opt.domain)) {
25910
+ throw new TypeError('option domain is invalid');
25911
+ }
25912
+
25913
+ str += '; Domain=' + opt.domain;
25914
+ }
25915
+
25916
+ if (opt.path) {
25917
+ if (!fieldContentRegExp.test(opt.path)) {
25918
+ throw new TypeError('option path is invalid');
25919
+ }
25920
+
25921
+ str += '; Path=' + opt.path;
25922
+ }
25923
+
25924
+ if (opt.expires) {
25925
+ if (typeof opt.expires.toUTCString !== 'function') {
25926
+ throw new TypeError('option expires is invalid');
25927
+ }
25928
+
25929
+ str += '; Expires=' + opt.expires.toUTCString();
25930
+ }
25931
+
25932
+ if (opt.httpOnly) {
25933
+ str += '; HttpOnly';
25934
+ }
25935
+
25936
+ if (opt.secure) {
25937
+ str += '; Secure';
25938
+ }
25939
+
25940
+ if (opt.sameSite) {
25941
+ var sameSite = typeof opt.sameSite === 'string'
25942
+ ? opt.sameSite.toLowerCase() : opt.sameSite;
25943
+
25944
+ switch (sameSite) {
25945
+ case true:
25946
+ str += '; SameSite=Strict';
25947
+ break;
25948
+ case 'lax':
25949
+ str += '; SameSite=Lax';
25950
+ break;
25951
+ case 'strict':
25952
+ str += '; SameSite=Strict';
25953
+ break;
25954
+ case 'none':
25955
+ str += '; SameSite=None';
25956
+ break;
25957
+ default:
25958
+ throw new TypeError('option sameSite is invalid');
25959
+ }
25960
+ }
25961
+
25962
+ return str;
25963
+ }
25964
+
25965
+ /**
25966
+ * Try decoding a string using a decoding function.
25967
+ *
25968
+ * @param {string} str
25969
+ * @param {function} decode
25970
+ * @private
25971
+ */
25972
+
25973
+ function tryDecode(str, decode) {
25974
+ try {
25975
+ return decode(str);
25976
+ } catch (e) {
25977
+ return str;
25978
+ }
25979
+ }
25980
+
25981
+
25982
+ /***/ }),
25983
+
25984
+ /***/ "../../node_modules/fast-text-encoding/text.min.js":
25985
+ /*!********************************************************************!*\
25986
+ !*** /root/amplify-js/node_modules/fast-text-encoding/text.min.js ***!
25987
+ \********************************************************************/
25988
+ /*! no static exports found */
25989
+ /***/ (function(module, exports, __webpack_require__) {
25990
+
25991
+ /* WEBPACK VAR INJECTION */(function(global, Buffer) {(function(l){function m(){}function k(a,c){a=void 0===a?"utf-8":a;c=void 0===c?{fatal:!1}:c;if(-1===r.indexOf(a.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+a+"') is invalid.");if(c.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}function t(a){return Buffer.from(a.buffer,a.byteOffset,a.byteLength).toString("utf-8")}function u(a){var c=URL.createObjectURL(new Blob([a],{type:"text/plain;charset=UTF-8"}));
25992
+ try{var f=new XMLHttpRequest;f.open("GET",c,!1);f.send();return f.responseText}catch(e){return q(a)}finally{URL.revokeObjectURL(c)}}function q(a){for(var c=0,f=Math.min(65536,a.length+1),e=new Uint16Array(f),h=[],d=0;;){var b=c<a.length;if(!b||d>=f-1){h.push(String.fromCharCode.apply(null,e.subarray(0,d)));if(!b)return h.join("");a=a.subarray(c);d=c=0}b=a[c++];if(0===(b&128))e[d++]=b;else if(192===(b&224)){var g=a[c++]&63;e[d++]=(b&31)<<6|g}else if(224===(b&240)){g=a[c++]&63;var n=a[c++]&63;e[d++]=
25993
+ (b&31)<<12|g<<6|n}else if(240===(b&248)){g=a[c++]&63;n=a[c++]&63;var v=a[c++]&63;b=(b&7)<<18|g<<12|n<<6|v;65535<b&&(b-=65536,e[d++]=b>>>10&1023|55296,b=56320|b&1023);e[d++]=b}}}if(l.TextEncoder&&l.TextDecoder)return!1;var r=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(a,c){c=void 0===c?{stream:!1}:c;if(c.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");c=0;for(var f=a.length,e=0,h=Math.max(32,
25994
+ f+(f>>>1)+7),d=new Uint8Array(h>>>3<<3);c<f;){var b=a.charCodeAt(c++);if(55296<=b&&56319>=b){if(c<f){var g=a.charCodeAt(c);56320===(g&64512)&&(++c,b=((b&1023)<<10)+(g&1023)+65536)}if(55296<=b&&56319>=b)continue}e+4>d.length&&(h+=8,h*=1+c/a.length*2,h=h>>>3<<3,g=new Uint8Array(h),g.set(d),d=g);if(0===(b&4294967168))d[e++]=b;else{if(0===(b&4294965248))d[e++]=b>>>6&31|192;else if(0===(b&4294901760))d[e++]=b>>>12&15|224,d[e++]=b>>>6&63|128;else if(0===(b&4292870144))d[e++]=b>>>18&7|240,d[e++]=b>>>12&
25995
+ 63|128,d[e++]=b>>>6&63|128;else continue;d[e++]=b&63|128}}return d.slice?d.slice(0,e):d.subarray(0,e)};Object.defineProperty(k.prototype,"encoding",{value:"utf-8"});Object.defineProperty(k.prototype,"fatal",{value:!1});Object.defineProperty(k.prototype,"ignoreBOM",{value:!1});var p=q;"function"===typeof Buffer&&Buffer.from?p=t:"function"===typeof Blob&&"function"===typeof URL&&"function"===typeof URL.createObjectURL&&(p=u);k.prototype.decode=function(a,c){c=void 0===c?{stream:!1}:c;if(c.stream)throw Error("Failed to decode: the 'stream' option is unsupported.");
25996
+ a=a instanceof Uint8Array?a:a.buffer instanceof ArrayBuffer?new Uint8Array(a.buffer):new Uint8Array(a);return p(a)};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this);
25997
+
25998
+ /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../buffer/index.js */ "../../node_modules/buffer/index.js").Buffer))
25999
+
26000
+ /***/ }),
26001
+
25770
26002
  /***/ "../../node_modules/ieee754/index.js":
25771
26003
  /*!******************************************************!*\
25772
26004
  !*** /root/amplify-js/node_modules/ieee754/index.js ***!
@@ -27077,7 +27309,7 @@ function __classPrivateFieldSet(receiver, privateMap, value) {
27077
27309
 
27078
27310
  "use strict";
27079
27311
  __webpack_require__.r(__webpack_exports__);
27080
- /* harmony import */ var cookie__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! cookie */ "../../node_modules/universal-cookie/node_modules/cookie/index.js");
27312
+ /* harmony import */ var cookie__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! cookie */ "../../node_modules/cookie/index.js");
27081
27313
  /* harmony import */ var cookie__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cookie__WEBPACK_IMPORTED_MODULE_0__);
27082
27314
  /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "../../node_modules/universal-cookie/es6/utils.js");
27083
27315
  var __assign = (undefined && undefined.__assign) || function () {
@@ -27174,295 +27406,81 @@ var Cookies = /** @class */ (function () {
27174
27406
  "use strict";
27175
27407
  __webpack_require__.r(__webpack_exports__);
27176
27408
  /* harmony import */ var _Cookies__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cookies */ "../../node_modules/universal-cookie/es6/Cookies.js");
27177
-
27178
- /* harmony default export */ __webpack_exports__["default"] = (_Cookies__WEBPACK_IMPORTED_MODULE_0__["default"]);
27179
-
27180
-
27181
- /***/ }),
27182
-
27183
- /***/ "../../node_modules/universal-cookie/es6/utils.js":
27184
- /*!*******************************************************************!*\
27185
- !*** /root/amplify-js/node_modules/universal-cookie/es6/utils.js ***!
27186
- \*******************************************************************/
27187
- /*! exports provided: hasDocumentCookie, cleanCookies, parseCookies, isParsingCookie, readCookie */
27188
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
27189
-
27190
- "use strict";
27191
- __webpack_require__.r(__webpack_exports__);
27192
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasDocumentCookie", function() { return hasDocumentCookie; });
27193
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cleanCookies", function() { return cleanCookies; });
27194
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseCookies", function() { return parseCookies; });
27195
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isParsingCookie", function() { return isParsingCookie; });
27196
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "readCookie", function() { return readCookie; });
27197
- /* harmony import */ var cookie__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! cookie */ "../../node_modules/universal-cookie/node_modules/cookie/index.js");
27198
- /* harmony import */ var cookie__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cookie__WEBPACK_IMPORTED_MODULE_0__);
27199
-
27200
- function hasDocumentCookie() {
27201
- // Can we get/set cookies on document.cookie?
27202
- return typeof document === 'object' && typeof document.cookie === 'string';
27203
- }
27204
- function cleanCookies() {
27205
- document.cookie.split(';').forEach(function (c) {
27206
- document.cookie = c
27207
- .replace(/^ +/, '')
27208
- .replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/');
27209
- });
27210
- }
27211
- function parseCookies(cookies, options) {
27212
- if (typeof cookies === 'string') {
27213
- return cookie__WEBPACK_IMPORTED_MODULE_0__["parse"](cookies, options);
27214
- }
27215
- else if (typeof cookies === 'object' && cookies !== null) {
27216
- return cookies;
27217
- }
27218
- else {
27219
- return {};
27220
- }
27221
- }
27222
- function isParsingCookie(value, doNotParse) {
27223
- if (typeof doNotParse === 'undefined') {
27224
- // We guess if the cookie start with { or [, it has been serialized
27225
- doNotParse =
27226
- !value || (value[0] !== '{' && value[0] !== '[' && value[0] !== '"');
27227
- }
27228
- return !doNotParse;
27229
- }
27230
- function readCookie(value, options) {
27231
- if (options === void 0) { options = {}; }
27232
- var cleanValue = cleanupCookieValue(value);
27233
- if (isParsingCookie(cleanValue, options.doNotParse)) {
27234
- try {
27235
- return JSON.parse(cleanValue);
27236
- }
27237
- catch (e) {
27238
- // At least we tried
27239
- }
27240
- }
27241
- // Ignore clean value if we failed the deserialization
27242
- // It is not relevant anymore to trim those values
27243
- return value;
27244
- }
27245
- function cleanupCookieValue(value) {
27246
- // express prepend j: before serializing a cookie
27247
- if (value && value[0] === 'j' && value[1] === ':') {
27248
- return value.substr(2);
27249
- }
27250
- return value;
27251
- }
27252
-
27253
-
27254
- /***/ }),
27255
-
27256
- /***/ "../../node_modules/universal-cookie/node_modules/cookie/index.js":
27257
- /*!***********************************************************************************!*\
27258
- !*** /root/amplify-js/node_modules/universal-cookie/node_modules/cookie/index.js ***!
27259
- \***********************************************************************************/
27260
- /*! no static exports found */
27261
- /***/ (function(module, exports, __webpack_require__) {
27262
-
27263
- "use strict";
27264
- /*!
27265
- * cookie
27266
- * Copyright(c) 2012-2014 Roman Shtylman
27267
- * Copyright(c) 2015 Douglas Christopher Wilson
27268
- * MIT Licensed
27269
- */
27270
-
27271
-
27272
-
27273
- /**
27274
- * Module exports.
27275
- * @public
27276
- */
27277
-
27278
- exports.parse = parse;
27279
- exports.serialize = serialize;
27280
-
27281
- /**
27282
- * Module variables.
27283
- * @private
27284
- */
27285
-
27286
- var decode = decodeURIComponent;
27287
- var encode = encodeURIComponent;
27288
-
27289
- /**
27290
- * RegExp to match field-content in RFC 7230 sec 3.2
27291
- *
27292
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
27293
- * field-vchar = VCHAR / obs-text
27294
- * obs-text = %x80-FF
27295
- */
27296
-
27297
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
27298
-
27299
- /**
27300
- * Parse a cookie header.
27301
- *
27302
- * Parse the given cookie header string into an object
27303
- * The object has the various cookies as keys(names) => values
27304
- *
27305
- * @param {string} str
27306
- * @param {object} [options]
27307
- * @return {object}
27308
- * @public
27309
- */
27310
-
27311
- function parse(str, options) {
27312
- if (typeof str !== 'string') {
27313
- throw new TypeError('argument str must be a string');
27314
- }
27315
-
27316
- var obj = {}
27317
- var opt = options || {};
27318
- var pairs = str.split(';')
27319
- var dec = opt.decode || decode;
27320
-
27321
- for (var i = 0; i < pairs.length; i++) {
27322
- var pair = pairs[i];
27323
- var index = pair.indexOf('=')
27324
-
27325
- // skip things that don't look like key=value
27326
- if (index < 0) {
27327
- continue;
27328
- }
27329
-
27330
- var key = pair.substring(0, index).trim()
27331
-
27332
- // only assign once
27333
- if (undefined == obj[key]) {
27334
- var val = pair.substring(index + 1, pair.length).trim()
27335
-
27336
- // quoted values
27337
- if (val[0] === '"') {
27338
- val = val.slice(1, -1)
27339
- }
27340
-
27341
- obj[key] = tryDecode(val, dec);
27342
- }
27343
- }
27344
-
27345
- return obj;
27346
- }
27347
-
27348
- /**
27349
- * Serialize data into a cookie header.
27350
- *
27351
- * Serialize the a name value pair into a cookie string suitable for
27352
- * http headers. An optional options object specified cookie parameters.
27353
- *
27354
- * serialize('foo', 'bar', { httpOnly: true })
27355
- * => "foo=bar; httpOnly"
27356
- *
27357
- * @param {string} name
27358
- * @param {string} val
27359
- * @param {object} [options]
27360
- * @return {string}
27361
- * @public
27362
- */
27363
-
27364
- function serialize(name, val, options) {
27365
- var opt = options || {};
27366
- var enc = opt.encode || encode;
27367
-
27368
- if (typeof enc !== 'function') {
27369
- throw new TypeError('option encode is invalid');
27370
- }
27371
-
27372
- if (!fieldContentRegExp.test(name)) {
27373
- throw new TypeError('argument name is invalid');
27374
- }
27375
-
27376
- var value = enc(val);
27377
-
27378
- if (value && !fieldContentRegExp.test(value)) {
27379
- throw new TypeError('argument val is invalid');
27380
- }
27381
-
27382
- var str = name + '=' + value;
27383
-
27384
- if (null != opt.maxAge) {
27385
- var maxAge = opt.maxAge - 0;
27386
-
27387
- if (isNaN(maxAge) || !isFinite(maxAge)) {
27388
- throw new TypeError('option maxAge is invalid')
27389
- }
27390
-
27391
- str += '; Max-Age=' + Math.floor(maxAge);
27392
- }
27393
-
27394
- if (opt.domain) {
27395
- if (!fieldContentRegExp.test(opt.domain)) {
27396
- throw new TypeError('option domain is invalid');
27397
- }
27398
-
27399
- str += '; Domain=' + opt.domain;
27400
- }
27401
-
27402
- if (opt.path) {
27403
- if (!fieldContentRegExp.test(opt.path)) {
27404
- throw new TypeError('option path is invalid');
27405
- }
27406
-
27407
- str += '; Path=' + opt.path;
27408
- }
27409
-
27410
- if (opt.expires) {
27411
- if (typeof opt.expires.toUTCString !== 'function') {
27412
- throw new TypeError('option expires is invalid');
27413
- }
27414
-
27415
- str += '; Expires=' + opt.expires.toUTCString();
27416
- }
27417
-
27418
- if (opt.httpOnly) {
27419
- str += '; HttpOnly';
27420
- }
27421
-
27422
- if (opt.secure) {
27423
- str += '; Secure';
27424
- }
27425
-
27426
- if (opt.sameSite) {
27427
- var sameSite = typeof opt.sameSite === 'string'
27428
- ? opt.sameSite.toLowerCase() : opt.sameSite;
27429
-
27430
- switch (sameSite) {
27431
- case true:
27432
- str += '; SameSite=Strict';
27433
- break;
27434
- case 'lax':
27435
- str += '; SameSite=Lax';
27436
- break;
27437
- case 'strict':
27438
- str += '; SameSite=Strict';
27439
- break;
27440
- case 'none':
27441
- str += '; SameSite=None';
27442
- break;
27443
- default:
27444
- throw new TypeError('option sameSite is invalid');
27445
- }
27446
- }
27409
+
27410
+ /* harmony default export */ __webpack_exports__["default"] = (_Cookies__WEBPACK_IMPORTED_MODULE_0__["default"]);
27447
27411
 
27448
- return str;
27449
- }
27450
27412
 
27451
- /**
27452
- * Try decoding a string using a decoding function.
27453
- *
27454
- * @param {string} str
27455
- * @param {function} decode
27456
- * @private
27457
- */
27413
+ /***/ }),
27458
27414
 
27459
- function tryDecode(str, decode) {
27460
- try {
27461
- return decode(str);
27462
- } catch (e) {
27463
- return str;
27464
- }
27465
- }
27415
+ /***/ "../../node_modules/universal-cookie/es6/utils.js":
27416
+ /*!*******************************************************************!*\
27417
+ !*** /root/amplify-js/node_modules/universal-cookie/es6/utils.js ***!
27418
+ \*******************************************************************/
27419
+ /*! exports provided: hasDocumentCookie, cleanCookies, parseCookies, isParsingCookie, readCookie */
27420
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
27421
+
27422
+ "use strict";
27423
+ __webpack_require__.r(__webpack_exports__);
27424
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasDocumentCookie", function() { return hasDocumentCookie; });
27425
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cleanCookies", function() { return cleanCookies; });
27426
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseCookies", function() { return parseCookies; });
27427
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isParsingCookie", function() { return isParsingCookie; });
27428
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "readCookie", function() { return readCookie; });
27429
+ /* harmony import */ var cookie__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! cookie */ "../../node_modules/cookie/index.js");
27430
+ /* harmony import */ var cookie__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cookie__WEBPACK_IMPORTED_MODULE_0__);
27431
+
27432
+ function hasDocumentCookie() {
27433
+ // Can we get/set cookies on document.cookie?
27434
+ return typeof document === 'object' && typeof document.cookie === 'string';
27435
+ }
27436
+ function cleanCookies() {
27437
+ document.cookie.split(';').forEach(function (c) {
27438
+ document.cookie = c
27439
+ .replace(/^ +/, '')
27440
+ .replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/');
27441
+ });
27442
+ }
27443
+ function parseCookies(cookies, options) {
27444
+ if (typeof cookies === 'string') {
27445
+ return cookie__WEBPACK_IMPORTED_MODULE_0__["parse"](cookies, options);
27446
+ }
27447
+ else if (typeof cookies === 'object' && cookies !== null) {
27448
+ return cookies;
27449
+ }
27450
+ else {
27451
+ return {};
27452
+ }
27453
+ }
27454
+ function isParsingCookie(value, doNotParse) {
27455
+ if (typeof doNotParse === 'undefined') {
27456
+ // We guess if the cookie start with { or [, it has been serialized
27457
+ doNotParse =
27458
+ !value || (value[0] !== '{' && value[0] !== '[' && value[0] !== '"');
27459
+ }
27460
+ return !doNotParse;
27461
+ }
27462
+ function readCookie(value, options) {
27463
+ if (options === void 0) { options = {}; }
27464
+ var cleanValue = cleanupCookieValue(value);
27465
+ if (isParsingCookie(cleanValue, options.doNotParse)) {
27466
+ try {
27467
+ return JSON.parse(cleanValue);
27468
+ }
27469
+ catch (e) {
27470
+ // At least we tried
27471
+ }
27472
+ }
27473
+ // Ignore clean value if we failed the deserialization
27474
+ // It is not relevant anymore to trim those values
27475
+ return value;
27476
+ }
27477
+ function cleanupCookieValue(value) {
27478
+ // express prepend j: before serializing a cookie
27479
+ if (value && value[0] === 'j' && value[1] === ':') {
27480
+ return value.substr(2);
27481
+ }
27482
+ return value;
27483
+ }
27466
27484
 
27467
27485
 
27468
27486
  /***/ }),
@@ -30698,7 +30716,7 @@ function () {
30698
30716
  function HubClass(name) {
30699
30717
  this.listeners = [];
30700
30718
  this.patterns = [];
30701
- this.protectedChannels = ['core', 'auth', 'api', 'analytics', 'interactions', 'pubsub', 'storage', 'xr'];
30719
+ this.protectedChannels = ['core', 'auth', 'api', 'analytics', 'interactions', 'pubsub', 'storage', 'ui', 'xr'];
30702
30720
  this.name = name;
30703
30721
  } // Note - Need to pass channel as a reference for removal to work and not anonymous function
30704
30722
 
@@ -31646,6 +31664,7 @@ var LOG_LEVELS = {
31646
31664
  WARN: 4,
31647
31665
  ERROR: 5
31648
31666
  };
31667
+ var COMPATIBLE_PLUGINS = [_Util_Constants__WEBPACK_IMPORTED_MODULE_0__["AWS_CLOUDWATCH_CATEGORY"]];
31649
31668
  var LOG_TYPE;
31650
31669
 
31651
31670
  (function (LOG_TYPE) {
@@ -31655,12 +31674,13 @@ var LOG_TYPE;
31655
31674
  LOG_TYPE["WARN"] = "WARN";
31656
31675
  LOG_TYPE["VERBOSE"] = "VERBOSE";
31657
31676
  })(LOG_TYPE || (LOG_TYPE = {}));
31677
+
31678
+ var cloudWatchExcludeList = ['AWSCloudWatch', 'Amplify', 'Credentials', 'AuthClass', 'CloudLogger'];
31658
31679
  /**
31659
31680
  * Write logs
31660
31681
  * @class Logger
31661
31682
  */
31662
31683
 
31663
-
31664
31684
  var ConsoleLogger =
31665
31685
  /** @class */
31666
31686
  function () {
@@ -31676,8 +31696,19 @@ function () {
31676
31696
  this.name = name;
31677
31697
  this.level = level;
31678
31698
  this._pluggables = [];
31699
+ this.addPluggable = this.addPluggable.bind(this);
31679
31700
  }
31680
31701
 
31702
+ ConsoleLogger.globalPluggables = function (pluggable) {
31703
+ if (pluggable && COMPATIBLE_PLUGINS.includes(pluggable.getCategoryName())) {
31704
+ ConsoleLogger._globalpluggables.push(pluggable);
31705
+ }
31706
+ };
31707
+
31708
+ ConsoleLogger.clearGlobalPluggables = function () {
31709
+ ConsoleLogger._globalpluggables = [];
31710
+ };
31711
+
31681
31712
  ConsoleLogger.prototype._padding = function (n) {
31682
31713
  return n < 10 ? '0' + n : '' + n;
31683
31714
  };
@@ -31692,6 +31723,20 @@ function () {
31692
31723
  this._config = config;
31693
31724
  return this._config;
31694
31725
  };
31726
+
31727
+ ConsoleLogger.prototype._checkPluggables = function () {
31728
+ if (this._pluggables.length !== ConsoleLogger._globalpluggables.length) {
31729
+ if (ConsoleLogger._globalpluggables.length > 0) {
31730
+ ConsoleLogger._globalpluggables.forEach(this.addPluggable);
31731
+
31732
+ return;
31733
+ }
31734
+
31735
+ if (ConsoleLogger._globalpluggables.length === 0) {
31736
+ this._pluggables = [];
31737
+ }
31738
+ }
31739
+ };
31695
31740
  /**
31696
31741
  * Write log
31697
31742
  * @method
@@ -31704,12 +31749,49 @@ function () {
31704
31749
  ConsoleLogger.prototype._log = function (type) {
31705
31750
  var e_1, _a;
31706
31751
 
31752
+ var _this = this;
31753
+
31707
31754
  var msg = [];
31708
31755
 
31709
31756
  for (var _i = 1; _i < arguments.length; _i++) {
31710
31757
  msg[_i - 1] = arguments[_i];
31711
31758
  }
31712
31759
 
31760
+ if (!cloudWatchExcludeList.includes(this.name)) {
31761
+ this._checkPluggables();
31762
+ }
31763
+
31764
+ var generateMessage = function generateMessage(msg) {};
31765
+
31766
+ var generateCloudMessage = function generateCloudMessage(msg) {
31767
+ var message = '';
31768
+ var data;
31769
+
31770
+ if (msg.length === 1 && typeof msg[0] === 'string') {
31771
+ message = msg[0];
31772
+ } else if (msg.length === 1) {
31773
+ data = msg[0];
31774
+ } else if (typeof msg[0] === 'string') {
31775
+ var obj = msg.slice(1);
31776
+
31777
+ if (obj.length === 1) {
31778
+ obj = obj[0];
31779
+ }
31780
+
31781
+ message = msg[0];
31782
+ data = obj;
31783
+ } else {
31784
+ data = msg;
31785
+ }
31786
+
31787
+ return JSON.stringify({
31788
+ level: type,
31789
+ "class": _this.name,
31790
+ message: message,
31791
+ data: data
31792
+ });
31793
+ };
31794
+
31713
31795
  var logger_level_name = this.level;
31714
31796
 
31715
31797
  if (ConsoleLogger.LOG_LEVEL) {
@@ -31723,62 +31805,72 @@ function () {
31723
31805
  var logger_level = LOG_LEVELS[logger_level_name];
31724
31806
  var type_level = LOG_LEVELS[type];
31725
31807
 
31726
- if (!(type_level >= logger_level)) {
31727
- // Do nothing if type is not greater than or equal to logger level (handle undefined)
31728
- return;
31729
- }
31808
+ if (type_level >= logger_level) {
31809
+ var log = console.log.bind(console);
31730
31810
 
31731
- var log = console.log.bind(console);
31811
+ if (type === LOG_TYPE.ERROR && console.error) {
31812
+ log = console.error.bind(console);
31813
+ }
31732
31814
 
31733
- if (type === LOG_TYPE.ERROR && console.error) {
31734
- log = console.error.bind(console);
31735
- }
31815
+ if (type === LOG_TYPE.WARN && console.warn) {
31816
+ log = console.warn.bind(console);
31817
+ }
31736
31818
 
31737
- if (type === LOG_TYPE.WARN && console.warn) {
31738
- log = console.warn.bind(console);
31739
- }
31819
+ var prefix = "[" + type + "] " + this._ts() + " " + this.name;
31820
+ var message = '';
31821
+ var data = void 0;
31740
31822
 
31741
- var prefix = "[" + type + "] " + this._ts() + " " + this.name;
31742
- var message = '';
31823
+ if (msg.length === 1 && typeof msg[0] === 'string') {
31824
+ message = msg[0];
31825
+ log(prefix + " - " + message);
31826
+ } else if (msg.length === 1) {
31827
+ data = msg[0];
31828
+ log(prefix, data);
31829
+ } else if (typeof msg[0] === 'string') {
31830
+ var obj = msg.slice(1);
31743
31831
 
31744
- if (msg.length === 1 && typeof msg[0] === 'string') {
31745
- message = prefix + " - " + msg[0];
31746
- log(message);
31747
- } else if (msg.length === 1) {
31748
- message = prefix + " " + msg[0];
31749
- log(prefix, msg[0]);
31750
- } else if (typeof msg[0] === 'string') {
31751
- var obj = msg.slice(1);
31832
+ if (obj.length === 1) {
31833
+ obj = obj[0];
31834
+ }
31752
31835
 
31753
- if (obj.length === 1) {
31754
- obj = obj[0];
31836
+ message = msg[0];
31837
+ data = obj;
31838
+ log(prefix + " - " + message, data);
31839
+ } else {
31840
+ data = msg;
31841
+ log(prefix, data);
31755
31842
  }
31756
-
31757
- message = prefix + " - " + msg[0] + " " + obj;
31758
- log(prefix + " - " + msg[0], obj);
31759
- } else {
31760
- message = prefix + " " + msg;
31761
- log(prefix, msg);
31762
31843
  }
31763
31844
 
31764
- try {
31765
- for (var _b = __values(this._pluggables), _c = _b.next(); !_c.done; _c = _b.next()) {
31766
- var plugin = _c.value;
31767
- var logEvent = {
31768
- message: message,
31769
- timestamp: Date.now()
31770
- };
31771
- plugin.pushLogs([logEvent]);
31772
- }
31773
- } catch (e_1_1) {
31774
- e_1 = {
31775
- error: e_1_1
31776
- };
31777
- } finally {
31845
+ if (ConsoleLogger.CLOUD_LOG_LEVEL != null && !cloudWatchExcludeList.includes(this.name)) {
31846
+ var cloudMessage = generateCloudMessage(msg);
31847
+
31778
31848
  try {
31779
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
31849
+ for (var _b = __values(this._pluggables), _c = _b.next(); !_c.done; _c = _b.next()) {
31850
+ var plugin = _c.value;
31851
+ var logger_level_1 = LOG_LEVELS[ConsoleLogger.CLOUD_LOG_LEVEL];
31852
+ var type_level_1 = LOG_LEVELS[type];
31853
+ var logEvent = {
31854
+ message: cloudMessage,
31855
+ timestamp: Date.now()
31856
+ };
31857
+
31858
+ if (type_level_1 >= logger_level_1) {
31859
+ plugin.pushLogs([logEvent]);
31860
+ } else {
31861
+ plugin.pushLogs([]);
31862
+ }
31863
+ }
31864
+ } catch (e_1_1) {
31865
+ e_1 = {
31866
+ error: e_1_1
31867
+ };
31780
31868
  } finally {
31781
- if (e_1) throw e_1.error;
31869
+ try {
31870
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
31871
+ } finally {
31872
+ if (e_1) throw e_1.error;
31873
+ }
31782
31874
  }
31783
31875
  }
31784
31876
  };
@@ -31886,10 +31978,8 @@ function () {
31886
31978
  };
31887
31979
 
31888
31980
  ConsoleLogger.prototype.addPluggable = function (pluggable) {
31889
- if (pluggable && pluggable.getCategoryName() === _Util_Constants__WEBPACK_IMPORTED_MODULE_0__["AWS_CLOUDWATCH_CATEGORY"]) {
31981
+ if (pluggable && COMPATIBLE_PLUGINS.includes(pluggable.getCategoryName())) {
31890
31982
  this._pluggables.push(pluggable);
31891
-
31892
- pluggable.configure(this._config);
31893
31983
  }
31894
31984
  };
31895
31985
 
@@ -31897,7 +31987,9 @@ function () {
31897
31987
  return this._pluggables;
31898
31988
  };
31899
31989
 
31990
+ ConsoleLogger._globalpluggables = [];
31900
31991
  ConsoleLogger.LOG_LEVEL = null;
31992
+ ConsoleLogger.CLOUD_LOG_LEVEL = null;
31901
31993
  return ConsoleLogger;
31902
31994
  }();
31903
31995
 
@@ -32725,7 +32817,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
32725
32817
  __webpack_require__.r(__webpack_exports__);
32726
32818
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
32727
32819
  // generated by genversion
32728
- var version = '4.3.13';
32820
+ var version = '4.3.14';
32729
32821
 
32730
32822
  /***/ }),
32731
32823
 
@@ -32745,6 +32837,15 @@ __webpack_require__.r(__webpack_exports__);
32745
32837
  /* harmony import */ var _Platform__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Platform */ "./lib-esm/Platform/index.js");
32746
32838
  /* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Parser */ "./lib-esm/Parser.js");
32747
32839
  /* harmony import */ var _Util_Constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Util/Constants */ "./lib-esm/Util/Constants.js");
32840
+ function _typeof(obj) {
32841
+ "@babel/helpers - typeof";
32842
+
32843
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
32844
+ return typeof obj;
32845
+ } : function (obj) {
32846
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
32847
+ }, _typeof(obj);
32848
+ }
32748
32849
  /*
32749
32850
  * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
32750
32851
  *
@@ -32757,6 +32858,8 @@ __webpack_require__.r(__webpack_exports__);
32757
32858
  * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
32758
32859
  * and limitations under the License.
32759
32860
  */
32861
+
32862
+
32760
32863
  var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
32761
32864
  function adopt(value) {
32762
32865
  return value instanceof P ? value : new P(function (resolve) {
@@ -32900,61 +33003,42 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
32900
33003
  }
32901
33004
  };
32902
33005
 
32903
- var __read = undefined && undefined.__read || function (o, n) {
32904
- var m = typeof Symbol === "function" && o[Symbol.iterator];
32905
- if (!m) return o;
32906
- var i = m.call(o),
32907
- r,
32908
- ar = [],
32909
- e;
32910
-
32911
- try {
32912
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
32913
- ar.push(r.value);
32914
- }
32915
- } catch (error) {
32916
- e = {
32917
- error: error
32918
- };
32919
- } finally {
32920
- try {
32921
- if (r && !r.done && (m = i["return"])) m.call(i);
32922
- } finally {
32923
- if (e) throw e.error;
32924
- }
32925
- }
32926
-
32927
- return ar;
32928
- };
32929
-
32930
- var __spread = undefined && undefined.__spread || function () {
32931
- for (var ar = [], i = 0; i < arguments.length; i++) {
32932
- ar = ar.concat(__read(arguments[i]));
32933
- }
32934
33006
 
32935
- return ar;
32936
- };
32937
33007
 
32938
33008
 
32939
33009
 
32940
33010
 
32941
33011
 
32942
33012
 
33013
+ if (typeof window === 'undefined' || (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.TextEncoder) {
33014
+ __webpack_require__(/*! fast-text-encoding */ "../../node_modules/fast-text-encoding/text.min.js");
33015
+ }
32943
33016
 
32944
33017
  var logger = new _Logger__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]('AWSCloudWatch');
33018
+ var INTERVAL = 10000;
32945
33019
 
32946
33020
  var AWSCloudWatchProvider =
32947
33021
  /** @class */
32948
33022
  function () {
32949
33023
  function AWSCloudWatchProvider(config) {
32950
- this.configure(config);
32951
- this._dataTracker = {
32952
- eventUploadInProgress: false,
32953
- logEvents: []
32954
- };
32955
- this._currentLogBatch = [];
33024
+ this._initialized = false;
33025
+ console.log('cstr', config);
32956
33026
 
32957
- this._initiateLogPushInterval();
33027
+ if (!this._initialized) {
33028
+ this.configure(config);
33029
+ this._dataTracker = {
33030
+ eventUploadInProgress: false,
33031
+ logEvents: [],
33032
+ verifiedLogGroup: {
33033
+ logGroupName: this._config.logGroupName
33034
+ }
33035
+ };
33036
+ this._currentLogBatch = [];
33037
+
33038
+ this._initiateLogPushInterval();
33039
+
33040
+ this._initialized = true;
33041
+ }
32958
33042
  }
32959
33043
 
32960
33044
  AWSCloudWatchProvider.prototype.getProviderName = function () {
@@ -32969,6 +33053,12 @@ function () {
32969
33053
  return this._dataTracker.logEvents;
32970
33054
  };
32971
33055
 
33056
+ AWSCloudWatchProvider.prototype.setPreFlightCheck = function (cb) {
33057
+ if (typeof cb === 'function') {
33058
+ this._preFlightCheck = cb;
33059
+ }
33060
+ };
33061
+
32972
33062
  AWSCloudWatchProvider.prototype.configure = function (config) {
32973
33063
  if (!config) return this._config || {};
32974
33064
  var conf = Object.assign({}, this._config, Object(_Parser__WEBPACK_IMPORTED_MODULE_4__["parseMobileHubConfig"])(config).Logging, config);
@@ -33222,8 +33312,27 @@ function () {
33222
33312
  };
33223
33313
 
33224
33314
  AWSCloudWatchProvider.prototype.pushLogs = function (logs) {
33225
- logger.debug('pushing log events to Cloudwatch...');
33226
- this._dataTracker.logEvents = __spread(this._dataTracker.logEvents, logs);
33315
+ logger.debug('pushing log events to buffer');
33316
+ this._dataTracker.logEvents = this._dataTracker.logEvents.concat(logs);
33317
+ };
33318
+
33319
+ AWSCloudWatchProvider.prototype.pause = function () {
33320
+ this._processing = false;
33321
+
33322
+ if (this._timer) {
33323
+ clearInterval(this._timer);
33324
+ }
33325
+ };
33326
+
33327
+ AWSCloudWatchProvider.prototype.resume = function () {
33328
+ this._processing = true;
33329
+
33330
+ this._initiateLogPushInterval();
33331
+ };
33332
+
33333
+ AWSCloudWatchProvider.prototype.clear = function () {
33334
+ this._dataTracker.logEvents = [];
33335
+ this._currentLogBatch = [];
33227
33336
  };
33228
33337
 
33229
33338
  AWSCloudWatchProvider.prototype._validateLogGroupExistsAndCreate = function (logGroupName) {
@@ -33540,13 +33649,33 @@ function () {
33540
33649
  return __generator(this, function (_a) {
33541
33650
  switch (_a.label) {
33542
33651
  case 0:
33543
- _a.trys.push([0, 3,, 4]);
33652
+ _a.trys.push([0, 4,, 5]);
33544
33653
 
33545
33654
  return [4
33546
33655
  /*yield*/
33547
- , this._getNextSequenceToken()];
33656
+ , this._preFlightCheck()];
33548
33657
 
33549
33658
  case 1:
33659
+ /**
33660
+ * CloudWatch has restrictions on the size of the log events that get sent up.
33661
+ * We need to track both the size of each event and the total size of the batch
33662
+ * of logs.
33663
+ *
33664
+ * We also need to ensure that the logs in the batch are sorted in chronological order.
33665
+ * https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
33666
+ */
33667
+ if (!_a.sent()) {
33668
+ this.clear();
33669
+ return [2
33670
+ /*return*/
33671
+ ];
33672
+ }
33673
+
33674
+ return [4
33675
+ /*yield*/
33676
+ , this._getNextSequenceToken()];
33677
+
33678
+ case 2:
33550
33679
  seqToken = _a.sent();
33551
33680
  logBatch = this._currentLogBatch.length === 0 ? this._getBufferedBatchOfLogs() : this._currentLogBatch;
33552
33681
  putLogsPayload = {
@@ -33560,7 +33689,7 @@ function () {
33560
33689
  /*yield*/
33561
33690
  , this._sendLogEvents(putLogsPayload)];
33562
33691
 
33563
- case 2:
33692
+ case 3:
33564
33693
  sendLogEventsResponse = _a.sent();
33565
33694
  this._nextSequenceToken = sendLogEventsResponse.nextSequenceToken;
33566
33695
  this._dataTracker.eventUploadInProgress = false;
@@ -33569,7 +33698,7 @@ function () {
33569
33698
  /*return*/
33570
33699
  , sendLogEventsResponse];
33571
33700
 
33572
- case 3:
33701
+ case 4:
33573
33702
  err_5 = _a.sent();
33574
33703
  logger.error("error during _safeUploadLogEvents: " + err_5);
33575
33704
 
@@ -33586,9 +33715,9 @@ function () {
33586
33715
 
33587
33716
  return [3
33588
33717
  /*break*/
33589
- , 4];
33718
+ , 5];
33590
33719
 
33591
- case 4:
33720
+ case 5:
33592
33721
  return [2
33593
33722
  /*return*/
33594
33723
  ];
@@ -33597,6 +33726,41 @@ function () {
33597
33726
  });
33598
33727
  };
33599
33728
 
33729
+ AWSCloudWatchProvider.prototype.truncateOversizedEvent = function (event) {
33730
+ var timestamp = event.timestamp,
33731
+ message = event.message;
33732
+ var messageJson;
33733
+
33734
+ try {
33735
+ messageJson = JSON.parse(message);
33736
+ var truncated = JSON.stringify({
33737
+ level: messageJson.level,
33738
+ "class": messageJson["class"],
33739
+ message: messageJson.message.substring(0, 500)
33740
+ });
33741
+
33742
+ if (messageJson.data != null) {
33743
+ truncated['data'] = "OBJECT SIZE EXCEEDS CLOUDWATCH EVENT LIMIT. Truncated: " + JSON.stringify(messageJson.data).substring(0, 500);
33744
+ }
33745
+
33746
+ return {
33747
+ timestamp: timestamp,
33748
+ message: truncated
33749
+ };
33750
+ } catch (error) {
33751
+ logger.warn('Could not minify oversized event', error);
33752
+ var truncated = JSON.stringify({
33753
+ level: 'UNKNOWN',
33754
+ "class": 'Unknown',
33755
+ message: 'OBJECT SIZE EXCEEDS CLOUDWATCH EVENT LIMIT. Could not parse event to truncate'
33756
+ });
33757
+ return {
33758
+ timestamp: timestamp,
33759
+ message: truncated
33760
+ };
33761
+ }
33762
+ };
33763
+
33600
33764
  AWSCloudWatchProvider.prototype._getBufferedBatchOfLogs = function () {
33601
33765
  /**
33602
33766
  * CloudWatch has restrictions on the size of the log events that get sent up.
@@ -33616,7 +33780,9 @@ function () {
33616
33780
  if (eventSize > _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_MAX_EVENT_SIZE"]) {
33617
33781
  var errString = "Log entry exceeds maximum size for CloudWatch logs. Log size: " + eventSize + ". Truncating log message.";
33618
33782
  logger.warn(errString);
33619
- currentEvent.message = currentEvent.message.substring(0, eventSize);
33783
+ currentEvent = this.truncateOversizedEvent(currentEvent);
33784
+ this._dataTracker.logEvents[currentEventIdx] = currentEvent;
33785
+ eventSize = new TextEncoder().encode(currentEvent.message).length + _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_BASE_BUFFER_SIZE"];
33620
33786
  }
33621
33787
 
33622
33788
  if (totalByteSize + eventSize > _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE"]) break;
@@ -33707,6 +33873,7 @@ function () {
33707
33873
  case 3:
33708
33874
  err_7 = _a.sent();
33709
33875
  logger.error("error when calling _safeUploadLogEvents in the timer interval - " + err_7);
33876
+ this.pause();
33710
33877
  return [3
33711
33878
  /*break*/
33712
33879
  , 4];
@@ -33718,7 +33885,7 @@ function () {
33718
33885
  }
33719
33886
  });
33720
33887
  });
33721
- }, 2000);
33888
+ }, INTERVAL);
33722
33889
  };
33723
33890
 
33724
33891
  AWSCloudWatchProvider.prototype._getDocUploadPermissibility = function () {
@@ -34750,7 +34917,7 @@ function () {
34750
34917
  /*!***********************************!*\
34751
34918
  !*** ./lib-esm/Util/Constants.js ***!
34752
34919
  \***********************************/
34753
- /*! exports provided: AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES */
34920
+ /*! exports provided: AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY */
34754
34921
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
34755
34922
 
34756
34923
  "use strict";
@@ -34762,6 +34929,8 @@ __webpack_require__.r(__webpack_exports__);
34762
34929
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_CLOUDWATCH_PROVIDER_NAME", function() { return AWS_CLOUDWATCH_PROVIDER_NAME; });
34763
34930
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NO_CREDS_ERROR_STRING", function() { return NO_CREDS_ERROR_STRING; });
34764
34931
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RETRY_ERROR_CODES", function() { return RETRY_ERROR_CODES; });
34932
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_PROVIDER_NAME", function() { return AMAZON_KINESIS_LOGGING_PROVIDER_NAME; });
34933
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_CATEGORY", function() { return AMAZON_KINESIS_LOGGING_CATEGORY; });
34765
34934
  /*
34766
34935
  * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
34767
34936
  *
@@ -34775,11 +34944,14 @@ __webpack_require__.r(__webpack_exports__);
34775
34944
  * and limitations under the License.
34776
34945
  */
34777
34946
  // Logging constants
34947
+ // Cloudwatch
34778
34948
  var AWS_CLOUDWATCH_BASE_BUFFER_SIZE = 26;
34779
34949
  var AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE = 1048576;
34780
34950
  var AWS_CLOUDWATCH_MAX_EVENT_SIZE = 256000;
34781
34951
  var AWS_CLOUDWATCH_CATEGORY = 'Logging';
34782
34952
  var AWS_CLOUDWATCH_PROVIDER_NAME = 'AWSCloudWatch';
34953
+ var AMAZON_KINESIS_LOGGING_CATEGORY = 'KinesisLogging';
34954
+ var AMAZON_KINESIS_LOGGING_PROVIDER_NAME = 'AmazonKinesisLogging';
34783
34955
  var NO_CREDS_ERROR_STRING = 'No credentials';
34784
34956
  var RETRY_ERROR_CODES = ['ResourceNotFoundException', 'InvalidSequenceTokenException'];
34785
34957
 
@@ -35482,7 +35654,7 @@ function urlSafeDecode(hex) {
35482
35654
  /*!*******************************!*\
35483
35655
  !*** ./lib-esm/Util/index.js ***!
35484
35656
  \*******************************/
35485
- /*! exports provided: NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES */
35657
+ /*! exports provided: NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY */
35486
35658
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
35487
35659
 
35488
35660
  "use strict";
@@ -35523,6 +35695,10 @@ __webpack_require__.r(__webpack_exports__);
35523
35695
 
35524
35696
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RETRY_ERROR_CODES", function() { return _Constants__WEBPACK_IMPORTED_MODULE_5__["RETRY_ERROR_CODES"]; });
35525
35697
 
35698
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_PROVIDER_NAME", function() { return _Constants__WEBPACK_IMPORTED_MODULE_5__["AMAZON_KINESIS_LOGGING_PROVIDER_NAME"]; });
35699
+
35700
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_CATEGORY", function() { return _Constants__WEBPACK_IMPORTED_MODULE_5__["AMAZON_KINESIS_LOGGING_CATEGORY"]; });
35701
+
35526
35702
 
35527
35703
 
35528
35704
 
@@ -35572,7 +35748,7 @@ var USER_AGENT_HEADER = 'x-amz-user-agent';
35572
35748
  /*!**************************!*\
35573
35749
  !*** ./lib-esm/index.js ***!
35574
35750
  \**************************/
35575
- /*! exports provided: AmplifyClass, ClientDevice, ConsoleLogger, Logger, missingConfig, invalidParameter, Hub, I18n, isEmpty, sortByField, objectLessAttributes, filenameToContentType, isTextFile, generateRandomString, makeQuerablePromise, isWebWorker, browserOrNode, transferKeyToLowerCase, transferKeyToUpperCase, isStrictObject, JS, Signer, parseMobileHubConfig, Parser, AWSCloudWatchProvider, FacebookOAuth, GoogleOAuth, Linking, AppState, AsyncStorage, Credentials, CredentialsClass, ServiceWorker, StorageHelper, MemoryStorage, UniversalStorage, Platform, getAmplifyUserAgent, INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER, INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, Constants, NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, Amplify, default */
35751
+ /*! exports provided: AmplifyClass, ClientDevice, ConsoleLogger, Logger, missingConfig, invalidParameter, Hub, I18n, isEmpty, sortByField, objectLessAttributes, filenameToContentType, isTextFile, generateRandomString, makeQuerablePromise, isWebWorker, browserOrNode, transferKeyToLowerCase, transferKeyToUpperCase, isStrictObject, JS, Signer, parseMobileHubConfig, Parser, AWSCloudWatchProvider, FacebookOAuth, GoogleOAuth, Linking, AppState, AsyncStorage, Credentials, CredentialsClass, ServiceWorker, StorageHelper, MemoryStorage, UniversalStorage, Platform, getAmplifyUserAgent, INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER, INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, Constants, NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY, Amplify, default */
35576
35752
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
35577
35753
 
35578
35754
  "use strict";
@@ -35711,6 +35887,10 @@ __webpack_require__.r(__webpack_exports__);
35711
35887
 
35712
35888
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RETRY_ERROR_CODES", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["RETRY_ERROR_CODES"]; });
35713
35889
 
35890
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_PROVIDER_NAME", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["AMAZON_KINESIS_LOGGING_PROVIDER_NAME"]; });
35891
+
35892
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_CATEGORY", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["AMAZON_KINESIS_LOGGING_CATEGORY"]; });
35893
+
35714
35894
  /*
35715
35895
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
35716
35896
  *