@warlock.js/devtools 5.56.0 → 5.57.0
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/CHANGELOG.md +23 -0
- package/cjs/{boot-BQi0Etor.cjs → boot-Dy5OqgTM.cjs} +4 -4
- package/cjs/{boot-BQi0Etor.cjs.map → boot-Dy5OqgTM.cjs.map} +1 -1
- package/cjs/{http-CabcUwBx.cjs → http-DCfXQvw-.cjs} +3 -3
- package/cjs/{http-CabcUwBx.cjs.map → http-DCfXQvw-.cjs.map} +1 -1
- package/cjs/index.cjs +2 -1
- package/cjs/{panels-B0dAfGbJ.cjs → panels-Rcmeitu3.cjs} +26 -6
- package/cjs/panels-Rcmeitu3.cjs.map +1 -0
- package/cjs/{server-B6xdeKS8.cjs → server-ykxsOwob.cjs} +3 -3
- package/cjs/{server-B6xdeKS8.cjs.map → server-ykxsOwob.cjs.map} +1 -1
- package/cjs/{src-Ce-3Lniv.cjs → src-UPtTCI2j.cjs} +53 -4
- package/cjs/src-UPtTCI2j.cjs.map +1 -0
- package/cjs/{stream-route-BGJa-zQu.cjs → stream-route-CJTABkUy.cjs} +2 -2
- package/cjs/{stream-route-BGJa-zQu.cjs.map → stream-route-CJTABkUy.cjs.map} +1 -1
- package/esm/index.d.mts +3 -2
- package/esm/index.mjs +2 -1
- package/esm/panel-tokens.d.mts +13 -0
- package/esm/panel-tokens.d.mts.map +1 -0
- package/esm/panel-tokens.mjs +45 -0
- package/esm/panel-tokens.mjs.map +1 -0
- package/esm/panels.mjs +25 -5
- package/esm/panels.mjs.map +1 -1
- package/esm/types.d.mts +6 -2
- package/esm/types.d.mts.map +1 -1
- package/llms-full.txt +7 -0
- package/package.json +8 -8
- package/skills/SKILL.md +7 -0
- package/ui/dashboard/assets/app.css +1 -1
- package/ui/dashboard/assets/app.js +4 -4
- package/ui/dashboard/build-info.json +10 -10
- package/ui/dashboard/index.html +1 -0
- package/ui/panels/processes.js +12 -3
- package/cjs/panels-B0dAfGbJ.cjs.map +0 -1
- package/cjs/src-Ce-3Lniv.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,29 @@ All notable changes to `@warlock.js/devtools` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 5.57.0 - 2026-11-18
|
|
8
|
+
|
|
9
|
+
### Upgrading
|
|
10
|
+
|
|
11
|
+
- The dashboard has a new palette and layout. A package panel whose stylesheet used CSS variables the dashboard never defined (anything outside `DEVTOOLS_PANEL_TOKENS`) should switch to the listed tokens; see "Styling a panel" in the docs.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- The `panels` option accepts `[specifier, options]` entries. The options object is passed to the panel factory next to `root` and `mode`, for example `panels: [["@warlock.js/grimoire/devtools", { ttlMs: 60_000 }]]`. An invalid entry is reported with what to change and skipped; the other panels still load.
|
|
16
|
+
- `DEVTOOLS_PANEL_TOKENS`: the CSS variables a package panel stylesheet may use. Every one is defined in the light and the dark theme, and a spec checks the definitions, their WCAG AA contrast and the built-in panel views.
|
|
17
|
+
- A command palette (Ctrl/Cmd+K, or the search button in the top bar) jumps to any tab, the account page or an admin page.
|
|
18
|
+
- A theme toggle (system, light, dark) in the top bar, saved in the browser.
|
|
19
|
+
- Package panels show a "Loading <title>…" state while their view loads, so a slow panel is never a blank area.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- The dashboard has a new look: a left sidebar with grouped, icon-labelled tabs (Monitor, Application, AI, Packages), a slim top bar, and a slide-over menu on narrow screens. Light and dark themes use a tinted palette with one brand colour, and every text colour meets WCAG AA contrast on both themes.
|
|
24
|
+
- Every built-in tab opens with a description and its actions, a row of summary figures, and a filter bar with result counts and a Clear filters action. Requests gains a status-class filter, Queries a Slow / N+1 / Errors filter, Errors a Source filter, and Logs a message search and a level control.
|
|
25
|
+
- Status codes, methods and log levels are colour-coded pills, durations show a bar sized against the rest of the list, table headers stay in view while scrolling, and rows open their detail with the keyboard as well as the mouse. Tables scroll inside their card on narrow screens.
|
|
26
|
+
- Detail views are split into titled sections with key/value grids and code blocks with copy buttons. The request detail has a Close button and a waterfall legend.
|
|
27
|
+
- Badges gain `success`, `warning`, `info`, `brand` and `neutral` tones, buttons gain `brand` and `soft`, and empty states show an icon and what to do next.
|
|
28
|
+
- Sign-in, account and admin screens use the new look.
|
|
29
|
+
|
|
7
30
|
## 5.56.0 - 2026-11-17
|
|
8
31
|
|
|
9
32
|
### Upgrading
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_panels = require("./panels-
|
|
1
|
+
const require_panels = require("./panels-Rcmeitu3.cjs");
|
|
2
2
|
const require_errors = require("./errors-CyZp5yS-.cjs");
|
|
3
3
|
const require_options = require("./options-CWqFC5__.cjs");
|
|
4
4
|
|
|
@@ -34,7 +34,7 @@ async function bootProductionDevtools(input) {
|
|
|
34
34
|
Promise.resolve().then(() => require("./auth-DzU0gHDG.cjs")),
|
|
35
35
|
Promise.resolve().then(() => require("./capture-CqIiaznN.cjs")),
|
|
36
36
|
Promise.resolve().then(() => require("./insights-BKtqxdnP.cjs")),
|
|
37
|
-
Promise.resolve().then(() => require("./http-
|
|
37
|
+
Promise.resolve().then(() => require("./http-DCfXQvw-.cjs"))
|
|
38
38
|
]);
|
|
39
39
|
const store = await createCascadeStore();
|
|
40
40
|
await store.verify();
|
|
@@ -96,7 +96,7 @@ async function bootProductionDevtools(input) {
|
|
|
96
96
|
const { builtIn, panels } = require_panels.productionPanels(input.panels, production.panels);
|
|
97
97
|
if (typeof core.excludeFromRequestLog === "function") stops.push(core.excludeFromRequestLog(production.path));
|
|
98
98
|
if (builtIn.includes("mail")) {
|
|
99
|
-
const { attachMailSource } = await Promise.resolve().then(() => require("./src-
|
|
99
|
+
const { attachMailSource } = await Promise.resolve().then(() => require("./src-UPtTCI2j.cjs")).then((n) => n.mail_source_exports);
|
|
100
100
|
stops.push(await attachMailSource(capture.collector));
|
|
101
101
|
}
|
|
102
102
|
httpModule.mountProductionDevtools(server, {
|
|
@@ -135,4 +135,4 @@ async function bootProductionDevtools(input) {
|
|
|
135
135
|
|
|
136
136
|
//#endregion
|
|
137
137
|
exports.bootProductionDevtools = bootProductionDevtools;
|
|
138
|
-
//# sourceMappingURL=boot-
|
|
138
|
+
//# sourceMappingURL=boot-Dy5OqgTM.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot-
|
|
1
|
+
{"version":3,"file":"boot-Dy5OqgTM.cjs","names":["resolveProductionOptions","DevtoolsProductionConfigError","productionPanels"],"sources":["../../../../../../../packages/devtools/src/production/boot.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { type MountedDevtoolsPanel, productionPanels } from \"../panels\";\nimport type { MountDevtoolsRoutesDeps } from \"../server/types\";\nimport type { DevtoolsDisposer, ResolvedDevtoolsOptions } from \"../types\";\nimport { DevtoolsProductionConfigError } from \"./errors\";\nimport { resolveProductionOptions } from \"./options\";\n\n/** What the connector hands production boot. */\nexport type BootProductionDevtoolsInput = {\n options: ResolvedDevtoolsOptions;\n env: Readonly<Record<string, string | undefined>>;\n server: FastifyInstance;\n /** Package panels loaded with `mode: \"production\"` (not yet filtered). */\n panels: readonly MountedDevtoolsPanel[];\n /** The route deps the connector builds for development, reused (requestLog, listRoutes, ai, …). */\n routes: Omit<MountDevtoolsRoutesDeps, \"collector\" | \"options\" | \"isDevelopment\">;\n /** Reads one config value (`encryption.key`); defaults to core's `config.get`. */\n readConfig?: (key: string) => unknown;\n log: {\n info(module: string, action: string, message: string): unknown;\n warn(module: string, action: string, message: string): unknown;\n error(module: string, action: string, message: string): unknown;\n };\n};\n\n/** `/ops-…`: the first part of the path, enough to recognise it and not enough to use it. */\nexport function maskDashboardPath(path: string): string {\n const match = /^\\/[A-Za-z]{1,8}-/.exec(path);\n\n return `${match ? match[0] : \"/\"}…`;\n}\n\n/** The key core encrypts with: 64 hex characters. */\nfunction hasEncryptionKey(value: unknown): boolean {\n return typeof value === \"string\" && /^[0-9a-fA-F]{64}$/.test(value);\n}\n\n/**\n * Starts the production monitor, in this order: resolve options (env) →\n * check `encryption.key` (DT006) → cascade store (DT005) → `store.verify()`\n * (DT008) → `ensureFirstAdmin()` (DT003/DT004) → instance info → capture\n * (attach hooks) → resource monitor, health history, jobs reader → local\n * reporter → report writer → shared insights → `excludeFromRequestLog(path)`\n * → mount. Logs one line with the path masked (`/ops-…`), never the full path.\n * Any `DevtoolsProductionConfigError` propagates: the app does not boot.\n *\n * Returns the disposer the connector calls at shutdown (flush samples, stop\n * timers, detach hooks).\n */\nexport async function bootProductionDevtools(\n input: BootProductionDevtoolsInput,\n): Promise<DevtoolsDisposer> {\n const { options, env, server, log } = input;\n const production = resolveProductionOptions(options.production, env);\n const core = await import(\"@warlock.js/core\");\n const readConfig = input.readConfig ?? ((key: string) => core.config.get(key));\n\n if (!hasEncryptionKey(readConfig(\"encryption.key\"))) {\n throw new DevtoolsProductionConfigError(\"DT006\");\n }\n\n const [{ createCascadeStore }, authModule, captureModule, insightsModule, httpModule] =\n await Promise.all([\n import(\"./store\"),\n import(\"./auth\"),\n import(\"./capture\"),\n import(\"./insights\"),\n import(\"./http\"),\n ]);\n\n const store = await createCascadeStore();\n\n await store.verify();\n\n const warn = (message: string): void => {\n log.warn(\"devtools\", \"production\", message);\n };\n const instance = insightsModule.createInstanceInfo();\n const [crypto, passkeys] = await Promise.all([\n authModule.defaultDevtoolsCrypto(),\n authModule.loadDevtoolsPasskeys(),\n ]);\n const auth = authModule.createDevtoolsAuth({\n store,\n options: production,\n instance,\n crypto,\n passkeys,\n warn,\n });\n\n await auth.ensureFirstAdmin();\n\n const isDashboardPath = (path: string): boolean =>\n path === production.path || path.startsWith(`${production.path}/`);\n const capture = captureModule.createProductionCapture({\n options,\n production,\n instance,\n store,\n isDashboardPath,\n warn,\n });\n const stops: (() => unknown)[] = [];\n\n try {\n stops.push(await capture.attach());\n\n const resources = insightsModule.createResourceMonitor();\n const health = insightsModule.createHealthHistory();\n\n resources.start();\n health.start();\n stops.push(\n () => resources.stop(),\n () => health.stop(),\n );\n\n const reporter = insightsModule.createLocalReporter({\n instance,\n resources,\n health,\n jobs: insightsModule.createJobsReader(),\n queries: capture.queries,\n routes: capture.routes,\n errors: capture.errors,\n logs: capture.logs,\n counters: () => capture.counters(),\n });\n const writer = insightsModule.startReportWriter({ reporter, store, production, warn });\n\n stops.push(() => writer.stop());\n\n const insights = insightsModule.createSharedInsights({\n store,\n reporter,\n sampleRate: production.sampleRate,\n });\n const state = httpModule.createDashboardState(store, production.path);\n const { builtIn, panels } = productionPanels(input.panels, production.panels);\n\n // The dashboard's own requests are not worth a line in the request log, and its sign-in bodies must not reach it.\n if (typeof core.excludeFromRequestLog === \"function\") {\n stops.push(core.excludeFromRequestLog(production.path));\n }\n\n // Mail previews exist only when the project turned that tab on.\n if (builtIn.includes(\"mail\")) {\n const { attachMailSource } = await import(\"../sources/mail-source\");\n\n stops.push(await attachMailSource(capture.collector));\n }\n\n httpModule.mountProductionDevtools(server, {\n routes: {\n ...input.routes,\n collector: capture.collector,\n options,\n isDevelopment: () => false,\n },\n production,\n store,\n auth,\n capture,\n insights,\n instance,\n panels,\n builtInPanels: builtIn,\n state,\n warn,\n });\n\n log.info(\n \"devtools\",\n \"ready\",\n `devtools production monitor mounted at ${maskDashboardPath(production.path)} (DEVTOOLS_PATH)`,\n );\n } catch (error) {\n for (const stop of stops.splice(0).reverse()) {\n try {\n void Promise.resolve(stop()).catch(() => undefined);\n } catch {\n // Cleanup after a failed boot must not hide the real error.\n }\n }\n\n void capture.dispose().catch(() => undefined);\n\n throw error;\n }\n\n return () => {\n for (const stop of stops.splice(0).reverse()) {\n try {\n void Promise.resolve(stop()).catch(() => undefined);\n } catch {\n // Shutdown continues past a failing step.\n }\n }\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AK,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC,YAAY,MAAS;EACpD,QAAQ,CAER;EAGF,AAAK,QAAQ,QAAQ,CAAC,CAAC,YAAY,MAAS;EAE5C,MAAM;CACR;CAEA,aAAa;EACX,KAAK,MAAM,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,QAAQ,GACzC,IAAI;GACF,AAAK,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC,YAAY,MAAS;EACpD,QAAQ,CAER;EAGF,AAAK,QAAQ,QAAQ,CAAC,CAAC,YAAY,MAAS;CAC9C;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_panels = require("./panels-
|
|
1
|
+
const require_panels = require("./panels-Rcmeitu3.cjs");
|
|
2
2
|
const require_errors = require("./errors-CyZp5yS-.cjs");
|
|
3
3
|
const require_ip = require("./ip-DbNhPOzi.cjs");
|
|
4
|
-
const require_stream_route = require("./stream-route-
|
|
4
|
+
const require_stream_route = require("./stream-route-CJTABkUy.cjs");
|
|
5
5
|
let node_crypto = require("node:crypto");
|
|
6
6
|
let node_net = require("node:net");
|
|
7
7
|
|
|
@@ -867,4 +867,4 @@ exports.mountProductionDevtools = mountProductionDevtools;
|
|
|
867
867
|
exports.productionRouteAccess = productionRouteAccess;
|
|
868
868
|
exports.resolveClient = resolveClient;
|
|
869
869
|
exports.sessionCookie = sessionCookie;
|
|
870
|
-
//# sourceMappingURL=http-
|
|
870
|
+
//# sourceMappingURL=http-DCfXQvw-.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-CabcUwBx.cjs","names":["normalizeIp","isIP","ipMatches","DevtoolsApiError","createHash","DevtoolsApiError","ipMatches","createErrorRef","DEVTOOLS_ERROR_MESSAGES","listPanelInfos","createHash"],"sources":["../../../../../../../packages/devtools/src/production/http/access.ts","../../../../../../../packages/devtools/src/production/http/client.ts","../../../../../../../packages/devtools/src/production/http/constants.ts","../../../../../../../packages/devtools/src/production/http/context.ts","../../../../../../../packages/devtools/src/production/http/cookie.ts","../../../../../../../packages/devtools/src/production/http/auth-routes.ts","../../../../../../../packages/devtools/src/production/http/headers.ts","../../../../../../../packages/devtools/src/production/http/mount.ts","../../../../../../../packages/devtools/src/production/http/state.ts"],"sourcesContent":["import type { DevtoolsRouteAccess, DevtoolsRouteAccessRule } from \"./types\";\n\ntype Method = DevtoolsRouteAccessRule[\"method\"];\n\nconst PUBLIC: DevtoolsRouteAccess = { type: \"public\" };\nconst VIEWER: DevtoolsRouteAccess = { type: \"viewer\" };\nconst ADMIN: DevtoolsRouteAccess = { type: \"admin\" };\n\nconst pending = (...stages: Extract<DevtoolsRouteAccess, { type: \"pending\" }>[\"stages\"]) =>\n ({ type: \"pending\", stages }) satisfies DevtoolsRouteAccess;\n\nconst ALL_STEPS = [\"password-change\", \"mfa-enrol\", \"mfa-verify\"] as const;\n\n/**\n * The access table: every production route, its method and who may call it.\n * A route with no entry is `admin` (fail closed). A package panel `<id>`\n * gets `GET /api/<id>` and `GET /api/<id>/*` for viewers and every other\n * method there for admins, audited as `panel.action`; a url ending in `/*`\n * matches every pattern below it.\n */\nexport function productionRouteAccess(panelIds: readonly string[]): DevtoolsRouteAccessRule[] {\n const rule = (\n method: Method,\n url: string,\n access: DevtoolsRouteAccess,\n audit?: DevtoolsRouteAccessRule[\"audit\"],\n ): DevtoolsRouteAccessRule => ({ method, url, access, ...(audit ? { audit } : {}) });\n\n const rules: DevtoolsRouteAccessRule[] = [\n // The shell and its sign-in steps.\n rule(\"GET\", \"/\", PUBLIC),\n rule(\"GET\", \"/assets/:name\", PUBLIC),\n rule(\"GET\", \"/api/auth/session\", PUBLIC),\n rule(\"POST\", \"/api/auth/login\", PUBLIC),\n rule(\"POST\", \"/api/auth/setup\", PUBLIC),\n rule(\"POST\", \"/api/auth/invite/inspect\", PUBLIC),\n rule(\"POST\", \"/api/auth/invite/accept\", PUBLIC),\n rule(\"POST\", \"/api/auth/password\", pending(\"password-change\")),\n rule(\"POST\", \"/api/auth/totp/start\", pending(\"mfa-enrol\")),\n rule(\"POST\", \"/api/auth/totp/confirm\", pending(\"mfa-enrol\")),\n rule(\"POST\", \"/api/auth/passkey/options\", pending(\"mfa-enrol\", \"mfa-verify\")),\n rule(\"POST\", \"/api/auth/passkey/verify\", pending(\"mfa-enrol\", \"mfa-verify\")),\n rule(\"POST\", \"/api/auth/mfa\", pending(\"mfa-verify\")),\n rule(\"POST\", \"/api/auth/logout\", pending(...ALL_STEPS)),\n\n // The signed-in account.\n rule(\"GET\", \"/api/panels\", VIEWER),\n rule(\"GET\", \"/api/account\", VIEWER),\n rule(\"GET\", \"/api/account/sessions\", VIEWER),\n rule(\"DELETE\", \"/api/account/sessions/:id\", VIEWER),\n rule(\"POST\", \"/api/account/password\", VIEWER),\n rule(\"POST\", \"/api/account/totp/start\", VIEWER),\n rule(\"POST\", \"/api/account/totp/confirm\", VIEWER),\n rule(\"DELETE\", \"/api/account/totp\", VIEWER),\n rule(\"POST\", \"/api/account/recovery-codes\", VIEWER),\n rule(\"POST\", \"/api/account/passkey/options\", VIEWER),\n rule(\"POST\", \"/api/account/passkey/verify\", VIEWER),\n rule(\"DELETE\", \"/api/account/passkeys/:id\", VIEWER),\n\n // Administration.\n rule(\"GET\", \"/api/admin/users\", ADMIN),\n rule(\"POST\", \"/api/admin/invites\", ADMIN),\n rule(\"DELETE\", \"/api/admin/invites/:id\", ADMIN),\n rule(\"PATCH\", \"/api/admin/users/:id\", ADMIN),\n rule(\"DELETE\", \"/api/admin/users/:id\", ADMIN),\n rule(\"POST\", \"/api/admin/users/:id/reset-mfa\", ADMIN),\n rule(\"POST\", \"/api/admin/users/:id/sign-out\", ADMIN),\n rule(\"GET\", \"/api/admin/audit\", ADMIN),\n rule(\"POST\", \"/api/admin/disable\", ADMIN),\n\n // Data.\n rule(\"GET\", \"/api/stream\", VIEWER),\n rule(\"GET\", \"/api/instances\", VIEWER),\n rule(\"GET\", \"/api/resources\", VIEWER),\n rule(\"GET\", \"/api/queries/stats\", VIEWER),\n rule(\"GET\", \"/api/routes/stats\", VIEWER),\n rule(\"GET\", \"/api/health\", VIEWER),\n rule(\"GET\", \"/api/errors\", VIEWER),\n rule(\"GET\", \"/api/jobs\", VIEWER),\n rule(\"GET\", \"/api/logs\", VIEWER),\n rule(\"GET\", \"/api/requests\", VIEWER),\n rule(\"GET\", \"/api/requests/:id\", VIEWER),\n rule(\"GET\", \"/api/requests/:id/curl\", VIEWER),\n rule(\"DELETE\", \"/api/requests\", ADMIN, \"requests.cleared\"),\n rule(\"POST\", \"/api/queries/:shapeId/explain\", ADMIN, \"explain.run\"),\n rule(\"GET\", \"/api/routes\", VIEWER),\n rule(\"GET\", \"/panels/:id/:name\", VIEWER),\n\n // Tabs that are off unless the project turns them on.\n rule(\"GET\", \"/api/mails\", VIEWER),\n rule(\"GET\", \"/api/mails/:id\", VIEWER),\n rule(\"GET\", \"/api/mails/:id/html\", VIEWER),\n rule(\"GET\", \"/api/ai\", VIEWER),\n rule(\"GET\", \"/api/ai/agent-runs\", VIEWER),\n rule(\"GET\", \"/api/ai/agent-runs/:id\", VIEWER),\n rule(\"GET\", \"/api/ai/runs/:id\", VIEWER),\n rule(\"GET\", \"/api/openapi.json\", VIEWER),\n rule(\"GET\", \"/api/postman.json\", VIEWER),\n rule(\"GET\", \"/docs\", VIEWER),\n rule(\"GET\", \"/docs/swagger\", VIEWER),\n ];\n\n for (const id of panelIds) {\n rules.push(rule(\"GET\", `/api/${id}`, VIEWER), rule(\"GET\", `/api/${id}/*`, VIEWER));\n\n for (const method of [\"POST\", \"PUT\", \"PATCH\", \"DELETE\"] as const) {\n rules.push(\n rule(method, `/api/${id}`, ADMIN, \"panel.action\"),\n rule(method, `/api/${id}/*`, ADMIN, \"panel.action\"),\n );\n }\n }\n\n return rules;\n}\n\n/** Looks routes up by method and URL pattern: exact first, then the longest `/*` prefix. */\nexport function createAccessLookup(\n rules: readonly DevtoolsRouteAccessRule[],\n): (method: string, pattern: string) => DevtoolsRouteAccessRule | undefined {\n const exact = new Map<string, DevtoolsRouteAccessRule>();\n const wildcards: { method: Method; prefix: string; rule: DevtoolsRouteAccessRule }[] = [];\n\n for (const rule of rules) {\n if (rule.url.endsWith(\"/*\")) {\n wildcards.push({ method: rule.method, prefix: rule.url.slice(0, -1), rule });\n } else {\n exact.set(`${rule.method} ${rule.url}`, rule);\n }\n }\n\n wildcards.sort((a, b) => b.prefix.length - a.prefix.length);\n\n return (method, pattern) => {\n // A HEAD request is answered by the GET route.\n const verb = method === \"HEAD\" ? \"GET\" : method;\n const found = exact.get(`${verb} ${pattern}`);\n\n if (found) return found;\n\n return wildcards.find((item) => item.method === verb && pattern.startsWith(item.prefix))?.rule;\n };\n}\n","import { isIP } from \"node:net\";\nimport type { DevtoolsClientInfo, DevtoolsProxyRequest } from \"./types\";\nimport { ipMatches, normalizeIp } from \"./ip\";\n\n/** The first value of a header that may repeat or hold a comma list. */\nfunction firstValue(value: string | string[] | undefined): string | undefined {\n const text = Array.isArray(value) ? value[0] : value;\n const first = text?.split(\",\")[0]?.trim();\n\n return first === undefined || first === \"\" ? undefined : first;\n}\n\n/** The host name of a `Host` value: no port, lower case, brackets of an IPv6 literal kept. */\nfunction hostnameOf(host: string): string {\n const value = host.trim().toLowerCase();\n\n if (value.startsWith(\"[\")) {\n const end = value.indexOf(\"]\");\n\n return end === -1 ? value : value.slice(0, end + 1);\n }\n\n const colon = value.indexOf(\":\");\n\n return colon === -1 ? value : value.slice(0, colon);\n}\n\n/** The client address out of an `X-Forwarded-For` value, walking right to left past trusted hops. */\nfunction forwardedClient(\n header: string | string[] | undefined,\n trusted: readonly string[],\n): string | undefined {\n const text = Array.isArray(header) ? header.join(\",\") : header;\n const hops = (text ?? \"\")\n .split(\",\")\n .map((hop) => normalizeIp(hop.trim().replace(/^\\[|\\]$/g, \"\")))\n .filter((hop) => isIP(hop) !== 0);\n\n for (let index = hops.length - 1; index >= 0; index -= 1) {\n const hop = hops[index];\n\n if (hop !== undefined && !ipMatches(hop, trusted)) return hop;\n }\n\n // Every hop is a trusted proxy: the leftmost is the origin of the chain.\n return hops[0];\n}\n\n/**\n * The client IP, protocol and host. Forwarding headers are read only when the\n * socket peer is a trusted proxy; `X-Forwarded-For` is walked right to left,\n * skipping trusted addresses, and the first untrusted one is the client.\n */\nexport function resolveClient(\n request: DevtoolsProxyRequest,\n trustedProxies: readonly string[],\n): DevtoolsClientInfo {\n const peer = normalizeIp(request.socket.remoteAddress ?? \"\");\n const headers = request.headers;\n let ip = peer;\n let proto = request.socket.encrypted === true ? \"https\" : \"http\";\n let host = firstValue(headers.host) ?? \"\";\n\n if (peer !== \"\" && ipMatches(peer, trustedProxies)) {\n ip = forwardedClient(headers[\"x-forwarded-for\"], trustedProxies) ?? peer;\n\n const forwardedProto = firstValue(headers[\"x-forwarded-proto\"])?.toLowerCase();\n\n if (forwardedProto === \"http\" || forwardedProto === \"https\") proto = forwardedProto;\n\n host = firstValue(headers[\"x-forwarded-host\"]) ?? host;\n }\n\n host = host.toLowerCase();\n\n return { ip, proto, hostname: hostnameOf(host), host };\n}\n","/** The header the dashboard sends the CSRF token in. */\nexport const DEVTOOLS_CSRF_HEADER = \"x-devtools-csrf\";\n\n/** The session cookie name over HTTPS (`__Secure-` makes browsers refuse it over plain HTTP). */\nexport const DEVTOOLS_SESSION_COOKIE = \"__Secure-warlock-devtools\";\n\n/** The session cookie name when `requireHttps` is off (local trials only). */\nexport const DEVTOOLS_SESSION_COOKIE_INSECURE = \"warlock-devtools\";\n","import type { FastifyRequest } from \"fastify\";\nimport type { DevtoolsAuthenticated, DevtoolsRequestMeta } from \"../auth/types\";\nimport type { DevtoolsClientInfo, DevtoolsRouteAccessRule } from \"./types\";\n\n/** What the gate learned about a dashboard request, for the handlers that follow. */\nexport type DevtoolsRequestContext = {\n client: DevtoolsClientInfo;\n meta: DevtoolsRequestMeta;\n /** The access rule the route matched; `undefined` for a route with no entry (treated as admin). */\n rule: DevtoolsRouteAccessRule | undefined;\n /** The route pattern relative to the dashboard path (`/api/requests/:id`). */\n pattern: string;\n /** The session, for every route that is not public. */\n authenticated: DevtoolsAuthenticated | null;\n};\n\nconst contexts = new WeakMap<FastifyRequest, DevtoolsRequestContext>();\n\n/** Stores the context of `request` (the gate calls this). */\nexport function setDevtoolsRequestContext(\n request: FastifyRequest,\n context: DevtoolsRequestContext,\n): void {\n contexts.set(request, context);\n}\n\n/** The context the gate stored for `request`, or `undefined` outside the production dashboard. */\nexport function devtoolsRequestContext(\n request: FastifyRequest,\n): DevtoolsRequestContext | undefined {\n return contexts.get(request);\n}\n","import { DEVTOOLS_SESSION_COOKIE, DEVTOOLS_SESSION_COOKIE_INSECURE } from \"./constants\";\n\n/** The cookie name for the HTTPS mode. */\nexport function sessionCookieName(secure: boolean): string {\n return secure ? DEVTOOLS_SESSION_COOKIE : DEVTOOLS_SESSION_COOKIE_INSECURE;\n}\n\n/**\n * `Set-Cookie` value for a session token (or a clearing cookie when `token`\n * is `null`). The cookie is a browser-session cookie scoped to the dashboard\n * path, `HttpOnly` and `SameSite=Strict`, with no `Domain`.\n */\nexport function sessionCookie(\n token: string | null,\n options: { path: string; secure: boolean },\n): string {\n const parts = [\n `${sessionCookieName(options.secure)}=${token ?? \"\"}`,\n `Path=${options.path}`,\n \"HttpOnly\",\n \"SameSite=Strict\",\n ];\n\n if (options.secure) parts.push(\"Secure\");\n\n if (token === null) parts.push(\"Max-Age=0\", \"Expires=Thu, 01 Jan 1970 00:00:00 GMT\");\n\n return parts.join(\"; \");\n}\n\n/** The value of cookie `name` in a `Cookie` header, or `undefined`. */\nexport function readCookie(header: string | undefined, name: string): string | undefined {\n if (!header) return undefined;\n\n for (const pair of header.split(\";\")) {\n const equals = pair.indexOf(\"=\");\n\n if (equals === -1) continue;\n\n if (pair.slice(0, equals).trim() === name) {\n const value = pair.slice(equals + 1).trim();\n\n return value === \"\" ? undefined : value;\n }\n }\n\n return undefined;\n}\n","import type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport type { DevtoolsAuthenticated, DevtoolsAuthStep, DevtoolsRequestMeta } from \"../auth/types\";\nimport type { DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsRole } from \"../contracts\";\nimport { DevtoolsApiError } from \"../errors\";\nimport { readCookie, sessionCookie, sessionCookieName } from \"./cookie\";\nimport { devtoolsRequestContext } from \"./context\";\nimport type { MountProductionDevtoolsDeps } from \"./types\";\n\nconst MAX_TEXT = 1024;\nconst MAX_EMAIL = 320;\nconst MAX_CODE = 128;\nconst MAX_TOKEN = 512;\nconst ROLES: readonly DevtoolsRole[] = [\"admin\", \"viewer\"];\n\n/** A request body that is a plain JSON object, or `input.invalid`. */\nfunction bodyOf(request: FastifyRequest): Record<string, unknown> {\n const body: unknown = request.body;\n\n if (body === null || typeof body !== \"object\" || Array.isArray(body)) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return body as Record<string, unknown>;\n}\n\n/** A non-empty string field no longer than `max`, or `input.invalid`. */\nfunction text(body: Record<string, unknown>, key: string, max = MAX_TEXT): string {\n const value = body[key];\n\n if (typeof value !== \"string\" || value === \"\" || value.length > max) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return value;\n}\n\n/** An optional string field; `undefined` when absent, `input.invalid` when present but wrong. */\nfunction optionalText(\n body: Record<string, unknown>,\n key: string,\n max = MAX_TEXT,\n): string | undefined {\n return body[key] === undefined ? undefined : text(body, key, max);\n}\n\nfunction email(body: Record<string, unknown>): string {\n const value = text(body, \"email\", MAX_EMAIL).trim().toLowerCase();\n\n if (!/^[^\\s@]+@[^\\s@]+$/.test(value)) throw new DevtoolsApiError(\"input.invalid\");\n\n return value;\n}\n\nfunction role(body: Record<string, unknown>): DevtoolsRole {\n const value = body.role;\n\n if (typeof value !== \"string\" || !ROLES.includes(value as DevtoolsRole)) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return value as DevtoolsRole;\n}\n\nfunction purpose(body: Record<string, unknown>): \"register\" | \"login\" {\n const value = body.purpose;\n\n if (value !== \"register\" && value !== \"login\") throw new DevtoolsApiError(\"input.invalid\");\n\n return value;\n}\n\nfunction idParam(request: FastifyRequest): string {\n const { id } = (request.params ?? {}) as { id?: unknown };\n\n if (typeof id !== \"string\" || id === \"\" || id.length > MAX_CODE) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return id;\n}\n\n/** The `current` password of a request that may have no body (a DELETE). */\nfunction currentOf(request: FastifyRequest): string | undefined {\n return request.body === undefined || request.body === null\n ? undefined\n : optionalText(bodyOf(request), \"current\");\n}\n\n/** What the gate stored, for a route that is never reached without it. */\nfunction contextOf(request: FastifyRequest): {\n meta: DevtoolsRequestMeta;\n auth: DevtoolsAuthenticated;\n} {\n const context = devtoolsRequestContext(request);\n\n if (!context?.authenticated) throw new Error(\"A dashboard route ran without its session.\");\n\n return { meta: context.meta, auth: context.authenticated };\n}\n\nfunction metaOf(request: FastifyRequest): DevtoolsRequestMeta {\n const context = devtoolsRequestContext(request);\n\n if (!context) throw new Error(\"A dashboard route ran without its request context.\");\n\n return context.meta;\n}\n\n/**\n * Registers the sign-in, account and admin routes. All decisions live in the\n * auth service; the handlers read the body, call it and answer. The gate\n * (`mountProductionDevtools`) has already checked the session, role, origin\n * and CSRF token by the time a handler runs.\n */\nexport function registerAuthRoutes(\n server: FastifyInstance,\n deps: MountProductionDevtoolsDeps,\n): void {\n const { auth, store, state, production } = deps;\n const cookieOptions = { path: production.path, secure: production.requireHttps };\n\n /** Sets the new session cookie when the step minted one; answers the step. */\n const answerStep = (\n reply: FastifyReply,\n step: DevtoolsAuthStep,\n recoveryCodes?: string[] | null,\n ): DevtoolsAuthStepResult & { recoveryCodes?: string[] } => {\n if (step.token !== null) reply.header(\"set-cookie\", sessionCookie(step.token, cookieOptions));\n\n return {\n stage: step.stage,\n csrf: step.csrf,\n ...(recoveryCodes ? { recoveryCodes } : {}),\n };\n };\n\n /** The stage and CSRF token of the session in force, for answers that do not change it. */\n const currentStep = (authenticated: DevtoolsAuthenticated): DevtoolsAuthStepResult => ({\n stage: authenticated.stage,\n csrf: auth.csrfToken(authenticated.session),\n });\n\n const clearCookie = (reply: FastifyReply): void => {\n reply.header(\"set-cookie\", sessionCookie(null, cookieOptions));\n };\n\n const requireAdmin = (authenticated: DevtoolsAuthenticated): void => {\n if (authenticated.account.role !== \"admin\" || authenticated.stage !== \"active\") {\n throw new DevtoolsApiError(\"role.forbidden\");\n }\n };\n\n // ---- Public ------------------------------------------------------------\n\n server.get(\"/api/auth/session\", async (request, reply) => {\n const token = readCookie(request.headers.cookie, sessionCookieName(production.requireHttps));\n const authenticated = token === undefined ? null : await auth.authenticate(token);\n\n // A cookie that no longer matches a session is dead weight: clear it.\n if (token !== undefined && authenticated === null) clearCookie(reply);\n\n return auth.sessionView(authenticated);\n });\n\n server.post(\"/api/auth/login\", async (request, reply) => {\n const body = bodyOf(request);\n const step = await auth.login(\n { email: email(body), password: text(body, \"password\") },\n metaOf(request),\n );\n\n return answerStep(reply, step);\n });\n\n server.post(\"/api/auth/setup\", async (request, reply) => {\n const body = bodyOf(request);\n const step = await auth.setup(\n { token: text(body, \"token\", MAX_TOKEN), password: text(body, \"password\") },\n metaOf(request),\n );\n\n return answerStep(reply, step);\n });\n\n server.post(\"/api/auth/invite/inspect\", async (request) => {\n const body = bodyOf(request);\n\n return auth.inspectInvite(text(body, \"token\", MAX_TOKEN));\n });\n\n server.post(\"/api/auth/invite/accept\", async (request, reply) => {\n const body = bodyOf(request);\n const step = await auth.acceptInvite(\n { token: text(body, \"token\", MAX_TOKEN), password: text(body, \"password\") },\n metaOf(request),\n );\n\n return answerStep(reply, step);\n });\n\n // ---- Sign-in steps and the account (a session is required) --------------\n\n const changePassword = async (request: FastifyRequest, reply: FastifyReply) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n const current = optionalText(body, \"current\");\n const step = await auth.changePassword(\n authenticated,\n { ...(current === undefined ? {} : { current }), password: text(body, \"password\") },\n meta,\n );\n\n return answerStep(reply, step);\n };\n\n const startTotp = async (request: FastifyRequest) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n return auth.startTotp(authenticated, meta);\n };\n\n const confirmTotp = async (request: FastifyRequest, reply: FastifyReply) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n const result = await auth.confirmTotp(\n authenticated,\n text(body, \"code\", MAX_CODE),\n meta,\n optionalText(body, \"current\"),\n );\n\n return answerStep(reply, result.step, result.recoveryCodes);\n };\n\n const passkeyOptions = async (request: FastifyRequest) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n return auth.passkeyOptions(authenticated, purpose(bodyOf(request)), meta);\n };\n\n const passkeyVerify = async (request: FastifyRequest, reply: FastifyReply) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n\n if (body.response === null || typeof body.response !== \"object\") {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n const result = await auth.verifyPasskey(\n authenticated,\n purpose(body),\n body.response,\n meta,\n optionalText(body, \"current\"),\n );\n\n if (result.step === null) {\n return {\n ...currentStep(authenticated),\n ...(result.recoveryCodes ? { recoveryCodes: result.recoveryCodes } : {}),\n };\n }\n\n return answerStep(reply, result.step, result.recoveryCodes);\n };\n\n server.post(\"/api/auth/password\", changePassword);\n server.post(\"/api/auth/totp/start\", startTotp);\n server.post(\"/api/auth/totp/confirm\", confirmTotp);\n server.post(\"/api/auth/passkey/options\", passkeyOptions);\n server.post(\"/api/auth/passkey/verify\", passkeyVerify);\n\n server.post(\"/api/auth/mfa\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n const code = optionalText(body, \"code\", MAX_CODE);\n const recoveryCode = optionalText(body, \"recoveryCode\", MAX_CODE);\n\n if ((code === undefined) === (recoveryCode === undefined)) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n const step = await auth.verifySecondFactor(\n authenticated,\n code === undefined ? { recoveryCode: recoveryCode as string } : { code },\n meta,\n );\n\n return answerStep(reply, step);\n });\n\n server.post(\"/api/auth/logout\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.logout(authenticated, meta);\n clearCookie(reply);\n\n return reply.code(204).send();\n });\n\n server.get(\"/api/account\", async (request) => {\n const { auth: authenticated } = contextOf(request);\n\n return auth.accountView(authenticated.account);\n });\n\n server.get(\"/api/account/sessions\", async (request) => {\n const { auth: authenticated } = contextOf(request);\n\n return auth.listSessions(authenticated);\n });\n\n server.delete(\"/api/account/sessions/:id\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.revokeSession(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.post(\"/api/account/password\", changePassword);\n server.post(\"/api/account/totp/start\", startTotp);\n server.post(\"/api/account/totp/confirm\", confirmTotp);\n\n server.delete(\"/api/account/totp\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.removeTotp(authenticated, meta, currentOf(request));\n\n return reply.code(204).send();\n });\n\n server.post(\"/api/account/recovery-codes\", async (request) => {\n const { auth: authenticated, meta } = contextOf(request);\n // No code: a passkey step-up in this session stands in for it.\n const codes = await auth.regenerateRecoveryCodes(\n authenticated,\n optionalText(bodyOf(request), \"code\", MAX_CODE) ?? \"\",\n meta,\n );\n\n return { codes };\n });\n\n server.post(\"/api/account/passkey/options\", passkeyOptions);\n server.post(\"/api/account/passkey/verify\", passkeyVerify);\n\n server.delete(\"/api/account/passkeys/:id\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.removePasskey(authenticated, idParam(request), meta, currentOf(request));\n\n return reply.code(204).send();\n });\n\n // ---- Admin ---------------------------------------------------------------\n\n server.get(\"/api/admin/users\", async (request) => {\n const { auth: authenticated } = contextOf(request);\n\n return auth.listUsers(authenticated);\n });\n\n server.post(\"/api/admin/invites\", async (request) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n\n return auth.createInvite(authenticated, { email: email(body), role: role(body) }, meta);\n });\n\n server.delete(\"/api/admin/invites/:id\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.revokeInvite(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.patch(\"/api/admin/users/:id\", async (request) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n return auth.setRole(authenticated, idParam(request), role(bodyOf(request)), meta);\n });\n\n server.delete(\"/api/admin/users/:id\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.removeAccount(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.post(\"/api/admin/users/:id/reset-mfa\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.resetSecondFactor(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.post(\"/api/admin/users/:id/sign-out\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.signOutAccount(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.get<{ Querystring: Record<string, string | undefined> }>(\n \"/api/admin/audit\",\n async (request) => {\n const { auth: authenticated } = contextOf(request);\n\n requireAdmin(authenticated);\n\n const query = request.query;\n const types = query.type\n ?.split(\",\")\n .map((type) => type.trim())\n .filter((type) => type !== \"\");\n const before = query.before === undefined ? undefined : Number(query.before);\n const limit = query.limit === undefined ? 100 : Number(query.limit);\n\n if (\n (before !== undefined && !Number.isFinite(before)) ||\n !Number.isInteger(limit) ||\n limit < 1\n ) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return store.audit.list({\n ...(types && types.length > 0 ? { types: types as DevtoolsAuditType[] } : {}),\n ...(query.account ? { accountId: query.account } : {}),\n ...(before === undefined ? {} : { before }),\n limit: Math.min(limit, 500),\n });\n },\n );\n\n server.post(\"/api/admin/disable\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n if (bodyOf(request).confirm !== \"disable\") throw new DevtoolsApiError(\"input.invalid\");\n\n await auth.disableDashboard(authenticated, meta);\n // This process closes at once; the others within the state cache time.\n state.invalidate();\n\n return reply.code(204).send();\n });\n}\n","/** Headers on every dashboard answer that is not the uniform 404. */\nexport const DASHBOARD_HEADERS: Readonly<Record<string, string>> = {\n \"Cache-Control\": \"no-store\",\n \"X-Robots-Tag\": \"noindex, nofollow, noarchive\",\n \"Referrer-Policy\": \"no-referrer\",\n \"X-Content-Type-Options\": \"nosniff\",\n \"X-Frame-Options\": \"DENY\",\n \"Cross-Origin-Opener-Policy\": \"same-origin\",\n \"Cross-Origin-Resource-Policy\": \"same-origin\",\n \"Permissions-Policy\":\n \"camera=(), microphone=(), geolocation=(), publickey-credentials-get=(self), publickey-credentials-create=(self)\",\n};\n\n/** The policy of the dashboard's own HTML: scripts and styles from the bundle only. */\nexport const DASHBOARD_CSP =\n \"default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; frame-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; object-src 'none'\";\n\n/**\n * The policy of the opt-in API documentation pages: scripts from the dashboard\n * only (Scalar and Swagger UI probe `Function` in a try/catch and work without\n * `'unsafe-eval'`), inline styles, and framing by the dashboard itself, whose\n * API tab shows them in a frame.\n */\nexport const DOCS_CSP =\n \"default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'self'; base-uri 'none'; form-action 'self'; object-src 'none'\";\n","import { createHash } from \"node:crypto\";\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport { listPanelInfos } from \"../../panels\";\nimport { registerAiRoutes } from \"../../server/ai-routes\";\nimport { registerShapeExplainRoute } from \"../../server/explain-route\";\nimport { registerInsightsRoutes } from \"../../server/insights-routes\";\nimport { registerLogRoutes } from \"../../server/log-routes\";\nimport { registerMailRoutes } from \"../../server/mail-routes\";\nimport { registerOpenApiRoutes } from \"../../server/openapi-routes\";\nimport { registerPanelRoutes } from \"../../server/panel-routes\";\nimport { registerRequestsRoutes } from \"../../server/requests-routes\";\nimport { registerRouteRoutes } from \"../../server/route-routes\";\nimport { registerStreamRoute } from \"../../server/stream-route\";\nimport type { DevtoolsStreamSession, MountDevtoolsRoutesDeps } from \"../../server/types\";\nimport { registerUiAssets } from \"../../server/ui-assets\";\nimport type { DevtoolsAuthenticated, DevtoolsRequestMeta } from \"../auth/types\";\nimport { DevtoolsApiError, createErrorRef, DEVTOOLS_ERROR_MESSAGES } from \"../errors\";\nimport { createAccessLookup, productionRouteAccess } from \"./access\";\nimport { registerAuthRoutes } from \"./auth-routes\";\nimport { resolveClient } from \"./client\";\nimport { setDevtoolsRequestContext, devtoolsRequestContext } from \"./context\";\nimport { readCookie, sessionCookieName } from \"./cookie\";\nimport { DASHBOARD_CSP, DASHBOARD_HEADERS, DOCS_CSP } from \"./headers\";\nimport { DEVTOOLS_CSRF_HEADER } from \"./constants\";\nimport { ipMatches } from \"./ip\";\nimport type { DevtoolsRouteAccess, MountProductionDevtoolsDeps } from \"./types\";\n\n/** Open live streams a session may hold, and an instance may serve. */\nconst MAX_STREAMS_PER_SESSION = 3;\nconst MAX_STREAMS_PER_INSTANCE = 50;\n\nconst MAX_USER_AGENT = 200;\n\n/** Methods that never change state. */\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\n/** The routes of the opt-in API documentation pages (they keep a CSP of their own). */\nconst DOCS_PATTERNS = new Set([\"/docs\", \"/docs/swagger\"]);\n\n/** The mail preview's HTML: framed by the dashboard, with a policy of its own. */\nconst MAIL_HTML_PATTERN = \"/api/mails/:id/html\";\n\n/** Which tab a route belongs to: a route of a tab that is off answers the uniform 404. */\nconst TAB_OF_ROUTE: readonly (readonly [prefix: string, tab: string])[] = [\n [\"/api/resources\", \"resources\"],\n [\"/api/queries\", \"queries\"],\n [\"/api/routes/stats\", \"routes\"],\n [\"/api/routes\", \"routes\"],\n [\"/api/health\", \"health\"],\n [\"/api/errors\", \"errors\"],\n [\"/api/jobs\", \"jobs\"],\n [\"/api/logs\", \"logs\"],\n [\"/api/requests\", \"requests\"],\n [\"/api/mails\", \"mail\"],\n [\"/api/ai/agent-runs\", \"agents\"],\n [\"/api/ai\", \"ai\"],\n [\"/api/openapi.json\", \"api\"],\n [\"/api/postman.json\", \"api\"],\n [\"/docs\", \"api\"],\n];\n\nfunction tabOf(pattern: string): string | undefined {\n return TAB_OF_ROUTE.find(\n ([prefix]) => pattern === prefix || pattern.startsWith(`${prefix}/`),\n )?.[1];\n}\n\nfunction tokenHash(token: string): string {\n return createHash(\"sha256\").update(token).digest(\"hex\");\n}\n\n/** Requests that were answered with the uniform 404: they get none of the dashboard's headers. */\nconst uniformNotFound = new WeakSet<FastifyRequest>();\n\n/**\n * The origin the browser must send for an unsafe request: `production.origin`,\n * else the scheme and host the request was addressed to.\n */\nfunction originAllowed(request: FastifyRequest, expected: string): boolean {\n const origin = request.headers.origin;\n const site = request.headers[\"sec-fetch-site\"];\n\n if (site !== undefined && site !== \"same-origin\") return false;\n\n if (origin !== undefined) return origin.toLowerCase() === expected.toLowerCase();\n\n // No Origin header: a same-origin fetch from an older browser. Accept it only with the fetch metadata that proves it.\n return site === \"same-origin\";\n}\n\nfunction hasBody(request: FastifyRequest): boolean {\n const length = request.headers[\"content-length\"];\n\n return (\n (length !== undefined && length !== \"0\") || request.headers[\"transfer-encoding\"] !== undefined\n );\n}\n\nfunction isJson(request: FastifyRequest): boolean {\n return /^application\\/json\\s*(;|$)/i.test(request.headers[\"content-type\"] ?? \"\");\n}\n\nfunction sessionAccessOk(\n access: Exclude<DevtoolsRouteAccess, { type: \"public\" }>,\n stage: string,\n): boolean {\n if (stage === \"active\") return true;\n\n return access.type === \"pending\" && (access.stages as readonly string[]).includes(stage);\n}\n\n/**\n * Mounts the production monitor under `production.path` in one encapsulated\n * Fastify context: the gate (uniform 404, HTTPS, allowed IPs, open state),\n * session and role checks from the access table, CSRF and origin checks,\n * security headers and CORS stripping, the auth/account/admin routes, and\n * the shared data routes of the enabled tabs.\n */\nexport function mountProductionDevtools(\n server: FastifyInstance,\n deps: MountProductionDevtoolsDeps,\n): void {\n const { production, auth, state, store } = deps;\n const prefix = production.path;\n const cookieName = sessionCookieName(production.requireHttps);\n const enabledTabs = new Set(deps.builtInPanels);\n const lookup = createAccessLookup(productionRouteAccess(deps.panels.map((panel) => panel.id)));\n const streamsPerSession = new Map<string, number>();\n let streamsInstance = 0;\n let lastWarningAt = 0;\n\n const warn = (message: string): void => {\n // At most one line a minute: a database outage must not flood the log.\n const now = Date.now();\n\n if (now - lastWarningAt < 60_000) return;\n\n lastWarningAt = now;\n deps.warn?.(message);\n };\n\n const notFound = (request: FastifyRequest, reply: FastifyReply): FastifyReply => {\n uniformNotFound.add(request);\n\n // The app's own not-found handler answers, so the reply is the one any unknown URL gets.\n reply.callNotFound();\n\n // Returning the reply is what stops an async hook's lifecycle.\n return reply;\n };\n\n const streamSession = async (request: FastifyRequest): Promise<DevtoolsStreamSession> => {\n const authenticated = devtoolsRequestContext(request)?.authenticated;\n\n if (!authenticated) throw new Error(\"A dashboard stream was opened without a session.\");\n\n const sessionId = authenticated.session.id;\n const token = readCookie(request.headers.cookie, cookieName);\n const open = streamsPerSession.get(sessionId) ?? 0;\n\n if (open >= MAX_STREAMS_PER_SESSION || streamsInstance >= MAX_STREAMS_PER_INSTANCE) {\n throw new DevtoolsApiError(\"stream.too-many\");\n }\n\n streamsPerSession.set(sessionId, open + 1);\n streamsInstance += 1;\n\n let released = false;\n\n return {\n role: authenticated.account.role,\n logLevels: production.logLevels,\n headers: DASHBOARD_HEADERS,\n // Reads the session without touching `lastSeenAt`: a stream left open must not keep the session alive.\n async revalidate() {\n if (token === undefined || !(await state.isOpen())) return false;\n\n const session = await store.sessions.findByTokenHash(tokenHash(token));\n const now = Date.now();\n\n if (\n session === null ||\n session.stage !== \"active\" ||\n now >= session.expiresAt ||\n now - session.lastSeenAt >= production.session.idleMinutes * 60_000\n ) {\n return false;\n }\n\n return (await store.accounts.findById(session.accountId)) !== null;\n },\n release() {\n if (released) return;\n\n released = true;\n streamsInstance -= 1;\n\n const left = (streamsPerSession.get(sessionId) ?? 1) - 1;\n\n if (left <= 0) streamsPerSession.delete(sessionId);\n else streamsPerSession.set(sessionId, left);\n },\n };\n };\n\n // The route deps the shared route files read: the development deps, completed.\n const routes: MountDevtoolsRoutesDeps = {\n ...deps.routes,\n mode: \"production\",\n isDevelopment: () => false,\n instance: deps.instance,\n insights: deps.insights,\n collector: deps.routes.collector ?? deps.capture.collector,\n requests: deps.routes.requests ?? deps.capture.requests,\n explainShape: deps.routes.explainShape ?? ((shapeId) => deps.capture.explain(shapeId)),\n builtInPanels: deps.builtInPanels,\n streamSession,\n };\n\n server.register(\n async (instance) => {\n // ---- The gate -------------------------------------------------------\n instance.addHook(\"onRequest\", async (request, reply) => {\n let open: boolean;\n\n try {\n open = await state.isOpen();\n } catch (error) {\n // Fail closed: when the state cannot be read the dashboard does not answer.\n warn(\n `The devtools dashboard state could not be read and the dashboard is closed: ${error instanceof Error ? error.message : String(error)}`,\n );\n open = false;\n }\n\n if (!open) return notFound(request, reply);\n\n const client = resolveClient(request, production.trustedProxies);\n\n if (production.requireHttps && client.proto !== \"https\") return notFound(request, reply);\n\n if (production.allowedIps.length > 0 && !ipMatches(client.ip, production.allowedIps)) {\n return notFound(request, reply);\n }\n\n const userAgent = request.headers[\"user-agent\"];\n const expectedOrigin = production.origin ?? `${client.proto}://${client.host}`;\n const meta: DevtoolsRequestMeta = {\n ip: client.ip,\n userAgent: typeof userAgent === \"string\" ? userAgent.slice(0, MAX_USER_AGENT) : null,\n origin: expectedOrigin,\n hostname: client.hostname,\n };\n\n const routeUrl = request.routeOptions.url ?? \"\";\n const relative = routeUrl.startsWith(prefix) ? routeUrl.slice(prefix.length) : routeUrl;\n // The shell is registered once for both `<path>` and `<path>/`.\n const pattern = relative === \"\" ? \"/\" : relative;\n const method = request.method;\n\n // The bare path (no trailing slash) redirects to the shell's address. The\n // address as sent: core's server drops a trailing slash before routing,\n // so the rewritten URL of `<path>/` is the bare path too.\n const sent = request.originalUrl ?? request.raw.url ?? \"\";\n\n if (sent.split(\"?\")[0] === prefix) {\n setDevtoolsRequestContext(request, {\n client,\n meta,\n rule: undefined,\n pattern,\n authenticated: null,\n });\n\n if (method !== \"GET\" && method !== \"HEAD\") return notFound(request, reply);\n\n const search = sent.includes(\"?\") ? `?${sent.split(\"?\").slice(1).join(\"?\")}` : \"\";\n\n return reply.redirect(`${prefix}/${search}`, 308);\n }\n\n const tab = tabOf(pattern);\n\n if (tab !== undefined && !enabledTabs.has(tab)) return notFound(request, reply);\n\n const rule = lookup(method, pattern);\n const access: DevtoolsRouteAccess = rule?.access ?? { type: \"admin\" };\n let authenticated: DevtoolsAuthenticated | null = null;\n\n if (access.type !== \"public\") {\n try {\n authenticated = await auth.authenticate(readCookie(request.headers.cookie, cookieName));\n } catch (error) {\n warn(\n `The devtools session could not be checked and the request was refused: ${error instanceof Error ? error.message : String(error)}`,\n );\n\n return notFound(request, reply);\n }\n\n if (authenticated === null || !sessionAccessOk(access, authenticated.stage)) {\n return notFound(request, reply);\n }\n\n if (access.type === \"admin\" && authenticated.account.role !== \"admin\") {\n setDevtoolsRequestContext(request, { client, meta, rule, pattern, authenticated });\n throw new DevtoolsApiError(\"role.forbidden\");\n }\n }\n\n setDevtoolsRequestContext(request, { client, meta, rule, pattern, authenticated });\n\n if (SAFE_METHODS.has(method)) return;\n\n if (!originAllowed(request, expectedOrigin)) {\n if (authenticated === null) return notFound(request, reply);\n\n throw new DevtoolsApiError(\"csrf.invalid\");\n }\n\n if (hasBody(request) && !isJson(request)) throw new DevtoolsApiError(\"input.invalid\");\n\n if (authenticated !== null) {\n const header = request.headers[DEVTOOLS_CSRF_HEADER];\n\n if (!auth.verifyCsrf(authenticated, Array.isArray(header) ? header[0] : header)) {\n throw new DevtoolsApiError(\"csrf.invalid\");\n }\n }\n });\n\n // ---- Headers --------------------------------------------------------\n instance.addHook(\"onSend\", async (request, reply, payload) => {\n // The uniform 404 must look like any other 404 of the app.\n if (uniformNotFound.has(request)) return payload;\n\n for (const name of Object.keys(reply.getHeaders())) {\n if (name.startsWith(\"access-control-\")) reply.removeHeader(name);\n }\n\n reply.headers(DASHBOARD_HEADERS);\n\n const pattern = devtoolsRequestContext(request)?.pattern ?? \"\";\n\n // The mail preview is the one page the dashboard frames, from its own origin, and it sends its own policy.\n if (pattern === MAIL_HTML_PATTERN) {\n reply.header(\"X-Frame-Options\", \"SAMEORIGIN\");\n\n return payload;\n }\n\n // The API docs pages are shown in a frame by the dashboard's API tab.\n if (DOCS_PATTERNS.has(pattern)) reply.header(\"X-Frame-Options\", \"SAMEORIGIN\");\n\n // Always the dashboard's policy: the app's own (core's security headers set one on every response) is not\n // written for this page and must not replace it.\n if (String(reply.getHeader(\"content-type\") ?? \"\").startsWith(\"text/html\")) {\n reply.header(\n \"Content-Security-Policy\",\n DOCS_PATTERNS.has(pattern) ? DOCS_CSP : DASHBOARD_CSP,\n );\n }\n\n return payload;\n });\n\n // ---- Audit ----------------------------------------------------------\n instance.addHook(\"onResponse\", async (request, reply) => {\n const context = devtoolsRequestContext(request);\n const type = context?.rule?.audit;\n\n if (!context || !type || reply.statusCode < 200 || reply.statusCode > 299) return;\n\n const params = (request.params ?? {}) as Record<string, string | undefined>;\n const detail: Record<string, string | number | boolean | null> =\n type === \"explain.run\"\n ? { shapeId: params.shapeId ?? null }\n : type === \"panel.action\"\n ? {\n panel: context.pattern.split(\"/\")[2] ?? null,\n method: request.method,\n route: context.pattern,\n }\n : {};\n\n await auth.audit(type, { auth: context.authenticated, meta: context.meta, detail });\n });\n\n // ---- Errors ---------------------------------------------------------\n instance.setErrorHandler(\n (error: Error & { statusCode?: number; code?: string }, request, reply) => {\n if (error instanceof DevtoolsApiError) {\n return reply.code(error.statusCode).send(error.toBody());\n }\n\n const status = error.statusCode;\n\n // The request itself was wrong (bad JSON, too large): say so in the dashboard's own shape.\n if (status !== undefined && status >= 400 && status < 500) {\n return reply\n .code(status)\n .send(\n error.code?.startsWith(\"FST_ERR_\")\n ? new DevtoolsApiError(\"input.invalid\").toBody()\n : { error: error.message },\n );\n }\n\n const ref = createErrorRef();\n\n // Never rate limited: the reference the browser shows must always be findable in the log. The route is\n // written relative to the dashboard path, which never reaches the log.\n deps.warn?.(\n `Devtools dashboard error ${ref} on ${request.method} ${devtoolsRequestContext(request)?.pattern ?? \"(dashboard route)\"}: ${error.message}`,\n );\n request.log.error({ ref, err: error }, \"devtools dashboard error\");\n\n return reply.code(500).send({\n error: DEVTOOLS_ERROR_MESSAGES[\"server.error\"],\n code: \"server.error\",\n ref,\n });\n },\n );\n\n // ---- Routes ---------------------------------------------------------\n registerUiAssets(instance, { notFound });\n registerAuthRoutes(instance, deps);\n\n instance.get(\"/api/panels\", async () => listPanelInfos(deps.panels, deps.builtInPanels));\n\n registerRequestsRoutes(instance, routes);\n registerRouteRoutes(instance, routes);\n registerInsightsRoutes(instance, routes);\n registerLogRoutes(instance, routes);\n registerShapeExplainRoute(instance, routes);\n registerPanelRoutes(instance, deps.panels);\n\n if (enabledTabs.has(\"mail\")) registerMailRoutes(instance, routes);\n if (enabledTabs.has(\"ai\") || enabledTabs.has(\"agents\")) registerAiRoutes(instance, routes);\n if (enabledTabs.has(\"api\")) registerOpenApiRoutes(instance, routes);\n\n registerStreamRoute(instance, routes);\n },\n { prefix },\n );\n}\n","import { createHash } from \"node:crypto\";\nimport type { DevtoolsStore } from \"../store/types\";\nimport type { DevtoolsDashboardState } from \"./types\";\n\n/** SHA-256 hex of a dashboard path: what `disabledPathHash` holds. */\nexport function hashDashboardPath(path: string): string {\n return createHash(\"sha256\").update(path).digest(\"hex\");\n}\n\n/**\n * The open/closed state with a `ttlMs` cache (default 5000). Open means the\n * dashboard is not disabled for this path and not locked. A failed read is\n * not cached and rejects, so the caller can fail closed.\n */\nexport function createDashboardState(\n store: DevtoolsStore,\n path: string,\n options: { ttlMs?: number; now?: () => number } = {},\n): DevtoolsDashboardState {\n const ttlMs = options.ttlMs ?? 5000;\n const now = options.now ?? Date.now;\n const pathHash = hashDashboardPath(path);\n let cached: { open: boolean; at: number } | null = null;\n let pending: Promise<boolean> | null = null;\n let generation = 0;\n\n const read = async (): Promise<boolean> => {\n const started = generation;\n const state = await store.state.read();\n const at = now();\n const disabled = state.disabled && state.disabledPathHash === pathHash;\n const locked = state.lockedUntil !== null && state.lockedUntil > at;\n const open = !disabled && !locked;\n\n if (started === generation) cached = { open, at };\n\n return open;\n };\n\n return {\n async isOpen() {\n if (cached !== null && now() - cached.at < ttlMs) return cached.open;\n\n if (pending === null) {\n const current = read().finally(() => {\n if (pending === current) pending = null;\n });\n\n pending = current;\n }\n\n return pending;\n },\n invalidate() {\n generation += 1;\n cached = null;\n pending = null;\n },\n };\n}\n"],"mappings":";;;;;;;;AAIA,MAAM,SAA8B,EAAE,MAAM,SAAS;AACrD,MAAM,SAA8B,EAAE,MAAM,SAAS;AACrD,MAAM,QAA6B,EAAE,MAAM,QAAQ;AAEnD,MAAM,WAAW,GAAG,YACjB;CAAE,MAAM;CAAW;AAAO;AAE7B,MAAM,YAAY;CAAC;CAAmB;CAAa;AAAY;;;;;;;;AAS/D,SAAgB,sBAAsB,UAAwD;CAC5F,MAAM,QACJ,QACA,KACA,QACA,WAC6B;EAAE;EAAQ;EAAK;EAAQ,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;CAAG;CAElF,MAAM,QAAmC;EAEvC,KAAK,OAAO,KAAK,MAAM;EACvB,KAAK,OAAO,iBAAiB,MAAM;EACnC,KAAK,OAAO,qBAAqB,MAAM;EACvC,KAAK,QAAQ,mBAAmB,MAAM;EACtC,KAAK,QAAQ,mBAAmB,MAAM;EACtC,KAAK,QAAQ,4BAA4B,MAAM;EAC/C,KAAK,QAAQ,2BAA2B,MAAM;EAC9C,KAAK,QAAQ,sBAAsB,QAAQ,iBAAiB,CAAC;EAC7D,KAAK,QAAQ,wBAAwB,QAAQ,WAAW,CAAC;EACzD,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,YAA8B;EACzC,MAAM,UAAU;EAChB,MAAM,QAAQ,MAAM,MAAM,MAAM,KAAK;EACrC,MAAM,KAAK,IAAI;EACf,MAAM,WAAW,MAAM,YAAY,MAAM,qBAAqB;EAC9D,MAAM,SAAS,MAAM,gBAAgB,QAAQ,MAAM,cAAc;EACjE,MAAM,OAAO,CAAC,YAAY,CAAC;EAE3B,IAAI,YAAY,YAAY,SAAS;GAAE;GAAM;EAAG;EAEhD,OAAO;CACT;CAEA,OAAO;EACL,MAAM,SAAS;GACb,IAAI,WAAW,QAAQ,IAAI,IAAI,OAAO,KAAK,OAAO,OAAO,OAAO;GAEhE,IAAI,YAAY,MAAM;IACpB,MAAM,UAAU,KAAK,CAAC,CAAC,cAAc;KACnC,IAAI,YAAY,SAAS,UAAU;IACrC,CAAC;IAED,UAAU;GACZ;GAEA,OAAO;EACT;EACA,aAAa;GACX,cAAc;GACd,SAAS;GACT,UAAU;EACZ;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"http-DCfXQvw-.cjs","names":["normalizeIp","isIP","ipMatches","DevtoolsApiError","createHash","DevtoolsApiError","ipMatches","createErrorRef","DEVTOOLS_ERROR_MESSAGES","listPanelInfos","createHash"],"sources":["../../../../../../../packages/devtools/src/production/http/access.ts","../../../../../../../packages/devtools/src/production/http/client.ts","../../../../../../../packages/devtools/src/production/http/constants.ts","../../../../../../../packages/devtools/src/production/http/context.ts","../../../../../../../packages/devtools/src/production/http/cookie.ts","../../../../../../../packages/devtools/src/production/http/auth-routes.ts","../../../../../../../packages/devtools/src/production/http/headers.ts","../../../../../../../packages/devtools/src/production/http/mount.ts","../../../../../../../packages/devtools/src/production/http/state.ts"],"sourcesContent":["import type { DevtoolsRouteAccess, DevtoolsRouteAccessRule } from \"./types\";\n\ntype Method = DevtoolsRouteAccessRule[\"method\"];\n\nconst PUBLIC: DevtoolsRouteAccess = { type: \"public\" };\nconst VIEWER: DevtoolsRouteAccess = { type: \"viewer\" };\nconst ADMIN: DevtoolsRouteAccess = { type: \"admin\" };\n\nconst pending = (...stages: Extract<DevtoolsRouteAccess, { type: \"pending\" }>[\"stages\"]) =>\n ({ type: \"pending\", stages }) satisfies DevtoolsRouteAccess;\n\nconst ALL_STEPS = [\"password-change\", \"mfa-enrol\", \"mfa-verify\"] as const;\n\n/**\n * The access table: every production route, its method and who may call it.\n * A route with no entry is `admin` (fail closed). A package panel `<id>`\n * gets `GET /api/<id>` and `GET /api/<id>/*` for viewers and every other\n * method there for admins, audited as `panel.action`; a url ending in `/*`\n * matches every pattern below it.\n */\nexport function productionRouteAccess(panelIds: readonly string[]): DevtoolsRouteAccessRule[] {\n const rule = (\n method: Method,\n url: string,\n access: DevtoolsRouteAccess,\n audit?: DevtoolsRouteAccessRule[\"audit\"],\n ): DevtoolsRouteAccessRule => ({ method, url, access, ...(audit ? { audit } : {}) });\n\n const rules: DevtoolsRouteAccessRule[] = [\n // The shell and its sign-in steps.\n rule(\"GET\", \"/\", PUBLIC),\n rule(\"GET\", \"/assets/:name\", PUBLIC),\n rule(\"GET\", \"/api/auth/session\", PUBLIC),\n rule(\"POST\", \"/api/auth/login\", PUBLIC),\n rule(\"POST\", \"/api/auth/setup\", PUBLIC),\n rule(\"POST\", \"/api/auth/invite/inspect\", PUBLIC),\n rule(\"POST\", \"/api/auth/invite/accept\", PUBLIC),\n rule(\"POST\", \"/api/auth/password\", pending(\"password-change\")),\n rule(\"POST\", \"/api/auth/totp/start\", pending(\"mfa-enrol\")),\n rule(\"POST\", \"/api/auth/totp/confirm\", pending(\"mfa-enrol\")),\n rule(\"POST\", \"/api/auth/passkey/options\", pending(\"mfa-enrol\", \"mfa-verify\")),\n rule(\"POST\", \"/api/auth/passkey/verify\", pending(\"mfa-enrol\", \"mfa-verify\")),\n rule(\"POST\", \"/api/auth/mfa\", pending(\"mfa-verify\")),\n rule(\"POST\", \"/api/auth/logout\", pending(...ALL_STEPS)),\n\n // The signed-in account.\n rule(\"GET\", \"/api/panels\", VIEWER),\n rule(\"GET\", \"/api/account\", VIEWER),\n rule(\"GET\", \"/api/account/sessions\", VIEWER),\n rule(\"DELETE\", \"/api/account/sessions/:id\", VIEWER),\n rule(\"POST\", \"/api/account/password\", VIEWER),\n rule(\"POST\", \"/api/account/totp/start\", VIEWER),\n rule(\"POST\", \"/api/account/totp/confirm\", VIEWER),\n rule(\"DELETE\", \"/api/account/totp\", VIEWER),\n rule(\"POST\", \"/api/account/recovery-codes\", VIEWER),\n rule(\"POST\", \"/api/account/passkey/options\", VIEWER),\n rule(\"POST\", \"/api/account/passkey/verify\", VIEWER),\n rule(\"DELETE\", \"/api/account/passkeys/:id\", VIEWER),\n\n // Administration.\n rule(\"GET\", \"/api/admin/users\", ADMIN),\n rule(\"POST\", \"/api/admin/invites\", ADMIN),\n rule(\"DELETE\", \"/api/admin/invites/:id\", ADMIN),\n rule(\"PATCH\", \"/api/admin/users/:id\", ADMIN),\n rule(\"DELETE\", \"/api/admin/users/:id\", ADMIN),\n rule(\"POST\", \"/api/admin/users/:id/reset-mfa\", ADMIN),\n rule(\"POST\", \"/api/admin/users/:id/sign-out\", ADMIN),\n rule(\"GET\", \"/api/admin/audit\", ADMIN),\n rule(\"POST\", \"/api/admin/disable\", ADMIN),\n\n // Data.\n rule(\"GET\", \"/api/stream\", VIEWER),\n rule(\"GET\", \"/api/instances\", VIEWER),\n rule(\"GET\", \"/api/resources\", VIEWER),\n rule(\"GET\", \"/api/queries/stats\", VIEWER),\n rule(\"GET\", \"/api/routes/stats\", VIEWER),\n rule(\"GET\", \"/api/health\", VIEWER),\n rule(\"GET\", \"/api/errors\", VIEWER),\n rule(\"GET\", \"/api/jobs\", VIEWER),\n rule(\"GET\", \"/api/logs\", VIEWER),\n rule(\"GET\", \"/api/requests\", VIEWER),\n rule(\"GET\", \"/api/requests/:id\", VIEWER),\n rule(\"GET\", \"/api/requests/:id/curl\", VIEWER),\n rule(\"DELETE\", \"/api/requests\", ADMIN, \"requests.cleared\"),\n rule(\"POST\", \"/api/queries/:shapeId/explain\", ADMIN, \"explain.run\"),\n rule(\"GET\", \"/api/routes\", VIEWER),\n rule(\"GET\", \"/panels/:id/:name\", VIEWER),\n\n // Tabs that are off unless the project turns them on.\n rule(\"GET\", \"/api/mails\", VIEWER),\n rule(\"GET\", \"/api/mails/:id\", VIEWER),\n rule(\"GET\", \"/api/mails/:id/html\", VIEWER),\n rule(\"GET\", \"/api/ai\", VIEWER),\n rule(\"GET\", \"/api/ai/agent-runs\", VIEWER),\n rule(\"GET\", \"/api/ai/agent-runs/:id\", VIEWER),\n rule(\"GET\", \"/api/ai/runs/:id\", VIEWER),\n rule(\"GET\", \"/api/openapi.json\", VIEWER),\n rule(\"GET\", \"/api/postman.json\", VIEWER),\n rule(\"GET\", \"/docs\", VIEWER),\n rule(\"GET\", \"/docs/swagger\", VIEWER),\n ];\n\n for (const id of panelIds) {\n rules.push(rule(\"GET\", `/api/${id}`, VIEWER), rule(\"GET\", `/api/${id}/*`, VIEWER));\n\n for (const method of [\"POST\", \"PUT\", \"PATCH\", \"DELETE\"] as const) {\n rules.push(\n rule(method, `/api/${id}`, ADMIN, \"panel.action\"),\n rule(method, `/api/${id}/*`, ADMIN, \"panel.action\"),\n );\n }\n }\n\n return rules;\n}\n\n/** Looks routes up by method and URL pattern: exact first, then the longest `/*` prefix. */\nexport function createAccessLookup(\n rules: readonly DevtoolsRouteAccessRule[],\n): (method: string, pattern: string) => DevtoolsRouteAccessRule | undefined {\n const exact = new Map<string, DevtoolsRouteAccessRule>();\n const wildcards: { method: Method; prefix: string; rule: DevtoolsRouteAccessRule }[] = [];\n\n for (const rule of rules) {\n if (rule.url.endsWith(\"/*\")) {\n wildcards.push({ method: rule.method, prefix: rule.url.slice(0, -1), rule });\n } else {\n exact.set(`${rule.method} ${rule.url}`, rule);\n }\n }\n\n wildcards.sort((a, b) => b.prefix.length - a.prefix.length);\n\n return (method, pattern) => {\n // A HEAD request is answered by the GET route.\n const verb = method === \"HEAD\" ? \"GET\" : method;\n const found = exact.get(`${verb} ${pattern}`);\n\n if (found) return found;\n\n return wildcards.find((item) => item.method === verb && pattern.startsWith(item.prefix))?.rule;\n };\n}\n","import { isIP } from \"node:net\";\nimport type { DevtoolsClientInfo, DevtoolsProxyRequest } from \"./types\";\nimport { ipMatches, normalizeIp } from \"./ip\";\n\n/** The first value of a header that may repeat or hold a comma list. */\nfunction firstValue(value: string | string[] | undefined): string | undefined {\n const text = Array.isArray(value) ? value[0] : value;\n const first = text?.split(\",\")[0]?.trim();\n\n return first === undefined || first === \"\" ? undefined : first;\n}\n\n/** The host name of a `Host` value: no port, lower case, brackets of an IPv6 literal kept. */\nfunction hostnameOf(host: string): string {\n const value = host.trim().toLowerCase();\n\n if (value.startsWith(\"[\")) {\n const end = value.indexOf(\"]\");\n\n return end === -1 ? value : value.slice(0, end + 1);\n }\n\n const colon = value.indexOf(\":\");\n\n return colon === -1 ? value : value.slice(0, colon);\n}\n\n/** The client address out of an `X-Forwarded-For` value, walking right to left past trusted hops. */\nfunction forwardedClient(\n header: string | string[] | undefined,\n trusted: readonly string[],\n): string | undefined {\n const text = Array.isArray(header) ? header.join(\",\") : header;\n const hops = (text ?? \"\")\n .split(\",\")\n .map((hop) => normalizeIp(hop.trim().replace(/^\\[|\\]$/g, \"\")))\n .filter((hop) => isIP(hop) !== 0);\n\n for (let index = hops.length - 1; index >= 0; index -= 1) {\n const hop = hops[index];\n\n if (hop !== undefined && !ipMatches(hop, trusted)) return hop;\n }\n\n // Every hop is a trusted proxy: the leftmost is the origin of the chain.\n return hops[0];\n}\n\n/**\n * The client IP, protocol and host. Forwarding headers are read only when the\n * socket peer is a trusted proxy; `X-Forwarded-For` is walked right to left,\n * skipping trusted addresses, and the first untrusted one is the client.\n */\nexport function resolveClient(\n request: DevtoolsProxyRequest,\n trustedProxies: readonly string[],\n): DevtoolsClientInfo {\n const peer = normalizeIp(request.socket.remoteAddress ?? \"\");\n const headers = request.headers;\n let ip = peer;\n let proto = request.socket.encrypted === true ? \"https\" : \"http\";\n let host = firstValue(headers.host) ?? \"\";\n\n if (peer !== \"\" && ipMatches(peer, trustedProxies)) {\n ip = forwardedClient(headers[\"x-forwarded-for\"], trustedProxies) ?? peer;\n\n const forwardedProto = firstValue(headers[\"x-forwarded-proto\"])?.toLowerCase();\n\n if (forwardedProto === \"http\" || forwardedProto === \"https\") proto = forwardedProto;\n\n host = firstValue(headers[\"x-forwarded-host\"]) ?? host;\n }\n\n host = host.toLowerCase();\n\n return { ip, proto, hostname: hostnameOf(host), host };\n}\n","/** The header the dashboard sends the CSRF token in. */\nexport const DEVTOOLS_CSRF_HEADER = \"x-devtools-csrf\";\n\n/** The session cookie name over HTTPS (`__Secure-` makes browsers refuse it over plain HTTP). */\nexport const DEVTOOLS_SESSION_COOKIE = \"__Secure-warlock-devtools\";\n\n/** The session cookie name when `requireHttps` is off (local trials only). */\nexport const DEVTOOLS_SESSION_COOKIE_INSECURE = \"warlock-devtools\";\n","import type { FastifyRequest } from \"fastify\";\nimport type { DevtoolsAuthenticated, DevtoolsRequestMeta } from \"../auth/types\";\nimport type { DevtoolsClientInfo, DevtoolsRouteAccessRule } from \"./types\";\n\n/** What the gate learned about a dashboard request, for the handlers that follow. */\nexport type DevtoolsRequestContext = {\n client: DevtoolsClientInfo;\n meta: DevtoolsRequestMeta;\n /** The access rule the route matched; `undefined` for a route with no entry (treated as admin). */\n rule: DevtoolsRouteAccessRule | undefined;\n /** The route pattern relative to the dashboard path (`/api/requests/:id`). */\n pattern: string;\n /** The session, for every route that is not public. */\n authenticated: DevtoolsAuthenticated | null;\n};\n\nconst contexts = new WeakMap<FastifyRequest, DevtoolsRequestContext>();\n\n/** Stores the context of `request` (the gate calls this). */\nexport function setDevtoolsRequestContext(\n request: FastifyRequest,\n context: DevtoolsRequestContext,\n): void {\n contexts.set(request, context);\n}\n\n/** The context the gate stored for `request`, or `undefined` outside the production dashboard. */\nexport function devtoolsRequestContext(\n request: FastifyRequest,\n): DevtoolsRequestContext | undefined {\n return contexts.get(request);\n}\n","import { DEVTOOLS_SESSION_COOKIE, DEVTOOLS_SESSION_COOKIE_INSECURE } from \"./constants\";\n\n/** The cookie name for the HTTPS mode. */\nexport function sessionCookieName(secure: boolean): string {\n return secure ? DEVTOOLS_SESSION_COOKIE : DEVTOOLS_SESSION_COOKIE_INSECURE;\n}\n\n/**\n * `Set-Cookie` value for a session token (or a clearing cookie when `token`\n * is `null`). The cookie is a browser-session cookie scoped to the dashboard\n * path, `HttpOnly` and `SameSite=Strict`, with no `Domain`.\n */\nexport function sessionCookie(\n token: string | null,\n options: { path: string; secure: boolean },\n): string {\n const parts = [\n `${sessionCookieName(options.secure)}=${token ?? \"\"}`,\n `Path=${options.path}`,\n \"HttpOnly\",\n \"SameSite=Strict\",\n ];\n\n if (options.secure) parts.push(\"Secure\");\n\n if (token === null) parts.push(\"Max-Age=0\", \"Expires=Thu, 01 Jan 1970 00:00:00 GMT\");\n\n return parts.join(\"; \");\n}\n\n/** The value of cookie `name` in a `Cookie` header, or `undefined`. */\nexport function readCookie(header: string | undefined, name: string): string | undefined {\n if (!header) return undefined;\n\n for (const pair of header.split(\";\")) {\n const equals = pair.indexOf(\"=\");\n\n if (equals === -1) continue;\n\n if (pair.slice(0, equals).trim() === name) {\n const value = pair.slice(equals + 1).trim();\n\n return value === \"\" ? undefined : value;\n }\n }\n\n return undefined;\n}\n","import type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport type { DevtoolsAuthenticated, DevtoolsAuthStep, DevtoolsRequestMeta } from \"../auth/types\";\nimport type { DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsRole } from \"../contracts\";\nimport { DevtoolsApiError } from \"../errors\";\nimport { readCookie, sessionCookie, sessionCookieName } from \"./cookie\";\nimport { devtoolsRequestContext } from \"./context\";\nimport type { MountProductionDevtoolsDeps } from \"./types\";\n\nconst MAX_TEXT = 1024;\nconst MAX_EMAIL = 320;\nconst MAX_CODE = 128;\nconst MAX_TOKEN = 512;\nconst ROLES: readonly DevtoolsRole[] = [\"admin\", \"viewer\"];\n\n/** A request body that is a plain JSON object, or `input.invalid`. */\nfunction bodyOf(request: FastifyRequest): Record<string, unknown> {\n const body: unknown = request.body;\n\n if (body === null || typeof body !== \"object\" || Array.isArray(body)) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return body as Record<string, unknown>;\n}\n\n/** A non-empty string field no longer than `max`, or `input.invalid`. */\nfunction text(body: Record<string, unknown>, key: string, max = MAX_TEXT): string {\n const value = body[key];\n\n if (typeof value !== \"string\" || value === \"\" || value.length > max) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return value;\n}\n\n/** An optional string field; `undefined` when absent, `input.invalid` when present but wrong. */\nfunction optionalText(\n body: Record<string, unknown>,\n key: string,\n max = MAX_TEXT,\n): string | undefined {\n return body[key] === undefined ? undefined : text(body, key, max);\n}\n\nfunction email(body: Record<string, unknown>): string {\n const value = text(body, \"email\", MAX_EMAIL).trim().toLowerCase();\n\n if (!/^[^\\s@]+@[^\\s@]+$/.test(value)) throw new DevtoolsApiError(\"input.invalid\");\n\n return value;\n}\n\nfunction role(body: Record<string, unknown>): DevtoolsRole {\n const value = body.role;\n\n if (typeof value !== \"string\" || !ROLES.includes(value as DevtoolsRole)) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return value as DevtoolsRole;\n}\n\nfunction purpose(body: Record<string, unknown>): \"register\" | \"login\" {\n const value = body.purpose;\n\n if (value !== \"register\" && value !== \"login\") throw new DevtoolsApiError(\"input.invalid\");\n\n return value;\n}\n\nfunction idParam(request: FastifyRequest): string {\n const { id } = (request.params ?? {}) as { id?: unknown };\n\n if (typeof id !== \"string\" || id === \"\" || id.length > MAX_CODE) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return id;\n}\n\n/** The `current` password of a request that may have no body (a DELETE). */\nfunction currentOf(request: FastifyRequest): string | undefined {\n return request.body === undefined || request.body === null\n ? undefined\n : optionalText(bodyOf(request), \"current\");\n}\n\n/** What the gate stored, for a route that is never reached without it. */\nfunction contextOf(request: FastifyRequest): {\n meta: DevtoolsRequestMeta;\n auth: DevtoolsAuthenticated;\n} {\n const context = devtoolsRequestContext(request);\n\n if (!context?.authenticated) throw new Error(\"A dashboard route ran without its session.\");\n\n return { meta: context.meta, auth: context.authenticated };\n}\n\nfunction metaOf(request: FastifyRequest): DevtoolsRequestMeta {\n const context = devtoolsRequestContext(request);\n\n if (!context) throw new Error(\"A dashboard route ran without its request context.\");\n\n return context.meta;\n}\n\n/**\n * Registers the sign-in, account and admin routes. All decisions live in the\n * auth service; the handlers read the body, call it and answer. The gate\n * (`mountProductionDevtools`) has already checked the session, role, origin\n * and CSRF token by the time a handler runs.\n */\nexport function registerAuthRoutes(\n server: FastifyInstance,\n deps: MountProductionDevtoolsDeps,\n): void {\n const { auth, store, state, production } = deps;\n const cookieOptions = { path: production.path, secure: production.requireHttps };\n\n /** Sets the new session cookie when the step minted one; answers the step. */\n const answerStep = (\n reply: FastifyReply,\n step: DevtoolsAuthStep,\n recoveryCodes?: string[] | null,\n ): DevtoolsAuthStepResult & { recoveryCodes?: string[] } => {\n if (step.token !== null) reply.header(\"set-cookie\", sessionCookie(step.token, cookieOptions));\n\n return {\n stage: step.stage,\n csrf: step.csrf,\n ...(recoveryCodes ? { recoveryCodes } : {}),\n };\n };\n\n /** The stage and CSRF token of the session in force, for answers that do not change it. */\n const currentStep = (authenticated: DevtoolsAuthenticated): DevtoolsAuthStepResult => ({\n stage: authenticated.stage,\n csrf: auth.csrfToken(authenticated.session),\n });\n\n const clearCookie = (reply: FastifyReply): void => {\n reply.header(\"set-cookie\", sessionCookie(null, cookieOptions));\n };\n\n const requireAdmin = (authenticated: DevtoolsAuthenticated): void => {\n if (authenticated.account.role !== \"admin\" || authenticated.stage !== \"active\") {\n throw new DevtoolsApiError(\"role.forbidden\");\n }\n };\n\n // ---- Public ------------------------------------------------------------\n\n server.get(\"/api/auth/session\", async (request, reply) => {\n const token = readCookie(request.headers.cookie, sessionCookieName(production.requireHttps));\n const authenticated = token === undefined ? null : await auth.authenticate(token);\n\n // A cookie that no longer matches a session is dead weight: clear it.\n if (token !== undefined && authenticated === null) clearCookie(reply);\n\n return auth.sessionView(authenticated);\n });\n\n server.post(\"/api/auth/login\", async (request, reply) => {\n const body = bodyOf(request);\n const step = await auth.login(\n { email: email(body), password: text(body, \"password\") },\n metaOf(request),\n );\n\n return answerStep(reply, step);\n });\n\n server.post(\"/api/auth/setup\", async (request, reply) => {\n const body = bodyOf(request);\n const step = await auth.setup(\n { token: text(body, \"token\", MAX_TOKEN), password: text(body, \"password\") },\n metaOf(request),\n );\n\n return answerStep(reply, step);\n });\n\n server.post(\"/api/auth/invite/inspect\", async (request) => {\n const body = bodyOf(request);\n\n return auth.inspectInvite(text(body, \"token\", MAX_TOKEN));\n });\n\n server.post(\"/api/auth/invite/accept\", async (request, reply) => {\n const body = bodyOf(request);\n const step = await auth.acceptInvite(\n { token: text(body, \"token\", MAX_TOKEN), password: text(body, \"password\") },\n metaOf(request),\n );\n\n return answerStep(reply, step);\n });\n\n // ---- Sign-in steps and the account (a session is required) --------------\n\n const changePassword = async (request: FastifyRequest, reply: FastifyReply) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n const current = optionalText(body, \"current\");\n const step = await auth.changePassword(\n authenticated,\n { ...(current === undefined ? {} : { current }), password: text(body, \"password\") },\n meta,\n );\n\n return answerStep(reply, step);\n };\n\n const startTotp = async (request: FastifyRequest) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n return auth.startTotp(authenticated, meta);\n };\n\n const confirmTotp = async (request: FastifyRequest, reply: FastifyReply) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n const result = await auth.confirmTotp(\n authenticated,\n text(body, \"code\", MAX_CODE),\n meta,\n optionalText(body, \"current\"),\n );\n\n return answerStep(reply, result.step, result.recoveryCodes);\n };\n\n const passkeyOptions = async (request: FastifyRequest) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n return auth.passkeyOptions(authenticated, purpose(bodyOf(request)), meta);\n };\n\n const passkeyVerify = async (request: FastifyRequest, reply: FastifyReply) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n\n if (body.response === null || typeof body.response !== \"object\") {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n const result = await auth.verifyPasskey(\n authenticated,\n purpose(body),\n body.response,\n meta,\n optionalText(body, \"current\"),\n );\n\n if (result.step === null) {\n return {\n ...currentStep(authenticated),\n ...(result.recoveryCodes ? { recoveryCodes: result.recoveryCodes } : {}),\n };\n }\n\n return answerStep(reply, result.step, result.recoveryCodes);\n };\n\n server.post(\"/api/auth/password\", changePassword);\n server.post(\"/api/auth/totp/start\", startTotp);\n server.post(\"/api/auth/totp/confirm\", confirmTotp);\n server.post(\"/api/auth/passkey/options\", passkeyOptions);\n server.post(\"/api/auth/passkey/verify\", passkeyVerify);\n\n server.post(\"/api/auth/mfa\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n const code = optionalText(body, \"code\", MAX_CODE);\n const recoveryCode = optionalText(body, \"recoveryCode\", MAX_CODE);\n\n if ((code === undefined) === (recoveryCode === undefined)) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n const step = await auth.verifySecondFactor(\n authenticated,\n code === undefined ? { recoveryCode: recoveryCode as string } : { code },\n meta,\n );\n\n return answerStep(reply, step);\n });\n\n server.post(\"/api/auth/logout\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.logout(authenticated, meta);\n clearCookie(reply);\n\n return reply.code(204).send();\n });\n\n server.get(\"/api/account\", async (request) => {\n const { auth: authenticated } = contextOf(request);\n\n return auth.accountView(authenticated.account);\n });\n\n server.get(\"/api/account/sessions\", async (request) => {\n const { auth: authenticated } = contextOf(request);\n\n return auth.listSessions(authenticated);\n });\n\n server.delete(\"/api/account/sessions/:id\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.revokeSession(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.post(\"/api/account/password\", changePassword);\n server.post(\"/api/account/totp/start\", startTotp);\n server.post(\"/api/account/totp/confirm\", confirmTotp);\n\n server.delete(\"/api/account/totp\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.removeTotp(authenticated, meta, currentOf(request));\n\n return reply.code(204).send();\n });\n\n server.post(\"/api/account/recovery-codes\", async (request) => {\n const { auth: authenticated, meta } = contextOf(request);\n // No code: a passkey step-up in this session stands in for it.\n const codes = await auth.regenerateRecoveryCodes(\n authenticated,\n optionalText(bodyOf(request), \"code\", MAX_CODE) ?? \"\",\n meta,\n );\n\n return { codes };\n });\n\n server.post(\"/api/account/passkey/options\", passkeyOptions);\n server.post(\"/api/account/passkey/verify\", passkeyVerify);\n\n server.delete(\"/api/account/passkeys/:id\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.removePasskey(authenticated, idParam(request), meta, currentOf(request));\n\n return reply.code(204).send();\n });\n\n // ---- Admin ---------------------------------------------------------------\n\n server.get(\"/api/admin/users\", async (request) => {\n const { auth: authenticated } = contextOf(request);\n\n return auth.listUsers(authenticated);\n });\n\n server.post(\"/api/admin/invites\", async (request) => {\n const { auth: authenticated, meta } = contextOf(request);\n const body = bodyOf(request);\n\n return auth.createInvite(authenticated, { email: email(body), role: role(body) }, meta);\n });\n\n server.delete(\"/api/admin/invites/:id\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.revokeInvite(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.patch(\"/api/admin/users/:id\", async (request) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n return auth.setRole(authenticated, idParam(request), role(bodyOf(request)), meta);\n });\n\n server.delete(\"/api/admin/users/:id\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.removeAccount(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.post(\"/api/admin/users/:id/reset-mfa\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.resetSecondFactor(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.post(\"/api/admin/users/:id/sign-out\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n await auth.signOutAccount(authenticated, idParam(request), meta);\n\n return reply.code(204).send();\n });\n\n server.get<{ Querystring: Record<string, string | undefined> }>(\n \"/api/admin/audit\",\n async (request) => {\n const { auth: authenticated } = contextOf(request);\n\n requireAdmin(authenticated);\n\n const query = request.query;\n const types = query.type\n ?.split(\",\")\n .map((type) => type.trim())\n .filter((type) => type !== \"\");\n const before = query.before === undefined ? undefined : Number(query.before);\n const limit = query.limit === undefined ? 100 : Number(query.limit);\n\n if (\n (before !== undefined && !Number.isFinite(before)) ||\n !Number.isInteger(limit) ||\n limit < 1\n ) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n return store.audit.list({\n ...(types && types.length > 0 ? { types: types as DevtoolsAuditType[] } : {}),\n ...(query.account ? { accountId: query.account } : {}),\n ...(before === undefined ? {} : { before }),\n limit: Math.min(limit, 500),\n });\n },\n );\n\n server.post(\"/api/admin/disable\", async (request, reply) => {\n const { auth: authenticated, meta } = contextOf(request);\n\n if (bodyOf(request).confirm !== \"disable\") throw new DevtoolsApiError(\"input.invalid\");\n\n await auth.disableDashboard(authenticated, meta);\n // This process closes at once; the others within the state cache time.\n state.invalidate();\n\n return reply.code(204).send();\n });\n}\n","/** Headers on every dashboard answer that is not the uniform 404. */\nexport const DASHBOARD_HEADERS: Readonly<Record<string, string>> = {\n \"Cache-Control\": \"no-store\",\n \"X-Robots-Tag\": \"noindex, nofollow, noarchive\",\n \"Referrer-Policy\": \"no-referrer\",\n \"X-Content-Type-Options\": \"nosniff\",\n \"X-Frame-Options\": \"DENY\",\n \"Cross-Origin-Opener-Policy\": \"same-origin\",\n \"Cross-Origin-Resource-Policy\": \"same-origin\",\n \"Permissions-Policy\":\n \"camera=(), microphone=(), geolocation=(), publickey-credentials-get=(self), publickey-credentials-create=(self)\",\n};\n\n/** The policy of the dashboard's own HTML: scripts and styles from the bundle only. */\nexport const DASHBOARD_CSP =\n \"default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; frame-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; object-src 'none'\";\n\n/**\n * The policy of the opt-in API documentation pages: scripts from the dashboard\n * only (Scalar and Swagger UI probe `Function` in a try/catch and work without\n * `'unsafe-eval'`), inline styles, and framing by the dashboard itself, whose\n * API tab shows them in a frame.\n */\nexport const DOCS_CSP =\n \"default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'self'; base-uri 'none'; form-action 'self'; object-src 'none'\";\n","import { createHash } from \"node:crypto\";\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport { listPanelInfos } from \"../../panels\";\nimport { registerAiRoutes } from \"../../server/ai-routes\";\nimport { registerShapeExplainRoute } from \"../../server/explain-route\";\nimport { registerInsightsRoutes } from \"../../server/insights-routes\";\nimport { registerLogRoutes } from \"../../server/log-routes\";\nimport { registerMailRoutes } from \"../../server/mail-routes\";\nimport { registerOpenApiRoutes } from \"../../server/openapi-routes\";\nimport { registerPanelRoutes } from \"../../server/panel-routes\";\nimport { registerRequestsRoutes } from \"../../server/requests-routes\";\nimport { registerRouteRoutes } from \"../../server/route-routes\";\nimport { registerStreamRoute } from \"../../server/stream-route\";\nimport type { DevtoolsStreamSession, MountDevtoolsRoutesDeps } from \"../../server/types\";\nimport { registerUiAssets } from \"../../server/ui-assets\";\nimport type { DevtoolsAuthenticated, DevtoolsRequestMeta } from \"../auth/types\";\nimport { DevtoolsApiError, createErrorRef, DEVTOOLS_ERROR_MESSAGES } from \"../errors\";\nimport { createAccessLookup, productionRouteAccess } from \"./access\";\nimport { registerAuthRoutes } from \"./auth-routes\";\nimport { resolveClient } from \"./client\";\nimport { setDevtoolsRequestContext, devtoolsRequestContext } from \"./context\";\nimport { readCookie, sessionCookieName } from \"./cookie\";\nimport { DASHBOARD_CSP, DASHBOARD_HEADERS, DOCS_CSP } from \"./headers\";\nimport { DEVTOOLS_CSRF_HEADER } from \"./constants\";\nimport { ipMatches } from \"./ip\";\nimport type { DevtoolsRouteAccess, MountProductionDevtoolsDeps } from \"./types\";\n\n/** Open live streams a session may hold, and an instance may serve. */\nconst MAX_STREAMS_PER_SESSION = 3;\nconst MAX_STREAMS_PER_INSTANCE = 50;\n\nconst MAX_USER_AGENT = 200;\n\n/** Methods that never change state. */\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\n/** The routes of the opt-in API documentation pages (they keep a CSP of their own). */\nconst DOCS_PATTERNS = new Set([\"/docs\", \"/docs/swagger\"]);\n\n/** The mail preview's HTML: framed by the dashboard, with a policy of its own. */\nconst MAIL_HTML_PATTERN = \"/api/mails/:id/html\";\n\n/** Which tab a route belongs to: a route of a tab that is off answers the uniform 404. */\nconst TAB_OF_ROUTE: readonly (readonly [prefix: string, tab: string])[] = [\n [\"/api/resources\", \"resources\"],\n [\"/api/queries\", \"queries\"],\n [\"/api/routes/stats\", \"routes\"],\n [\"/api/routes\", \"routes\"],\n [\"/api/health\", \"health\"],\n [\"/api/errors\", \"errors\"],\n [\"/api/jobs\", \"jobs\"],\n [\"/api/logs\", \"logs\"],\n [\"/api/requests\", \"requests\"],\n [\"/api/mails\", \"mail\"],\n [\"/api/ai/agent-runs\", \"agents\"],\n [\"/api/ai\", \"ai\"],\n [\"/api/openapi.json\", \"api\"],\n [\"/api/postman.json\", \"api\"],\n [\"/docs\", \"api\"],\n];\n\nfunction tabOf(pattern: string): string | undefined {\n return TAB_OF_ROUTE.find(\n ([prefix]) => pattern === prefix || pattern.startsWith(`${prefix}/`),\n )?.[1];\n}\n\nfunction tokenHash(token: string): string {\n return createHash(\"sha256\").update(token).digest(\"hex\");\n}\n\n/** Requests that were answered with the uniform 404: they get none of the dashboard's headers. */\nconst uniformNotFound = new WeakSet<FastifyRequest>();\n\n/**\n * The origin the browser must send for an unsafe request: `production.origin`,\n * else the scheme and host the request was addressed to.\n */\nfunction originAllowed(request: FastifyRequest, expected: string): boolean {\n const origin = request.headers.origin;\n const site = request.headers[\"sec-fetch-site\"];\n\n if (site !== undefined && site !== \"same-origin\") return false;\n\n if (origin !== undefined) return origin.toLowerCase() === expected.toLowerCase();\n\n // No Origin header: a same-origin fetch from an older browser. Accept it only with the fetch metadata that proves it.\n return site === \"same-origin\";\n}\n\nfunction hasBody(request: FastifyRequest): boolean {\n const length = request.headers[\"content-length\"];\n\n return (\n (length !== undefined && length !== \"0\") || request.headers[\"transfer-encoding\"] !== undefined\n );\n}\n\nfunction isJson(request: FastifyRequest): boolean {\n return /^application\\/json\\s*(;|$)/i.test(request.headers[\"content-type\"] ?? \"\");\n}\n\nfunction sessionAccessOk(\n access: Exclude<DevtoolsRouteAccess, { type: \"public\" }>,\n stage: string,\n): boolean {\n if (stage === \"active\") return true;\n\n return access.type === \"pending\" && (access.stages as readonly string[]).includes(stage);\n}\n\n/**\n * Mounts the production monitor under `production.path` in one encapsulated\n * Fastify context: the gate (uniform 404, HTTPS, allowed IPs, open state),\n * session and role checks from the access table, CSRF and origin checks,\n * security headers and CORS stripping, the auth/account/admin routes, and\n * the shared data routes of the enabled tabs.\n */\nexport function mountProductionDevtools(\n server: FastifyInstance,\n deps: MountProductionDevtoolsDeps,\n): void {\n const { production, auth, state, store } = deps;\n const prefix = production.path;\n const cookieName = sessionCookieName(production.requireHttps);\n const enabledTabs = new Set(deps.builtInPanels);\n const lookup = createAccessLookup(productionRouteAccess(deps.panels.map((panel) => panel.id)));\n const streamsPerSession = new Map<string, number>();\n let streamsInstance = 0;\n let lastWarningAt = 0;\n\n const warn = (message: string): void => {\n // At most one line a minute: a database outage must not flood the log.\n const now = Date.now();\n\n if (now - lastWarningAt < 60_000) return;\n\n lastWarningAt = now;\n deps.warn?.(message);\n };\n\n const notFound = (request: FastifyRequest, reply: FastifyReply): FastifyReply => {\n uniformNotFound.add(request);\n\n // The app's own not-found handler answers, so the reply is the one any unknown URL gets.\n reply.callNotFound();\n\n // Returning the reply is what stops an async hook's lifecycle.\n return reply;\n };\n\n const streamSession = async (request: FastifyRequest): Promise<DevtoolsStreamSession> => {\n const authenticated = devtoolsRequestContext(request)?.authenticated;\n\n if (!authenticated) throw new Error(\"A dashboard stream was opened without a session.\");\n\n const sessionId = authenticated.session.id;\n const token = readCookie(request.headers.cookie, cookieName);\n const open = streamsPerSession.get(sessionId) ?? 0;\n\n if (open >= MAX_STREAMS_PER_SESSION || streamsInstance >= MAX_STREAMS_PER_INSTANCE) {\n throw new DevtoolsApiError(\"stream.too-many\");\n }\n\n streamsPerSession.set(sessionId, open + 1);\n streamsInstance += 1;\n\n let released = false;\n\n return {\n role: authenticated.account.role,\n logLevels: production.logLevels,\n headers: DASHBOARD_HEADERS,\n // Reads the session without touching `lastSeenAt`: a stream left open must not keep the session alive.\n async revalidate() {\n if (token === undefined || !(await state.isOpen())) return false;\n\n const session = await store.sessions.findByTokenHash(tokenHash(token));\n const now = Date.now();\n\n if (\n session === null ||\n session.stage !== \"active\" ||\n now >= session.expiresAt ||\n now - session.lastSeenAt >= production.session.idleMinutes * 60_000\n ) {\n return false;\n }\n\n return (await store.accounts.findById(session.accountId)) !== null;\n },\n release() {\n if (released) return;\n\n released = true;\n streamsInstance -= 1;\n\n const left = (streamsPerSession.get(sessionId) ?? 1) - 1;\n\n if (left <= 0) streamsPerSession.delete(sessionId);\n else streamsPerSession.set(sessionId, left);\n },\n };\n };\n\n // The route deps the shared route files read: the development deps, completed.\n const routes: MountDevtoolsRoutesDeps = {\n ...deps.routes,\n mode: \"production\",\n isDevelopment: () => false,\n instance: deps.instance,\n insights: deps.insights,\n collector: deps.routes.collector ?? deps.capture.collector,\n requests: deps.routes.requests ?? deps.capture.requests,\n explainShape: deps.routes.explainShape ?? ((shapeId) => deps.capture.explain(shapeId)),\n builtInPanels: deps.builtInPanels,\n streamSession,\n };\n\n server.register(\n async (instance) => {\n // ---- The gate -------------------------------------------------------\n instance.addHook(\"onRequest\", async (request, reply) => {\n let open: boolean;\n\n try {\n open = await state.isOpen();\n } catch (error) {\n // Fail closed: when the state cannot be read the dashboard does not answer.\n warn(\n `The devtools dashboard state could not be read and the dashboard is closed: ${error instanceof Error ? error.message : String(error)}`,\n );\n open = false;\n }\n\n if (!open) return notFound(request, reply);\n\n const client = resolveClient(request, production.trustedProxies);\n\n if (production.requireHttps && client.proto !== \"https\") return notFound(request, reply);\n\n if (production.allowedIps.length > 0 && !ipMatches(client.ip, production.allowedIps)) {\n return notFound(request, reply);\n }\n\n const userAgent = request.headers[\"user-agent\"];\n const expectedOrigin = production.origin ?? `${client.proto}://${client.host}`;\n const meta: DevtoolsRequestMeta = {\n ip: client.ip,\n userAgent: typeof userAgent === \"string\" ? userAgent.slice(0, MAX_USER_AGENT) : null,\n origin: expectedOrigin,\n hostname: client.hostname,\n };\n\n const routeUrl = request.routeOptions.url ?? \"\";\n const relative = routeUrl.startsWith(prefix) ? routeUrl.slice(prefix.length) : routeUrl;\n // The shell is registered once for both `<path>` and `<path>/`.\n const pattern = relative === \"\" ? \"/\" : relative;\n const method = request.method;\n\n // The bare path (no trailing slash) redirects to the shell's address. The\n // address as sent: core's server drops a trailing slash before routing,\n // so the rewritten URL of `<path>/` is the bare path too.\n const sent = request.originalUrl ?? request.raw.url ?? \"\";\n\n if (sent.split(\"?\")[0] === prefix) {\n setDevtoolsRequestContext(request, {\n client,\n meta,\n rule: undefined,\n pattern,\n authenticated: null,\n });\n\n if (method !== \"GET\" && method !== \"HEAD\") return notFound(request, reply);\n\n const search = sent.includes(\"?\") ? `?${sent.split(\"?\").slice(1).join(\"?\")}` : \"\";\n\n return reply.redirect(`${prefix}/${search}`, 308);\n }\n\n const tab = tabOf(pattern);\n\n if (tab !== undefined && !enabledTabs.has(tab)) return notFound(request, reply);\n\n const rule = lookup(method, pattern);\n const access: DevtoolsRouteAccess = rule?.access ?? { type: \"admin\" };\n let authenticated: DevtoolsAuthenticated | null = null;\n\n if (access.type !== \"public\") {\n try {\n authenticated = await auth.authenticate(readCookie(request.headers.cookie, cookieName));\n } catch (error) {\n warn(\n `The devtools session could not be checked and the request was refused: ${error instanceof Error ? error.message : String(error)}`,\n );\n\n return notFound(request, reply);\n }\n\n if (authenticated === null || !sessionAccessOk(access, authenticated.stage)) {\n return notFound(request, reply);\n }\n\n if (access.type === \"admin\" && authenticated.account.role !== \"admin\") {\n setDevtoolsRequestContext(request, { client, meta, rule, pattern, authenticated });\n throw new DevtoolsApiError(\"role.forbidden\");\n }\n }\n\n setDevtoolsRequestContext(request, { client, meta, rule, pattern, authenticated });\n\n if (SAFE_METHODS.has(method)) return;\n\n if (!originAllowed(request, expectedOrigin)) {\n if (authenticated === null) return notFound(request, reply);\n\n throw new DevtoolsApiError(\"csrf.invalid\");\n }\n\n if (hasBody(request) && !isJson(request)) throw new DevtoolsApiError(\"input.invalid\");\n\n if (authenticated !== null) {\n const header = request.headers[DEVTOOLS_CSRF_HEADER];\n\n if (!auth.verifyCsrf(authenticated, Array.isArray(header) ? header[0] : header)) {\n throw new DevtoolsApiError(\"csrf.invalid\");\n }\n }\n });\n\n // ---- Headers --------------------------------------------------------\n instance.addHook(\"onSend\", async (request, reply, payload) => {\n // The uniform 404 must look like any other 404 of the app.\n if (uniformNotFound.has(request)) return payload;\n\n for (const name of Object.keys(reply.getHeaders())) {\n if (name.startsWith(\"access-control-\")) reply.removeHeader(name);\n }\n\n reply.headers(DASHBOARD_HEADERS);\n\n const pattern = devtoolsRequestContext(request)?.pattern ?? \"\";\n\n // The mail preview is the one page the dashboard frames, from its own origin, and it sends its own policy.\n if (pattern === MAIL_HTML_PATTERN) {\n reply.header(\"X-Frame-Options\", \"SAMEORIGIN\");\n\n return payload;\n }\n\n // The API docs pages are shown in a frame by the dashboard's API tab.\n if (DOCS_PATTERNS.has(pattern)) reply.header(\"X-Frame-Options\", \"SAMEORIGIN\");\n\n // Always the dashboard's policy: the app's own (core's security headers set one on every response) is not\n // written for this page and must not replace it.\n if (String(reply.getHeader(\"content-type\") ?? \"\").startsWith(\"text/html\")) {\n reply.header(\n \"Content-Security-Policy\",\n DOCS_PATTERNS.has(pattern) ? DOCS_CSP : DASHBOARD_CSP,\n );\n }\n\n return payload;\n });\n\n // ---- Audit ----------------------------------------------------------\n instance.addHook(\"onResponse\", async (request, reply) => {\n const context = devtoolsRequestContext(request);\n const type = context?.rule?.audit;\n\n if (!context || !type || reply.statusCode < 200 || reply.statusCode > 299) return;\n\n const params = (request.params ?? {}) as Record<string, string | undefined>;\n const detail: Record<string, string | number | boolean | null> =\n type === \"explain.run\"\n ? { shapeId: params.shapeId ?? null }\n : type === \"panel.action\"\n ? {\n panel: context.pattern.split(\"/\")[2] ?? null,\n method: request.method,\n route: context.pattern,\n }\n : {};\n\n await auth.audit(type, { auth: context.authenticated, meta: context.meta, detail });\n });\n\n // ---- Errors ---------------------------------------------------------\n instance.setErrorHandler(\n (error: Error & { statusCode?: number; code?: string }, request, reply) => {\n if (error instanceof DevtoolsApiError) {\n return reply.code(error.statusCode).send(error.toBody());\n }\n\n const status = error.statusCode;\n\n // The request itself was wrong (bad JSON, too large): say so in the dashboard's own shape.\n if (status !== undefined && status >= 400 && status < 500) {\n return reply\n .code(status)\n .send(\n error.code?.startsWith(\"FST_ERR_\")\n ? new DevtoolsApiError(\"input.invalid\").toBody()\n : { error: error.message },\n );\n }\n\n const ref = createErrorRef();\n\n // Never rate limited: the reference the browser shows must always be findable in the log. The route is\n // written relative to the dashboard path, which never reaches the log.\n deps.warn?.(\n `Devtools dashboard error ${ref} on ${request.method} ${devtoolsRequestContext(request)?.pattern ?? \"(dashboard route)\"}: ${error.message}`,\n );\n request.log.error({ ref, err: error }, \"devtools dashboard error\");\n\n return reply.code(500).send({\n error: DEVTOOLS_ERROR_MESSAGES[\"server.error\"],\n code: \"server.error\",\n ref,\n });\n },\n );\n\n // ---- Routes ---------------------------------------------------------\n registerUiAssets(instance, { notFound });\n registerAuthRoutes(instance, deps);\n\n instance.get(\"/api/panels\", async () => listPanelInfos(deps.panels, deps.builtInPanels));\n\n registerRequestsRoutes(instance, routes);\n registerRouteRoutes(instance, routes);\n registerInsightsRoutes(instance, routes);\n registerLogRoutes(instance, routes);\n registerShapeExplainRoute(instance, routes);\n registerPanelRoutes(instance, deps.panels);\n\n if (enabledTabs.has(\"mail\")) registerMailRoutes(instance, routes);\n if (enabledTabs.has(\"ai\") || enabledTabs.has(\"agents\")) registerAiRoutes(instance, routes);\n if (enabledTabs.has(\"api\")) registerOpenApiRoutes(instance, routes);\n\n registerStreamRoute(instance, routes);\n },\n { prefix },\n );\n}\n","import { createHash } from \"node:crypto\";\nimport type { DevtoolsStore } from \"../store/types\";\nimport type { DevtoolsDashboardState } from \"./types\";\n\n/** SHA-256 hex of a dashboard path: what `disabledPathHash` holds. */\nexport function hashDashboardPath(path: string): string {\n return createHash(\"sha256\").update(path).digest(\"hex\");\n}\n\n/**\n * The open/closed state with a `ttlMs` cache (default 5000). Open means the\n * dashboard is not disabled for this path and not locked. A failed read is\n * not cached and rejects, so the caller can fail closed.\n */\nexport function createDashboardState(\n store: DevtoolsStore,\n path: string,\n options: { ttlMs?: number; now?: () => number } = {},\n): DevtoolsDashboardState {\n const ttlMs = options.ttlMs ?? 5000;\n const now = options.now ?? Date.now;\n const pathHash = hashDashboardPath(path);\n let cached: { open: boolean; at: number } | null = null;\n let pending: Promise<boolean> | null = null;\n let generation = 0;\n\n const read = async (): Promise<boolean> => {\n const started = generation;\n const state = await store.state.read();\n const at = now();\n const disabled = state.disabled && state.disabledPathHash === pathHash;\n const locked = state.lockedUntil !== null && state.lockedUntil > at;\n const open = !disabled && !locked;\n\n if (started === generation) cached = { open, at };\n\n return open;\n };\n\n return {\n async isOpen() {\n if (cached !== null && now() - cached.at < ttlMs) return cached.open;\n\n if (pending === null) {\n const current = read().finally(() => {\n if (pending === current) pending = null;\n });\n\n pending = current;\n }\n\n return pending;\n },\n invalidate() {\n generation += 1;\n cached = null;\n pending = null;\n },\n };\n}\n"],"mappings":";;;;;;;;AAIA,MAAM,SAA8B,EAAE,MAAM,SAAS;AACrD,MAAM,SAA8B,EAAE,MAAM,SAAS;AACrD,MAAM,QAA6B,EAAE,MAAM,QAAQ;AAEnD,MAAM,WAAW,GAAG,YACjB;CAAE,MAAM;CAAW;AAAO;AAE7B,MAAM,YAAY;CAAC;CAAmB;CAAa;AAAY;;;;;;;;AAS/D,SAAgB,sBAAsB,UAAwD;CAC5F,MAAM,QACJ,QACA,KACA,QACA,WAC6B;EAAE;EAAQ;EAAK;EAAQ,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;CAAG;CAElF,MAAM,QAAmC;EAEvC,KAAK,OAAO,KAAK,MAAM;EACvB,KAAK,OAAO,iBAAiB,MAAM;EACnC,KAAK,OAAO,qBAAqB,MAAM;EACvC,KAAK,QAAQ,mBAAmB,MAAM;EACtC,KAAK,QAAQ,mBAAmB,MAAM;EACtC,KAAK,QAAQ,4BAA4B,MAAM;EAC/C,KAAK,QAAQ,2BAA2B,MAAM;EAC9C,KAAK,QAAQ,sBAAsB,QAAQ,iBAAiB,CAAC;EAC7D,KAAK,QAAQ,wBAAwB,QAAQ,WAAW,CAAC;EACzD,KAAK,QAAQ,0BAA0B,QAAQ,WAAW,CAAC;EAC3D,KAAK,QAAQ,6BAA6B,QAAQ,aAAa,YAAY,CAAC;EAC5E,KAAK,QAAQ,4BAA4B,QAAQ,aAAa,YAAY,CAAC;EAC3E,KAAK,QAAQ,iBAAiB,QAAQ,YAAY,CAAC;EACnD,KAAK,QAAQ,oBAAoB,QAAQ,GAAG,SAAS,CAAC;EAGtD,KAAK,OAAO,eAAe,MAAM;EACjC,KAAK,OAAO,gBAAgB,MAAM;EAClC,KAAK,OAAO,yBAAyB,MAAM;EAC3C,KAAK,UAAU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KAAK,OAAO,OAAO,OAAO;GAEhE,IAAI,YAAY,MAAM;IACpB,MAAM,UAAU,KAAK,CAAC,CAAC,cAAc;KACnC,IAAI,YAAY,SAAS,UAAU;IACrC,CAAC;IAED,UAAU;GACZ;GAEA,OAAO;EACT;EACA,aAAa;GACX,cAAc;GACd,SAAS;GACT,UAAU;EACZ;CACF;AACF"}
|
package/cjs/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_src = require("./src-
|
|
2
|
+
const require_src = require("./src-UPtTCI2j.cjs");
|
|
3
3
|
|
|
4
|
+
exports.DEVTOOLS_PANEL_TOKENS = require_src.DEVTOOLS_PANEL_TOKENS;
|
|
4
5
|
exports.devtoolsConnector = require_src.devtoolsConnector;
|
|
@@ -119,6 +119,17 @@ function checkDevtoolsPanels(panels) {
|
|
|
119
119
|
const taken = /* @__PURE__ */ new Map();
|
|
120
120
|
return panels.map((panel) => checkDevtoolsPanel(panel, taken));
|
|
121
121
|
}
|
|
122
|
+
function isPlainObject(value) {
|
|
123
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
124
|
+
const prototype = Object.getPrototypeOf(value);
|
|
125
|
+
return prototype === Object.prototype || prototype === null;
|
|
126
|
+
}
|
|
127
|
+
/** What is wrong with a `[specifier, options]` entry, or `undefined` when it is valid. */
|
|
128
|
+
function tupleProblem(entry) {
|
|
129
|
+
if (entry.length !== 2) return `it has ${entry.length} item(s); use exactly [specifier, options]`;
|
|
130
|
+
if (typeof entry[0] !== "string" || entry[0] === "") return `its first item is ${JSON.stringify(entry[0])}; use the module specifier as a string`;
|
|
131
|
+
if (!isPlainObject(entry[1])) return `its second item is not a plain object; pass the options as { name: value }`;
|
|
132
|
+
}
|
|
122
133
|
/** The URL or specifier to import for a `panels` entry. */
|
|
123
134
|
function resolvePanelSpecifier(entry, root) {
|
|
124
135
|
if (entry.startsWith("./") || entry.startsWith("../") || node_path.default.isAbsolute(entry)) return (0, node_url.pathToFileURL)(node_path.default.resolve(root, entry)).href;
|
|
@@ -187,8 +198,9 @@ function resolveWithRequire(entry, root) {
|
|
|
187
198
|
}
|
|
188
199
|
}
|
|
189
200
|
/** The panels a module's default export describes. */
|
|
190
|
-
async function panelsOf(exported, root, mode) {
|
|
201
|
+
async function panelsOf(exported, root, mode, panelOptions = {}) {
|
|
191
202
|
const value = typeof exported === "function" ? await exported({
|
|
203
|
+
...panelOptions,
|
|
192
204
|
root,
|
|
193
205
|
mode
|
|
194
206
|
}) : exported;
|
|
@@ -212,13 +224,21 @@ async function loadDevtoolsPanels(entries, options) {
|
|
|
212
224
|
for (const entry of entries) {
|
|
213
225
|
let candidates;
|
|
214
226
|
try {
|
|
215
|
-
if (
|
|
216
|
-
const
|
|
227
|
+
if (Array.isArray(entry)) {
|
|
228
|
+
const problem = tupleProblem(entry);
|
|
229
|
+
if (problem !== void 0) {
|
|
230
|
+
options.warn(`Devtools panels entry ${JSON.stringify(entry)} is invalid: ${problem}. Example: ["@warlock.js/grimoire/devtools", { ttlMs: 60000 }]. The entry was not added.`);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (typeof entry === "string" || Array.isArray(entry)) {
|
|
235
|
+
const [specifier, panelOptions] = typeof entry === "string" ? [entry, void 0] : entry;
|
|
236
|
+
const module = await importModule(resolvePanelSpecifier(specifier, options.root));
|
|
217
237
|
if (module.default === void 0) throw new Error("the module has no default export");
|
|
218
|
-
candidates = await panelsOf(module.default, options.root, mode);
|
|
238
|
+
candidates = await panelsOf(module.default, options.root, mode, panelOptions);
|
|
219
239
|
} else candidates = [entry];
|
|
220
240
|
} catch (error) {
|
|
221
|
-
options.warn(`Devtools panel module "${String(entry)}" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools "panels" option.`);
|
|
241
|
+
options.warn(`Devtools panel module "${String(Array.isArray(entry) ? entry[0] : entry)}" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools "panels" option.`);
|
|
222
242
|
continue;
|
|
223
243
|
}
|
|
224
244
|
for (const candidate of candidates) try {
|
|
@@ -295,4 +315,4 @@ Object.defineProperty(exports, "productionPanels", {
|
|
|
295
315
|
return productionPanels;
|
|
296
316
|
}
|
|
297
317
|
});
|
|
298
|
-
//# sourceMappingURL=panels-
|
|
318
|
+
//# sourceMappingURL=panels-Rcmeitu3.cjs.map
|