@honeybadger-io/js 6.16.4 → 6.16.6

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.
@@ -182,6 +182,17 @@ var stackTraceParser_esm = /*#__PURE__*/Object.freeze({
182
182
  var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
183
183
 
184
184
  (function (exports) {
185
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
186
+ __assign = Object.assign || function(t) {
187
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
188
+ s = arguments[i];
189
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
190
+ t[p] = s[p];
191
+ }
192
+ return t;
193
+ };
194
+ return __assign.apply(this, arguments);
195
+ };
185
196
  var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
186
197
  if (k2 === undefined) k2 = k;
187
198
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -242,7 +253,7 @@ var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
242
253
  }
243
254
  };
244
255
  Object.defineProperty(exports, "__esModule", { value: true });
245
- exports.logDeprecatedMethod = exports.globalThisOrWindow = exports.isBrowserConfig = exports.clone = exports.formatCGIData = exports.filterUrl = exports.filter = exports.generateStackTrace = exports.endpoint = exports.instrumentConsole = exports.instrument = exports.isErrorObject = exports.makeNotice = exports.logger = exports.sanitize = exports.shallowClone = exports.runAfterNotifyHandlers = exports.shouldSampleEvent = exports.resolveInsights = exports.runBeforeEventHandlers = exports.runBeforeNotifyHandlers = exports.getSourceForBacktrace = exports.getCauses = exports.calculateBacktraceShift = exports.DEFAULT_BACKTRACE_SHIFT = exports.makeBacktrace = exports.objectIsExtensible = exports.objectIsEmpty = exports.mergeNotice = exports.merge = void 0;
256
+ exports.logDeprecatedMethod = exports.globalThisOrWindow = exports.isBrowserConfig = exports.clone = exports.formatCGIData = exports.filterBreadcrumbs = exports.filterUrl = exports.filter = exports.generateStackTrace = exports.endpoint = exports.instrumentConsole = exports.instrument = exports.isErrorObject = exports.makeNotice = exports.logger = exports.sanitize = exports.shallowClone = exports.runAfterNotifyHandlers = exports.shouldSampleEvent = exports.resolveInsights = exports.runBeforeEventHandlers = exports.runBeforeNotifyHandlers = exports.getSourceForBacktrace = exports.getCauses = exports.calculateBacktraceShift = exports.DEFAULT_BACKTRACE_SHIFT = exports.makeBacktrace = exports.objectIsExtensible = exports.objectIsEmpty = exports.mergeNotice = exports.merge = void 0;
246
257
  /* eslint-disable prefer-rest-params */
247
258
  var stackTraceParser = __importStar(require$$0$1);
248
259
  function merge(obj1, obj2) {
@@ -828,6 +839,76 @@ var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
828
839
  return result;
829
840
  }
830
841
  exports.filterUrl = filterUrl;
842
+ /**
843
+ * Breadcrumb metadata keys whose value is a URL, and so may carry a query string.
844
+ *
845
+ * Checked by name rather than by running `filterUrl` over every string value: a `?` is
846
+ * ordinary punctuation in a breadcrumb message or a console argument, and rewriting around
847
+ * it would mangle text that is not a URL at all.
848
+ */
849
+ var URL_METADATA_KEYS = ['url', 'from', 'to', 'href'];
850
+ /**
851
+ * Recursively rewrites the query string of every URL-bearing value.
852
+ *
853
+ * Nested as well as top-level: a breadcrumb may well carry
854
+ * `metadata: { request: { url: '/checkout?token=secret' } }`, and `filter` leaves that URL
855
+ * alone because the key `request` matches no filter.
856
+ *
857
+ * Safe to recurse without a seen-list because `filter` has already run: it replaces a
858
+ * circular reference with a string, so what arrives here is acyclic.
859
+ */
860
+ function filterUrlValues(value, filters) {
861
+ if (is('Array', value)) {
862
+ return value.map(function (entry) { return filterUrlValues(entry, filters); });
863
+ }
864
+ if (!is('Object', value)) {
865
+ return value;
866
+ }
867
+ var result = {};
868
+ var source = value;
869
+ // Own enumerable keys only, assigned with `defineProperty`: a plain `result[key] =` would
870
+ // reassign the prototype rather than create a property for a key named `__proto__`, and
871
+ // breadcrumb metadata is host-supplied.
872
+ Object.keys(source).forEach(function (key) {
873
+ var entry = source[key];
874
+ var filtered = URL_METADATA_KEYS.includes(key.toLowerCase()) && typeof entry === 'string'
875
+ ? filterUrl(entry, filters)
876
+ : filterUrlValues(entry, filters);
877
+ Object.defineProperty(result, key, {
878
+ value: filtered,
879
+ enumerable: true,
880
+ writable: true,
881
+ configurable: true
882
+ });
883
+ });
884
+ return result;
885
+ }
886
+ /**
887
+ * Applies `filters` to a breadcrumb trail.
888
+ *
889
+ * Metadata is filtered by key, exactly as `params` and `session` are, and any value under a
890
+ * URL-bearing key additionally has its query string filtered. Breadcrumb metadata is mostly
891
+ * generated by this library -- the XHR, fetch and navigation integrations all record a full
892
+ * URL -- so a query string lands there without the user ever choosing to put it there.
893
+ */
894
+ function filterBreadcrumbs(trail, filters) {
895
+ if (!is('Array', trail)) {
896
+ return [];
897
+ }
898
+ return trail.map(function (breadcrumb) {
899
+ // Leave a crumb that never carried metadata exactly as it is, so the payload shape does
900
+ // not change for it.
901
+ if (!is('Object', breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.metadata)) {
902
+ return breadcrumb;
903
+ }
904
+ // `filter` runs first, so a key-matched value is already '[FILTERED]' by the time the
905
+ // URL pass sees it. Passing that through `filterUrl` is harmless: it holds no '?', so
906
+ // it is returned untouched.
907
+ var metadata = filterUrlValues(filter(breadcrumb.metadata, filters), filters);
908
+ return __assign(__assign({}, breadcrumb), { metadata: metadata });
909
+ });
910
+ }
911
+ exports.filterBreadcrumbs = filterBreadcrumbs;
831
912
  function formatCGIData(vars, prefix) {
832
913
  if (prefix === void 0) { prefix = ''; }
833
914
  var formattedVars = {};
@@ -1455,7 +1536,7 @@ var Client = /** @class */ (function () {
1455
1536
  this.__notifier = {
1456
1537
  name: '@honeybadger-io/core',
1457
1538
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
1458
- version: '6.16.4'
1539
+ version: '6.16.6'
1459
1540
  };
1460
1541
  this.config = __assign(__assign({}, defaults_1.CONFIG), opts);
1461
1542
  this.__initStore();
@@ -1816,7 +1897,7 @@ var Client = /** @class */ (function () {
1816
1897
  notifier: this.__notifier,
1817
1898
  breadcrumbs: {
1818
1899
  enabled: !!this.config.breadcrumbsEnabled,
1819
- trail: notice.__breadcrumbs || []
1900
+ trail: (0, util_1.filterBreadcrumbs)(notice.__breadcrumbs || [], this.config.filters)
1820
1901
  },
1821
1902
  error: {
1822
1903
  class: notice.name,