@quatronic/sdk 0.8.0 → 0.9.0-rc.1
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.
- package/dist/{chunk-G7VPNC6M.js → chunk-IFESUTF2.js} +21 -100
- package/dist/chunk-IFESUTF2.js.map +1 -0
- package/dist/{chunk-WU7N4PET.js → chunk-POZI4OKJ.js} +2 -2
- package/dist/chunk-YFZB5EW6.js +107 -0
- package/dist/chunk-YFZB5EW6.js.map +1 -0
- package/dist/next/boot/index.js +3 -2
- package/dist/next/boot/index.js.map +1 -1
- package/dist/next/security/index.js +3 -3
- package/dist/next/sentry/client.js +2 -1
- package/dist/next/sentry/client.js.map +1 -1
- package/dist/next/sentry/index.d.ts +1 -0
- package/dist/next/sentry/index.js +5 -1
- package/dist/next/sentry/index.js.map +1 -1
- package/dist/next/sentry/register.js +3 -2
- package/dist/node/sentry/index.d.ts +3 -0
- package/dist/node/sentry/index.js +7 -0
- package/dist/node/sentry/index.js.map +1 -0
- package/dist/node/sentry/register.js +2 -1
- package/dist/node/sentry/register.js.map +1 -1
- package/package.json +5 -1
- package/dist/chunk-G7VPNC6M.js.map +0 -1
- /package/dist/{chunk-WU7N4PET.js.map → chunk-POZI4OKJ.js.map} +0 -0
|
@@ -1,46 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setTelemetryHooks
|
|
3
|
-
} from "./chunk-MET4SIMB.js";
|
|
4
|
-
import {
|
|
5
|
-
makeDevSinkTransport
|
|
6
|
-
} from "./chunk-7ASQHY7O.js";
|
|
7
|
-
|
|
8
|
-
// src/sentry-core/noise.ts
|
|
9
|
-
var NOISE_EXACT = /* @__PURE__ */ new Set(["/favicon.ico", "/api/auth/me"]);
|
|
10
|
-
var RSC_QUERY_RE = /[?&]_rsc=/;
|
|
11
|
-
function isNoisePath(rawUrl, opts = {}) {
|
|
12
|
-
if (RSC_QUERY_RE.test(rawUrl)) return true;
|
|
13
|
-
const path = (rawUrl.split("?")[0] ?? "").trim();
|
|
14
|
-
if (!path) return false;
|
|
15
|
-
if (NOISE_EXACT.has(path)) return true;
|
|
16
|
-
if (path.endsWith(".map")) return true;
|
|
17
|
-
if (path.startsWith("/_next/")) return true;
|
|
18
|
-
if ((opts.noisePrefixes ?? []).some((p) => path.startsWith(p))) return true;
|
|
19
|
-
if (opts.healthPath && path === opts.healthPath) return true;
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// src/sentry-core/sampler.ts
|
|
24
|
-
var MUTATIONS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
25
|
-
var str = (v) => typeof v === "string" && v ? v : void 0;
|
|
26
|
-
function pathOf(ctx) {
|
|
27
|
-
const a = ctx.attributes ?? {};
|
|
28
|
-
return str(a["url.path"]) ?? str(a["http.target"]) ?? ctx.name.split(" ")[1];
|
|
29
|
-
}
|
|
30
|
-
function createTracesSampler(policy) {
|
|
31
|
-
return (ctx) => {
|
|
32
|
-
const path = pathOf(ctx);
|
|
33
|
-
if (path && isNoisePath(path, { healthPath: policy.healthPath })) return 0;
|
|
34
|
-
const a = ctx.attributes ?? {};
|
|
35
|
-
const method = (str(a["http.request.method"]) ?? str(a["http.method"]) ?? "").toUpperCase();
|
|
36
|
-
if (MUTATIONS.has(method)) return 1;
|
|
37
|
-
return ctx.inheritOrSampleWith(policy.production ? policy.readRate : 1);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
1
|
// src/sentry-core/scrub.ts
|
|
42
2
|
var REDACTED = "\u25CF\u25CF\u25CF";
|
|
43
3
|
var EMAIL = /(?<![A-Z0-9._%+-])[A-Z0-9._%+-]{1,64}@[A-Z0-9-]+(?:\.[A-Z0-9-]+)*\.[A-Z]{2,}/gi;
|
|
4
|
+
var URL_USERINFO = /\b([a-z][a-z0-9+.-]{0,31}:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi;
|
|
44
5
|
var JWT = /eyJ[\w-]+\.[\w-]+\.[\w-]+/g;
|
|
45
6
|
var AUTH_SCHEME = /\b(Bearer|Basic)\s+\S+/gi;
|
|
46
7
|
var PARAMS_TAIL = /\bparams:\s.*$/s;
|
|
@@ -61,8 +22,21 @@ var REDACT_PREFIXES = ["net.peer.", "net.sock.", "net.host.", "network.peer.", "
|
|
|
61
22
|
var DROP_SPAN_KEYS = /* @__PURE__ */ new Set(["user_agent.original", "http.user_agent", "client.address", "http.client_ip"]);
|
|
62
23
|
var DROP_SPAN_PREFIXES = ["http.request.header.", "http.response.header."];
|
|
63
24
|
var URL_SPAN_KEYS = /* @__PURE__ */ new Set(["url.full", "http.url", "url", "http.target", "url.query", "http.query"]);
|
|
25
|
+
var SECRETS = /* @__PURE__ */ Symbol.for("@quatronic/sdk.sentry-secret-values");
|
|
26
|
+
var secretHolder = globalThis;
|
|
27
|
+
function secretState() {
|
|
28
|
+
return secretHolder[SECRETS] ??= { values: /* @__PURE__ */ new Set(), longestFirst: [] };
|
|
29
|
+
}
|
|
30
|
+
function registerSecretValues(values) {
|
|
31
|
+
const state = secretState();
|
|
32
|
+
for (const v of values) if (typeof v === "string" && v.length >= 8) state.values.add(v);
|
|
33
|
+
state.longestFirst = [...state.values].sort((a, b) => b.length - a.length);
|
|
34
|
+
}
|
|
35
|
+
function maskSecretValues(s) {
|
|
36
|
+
return secretState().longestFirst.reduce((acc, v) => acc.replaceAll(v, REDACTED), s);
|
|
37
|
+
}
|
|
64
38
|
function redactText(s) {
|
|
65
|
-
return s.replace(PARAMS_TAIL, "params: [redacted]").replace(AUTH_SCHEME, "$1 [redacted]").replace(JWT, "[jwt]").replace(EMAIL, "[email]");
|
|
39
|
+
return maskSecretValues(s).replace(URL_USERINFO, `$1${REDACTED}@`).replace(PARAMS_TAIL, "params: [redacted]").replace(AUTH_SCHEME, "$1 [redacted]").replace(JWT, "[jwt]").replace(EMAIL, "[email]");
|
|
66
40
|
}
|
|
67
41
|
function redactQuery(query) {
|
|
68
42
|
return query.split("&").map((pair) => {
|
|
@@ -127,64 +101,11 @@ function scrubSpan(s) {
|
|
|
127
101
|
return s;
|
|
128
102
|
}
|
|
129
103
|
|
|
130
|
-
// src/sentry-core/options.ts
|
|
131
|
-
function isTty() {
|
|
132
|
-
try {
|
|
133
|
-
return typeof process !== "undefined" && process.stdout?.isTTY === true;
|
|
134
|
-
} catch {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function buildOptions(runtime, cfg) {
|
|
139
|
-
return {
|
|
140
|
-
dsn: cfg.dsn,
|
|
141
|
-
environment: cfg.environment,
|
|
142
|
-
release: cfg.release,
|
|
143
|
-
sendDefaultPii: false,
|
|
144
|
-
dataCollection: {
|
|
145
|
-
userInfo: false,
|
|
146
|
-
cookies: false,
|
|
147
|
-
httpHeaders: { request: false, response: false },
|
|
148
|
-
httpBodies: [],
|
|
149
|
-
databaseQueryData: false,
|
|
150
|
-
stackFrameVariables: false,
|
|
151
|
-
genAI: { inputs: false, outputs: false },
|
|
152
|
-
urlQueryParams: { deny: [...SECRET_PARAMS] }
|
|
153
|
-
},
|
|
154
|
-
enableLogs: true,
|
|
155
|
-
tracesSampler: createTracesSampler({
|
|
156
|
-
production: cfg.environment === "production",
|
|
157
|
-
readRate: cfg.readSampleRate,
|
|
158
|
-
healthPath: cfg.healthPath
|
|
159
|
-
}),
|
|
160
|
-
tracePropagationTargets: runtime === "browser" ? [/^\//] : cfg.connOrigins,
|
|
161
|
-
beforeSend: scrubEvent,
|
|
162
|
-
beforeSendTransaction: scrubEvent,
|
|
163
|
-
beforeSendLog: scrubLog,
|
|
164
|
-
beforeSendSpan: scrubSpan,
|
|
165
|
-
initialScope: { tags: cfg.tags },
|
|
166
|
-
...cfg.local ? { transport: makeDevSinkTransport({ traces: cfg.devTraces ?? "line", color: runtime !== "browser" && isTty() }) } : {}
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// src/sentry-core/init.ts
|
|
171
|
-
var DONE = /* @__PURE__ */ Symbol.for("@quatronic/sdk.sentry-initialised");
|
|
172
|
-
var holder = globalThis;
|
|
173
|
-
function initSentry(sentry, runtime, cfg, extra = {}) {
|
|
174
|
-
if (!cfg || holder[DONE]) return false;
|
|
175
|
-
holder[DONE] = true;
|
|
176
|
-
try {
|
|
177
|
-
const extras = typeof extra === "function" ? extra() : extra;
|
|
178
|
-
sentry.init({ ...extras, ...buildOptions(runtime, cfg) });
|
|
179
|
-
} catch (err) {
|
|
180
|
-
console.error("[qore] Sentry init failed", err);
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
setTelemetryHooks({ log: sentry.logger, setUser: (u) => sentry.setUser(u) });
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
104
|
export {
|
|
188
|
-
|
|
105
|
+
SECRET_PARAMS,
|
|
106
|
+
registerSecretValues,
|
|
107
|
+
scrubEvent,
|
|
108
|
+
scrubLog,
|
|
109
|
+
scrubSpan
|
|
189
110
|
};
|
|
190
|
-
//# sourceMappingURL=chunk-
|
|
111
|
+
//# sourceMappingURL=chunk-IFESUTF2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sentry-core/scrub.ts"],"sourcesContent":["export const REDACTED = \"●●●\"\n\n// Bounded and anchored (`(?<![...])` + `{1,64}` local part, no `.` in the\n// domain-char class) so it cannot backtrack catastrophically on long runs of\n// email-charset bytes — see the fix-round-1 report for the O(n²) it replaced.\nconst EMAIL = /(?<![A-Z0-9._%+-])[A-Z0-9._%+-]{1,64}@[A-Z0-9-]+(?:\\.[A-Z0-9-]+)*\\.[A-Z]{2,}/gi\nconst URL_USERINFO = /\\b([a-z][a-z0-9+.-]{0,31}:\\/\\/)[^/\\s:@]+(?::[^/\\s@]*)?@/gi\nconst JWT = /eyJ[\\w-]+\\.[\\w-]+\\.[\\w-]+/g\nconst AUTH_SCHEME = /\\b(Bearer|Basic)\\s+\\S+/gi\nconst PARAMS_TAIL = /\\bparams:\\s.*$/s\nexport const SECRET_PARAMS: ReadonlySet<string> = new Set([\"token\", \"code\", \"state\", \"password\", \"secret\", \"key\", \"session\", \"access_token\", \"refresh_token\", \"id_token\"])\nconst SECRET_HEADERS = new Set([\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-qdc-connection-token\",\n \"x-forwarded-for\",\n \"x-real-ip\",\n \"forwarded\",\n \"user-agent\",\n])\nconst DROP_LOG_ATTRS = new Set([\"ip\", \"ip_address\", \"user_agent\", \"email\", \"user_email\", \"server.address\"])\nconst REDACT_KEYS = new Set([\"db.connection_string\", \"db.user\"])\nconst REDACT_PREFIXES = [\"net.peer.\", \"net.sock.\", \"net.host.\", \"network.peer.\", \"network.local.\"]\nconst DROP_SPAN_KEYS = new Set([\"user_agent.original\", \"http.user_agent\", \"client.address\", \"http.client_ip\"])\nconst DROP_SPAN_PREFIXES = [\"http.request.header.\", \"http.response.header.\"]\nconst URL_SPAN_KEYS = new Set([\"url.full\", \"http.url\", \"url\", \"http.target\", \"url.query\", \"http.query\"])\n\nconst SECRETS = Symbol.for(\"@quatronic/sdk.sentry-secret-values\")\ntype SecretHolder = { [SECRETS]?: { values: Set<string>; longestFirst: string[] } }\nconst secretHolder = globalThis as SecretHolder\n\n// On globalThis because a Next app can bundle this module twice: the copy\n// serverEnv() registers into is not necessarily the one beforeSend reads.\nfunction secretState(): NonNullable<SecretHolder[typeof SECRETS]> {\n return (secretHolder[SECRETS] ??= { values: new Set(), longestFirst: [] })\n}\n\nexport function registerSecretValues(values: Iterable<unknown>): void {\n const state = secretState()\n for (const v of values) if (typeof v === \"string\" && v.length >= 8) state.values.add(v)\n state.longestFirst = [...state.values].sort((a, b) => b.length - a.length)\n}\n\nfunction maskSecretValues(s: string): string {\n return secretState().longestFirst.reduce((acc, v) => acc.replaceAll(v, REDACTED), s)\n}\n\nexport function redactText(s: string): string {\n return maskSecretValues(s)\n .replace(URL_USERINFO, `$1${REDACTED}@`)\n .replace(PARAMS_TAIL, \"params: [redacted]\")\n .replace(AUTH_SCHEME, \"$1 [redacted]\")\n .replace(JWT, \"[jwt]\")\n .replace(EMAIL, \"[email]\")\n}\n\nfunction redactQuery(query: string): string {\n return query\n .split(\"&\")\n .map((pair) => {\n const [k, v] = pair.split(\"=\", 2)\n return v !== undefined && SECRET_PARAMS.has(k!.toLowerCase()) ? `${k}=[redacted]` : pair\n })\n .join(\"&\")\n}\n\nfunction redactUrl(url: string): string {\n const i = url.indexOf(\"?\")\n return i < 0 ? url : url.slice(0, i + 1) + redactQuery(url.slice(i + 1))\n}\n\n// For values that are either a URL/path or a bare query string (no `?`).\nfunction redactUrlOrQuery(v: string): string {\n return v.includes(\"?\") ? redactUrl(v) : redactQuery(v)\n}\n\ntype Dict = Record<string, unknown>\n\nexport interface SentryEventLike {\n server_name?: string\n user?: Dict\n request?: { url?: string; query_string?: unknown; cookies?: unknown; headers?: Record<string, string>; data?: unknown }\n message?: string\n exception?: { values?: Array<{ type?: string; value?: string }> }\n breadcrumbs?: Array<{ message?: string; data?: Dict }>\n contexts?: { nextjs?: Dict } & Dict\n}\n\nexport function scrubEvent<E extends SentryEventLike>(e: E): E {\n delete e.server_name\n if (e.user) e.user = e.user.id ? { id: e.user.id } : {}\n if (e.request) {\n delete e.request.cookies\n delete e.request.data\n if (e.request.url) e.request.url = redactUrl(e.request.url)\n if (typeof e.request.query_string === \"string\") e.request.query_string = redactQuery(e.request.query_string)\n if (e.request.headers) {\n e.request.headers = Object.fromEntries(\n Object.entries(e.request.headers).filter(([k]) => !SECRET_HEADERS.has(k.toLowerCase())),\n )\n }\n }\n const nextjs = e.contexts?.nextjs\n if (typeof nextjs?.request_path === \"string\") nextjs.request_path = redactUrl(nextjs.request_path)\n if (e.message) e.message = redactText(e.message)\n for (const v of e.exception?.values ?? []) if (v.value) v.value = redactText(v.value)\n for (const b of e.breadcrumbs ?? []) {\n if (b.message) b.message = redactText(b.message)\n const d = b.data\n if (!d) continue\n for (const k of [\"url\", \"from\", \"to\"]) if (typeof d[k] === \"string\") d[k] = redactUrl(d[k])\n if (typeof d[\"http.query\"] === \"string\") d[\"http.query\"] = redactUrlOrQuery(d[\"http.query\"])\n if (Array.isArray(d.arguments)) d.arguments = d.arguments.map((a) => (typeof a === \"string\" ? redactText(a) : a))\n }\n return e\n}\n\nexport interface SentryLogLike {\n message: string\n attributes?: Dict\n}\n\nexport function scrubLog<L extends SentryLogLike>(l: L): L {\n l.message = redactText(l.message)\n if (l.attributes) {\n const out: Dict = {}\n for (const [k, v] of Object.entries(l.attributes)) {\n if (DROP_LOG_ATTRS.has(k)) continue\n out[k] = typeof v === \"string\" ? redactText(v) : v\n }\n l.attributes = out\n }\n return l\n}\n\nexport interface SentrySpanLike {\n description?: string\n data?: Dict\n}\n\nexport function scrubSpan<S extends SentrySpanLike>(s: S): S {\n // Browser page-metric spans are described by the full page URL.\n if (typeof s.description === \"string\") s.description = redactUrl(s.description)\n for (const [k, v] of Object.entries(s.data ?? {})) {\n if (DROP_SPAN_KEYS.has(k) || DROP_SPAN_PREFIXES.some((p) => k.startsWith(p))) delete s.data![k]\n else if (REDACT_KEYS.has(k) || REDACT_PREFIXES.some((p) => k.startsWith(p))) s.data![k] = REDACTED\n else if (typeof v === \"string\" && URL_SPAN_KEYS.has(k)) s.data![k] = redactUrlOrQuery(v)\n }\n return s\n}\n"],"mappings":";AAAO,IAAM,WAAW;AAKxB,IAAM,QAAQ;AACd,IAAM,eAAe;AACrB,IAAM,MAAM;AACZ,IAAM,cAAc;AACpB,IAAM,cAAc;AACb,IAAM,gBAAqC,oBAAI,IAAI,CAAC,SAAS,QAAQ,SAAS,YAAY,UAAU,OAAO,WAAW,gBAAgB,iBAAiB,UAAU,CAAC;AACzK,IAAM,iBAAiB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,IAAM,iBAAiB,oBAAI,IAAI,CAAC,MAAM,c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AM,EAAE,WAAW,CAAC,CAAC,EAAG,GAAE,KAAM,CAAC,IAAI;AAAA,aACjF,OAAO,MAAM,YAAY,cAAc,IAAI,CAAC,EAAG,GAAE,KAAM,CAAC,IAAI,iBAAiB,CAAC;AAAA,EACzF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initSentry
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YFZB5EW6.js";
|
|
4
4
|
import {
|
|
5
5
|
readSentryConfig
|
|
6
6
|
} from "./chunk-7ASQHY7O.js";
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
register,
|
|
18
18
|
onRequestError
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
20
|
+
//# sourceMappingURL=chunk-POZI4OKJ.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setTelemetryHooks
|
|
3
|
+
} from "./chunk-MET4SIMB.js";
|
|
4
|
+
import {
|
|
5
|
+
makeDevSinkTransport
|
|
6
|
+
} from "./chunk-7ASQHY7O.js";
|
|
7
|
+
import {
|
|
8
|
+
SECRET_PARAMS,
|
|
9
|
+
scrubEvent,
|
|
10
|
+
scrubLog,
|
|
11
|
+
scrubSpan
|
|
12
|
+
} from "./chunk-IFESUTF2.js";
|
|
13
|
+
|
|
14
|
+
// src/sentry-core/noise.ts
|
|
15
|
+
var NOISE_EXACT = /* @__PURE__ */ new Set(["/favicon.ico", "/api/auth/me"]);
|
|
16
|
+
var RSC_QUERY_RE = /[?&]_rsc=/;
|
|
17
|
+
function isNoisePath(rawUrl, opts = {}) {
|
|
18
|
+
if (RSC_QUERY_RE.test(rawUrl)) return true;
|
|
19
|
+
const path = (rawUrl.split("?")[0] ?? "").trim();
|
|
20
|
+
if (!path) return false;
|
|
21
|
+
if (NOISE_EXACT.has(path)) return true;
|
|
22
|
+
if (path.endsWith(".map")) return true;
|
|
23
|
+
if (path.startsWith("/_next/")) return true;
|
|
24
|
+
if ((opts.noisePrefixes ?? []).some((p) => path.startsWith(p))) return true;
|
|
25
|
+
if (opts.healthPath && path === opts.healthPath) return true;
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/sentry-core/sampler.ts
|
|
30
|
+
var MUTATIONS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
31
|
+
var str = (v) => typeof v === "string" && v ? v : void 0;
|
|
32
|
+
function pathOf(ctx) {
|
|
33
|
+
const a = ctx.attributes ?? {};
|
|
34
|
+
return str(a["url.path"]) ?? str(a["http.target"]) ?? ctx.name.split(" ")[1];
|
|
35
|
+
}
|
|
36
|
+
function createTracesSampler(policy) {
|
|
37
|
+
return (ctx) => {
|
|
38
|
+
const path = pathOf(ctx);
|
|
39
|
+
if (path && isNoisePath(path, { healthPath: policy.healthPath })) return 0;
|
|
40
|
+
const a = ctx.attributes ?? {};
|
|
41
|
+
const method = (str(a["http.request.method"]) ?? str(a["http.method"]) ?? "").toUpperCase();
|
|
42
|
+
if (MUTATIONS.has(method)) return 1;
|
|
43
|
+
return ctx.inheritOrSampleWith(policy.production ? policy.readRate : 1);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/sentry-core/options.ts
|
|
48
|
+
function isTty() {
|
|
49
|
+
try {
|
|
50
|
+
return typeof process !== "undefined" && process.stdout?.isTTY === true;
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function buildOptions(runtime, cfg) {
|
|
56
|
+
return {
|
|
57
|
+
dsn: cfg.dsn,
|
|
58
|
+
environment: cfg.environment,
|
|
59
|
+
release: cfg.release,
|
|
60
|
+
sendDefaultPii: false,
|
|
61
|
+
dataCollection: {
|
|
62
|
+
userInfo: false,
|
|
63
|
+
cookies: false,
|
|
64
|
+
httpHeaders: { request: false, response: false },
|
|
65
|
+
httpBodies: [],
|
|
66
|
+
databaseQueryData: false,
|
|
67
|
+
stackFrameVariables: false,
|
|
68
|
+
genAI: { inputs: false, outputs: false },
|
|
69
|
+
urlQueryParams: { deny: [...SECRET_PARAMS] }
|
|
70
|
+
},
|
|
71
|
+
enableLogs: true,
|
|
72
|
+
tracesSampler: createTracesSampler({
|
|
73
|
+
production: cfg.environment === "production",
|
|
74
|
+
readRate: cfg.readSampleRate,
|
|
75
|
+
healthPath: cfg.healthPath
|
|
76
|
+
}),
|
|
77
|
+
tracePropagationTargets: runtime === "browser" ? [/^\//] : cfg.connOrigins,
|
|
78
|
+
beforeSend: scrubEvent,
|
|
79
|
+
beforeSendTransaction: scrubEvent,
|
|
80
|
+
beforeSendLog: scrubLog,
|
|
81
|
+
beforeSendSpan: scrubSpan,
|
|
82
|
+
initialScope: { tags: cfg.tags },
|
|
83
|
+
...cfg.local ? { transport: makeDevSinkTransport({ traces: cfg.devTraces ?? "line", color: runtime !== "browser" && isTty() }) } : {}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/sentry-core/init.ts
|
|
88
|
+
var DONE = /* @__PURE__ */ Symbol.for("@quatronic/sdk.sentry-initialised");
|
|
89
|
+
var holder = globalThis;
|
|
90
|
+
function initSentry(sentry, runtime, cfg, extra = {}) {
|
|
91
|
+
if (!cfg || holder[DONE]) return false;
|
|
92
|
+
holder[DONE] = true;
|
|
93
|
+
try {
|
|
94
|
+
const extras = typeof extra === "function" ? extra() : extra;
|
|
95
|
+
sentry.init({ ...extras, ...buildOptions(runtime, cfg) });
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error("[qore] Sentry init failed", err);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
setTelemetryHooks({ log: sentry.logger, setUser: (u) => sentry.setUser(u) });
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
initSentry
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=chunk-YFZB5EW6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sentry-core/noise.ts","../src/sentry-core/sampler.ts","../src/sentry-core/options.ts","../src/sentry-core/init.ts"],"sourcesContent":["// Pure predicate deciding whether an HTTP request is infrastructural noise that\n// should never become a span: a `_rsc` query param, `/favicon.ico`, the SDK's\n// session poll, source maps, `/_next/*`, plus the caller's prefixes and health path.\n\nexport interface NoiseFilterOptions {\n healthPath?: string\n noisePrefixes?: string[]\n}\n\n// `/api/auth/me` is the SDK's own session poll (PortalProvider fires it on every\n// page mount): a heartbeat, not user activity.\nconst NOISE_EXACT = new Set([\"/favicon.ico\", \"/api/auth/me\"])\n\n// React Server Components navigations/prefetches carry a `?_rsc=` query param;\n// they look like real routes, so a path-prefix filter misses them.\nconst RSC_QUERY_RE = /[?&]_rsc=/\n\nexport function isNoisePath(rawUrl: string, opts: NoiseFilterOptions = {}): boolean {\n if (RSC_QUERY_RE.test(rawUrl)) return true\n const path = (rawUrl.split(\"?\")[0] ?? \"\").trim()\n if (!path) return false\n if (NOISE_EXACT.has(path)) return true\n if (path.endsWith(\".map\")) return true\n if (path.startsWith(\"/_next/\")) return true\n if ((opts.noisePrefixes ?? []).some((p) => path.startsWith(p))) return true\n if (opts.healthPath && path === opts.healthPath) return true\n return false\n}\n","import { isNoisePath } from \"./noise\"\n\nexport interface SamplingContextLike {\n name: string\n attributes?: Record<string, unknown>\n inheritOrSampleWith: (fallback: number) => number\n}\n\nconst MUTATIONS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"])\n\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" && v ? v : undefined)\n\nfunction pathOf(ctx: SamplingContextLike): string | undefined {\n const a = ctx.attributes ?? {}\n return str(a[\"url.path\"]) ?? str(a[\"http.target\"]) ?? ctx.name.split(\" \")[1]\n}\n\nexport function createTracesSampler(policy: { production: boolean; readRate: number; healthPath: string }) {\n return (ctx: SamplingContextLike): number => {\n const path = pathOf(ctx)\n if (path && isNoisePath(path, { healthPath: policy.healthPath })) return 0\n const a = ctx.attributes ?? {}\n const method = (str(a[\"http.request.method\"]) ?? str(a[\"http.method\"]) ?? \"\").toUpperCase()\n if (MUTATIONS.has(method)) return 1\n return ctx.inheritOrSampleWith(policy.production ? policy.readRate : 1)\n }\n}\n","import { makeDevSinkTransport } from \"./dev-sink\"\nimport type { SentryConfig } from \"./env\"\nimport { createTracesSampler, type SamplingContextLike } from \"./sampler\"\nimport { SECRET_PARAMS, scrubEvent, scrubLog, scrubSpan } from \"./scrub\"\n\nexport type Runtime = \"node\" | \"edge\" | \"browser\"\n\n// Structural copy of @sentry/core's DataCollection (10.75+): stop PII at collection,\n// the scrubbers stay as the backstop. Older 10.x ignores the unknown option.\nexport interface QoreDataCollection {\n userInfo: false\n cookies: false\n httpHeaders: { request: false; response: false }\n httpBodies: []\n databaseQueryData: false\n stackFrameVariables: false\n genAI: { inputs: false; outputs: false }\n urlQueryParams: { deny: string[] }\n}\n\nexport interface QoreSentryOptions {\n dsn: string\n environment: string\n release?: string\n sendDefaultPii: false\n dataCollection: QoreDataCollection\n enableLogs: true\n tracesSampler: (ctx: SamplingContextLike) => number\n tracePropagationTargets: Array<string | RegExp>\n beforeSend: typeof scrubEvent\n beforeSendTransaction: typeof scrubEvent\n beforeSendLog: typeof scrubLog\n beforeSendSpan: typeof scrubSpan\n initialScope: { tags: Record<string, string> }\n transport?: ReturnType<typeof makeDevSinkTransport>\n}\n\nfunction isTty(): boolean {\n try {\n return typeof process !== \"undefined\" && process.stdout?.isTTY === true\n } catch {\n return false\n }\n}\n\nexport function buildOptions(runtime: Runtime, cfg: SentryConfig): QoreSentryOptions {\n return {\n dsn: cfg.dsn,\n environment: cfg.environment,\n release: cfg.release,\n sendDefaultPii: false,\n dataCollection: {\n userInfo: false,\n cookies: false,\n httpHeaders: { request: false, response: false },\n httpBodies: [],\n databaseQueryData: false,\n stackFrameVariables: false,\n genAI: { inputs: false, outputs: false },\n urlQueryParams: { deny: [...SECRET_PARAMS] },\n },\n enableLogs: true,\n tracesSampler: createTracesSampler({\n production: cfg.environment === \"production\",\n readRate: cfg.readSampleRate,\n healthPath: cfg.healthPath,\n }),\n tracePropagationTargets: runtime === \"browser\" ? [/^\\//] : cfg.connOrigins,\n beforeSend: scrubEvent,\n beforeSendTransaction: scrubEvent,\n beforeSendLog: scrubLog,\n beforeSendSpan: scrubSpan,\n initialScope: { tags: cfg.tags },\n ...(cfg.local\n ? { transport: makeDevSinkTransport({ traces: cfg.devTraces ?? \"line\", color: runtime !== \"browser\" && isTty() }) }\n : {}),\n }\n}\n","import { setTelemetryHooks } from \"../telemetry-hooks\"\nimport type { SentryConfig } from \"./env\"\nimport { buildOptions, type Runtime } from \"./options\"\n\nexport interface SentryLike {\n init(options: object): unknown\n logger: Record<\"debug\" | \"info\" | \"warn\" | \"error\", (msg: string, attrs?: Record<string, string | number | boolean>) => void>\n setUser(user: { id: string } | null): void\n}\n\nconst DONE = Symbol.for(\"@quatronic/sdk.sentry-initialised\")\ntype Holder = { [DONE]?: boolean }\nconst holder = globalThis as Holder\n\n// A factory `extra` runs only once the guard passes, inside the try: integrations\n// such as Replay throw when constructed twice.\nexport function initSentry(\n sentry: SentryLike,\n runtime: Runtime,\n cfg: SentryConfig | null,\n extra: object | (() => object) = {},\n): boolean {\n if (!cfg || holder[DONE]) return false\n holder[DONE] = true\n try {\n const extras = typeof extra === \"function\" ? extra() : extra\n sentry.init({ ...extras, ...buildOptions(runtime, cfg) })\n } catch (err) {\n console.error(\"[qore] Sentry init failed\", err)\n return false\n }\n setTelemetryHooks({ log: sentry.logger, setUser: (u) => sentry.setUser(u) })\n return true\n}\n\nexport function resetSentryInitForTests(): void {\n delete holder[DONE]\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,IAAM,cAAc,oBAAI,IAAI,CAAC,gBAAgB,cAAc,CAAC;AAI5D,IAAM,eAAe;AAEd,SAAS,YAAY,QAAgB,OAA2B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,SAAS,GAAG,EAAE,CAAC;AAAA,EAC1D,SAAS,KAAK;AACZ,YAAQ,MAAM,6BAA6B,GAAG;AAC9C,WAAO;AAAA,EACT;AACA,oBAAkB,EAAE,KAAK,OAAO,QAAQ,SAAS,CAAC,MAAM,OAAO,QAAQ,CAAC,EAAE,CAAC;AAC3E,SAAO;AACT;","names":[]}
|
package/dist/next/boot/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
onRequestError,
|
|
3
3
|
register
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-POZI4OKJ.js";
|
|
5
|
+
import "../../chunk-YFZB5EW6.js";
|
|
6
6
|
import "../../chunk-MET4SIMB.js";
|
|
7
7
|
import "../../chunk-7ASQHY7O.js";
|
|
8
|
+
import "../../chunk-IFESUTF2.js";
|
|
8
9
|
|
|
9
10
|
// src/next/boot/index.ts
|
|
10
11
|
async function qoreRegister(node) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/boot/index.ts"],"sourcesContent":["// The body of a Next app's `src/instrumentation.ts`. The app passes what only\n// it can name (its env, migrations, seed); the platform's own boot steps live\n// here, so a new one reaches every app as an SDK release.\n//\n// export async function register() {\n// await qoreRegister(process.env.NEXT_RUNTIME === \"nodejs\" ? { ...loaders } : undefined)\n// // the app's own boot code, after migrations\n// }\n//\n// The ternary in the app file, and the `if` below, are what keep the Node-only\n// loaders out of the edge bundle: Next replaces NEXT_RUNTIME at build time and\n// the bundler drops the dead branch with its imports.\nimport { register as registerSentry } from \"../sentry/register\"\nimport type { NodeBoot } from \"./types\"\n\nexport { onRequestError } from \"../sentry/register\"\nexport type { NodeBoot } from \"./types\"\n\nexport async function qoreRegister(node?: NodeBoot): Promise<void> {\n await registerSentry()\n if (process.env.NEXT_RUNTIME === \"nodejs\" && node) {\n const { bootNode } = await import(\"./node\")\n await bootNode(node)\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/next/boot/index.ts"],"sourcesContent":["// The body of a Next app's `src/instrumentation.ts`. The app passes what only\n// it can name (its env, migrations, seed); the platform's own boot steps live\n// here, so a new one reaches every app as an SDK release.\n//\n// export async function register() {\n// await qoreRegister(process.env.NEXT_RUNTIME === \"nodejs\" ? { ...loaders } : undefined)\n// // the app's own boot code, after migrations\n// }\n//\n// The ternary in the app file, and the `if` below, are what keep the Node-only\n// loaders out of the edge bundle: Next replaces NEXT_RUNTIME at build time and\n// the bundler drops the dead branch with its imports.\nimport { register as registerSentry } from \"../sentry/register\"\nimport type { NodeBoot } from \"./types\"\n\nexport { onRequestError } from \"../sentry/register\"\nexport type { NodeBoot } from \"./types\"\n\nexport async function qoreRegister(node?: NodeBoot): Promise<void> {\n await registerSentry()\n if (process.env.NEXT_RUNTIME === \"nodejs\" && node) {\n const { bootNode } = await import(\"./node\")\n await bootNode(node)\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,eAAsB,aAAa,MAAgC;AACjE,QAAM,SAAe;AACrB,MAAI,QAAQ,IAAI,iBAAiB,YAAY,MAAM;AACjD,UAAM,EAAE,SAAS,IAAI,MAAM,OAAO,wBAAQ;AAC1C,UAAM,SAAS,IAAI;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
STATIC_SECURITY_HEADERS
|
|
3
|
+
} from "../../chunk-2HE2D4SY.js";
|
|
1
4
|
import {
|
|
2
5
|
proxyMatcher
|
|
3
6
|
} from "../../chunk-X6D3TBNS.js";
|
|
@@ -7,9 +10,6 @@ import {
|
|
|
7
10
|
readCspReport
|
|
8
11
|
} from "../../chunk-P7HNHLW7.js";
|
|
9
12
|
import "../../chunk-FUPTRHT7.js";
|
|
10
|
-
import {
|
|
11
|
-
STATIC_SECURITY_HEADERS
|
|
12
|
-
} from "../../chunk-2HE2D4SY.js";
|
|
13
13
|
|
|
14
14
|
// src/next/security/index.ts
|
|
15
15
|
import { NextResponse as NextResponse2 } from "next/server";
|
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
} from "../../chunk-DYOSRJH3.js";
|
|
4
4
|
import {
|
|
5
5
|
initSentry
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-YFZB5EW6.js";
|
|
7
7
|
import "../../chunk-MET4SIMB.js";
|
|
8
8
|
import "../../chunk-7ASQHY7O.js";
|
|
9
|
+
import "../../chunk-IFESUTF2.js";
|
|
9
10
|
|
|
10
11
|
// src/next/sentry/client.ts
|
|
11
12
|
import * as Sentry from "@sentry/nextjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/sentry/client.ts"],"sourcesContent":["import * as Sentry from \"@sentry/nextjs\"\nimport { initSentry, type SentryLike } from \"../../sentry-core/init\"\nimport { readRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// maskAllInputs skips type=\"hidden\", whose values (CSRF tokens, ids) would otherwise be\n// recorded as-is; blocking them drops the element and its input events.\nconst REPLAY_PRIVACY = {\n maskAllText: true, maskAllInputs: true, blockAllMedia: true, block: ['input[type=\"hidden\"]'],\n}\n\ntype BrowserSentry = SentryLike & { replayIntegration(options: object): unknown }\n\nexport function initBrowser(doc: Document, sentry: BrowserSentry): boolean {\n const cfg = readRuntimeConfig(doc)\n // Locally a replay would only print binary segments; errors and logs are what matter there.\n return initSentry(sentry, \"browser\", cfg, () =>\n cfg?.local\n ? {}\n : {\n integrations: [sentry.replayIntegration(REPLAY_PRIVACY)],\n replaysSessionSampleRate: 0,\n replaysOnErrorSampleRate: 1,\n },\n )\n}\n\nif (typeof document !== \"undefined\") initBrowser(document, Sentry)\n\nexport const onRouterTransitionStart = Sentry.captureRouterTransitionStart\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/next/sentry/client.ts"],"sourcesContent":["import * as Sentry from \"@sentry/nextjs\"\nimport { initSentry, type SentryLike } from \"../../sentry-core/init\"\nimport { readRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// maskAllInputs skips type=\"hidden\", whose values (CSRF tokens, ids) would otherwise be\n// recorded as-is; blocking them drops the element and its input events.\nconst REPLAY_PRIVACY = {\n maskAllText: true, maskAllInputs: true, blockAllMedia: true, block: ['input[type=\"hidden\"]'],\n}\n\ntype BrowserSentry = SentryLike & { replayIntegration(options: object): unknown }\n\nexport function initBrowser(doc: Document, sentry: BrowserSentry): boolean {\n const cfg = readRuntimeConfig(doc)\n // Locally a replay would only print binary segments; errors and logs are what matter there.\n return initSentry(sentry, \"browser\", cfg, () =>\n cfg?.local\n ? {}\n : {\n integrations: [sentry.replayIntegration(REPLAY_PRIVACY)],\n replaysSessionSampleRate: 0,\n replaysOnErrorSampleRate: 1,\n },\n )\n}\n\nif (typeof document !== \"undefined\") initBrowser(document, Sentry)\n\nexport const onRouterTransitionStart = Sentry.captureRouterTransitionStart\n"],"mappings":";;;;;;;;;;;AAAA,YAAY,YAAY;AAMxB,IAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EAAM,eAAe;AAAA,EAAM,eAAe;AAAA,EAAM,OAAO,CAAC,sBAAsB;AAC7F;AAIO,SAAS,YAAY,KAAe,QAAgC;AACzE,QAAM,MAAM,kBAAkB,GAAG;AAEjC,SAAO;AAAA,IAAW;AAAA,IAAQ;AAAA,IAAW;AAAA,IAAK,MACxC,KAAK,QACD,CAAC,IACD;AAAA,MACE,cAAc,CAAC,OAAO,kBAAkB,cAAc,CAAC;AAAA,MACvD,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,IAC5B;AAAA,EACN;AACF;AAEA,IAAI,OAAO,aAAa,YAAa,aAAY,UAAU,MAAM;AAE1D,IAAM,0BAAiC;","names":[]}
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
readSentryConfig
|
|
7
7
|
} from "../../chunk-7ASQHY7O.js";
|
|
8
|
+
import {
|
|
9
|
+
registerSecretValues
|
|
10
|
+
} from "../../chunk-IFESUTF2.js";
|
|
8
11
|
|
|
9
12
|
// src/next/sentry/index.tsx
|
|
10
13
|
import { connection } from "next/server";
|
|
@@ -23,6 +26,7 @@ async function QdcSentryRuntimeConfig() {
|
|
|
23
26
|
);
|
|
24
27
|
}
|
|
25
28
|
export {
|
|
26
|
-
QdcSentryRuntimeConfig
|
|
29
|
+
QdcSentryRuntimeConfig,
|
|
30
|
+
registerSecretValues
|
|
27
31
|
};
|
|
28
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/sentry/index.tsx"],"sourcesContent":["import { connection } from \"next/server\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { RUNTIME_CONFIG_ID, serializeRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// Env is read per request: a prerendered layout would bake in the build's (empty) env.\nexport async function QdcSentryRuntimeConfig() {\n await connection()\n const cfg = readSentryConfig(process.env, { frontend: true })\n if (!cfg) return null\n return (\n <script\n id={RUNTIME_CONFIG_ID}\n type=\"application/json\"\n dangerouslySetInnerHTML={{ __html: serializeRuntimeConfig(cfg) }}\n />\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/next/sentry/index.tsx"],"sourcesContent":["import { connection } from \"next/server\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { RUNTIME_CONFIG_ID, serializeRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// Env is read per request: a prerendered layout would bake in the build's (empty) env.\nexport async function QdcSentryRuntimeConfig() {\n await connection()\n const cfg = readSentryConfig(process.env, { frontend: true })\n if (!cfg) return null\n return (\n <script\n id={RUNTIME_CONFIG_ID}\n type=\"application/json\"\n dangerouslySetInnerHTML={{ __html: serializeRuntimeConfig(cfg) }}\n />\n )\n}\n\nexport { registerSecretValues } from \"../../sentry-core/scrub\"\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAUvB;AALJ,eAAsB,yBAAyB;AAC7C,QAAM,WAAW;AACjB,QAAM,MAAM,iBAAiB,QAAQ,KAAK,EAAE,UAAU,KAAK,CAAC;AAC5D,MAAI,CAAC,IAAK,QAAO;AACjB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI;AAAA,MACJ,MAAK;AAAA,MACL,yBAAyB,EAAE,QAAQ,uBAAuB,GAAG,EAAE;AAAA;AAAA,EACjE;AAEJ;","names":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
onRequestError,
|
|
3
3
|
register
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-POZI4OKJ.js";
|
|
5
|
+
import "../../chunk-YFZB5EW6.js";
|
|
6
6
|
import "../../chunk-MET4SIMB.js";
|
|
7
7
|
import "../../chunk-7ASQHY7O.js";
|
|
8
|
+
import "../../chunk-IFESUTF2.js";
|
|
8
9
|
export {
|
|
9
10
|
onRequestError,
|
|
10
11
|
register
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initSentry
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-YFZB5EW6.js";
|
|
4
4
|
import "../../chunk-MET4SIMB.js";
|
|
5
5
|
import {
|
|
6
6
|
readSentryConfig
|
|
7
7
|
} from "../../chunk-7ASQHY7O.js";
|
|
8
|
+
import "../../chunk-IFESUTF2.js";
|
|
8
9
|
|
|
9
10
|
// src/node/sentry/register.ts
|
|
10
11
|
import * as Sentry from "@sentry/node";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/node/sentry/register.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { initSentry } from \"../../sentry-core/init\"\n\ninitSentry(Sentry, \"node\", readSentryConfig(process.env, { frontend: false }))\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/node/sentry/register.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { initSentry } from \"../../sentry-core/init\"\n\ninitSentry(Sentry, \"node\", readSentryConfig(process.env, { frontend: false }))\n"],"mappings":";;;;;;;;;;AAAA,YAAY,YAAY;AAIxB,WAAW,QAAQ,QAAQ,iBAAiB,QAAQ,KAAK,EAAE,UAAU,MAAM,CAAC,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatronic/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-rc.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
"types": "./dist/next/sentry/client.d.ts",
|
|
49
49
|
"import": "./dist/next/sentry/client.js"
|
|
50
50
|
},
|
|
51
|
+
"./node/sentry": {
|
|
52
|
+
"types": "./dist/node/sentry/index.d.ts",
|
|
53
|
+
"import": "./dist/node/sentry/index.js"
|
|
54
|
+
},
|
|
51
55
|
"./node/sentry/register": {
|
|
52
56
|
"types": "./dist/node/sentry/register.d.ts",
|
|
53
57
|
"import": "./dist/node/sentry/register.js"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sentry-core/noise.ts","../src/sentry-core/sampler.ts","../src/sentry-core/scrub.ts","../src/sentry-core/options.ts","../src/sentry-core/init.ts"],"sourcesContent":["// Pure predicate deciding whether an HTTP request is infrastructural noise that\n// should never become a span: a `_rsc` query param, `/favicon.ico`, the SDK's\n// session poll, source maps, `/_next/*`, plus the caller's prefixes and health path.\n\nexport interface NoiseFilterOptions {\n healthPath?: string\n noisePrefixes?: string[]\n}\n\n// `/api/auth/me` is the SDK's own session poll (PortalProvider fires it on every\n// page mount): a heartbeat, not user activity.\nconst NOISE_EXACT = new Set([\"/favicon.ico\", \"/api/auth/me\"])\n\n// React Server Components navigations/prefetches carry a `?_rsc=` query param;\n// they look like real routes, so a path-prefix filter misses them.\nconst RSC_QUERY_RE = /[?&]_rsc=/\n\nexport function isNoisePath(rawUrl: string, opts: NoiseFilterOptions = {}): boolean {\n if (RSC_QUERY_RE.test(rawUrl)) return true\n const path = (rawUrl.split(\"?\")[0] ?? \"\").trim()\n if (!path) return false\n if (NOISE_EXACT.has(path)) return true\n if (path.endsWith(\".map\")) return true\n if (path.startsWith(\"/_next/\")) return true\n if ((opts.noisePrefixes ?? []).some((p) => path.startsWith(p))) return true\n if (opts.healthPath && path === opts.healthPath) return true\n return false\n}\n","import { isNoisePath } from \"./noise\"\n\nexport interface SamplingContextLike {\n name: string\n attributes?: Record<string, unknown>\n inheritOrSampleWith: (fallback: number) => number\n}\n\nconst MUTATIONS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"])\n\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" && v ? v : undefined)\n\nfunction pathOf(ctx: SamplingContextLike): string | undefined {\n const a = ctx.attributes ?? {}\n return str(a[\"url.path\"]) ?? str(a[\"http.target\"]) ?? ctx.name.split(\" \")[1]\n}\n\nexport function createTracesSampler(policy: { production: boolean; readRate: number; healthPath: string }) {\n return (ctx: SamplingContextLike): number => {\n const path = pathOf(ctx)\n if (path && isNoisePath(path, { healthPath: policy.healthPath })) return 0\n const a = ctx.attributes ?? {}\n const method = (str(a[\"http.request.method\"]) ?? str(a[\"http.method\"]) ?? \"\").toUpperCase()\n if (MUTATIONS.has(method)) return 1\n return ctx.inheritOrSampleWith(policy.production ? policy.readRate : 1)\n }\n}\n","export const REDACTED = \"●●●\"\n\n// Bounded and anchored (`(?<![...])` + `{1,64}` local part, no `.` in the\n// domain-char class) so it cannot backtrack catastrophically on long runs of\n// email-charset bytes — see the fix-round-1 report for the O(n²) it replaced.\nconst EMAIL = /(?<![A-Z0-9._%+-])[A-Z0-9._%+-]{1,64}@[A-Z0-9-]+(?:\\.[A-Z0-9-]+)*\\.[A-Z]{2,}/gi\nconst JWT = /eyJ[\\w-]+\\.[\\w-]+\\.[\\w-]+/g\nconst AUTH_SCHEME = /\\b(Bearer|Basic)\\s+\\S+/gi\nconst PARAMS_TAIL = /\\bparams:\\s.*$/s\nexport const SECRET_PARAMS: ReadonlySet<string> = new Set([\"token\", \"code\", \"state\", \"password\", \"secret\", \"key\", \"session\", \"access_token\", \"refresh_token\", \"id_token\"])\nconst SECRET_HEADERS = new Set([\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-qdc-connection-token\",\n \"x-forwarded-for\",\n \"x-real-ip\",\n \"forwarded\",\n \"user-agent\",\n])\nconst DROP_LOG_ATTRS = new Set([\"ip\", \"ip_address\", \"user_agent\", \"email\", \"user_email\", \"server.address\"])\nconst REDACT_KEYS = new Set([\"db.connection_string\", \"db.user\"])\nconst REDACT_PREFIXES = [\"net.peer.\", \"net.sock.\", \"net.host.\", \"network.peer.\", \"network.local.\"]\nconst DROP_SPAN_KEYS = new Set([\"user_agent.original\", \"http.user_agent\", \"client.address\", \"http.client_ip\"])\nconst DROP_SPAN_PREFIXES = [\"http.request.header.\", \"http.response.header.\"]\nconst URL_SPAN_KEYS = new Set([\"url.full\", \"http.url\", \"url\", \"http.target\", \"url.query\", \"http.query\"])\n\nexport function redactText(s: string): string {\n return s\n .replace(PARAMS_TAIL, \"params: [redacted]\")\n .replace(AUTH_SCHEME, \"$1 [redacted]\")\n .replace(JWT, \"[jwt]\")\n .replace(EMAIL, \"[email]\")\n}\n\nfunction redactQuery(query: string): string {\n return query\n .split(\"&\")\n .map((pair) => {\n const [k, v] = pair.split(\"=\", 2)\n return v !== undefined && SECRET_PARAMS.has(k!.toLowerCase()) ? `${k}=[redacted]` : pair\n })\n .join(\"&\")\n}\n\nfunction redactUrl(url: string): string {\n const i = url.indexOf(\"?\")\n return i < 0 ? url : url.slice(0, i + 1) + redactQuery(url.slice(i + 1))\n}\n\n// For values that are either a URL/path or a bare query string (no `?`).\nfunction redactUrlOrQuery(v: string): string {\n return v.includes(\"?\") ? redactUrl(v) : redactQuery(v)\n}\n\ntype Dict = Record<string, unknown>\n\nexport interface SentryEventLike {\n server_name?: string\n user?: Dict\n request?: { url?: string; query_string?: unknown; cookies?: unknown; headers?: Record<string, string>; data?: unknown }\n message?: string\n exception?: { values?: Array<{ type?: string; value?: string }> }\n breadcrumbs?: Array<{ message?: string; data?: Dict }>\n contexts?: { nextjs?: Dict } & Dict\n}\n\nexport function scrubEvent<E extends SentryEventLike>(e: E): E {\n delete e.server_name\n if (e.user) e.user = e.user.id ? { id: e.user.id } : {}\n if (e.request) {\n delete e.request.cookies\n delete e.request.data\n if (e.request.url) e.request.url = redactUrl(e.request.url)\n if (typeof e.request.query_string === \"string\") e.request.query_string = redactQuery(e.request.query_string)\n if (e.request.headers) {\n e.request.headers = Object.fromEntries(\n Object.entries(e.request.headers).filter(([k]) => !SECRET_HEADERS.has(k.toLowerCase())),\n )\n }\n }\n const nextjs = e.contexts?.nextjs\n if (typeof nextjs?.request_path === \"string\") nextjs.request_path = redactUrl(nextjs.request_path)\n if (e.message) e.message = redactText(e.message)\n for (const v of e.exception?.values ?? []) if (v.value) v.value = redactText(v.value)\n for (const b of e.breadcrumbs ?? []) {\n if (b.message) b.message = redactText(b.message)\n const d = b.data\n if (!d) continue\n for (const k of [\"url\", \"from\", \"to\"]) if (typeof d[k] === \"string\") d[k] = redactUrl(d[k])\n if (typeof d[\"http.query\"] === \"string\") d[\"http.query\"] = redactUrlOrQuery(d[\"http.query\"])\n if (Array.isArray(d.arguments)) d.arguments = d.arguments.map((a) => (typeof a === \"string\" ? redactText(a) : a))\n }\n return e\n}\n\nexport interface SentryLogLike {\n message: string\n attributes?: Dict\n}\n\nexport function scrubLog<L extends SentryLogLike>(l: L): L {\n l.message = redactText(l.message)\n if (l.attributes) {\n const out: Dict = {}\n for (const [k, v] of Object.entries(l.attributes)) {\n if (DROP_LOG_ATTRS.has(k)) continue\n out[k] = typeof v === \"string\" ? redactText(v) : v\n }\n l.attributes = out\n }\n return l\n}\n\nexport interface SentrySpanLike {\n description?: string\n data?: Dict\n}\n\nexport function scrubSpan<S extends SentrySpanLike>(s: S): S {\n // Browser page-metric spans are described by the full page URL.\n if (typeof s.description === \"string\") s.description = redactUrl(s.description)\n for (const [k, v] of Object.entries(s.data ?? {})) {\n if (DROP_SPAN_KEYS.has(k) || DROP_SPAN_PREFIXES.some((p) => k.startsWith(p))) delete s.data![k]\n else if (REDACT_KEYS.has(k) || REDACT_PREFIXES.some((p) => k.startsWith(p))) s.data![k] = REDACTED\n else if (typeof v === \"string\" && URL_SPAN_KEYS.has(k)) s.data![k] = redactUrlOrQuery(v)\n }\n return s\n}\n","import { makeDevSinkTransport } from \"./dev-sink\"\nimport type { SentryConfig } from \"./env\"\nimport { createTracesSampler, type SamplingContextLike } from \"./sampler\"\nimport { SECRET_PARAMS, scrubEvent, scrubLog, scrubSpan } from \"./scrub\"\n\nexport type Runtime = \"node\" | \"edge\" | \"browser\"\n\n// Structural copy of @sentry/core's DataCollection (10.75+): stop PII at collection,\n// the scrubbers stay as the backstop. Older 10.x ignores the unknown option.\nexport interface QoreDataCollection {\n userInfo: false\n cookies: false\n httpHeaders: { request: false; response: false }\n httpBodies: []\n databaseQueryData: false\n stackFrameVariables: false\n genAI: { inputs: false; outputs: false }\n urlQueryParams: { deny: string[] }\n}\n\nexport interface QoreSentryOptions {\n dsn: string\n environment: string\n release?: string\n sendDefaultPii: false\n dataCollection: QoreDataCollection\n enableLogs: true\n tracesSampler: (ctx: SamplingContextLike) => number\n tracePropagationTargets: Array<string | RegExp>\n beforeSend: typeof scrubEvent\n beforeSendTransaction: typeof scrubEvent\n beforeSendLog: typeof scrubLog\n beforeSendSpan: typeof scrubSpan\n initialScope: { tags: Record<string, string> }\n transport?: ReturnType<typeof makeDevSinkTransport>\n}\n\nfunction isTty(): boolean {\n try {\n return typeof process !== \"undefined\" && process.stdout?.isTTY === true\n } catch {\n return false\n }\n}\n\nexport function buildOptions(runtime: Runtime, cfg: SentryConfig): QoreSentryOptions {\n return {\n dsn: cfg.dsn,\n environment: cfg.environment,\n release: cfg.release,\n sendDefaultPii: false,\n dataCollection: {\n userInfo: false,\n cookies: false,\n httpHeaders: { request: false, response: false },\n httpBodies: [],\n databaseQueryData: false,\n stackFrameVariables: false,\n genAI: { inputs: false, outputs: false },\n urlQueryParams: { deny: [...SECRET_PARAMS] },\n },\n enableLogs: true,\n tracesSampler: createTracesSampler({\n production: cfg.environment === \"production\",\n readRate: cfg.readSampleRate,\n healthPath: cfg.healthPath,\n }),\n tracePropagationTargets: runtime === \"browser\" ? [/^\\//] : cfg.connOrigins,\n beforeSend: scrubEvent,\n beforeSendTransaction: scrubEvent,\n beforeSendLog: scrubLog,\n beforeSendSpan: scrubSpan,\n initialScope: { tags: cfg.tags },\n ...(cfg.local\n ? { transport: makeDevSinkTransport({ traces: cfg.devTraces ?? \"line\", color: runtime !== \"browser\" && isTty() }) }\n : {}),\n }\n}\n","import { setTelemetryHooks } from \"../telemetry-hooks\"\nimport type { SentryConfig } from \"./env\"\nimport { buildOptions, type Runtime } from \"./options\"\n\nexport interface SentryLike {\n init(options: object): unknown\n logger: Record<\"debug\" | \"info\" | \"warn\" | \"error\", (msg: string, attrs?: Record<string, string | number | boolean>) => void>\n setUser(user: { id: string } | null): void\n}\n\nconst DONE = Symbol.for(\"@quatronic/sdk.sentry-initialised\")\ntype Holder = { [DONE]?: boolean }\nconst holder = globalThis as Holder\n\n// A factory `extra` runs only once the guard passes, inside the try: integrations\n// such as Replay throw when constructed twice.\nexport function initSentry(\n sentry: SentryLike,\n runtime: Runtime,\n cfg: SentryConfig | null,\n extra: object | (() => object) = {},\n): boolean {\n if (!cfg || holder[DONE]) return false\n holder[DONE] = true\n try {\n const extras = typeof extra === \"function\" ? extra() : extra\n sentry.init({ ...extras, ...buildOptions(runtime, cfg) })\n } catch (err) {\n console.error(\"[qore] Sentry init failed\", err)\n return false\n }\n setTelemetryHooks({ log: sentry.logger, setUser: (u) => sentry.setUser(u) })\n return true\n}\n\nexport function resetSentryInitForTests(): void {\n delete holder[DONE]\n}\n"],"mappings":";;;;;;;;AAWA,IAAM,cAAc,oBAAI,IAAI,CAAC,gBAAgB,cAAc,CAAC;AAI5D,IAAM,eAAe;AAEd,SAAS,YAAY,QAAgB,OAA2B,CAAC,GAAY;AAClF,MAAI,aAAa,KAAK,MAAM,EAAG,QAAO;AACtC,QAAM,QAAQ,OAAO,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,KAAK;AAC/C,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,YAAY,IAAI,IAAI,EAAG,QAAO;AAClC,MAAI,KAAK,SAAS,MAAM,EAAG,QAAO;AAClC,MAAI,KAAK,WAAW,SAAS,EAAG,QAAO;AACvC,OAAK,KAAK,iBAAiB,CAAC,GAAG,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,EAAG,QAAO;AACvE,MAAI,KAAK,cAAc,SAAS,KAAK,WAAY,QAAO;AACxD,SAAO;AACT;;;ACnBA,IAAM,YAAY,oBAAI,IAAI,CAAC,QAAQ,OAAO,SAAS,QAAQ,CAAC;AAE5D,IAAM,MAAM,CAAC,MAAoC,OAAO,MAAM,YAAY,IAAI,IAAI;AAElF,SAAS,OAAO,KAA8C;AAC5D,QAAM,IAAI,IAAI,cAAc,CAAC;AAC7B,SAAO,IAAI,EAAE,UAAU,CAAC,KAAK,IAAI,EAAE,aAAa,CAAC,KAAK,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC;AAC7E;AAEO,SAAS,oBAAoB,QAAuE;AACzG,SAAO,CAAC,QAAqC;AAC3C,UAAM,OAAO,OAAO,GAAG;AACvB,QAAI,QAAQ,YAAY,MAAM,EAAE,YAAY,OAAO,WAAW,CAAC,EAAG,QAAO;AACzE,UAAM,IAAI,IAAI,cAAc,CAAC;AAC7B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