@kenkaiiii/error-mom 0.3.2 → 0.3.3

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.
@@ -1,10 +1,11 @@
1
1
  // src/shared.ts
2
+ import {
3
+ redactStringCredentials
4
+ } from "@kenkaiiii/error-mom-protocol";
2
5
  var SDK_NAME = "@kenkaiiii/error-mom";
3
- var SDK_VERSION = "0.3.2";
6
+ var SDK_VERSION = "0.3.3";
4
7
  var MAX_BREADCRUMBS = 50;
5
8
  var SECRET_KEY = /authorization|cookie|password|passwd|secret|token|api[-_]?key|session/i;
6
- var URL_CREDENTIAL = /([?&](?:token|key|secret|password|code)=)[^&\s]*/gi;
7
- var EMAIL = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
8
9
  function wrapFunction(capture, fn, context) {
9
10
  return (...args) => {
10
11
  try {
@@ -23,7 +24,7 @@ function wrapFunction(capture, fn, context) {
23
24
  };
24
25
  }
25
26
  function redactString(value) {
26
- return value.replace(URL_CREDENTIAL, "$1[REDACTED]").replace(EMAIL, "[REDACTED_EMAIL]");
27
+ return redactStringCredentials(value);
27
28
  }
28
29
  function sanitize(value, depth = 0) {
29
30
  if (depth > 5) return "[TRUNCATED]";
@@ -83,8 +84,8 @@ function createEvent(value, options, breadcrumbs, runtime, captureContext = {})
83
84
  ...typeof location !== "undefined" ? { url: redactString(location.href) } : {},
84
85
  ...captureContext.culprit ? { culprit: redactString(captureContext.culprit) } : {},
85
86
  ...options.installationId ? { installationId: options.installationId } : {},
86
- breadcrumbs: breadcrumbs.slice(-MAX_BREADCRUMBS),
87
- tags: { ...options.tags, ...captureContext.tags },
87
+ breadcrumbs: sanitize(breadcrumbs.slice(-MAX_BREADCRUMBS)),
88
+ tags: sanitize({ ...options.tags, ...captureContext.tags }),
88
89
  context: sanitize(captureContext.context ?? {}) ?? {}
89
90
  };
90
91
  }
package/dist/index.cjs CHANGED
@@ -25,12 +25,11 @@ __export(index_exports, {
25
25
  module.exports = __toCommonJS(index_exports);
26
26
 
27
27
  // src/shared.ts
28
+ var import_error_mom_protocol = require("@kenkaiiii/error-mom-protocol");
28
29
  var SDK_NAME = "@kenkaiiii/error-mom";
29
- var SDK_VERSION = "0.3.2";
30
+ var SDK_VERSION = "0.3.3";
30
31
  var MAX_BREADCRUMBS = 50;
31
32
  var SECRET_KEY = /authorization|cookie|password|passwd|secret|token|api[-_]?key|session/i;
32
- var URL_CREDENTIAL = /([?&](?:token|key|secret|password|code)=)[^&\s]*/gi;
33
- var EMAIL = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
34
33
  function wrapFunction(capture, fn, context) {
35
34
  return (...args) => {
36
35
  try {
@@ -49,7 +48,7 @@ function wrapFunction(capture, fn, context) {
49
48
  };
50
49
  }
51
50
  function redactString(value) {
52
- return value.replace(URL_CREDENTIAL, "$1[REDACTED]").replace(EMAIL, "[REDACTED_EMAIL]");
51
+ return (0, import_error_mom_protocol.redactStringCredentials)(value);
53
52
  }
54
53
  function sanitize(value, depth = 0) {
55
54
  if (depth > 5) return "[TRUNCATED]";
@@ -109,8 +108,8 @@ function createEvent(value, options, breadcrumbs, runtime, captureContext = {})
109
108
  ...typeof location !== "undefined" ? { url: redactString(location.href) } : {},
110
109
  ...captureContext.culprit ? { culprit: redactString(captureContext.culprit) } : {},
111
110
  ...options.installationId ? { installationId: options.installationId } : {},
112
- breadcrumbs: breadcrumbs.slice(-MAX_BREADCRUMBS),
113
- tags: { ...options.tags, ...captureContext.tags },
111
+ breadcrumbs: sanitize(breadcrumbs.slice(-MAX_BREADCRUMBS)),
112
+ tags: sanitize({ ...options.tags, ...captureContext.tags }),
114
113
  context: sanitize(captureContext.context ?? {}) ?? {}
115
114
  };
116
115
  }
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  printable,
9
9
  redactString,
10
10
  wrapFunction
11
- } from "./chunk-GHOIVBTK.js";
11
+ } from "./chunk-UNG24UNX.js";
12
12
 
13
13
  // src/index.ts
14
14
  var clients = /* @__PURE__ */ new Map();
package/dist/node.cjs CHANGED
@@ -30,12 +30,11 @@ var import_node_os = require("os");
30
30
  var import_node_path = require("path");
31
31
 
32
32
  // src/shared.ts
33
+ var import_error_mom_protocol = require("@kenkaiiii/error-mom-protocol");
33
34
  var SDK_NAME = "@kenkaiiii/error-mom";
34
- var SDK_VERSION = "0.3.2";
35
+ var SDK_VERSION = "0.3.3";
35
36
  var MAX_BREADCRUMBS = 50;
36
37
  var SECRET_KEY = /authorization|cookie|password|passwd|secret|token|api[-_]?key|session/i;
37
- var URL_CREDENTIAL = /([?&](?:token|key|secret|password|code)=)[^&\s]*/gi;
38
- var EMAIL = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
39
38
  function wrapFunction(capture, fn, context) {
40
39
  return (...args) => {
41
40
  try {
@@ -54,7 +53,7 @@ function wrapFunction(capture, fn, context) {
54
53
  };
55
54
  }
56
55
  function redactString(value) {
57
- return value.replace(URL_CREDENTIAL, "$1[REDACTED]").replace(EMAIL, "[REDACTED_EMAIL]");
56
+ return (0, import_error_mom_protocol.redactStringCredentials)(value);
58
57
  }
59
58
  function sanitize(value, depth = 0) {
60
59
  if (depth > 5) return "[TRUNCATED]";
@@ -114,8 +113,8 @@ function createEvent(value, options, breadcrumbs, runtime, captureContext = {})
114
113
  ...typeof location !== "undefined" ? { url: redactString(location.href) } : {},
115
114
  ...captureContext.culprit ? { culprit: redactString(captureContext.culprit) } : {},
116
115
  ...options.installationId ? { installationId: options.installationId } : {},
117
- breadcrumbs: breadcrumbs.slice(-MAX_BREADCRUMBS),
118
- tags: { ...options.tags, ...captureContext.tags },
116
+ breadcrumbs: sanitize(breadcrumbs.slice(-MAX_BREADCRUMBS)),
117
+ tags: sanitize({ ...options.tags, ...captureContext.tags }),
119
118
  context: sanitize(captureContext.context ?? {}) ?? {}
120
119
  };
121
120
  }
package/dist/node.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  printable,
9
9
  redactString,
10
10
  wrapFunction
11
- } from "./chunk-GHOIVBTK.js";
11
+ } from "./chunk-UNG24UNX.js";
12
12
 
13
13
  // src/node.ts
14
14
  import { createHash } from "crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenkaiiii/error-mom",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Automatic browser and Node.js error capture for self-hosted Error Mom",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -22,7 +22,7 @@
22
22
  "README.md"
23
23
  ],
24
24
  "dependencies": {
25
- "@kenkaiiii/error-mom-protocol": "0.1.0"
25
+ "@kenkaiiii/error-mom-protocol": "0.1.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsup": "^8.5.1",