@quatronic/sdk 0.3.1 → 0.3.2-canary-20260921104155

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.
@@ -29,7 +29,7 @@ import { hostname } from "os";
29
29
  // package.json
30
30
  var package_default = {
31
31
  name: "@quatronic/sdk",
32
- version: "0.3.1",
32
+ version: "0.3.2-canary-20260921104155",
33
33
  type: "module",
34
34
  private: false,
35
35
  publishConfig: {
@@ -439,4 +439,4 @@ function startNodeSdk(opts) {
439
439
  export {
440
440
  startNodeSdk
441
441
  };
442
- //# sourceMappingURL=chunk-WZ4LQM56.js.map
442
+ //# sourceMappingURL=chunk-2TNRRSZF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/observability-core/start-node-sdk.ts","../src/observability-core/resource.ts","../package.json","../src/observability-core/noise-filter.ts","../src/observability-core/http-sanitize.ts","../src/observability-core/span-scrub.ts","../src/observability-core/scrub-span-processor.ts","../src/observability-core/format-fatal.ts"],"sourcesContent":["// Shared NodeSDK bootstrap for every server runtime (Next and plain Node). The\n// only per-runtime difference is the noise-prefix list. Importing this module's\n// caller (a register entry) must happen before pino/node:http are first imported\n// so the instrumentations can patch them.\nimport { NodeSDK } from \"@opentelemetry/sdk-node\"\nimport { OTLPTraceExporter } from \"@opentelemetry/exporter-trace-otlp-http\"\nimport { OTLPMetricExporter } from \"@opentelemetry/exporter-metrics-otlp-http\"\nimport { OTLPLogExporter } from \"@opentelemetry/exporter-logs-otlp-http\"\nimport { PeriodicExportingMetricReader } from \"@opentelemetry/sdk-metrics\"\nimport { BatchLogRecordProcessor } from \"@opentelemetry/sdk-logs\"\nimport { BatchSpanProcessor } from \"@opentelemetry/sdk-trace-base\"\nimport { HttpInstrumentation } from \"@opentelemetry/instrumentation-http\"\nimport { UndiciInstrumentation } from \"@opentelemetry/instrumentation-undici\"\nimport { PinoInstrumentation } from \"@opentelemetry/instrumentation-pino\"\nimport { PgInstrumentation } from \"@opentelemetry/instrumentation-pg\"\nimport { buildResource } from \"./resource\"\nimport { qdcSanitizeHttp, qdcTracesSampleRatio, qdcEnhancedDbReporting, qdcHealthPath } from \"./env\"\nimport { shouldIgnoreIncoming, shouldIgnoreOutgoing } from \"./noise-filter\"\nimport { sanitizeHttpSpanAttributes } from \"./http-sanitize\"\nimport { ScrubSpanProcessor } from \"./scrub-span-processor\"\nimport { formatFatal } from \"./format-fatal\"\n\nexport interface StartNodeSdkOptions {\n noisePrefixes: string[]\n}\n\nexport function startNodeSdk(opts: StartNodeSdkOptions): NodeSDK {\n const { noisePrefixes } = opts\n\n // Sampling defaults before NodeSDK reads env. Default 100% in all envs; an\n // explicit OTEL_TRACES_SAMPLER always wins.\n if (!process.env.OTEL_TRACES_SAMPLER) process.env.OTEL_TRACES_SAMPLER = \"parentbased_traceidratio\"\n if (!process.env.OTEL_TRACES_SAMPLER_ARG) process.env.OTEL_TRACES_SAMPLER_ARG = qdcTracesSampleRatio()\n\n const healthPath = qdcHealthPath()\n\n const httpInstrumentation = new HttpInstrumentation({\n ignoreIncomingRequestHook: (req) => shouldIgnoreIncoming(req, { healthPath, noisePrefixes }),\n ignoreOutgoingRequestHook: (req) => shouldIgnoreOutgoing({ path: req.path ?? undefined }, { healthPath, noisePrefixes }),\n ...(qdcSanitizeHttp()\n ? { requestHook: (span, request) => sanitizeHttpSpanAttributes(span, request as { url?: string; path?: string }) }\n : {}),\n })\n\n // Cross-module / cross-service propagation: global fetch (undici) is the natural\n // way a Next server and a Node backend call CONN_<ALIAS>_URL. instrumentation-http\n // does NOT see undici, so without this the traceparent is never injected and the\n // hop starts a new trace. Injection is unconditional on origin (server-to-server,\n // no CORS) — that is what continues the trace across modules.\n const undiciInstrumentation = new UndiciInstrumentation({\n ignoreRequestHook: (request) =>\n shouldIgnoreOutgoing({ path: (request as { path?: string }).path }, { healthPath, noisePrefixes }),\n ...(qdcSanitizeHttp()\n ? { requestHook: (span, request) =>\n sanitizeHttpSpanAttributes(span, { path: (request as { path?: string }).path }, \"stable\") }\n : {}),\n })\n\n // DB spans. Full SQL + values only off-prod (synthetic data); parametrized only\n // in prod-like envs. `requireParentSpan` drops queries that run with no active\n // parent span — connection-pool warmup, keepalive pings, startup/migration — so\n // each no longer surfaces as its own root trace. Queries inside an HTTP request\n // (or an `observe()` wrapper) still nest under that span and are kept.\n const pgInstrumentation = new PgInstrumentation({\n enhancedDatabaseReporting: qdcEnhancedDbReporting(),\n requireParentSpan: true,\n })\n\n let sdk: NodeSDK\n try {\n sdk = new NodeSDK({\n resource: buildResource(),\n spanProcessors: [new ScrubSpanProcessor(new BatchSpanProcessor(new OTLPTraceExporter()))],\n metricReader: new PeriodicExportingMetricReader({ exporter: new OTLPMetricExporter() }),\n logRecordProcessor: new BatchLogRecordProcessor(new OTLPLogExporter()),\n instrumentations: [httpInstrumentation, undiciInstrumentation, pgInstrumentation, new PinoInstrumentation()],\n })\n } catch (err: unknown) {\n process.stderr.write(`[qdc-sdk] initialization failed: ${err}\\n`)\n process.exit(1)\n }\n\n try {\n sdk.start()\n } catch (err: unknown) {\n process.stderr.write(`[qdc-sdk] SDK start failed: ${err}\\n`)\n process.exit(1)\n }\n\n const gracefulShutdown = async (signal: string): Promise<void> => {\n process.stderr.write(`[qdc-sdk] ${signal} received, shutting down\\n`)\n try { await sdk.shutdown() } catch { /* ignore */ }\n process.exit(0)\n }\n process.on(\"SIGTERM\", () => void gracefulShutdown(\"SIGTERM\"))\n process.on(\"SIGINT\", () => void gracefulShutdown(\"SIGINT\"))\n process.on(\"uncaughtException\", async (err) => {\n process.stderr.write(`[qdc-sdk] fatal: ${formatFatal(err)}\\n`)\n try { await sdk.shutdown() } finally { process.exit(1) }\n })\n process.on(\"unhandledRejection\", async (reason) => {\n process.stderr.write(`[qdc-sdk] fatal: ${formatFatal(reason)}\\n`)\n try { await sdk.shutdown() } finally { process.exit(1) }\n })\n\n return sdk\n}\n","import { type Resource, resourceFromAttributes } from \"@opentelemetry/resources\"\nimport { hostname } from \"node:os\"\nimport { qdcAppId, qdcCustomerId, qdcEnv, qdcModule } from \"./env\"\nimport pkg from \"../../package.json\" with { type: \"json\" }\n\nconst SDK_VERSION = (pkg as { version: string }).version\n\n/**\n * Maps the QDC identity env vars to the OpenTelemetry resource attributes used\n * by the SDK's server-side observability. The NodeSDK carries this resource on\n * every span and log record (the latter via the in-process PinoInstrumentation),\n * so it is the single source of truth for tenant labels.\n *\n * Identity is read from NEXT_PUBLIC_QDC_* with a fallback to legacy QDC_* (see\n * ./env). Throws if the customer or app id are missing — required to land logs\n * and traces under the correct tenant namespace.\n */\nexport function buildResourceAttributes(): Record<string, string> {\n const customerId = qdcCustomerId()\n if (!customerId)\n throw new Error(\"NEXT_PUBLIC_QDC_CUSTOMER_ID (or legacy QDC_CUSTOMER_ID) env var is required\")\n\n const appId = qdcAppId()\n if (!appId)\n throw new Error(\"NEXT_PUBLIC_QDC_APP_ID (or legacy QDC_APP_ID) env var is required\")\n\n const env = qdcEnv()\n\n const attrs: Record<string, string> = {\n \"service.name\": appId,\n \"service.namespace\": customerId,\n \"deployment.environment\": env,\n \"host.name\": hostname(),\n \"qdc.customer_id\": customerId,\n \"qdc.app_id\": appId,\n \"qdc.sdk.version\": SDK_VERSION,\n }\n const mod = qdcModule()\n if (mod) attrs[\"qdc.module\"] = mod\n return attrs\n}\n\nexport function buildResource(): Resource {\n return resourceFromAttributes(buildResourceAttributes())\n}\n","{\n \"name\": \"@quatronic/sdk\",\n \"version\": \"0.3.2-canary-20260921104155\",\n \"type\": \"module\",\n \"private\": false,\n \"publishConfig\": {\n \"registry\": \"https://registry.npmjs.org\",\n \"access\": \"public\"\n },\n \"files\": [\n \"dist\",\n \"semgrep\"\n ],\n \"bin\": {\n \"qdc-setup-env\": \"./dist/cli/setup-env.js\"\n },\n \"exports\": {\n \"./auth\": {\n \"types\": \"./dist/auth/index.d.ts\",\n \"import\": \"./dist/auth/index.js\"\n },\n \"./next/auth\": {\n \"types\": \"./dist/next/auth/index.d.ts\",\n \"import\": \"./dist/next/auth/index.js\"\n },\n \"./next/better-auth\": {\n \"types\": \"./dist/next/better-auth/index.d.ts\",\n \"import\": \"./dist/next/better-auth/index.js\"\n },\n \"./observability\": {\n \"types\": \"./dist/observability/index.d.ts\",\n \"import\": \"./dist/observability/index.js\"\n },\n \"./next/observability\": {\n \"types\": \"./dist/next/observability/index.d.ts\",\n \"import\": \"./dist/next/observability/index.js\"\n },\n \"./next/observability/register\": {\n \"types\": \"./dist/next/observability/register.d.ts\",\n \"import\": \"./dist/next/observability/register.js\"\n },\n \"./node/observability\": {\n \"types\": \"./dist/node/observability/index.d.ts\",\n \"import\": \"./dist/node/observability/index.js\"\n },\n \"./node/observability/register\": {\n \"types\": \"./dist/node/observability/register.d.ts\",\n \"import\": \"./dist/node/observability/register.js\"\n },\n \"./next/config\": {\n \"types\": \"./dist/next/config/index.d.ts\",\n \"import\": \"./dist/next/config/index.js\"\n },\n \"./next/security\": {\n \"types\": \"./dist/next/security/index.d.ts\",\n \"import\": \"./dist/next/security/index.js\"\n },\n \"./next/security/testing\": {\n \"types\": \"./dist/next/security/testing.d.ts\",\n \"import\": \"./dist/next/security/testing.js\"\n },\n \"./eslint\": {\n \"types\": \"./dist/eslint/index.d.ts\",\n \"import\": \"./dist/eslint/index.js\"\n },\n \"./next/connections\": {\n \"types\": \"./dist/next/connections/index.d.ts\",\n \"import\": \"./dist/next/connections/index.js\"\n },\n \"./node/connections\": {\n \"types\": \"./dist/node/connections/index.d.ts\",\n \"import\": \"./dist/node/connections/index.js\"\n },\n \"./node/net\": {\n \"types\": \"./dist/node/net/index.d.ts\",\n \"import\": \"./dist/node/net/index.js\"\n },\n \"./node/fspath\": {\n \"types\": \"./dist/node/fspath/index.d.ts\",\n \"import\": \"./dist/node/fspath/index.js\"\n },\n \"./node/parse\": {\n \"types\": \"./dist/node/parse/index.d.ts\",\n \"import\": \"./dist/node/parse/index.js\"\n },\n \"./node/identity\": {\n \"types\": \"./dist/node/identity/index.d.ts\",\n \"import\": \"./dist/node/identity/index.js\"\n },\n \"./node/db\": {\n \"types\": \"./dist/node/db/index.d.ts\",\n \"import\": \"./dist/node/db/index.js\"\n },\n \"./next/db\": {\n \"types\": \"./dist/next/db/index.d.ts\",\n \"import\": \"./dist/next/db/index.js\"\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"surface\": \"node scripts/api-surface.mjs\",\n \"surface:check\": \"node scripts/api-surface.mjs --check\",\n \"prepublishOnly\": \"pnpm build\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"tsc --noEmit && tsc -p tsconfig.test.json\",\n \"lint\": \"eslint src tests\",\n \"calibrate\": \"node scripts/calibrate.mjs\"\n },\n \"dependencies\": {\n \"@opentelemetry/api\": \"^1.9.1\",\n \"@opentelemetry/context-zone\": \"2.7.1\",\n \"@opentelemetry/exporter-logs-otlp-http\": \"^0.218.0\",\n \"@opentelemetry/exporter-metrics-otlp-http\": \"^0.218.0\",\n \"@opentelemetry/exporter-trace-otlp-http\": \"^0.218.0\",\n \"@opentelemetry/instrumentation\": \"^0.218.0\",\n \"@opentelemetry/instrumentation-document-load\": \"^0.63.0\",\n \"@opentelemetry/instrumentation-fetch\": \"^0.218.0\",\n \"@opentelemetry/instrumentation-http\": \"^0.218.0\",\n \"@opentelemetry/instrumentation-pg\": \"^0.71.0\",\n \"@opentelemetry/instrumentation-pino\": \"^0.64.0\",\n \"@opentelemetry/instrumentation-undici\": \"^0.28.0\",\n \"@opentelemetry/resources\": \"^2.7.1\",\n \"@opentelemetry/sdk-logs\": \"^0.218.0\",\n \"@opentelemetry/sdk-metrics\": \"^2.7.1\",\n \"@opentelemetry/sdk-node\": \"^0.218.0\",\n \"@opentelemetry/sdk-trace-base\": \"2.7.1\",\n \"@opentelemetry/sdk-trace-web\": \"2.7.1\",\n \"jose\": \"^5.9.6\",\n \"pino\": \"^10.3.1\"\n },\n \"peerDependencies\": {\n \"@better-auth/core\": \">=1.6\",\n \"better-auth\": \">=1.6\",\n \"drizzle-orm\": \">=0.36\",\n \"eslint\": \">=9\",\n \"next\": \">=15\",\n \"pg\": \">=8.13\",\n \"react\": \">=18\",\n \"react-dom\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"eslint\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"react-dom\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"drizzle-orm\": {\n \"optional\": true\n },\n \"pg\": {\n \"optional\": true\n },\n \"better-auth\": {\n \"optional\": true\n },\n \"@better-auth/core\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@better-auth/core\": \"^1.6.24\",\n \"@eslint/js\": \"^10.0.1\",\n \"@opentelemetry/instrumentation\": \"^0.218.0\",\n \"@opentelemetry/sdk-trace-base\": \"^2.7.0\",\n \"@testcontainers/postgresql\": \"^12.0.0\",\n \"@testing-library/react\": \"^16.1.0\",\n \"@types/node\": \"^22.10.2\",\n \"@types/pg\": \"^8.11.10\",\n \"@types/react\": \"^18.3.17\",\n \"@types/react-dom\": \"^18.3.5\",\n \"@vitest/coverage-v8\": \"^2.1.9\",\n \"better-auth\": \"^1.6.24\",\n \"drizzle-kit\": \"^0.30.1\",\n \"drizzle-orm\": \"^0.38.2\",\n \"eslint\": \"^10.5.0\",\n \"jsdom\": \"^25.0.1\",\n \"msw\": \"^2.7.0\",\n \"next\": \"^15.1.0\",\n \"pg\": \"^8.13.1\",\n \"react\": \"^18.3.1\",\n \"react-dom\": \"^18.3.1\",\n \"testcontainers\": \"^10.16.0\",\n \"tsup\": \"^8.3.5\",\n \"typescript\": \"^5.7.2\",\n \"typescript-eslint\": \"^8.61.1\",\n \"vitest\": \"^2.1.8\"\n }\n}\n","// Pure predicate deciding whether an HTTP request is infrastructural noise that\n// should never become a span. Framework-agnostic rules are built in: favicon,\n// source maps, OPTIONS, RSC navigations/prefetches (`?_rsc=` query + RSC headers),\n// and Next's `/_next/*` internals. Callers pass any additional environment-specific\n// prefixes (and an optional health path) via NoiseFilterOptions.\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. The meaningful auth flows keep\n// their labeled spans (Log in, Complete login, Log out, Refresh session);\n// dropping the inbound span here also drops its pg children (requireParentSpan).\nconst NOISE_EXACT = new Set([\"/favicon.ico\", \"/api/auth/me\"])\n\n// React Server Components navigations/prefetches/data-fetches. Next signals them\n// with a `?_rsc=` query param and/or an `RSC` / `Next-Router-Prefetch` request\n// header. They are real-looking routes, so a path-prefix filter misses them.\n// NOTE: `Next-Router-State-Tree` is intentionally NOT in this list — Next.js\n// sends it on server actions too (POST + Next-Action), not only on RSC navigations,\n// so it is not a safe RSC discriminator.\nconst RSC_QUERY_RE = /[?&]_rsc=/\nconst RSC_HEADERS = [\"rsc\", \"next-router-prefetch\"]\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\nexport function shouldIgnoreIncoming(\n req: { url?: string; method?: string; headers?: Record<string, unknown> },\n opts: NoiseFilterOptions = {},\n): boolean {\n if ((req.method ?? \"\").toUpperCase() === \"OPTIONS\") return true\n const headers = req.headers ?? {}\n // A Next.js server action is real work — never noise — even though it also\n // carries router headers. Exempt it explicitly so its inbound span (and the\n // DB child gated by pg requireParentSpan) is preserved.\n if (headers[\"next-action\"] != null) return false\n if (RSC_HEADERS.some((h) => headers[h] != null)) return true\n return isNoisePath(req.url ?? \"\", opts)\n}\n\nexport function shouldIgnoreOutgoing(\n req: { path?: string },\n opts: NoiseFilterOptions = {},\n): boolean {\n return isNoisePath(req.path ?? \"\", opts)\n}\n","// Pure HTTP-span PII sanitizer. No OTel SDK import so it is unit-testable in\n// isolation. register.ts wires sanitizeHttpSpanAttributes into the\n// HttpInstrumentation requestHook when QDC_OTEL_SANITIZE_HTTP is on.\n\nconst REDACTED = \"[redacted]\"\n\nexport type SemconvMode = \"legacy\" | \"stable\" | \"dup\"\n\n// instrumentation-http emits legacy attribute names by default and the stable\n// names (url.full/url.query/url.path) only when OTEL_SEMCONV_STABILITY_OPT_IN\n// selects \"http\" (stable only) or \"http/dup\" (both).\nexport function httpSemconvMode(\n optIn: string | undefined = process.env.OTEL_SEMCONV_STABILITY_OPT_IN,\n): SemconvMode {\n const tokens = (optIn ?? \"\").split(\",\").map((t) => t.trim().toLowerCase())\n if (tokens.includes(\"http/dup\")) return \"dup\"\n if (tokens.includes(\"http\")) return \"stable\"\n return \"legacy\"\n}\n\ninterface SpanLike {\n setAttribute(key: string, value: string): unknown\n}\n\ninterface RequestLike {\n url?: string // IncomingMessage (server spans): path + query\n path?: string // ClientRequest (outgoing spans): path + query\n}\n\nexport function sanitizeHttpSpanAttributes(\n span: SpanLike,\n request: RequestLike,\n mode: SemconvMode = httpSemconvMode(),\n): void {\n const raw = request.url ?? request.path ?? \"\"\n const queryStart = raw.indexOf(\"?\")\n const hasQuery = queryStart !== -1\n const path = hasQuery ? raw.slice(0, queryStart) : raw\n\n // Legacy semconv: redact http.url (once the query is gone it only duplicates\n // http.host + http.target); http.target keeps the path. Skip http.target when\n // we have no path info, so we don't clobber the instrumentation's \"/\" default.\n if (mode === \"legacy\" || mode === \"dup\") {\n if (path) span.setAttribute(\"http.target\", path)\n span.setAttribute(\"http.url\", REDACTED)\n }\n\n // Stable semconv: the query lives in url.full / url.query; url.path is already\n // query-less, so leave it intact. Only redact url.query when a query was\n // actually present — the instrumentation omits it otherwise, and writing it\n // unconditionally would falsely signal a redacted query on clean paths.\n if (mode === \"stable\" || mode === \"dup\") {\n span.setAttribute(\"url.full\", REDACTED)\n if (hasQuery) span.setAttribute(\"url.query\", REDACTED)\n }\n}\n","// Leaf-noise predicate + attribute redaction, pure so they unit-test without the\n// OTel SDK. Wired into export by scrub-span-processor.ts. Contract:\n// docs (QDC spec 2026-07-02): the SDK drops ONLY leaf spans — spans that never\n// have children — so parent/child chains can never break. Structural framework\n// spans (BaseServer.handleRequest, AppRender.fetch, undici) stay; the portal\n// folds those at render time.\n\nexport const REDACTED = \"●●●\"\n\n// next.span_type values that are pure leaves and never carry information a\n// developer needs: sub-millisecond router/renderer bookkeeping.\nconst NEXT_LEAF_NOISE = new Set([\n \"Middleware.execute\",\n \"NextNodeServer.findPageComponents\",\n \"NextNodeServer.startResponse\",\n])\n\n// pg connection-pool bookkeeping; the actual query span (pg.query:*) stays.\nconst NOISE_SPAN_NAMES = new Set([\"pg-pool.connect\", \"pg.connect\"])\n\nexport function isNoiseLeafSpan(name: string, attributes: Record<string, unknown>): boolean {\n const nextType = attributes[\"next.span_type\"]\n if (typeof nextType === \"string\" && NEXT_LEAF_NOISE.has(nextType)) return true\n return NOISE_SPAN_NAMES.has(name)\n}\n\nconst REDACT_KEYS = new Set([\"db.connection_string\", \"db.user\"])\nconst REDACT_PREFIXES = [\"net.peer.\", \"net.sock.\", \"net.host.\", \"network.peer.\", \"network.local.\"]\n\nexport function redactSpanAttributes(attributes: Record<string, unknown>): void {\n for (const key of Object.keys(attributes)) {\n if (REDACT_KEYS.has(key) || REDACT_PREFIXES.some((p) => key.startsWith(p))) {\n attributes[key] = REDACTED\n }\n }\n}\n","import type { Context } from \"@opentelemetry/api\"\nimport type { ReadableSpan, Span, SpanProcessor } from \"@opentelemetry/sdk-trace-base\"\nimport { isNoiseLeafSpan, redactSpanAttributes } from \"./span-scrub\"\n\n/** Wraps the export processor: drops leaf-noise spans and redacts sensitive\n * attributes on everything else. Runs in ALL envs — connection strings and\n * internal IPs never belong in the telemetry backend. */\nexport class ScrubSpanProcessor implements SpanProcessor {\n constructor(private readonly inner: SpanProcessor) {}\n\n onStart(span: Span, parentContext: Context): void {\n this.inner.onStart(span, parentContext)\n }\n\n onEnd(span: ReadableSpan): void {\n if (isNoiseLeafSpan(span.name, span.attributes as Record<string, unknown>)) return\n redactSpanAttributes(span.attributes as Record<string, unknown>)\n this.inner.onEnd(span)\n }\n\n forceFlush(): Promise<void> {\n return this.inner.forceFlush()\n }\n\n shutdown(): Promise<void> {\n return this.inner.shutdown()\n }\n}\n","// A crash that reaches the SDK's last-resort handlers is often the only thing an\n// operator ever sees about it: the process dies before any log exporter flushes,\n// so all that survives is this one stderr line in the platform's container log.\n// `${err}` would reduce it to \"Error: self-signed certificate\" — no stack, no\n// cause, no error code, i.e. no way to tell which of the app's boot steps threw.\nexport function formatFatal(err: unknown): string {\n if (!(err instanceof Error)) return String(err)\n\n let out = err.stack ?? `${err.name}: ${err.message}`\n\n const code = (err as { code?: unknown }).code\n if (typeof code === \"string\" || typeof code === \"number\") out += `\\n code: ${code}`\n\n // Fetch/undici and pg wrap the real failure in `cause`; without it a boot\n // crash reads as a generic \"TypeError: fetch failed\".\n let cause: unknown = (err as { cause?: unknown }).cause\n let depth = 0\n while (cause !== undefined && depth < 3) {\n const rendered = cause instanceof Error ? (cause.stack ?? `${cause.name}: ${cause.message}`) : String(cause)\n out += `\\n caused by: ${rendered}`\n cause = cause instanceof Error ? (cause as { cause?: unknown }).cause : undefined\n depth += 1\n }\n\n return out\n}\n"],"mappings":";;;;;;;;;;;;AAIA,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,qCAAqC;AAC9C,SAAS,+BAA+B;AACxC,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;;;ACdlC,SAAwB,8BAA8B;AACtD,SAAS,gBAAgB;;;ACDzB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,MAAQ;A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AAQ,OAAO,MAAM,+BAA+B,GAAG;AAAA,CAAI;AAC3D,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,mBAAmB,OAAO,WAAkC;AAChE,YAAQ,OAAO,MAAM,aAAa,MAAM;AAAA,CAA4B;AACpE,QAAI;AAAE,YAAM,IAAI,SAAS;AAAA,IAAE,QAAQ;AAAA,IAAe;AAClD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,UAAQ,GAAG,WAAW,MAAM,KAAK,iBAAiB,SAAS,CAAC;AAC5D,UAAQ,GAAG,UAAU,MAAM,KAAK,iBAAiB,QAAQ,CAAC;AAC1D,UAAQ,GAAG,qBAAqB,OAAO,QAAQ;AAC7C,YAAQ,OAAO,MAAM,oBAAoB,YAAY,GAAG,CAAC;AAAA,CAAI;AAC7D,QAAI;AAAE,YAAM,IAAI,SAAS;AAAA,IAAE,UAAE;AAAU,cAAQ,KAAK,CAAC;AAAA,IAAE;AAAA,EACzD,CAAC;AACD,UAAQ,GAAG,sBAAsB,OAAO,WAAW;AACjD,YAAQ,OAAO,MAAM,oBAAoB,YAAY,MAAM,CAAC;AAAA,CAAI;AAChE,QAAI;AAAE,YAAM,IAAI,SAAS;AAAA,IAAE,UAAE;AAAU,cAAQ,KAAK,CAAC;AAAA,IAAE;AAAA,EACzD,CAAC;AAED,SAAO;AACT;","names":["REDACTED"]}
@@ -232,7 +232,20 @@ var recommended = [
232
232
  "qdc/no-inner-html": "off",
233
233
  "qdc/no-insert-adjacent-html": "off",
234
234
  "qdc/no-document-write": "off",
235
- "qdc/no-raw-script-tag": "off"
235
+ "qdc/no-raw-script-tag": "off",
236
+ // The two location bans are off here for a different reason than the
237
+ // XSS ones above. They do not say "this is dangerous"; they say "this
238
+ // capability belongs in `src/db` or `src/scripts`, not scattered through
239
+ // the app", and that argument is about the shape of the *application*. A
240
+ // test reads a fixture off disk and an integration test opens a real
241
+ // connection; neither ships, and neither can be reached by a request, so
242
+ // neither is the traversal or injection surface the ban exists for.
243
+ //
244
+ // Found by running the pack over five live tenant repositories before it
245
+ // started blocking merges: `no-fs-import` fired six times in one repo and
246
+ // every hit was a test reading its own fixture.
247
+ "qdc/no-fs-import": "off",
248
+ "qdc/no-driver-import": "off"
236
249
  }
237
250
  }
238
251
  ];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/eslint/ast.ts","../../src/eslint/rules.ts","../../src/eslint/index.ts"],"sourcesContent":["// A deliberately narrow view of the AST, for rules that are deliberately\n// syntactic.\n//\n// ESLint's own `Rule.Node` is the ESTree union. It does not describe JSX at\n// all, and it forces a narrowing cascade for every property access — in rules\n// whose whole job is to read three or four fields off a node and report it.\n// So these rules declare exactly the fields they read and cast once, at the\n// visitor boundary, rather than per line.\n//\n// Anything that has to follow a value across functions or files is a Semgrep\n// rule instead; that pack ships in `semgrep/` alongside this plugin.\nexport interface AstNode {\n type: string\n /** `Identifier.name` and `MemberExpression.property.name`. Never a JSX name. */\n name?: string\n value?: unknown\n callee?: AstNode\n object?: AstNode\n property?: AstNode\n source?: AstNode\n arguments?: (AstNode | undefined)[]\n expressions?: unknown[]\n}\n\n/** Calls whose result is a URL this app decided on, not one a caller supplied. */\nexport const VETTED_CALLS = [\"safeRedirect\", \"safeFetch\", \"vetTarget\", \"clone\"]\n\n/** POSIX form of the file being linted, so the checks read the same on Windows. */\nexport function pathOf(filename: string): string {\n return filename.replaceAll(\"\\\\\", \"/\")\n}\n\n/** Is the linted file at, or inside, one of these project paths? */\nexport function isUnder(filename: string, paths: readonly string[]): boolean {\n const file = pathOf(filename)\n return paths.some((path) => file.endsWith(`/${path}`) || file.includes(`/${path}/`))\n}\n\n/** The called name, whether the callee is `f()` or `x.f()`. */\nexport function calleeName(node: AstNode): string {\n const callee = node.callee\n if (!callee) return \"\"\n if (callee.type === \"Identifier\") return callee.name ?? \"\"\n if (callee.type === \"MemberExpression\" && callee.property?.type === \"Identifier\") {\n return callee.property.name ?? \"\"\n }\n return \"\"\n}\n\n/**\n * A target this app wrote down, rather than one that arrived with the request.\n *\n * `allowIdentifier` is the whole difference between the two advisory rules:\n * judging what a bare variable holds takes dataflow, which is what the Semgrep\n * taint rules do. `qdc/safe-redirect` lets a variable through because\n * `NextResponse.redirect(url)` after `req.nextUrl.clone()` is the canonical\n * Next redirect and appears in every generated app; `qdc/safe-fetch` does not.\n */\nexport function isFixedTarget(node: AstNode | undefined, allowIdentifier: boolean): boolean {\n if (!node) return false\n if (node.type === \"Literal\") return typeof node.value === \"string\"\n if (node.type === \"TemplateLiteral\") return (node.expressions?.length ?? 0) === 0\n if (node.type === \"Identifier\") return allowIdentifier\n if (node.type === \"NewExpression\") {\n // `new URL(\"/login\", req.url)` fixes the path; the base only ever\n // contributes this app's own origin.\n return node.callee?.name === \"URL\" && isFixedTarget(node.arguments?.[0], allowIdentifier)\n }\n if (node.type === \"CallExpression\") return VETTED_CALLS.includes(calleeName(node))\n return false\n}\n","import type { Rule } from \"eslint\"\n\nimport { type AstNode, isFixedTarget, isUnder } from \"./ast\"\n\n/**\n * The twelve QDC security lint rules.\n *\n * One rule per id, rather than twelve entries in `no-restricted-syntax`, for\n * two reasons that only show up after the fact:\n *\n * - **Severity is per rule.** `no-restricted-syntax` carries one severity for\n * its whole array, and two of these are advisory on purpose — they fire on\n * shapes that are usually fine, and the Semgrep pack does the dataflow they\n * can only approximate.\n * - **Suppression is per rule.** `// eslint-disable-next-line\n * no-restricted-syntax` switches off every selector on that line, so\n * silencing \"no inline styles\" would silently also silence the\n * `dangerouslySetInnerHTML` ban sitting next to it.\n *\n * Suppress one by its own name, and say why:\n *\n * // eslint-disable-next-line qdc/no-dangerous-html -- sanitised in renderPost()\n */\n\n/** Modules that talk to the database directly, and where that is allowed. */\nconst DB_DRIVERS = [\"pg\", \"postgres\", \"mysql2\", \"mysql2/promise\"]\nconst DB_LAYER = [\"src/db\", \"src/lib/db.ts\"]\n\n/** Node's filesystem API, and where a generated app is expected to use it. */\nconst FS_MODULES = [\"fs\", \"node:fs\", \"fs/promises\", \"node:fs/promises\"]\nconst FS_CALLERS = [\"src/scripts\", \"src/db\"]\n\n/** Where a fetch goes out with the server's own network position. */\nconst SERVER_PATHS = [\"src/app/api\", \"src/lib/server\", \"src/proxy.ts\"]\n\n/** One cast, at the boundary, instead of one per `context.report` call. */\nfunction reporter(context: Rule.RuleContext, message: string): (node: AstNode) => void {\n return (node: AstNode) => {\n context.report({ node: node as unknown as Rule.Node, message })\n }\n}\n\nfunction listener(visitor: Record<string, (node: AstNode) => void>): Rule.RuleListener {\n return visitor as unknown as Rule.RuleListener\n}\n\nfunction meta(description: string, type: \"problem\" | \"suggestion\"): Rule.RuleModule[\"meta\"] {\n return { type, docs: { description }, schema: [] }\n}\n\n/** A rule that reports every node matching one of `selectors`. */\nfunction ban(id: string, message: string, selectors: string[]): Rule.RuleModule {\n const text = `${id} - ${message}`\n return {\n meta: meta(text, \"problem\"),\n create(context) {\n const report = reporter(context, text)\n return listener(Object.fromEntries(selectors.map((selector) => [selector, report])))\n },\n }\n}\n\n/** A rule that bans importing any of `modules`, except from `allowed` paths. */\nfunction banImports(\n id: string,\n message: string,\n modules: string[],\n allowed: string[],\n): Rule.RuleModule {\n const text = `${id} - ${message}`\n return {\n meta: meta(text, \"problem\"),\n create(context) {\n if (isUnder(context.filename, allowed)) return {}\n const report = reporter(context, text)\n const flag = (node: AstNode) => {\n const source = node.source\n if (source?.type === \"Literal\" && typeof source.value === \"string\") {\n if (modules.includes(source.value)) report(node)\n }\n }\n return listener({ ImportDeclaration: flag, ImportExpression: flag })\n },\n }\n}\n\nconst noStringEval: Rule.RuleModule = {\n meta: meta(\"QDC-XSS-005 - no code compiled from a string\", \"problem\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-XSS-005 - compiling a string into code runs whatever the string turned out to be. Pass a function.\",\n )\n const isStringy = (node: AstNode | undefined) =>\n node?.type === \"TemplateLiteral\" ||\n node?.type === \"BinaryExpression\" ||\n (node?.type === \"Literal\" && typeof node.value === \"string\")\n return listener({\n \"CallExpression[callee.name='eval']\": report,\n \"CallExpression[callee.name='Function']\": report,\n \"NewExpression[callee.name='Function']\": report,\n \"CallExpression[callee.name=/^set(Timeout|Interval)$/]\": (node) => {\n if (isStringy(node.arguments?.[0])) report(node)\n },\n })\n },\n}\n\nconst safeRedirect: Rule.RuleModule = {\n meta: meta(\"QDC-URL-001 - redirect to a target this app decided on\", \"suggestion\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-URL-001 - redirecting to a value that came with the request is an open redirect. Wrap it in safeRedirect from @quatronic/sdk/next/auth.\",\n )\n return listener({\n \"CallExpression[callee.object.name='NextResponse'][callee.property.name='redirect']\": (\n node,\n ) => {\n if (isFixedTarget(node.arguments?.[0], true)) return\n report(node)\n },\n })\n },\n}\n\nconst safeFetch: Rule.RuleModule = {\n meta: meta(\"QDC-NET-001 - server-side fetch of a caller-supplied URL\", \"suggestion\"),\n create(context) {\n if (!isUnder(context.filename, SERVER_PATHS)) return {}\n const report = reporter(\n context,\n \"QDC-NET-001 - a URL the server did not decide on reaches the private network too. Use safeFetch from @quatronic/sdk/node/net, or connection(alias).fetch for a wired module.\",\n )\n return listener({\n \"CallExpression[callee.name='fetch']\": (node) => {\n if (isFixedTarget(node.arguments?.[0], false)) return\n report(node)\n },\n })\n },\n}\n\nexport const rules: Record<string, Rule.RuleModule> = {\n \"no-dangerous-html\": ban(\n \"QDC-XSS-001\",\n \"dangerouslySetInnerHTML renders unescaped markup. Render text, or sanitise it first.\",\n [\"JSXAttribute[name.name='dangerouslySetInnerHTML']\"],\n ),\n \"no-inner-html\": ban(\n \"QDC-XSS-002\",\n \"Assigning innerHTML parses the string as markup. Use textContent.\",\n [\n \"AssignmentExpression[left.type='MemberExpression'][left.property.name=/^(innerHTML|outerHTML)$/]\",\n ],\n ),\n \"no-insert-adjacent-html\": ban(\n \"QDC-XSS-003\",\n \"insertAdjacentHTML parses its argument as markup. Build the nodes instead.\",\n [\"CallExpression[callee.property.name='insertAdjacentHTML']\"],\n ),\n \"no-document-write\": ban(\n \"QDC-XSS-004\",\n \"document.write parses its argument as markup and blocks the parser. Render it in React.\",\n [\"CallExpression[callee.object.name='document'][callee.property.name=/^write(ln)?$/]\"],\n ),\n \"no-string-eval\": noStringEval,\n \"no-raw-script-tag\": ban(\n \"QDC-CSP-001\",\n \"A hand-written <script> gets no nonce, and this app's CSP uses 'strict-dynamic', so it will not run. Use next/script.\",\n [\"JSXElement[openingElement.name.name='script']\"],\n ),\n \"no-sql-interpolation\": ban(\n \"QDC-SQL-001\",\n \"An interpolated string reaching .execute() is the injection. Use the sql tag, which parameterises.\",\n [\n \"CallExpression[callee.property.name='execute'] > TemplateLiteral[expressions.length>0]\",\n \"CallExpression[callee.property.name='execute'] > BinaryExpression[operator='+']\",\n ],\n ),\n \"no-sql-raw\": ban(\n \"QDC-SQL-002\",\n \"sql.raw() puts its argument into the query verbatim and sanitises nothing. Interpolate through the sql tag.\",\n [\"MemberExpression[object.name='sql'][property.name='raw']\"],\n ),\n \"no-driver-import\": banImports(\n \"QDC-SQL-003\",\n \"The database driver belongs in the db layer. Everywhere else, go through Drizzle.\",\n DB_DRIVERS,\n DB_LAYER,\n ),\n \"no-fs-import\": banImports(\n \"QDC-FS-001\",\n \"Request handlers should not reach the filesystem. If one must, use safeJoin from @quatronic/sdk/node/fspath.\",\n FS_MODULES,\n FS_CALLERS,\n ),\n \"safe-redirect\": safeRedirect,\n \"safe-fetch\": safeFetch,\n}\n\n/**\n * Rule name to QDC id, for docs and for anything that wants to assert the set\n * without re-deriving it from the messages.\n */\nexport const RULE_IDS: Record<string, string> = {\n \"no-dangerous-html\": \"QDC-XSS-001\",\n \"no-inner-html\": \"QDC-XSS-002\",\n \"no-insert-adjacent-html\": \"QDC-XSS-003\",\n \"no-document-write\": \"QDC-XSS-004\",\n \"no-string-eval\": \"QDC-XSS-005\",\n \"no-raw-script-tag\": \"QDC-CSP-001\",\n \"no-sql-interpolation\": \"QDC-SQL-001\",\n \"no-sql-raw\": \"QDC-SQL-002\",\n \"no-driver-import\": \"QDC-SQL-003\",\n \"no-fs-import\": \"QDC-FS-001\",\n \"safe-redirect\": \"QDC-URL-001\",\n \"safe-fetch\": \"QDC-NET-001\",\n}\n","import type { Linter, Rule } from \"eslint\"\n\nimport { RULE_IDS, rules } from \"./rules\"\n\nexport { RULE_IDS, rules } from \"./rules\"\n\n/**\n * The QDC security ESLint plugin.\n *\n * It lives here rather than in each generated app because a lint rule is the\n * cheapest security control QDC has, and a rule copied into every app can only\n * be tightened by editing every app. Shipped from the SDK, a corrected rule\n * reaches an app on its next `@quatronic/sdk` bump — the same bump the app\n * pays for everything else in the package.\n *\n * Usage in a generated app's `eslint.config.mjs`:\n *\n * import qdcSecurity from \"@quatronic/sdk/eslint\"\n *\n * export default [\n * ...whatever,\n * ...qdcSecurity.configs.recommended,\n * ]\n *\n * The rules are syntactic by design. Anything that has to follow a value\n * across functions and files is a Semgrep rule instead, in this package's\n * `semgrep/` directory, run by the same CI job.\n */\nconst plugin = {\n meta: { name: \"@quatronic/sdk/eslint\" },\n rules,\n}\n\n/** Where a generated app keeps the code these rules are about. */\nconst SRC_FILES = [\"src/**/*.{ts,tsx}\"]\nconst TEST_FILES = [\"**/*.test.{ts,tsx}\", \"**/*.spec.{ts,tsx}\"]\n\nexport interface QdcSecurityConfigs {\n recommended: Linter.Config[]\n}\n\n/**\n * The plugin object, typed explicitly: an inferred type here reaches into\n * `@eslint/core` and TypeScript refuses to name it in a `.d.ts`.\n */\nexport interface QdcSecurityPlugin {\n meta: { name: string }\n rules: Record<string, Rule.RuleModule>\n configs: QdcSecurityConfigs\n RULE_IDS: Record<string, string>\n}\n\n/**\n * Two blocks, spread into a flat config in this order.\n *\n * The second one is not decoration: a test that proves escaping works has to\n * build the markup it escapes, so the XSS bans are off there. It is a separate\n * block because flat-config rule options **replace** rather than merge — a\n * later block naming a rule wins outright — so the exemption has to come after\n * the block that switches the rules on, and has to name only what it exempts.\n */\nconst recommended: Linter.Config[] = [\n {\n files: SRC_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-dangerous-html\": \"error\",\n \"qdc/no-inner-html\": \"error\",\n \"qdc/no-insert-adjacent-html\": \"error\",\n \"qdc/no-document-write\": \"error\",\n \"qdc/no-string-eval\": \"error\",\n \"qdc/no-raw-script-tag\": \"error\",\n \"qdc/no-sql-interpolation\": \"error\",\n \"qdc/no-sql-raw\": \"error\",\n \"qdc/no-driver-import\": \"error\",\n \"qdc/no-fs-import\": \"error\",\n // Advisory, and `eslint .` does not fail on warnings. Both fire on\n // shapes that are often fine, so they prompt a look rather than block a\n // merge; qdc.redirect.tainted and qdc.ssrf.tainted-fetch in the Semgrep\n // pack follow the value and are what actually decide.\n \"qdc/safe-redirect\": \"warn\",\n \"qdc/safe-fetch\": \"warn\",\n },\n },\n {\n // Tests build markup on purpose, to prove the escaping works.\n files: TEST_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-dangerous-html\": \"off\",\n \"qdc/no-inner-html\": \"off\",\n \"qdc/no-insert-adjacent-html\": \"off\",\n \"qdc/no-document-write\": \"off\",\n \"qdc/no-raw-script-tag\": \"off\",\n },\n },\n]\n\nexport const configs: QdcSecurityConfigs = { recommended }\n\nconst qdcSecurity: QdcSecurityPlugin = { ...plugin, configs, RULE_IDS }\n\nexport default qdcSecurity\n"],"mappings":";AAyBO,IAAM,eAAe,CAAC,gBAAgB,aAAa,aAAa,OAAO;AAGvE,SAAS,OAAO,UAA0B;AAC/C,SAAO,SAAS,WAAW,MAAM,GAAG;AACtC;AAGO,SAAS,QAAQ,UAAkB,OAAmC;AAC3E,QAAM,OAAO,OAAO,QAAQ;AAC5B,SAAO,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,EAAE,KAAK,KAAK,SAAS,IAAI,IAAI,GAAG,CAAC;AACrF;AAGO,SAAS,WAAW,MAAuB;AAChD,QAAM,SAAS,KAAK;AACpB,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO,SAAS,aAAc,QAAO,OA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[]}
1
+ {"version":3,"sources":["../../src/eslint/ast.ts","../../src/eslint/rules.ts","../../src/eslint/index.ts"],"sourcesContent":["// A deliberately narrow view of the AST, for rules that are deliberately\n// syntactic.\n//\n// ESLint's own `Rule.Node` is the ESTree union. It does not describe JSX at\n// all, and it forces a narrowing cascade for every property access — in rules\n// whose whole job is to read three or four fields off a node and report it.\n// So these rules declare exactly the fields they read and cast once, at the\n// visitor boundary, rather than per line.\n//\n// Anything that has to follow a value across functions or files is a Semgrep\n// rule instead; that pack ships in `semgrep/` alongside this plugin.\nexport interface AstNode {\n type: string\n /** `Identifier.name` and `MemberExpression.property.name`. Never a JSX name. */\n name?: string\n value?: unknown\n callee?: AstNode\n object?: AstNode\n property?: AstNode\n source?: AstNode\n arguments?: (AstNode | undefined)[]\n expressions?: unknown[]\n}\n\n/** Calls whose result is a URL this app decided on, not one a caller supplied. */\nexport const VETTED_CALLS = [\"safeRedirect\", \"safeFetch\", \"vetTarget\", \"clone\"]\n\n/** POSIX form of the file being linted, so the checks read the same on Windows. */\nexport function pathOf(filename: string): string {\n return filename.replaceAll(\"\\\\\", \"/\")\n}\n\n/** Is the linted file at, or inside, one of these project paths? */\nexport function isUnder(filename: string, paths: readonly string[]): boolean {\n const file = pathOf(filename)\n return paths.some((path) => file.endsWith(`/${path}`) || file.includes(`/${path}/`))\n}\n\n/** The called name, whether the callee is `f()` or `x.f()`. */\nexport function calleeName(node: AstNode): string {\n const callee = node.callee\n if (!callee) return \"\"\n if (callee.type === \"Identifier\") return callee.name ?? \"\"\n if (callee.type === \"MemberExpression\" && callee.property?.type === \"Identifier\") {\n return callee.property.name ?? \"\"\n }\n return \"\"\n}\n\n/**\n * A target this app wrote down, rather than one that arrived with the request.\n *\n * `allowIdentifier` is the whole difference between the two advisory rules:\n * judging what a bare variable holds takes dataflow, which is what the Semgrep\n * taint rules do. `qdc/safe-redirect` lets a variable through because\n * `NextResponse.redirect(url)` after `req.nextUrl.clone()` is the canonical\n * Next redirect and appears in every generated app; `qdc/safe-fetch` does not.\n */\nexport function isFixedTarget(node: AstNode | undefined, allowIdentifier: boolean): boolean {\n if (!node) return false\n if (node.type === \"Literal\") return typeof node.value === \"string\"\n if (node.type === \"TemplateLiteral\") return (node.expressions?.length ?? 0) === 0\n if (node.type === \"Identifier\") return allowIdentifier\n if (node.type === \"NewExpression\") {\n // `new URL(\"/login\", req.url)` fixes the path; the base only ever\n // contributes this app's own origin.\n return node.callee?.name === \"URL\" && isFixedTarget(node.arguments?.[0], allowIdentifier)\n }\n if (node.type === \"CallExpression\") return VETTED_CALLS.includes(calleeName(node))\n return false\n}\n","import type { Rule } from \"eslint\"\n\nimport { type AstNode, isFixedTarget, isUnder } from \"./ast\"\n\n/**\n * The twelve QDC security lint rules.\n *\n * One rule per id, rather than twelve entries in `no-restricted-syntax`, for\n * two reasons that only show up after the fact:\n *\n * - **Severity is per rule.** `no-restricted-syntax` carries one severity for\n * its whole array, and two of these are advisory on purpose — they fire on\n * shapes that are usually fine, and the Semgrep pack does the dataflow they\n * can only approximate.\n * - **Suppression is per rule.** `// eslint-disable-next-line\n * no-restricted-syntax` switches off every selector on that line, so\n * silencing \"no inline styles\" would silently also silence the\n * `dangerouslySetInnerHTML` ban sitting next to it.\n *\n * Suppress one by its own name, and say why:\n *\n * // eslint-disable-next-line qdc/no-dangerous-html -- sanitised in renderPost()\n */\n\n/** Modules that talk to the database directly, and where that is allowed. */\nconst DB_DRIVERS = [\"pg\", \"postgres\", \"mysql2\", \"mysql2/promise\"]\nconst DB_LAYER = [\"src/db\", \"src/lib/db.ts\"]\n\n/** Node's filesystem API, and where a generated app is expected to use it. */\nconst FS_MODULES = [\"fs\", \"node:fs\", \"fs/promises\", \"node:fs/promises\"]\nconst FS_CALLERS = [\"src/scripts\", \"src/db\"]\n\n/** Where a fetch goes out with the server's own network position. */\nconst SERVER_PATHS = [\"src/app/api\", \"src/lib/server\", \"src/proxy.ts\"]\n\n/** One cast, at the boundary, instead of one per `context.report` call. */\nfunction reporter(context: Rule.RuleContext, message: string): (node: AstNode) => void {\n return (node: AstNode) => {\n context.report({ node: node as unknown as Rule.Node, message })\n }\n}\n\nfunction listener(visitor: Record<string, (node: AstNode) => void>): Rule.RuleListener {\n return visitor as unknown as Rule.RuleListener\n}\n\nfunction meta(description: string, type: \"problem\" | \"suggestion\"): Rule.RuleModule[\"meta\"] {\n return { type, docs: { description }, schema: [] }\n}\n\n/** A rule that reports every node matching one of `selectors`. */\nfunction ban(id: string, message: string, selectors: string[]): Rule.RuleModule {\n const text = `${id} - ${message}`\n return {\n meta: meta(text, \"problem\"),\n create(context) {\n const report = reporter(context, text)\n return listener(Object.fromEntries(selectors.map((selector) => [selector, report])))\n },\n }\n}\n\n/** A rule that bans importing any of `modules`, except from `allowed` paths. */\nfunction banImports(\n id: string,\n message: string,\n modules: string[],\n allowed: string[],\n): Rule.RuleModule {\n const text = `${id} - ${message}`\n return {\n meta: meta(text, \"problem\"),\n create(context) {\n if (isUnder(context.filename, allowed)) return {}\n const report = reporter(context, text)\n const flag = (node: AstNode) => {\n const source = node.source\n if (source?.type === \"Literal\" && typeof source.value === \"string\") {\n if (modules.includes(source.value)) report(node)\n }\n }\n return listener({ ImportDeclaration: flag, ImportExpression: flag })\n },\n }\n}\n\nconst noStringEval: Rule.RuleModule = {\n meta: meta(\"QDC-XSS-005 - no code compiled from a string\", \"problem\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-XSS-005 - compiling a string into code runs whatever the string turned out to be. Pass a function.\",\n )\n const isStringy = (node: AstNode | undefined) =>\n node?.type === \"TemplateLiteral\" ||\n node?.type === \"BinaryExpression\" ||\n (node?.type === \"Literal\" && typeof node.value === \"string\")\n return listener({\n \"CallExpression[callee.name='eval']\": report,\n \"CallExpression[callee.name='Function']\": report,\n \"NewExpression[callee.name='Function']\": report,\n \"CallExpression[callee.name=/^set(Timeout|Interval)$/]\": (node) => {\n if (isStringy(node.arguments?.[0])) report(node)\n },\n })\n },\n}\n\nconst safeRedirect: Rule.RuleModule = {\n meta: meta(\"QDC-URL-001 - redirect to a target this app decided on\", \"suggestion\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-URL-001 - redirecting to a value that came with the request is an open redirect. Wrap it in safeRedirect from @quatronic/sdk/next/auth.\",\n )\n return listener({\n \"CallExpression[callee.object.name='NextResponse'][callee.property.name='redirect']\": (\n node,\n ) => {\n if (isFixedTarget(node.arguments?.[0], true)) return\n report(node)\n },\n })\n },\n}\n\nconst safeFetch: Rule.RuleModule = {\n meta: meta(\"QDC-NET-001 - server-side fetch of a caller-supplied URL\", \"suggestion\"),\n create(context) {\n if (!isUnder(context.filename, SERVER_PATHS)) return {}\n const report = reporter(\n context,\n \"QDC-NET-001 - a URL the server did not decide on reaches the private network too. Use safeFetch from @quatronic/sdk/node/net, or connection(alias).fetch for a wired module.\",\n )\n return listener({\n \"CallExpression[callee.name='fetch']\": (node) => {\n if (isFixedTarget(node.arguments?.[0], false)) return\n report(node)\n },\n })\n },\n}\n\nexport const rules: Record<string, Rule.RuleModule> = {\n \"no-dangerous-html\": ban(\n \"QDC-XSS-001\",\n \"dangerouslySetInnerHTML renders unescaped markup. Render text, or sanitise it first.\",\n [\"JSXAttribute[name.name='dangerouslySetInnerHTML']\"],\n ),\n \"no-inner-html\": ban(\n \"QDC-XSS-002\",\n \"Assigning innerHTML parses the string as markup. Use textContent.\",\n [\n \"AssignmentExpression[left.type='MemberExpression'][left.property.name=/^(innerHTML|outerHTML)$/]\",\n ],\n ),\n \"no-insert-adjacent-html\": ban(\n \"QDC-XSS-003\",\n \"insertAdjacentHTML parses its argument as markup. Build the nodes instead.\",\n [\"CallExpression[callee.property.name='insertAdjacentHTML']\"],\n ),\n \"no-document-write\": ban(\n \"QDC-XSS-004\",\n \"document.write parses its argument as markup and blocks the parser. Render it in React.\",\n [\"CallExpression[callee.object.name='document'][callee.property.name=/^write(ln)?$/]\"],\n ),\n \"no-string-eval\": noStringEval,\n \"no-raw-script-tag\": ban(\n \"QDC-CSP-001\",\n \"A hand-written <script> gets no nonce, and this app's CSP uses 'strict-dynamic', so it will not run. Use next/script.\",\n [\"JSXElement[openingElement.name.name='script']\"],\n ),\n \"no-sql-interpolation\": ban(\n \"QDC-SQL-001\",\n \"An interpolated string reaching .execute() is the injection. Use the sql tag, which parameterises.\",\n [\n \"CallExpression[callee.property.name='execute'] > TemplateLiteral[expressions.length>0]\",\n \"CallExpression[callee.property.name='execute'] > BinaryExpression[operator='+']\",\n ],\n ),\n \"no-sql-raw\": ban(\n \"QDC-SQL-002\",\n \"sql.raw() puts its argument into the query verbatim and sanitises nothing. Interpolate through the sql tag.\",\n [\"MemberExpression[object.name='sql'][property.name='raw']\"],\n ),\n \"no-driver-import\": banImports(\n \"QDC-SQL-003\",\n \"The database driver belongs in the db layer. Everywhere else, go through Drizzle.\",\n DB_DRIVERS,\n DB_LAYER,\n ),\n \"no-fs-import\": banImports(\n \"QDC-FS-001\",\n \"Request handlers should not reach the filesystem. If one must, use safeJoin from @quatronic/sdk/node/fspath.\",\n FS_MODULES,\n FS_CALLERS,\n ),\n \"safe-redirect\": safeRedirect,\n \"safe-fetch\": safeFetch,\n}\n\n/**\n * Rule name to QDC id, for docs and for anything that wants to assert the set\n * without re-deriving it from the messages.\n */\nexport const RULE_IDS: Record<string, string> = {\n \"no-dangerous-html\": \"QDC-XSS-001\",\n \"no-inner-html\": \"QDC-XSS-002\",\n \"no-insert-adjacent-html\": \"QDC-XSS-003\",\n \"no-document-write\": \"QDC-XSS-004\",\n \"no-string-eval\": \"QDC-XSS-005\",\n \"no-raw-script-tag\": \"QDC-CSP-001\",\n \"no-sql-interpolation\": \"QDC-SQL-001\",\n \"no-sql-raw\": \"QDC-SQL-002\",\n \"no-driver-import\": \"QDC-SQL-003\",\n \"no-fs-import\": \"QDC-FS-001\",\n \"safe-redirect\": \"QDC-URL-001\",\n \"safe-fetch\": \"QDC-NET-001\",\n}\n","import type { Linter, Rule } from \"eslint\"\n\nimport { RULE_IDS, rules } from \"./rules\"\n\nexport { RULE_IDS, rules } from \"./rules\"\n\n/**\n * The QDC security ESLint plugin.\n *\n * It lives here rather than in each generated app because a lint rule is the\n * cheapest security control QDC has, and a rule copied into every app can only\n * be tightened by editing every app. Shipped from the SDK, a corrected rule\n * reaches an app on its next `@quatronic/sdk` bump — the same bump the app\n * pays for everything else in the package.\n *\n * Usage in a generated app's `eslint.config.mjs`:\n *\n * import qdcSecurity from \"@quatronic/sdk/eslint\"\n *\n * export default [\n * ...whatever,\n * ...qdcSecurity.configs.recommended,\n * ]\n *\n * The rules are syntactic by design. Anything that has to follow a value\n * across functions and files is a Semgrep rule instead, in this package's\n * `semgrep/` directory, run by the same CI job.\n */\nconst plugin = {\n meta: { name: \"@quatronic/sdk/eslint\" },\n rules,\n}\n\n/** Where a generated app keeps the code these rules are about. */\nconst SRC_FILES = [\"src/**/*.{ts,tsx}\"]\nconst TEST_FILES = [\"**/*.test.{ts,tsx}\", \"**/*.spec.{ts,tsx}\"]\n\nexport interface QdcSecurityConfigs {\n recommended: Linter.Config[]\n}\n\n/**\n * The plugin object, typed explicitly: an inferred type here reaches into\n * `@eslint/core` and TypeScript refuses to name it in a `.d.ts`.\n */\nexport interface QdcSecurityPlugin {\n meta: { name: string }\n rules: Record<string, Rule.RuleModule>\n configs: QdcSecurityConfigs\n RULE_IDS: Record<string, string>\n}\n\n/**\n * Two blocks, spread into a flat config in this order.\n *\n * The second one is not decoration: a test that proves escaping works has to\n * build the markup it escapes, so the XSS bans are off there. It is a separate\n * block because flat-config rule options **replace** rather than merge — a\n * later block naming a rule wins outright — so the exemption has to come after\n * the block that switches the rules on, and has to name only what it exempts.\n */\nconst recommended: Linter.Config[] = [\n {\n files: SRC_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-dangerous-html\": \"error\",\n \"qdc/no-inner-html\": \"error\",\n \"qdc/no-insert-adjacent-html\": \"error\",\n \"qdc/no-document-write\": \"error\",\n \"qdc/no-string-eval\": \"error\",\n \"qdc/no-raw-script-tag\": \"error\",\n \"qdc/no-sql-interpolation\": \"error\",\n \"qdc/no-sql-raw\": \"error\",\n \"qdc/no-driver-import\": \"error\",\n \"qdc/no-fs-import\": \"error\",\n // Advisory, and `eslint .` does not fail on warnings. Both fire on\n // shapes that are often fine, so they prompt a look rather than block a\n // merge; qdc.redirect.tainted and qdc.ssrf.tainted-fetch in the Semgrep\n // pack follow the value and are what actually decide.\n \"qdc/safe-redirect\": \"warn\",\n \"qdc/safe-fetch\": \"warn\",\n },\n },\n {\n // Tests build markup on purpose, to prove the escaping works.\n files: TEST_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-dangerous-html\": \"off\",\n \"qdc/no-inner-html\": \"off\",\n \"qdc/no-insert-adjacent-html\": \"off\",\n \"qdc/no-document-write\": \"off\",\n \"qdc/no-raw-script-tag\": \"off\",\n // The two location bans are off here for a different reason than the\n // XSS ones above. They do not say \"this is dangerous\"; they say \"this\n // capability belongs in `src/db` or `src/scripts`, not scattered through\n // the app\", and that argument is about the shape of the *application*. A\n // test reads a fixture off disk and an integration test opens a real\n // connection; neither ships, and neither can be reached by a request, so\n // neither is the traversal or injection surface the ban exists for.\n //\n // Found by running the pack over five live tenant repositories before it\n // started blocking merges: `no-fs-import` fired six times in one repo and\n // every hit was a test reading its own fixture.\n \"qdc/no-fs-import\": \"off\",\n \"qdc/no-driver-import\": \"off\",\n },\n },\n]\n\nexport const configs: QdcSecurityConfigs = { recommended }\n\nconst qdcSecurity: QdcSecurityPlugin = { ...plugin, configs, RULE_IDS }\n\nexport default qdcSecurity\n"],"mappings":";AAyBO,IAAM,eAAe,CAAC,gBAAgB,aAAa,aAAa,OAAO;AAGvE,SAAS,OAAO,UAA0B;AAC/C,SAAO,SAAS,WAAW,MAAM,GAAG;AACtC;AAGO,SAAS,QAAQ,UAAkB,OAAmC;AAC3E,QAAM,OAAO,OAAO,QAAQ;AAC5B,SAAO,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,EAAE,KAAK,KAAK,SA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,MACzB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAYzB,oBAAoB;AAAA,MACpB,wBAAwB;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,IAAM,UAA8B,EAAE,YAAY;AAEzD,IAAM,cAAiC,EAAE,GAAG,QAAQ,SAAS,SAAS;AAEtE,IAAO,iBAAQ;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  startNodeSdk
3
- } from "../../chunk-WZ4LQM56.js";
3
+ } from "../../chunk-2TNRRSZF.js";
4
4
  import "../../chunk-UWTYTBJP.js";
5
5
 
6
6
  // src/next/observability/register.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  startNodeSdk
3
- } from "../../chunk-WZ4LQM56.js";
3
+ } from "../../chunk-2TNRRSZF.js";
4
4
  import "../../chunk-UWTYTBJP.js";
5
5
 
6
6
  // src/node/observability/register.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatronic/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.3.2-canary-20260921104155",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -120,9 +120,9 @@ rules:
120
120
  # --------------------------------------------------------------------------
121
121
  - id: qdc.redirect.tainted
122
122
  mode: taint
123
- # WARNING until the corpus scores license the promotion; see
124
- # docs/security-rules.md. Promoted to ERROR in a later SDK minor.
125
- severity: WARNING
123
+ # Promoted from WARNING on 2026-09-17. The corpus licensed it and a scan of
124
+ # five live tenant repositories found nothing it would newly block.
125
+ severity: ERROR
126
126
  languages: [typescript, javascript]
127
127
  message: >-
128
128
  A user-controlled value reaches a redirect. An open redirect is a phishing
@@ -196,9 +196,9 @@ rules:
196
196
  # --------------------------------------------------------------------------
197
197
  - id: qdc.ssrf.tainted-fetch
198
198
  mode: taint
199
- # WARNING until the corpus scores license the promotion; see
200
- # docs/security-rules.md. Promoted to ERROR in a later SDK minor.
201
- severity: WARNING
199
+ # Promoted from WARNING on 2026-09-17. The corpus licensed it and a scan of
200
+ # five live tenant repositories found nothing it would newly block.
201
+ severity: ERROR
202
202
  languages: [typescript, javascript]
203
203
  message: >-
204
204
  A user-controlled value reaches an outbound request. That is how "fetch
@@ -492,10 +492,12 @@ rules:
492
492
  - "*.mjs"
493
493
  - "*.cjs"
494
494
  message: >-
495
- A lint or scan suppression carries no reason. Write it as
495
+ A QDC security suppression carries no reason. Write it as
496
496
  "-- <rule id>: <why this case is safe>", at least 20 characters, so the
497
497
  next reader can tell a considered exception from a silenced warning.
498
498
  A bare "nosemgrep" with no rule id is never acceptable - name the rule.
499
+ Ordinary lint suppressions are not this rule's business; only a `qdc/`
500
+ rule or a `nosemgrep` is.
499
501
  metadata:
500
502
  category: best-practice
501
503
  confidence: HIGH
@@ -508,5 +510,16 @@ rules:
508
510
  # inside that prose. Without this the rule fires on any file that
509
511
  # documents the convention it enforces - it fired on this pack's own
510
512
  # src/eslint/rules.ts.
511
- - pattern-regex: '(?m)^[ \t]*(?:[^\n`*\s][^\n`]*)?(?://|/\*)[ \t]*(?:eslint-disable(?:-next-line|-line)?\b|nosemgrep\b)[^\n]*'
513
+ #
514
+ # Only a *QDC* suppression is in scope, which is why the eslint branch
515
+ # requires a `qdc/` rule id on the same line. Demanding a 20-character
516
+ # justification for `no-console` or `react-hooks/exhaustive-deps` is not
517
+ # a security control, and it is how a security rule gets deleted: the dry
518
+ # run over five live tenant repositories produced seven findings, every
519
+ # one of them an ordinary lint suppression and not one of them a QDC
520
+ # rule - so on the day the scan started blocking, three of those five
521
+ # repos could not have merged anything, for reasons unrelated to
522
+ # security. `nosemgrep` needs no such qualifier: the only semgrep rules
523
+ # a generated app runs are these.
524
+ - pattern-regex: '(?m)^[ \t]*(?:[^\n`*\s][^\n`]*)?(?://|/\*)[ \t]*(?:eslint-disable(?:-next-line|-line)?\b[^\n]*\bqdc/|nosemgrep\b)[^\n]*'
512
525
  - pattern-not-regex: '--[ \t]*\S[^\n]{19,}'
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/observability-core/start-node-sdk.ts","../src/observability-core/resource.ts","../package.json","../src/observability-core/noise-filter.ts","../src/observability-core/http-sanitize.ts","../src/observability-core/span-scrub.ts","../src/observability-core/scrub-span-processor.ts","../src/observability-core/format-fatal.ts"],"sourcesContent":["// Shared NodeSDK bootstrap for every server runtime (Next and plain Node). The\n// only per-runtime difference is the noise-prefix list. Importing this module's\n// caller (a register entry) must happen before pino/node:http are first imported\n// so the instrumentations can patch them.\nimport { NodeSDK } from \"@opentelemetry/sdk-node\"\nimport { OTLPTraceExporter } from \"@opentelemetry/exporter-trace-otlp-http\"\nimport { OTLPMetricExporter } from \"@opentelemetry/exporter-metrics-otlp-http\"\nimport { OTLPLogExporter } from \"@opentelemetry/exporter-logs-otlp-http\"\nimport { PeriodicExportingMetricReader } from \"@opentelemetry/sdk-metrics\"\nimport { BatchLogRecordProcessor } from \"@opentelemetry/sdk-logs\"\nimport { BatchSpanProcessor } from \"@opentelemetry/sdk-trace-base\"\nimport { HttpInstrumentation } from \"@opentelemetry/instrumentation-http\"\nimport { UndiciInstrumentation } from \"@opentelemetry/instrumentation-undici\"\nimport { PinoInstrumentation } from \"@opentelemetry/instrumentation-pino\"\nimport { PgInstrumentation } from \"@opentelemetry/instrumentation-pg\"\nimport { buildResource } from \"./resource\"\nimport { qdcSanitizeHttp, qdcTracesSampleRatio, qdcEnhancedDbReporting, qdcHealthPath } from \"./env\"\nimport { shouldIgnoreIncoming, shouldIgnoreOutgoing } from \"./noise-filter\"\nimport { sanitizeHttpSpanAttributes } from \"./http-sanitize\"\nimport { ScrubSpanProcessor } from \"./scrub-span-processor\"\nimport { formatFatal } from \"./format-fatal\"\n\nexport interface StartNodeSdkOptions {\n noisePrefixes: string[]\n}\n\nexport function startNodeSdk(opts: StartNodeSdkOptions): NodeSDK {\n const { noisePrefixes } = opts\n\n // Sampling defaults before NodeSDK reads env. Default 100% in all envs; an\n // explicit OTEL_TRACES_SAMPLER always wins.\n if (!process.env.OTEL_TRACES_SAMPLER) process.env.OTEL_TRACES_SAMPLER = \"parentbased_traceidratio\"\n if (!process.env.OTEL_TRACES_SAMPLER_ARG) process.env.OTEL_TRACES_SAMPLER_ARG = qdcTracesSampleRatio()\n\n const healthPath = qdcHealthPath()\n\n const httpInstrumentation = new HttpInstrumentation({\n ignoreIncomingRequestHook: (req) => shouldIgnoreIncoming(req, { healthPath, noisePrefixes }),\n ignoreOutgoingRequestHook: (req) => shouldIgnoreOutgoing({ path: req.path ?? undefined }, { healthPath, noisePrefixes }),\n ...(qdcSanitizeHttp()\n ? { requestHook: (span, request) => sanitizeHttpSpanAttributes(span, request as { url?: string; path?: string }) }\n : {}),\n })\n\n // Cross-module / cross-service propagation: global fetch (undici) is the natural\n // way a Next server and a Node backend call CONN_<ALIAS>_URL. instrumentation-http\n // does NOT see undici, so without this the traceparent is never injected and the\n // hop starts a new trace. Injection is unconditional on origin (server-to-server,\n // no CORS) — that is what continues the trace across modules.\n const undiciInstrumentation = new UndiciInstrumentation({\n ignoreRequestHook: (request) =>\n shouldIgnoreOutgoing({ path: (request as { path?: string }).path }, { healthPath, noisePrefixes }),\n ...(qdcSanitizeHttp()\n ? { requestHook: (span, request) =>\n sanitizeHttpSpanAttributes(span, { path: (request as { path?: string }).path }, \"stable\") }\n : {}),\n })\n\n // DB spans. Full SQL + values only off-prod (synthetic data); parametrized only\n // in prod-like envs. `requireParentSpan` drops queries that run with no active\n // parent span — connection-pool warmup, keepalive pings, startup/migration — so\n // each no longer surfaces as its own root trace. Queries inside an HTTP request\n // (or an `observe()` wrapper) still nest under that span and are kept.\n const pgInstrumentation = new PgInstrumentation({\n enhancedDatabaseReporting: qdcEnhancedDbReporting(),\n requireParentSpan: true,\n })\n\n let sdk: NodeSDK\n try {\n sdk = new NodeSDK({\n resource: buildResource(),\n spanProcessors: [new ScrubSpanProcessor(new BatchSpanProcessor(new OTLPTraceExporter()))],\n metricReader: new PeriodicExportingMetricReader({ exporter: new OTLPMetricExporter() }),\n logRecordProcessor: new BatchLogRecordProcessor(new OTLPLogExporter()),\n instrumentations: [httpInstrumentation, undiciInstrumentation, pgInstrumentation, new PinoInstrumentation()],\n })\n } catch (err: unknown) {\n process.stderr.write(`[qdc-sdk] initialization failed: ${err}\\n`)\n process.exit(1)\n }\n\n try {\n sdk.start()\n } catch (err: unknown) {\n process.stderr.write(`[qdc-sdk] SDK start failed: ${err}\\n`)\n process.exit(1)\n }\n\n const gracefulShutdown = async (signal: string): Promise<void> => {\n process.stderr.write(`[qdc-sdk] ${signal} received, shutting down\\n`)\n try { await sdk.shutdown() } catch { /* ignore */ }\n process.exit(0)\n }\n process.on(\"SIGTERM\", () => void gracefulShutdown(\"SIGTERM\"))\n process.on(\"SIGINT\", () => void gracefulShutdown(\"SIGINT\"))\n process.on(\"uncaughtException\", async (err) => {\n process.stderr.write(`[qdc-sdk] fatal: ${formatFatal(err)}\\n`)\n try { await sdk.shutdown() } finally { process.exit(1) }\n })\n process.on(\"unhandledRejection\", async (reason) => {\n process.stderr.write(`[qdc-sdk] fatal: ${formatFatal(reason)}\\n`)\n try { await sdk.shutdown() } finally { process.exit(1) }\n })\n\n return sdk\n}\n","import { type Resource, resourceFromAttributes } from \"@opentelemetry/resources\"\nimport { hostname } from \"node:os\"\nimport { qdcAppId, qdcCustomerId, qdcEnv, qdcModule } from \"./env\"\nimport pkg from \"../../package.json\" with { type: \"json\" }\n\nconst SDK_VERSION = (pkg as { version: string }).version\n\n/**\n * Maps the QDC identity env vars to the OpenTelemetry resource attributes used\n * by the SDK's server-side observability. The NodeSDK carries this resource on\n * every span and log record (the latter via the in-process PinoInstrumentation),\n * so it is the single source of truth for tenant labels.\n *\n * Identity is read from NEXT_PUBLIC_QDC_* with a fallback to legacy QDC_* (see\n * ./env). Throws if the customer or app id are missing — required to land logs\n * and traces under the correct tenant namespace.\n */\nexport function buildResourceAttributes(): Record<string, string> {\n const customerId = qdcCustomerId()\n if (!customerId)\n throw new Error(\"NEXT_PUBLIC_QDC_CUSTOMER_ID (or legacy QDC_CUSTOMER_ID) env var is required\")\n\n const appId = qdcAppId()\n if (!appId)\n throw new Error(\"NEXT_PUBLIC_QDC_APP_ID (or legacy QDC_APP_ID) env var is required\")\n\n const env = qdcEnv()\n\n const attrs: Record<string, string> = {\n \"service.name\": appId,\n \"service.namespace\": customerId,\n \"deployment.environment\": env,\n \"host.name\": hostname(),\n \"qdc.customer_id\": customerId,\n \"qdc.app_id\": appId,\n \"qdc.sdk.version\": SDK_VERSION,\n }\n const mod = qdcModule()\n if (mod) attrs[\"qdc.module\"] = mod\n return attrs\n}\n\nexport function buildResource(): Resource {\n return resourceFromAttributes(buildResourceAttributes())\n}\n","{\n \"name\": \"@quatronic/sdk\",\n \"version\": \"0.3.1\",\n \"type\": \"module\",\n \"private\": false,\n \"publishConfig\": {\n \"registry\": \"https://registry.npmjs.org\",\n \"access\": \"public\"\n },\n \"files\": [\n \"dist\",\n \"semgrep\"\n ],\n \"bin\": {\n \"qdc-setup-env\": \"./dist/cli/setup-env.js\"\n },\n \"exports\": {\n \"./auth\": {\n \"types\": \"./dist/auth/index.d.ts\",\n \"import\": \"./dist/auth/index.js\"\n },\n \"./next/auth\": {\n \"types\": \"./dist/next/auth/index.d.ts\",\n \"import\": \"./dist/next/auth/index.js\"\n },\n \"./next/better-auth\": {\n \"types\": \"./dist/next/better-auth/index.d.ts\",\n \"import\": \"./dist/next/better-auth/index.js\"\n },\n \"./observability\": {\n \"types\": \"./dist/observability/index.d.ts\",\n \"import\": \"./dist/observability/index.js\"\n },\n \"./next/observability\": {\n \"types\": \"./dist/next/observability/index.d.ts\",\n \"import\": \"./dist/next/observability/index.js\"\n },\n \"./next/observability/register\": {\n \"types\": \"./dist/next/observability/register.d.ts\",\n \"import\": \"./dist/next/observability/register.js\"\n },\n \"./node/observability\": {\n \"types\": \"./dist/node/observability/index.d.ts\",\n \"import\": \"./dist/node/observability/index.js\"\n },\n \"./node/observability/register\": {\n \"types\": \"./dist/node/observability/register.d.ts\",\n \"import\": \"./dist/node/observability/register.js\"\n },\n \"./next/config\": {\n \"types\": \"./dist/next/config/index.d.ts\",\n \"import\": \"./dist/next/config/index.js\"\n },\n \"./next/security\": {\n \"types\": \"./dist/next/security/index.d.ts\",\n \"import\": \"./dist/next/security/index.js\"\n },\n \"./next/security/testing\": {\n \"types\": \"./dist/next/security/testing.d.ts\",\n \"import\": \"./dist/next/security/testing.js\"\n },\n \"./eslint\": {\n \"types\": \"./dist/eslint/index.d.ts\",\n \"import\": \"./dist/eslint/index.js\"\n },\n \"./next/connections\": {\n \"types\": \"./dist/next/connections/index.d.ts\",\n \"import\": \"./dist/next/connections/index.js\"\n },\n \"./node/connections\": {\n \"types\": \"./dist/node/connections/index.d.ts\",\n \"import\": \"./dist/node/connections/index.js\"\n },\n \"./node/net\": {\n \"types\": \"./dist/node/net/index.d.ts\",\n \"import\": \"./dist/node/net/index.js\"\n },\n \"./node/fspath\": {\n \"types\": \"./dist/node/fspath/index.d.ts\",\n \"import\": \"./dist/node/fspath/index.js\"\n },\n \"./node/parse\": {\n \"types\": \"./dist/node/parse/index.d.ts\",\n \"import\": \"./dist/node/parse/index.js\"\n },\n \"./node/identity\": {\n \"types\": \"./dist/node/identity/index.d.ts\",\n \"import\": \"./dist/node/identity/index.js\"\n },\n \"./node/db\": {\n \"types\": \"./dist/node/db/index.d.ts\",\n \"import\": \"./dist/node/db/index.js\"\n },\n \"./next/db\": {\n \"types\": \"./dist/next/db/index.d.ts\",\n \"import\": \"./dist/next/db/index.js\"\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"surface\": \"node scripts/api-surface.mjs\",\n \"surface:check\": \"node scripts/api-surface.mjs --check\",\n \"prepublishOnly\": \"pnpm build\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"tsc --noEmit && tsc -p tsconfig.test.json\",\n \"lint\": \"eslint src tests\",\n \"calibrate\": \"node scripts/calibrate.mjs\"\n },\n \"dependencies\": {\n \"@opentelemetry/api\": \"^1.9.1\",\n \"@opentelemetry/context-zone\": \"2.7.1\",\n \"@opentelemetry/exporter-logs-otlp-http\": \"^0.218.0\",\n \"@opentelemetry/exporter-metrics-otlp-http\": \"^0.218.0\",\n \"@opentelemetry/exporter-trace-otlp-http\": \"^0.218.0\",\n \"@opentelemetry/instrumentation\": \"^0.218.0\",\n \"@opentelemetry/instrumentation-document-load\": \"^0.63.0\",\n \"@opentelemetry/instrumentation-fetch\": \"^0.218.0\",\n \"@opentelemetry/instrumentation-http\": \"^0.218.0\",\n \"@opentelemetry/instrumentation-pg\": \"^0.71.0\",\n \"@opentelemetry/instrumentation-pino\": \"^0.64.0\",\n \"@opentelemetry/instrumentation-undici\": \"^0.28.0\",\n \"@opentelemetry/resources\": \"^2.7.1\",\n \"@opentelemetry/sdk-logs\": \"^0.218.0\",\n \"@opentelemetry/sdk-metrics\": \"^2.7.1\",\n \"@opentelemetry/sdk-node\": \"^0.218.0\",\n \"@opentelemetry/sdk-trace-base\": \"2.7.1\",\n \"@opentelemetry/sdk-trace-web\": \"2.7.1\",\n \"jose\": \"^5.9.6\",\n \"pino\": \"^10.3.1\"\n },\n \"peerDependencies\": {\n \"@better-auth/core\": \">=1.6\",\n \"better-auth\": \">=1.6\",\n \"drizzle-orm\": \">=0.36\",\n \"eslint\": \">=9\",\n \"next\": \">=15\",\n \"pg\": \">=8.13\",\n \"react\": \">=18\",\n \"react-dom\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"eslint\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"react-dom\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"drizzle-orm\": {\n \"optional\": true\n },\n \"pg\": {\n \"optional\": true\n },\n \"better-auth\": {\n \"optional\": true\n },\n \"@better-auth/core\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@better-auth/core\": \"^1.6.24\",\n \"@eslint/js\": \"^10.0.1\",\n \"@opentelemetry/instrumentation\": \"^0.218.0\",\n \"@opentelemetry/sdk-trace-base\": \"^2.7.0\",\n \"@testcontainers/postgresql\": \"^12.0.0\",\n \"@testing-library/react\": \"^16.1.0\",\n \"@types/node\": \"^22.10.2\",\n \"@types/pg\": \"^8.11.10\",\n \"@types/react\": \"^18.3.17\",\n \"@types/react-dom\": \"^18.3.5\",\n \"@vitest/coverage-v8\": \"^2.1.9\",\n \"better-auth\": \"^1.6.24\",\n \"drizzle-kit\": \"^0.30.1\",\n \"drizzle-orm\": \"^0.38.2\",\n \"eslint\": \"^10.5.0\",\n \"jsdom\": \"^25.0.1\",\n \"msw\": \"^2.7.0\",\n \"next\": \"^15.1.0\",\n \"pg\": \"^8.13.1\",\n \"react\": \"^18.3.1\",\n \"react-dom\": \"^18.3.1\",\n \"testcontainers\": \"^10.16.0\",\n \"tsup\": \"^8.3.5\",\n \"typescript\": \"^5.7.2\",\n \"typescript-eslint\": \"^8.61.1\",\n \"vitest\": \"^2.1.8\"\n }\n}\n","// Pure predicate deciding whether an HTTP request is infrastructural noise that\n// should never become a span. Framework-agnostic rules are built in: favicon,\n// source maps, OPTIONS, RSC navigations/prefetches (`?_rsc=` query + RSC headers),\n// and Next's `/_next/*` internals. Callers pass any additional environment-specific\n// prefixes (and an optional health path) via NoiseFilterOptions.\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. The meaningful auth flows keep\n// their labeled spans (Log in, Complete login, Log out, Refresh session);\n// dropping the inbound span here also drops its pg children (requireParentSpan).\nconst NOISE_EXACT = new Set([\"/favicon.ico\", \"/api/auth/me\"])\n\n// React Server Components navigations/prefetches/data-fetches. Next signals them\n// with a `?_rsc=` query param and/or an `RSC` / `Next-Router-Prefetch` request\n// header. They are real-looking routes, so a path-prefix filter misses them.\n// NOTE: `Next-Router-State-Tree` is intentionally NOT in this list — Next.js\n// sends it on server actions too (POST + Next-Action), not only on RSC navigations,\n// so it is not a safe RSC discriminator.\nconst RSC_QUERY_RE = /[?&]_rsc=/\nconst RSC_HEADERS = [\"rsc\", \"next-router-prefetch\"]\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\nexport function shouldIgnoreIncoming(\n req: { url?: string; method?: string; headers?: Record<string, unknown> },\n opts: NoiseFilterOptions = {},\n): boolean {\n if ((req.method ?? \"\").toUpperCase() === \"OPTIONS\") return true\n const headers = req.headers ?? {}\n // A Next.js server action is real work — never noise — even though it also\n // carries router headers. Exempt it explicitly so its inbound span (and the\n // DB child gated by pg requireParentSpan) is preserved.\n if (headers[\"next-action\"] != null) return false\n if (RSC_HEADERS.some((h) => headers[h] != null)) return true\n return isNoisePath(req.url ?? \"\", opts)\n}\n\nexport function shouldIgnoreOutgoing(\n req: { path?: string },\n opts: NoiseFilterOptions = {},\n): boolean {\n return isNoisePath(req.path ?? \"\", opts)\n}\n","// Pure HTTP-span PII sanitizer. No OTel SDK import so it is unit-testable in\n// isolation. register.ts wires sanitizeHttpSpanAttributes into the\n// HttpInstrumentation requestHook when QDC_OTEL_SANITIZE_HTTP is on.\n\nconst REDACTED = \"[redacted]\"\n\nexport type SemconvMode = \"legacy\" | \"stable\" | \"dup\"\n\n// instrumentation-http emits legacy attribute names by default and the stable\n// names (url.full/url.query/url.path) only when OTEL_SEMCONV_STABILITY_OPT_IN\n// selects \"http\" (stable only) or \"http/dup\" (both).\nexport function httpSemconvMode(\n optIn: string | undefined = process.env.OTEL_SEMCONV_STABILITY_OPT_IN,\n): SemconvMode {\n const tokens = (optIn ?? \"\").split(\",\").map((t) => t.trim().toLowerCase())\n if (tokens.includes(\"http/dup\")) return \"dup\"\n if (tokens.includes(\"http\")) return \"stable\"\n return \"legacy\"\n}\n\ninterface SpanLike {\n setAttribute(key: string, value: string): unknown\n}\n\ninterface RequestLike {\n url?: string // IncomingMessage (server spans): path + query\n path?: string // ClientRequest (outgoing spans): path + query\n}\n\nexport function sanitizeHttpSpanAttributes(\n span: SpanLike,\n request: RequestLike,\n mode: SemconvMode = httpSemconvMode(),\n): void {\n const raw = request.url ?? request.path ?? \"\"\n const queryStart = raw.indexOf(\"?\")\n const hasQuery = queryStart !== -1\n const path = hasQuery ? raw.slice(0, queryStart) : raw\n\n // Legacy semconv: redact http.url (once the query is gone it only duplicates\n // http.host + http.target); http.target keeps the path. Skip http.target when\n // we have no path info, so we don't clobber the instrumentation's \"/\" default.\n if (mode === \"legacy\" || mode === \"dup\") {\n if (path) span.setAttribute(\"http.target\", path)\n span.setAttribute(\"http.url\", REDACTED)\n }\n\n // Stable semconv: the query lives in url.full / url.query; url.path is already\n // query-less, so leave it intact. Only redact url.query when a query was\n // actually present — the instrumentation omits it otherwise, and writing it\n // unconditionally would falsely signal a redacted query on clean paths.\n if (mode === \"stable\" || mode === \"dup\") {\n span.setAttribute(\"url.full\", REDACTED)\n if (hasQuery) span.setAttribute(\"url.query\", REDACTED)\n }\n}\n","// Leaf-noise predicate + attribute redaction, pure so they unit-test without the\n// OTel SDK. Wired into export by scrub-span-processor.ts. Contract:\n// docs (QDC spec 2026-07-02): the SDK drops ONLY leaf spans — spans that never\n// have children — so parent/child chains can never break. Structural framework\n// spans (BaseServer.handleRequest, AppRender.fetch, undici) stay; the portal\n// folds those at render time.\n\nexport const REDACTED = \"●●●\"\n\n// next.span_type values that are pure leaves and never carry information a\n// developer needs: sub-millisecond router/renderer bookkeeping.\nconst NEXT_LEAF_NOISE = new Set([\n \"Middleware.execute\",\n \"NextNodeServer.findPageComponents\",\n \"NextNodeServer.startResponse\",\n])\n\n// pg connection-pool bookkeeping; the actual query span (pg.query:*) stays.\nconst NOISE_SPAN_NAMES = new Set([\"pg-pool.connect\", \"pg.connect\"])\n\nexport function isNoiseLeafSpan(name: string, attributes: Record<string, unknown>): boolean {\n const nextType = attributes[\"next.span_type\"]\n if (typeof nextType === \"string\" && NEXT_LEAF_NOISE.has(nextType)) return true\n return NOISE_SPAN_NAMES.has(name)\n}\n\nconst REDACT_KEYS = new Set([\"db.connection_string\", \"db.user\"])\nconst REDACT_PREFIXES = [\"net.peer.\", \"net.sock.\", \"net.host.\", \"network.peer.\", \"network.local.\"]\n\nexport function redactSpanAttributes(attributes: Record<string, unknown>): void {\n for (const key of Object.keys(attributes)) {\n if (REDACT_KEYS.has(key) || REDACT_PREFIXES.some((p) => key.startsWith(p))) {\n attributes[key] = REDACTED\n }\n }\n}\n","import type { Context } from \"@opentelemetry/api\"\nimport type { ReadableSpan, Span, SpanProcessor } from \"@opentelemetry/sdk-trace-base\"\nimport { isNoiseLeafSpan, redactSpanAttributes } from \"./span-scrub\"\n\n/** Wraps the export processor: drops leaf-noise spans and redacts sensitive\n * attributes on everything else. Runs in ALL envs — connection strings and\n * internal IPs never belong in the telemetry backend. */\nexport class ScrubSpanProcessor implements SpanProcessor {\n constructor(private readonly inner: SpanProcessor) {}\n\n onStart(span: Span, parentContext: Context): void {\n this.inner.onStart(span, parentContext)\n }\n\n onEnd(span: ReadableSpan): void {\n if (isNoiseLeafSpan(span.name, span.attributes as Record<string, unknown>)) return\n redactSpanAttributes(span.attributes as Record<string, unknown>)\n this.inner.onEnd(span)\n }\n\n forceFlush(): Promise<void> {\n return this.inner.forceFlush()\n }\n\n shutdown(): Promise<void> {\n return this.inner.shutdown()\n }\n}\n","// A crash that reaches the SDK's last-resort handlers is often the only thing an\n// operator ever sees about it: the process dies before any log exporter flushes,\n// so all that survives is this one stderr line in the platform's container log.\n// `${err}` would reduce it to \"Error: self-signed certificate\" — no stack, no\n// cause, no error code, i.e. no way to tell which of the app's boot steps threw.\nexport function formatFatal(err: unknown): string {\n if (!(err instanceof Error)) return String(err)\n\n let out = err.stack ?? `${err.name}: ${err.message}`\n\n const code = (err as { code?: unknown }).code\n if (typeof code === \"string\" || typeof code === \"number\") out += `\\n code: ${code}`\n\n // Fetch/undici and pg wrap the real failure in `cause`; without it a boot\n // crash reads as a generic \"TypeError: fetch failed\".\n let cause: unknown = (err as { cause?: unknown }).cause\n let depth = 0\n while (cause !== undefined && depth < 3) {\n const rendered = cause instanceof Error ? (cause.stack ?? `${cause.name}: ${cause.message}`) : String(cause)\n out += `\\n caused by: ${rendered}`\n cause = cause instanceof Error ? (cause as { cause?: unknown }).cause : undefined\n depth += 1\n }\n\n return out\n}\n"],"mappings":";;;;;;;;;;;;AAIA,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,qCAAqC;AAC9C,SAAS,+BAA+B;AACxC,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;;;ACdlC,SAAwB,8BAA8B;AACtD,SAAS,gBAAgB;;;ACDzB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,eAAiB;AAAA,IACf,UAAY;AAAA,IACZ,QAAU;AAAA,EACZ;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,iBAAiB;AAAA,EACnB;AAAA,EACA,SAAW;AAAA,IACT,UAAU;AAAA,MACR,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,eAAe;AAAA,MACb,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,sBAAsB;AAAA,MACpB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,M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