/******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading /******/ function webpackJsonpCallback(data) { /******/ var chunkIds = data[0]; /******/ var moreModules = data[1]; /******/ /******/ /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = []; /******/ for(;i < chunkIds.length; i++) { /******/ chunkId = chunkIds[i]; /******/ if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) { /******/ resolves.push(installedChunks[chunkId][0]); /******/ } /******/ installedChunks[chunkId] = 0; /******/ } /******/ for(moduleId in moreModules) { /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } /******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } /******/ /******/ }; /******/ /******/ /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // object to store loaded and loading chunks /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched /******/ // Promise = chunk loading, 0 = chunk loaded /******/ var installedChunks = { /******/ 0: 0 /******/ }; /******/ /******/ /******/ /******/ // script path function /******/ function jsonpScriptSrc(chunkId) { /******/ return __webpack_require__.p + "" + chunkId + ".@@@BUNDLE_SCRIPT@@@" /******/ } /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { /******/ var promises = []; /******/ /******/ /******/ // JSONP chunk loading for javascript /******/ /******/ var installedChunkData = installedChunks[chunkId]; /******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ /******/ // a Promise means "currently loading". /******/ if(installedChunkData) { /******/ promises.push(installedChunkData[2]); /******/ } else { /******/ // setup Promise in chunk cache /******/ var promise = new Promise(function(resolve, reject) { /******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; /******/ }); /******/ promises.push(installedChunkData[2] = promise); /******/ /******/ // start chunk loading /******/ var script = document.createElement('script'); /******/ var onScriptComplete; /******/ /******/ script.charset = 'utf-8'; /******/ script.timeout = 120; /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } /******/ script.src = jsonpScriptSrc(chunkId); /******/ /******/ // create error before stack unwound to get useful stacktrace later /******/ var error = new Error(); /******/ onScriptComplete = function (event) { /******/ // avoid mem leaks in IE. /******/ script.onerror = script.onload = null; /******/ clearTimeout(timeout); /******/ var chunk = installedChunks[chunkId]; /******/ if(chunk !== 0) { /******/ if(chunk) { /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); /******/ var realSrc = event && event.target && event.target.src; /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'; /******/ error.name = 'ChunkLoadError'; /******/ error.type = errorType; /******/ error.request = realSrc; /******/ chunk[1](error); /******/ } /******/ installedChunks[chunkId] = undefined; /******/ } /******/ }; /******/ var timeout = setTimeout(function(){ /******/ onScriptComplete({ type: 'timeout', target: script }); /******/ }, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ document.head.appendChild(script); /******/ } /******/ } /******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/"; /******/ /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ /******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; /******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray); /******/ jsonpArray.push = webpackJsonpCallback; /******/ jsonpArray = jsonpArray.slice(); /******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); /******/ var parentJsonpFunction = oldJsonpFunction; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 1266); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; if (true) { module.exports = __webpack_require__(1428); } else {} /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ if (false) { var throwOnDirectAccess, isValidElement, REACT_ELEMENT_TYPE; } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod module.exports = __webpack_require__(1456)(); } /***/ }), /* 2 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /***/ }), /* 3 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clsx", function() { return clsx; }); function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t= 256) { return false; } } return true; } function arrayify(value, options) { if (!options) { options = {}; } if (typeof (value) === "number") { logger.checkSafeUint53(value, "invalid arrayify value"); const result = []; while (value) { result.unshift(value & 0xff); value = parseInt(String(value / 256)); } if (result.length === 0) { result.push(0); } return addSlice(new Uint8Array(result)); } if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { value = "0x" + value; } if (isHexable(value)) { value = value.toHexString(); } if (isHexString(value)) { let hex = value.substring(2); if (hex.length % 2) { if (options.hexPad === "left") { hex = "0" + hex; } else if (options.hexPad === "right") { hex += "0"; } else { logger.throwArgumentError("hex data is odd-length", "value", value); } } const result = []; for (let i = 0; i < hex.length; i += 2) { result.push(parseInt(hex.substring(i, i + 2), 16)); } return addSlice(new Uint8Array(result)); } if (isBytes(value)) { return addSlice(new Uint8Array(value)); } return logger.throwArgumentError("invalid arrayify value", "value", value); } function concat(items) { const objects = items.map(item => arrayify(item)); const length = objects.reduce((accum, item) => (accum + item.length), 0); const result = new Uint8Array(length); objects.reduce((offset, object) => { result.set(object, offset); return offset + object.length; }, 0); return addSlice(result); } function stripZeros(value) { let result = arrayify(value); if (result.length === 0) { return result; } // Find the first non-zero entry let start = 0; while (start < result.length && result[start] === 0) { start++; } // If we started with zeros, strip them if (start) { result = result.slice(start); } return result; } function zeroPad(value, length) { value = arrayify(value); if (value.length > length) { logger.throwArgumentError("value out of range", "value", arguments[0]); } const result = new Uint8Array(length); result.set(value, length - value.length); return addSlice(result); } function isHexString(value, length) { if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { return false; } if (length && value.length !== 2 + 2 * length) { return false; } return true; } const HexCharacters = "0123456789abcdef"; function hexlify(value, options) { if (!options) { options = {}; } if (typeof (value) === "number") { logger.checkSafeUint53(value, "invalid hexlify value"); let hex = ""; while (value) { hex = HexCharacters[value & 0xf] + hex; value = Math.floor(value / 16); } if (hex.length) { if (hex.length % 2) { hex = "0" + hex; } return "0x" + hex; } return "0x00"; } if (typeof (value) === "bigint") { value = value.toString(16); if (value.length % 2) { return ("0x0" + value); } return "0x" + value; } if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { value = "0x" + value; } if (isHexable(value)) { return value.toHexString(); } if (isHexString(value)) { if (value.length % 2) { if (options.hexPad === "left") { value = "0x0" + value.substring(2); } else if (options.hexPad === "right") { value += "0"; } else { logger.throwArgumentError("hex data is odd-length", "value", value); } } return value.toLowerCase(); } if (isBytes(value)) { let result = "0x"; for (let i = 0; i < value.length; i++) { let v = value[i]; result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; } return result; } return logger.throwArgumentError("invalid hexlify value", "value", value); } /* function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number { if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") { return "0x0" + value.substring(2); } return value; } */ function hexDataLength(data) { if (typeof (data) !== "string") { data = hexlify(data); } else if (!isHexString(data) || (data.length % 2)) { return null; } return (data.length - 2) / 2; } function hexDataSlice(data, offset, endOffset) { if (typeof (data) !== "string") { data = hexlify(data); } else if (!isHexString(data) || (data.length % 2)) { logger.throwArgumentError("invalid hexData", "value", data); } offset = 2 + 2 * offset; if (endOffset != null) { return "0x" + data.substring(offset, 2 + 2 * endOffset); } return "0x" + data.substring(offset); } function hexConcat(items) { let result = "0x"; items.forEach((item) => { result += hexlify(item).substring(2); }); return result; } function hexValue(value) { const trimmed = hexStripZeros(hexlify(value, { hexPad: "left" })); if (trimmed === "0x") { return "0x0"; } return trimmed; } function hexStripZeros(value) { if (typeof (value) !== "string") { value = hexlify(value); } if (!isHexString(value)) { logger.throwArgumentError("invalid hex string", "value", value); } value = value.substring(2); let offset = 0; while (offset < value.length && value[offset] === "0") { offset++; } return "0x" + value.substring(offset); } function hexZeroPad(value, length) { if (typeof (value) !== "string") { value = hexlify(value); } else if (!isHexString(value)) { logger.throwArgumentError("invalid hex string", "value", value); } if (value.length > 2 * length + 2) { logger.throwArgumentError("value out of range", "value", arguments[1]); } while (value.length < 2 * length + 2) { value = "0x0" + value.substring(2); } return value; } function splitSignature(signature) { const result = { r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0, yParityAndS: "0x", compact: "0x" }; if (isBytesLike(signature)) { let bytes = arrayify(signature); // Get the r, s and v if (bytes.length === 64) { // EIP-2098; pull the v from the top bit of s and clear it result.v = 27 + (bytes[32] >> 7); bytes[32] &= 0x7f; result.r = hexlify(bytes.slice(0, 32)); result.s = hexlify(bytes.slice(32, 64)); } else if (bytes.length === 65) { result.r = hexlify(bytes.slice(0, 32)); result.s = hexlify(bytes.slice(32, 64)); result.v = bytes[64]; } else { logger.throwArgumentError("invalid signature string", "signature", signature); } // Allow a recid to be used as the v if (result.v < 27) { if (result.v === 0 || result.v === 1) { result.v += 27; } else { logger.throwArgumentError("signature invalid v byte", "signature", signature); } } // Compute recoveryParam from v result.recoveryParam = 1 - (result.v % 2); // Compute _vs from recoveryParam and s if (result.recoveryParam) { bytes[32] |= 0x80; } result._vs = hexlify(bytes.slice(32, 64)); } else { result.r = signature.r; result.s = signature.s; result.v = signature.v; result.recoveryParam = signature.recoveryParam; result._vs = signature._vs; // If the _vs is available, use it to populate missing s, v and recoveryParam // and verify non-missing s, v and recoveryParam if (result._vs != null) { const vs = zeroPad(arrayify(result._vs), 32); result._vs = hexlify(vs); // Set or check the recid const recoveryParam = ((vs[0] >= 128) ? 1 : 0); if (result.recoveryParam == null) { result.recoveryParam = recoveryParam; } else if (result.recoveryParam !== recoveryParam) { logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); } // Set or check the s vs[0] &= 0x7f; const s = hexlify(vs); if (result.s == null) { result.s = s; } else if (result.s !== s) { logger.throwArgumentError("signature v mismatch _vs", "signature", signature); } } // Use recid and v to populate each other if (result.recoveryParam == null) { if (result.v == null) { logger.throwArgumentError("signature missing v and recoveryParam", "signature", signature); } else if (result.v === 0 || result.v === 1) { result.recoveryParam = result.v; } else { result.recoveryParam = 1 - (result.v % 2); } } else { if (result.v == null) { result.v = 27 + result.recoveryParam; } else { const recId = (result.v === 0 || result.v === 1) ? result.v : (1 - (result.v % 2)); if (result.recoveryParam !== recId) { logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature); } } } if (result.r == null || !isHexString(result.r)) { logger.throwArgumentError("signature missing or invalid r", "signature", signature); } else { result.r = hexZeroPad(result.r, 32); } if (result.s == null || !isHexString(result.s)) { logger.throwArgumentError("signature missing or invalid s", "signature", signature); } else { result.s = hexZeroPad(result.s, 32); } const vs = arrayify(result.s); if (vs[0] >= 128) { logger.throwArgumentError("signature s out of range", "signature", signature); } if (result.recoveryParam) { vs[0] |= 0x80; } const _vs = hexlify(vs); if (result._vs) { if (!isHexString(result._vs)) { logger.throwArgumentError("signature invalid _vs", "signature", signature); } result._vs = hexZeroPad(result._vs, 32); } // Set or check the _vs if (result._vs == null) { result._vs = _vs; } else if (result._vs !== _vs) { logger.throwArgumentError("signature _vs mismatch v and s", "signature", signature); } } result.yParityAndS = result._vs; result.compact = result.r + result.yParityAndS.substring(2); return result; } function joinSignature(signature) { signature = splitSignature(signature); return hexlify(concat([ signature.r, signature.s, (signature.recoveryParam ? "0x1c" : "0x1b") ])); } //# sourceMappingURL=index.js.map /***/ }), /* 6 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; }); /* harmony import */ var _objectWithoutPropertiesLoose_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81); function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = Object(_objectWithoutPropertiesLoose_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { // TODO(Babel 8): Remove this file. var runtime = __webpack_require__(1436)(); module.exports = runtime; // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736= try { regeneratorRuntime = runtime; } catch (accidentalStrictMode) { if (typeof globalThis === "object") { globalThis.regeneratorRuntime = runtime; } else { Function("r", "regeneratorRuntime = r")(runtime); } } /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global, process) { Object.defineProperty(exports, '__esModule', { value: true }); var tslib_1 = __webpack_require__(131); var core = __webpack_require__(1472); var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } var dist = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); /** JSDoc */ var Severity; (function (Severity) { /** JSDoc */ Severity["Fatal"] = "fatal"; /** JSDoc */ Severity["Error"] = "error"; /** JSDoc */ Severity["Warning"] = "warning"; /** JSDoc */ Severity["Log"] = "log"; /** JSDoc */ Severity["Info"] = "info"; /** JSDoc */ Severity["Debug"] = "debug"; /** JSDoc */ Severity["Critical"] = "critical"; })(Severity = exports.Severity || (exports.Severity = {})); // tslint:disable:no-unnecessary-qualifier no-namespace (function (Severity) { /** * Converts a string-based level into a {@link Severity}. * * @param level string representation of Severity * @returns Severity */ function fromString(level) { switch (level) { case 'debug': return Severity.Debug; case 'info': return Severity.Info; case 'warn': case 'warning': return Severity.Warning; case 'error': return Severity.Error; case 'fatal': return Severity.Fatal; case 'critical': return Severity.Critical; case 'log': default: return Severity.Log; } } Severity.fromString = fromString; })(Severity = exports.Severity || (exports.Severity = {})); /** The status of an event. */ var Status; (function (Status) { /** The status could not be determined. */ Status["Unknown"] = "unknown"; /** The event was skipped due to configuration or callbacks. */ Status["Skipped"] = "skipped"; /** The event was sent to Sentry successfully. */ Status["Success"] = "success"; /** The client is currently rate limited and will try again later. */ Status["RateLimit"] = "rate_limit"; /** The event could not be processed. */ Status["Invalid"] = "invalid"; /** A server-side error ocurred during submission. */ Status["Failed"] = "failed"; })(Status = exports.Status || (exports.Status = {})); // tslint:disable:no-unnecessary-qualifier no-namespace (function (Status) { /** * Converts a HTTP status code into a {@link Status}. * * @param code The HTTP response status code. * @returns The send status or {@link Status.Unknown}. */ function fromHttpCode(code) { if (code >= 200 && code < 300) { return Status.Success; } if (code === 429) { return Status.RateLimit; } if (code >= 400 && code < 500) { return Status.Invalid; } if (code >= 500) { return Status.Failed; } return Status.Unknown; } Status.fromHttpCode = fromHttpCode; })(Status = exports.Status || (exports.Status = {})); }); unwrapExports(dist); var dist_1 = dist.Severity; var dist_2 = dist.Status; var is = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); /** * Checks whether given value's type is one of a few Error or Error-like * {@link isError}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isError(wat) { switch (Object.prototype.toString.call(wat)) { case '[object Error]': return true; case '[object Exception]': return true; case '[object DOMException]': return true; default: return wat instanceof Error; } } exports.isError = isError; /** * Checks whether given value's type is ErrorEvent * {@link isErrorEvent}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isErrorEvent(wat) { return Object.prototype.toString.call(wat) === '[object ErrorEvent]'; } exports.isErrorEvent = isErrorEvent; /** * Checks whether given value's type is DOMError * {@link isDOMError}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isDOMError(wat) { return Object.prototype.toString.call(wat) === '[object DOMError]'; } exports.isDOMError = isDOMError; /** * Checks whether given value's type is DOMException * {@link isDOMException}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isDOMException(wat) { return Object.prototype.toString.call(wat) === '[object DOMException]'; } exports.isDOMException = isDOMException; /** * Checks whether given value's type is an undefined * {@link isUndefined}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isUndefined(wat) { return wat === void 0; } exports.isUndefined = isUndefined; /** * Checks whether given value's type is a function * {@link isFunction}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isFunction(wat) { return typeof wat === 'function'; } exports.isFunction = isFunction; /** * Checks whether given value's type is a string * {@link isString}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isString(wat) { return Object.prototype.toString.call(wat) === '[object String]'; } exports.isString = isString; /** * Checks whether given value's is a primitive (undefined, null, number, boolean, string) * {@link isPrimitive}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isPrimitive(wat) { return wat === null || (typeof wat !== 'object' && typeof wat !== 'function'); } exports.isPrimitive = isPrimitive; /** * Checks whether given value's type is an array * {@link isArray}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isArray(wat) { return Object.prototype.toString.call(wat) === '[object Array]'; } exports.isArray = isArray; /** * Checks whether given value's type is an object literal * {@link isPlainObject}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isPlainObject(wat) { return Object.prototype.toString.call(wat) === '[object Object]'; } exports.isPlainObject = isPlainObject; /** * Checks whether given value's type is an regexp * {@link isRegExp}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isRegExp(wat) { return Object.prototype.toString.call(wat) === '[object RegExp]'; } exports.isRegExp = isRegExp; /** * Checks whether given value's type is a NaN * {@link isNaN}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isNaN(wat) { return wat !== wat; } exports.isNaN = isNaN; /** * Checks whether given value's type is a SyntheticEvent * {@link isSyntheticEvent}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isSyntheticEvent(wat) { // tslint:disable-next-line:no-unsafe-any return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat; } exports.isSyntheticEvent = isSyntheticEvent; }); unwrapExports(is); var is_1 = is.isError; var is_2 = is.isErrorEvent; var is_3 = is.isDOMError; var is_4 = is.isDOMException; var is_5 = is.isUndefined; var is_6 = is.isFunction; var is_7 = is.isString; var is_8 = is.isPrimitive; var is_9 = is.isArray; var is_10 = is.isPlainObject; var is_11 = is.isRegExp; var is_12 = is.isNaN; var is_13 = is.isSyntheticEvent; var misc = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); /** * Requires a module which is protected against bundler minification. * * @param request The module path to resolve */ function dynamicRequire(mod, request) { return mod.require(request); } exports.dynamicRequire = dynamicRequire; /** * Checks whether we're in the Node.js or Browser environment * * @returns Answer to given question */ function isNodeEnv() { // tslint:disable:strict-type-predicates return Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; } exports.isNodeEnv = isNodeEnv; var fallbackGlobalObject = {}; /** * Safely get global scope object * * @returns Global scope object */ // tslint:disable:strict-type-predicates function getGlobalObject() { return isNodeEnv() ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : fallbackGlobalObject; } exports.getGlobalObject = getGlobalObject; /** * UUID4 generator * * @returns string Generated UUID4. */ function uuid4() { var global = getGlobalObject(); var crypto = global.crypto || global.msCrypto; if (!(crypto === void 0) && crypto.getRandomValues) { // Use window.crypto API if available var arr = new Uint16Array(8); crypto.getRandomValues(arr); // set 4 in byte 7 // tslint:disable-next-line:no-bitwise arr[3] = (arr[3] & 0xfff) | 0x4000; // set 2 most significant bits of byte 9 to '10' // tslint:disable-next-line:no-bitwise arr[4] = (arr[4] & 0x3fff) | 0x8000; var pad = function (num) { var v = num.toString(16); while (v.length < 4) { v = "0" + v; } return v; }; return (pad(arr[0]) + pad(arr[1]) + pad(arr[2]) + pad(arr[3]) + pad(arr[4]) + pad(arr[5]) + pad(arr[6]) + pad(arr[7])); } else { // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523 return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) { // tslint:disable-next-line:no-bitwise var r = (Math.random() * 16) | 0; // tslint:disable-next-line:no-bitwise var v = c === 'x' ? r : (r & 0x3) | 0x8; return v.toString(16); }); } } exports.uuid4 = uuid4; /** * Given a child DOM element, returns a query-selector statement describing that * and its ancestors * e.g. [HTMLElement] => body > div > input#foo.btn[name=baz] * @returns generated DOM path */ function htmlTreeAsString(elem) { var currentElem = elem; var MAX_TRAVERSE_HEIGHT = 5; var MAX_OUTPUT_LEN = 80; var out = []; var height = 0; var len = 0; var separator = ' > '; var sepLength = separator.length; var nextStr; while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) { nextStr = htmlElementAsString(currentElem); // bail out if // - nextStr is the 'html' element // - the length of the string that would be created exceeds MAX_OUTPUT_LEN // (ignore this limit if we are on the first iteration) if (nextStr === 'html' || (height > 1 && len + out.length * sepLength + nextStr.length >= MAX_OUTPUT_LEN)) { break; } out.push(nextStr); len += nextStr.length; currentElem = currentElem.parentNode; } return out.reverse().join(separator); } exports.htmlTreeAsString = htmlTreeAsString; /** * Returns a simple, query-selector representation of a DOM element * e.g. [HTMLElement] => input#foo.btn[name=baz] * @returns generated DOM path */ function htmlElementAsString(elem) { var out = []; var className; var classes; var key; var attr; var i; if (!elem || !elem.tagName) { return ''; } out.push(elem.tagName.toLowerCase()); if (elem.id) { out.push("#" + elem.id); } className = elem.className; if (className && is.isString(className)) { classes = className.split(/\s+/); for (i = 0; i < classes.length; i++) { out.push("." + classes[i]); } } var attrWhitelist = ['type', 'name', 'title', 'alt']; for (i = 0; i < attrWhitelist.length; i++) { key = attrWhitelist[i]; attr = elem.getAttribute(key); if (attr) { out.push("[" + key + "=\"" + attr + "\"]"); } } return out.join(''); } exports.htmlElementAsString = htmlElementAsString; /** * Parses string form of URL into an object * // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B * // intentionally using regex and not href parsing trick because React Native and other * // environments where DOM might not be available * @returns parsed URL object */ function parseUrl(url) { if (!url) { return {}; } var match = url.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/); if (!match) { return {}; } // coerce to undefined values to empty string so we don't get 'undefined' var query = match[6] || ''; var fragment = match[8] || ''; return { host: match[4], path: match[5], protocol: match[2], relative: match[5] + query + fragment, }; } exports.parseUrl = parseUrl; /** * Extracts either message or type+value from an event that can be used for user-facing logs * @returns event's description */ function getEventDescription(event) { if (event.message) { return event.message; } else if (event.exception && event.exception.values && event.exception.values[0]) { var exception = event.exception.values[0]; if (exception.type && exception.value) { return exception.type + ": " + exception.value; } else { return exception.type || exception.value || event.event_id || ''; } } else { return event.event_id || ''; } } exports.getEventDescription = getEventDescription; /** JSDoc */ function consoleSandbox(callback) { var global = getGlobalObject(); var levels = ['debug', 'info', 'warn', 'error', 'log']; if (!('console' in global)) { return callback(); } var originalConsole = global.console; var wrappedLevels = {}; // Restore all wrapped console methods levels.forEach(function (level) { if (level in global.console && originalConsole[level].__sentry__) { wrappedLevels[level] = originalConsole[level].__sentry_wrapped__; originalConsole[level] = originalConsole[level].__sentry_original__; } }); // Perform callback manipulations var result = callback(); // Revert restoration to wrapped state Object.keys(wrappedLevels).forEach(function (level) { originalConsole[level] = wrappedLevels[level]; }); return result; } exports.consoleSandbox = consoleSandbox; }); unwrapExports(misc); var misc_1 = misc.dynamicRequire; var misc_2 = misc.isNodeEnv; var misc_3 = misc.getGlobalObject; var misc_4 = misc.uuid4; var misc_5 = misc.htmlTreeAsString; var misc_6 = misc.htmlElementAsString; var misc_7 = misc.parseUrl; var misc_8 = misc.getEventDescription; var misc_9 = misc.consoleSandbox; var supports = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); /** * Tells whether current environment supports ErrorEvent objects * {@link supportsErrorEvent}. * * @returns Answer to the given question. */ function supportsErrorEvent() { try { // tslint:disable:no-unused-expression new ErrorEvent(''); return true; } catch (e) { return false; } } exports.supportsErrorEvent = supportsErrorEvent; /** * Tells whether current environment supports DOMError objects * {@link supportsDOMError}. * * @returns Answer to the given question. */ function supportsDOMError() { try { // It really needs 1 argument, not 0. // Chrome: VM89:1 Uncaught TypeError: Failed to construct 'DOMError': // 1 argument required, but only 0 present. // @ts-ignore // tslint:disable:no-unused-expression new DOMError(''); return true; } catch (e) { return false; } } exports.supportsDOMError = supportsDOMError; /** * Tells whether current environment supports DOMException objects * {@link supportsDOMException}. * * @returns Answer to the given question. */ function supportsDOMException() { try { // tslint:disable:no-unused-expression new DOMException(''); return true; } catch (e) { return false; } } exports.supportsDOMException = supportsDOMException; /** * Tells whether current environment supports Fetch API * {@link supportsFetch}. * * @returns Answer to the given question. */ function supportsFetch() { if (!('fetch' in misc.getGlobalObject())) { return false; } try { // tslint:disable-next-line:no-unused-expression new Headers(); // tslint:disable-next-line:no-unused-expression new Request(''); // tslint:disable-next-line:no-unused-expression new Response(); return true; } catch (e) { return false; } } exports.supportsFetch = supportsFetch; /** * Tells whether current environment supports Fetch API natively * {@link supportsNativeFetch}. * * @returns Answer to the given question. */ function supportsNativeFetch() { if (!supportsFetch()) { return false; } var global = misc.getGlobalObject(); var fetch = global.fetch; // tslint:disable-next-line:no-unsafe-any return fetch.toString().indexOf('native') !== -1; } exports.supportsNativeFetch = supportsNativeFetch; /** * Tells whether current environment supports ReportingObserver API * {@link supportsReportingObserver}. * * @returns Answer to the given question. */ function supportsReportingObserver() { return 'ReportingObserver' in misc.getGlobalObject(); } exports.supportsReportingObserver = supportsReportingObserver; /** * Tells whether current environment supports Referrer Policy API * {@link supportsReferrerPolicy}. * * @returns Answer to the given question. */ function supportsReferrerPolicy() { // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default // https://caniuse.com/#feat=referrer-policy // It doesn't. And it throw exception instead of ignoring this parameter... // REF: https://github.com/getsentry/raven-js/issues/1233 if (!supportsFetch()) { return false; } try { // tslint:disable:no-unused-expression new Request('pickleRick', { referrerPolicy: 'origin', }); return true; } catch (e) { return false; } } exports.supportsReferrerPolicy = supportsReferrerPolicy; /** * Tells whether current environment supports History API * {@link supportsHistory}. * * @returns Answer to the given question. */ function supportsHistory() { // NOTE: in Chrome App environment, touching history.pushState, *even inside // a try/catch block*, will cause Chrome to output an error to console.error // borrowed from: https://github.com/angular/angular.js/pull/13945/files var global = misc.getGlobalObject(); var chrome = global.chrome; // tslint:disable-next-line:no-unsafe-any var isChromePackagedApp = chrome && chrome.app && chrome.app.runtime; var hasHistoryApi = 'history' in global && !!global.history.pushState && !!global.history.replaceState; return !isChromePackagedApp && hasHistoryApi; } exports.supportsHistory = supportsHistory; }); unwrapExports(supports); var supports_1 = supports.supportsErrorEvent; var supports_2 = supports.supportsDOMError; var supports_3 = supports.supportsDOMException; var supports_4 = supports.supportsFetch; var supports_5 = supports.supportsNativeFetch; var supports_6 = supports.supportsReportingObserver; var supports_7 = supports.supportsReferrerPolicy; var supports_8 = supports.supportsHistory; var memo = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); // tslint:disable:no-unsafe-any /** * Memo class used for decycle json objects. Uses WeakSet if available otherwise array. */ var Memo = /** @class */ (function () { function Memo() { // tslint:disable-next-line this.hasWeakSet = typeof WeakSet === 'function'; this.inner = this.hasWeakSet ? new WeakSet() : []; } /** * Sets obj to remember. * @param obj Object to remember */ Memo.prototype.memoize = function (obj) { if (this.hasWeakSet) { if (this.inner.has(obj)) { return true; } this.inner.add(obj); return false; } else { // tslint:disable-next-line:prefer-for-of for (var i = 0; i < this.inner.length; i++) { var value = this.inner[i]; if (value === obj) { return true; } } this.inner.push(obj); return false; } }; /** * Removes object from internal storage. * @param obj Object to forget */ Memo.prototype.unmemoize = function (obj) { if (this.hasWeakSet) { this.inner.delete(obj); } else { for (var i = 0; i < this.inner.length; i++) { if (this.inner[i] === obj) { this.inner.splice(i, 1); break; } } } }; return Memo; }()); exports.Memo = Memo; }); unwrapExports(memo); var memo_1 = memo.Memo; var string = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); /** * Truncates given string to the maximum characters count * * @param str An object that contains serializable values * @param max Maximum number of characters in truncated string * @returns string Encoded */ function truncate(str, max) { if (max === void 0) { max = 0; } if (max === 0 || !is.isString(str)) { return str; } return str.length <= max ? str : str.substr(0, max) + "..."; } exports.truncate = truncate; /** * This is basically just `trim_line` from * https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67 * * @param str An object that contains serializable values * @param max Maximum number of characters in truncated string * @returns string Encoded */ function snipLine(line, colno) { var newLine = line; var ll = newLine.length; if (ll <= 150) { return newLine; } if (colno > ll) { colno = ll; // tslint:disable-line:no-parameter-reassignment } var start = Math.max(colno - 60, 0); if (start < 5) { start = 0; } var end = Math.min(start + 140, ll); if (end > ll - 5) { end = ll; } if (end === ll) { start = Math.max(end - 140, 0); } newLine = newLine.slice(start, end); if (start > 0) { newLine = "'{snip} " + newLine; } if (end < ll) { newLine += ' {snip}'; } return newLine; } exports.snipLine = snipLine; /** * Join values in array * @param input array of values to be joined together * @param delimiter string to be placed in-between values * @returns Joined values */ function safeJoin(input, delimiter) { if (!Array.isArray(input)) { return ''; } var output = []; // tslint:disable-next-line:prefer-for-of for (var i = 0; i < input.length; i++) { var value = input[i]; try { output.push(String(value)); } catch (e) { output.push('[value cannot be serialized]'); } } return output.join(delimiter); } exports.safeJoin = safeJoin; /** * Checks if given value is included in the target * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill * @param target source string * @param search string to be looked for * @returns An answer */ function includes(target, search) { if (search.length > target.length) { return false; } else { return target.indexOf(search) !== -1; } } exports.includes = includes; }); unwrapExports(string); var string_1 = string.truncate; var string_2 = string.snipLine; var string_3 = string.safeJoin; var string_4 = string.includes; var object = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); /** * Serializes the given object into a string. * Like JSON.stringify, but doesn't throw on circular references. * * @param object A JSON-serializable object. * @returns A string containing the serialized object. */ function serialize(object) { return JSON.stringify(object, serializer({ normalize: false })); } exports.serialize = serialize; /** * Deserializes an object from a string previously serialized with * {@link serialize}. * * @param str A serialized object. * @returns The deserialized object. */ function deserialize(str) { return JSON.parse(str); } exports.deserialize = deserialize; /** * Creates a deep copy of the given object. * * The object must be serializable, i.e.: * - It must not contain any cycles * - Only primitive types are allowed (object, array, number, string, boolean) * - Its depth should be considerably low for performance reasons * * @param object A JSON-serializable object. * @returns The object clone. */ function clone(object) { return deserialize(serialize(object)); } exports.clone = clone; /** * Wrap a given object method with a higher-order function * * @param source An object that contains a method to be wrapped. * @param name A name of method to be wrapped. * @param replacement A function that should be used to wrap a given method. * @returns void */ function fill(source, name, replacement) { if (!(name in source) || source[name].__sentry__) { return; } var original = source[name]; var wrapped = replacement(original); // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work // otherwise it'll throw "TypeError: Object.defineProperties called on non-object" // tslint:disable-next-line:strict-type-predicates if (typeof wrapped === 'function') { wrapped.prototype = wrapped.prototype || {}; Object.defineProperties(wrapped, { __sentry__: { enumerable: false, value: true, }, __sentry_original__: { enumerable: false, value: original, }, __sentry_wrapped__: { enumerable: false, value: wrapped, }, }); } source[name] = wrapped; } exports.fill = fill; /** * Encodes given object into url-friendly format * * @param object An object that contains serializable values * @returns string Encoded */ function urlEncode(object) { return Object.keys(object) .map( // tslint:disable-next-line:no-unsafe-any function (key) { return encodeURIComponent(key) + "=" + encodeURIComponent(object[key]); }) .join('&'); } exports.urlEncode = urlEncode; // Default Node.js REPL depth var MAX_SERIALIZE_EXCEPTION_DEPTH = 3; // 100kB, as 200kB is max payload size, so half sounds reasonable var MAX_SERIALIZE_EXCEPTION_SIZE = 100 * 1024; var MAX_SERIALIZE_KEYS_LENGTH = 40; /** JSDoc */ function utf8Length(value) { // tslint:disable-next-line:no-bitwise return ~-encodeURI(value).split(/%..|./).length; } /** JSDoc */ function jsonSize(value) { return utf8Length(JSON.stringify(value)); } /** JSDoc */ function serializeValue(value) { var type = Object.prototype.toString.call(value); // Node.js REPL notation if (typeof value === 'string') { return string.truncate(value, 40); } else if (type === '[object Object]') { return '[Object]'; } else if (type === '[object Array]') { return '[Array]'; } else { var normalized = normalizeValue(value); return is.isPrimitive(normalized) ? "" + normalized : type; } } /** JSDoc */ function serializeObject(value, depth) { if (depth === 0) { return serializeValue(value); } if (is.isPlainObject(value)) { var serialized_1 = {}; var val_1 = value; Object.keys(val_1).forEach(function (key) { serialized_1[key] = serializeObject(val_1[key], depth - 1); }); return serialized_1; } else if (is.isArray(value)) { var val = value; return val.map(function (v) { return serializeObject(v, depth - 1); }); } return serializeValue(value); } exports.serializeObject = serializeObject; /** JSDoc */ function limitObjectDepthToSize(object, depth, maxSize) { if (depth === void 0) { depth = MAX_SERIALIZE_EXCEPTION_DEPTH; } if (maxSize === void 0) { maxSize = MAX_SERIALIZE_EXCEPTION_SIZE; } var serialized = serializeObject(object, depth); if (jsonSize(serialize(serialized)) > maxSize) { return limitObjectDepthToSize(object, depth - 1); } return serialized; } exports.limitObjectDepthToSize = limitObjectDepthToSize; /** JSDoc */ function serializeKeysToEventMessage(keys, maxLength) { if (maxLength === void 0) { maxLength = MAX_SERIALIZE_KEYS_LENGTH; } if (!keys.length) { return '[object has no keys]'; } if (keys[0].length >= maxLength) { return string.truncate(keys[0], maxLength); } for (var includedKeys = keys.length; includedKeys > 0; includedKeys--) { var serialized = keys.slice(0, includedKeys).join(', '); if (serialized.length > maxLength) { continue; } if (includedKeys === keys.length) { return serialized; } return string.truncate(serialized, maxLength); } return ''; } exports.serializeKeysToEventMessage = serializeKeysToEventMessage; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill /** JSDoc */ function assign(target) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } if (target === null || target === undefined) { throw new TypeError('Cannot convert undefined or null to object'); } var to = Object(target); // tslint:disable-next-line:prefer-for-of for (var i = 0; i < args.length; i++) { var source = args[i]; if (source !== null) { for (var nextKey in source) { if (Object.prototype.hasOwnProperty.call(source, nextKey)) { to[nextKey] = source[nextKey]; } } } } return to; } exports.assign = assign; /** * Transforms Error object into an object literal with all it's attributes * attached to it. * * Based on: https://github.com/ftlabs/js-abbreviate/blob/fa709e5f139e7770a71827b1893f22418097fbda/index.js#L95-L106 * * @param error An Error containing all relevant information * @returns An object with all error properties */ function objectifyError(error) { // These properties are implemented as magical getters and don't show up in `for-in` loop var err = { message: error.message, name: error.name, stack: error.stack, }; for (var i in error) { if (Object.prototype.hasOwnProperty.call(error, i)) { err[i] = error[i]; } } return err; } /** * normalizeValue() * * Takes unserializable input and make it serializable friendly * * - translates undefined/NaN values to "[undefined]"/"[NaN]" respectively, * - serializes Error objects * - filter global objects */ function normalizeValue(value, key) { if (key === 'domain' && typeof value === 'object' && value._events) { return '[Domain]'; } if (key === 'domainEmitter') { return '[DomainEmitter]'; } if (typeof commonjsGlobal !== 'undefined' && value === commonjsGlobal) { return '[Global]'; } if (typeof window !== 'undefined' && value === window) { return '[Window]'; } if (typeof document !== 'undefined' && value === document) { return '[Document]'; } // tslint:disable-next-line:strict-type-predicates if (typeof Event !== 'undefined' && value instanceof Event) { return Object.getPrototypeOf(value) ? value.constructor.name : 'Event'; } // React's SyntheticEvent thingy if (is.isSyntheticEvent(value)) { return '[SyntheticEvent]'; } if (is.isNaN(value)) { return '[NaN]'; } if (is.isUndefined(value)) { return '[undefined]'; } if (typeof value === 'function') { return "[Function: " + (value.name || '') + "]"; } return value; } /** * Decycles an object to make it safe for json serialization. * * @param obj Object to be decycled * @param memo Optional Memo class handling decycling */ function decycle(obj, depth, memo$$1) { if (depth === void 0) { depth = +Infinity; } if (memo$$1 === void 0) { memo$$1 = new memo.Memo(); } if (depth === 0) { return serializeValue(obj); } // If an object was normalized to its string form, we should just bail out as theres no point in going down that branch var normalized = normalizeValue(obj); if (is.isPrimitive(normalized)) { return normalized; } // tslint:disable-next-line:no-unsafe-any var source = (is.isError(obj) ? objectifyError(obj) : obj); var copy = is.isArray(obj) ? [] : {}; if (memo$$1.memoize(obj)) { return '[Circular ~]'; } for (var key in source) { // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration. if (!Object.prototype.hasOwnProperty.call(source, key)) { continue; } copy[key] = decycle(source[key], depth - 1, memo$$1); } memo$$1.unmemoize(obj); return copy; } exports.decycle = decycle; /** * serializer() * * Remove circular references, * translates undefined/NaN values to "[undefined]"/"[NaN]" respectively, * and takes care of Error objects serialization */ function serializer(options) { if (options === void 0) { options = { normalize: true }; } return function (key, value) { // tslint:disable-next-line return options.normalize ? normalizeValue(decycle(value, options.depth), key) : decycle(value, options.depth); }; } /** * safeNormalize() * * Creates a copy of the input by applying serializer function on it and parsing it back to unify the data */ function safeNormalize(input, depth) { try { return JSON.parse(JSON.stringify(input, serializer({ normalize: true, depth: depth }))); } catch (_oO) { return '**non-serializable**'; } } exports.safeNormalize = safeNormalize; }); unwrapExports(object); var object_1 = object.serialize; var object_2 = object.deserialize; var object_3 = object.clone; var object_4 = object.fill; var object_5 = object.urlEncode; var object_6 = object.serializeObject; var object_7 = object.limitObjectDepthToSize; var object_8 = object.serializeKeysToEventMessage; var object_9 = object.assign; var object_10 = object.decycle; var object_11 = object.safeNormalize; // tslint:disable /* * JavaScript MD5 * https://github.com/blueimp/JavaScript-MD5 * * Copyright 2011, Sebastian Tschan * https://blueimp.net * * Licensed under the MIT license: * https://opensource.org/licenses/MIT * * Based on * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ /** * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safeAdd(x, y) { var lsw = (x & 0xffff) + (y & 0xffff); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xffff); } /** * Bitwise rotate a 32-bit number to the left. */ function bitRotateLeft(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } /** * These functions implement the four basic operations the algorithm uses. */ function md5cmn(q, a, b, x, s, t) { return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b); } function md5ff(a, b, c, d, x, s, t) { return md5cmn((b & c) | (~b & d), a, b, x, s, t); } function md5gg(a, b, c, d, x, s, t) { return md5cmn((b & d) | (c & ~d), a, b, x, s, t); } function md5hh(a, b, c, d, x, s, t) { return md5cmn(b ^ c ^ d, a, b, x, s, t); } function md5ii(a, b, c, d, x, s, t) { return md5cmn(c ^ (b | ~d), a, b, x, s, t); } /** * Calculate the MD5 of an array of little-endian words, and a bit length. */ function binlMD5(x, len) { /** append padding */ x[len >> 5] |= 0x80 << len % 32; x[(((len + 64) >>> 9) << 4) + 14] = len; var i; var olda; var oldb; var oldc; var oldd; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for (i = 0; i < x.length; i += 16) { olda = a; oldb = b; oldc = c; oldd = d; a = md5ff(a, b, c, d, x[i], 7, -680876936); d = md5ff(d, a, b, c, x[i + 1], 12, -389564586); c = md5ff(c, d, a, b, x[i + 2], 17, 606105819); b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330); a = md5ff(a, b, c, d, x[i + 4], 7, -176418897); d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426); c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341); b = md5ff(b, c, d, a, x[i + 7], 22, -45705983); a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416); d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417); c = md5ff(c, d, a, b, x[i + 10], 17, -42063); b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162); a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682); d = md5ff(d, a, b, c, x[i + 13], 12, -40341101); c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290); b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329); a = md5gg(a, b, c, d, x[i + 1], 5, -165796510); d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632); c = md5gg(c, d, a, b, x[i + 11], 14, 643717713); b = md5gg(b, c, d, a, x[i], 20, -373897302); a = md5gg(a, b, c, d, x[i + 5], 5, -701558691); d = md5gg(d, a, b, c, x[i + 10], 9, 38016083); c = md5gg(c, d, a, b, x[i + 15], 14, -660478335); b = md5gg(b, c, d, a, x[i + 4], 20, -405537848); a = md5gg(a, b, c, d, x[i + 9], 5, 568446438); d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690); c = md5gg(c, d, a, b, x[i + 3], 14, -187363961); b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501); a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467); d = md5gg(d, a, b, c, x[i + 2], 9, -51403784); c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473); b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734); a = md5hh(a, b, c, d, x[i + 5], 4, -378558); d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463); c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562); b = md5hh(b, c, d, a, x[i + 14], 23, -35309556); a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060); d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353); c = md5hh(c, d, a, b, x[i + 7], 16, -155497632); b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640); a = md5hh(a, b, c, d, x[i + 13], 4, 681279174); d = md5hh(d, a, b, c, x[i], 11, -358537222); c = md5hh(c, d, a, b, x[i + 3], 16, -722521979); b = md5hh(b, c, d, a, x[i + 6], 23, 76029189); a = md5hh(a, b, c, d, x[i + 9], 4, -640364487); d = md5hh(d, a, b, c, x[i + 12], 11, -421815835); c = md5hh(c, d, a, b, x[i + 15], 16, 530742520); b = md5hh(b, c, d, a, x[i + 2], 23, -995338651); a = md5ii(a, b, c, d, x[i], 6, -198630844); d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415); c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905); b = md5ii(b, c, d, a, x[i + 5], 21, -57434055); a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571); d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606); c = md5ii(c, d, a, b, x[i + 10], 15, -1051523); b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799); a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359); d = md5ii(d, a, b, c, x[i + 15], 10, -30611744); c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380); b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649); a = md5ii(a, b, c, d, x[i + 4], 6, -145523070); d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379); c = md5ii(c, d, a, b, x[i + 2], 15, 718787259); b = md5ii(b, c, d, a, x[i + 9], 21, -343485551); a = safeAdd(a, olda); b = safeAdd(b, oldb); c = safeAdd(c, oldc); d = safeAdd(d, oldd); } return [a, b, c, d]; } /** * Convert an array of little-endian words to a string */ function binl2rstr(input) { var i; var output = ''; var length32 = input.length * 32; for (i = 0; i < length32; i += 8) { output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff); } return output; } /** * Convert a raw string to an array of little-endian words * Characters >255 have their high-byte silently ignored. */ function rstr2binl(input) { var i; var output = []; output[(input.length >> 2) - 1] = undefined; for (i = 0; i < output.length; i += 1) { output[i] = 0; } var length8 = input.length * 8; for (i = 0; i < length8; i += 8) { output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32; } return output; } /** * Calculate the MD5 of a raw string */ function rstrMD5(s) { return binl2rstr(binlMD5(rstr2binl(s), s.length * 8)); } /** * Calculate the HMAC-MD5, of a key and some data (raw strings) */ function rstrHMACMD5(key, data) { var i; var bkey = rstr2binl(key); var ipad = []; var opad = []; var hash; ipad[15] = opad[15] = undefined; if (bkey.length > 16) { bkey = binlMD5(bkey, key.length * 8); } for (i = 0; i < 16; i += 1) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5c5c5c5c; } hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8); return binl2rstr(binlMD5(opad.concat(hash), 512 + 128)); } /** * Convert a raw string to a hex string */ function rstr2hex(input) { var hexTab = '0123456789abcdef'; var output = ''; var x; var i; for (i = 0; i < input.length; i += 1) { x = input.charCodeAt(i); output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f); } return output; } /** * Encode a string as utf-8 */ function str2rstrUTF8(input) { return unescape(encodeURIComponent(input)); } /* * Take string arguments and return either raw or hex encoded strings */ function rawMD5(s) { return rstrMD5(str2rstrUTF8(s)); } function hexMD5(s) { return rstr2hex(rawMD5(s)); } function rawHMACMD5(k, d) { return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d)); } function hexHMACMD5(k, d) { return rstr2hex(rawHMACMD5(k, d)); } function md5(string, key, raw) { if (!key) { if (!raw) { return hexMD5(string); } return rawMD5(string); } if (!raw) { return hexHMACMD5(key, string); } return rawHMACMD5(key, string); } // tslint:disable /** * TraceKit - Cross brower stack traces * * This was originally forked from github.com/occ/TraceKit, but has since been * largely modified and is now maintained as part of Sentry JS SDK. * * NOTE: Last merge with upstream repository * Jul 11,2018 - #f03357c * * https://github.com/csnover/TraceKit * @license MIT * @namespace TraceKit */ var window$1 = misc_3(); var TraceKit = { wrap: function () { return function () { }; }, report: false, collectWindowErrors: false, computeStackTrace: false, remoteFetching: false, linesOfContext: false, extendToAsynchronousCallbacks: false, }; // var TraceKit: TraceKitInterface = {}; // var TraceKit = {}; // global reference to slice var _slice = [].slice; var UNKNOWN_FUNCTION = '?'; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/; /** * A better form of hasOwnProperty
* Example: `_has(MainHostObject, property) === true/false` * * @param {Object} object to check property * @param {string} key to check * @return {Boolean} true if the object has the key and it is not inherited */ function _has(object, key) { return Object.prototype.hasOwnProperty.call(object, key); } /** * A safe form of location.href
* * @return {string} location.href */ function getLocationHref() { if (typeof document === 'undefined' || document.location == null) return ''; return document.location.href; } /** * A safe form of location.origin
* * @return {string} location.origin */ function getLocationOrigin() { if (typeof document === 'undefined' || document.location == null) return ''; // Oh dear IE10... if (!document.location.origin) { return (document.location.protocol + '//' + document.location.hostname + (document.location.port ? ':' + document.location.port : '')); } return document.location.origin; } /** * Wrap any function in a TraceKit reporter
* Example: `func = TraceKit.wrap(func);` * * @param {Function} func Function to be wrapped * @return {Function} The wrapped func * @memberof TraceKit */ TraceKit.wrap = function traceKitWrapper(func) { function wrapped() { try { // @ts-ignore return func.apply(this, arguments); } catch (e) { TraceKit.report(e); throw e; } } return wrapped; }; /** * Cross-browser processing of unhandled exceptions * * Syntax: * ```js * TraceKit.report.subscribe(function(stackInfo) { ... }) * TraceKit.report.unsubscribe(function(stackInfo) { ... }) * TraceKit.report(exception) * try { ...code... } catch(ex) { TraceKit.report(ex); } * ``` * * Supports: * - Firefox: full stack trace with line numbers, plus column number * on top frame; column number is not guaranteed * - Opera: full stack trace with line and column numbers * - Chrome: full stack trace with line and column numbers * - Safari: line and column number for the top frame only; some frames * may be missing, and column number is not guaranteed * - IE: line and column number for the top frame only; some frames * may be missing, and column number is not guaranteed * * In theory, TraceKit should work on all of the following versions: * - IE5.5+ (only 8.0 tested) * - Firefox 0.9+ (only 3.5+ tested) * - Opera 7+ (only 10.50 tested; versions 9 and earlier may require * Exceptions Have Stacktrace to be enabled in opera:config) * - Safari 3+ (only 4+ tested) * - Chrome 1+ (only 5+ tested) * - Konqueror 3.5+ (untested) * * Requires TraceKit.computeStackTrace. * * Tries to catch all unhandled exceptions and report them to the * subscribed handlers. Please note that TraceKit.report will rethrow the * exception. This is REQUIRED in order to get a useful stack trace in IE. * If the exception does not reach the top of the browser, you will only * get a stack trace from the point where TraceKit.report was called. * * Handlers receive a TraceKit.StackTrace object as described in the * TraceKit.computeStackTrace docs. * * @memberof TraceKit * @namespace */ TraceKit.report = (function reportModuleWrapper() { var handlers = [], lastException = null, lastExceptionStack = null; /** * Add a crash handler. * @param {Function} handler * @memberof TraceKit.report */ function subscribe(handler) { // NOTE: We call both handlers manually in browser/integrations/globalhandler.ts // So user can choose which one he wants to attach // installGlobalHandler(); // installGlobalUnhandledRejectionHandler(); handlers.push(handler); } /** * Remove a crash handler. * @param {Function} handler * @memberof TraceKit.report */ function unsubscribe(handler) { for (var i = handlers.length - 1; i >= 0; --i) { if (handlers[i] === handler) { handlers.splice(i, 1); } } if (handlers.length === 0) { uninstallGlobalHandler(); uninstallGlobalUnhandledRejectionHandler(); } } /** * Dispatch stack information to all handlers. * @param {TraceKit.StackTrace} stack * @param {boolean} isWindowError Is this a top-level window error? * @param {Error=} error The error that's being handled (if available, null otherwise) * @memberof TraceKit.report * @throws An exception if an error occurs while calling an handler. */ function notifyHandlers(stack, isWindowError, error) { var exception = null; if (isWindowError && !TraceKit.collectWindowErrors) { return; } for (var i in handlers) { if (_has(handlers, i)) { try { handlers[i](stack, isWindowError, error); } catch (inner) { exception = inner; } } } if (exception) { throw exception; } } var _oldOnerrorHandler, _onErrorHandlerInstalled; var _oldOnunhandledrejectionHandler, _onUnhandledRejectionHandlerInstalled; /** * Ensures all global unhandled exceptions are recorded. * Supported by Gecko and IE. * @param {string} message Error message. * @param {string} url URL of script that generated the exception. * @param {(number|string)} lineNo The line number at which the error occurred. * @param {(number|string)=} columnNo The column number at which the error occurred. * @param {Error=} errorObj The actual Error object. * @memberof TraceKit.report */ function traceKitWindowOnError(message, url, lineNo, columnNo, errorObj) { var stack = null; // If 'errorObj' is ErrorEvent, get real Error from inside errorObj = is_2(errorObj) ? errorObj.error : errorObj; // If 'message' is ErrorEvent, get real message from inside message = is_2(message) ? message.message : message; if (lastExceptionStack) { TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(lastExceptionStack, url, lineNo, message); processLastException(); } else if (errorObj && is_1(errorObj)) { stack = TraceKit.computeStackTrace(errorObj); stack.mechanism = 'onerror'; notifyHandlers(stack, true, errorObj); } else { var location = { url: url, line: lineNo, column: columnNo, }; var name; var msg = message; // must be new var or will modify original `arguments` if ({}.toString.call(message) === '[object String]') { var groups = message.match(ERROR_TYPES_RE); if (groups) { name = groups[1]; msg = groups[2]; } } location.func = TraceKit.computeStackTrace.guessFunctionName(location.url, location.line); location.context = TraceKit.computeStackTrace.gatherContext(location.url, location.line); stack = { name: name, message: msg, mode: 'onerror', mechanism: 'onerror', stack: [ tslib_1.__assign({}, location, { // Firefox sometimes doesn't return url correctly and this is an old behavior // that I prefer to port here as well. // It can be altered only here, as previously it's using `location.url` for other things — Kamil url: location.url || getLocationHref() }), ], }; notifyHandlers(stack, true, null); } if (_oldOnerrorHandler) { // @ts-ignore return _oldOnerrorHandler.apply(this, arguments); } return false; } /** * Ensures all unhandled rejections are recorded. * @param {PromiseRejectionEvent} e event. * @memberof TraceKit.report * @see https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onunhandledrejection * @see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent */ function traceKitWindowOnUnhandledRejection(e) { var err = (e && (e.detail ? e.detail.reason : e.reason)) || e; var stack = TraceKit.computeStackTrace(err); stack.mechanism = 'onunhandledrejection'; notifyHandlers(stack, true, err); } /** * Install a global onerror handler * @memberof TraceKit.report */ function installGlobalHandler() { if (_onErrorHandlerInstalled === true) { return; } _oldOnerrorHandler = window$1.onerror; window$1.onerror = traceKitWindowOnError; _onErrorHandlerInstalled = true; } /** * Uninstall the global onerror handler * @memberof TraceKit.report */ function uninstallGlobalHandler() { if (_onErrorHandlerInstalled) { window$1.onerror = _oldOnerrorHandler; _onErrorHandlerInstalled = false; } } /** * Install a global onunhandledrejection handler * @memberof TraceKit.report */ function installGlobalUnhandledRejectionHandler() { if (_onUnhandledRejectionHandlerInstalled === true) { return; } _oldOnunhandledrejectionHandler = window$1.onunhandledrejection; window$1.onunhandledrejection = traceKitWindowOnUnhandledRejection; _onUnhandledRejectionHandlerInstalled = true; } /** * Uninstall the global onunhandledrejection handler * @memberof TraceKit.report */ function uninstallGlobalUnhandledRejectionHandler() { if (_onUnhandledRejectionHandlerInstalled) { window$1.onunhandledrejection = _oldOnunhandledrejectionHandler; _onUnhandledRejectionHandlerInstalled = false; } } /** * Process the most recent exception * @memberof TraceKit.report */ function processLastException() { var _lastExceptionStack = lastExceptionStack, _lastException = lastException; lastExceptionStack = null; lastException = null; notifyHandlers(_lastExceptionStack, false, _lastException); } /** * Reports an unhandled Error to TraceKit. * @param {Error} ex * @memberof TraceKit.report * @throws An exception if an incomplete stack trace is detected (old IE browsers). */ function report(ex) { if (lastExceptionStack) { if (lastException === ex) { return; // already caught by an inner catch block, ignore } else { processLastException(); } } var stack = TraceKit.computeStackTrace(ex); lastExceptionStack = stack; lastException = ex; // If the stack trace is incomplete, wait for 2 seconds for // slow slow IE to see if onerror occurs or not before reporting // this exception; otherwise, we will end up with an incomplete // stack trace setTimeout(function () { if (lastException === ex) { processLastException(); } }, stack.incomplete ? 2000 : 0); throw ex; // re-throw to propagate to the top level (and cause window.onerror) } report.subscribe = subscribe; report.unsubscribe = unsubscribe; report.installGlobalHandler = installGlobalHandler; report.installGlobalUnhandledRejectionHandler = installGlobalUnhandledRejectionHandler; return report; })(); /** * An object representing a single stack frame. * @typedef {Object} StackFrame * @property {string} url The JavaScript or HTML file URL. * @property {string} func The function name, or empty for anonymous functions (if guessing did not work). * @property {string[]?} args The arguments passed to the function, if known. * @property {number=} line The line number, if known. * @property {number=} column The column number, if known. * @property {string[]} context An array of source code lines; the middle element corresponds to the correct line#. * @memberof TraceKit */ /** * An object representing a JavaScript stack trace. * @typedef {Object} StackTrace * @property {string} name The name of the thrown exception. * @property {string} message The exception error message. * @property {TraceKit.StackFrame[]} stack An array of stack frames. * @property {string} mode 'stack', 'stacktrace', 'multiline', 'callers', 'onerror', or 'failed' -- method used to collect the stack trace. * @memberof TraceKit */ /** * TraceKit.computeStackTrace: cross-browser stack traces in JavaScript * * Syntax: * ```js * s = TraceKit.computeStackTrace.ofCaller([depth]) * s = TraceKit.computeStackTrace(exception) // consider using TraceKit.report instead (see below) * ``` * * Supports: * - Firefox: full stack trace with line numbers and unreliable column * number on top frame * - Opera 10: full stack trace with line and column numbers * - Opera 9-: full stack trace with line numbers * - Chrome: full stack trace with line and column numbers * - Safari: line and column number for the topmost stacktrace element * only * - IE: no line numbers whatsoever * * Tries to guess names of anonymous functions by looking for assignments * in the source code. In IE and Safari, we have to guess source file names * by searching for function bodies inside all page scripts. This will not * work for scripts that are loaded cross-domain. * Here be dragons: some function names may be guessed incorrectly, and * duplicate functions may be mismatched. * * TraceKit.computeStackTrace should only be used for tracing purposes. * Logging of unhandled exceptions should be done with TraceKit.report, * which builds on top of TraceKit.computeStackTrace and provides better * IE support by utilizing the window.onerror event to retrieve information * about the top of the stack. * * Note: In IE and Safari, no stack trace is recorded on the Error object, * so computeStackTrace instead walks its *own* chain of callers. * This means that: * * in Safari, some methods may be missing from the stack trace; * * in IE, the topmost function in the stack trace will always be the * caller of computeStackTrace. * * This is okay for tracing (because you are likely to be calling * computeStackTrace from the function you want to be the topmost element * of the stack trace anyway), but not okay for logging unhandled * exceptions (because your catch block will likely be far away from the * inner function that actually caused the exception). * * Tracing example: * ```js * function trace(message) { * var stackInfo = TraceKit.computeStackTrace.ofCaller(); * var data = message + "\n"; * for(var i in stackInfo.stack) { * var item = stackInfo.stack[i]; * data += (item.func || '[anonymous]') + "() in " + item.url + ":" + (item.line || '0') + "\n"; * } * if (window.console) * console.info(data); * else * alert(data); * } * ``` * @memberof TraceKit * @namespace */ TraceKit.computeStackTrace = (function computeStackTraceWrapper() { var debug = false, sourceCache = {}; /** * Attempts to retrieve source code via XMLHttpRequest, which is used * to look up anonymous function names. * @param {string} url URL of source code. * @return {string} Source contents. * @memberof TraceKit.computeStackTrace */ function loadSource(url) { if (!TraceKit.remoteFetching) { //Only attempt request if remoteFetching is on. return ''; } try { var getXHR = function () { try { return new window$1.XMLHttpRequest(); } catch (e) { // explicitly bubble up the exception if not found return new window$1.ActiveXObject('Microsoft.XMLHTTP'); } }; var request = getXHR(); request.open('GET', url, false); request.send(''); return request.responseText; } catch (e) { return ''; } } /** * Retrieves source code from the source code cache. * @param {string} url URL of source code. * @return {Array.} Source contents. * @memberof TraceKit.computeStackTrace */ function getSource(url) { if (typeof url !== 'string') { return []; } if (!_has(sourceCache, url)) { // URL needs to be able to fetched within the acceptable domain. Otherwise, // cross-domain errors will be triggered. /* Regex matches: 0 - Full Url 1 - Protocol 2 - Domain 3 - Port (Useful for internal applications) 4 - Path */ var source = ''; var domain = ''; try { domain = window$1.document.domain; } catch (e) { } var match = /(.*)\:\/\/([^:\/]+)([:\d]*)\/{0,1}([\s\S]*)/.exec(url); if (match && match[2] === domain) { source = loadSource(url); } sourceCache[url] = source ? source.split('\n') : []; } return sourceCache[url]; } /** * Tries to use an externally loaded copy of source code to determine * the name of a function by looking at the name of the variable it was * assigned to, if any. * @param {string} url URL of source code. * @param {(string|number)} lineNo Line number in source code. * @return {string} The function name, if discoverable. * @memberof TraceKit.computeStackTrace */ function guessFunctionName(url, lineNo) { var reFunctionArgNames = /function ([^(]*)\(([^)]*)\)/, reGuessFunction = /['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/, line = '', maxLines = 10, source = getSource(url), m; if (!source.length) { return UNKNOWN_FUNCTION; } // Walk backwards from the first line in the function until we find the line which // matches the pattern above, which is the function definition for (var i = 0; i < maxLines; ++i) { line = source[lineNo - i] + line; if (!is_5(line)) { if ((m = reGuessFunction.exec(line))) { return m[1]; } else if ((m = reFunctionArgNames.exec(line))) { return m[1]; } } } return UNKNOWN_FUNCTION; } /** * Retrieves the surrounding lines from where an exception occurred. * @param {string} url URL of source code. * @param {(string|number)} line Line number in source code to center around for context. * @return {?Array.} Lines of source code. * @memberof TraceKit.computeStackTrace */ function gatherContext(url, line) { var source = getSource(url); if (!source.length) { return null; } var context = [], // linesBefore & linesAfter are inclusive with the offending line. // if linesOfContext is even, there will be one extra line // *before* the offending line. linesBefore = Math.floor(TraceKit.linesOfContext / 2), // Add one extra line if linesOfContext is odd linesAfter = linesBefore + (TraceKit.linesOfContext % 2), start = Math.max(0, line - linesBefore - 1), end = Math.min(source.length, line + linesAfter - 1); line -= 1; // convert to 0-based index for (var i = start; i < end; ++i) { if (!is_5(source[i])) { context.push(source[i]); } } return context.length > 0 ? context : null; } /** * Escapes special characters, except for whitespace, in a string to be * used inside a regular expression as a string literal. * @param {string} text The string. * @return {string} The escaped string literal. * @memberof TraceKit.computeStackTrace */ function escapeRegExp(text) { return text.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g, '\\$&'); } /** * Escapes special characters in a string to be used inside a regular * expression as a string literal. Also ensures that HTML entities will * be matched the same as their literal friends. * @param {string} body The string. * @return {string} The escaped string. * @memberof TraceKit.computeStackTrace */ function escapeCodeAsRegExpForMatchingInsideHTML(body) { return escapeRegExp(body) .replace('<', '(?:<|<)') .replace('>', '(?:>|>)') .replace('&', '(?:&|&)') .replace('"', '(?:"|")') .replace(/\s+/g, '\\s+'); } /** * Determines where a code fragment occurs in the source code. * @param {RegExp} re The function definition. * @param {Array.} urls A list of URLs to search. * @return {?Object.} An object containing * the url, line, and column number of the defined function. * @memberof TraceKit.computeStackTrace */ function findSourceInUrls(re, urls) { var source, m; for (var i = 0, j = urls.length; i < j; ++i) { if ((source = getSource(urls[i])).length) { source = source.join('\n'); if ((m = re.exec(source))) { return { url: urls[i], line: source.substring(0, m.index).split('\n').length, column: m.index - source.lastIndexOf('\n', m.index) - 1, }; } } } return null; } /** * Determines at which column a code fragment occurs on a line of the * source code. * @param {string} fragment The code fragment. * @param {string} url The URL to search. * @param {(string|number)} line The line number to examine. * @return {?number} The column number. * @memberof TraceKit.computeStackTrace */ function findSourceInLine(fragment, url, line) { var source = getSource(url), re = new RegExp('\\b' + escapeRegExp(fragment) + '\\b'), m; line -= 1; if (source && source.length > line && (m = re.exec(source[line]))) { return m.index; } return null; } /** * Determines where a function was defined within the source code. * @param {(Function|string)} func A function reference or serialized * function definition. * @return {?Object.} An object containing * the url, line, and column number of the defined function. * @memberof TraceKit.computeStackTrace */ function findSourceByFunctionBody(func) { if (is_5(window$1 && window$1.document)) { return; } var urls = [getLocationHref()], scripts = window$1.document.getElementsByTagName('script'), body, code = '' + func, codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, eventRE = /^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, re, parts, result; for (var i = 0; i < scripts.length; ++i) { var script = scripts[i]; if (script.src) { urls.push(script.src); } } if (!(parts = codeRE.exec(code))) { re = new RegExp(escapeRegExp(code).replace(/\s+/g, '\\s+')); } // not sure if this is really necessary, but I don’t have a test // corpus large enough to confirm that and it was in the original. else { var name = parts[1] ? '\\s+' + parts[1] : '', args = parts[2].split(',').join('\\s*,\\s*'); body = escapeRegExp(parts[3]).replace(/;$/, ';?'); // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+'); re = new RegExp('function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}'); } // look for a normal function definition if ((result = findSourceInUrls(re, urls))) { return result; } // look for an old-school event handler function if ((parts = eventRE.exec(code))) { var event = parts[1]; body = escapeCodeAsRegExpForMatchingInsideHTML(parts[2]); // look for a function defined in HTML as an onXXX handler re = new RegExp('on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]', 'i'); if ((result = findSourceInUrls(re, urls[0]))) { return result; } // look for ??? re = new RegExp(body); if ((result = findSourceInUrls(re, urls))) { return result; } } return null; } // Contents of Exception in various browsers. // // SAFARI: // ex.message = Can't find variable: qq // ex.line = 59 // ex.sourceId = 580238192 // ex.sourceURL = http://... // ex.expressionBeginOffset = 96 // ex.expressionCaretOffset = 98 // ex.expressionEndOffset = 98 // ex.name = ReferenceError // // FIREFOX: // ex.message = qq is not defined // ex.fileName = http://... // ex.lineNumber = 59 // ex.columnNumber = 69 // ex.stack = ...stack trace... (see the example below) // ex.name = ReferenceError // // CHROME: // ex.message = qq is not defined // ex.name = ReferenceError // ex.type = not_defined // ex.arguments = ['aa'] // ex.stack = ...stack trace... // // INTERNET EXPLORER: // ex.message = ... // ex.name = ReferenceError // // OPERA: // ex.message = ...message... (see the example below) // ex.name = ReferenceError // ex.opera#sourceloc = 11 (pretty much useless, duplicates the info in ex.message) // ex.stacktrace = n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace' /** * Computes stack trace information from the stack property. * Chrome and Gecko use this property. * @param {Error} ex * @return {?TraceKit.StackTrace} Stack trace information. * @memberof TraceKit.computeStackTrace */ function computeStackTraceFromStackProp(ex) { if (!ex.stack) { return null; } var chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|native|eval|webpack||[a-z]:|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i, winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i, // Used to additionally parse URL/line/column from eval frames isEval, geckoEval = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i, chromeEval = /\((\S*)(?::(\d+))(?::(\d+))\)/, lines = ex.stack.split('\n'), stack = [], submatch, parts, element, reference = /^(.*) is undefined$/.exec(ex.message); for (var i = 0, j = lines.length; i < j; ++i) { if ((parts = chrome.exec(lines[i]))) { var isNative = parts[2] && parts[2].indexOf('native') === 0; // start of line isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line if (isEval && (submatch = chromeEval.exec(parts[2]))) { // throw out eval line/column and use top-most line/column number parts[2] = submatch[1]; // url // NOTE: It's messing out our integration tests in Karma, let's see if we can live with it – Kamil // parts[3] = submatch[2]; // line // parts[4] = submatch[3]; // column } element = { url: !isNative ? parts[2] : null, func: parts[1] || UNKNOWN_FUNCTION, args: isNative ? [parts[2]] : [], line: parts[3] ? +parts[3] : null, column: parts[4] ? +parts[4] : null, }; } else if ((parts = winjs.exec(lines[i]))) { element = { url: parts[2], func: parts[1] || UNKNOWN_FUNCTION, args: [], line: +parts[3], column: parts[4] ? +parts[4] : null, }; } else if ((parts = gecko.exec(lines[i]))) { isEval = parts[3] && parts[3].indexOf(' > eval') > -1; if (isEval && (submatch = geckoEval.exec(parts[3]))) { // throw out eval line/column and use top-most line number parts[3] = submatch[1]; // NOTE: It's messing out our integration tests in Karma, let's see if we can live with it – Kamil // parts[4] = submatch[2]; // parts[5] = null; // no column when eval } else if (i === 0 && !parts[5] && !is_5(ex.columnNumber)) { // FireFox uses this awesome columnNumber property for its top frame // Also note, Firefox's column number is 0-based and everything else expects 1-based, // so adding 1 // NOTE: this hack doesn't work if top-most frame is eval stack[0].column = ex.columnNumber + 1; } element = { url: parts[3], func: parts[1] || UNKNOWN_FUNCTION, args: parts[2] ? parts[2].split(',') : [], line: parts[4] ? +parts[4] : null, column: parts[5] ? +parts[5] : null, }; } else { continue; } if (!element.func && element.line) { element.func = guessFunctionName(element.url, element.line); } if (TraceKit.remoteFetching && element.url && element.url.substr(0, 5) === 'blob:') { // Special case for handling JavaScript loaded into a blob. // We use a synchronous AJAX request here as a blob is already in // memory - it's not making a network request. This will generate a warning // in the browser console, but there has already been an error so that's not // that much of an issue. var xhr = new XMLHttpRequest(); xhr.open('GET', element.url, false); xhr.send(''); // If we failed to download the source, skip this patch if (xhr.status === 200) { var source = xhr.responseText || ''; // We trim the source down to the last 300 characters as sourceMappingURL is always at the end of the file. // Why 300? To be in line with: https://github.com/getsentry/sentry/blob/4af29e8f2350e20c28a6933354e4f42437b4ba42/src/sentry/lang/javascript/processor.py#L164-L175 source = source.slice(-300); // Now we dig out the source map URL var sourceMaps = source.match(/\/\/# sourceMappingURL=(.*)$/); // If we don't find a source map comment or we find more than one, continue on to the next element. if (sourceMaps) { var sourceMapAddress = sourceMaps[1]; // Now we check to see if it's a relative URL. // If it is, convert it to an absolute one. if (sourceMapAddress.charAt(0) === '~') { sourceMapAddress = getLocationOrigin() + sourceMapAddress.slice(1); } // Now we strip the '.map' off of the end of the URL and update the // element so that Sentry can match the map to the blob. element.url = sourceMapAddress.slice(0, -4); } } } element.context = element.line ? gatherContext(element.url, element.line) : null; stack.push(element); } if (!stack.length) { return null; } if (stack[0] && stack[0].line && !stack[0].column && reference) { stack[0].column = findSourceInLine(reference[1], stack[0].url, stack[0].line); } return { mode: 'stack', name: ex.name, message: ex.message, stack: stack, }; } /** * Computes stack trace information from the stacktrace property. * Opera 10+ uses this property. * @param {Error} ex * @return {?TraceKit.StackTrace} Stack trace information. * @memberof TraceKit.computeStackTrace */ function computeStackTraceFromStacktraceProp(ex) { // Access and store the stacktrace property before doing ANYTHING // else to it because Opera is not very good at providing it // reliably in other circumstances. var stacktrace = ex.stacktrace; if (!stacktrace) { return; } var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i, opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i, lines = stacktrace.split('\n'), stack = [], parts; for (var line = 0; line < lines.length; line += 2) { var element = null; if ((parts = opera10Regex.exec(lines[line]))) { element = { url: parts[2], line: +parts[1], column: null, func: parts[3], args: [], }; } else if ((parts = opera11Regex.exec(lines[line]))) { element = { url: parts[6], line: +parts[1], column: +parts[2], func: parts[3] || parts[4], args: parts[5] ? parts[5].split(',') : [], }; } if (element) { if (!element.func && element.line) { element.func = guessFunctionName(element.url, element.line); } if (element.line) { try { element.context = gatherContext(element.url, element.line); } catch (exc) { } } if (!element.context) { element.context = [lines[line + 1]]; } stack.push(element); } } if (!stack.length) { return null; } return { mode: 'stacktrace', name: ex.name, message: ex.message, stack: stack, }; } /** * NOT TESTED. * Computes stack trace information from an error message that includes * the stack trace. * Opera 9 and earlier use this method if the option to show stack * traces is turned on in opera:config. * @param {Error} ex * @return {?TraceKit.StackTrace} Stack information. * @memberof TraceKit.computeStackTrace */ function computeStackTraceFromOperaMultiLineMessage(ex) { // TODO: Clean this function up // Opera includes a stack trace into the exception message. An example is: // // Statement on line 3: Undefined variable: undefinedFunc // Backtrace: // Line 3 of linked script file://localhost/Users/andreyvit/Projects/TraceKit/javascript-client/sample.js: In function zzz // undefinedFunc(a); // Line 7 of inline#1 script in file://localhost/Users/andreyvit/Projects/TraceKit/javascript-client/sample.html: In function yyy // zzz(x, y, z); // Line 3 of inline#1 script in file://localhost/Users/andreyvit/Projects/TraceKit/javascript-client/sample.html: In function xxx // yyy(a, a, a); // Line 1 of function script // try { xxx('hi'); return false; } catch(ex) { TraceKit.report(ex); } // ... var lines = ex.message.split('\n'); if (lines.length < 4) { return null; } var lineRE1 = /^\s*Line (\d+) of linked script ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i, lineRE2 = /^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i, lineRE3 = /^\s*Line (\d+) of function script\s*$/i, stack = [], scripts = window$1 && window$1.document && window$1.document.getElementsByTagName('script'), inlineScriptBlocks = [], parts; for (var s in scripts) { if (_has(scripts, s) && !scripts[s].src) { inlineScriptBlocks.push(scripts[s]); } } for (var line = 2; line < lines.length; line += 2) { var item = null; if ((parts = lineRE1.exec(lines[line]))) { item = { url: parts[2], func: parts[3], args: [], line: +parts[1], column: null, }; } else if ((parts = lineRE2.exec(lines[line]))) { item = { url: parts[3], func: parts[4], args: [], line: +parts[1], column: null, }; var relativeLine = +parts[1]; // relative to the start of the