theokit 0.56.0 → 0.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/dist/{actions-virtual-module-KJBCM7PP.js → actions-virtual-module-GMRXCAVN.js} +2 -2
- package/dist/{actions-virtual-module-3V7VG2YL.js → actions-virtual-module-XAWZOWSY.js} +3 -3
- package/dist/{agent-NLG77PFN.js → agent-LS7I3ZQB.js} +2 -2
- package/dist/{app-typed-client-ZO3VKJ3O.js → app-typed-client-NMKJ4DR7.js} +3 -3
- package/dist/{app-typed-client-XSXAORG6.js → app-typed-client-W74QO5LH.js} +2 -2
- package/dist/{build-4GQLIFTD.js → build-FHE72YXR.js} +4 -4
- package/dist/chunk-CLBJTDI6.js +189 -0
- package/dist/chunk-CLBJTDI6.js.map +1 -0
- package/dist/{chunk-XYVZJCZU.js → chunk-CMCEGW3B.js} +3 -3
- package/dist/{chunk-XYVZJCZU.js.map → chunk-CMCEGW3B.js.map} +1 -1
- package/dist/{chunk-MWWFXYW3.js → chunk-CTRVTBGY.js} +3 -3
- package/dist/chunk-CTRVTBGY.js.map +1 -0
- package/dist/{chunk-22ZZSUKD.js → chunk-G5JYB2LO.js} +2 -2
- package/dist/{chunk-5TPBOAAH.js → chunk-KEDRCI2L.js} +8 -8
- package/dist/{chunk-TUO2FE3S.js → chunk-NC2OPE22.js} +2 -2
- package/dist/{chunk-6PFF5HMY.js → chunk-OKDCBENR.js} +3 -3
- package/dist/{chunk-ZTIB4QSV.js → chunk-Q6HS3NFG.js} +6 -6
- package/dist/cli/index.js +6 -6
- package/dist/client/index.js +8 -5
- package/dist/client/index.js.map +1 -1
- package/dist/{dev-ZNTHPBBN.js → dev-WDKROZBS.js} +5 -5
- package/dist/index.js +2 -2
- package/dist/{internal-api-D76JZGSC.js → internal-api-732K3H75.js} +3 -3
- package/dist/{internal-api-JNX3MTIM.js → internal-api-EVJSGGO3.js} +2 -2
- package/dist/{mcp-IMY3NUCL.js → mcp-PBUCHHAS.js} +2 -2
- package/dist/{preview-K4NIQLAK.js → preview-VFIFKVP4.js} +3 -3
- package/dist/{server-boundary-NW6LNNGK.js → server-boundary-B6U4DRRH.js} +3 -3
- package/dist/{server-boundary-654WC5SA.js → server-boundary-QRVK3OIJ.js} +2 -2
- package/dist/{start-ONZXIWEG.js → start-UAMJ5TSC.js} +5 -5
- package/dist/vite-plugin/index.js +2 -2
- package/dist/{vite-plugin-UET2BUFW.js → vite-plugin-ABJIDKE6.js} +5 -5
- package/package.json +4 -4
- package/dist/chunk-MWWFXYW3.js.map +0 -1
- package/dist/chunk-VSLY4KB3.js +0 -46
- package/dist/chunk-VSLY4KB3.js.map +0 -1
- /package/dist/{actions-virtual-module-KJBCM7PP.js.map → actions-virtual-module-GMRXCAVN.js.map} +0 -0
- /package/dist/{actions-virtual-module-3V7VG2YL.js.map → actions-virtual-module-XAWZOWSY.js.map} +0 -0
- /package/dist/{agent-NLG77PFN.js.map → agent-LS7I3ZQB.js.map} +0 -0
- /package/dist/{app-typed-client-ZO3VKJ3O.js.map → app-typed-client-NMKJ4DR7.js.map} +0 -0
- /package/dist/{app-typed-client-XSXAORG6.js.map → app-typed-client-W74QO5LH.js.map} +0 -0
- /package/dist/{build-4GQLIFTD.js.map → build-FHE72YXR.js.map} +0 -0
- /package/dist/{chunk-22ZZSUKD.js.map → chunk-G5JYB2LO.js.map} +0 -0
- /package/dist/{chunk-5TPBOAAH.js.map → chunk-KEDRCI2L.js.map} +0 -0
- /package/dist/{chunk-TUO2FE3S.js.map → chunk-NC2OPE22.js.map} +0 -0
- /package/dist/{chunk-6PFF5HMY.js.map → chunk-OKDCBENR.js.map} +0 -0
- /package/dist/{chunk-ZTIB4QSV.js.map → chunk-Q6HS3NFG.js.map} +0 -0
- /package/dist/{dev-ZNTHPBBN.js.map → dev-WDKROZBS.js.map} +0 -0
- /package/dist/{internal-api-D76JZGSC.js.map → internal-api-732K3H75.js.map} +0 -0
- /package/dist/{internal-api-JNX3MTIM.js.map → internal-api-EVJSGGO3.js.map} +0 -0
- /package/dist/{mcp-IMY3NUCL.js.map → mcp-PBUCHHAS.js.map} +0 -0
- /package/dist/{preview-K4NIQLAK.js.map → preview-VFIFKVP4.js.map} +0 -0
- /package/dist/{server-boundary-NW6LNNGK.js.map → server-boundary-B6U4DRRH.js.map} +0 -0
- /package/dist/{server-boundary-654WC5SA.js.map → server-boundary-QRVK3OIJ.js.map} +0 -0
- /package/dist/{start-ONZXIWEG.js.map → start-UAMJ5TSC.js.map} +0 -0
- /package/dist/{vite-plugin-UET2BUFW.js.map → vite-plugin-ABJIDKE6.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-CMCEGW3B.js";
|
|
2
2
|
import "./chunk-M357ILK5.js";
|
|
3
3
|
import "./chunk-BPYMC7SU.js";
|
|
4
4
|
import "./chunk-IRQGAC4L.js";
|
|
@@ -234,4 +234,4 @@ export const actions = manifest
|
|
|
234
234
|
export {
|
|
235
235
|
actionsVirtualModule
|
|
236
236
|
};
|
|
237
|
-
//# sourceMappingURL=actions-virtual-module-
|
|
237
|
+
//# sourceMappingURL=actions-virtual-module-GMRXCAVN.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "tsx/esm";
|
|
3
|
-
import "./chunk-
|
|
3
|
+
import "./chunk-G5JYB2LO.js";
|
|
4
4
|
import "./chunk-35QIWOHT.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-CTRVTBGY.js";
|
|
6
6
|
import "./chunk-RPET332G.js";
|
|
7
7
|
import "./chunk-5VLP3GQ2.js";
|
|
8
8
|
import "./chunk-C27VRUVN.js";
|
|
@@ -218,4 +218,4 @@ export const actions = manifest
|
|
|
218
218
|
export {
|
|
219
219
|
actionsVirtualModule
|
|
220
220
|
};
|
|
221
|
-
//# sourceMappingURL=actions-virtual-module-
|
|
221
|
+
//# sourceMappingURL=actions-virtual-module-XAWZOWSY.js.map
|
|
@@ -3,7 +3,7 @@ import "tsx/esm";
|
|
|
3
3
|
import {
|
|
4
4
|
agentCommand,
|
|
5
5
|
createAgentSsrLoader
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NC2OPE22.js";
|
|
7
7
|
import "./chunk-35QIWOHT.js";
|
|
8
8
|
import "./chunk-5NNFO7R7.js";
|
|
9
9
|
import "./chunk-Z7CJHDLS.js";
|
|
@@ -12,4 +12,4 @@ export {
|
|
|
12
12
|
agentCommand,
|
|
13
13
|
createAgentSsrLoader
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=agent-
|
|
15
|
+
//# sourceMappingURL=agent-LS7I3ZQB.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "tsx/esm";
|
|
3
|
-
import "./chunk-
|
|
3
|
+
import "./chunk-G5JYB2LO.js";
|
|
4
4
|
import "./chunk-35QIWOHT.js";
|
|
5
5
|
import {
|
|
6
6
|
scanControllerModules
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CTRVTBGY.js";
|
|
8
8
|
import "./chunk-RPET332G.js";
|
|
9
9
|
import "./chunk-5VLP3GQ2.js";
|
|
10
10
|
import "./chunk-C27VRUVN.js";
|
|
@@ -411,4 +411,4 @@ export {
|
|
|
411
411
|
generateClientDts,
|
|
412
412
|
shouldReemitForFile
|
|
413
413
|
};
|
|
414
|
-
//# sourceMappingURL=app-typed-client-
|
|
414
|
+
//# sourceMappingURL=app-typed-client-NMKJ4DR7.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
scanControllerModules
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CMCEGW3B.js";
|
|
4
4
|
import "./chunk-M357ILK5.js";
|
|
5
5
|
import "./chunk-BPYMC7SU.js";
|
|
6
6
|
import "./chunk-IRQGAC4L.js";
|
|
@@ -427,4 +427,4 @@ export {
|
|
|
427
427
|
generateClientDts,
|
|
428
428
|
shouldReemitForFile
|
|
429
429
|
};
|
|
430
|
-
//# sourceMappingURL=app-typed-client-
|
|
430
|
+
//# sourceMappingURL=app-typed-client-W74QO5LH.js.map
|
|
@@ -3,7 +3,7 @@ import "tsx/esm";
|
|
|
3
3
|
import {
|
|
4
4
|
describeControllerArtifacts,
|
|
5
5
|
emitControllerArtifacts
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-CLBJTDI6.js";
|
|
7
7
|
import {
|
|
8
8
|
validateProjectStructure
|
|
9
9
|
} from "./chunk-GEQJAFSV.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
emitOpenApi,
|
|
15
15
|
loadRoutesForOpenApi
|
|
16
16
|
} from "./chunk-47VNWTL4.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-CTRVTBGY.js";
|
|
18
18
|
import "./chunk-C27VRUVN.js";
|
|
19
19
|
import "./chunk-7UZZHCRN.js";
|
|
20
20
|
import {
|
|
@@ -554,7 +554,7 @@ async function buildCommand(options) {
|
|
|
554
554
|
`);
|
|
555
555
|
}
|
|
556
556
|
async function runAdapterBuild(target, config, cwd) {
|
|
557
|
-
const { theoPluginAsync } = await import("./vite-plugin-
|
|
557
|
+
const { theoPluginAsync } = await import("./vite-plugin-ABJIDKE6.js");
|
|
558
558
|
const { default: react } = await import("@vitejs/plugin-react");
|
|
559
559
|
const ctx = {
|
|
560
560
|
// `react()` may return Plugin or Plugin[] depending on version; spread the
|
|
@@ -676,4 +676,4 @@ function relativize3(absPath, root) {
|
|
|
676
676
|
export {
|
|
677
677
|
buildCommand
|
|
678
678
|
};
|
|
679
|
-
//# sourceMappingURL=build-
|
|
679
|
+
//# sourceMappingURL=build-FHE72YXR.js.map
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "tsx/esm";
|
|
3
|
+
import {
|
|
4
|
+
findControllerFiles
|
|
5
|
+
} from "./chunk-CTRVTBGY.js";
|
|
6
|
+
|
|
7
|
+
// src/cli/commands/build/emit-controllers.ts
|
|
8
|
+
import "reflect-metadata";
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
10
|
+
import { basename, dirname, join, relative, resolve } from "path";
|
|
11
|
+
import { pathToFileURL } from "url";
|
|
12
|
+
import {
|
|
13
|
+
CONTROLLER_PREFIX,
|
|
14
|
+
ROUTE_METHODS,
|
|
15
|
+
USE_GUARDS,
|
|
16
|
+
getMeta,
|
|
17
|
+
isControllerClass,
|
|
18
|
+
transformControllerSource
|
|
19
|
+
} from "@theokit/http";
|
|
20
|
+
var CONTROLLER_MANIFEST_FILE = "controllers.json";
|
|
21
|
+
var CONTROLLER_OUT_DIR = "controllers";
|
|
22
|
+
function rewriteLocalImports(code, sourceFile) {
|
|
23
|
+
const fromDir = dirname(sourceFile);
|
|
24
|
+
return code.replace(
|
|
25
|
+
/(\bfrom\s*|\bimport\s*\(\s*)(['"])(\.[^'"]*)\2/g,
|
|
26
|
+
(whole, lead, quote, spec) => {
|
|
27
|
+
const resolved = resolve(fromDir, spec);
|
|
28
|
+
const onDisk = existingSourcePath(resolved);
|
|
29
|
+
if (onDisk === void 0) return whole;
|
|
30
|
+
return `${lead}${quote}${pathToFileURL(onDisk).href}${quote}`;
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function existingSourcePath(resolved) {
|
|
35
|
+
const withoutExt = resolved.replace(/\.(js|mjs|cjs)$/, "");
|
|
36
|
+
const candidates = [
|
|
37
|
+
...resolved === withoutExt ? [] : [`${withoutExt}.ts`, `${withoutExt}.tsx`, resolved],
|
|
38
|
+
...resolved === withoutExt ? [`${resolved}.ts`, `${resolved}.tsx`, `${resolved}.js`] : [],
|
|
39
|
+
join(withoutExt, "index.ts"),
|
|
40
|
+
join(withoutExt, "index.tsx"),
|
|
41
|
+
join(withoutExt, "index.js")
|
|
42
|
+
];
|
|
43
|
+
return candidates.find((c) => existsSync(c));
|
|
44
|
+
}
|
|
45
|
+
var SERVED_PREFIX = "api";
|
|
46
|
+
var UnreachableControllerPathError = class extends Error {
|
|
47
|
+
constructor(controller, declaredPath, file) {
|
|
48
|
+
super(
|
|
49
|
+
[
|
|
50
|
+
`${controller} declares \`@Controller('${declaredPath}')\`, which this runtime never routes to.`,
|
|
51
|
+
``,
|
|
52
|
+
` ${file}`,
|
|
53
|
+
``,
|
|
54
|
+
` Controller routes are served from a fall-through that runs only for URLs under`,
|
|
55
|
+
` \`/${SERVED_PREFIX}/\` \u2014 a file-route miss is what reaches it. A path outside that`,
|
|
56
|
+
` prefix compiles, emits, and then answers 404 for the life of the app.`,
|
|
57
|
+
``,
|
|
58
|
+
` Write it as:`,
|
|
59
|
+
``,
|
|
60
|
+
` @Controller('${SERVED_PREFIX}/${declaredPath.replace(/^\/+/, "")}')`,
|
|
61
|
+
``,
|
|
62
|
+
` Refused at build rather than left to 404, for the reason this module already refuses a`,
|
|
63
|
+
` compile error: shipping a route nothing can reach, with nothing pointing back at why.`
|
|
64
|
+
].join("\n")
|
|
65
|
+
);
|
|
66
|
+
this.controller = controller;
|
|
67
|
+
this.declaredPath = declaredPath;
|
|
68
|
+
this.file = file;
|
|
69
|
+
}
|
|
70
|
+
controller;
|
|
71
|
+
declaredPath;
|
|
72
|
+
file;
|
|
73
|
+
name = "UnreachableControllerPathError";
|
|
74
|
+
};
|
|
75
|
+
function isReachable(prefix) {
|
|
76
|
+
const segments = prefix.split("/").filter((s) => s.length > 0);
|
|
77
|
+
return segments[0] === SERVED_PREFIX;
|
|
78
|
+
}
|
|
79
|
+
function assertControllerPathsReachable(loaded) {
|
|
80
|
+
for (const { cls, sourceFile } of loaded) {
|
|
81
|
+
const meta = getMeta(CONTROLLER_PREFIX, cls);
|
|
82
|
+
const prefix = meta?.prefix ?? "";
|
|
83
|
+
if (isReachable(prefix)) continue;
|
|
84
|
+
throw new UnreachableControllerPathError(cls.name || "a controller", prefix, sourceFile);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
var PUBLIC_ROUTE_METADATA = "theokit:public";
|
|
88
|
+
var UndeclaredControllerAccessError = class extends Error {
|
|
89
|
+
constructor(controller, method, verb, file) {
|
|
90
|
+
super(
|
|
91
|
+
[
|
|
92
|
+
`${controller}.${method}() serves ${verb} and declares no access decision.`,
|
|
93
|
+
``,
|
|
94
|
+
` ${file}`,
|
|
95
|
+
``,
|
|
96
|
+
` A file route with no \`.policy\` fails this build for the same reason (ADR 0001): a route`,
|
|
97
|
+
` nobody thought about is the one that ships open. The decorator path now says the same.`,
|
|
98
|
+
``,
|
|
99
|
+
` Require a session:`,
|
|
100
|
+
``,
|
|
101
|
+
` @UseGuards(AuthGuard) // on the method, or on the @Controller to cover all of them`,
|
|
102
|
+
``,
|
|
103
|
+
` Or state that it is open on purpose \u2014 a health check, an OAuth callback:`,
|
|
104
|
+
``,
|
|
105
|
+
` @SetMetadata('${PUBLIC_ROUTE_METADATA}', true)`,
|
|
106
|
+
``,
|
|
107
|
+
` Both are declarations. What is refused is neither.`
|
|
108
|
+
].join("\n")
|
|
109
|
+
);
|
|
110
|
+
this.controller = controller;
|
|
111
|
+
this.method = method;
|
|
112
|
+
this.verb = verb;
|
|
113
|
+
this.file = file;
|
|
114
|
+
}
|
|
115
|
+
controller;
|
|
116
|
+
method;
|
|
117
|
+
verb;
|
|
118
|
+
file;
|
|
119
|
+
name = "UndeclaredControllerAccessError";
|
|
120
|
+
};
|
|
121
|
+
function assertControllerAccessDeclared(loaded) {
|
|
122
|
+
for (const { cls, sourceFile } of loaded) {
|
|
123
|
+
if (getMeta(USE_GUARDS, cls) !== void 0) continue;
|
|
124
|
+
if (Reflect.getMetadata(PUBLIC_ROUTE_METADATA, cls) === true) continue;
|
|
125
|
+
const routes = getMeta(ROUTE_METHODS, cls) ?? [];
|
|
126
|
+
for (const { verb, propertyKey } of routes) {
|
|
127
|
+
if (getMeta(USE_GUARDS, cls, propertyKey) !== void 0) continue;
|
|
128
|
+
if (Reflect.getMetadata(PUBLIC_ROUTE_METADATA, cls, propertyKey) === true) continue;
|
|
129
|
+
throw new UndeclaredControllerAccessError(
|
|
130
|
+
cls.name || "a controller",
|
|
131
|
+
propertyKey,
|
|
132
|
+
verb,
|
|
133
|
+
sourceFile
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function loadEmittedControllers(emitted) {
|
|
139
|
+
const out = [];
|
|
140
|
+
for (const { modulePath, sourceFile } of emitted) {
|
|
141
|
+
const url = `${pathToFileURL(modulePath).href}?t=${Date.now()}`;
|
|
142
|
+
const mod = await import(url);
|
|
143
|
+
for (const exported of Object.values(mod)) {
|
|
144
|
+
if (typeof exported !== "function" || !isControllerClass(exported)) continue;
|
|
145
|
+
out.push({ cls: exported, sourceFile });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
async function emitControllerArtifacts(opts) {
|
|
151
|
+
const controllersDir = resolve(opts.serverDir, CONTROLLER_OUT_DIR);
|
|
152
|
+
const files = findControllerFiles(controllersDir);
|
|
153
|
+
if (files.length === 0) return null;
|
|
154
|
+
const outDir = resolve(opts.distDir, CONTROLLER_OUT_DIR);
|
|
155
|
+
mkdirSync(outDir, { recursive: true });
|
|
156
|
+
const modules = [];
|
|
157
|
+
const emitted = [];
|
|
158
|
+
for (const file of files) {
|
|
159
|
+
const compiled = await transformControllerSource(readFileSync(file, "utf-8"), file);
|
|
160
|
+
const code = rewriteLocalImports(compiled, file);
|
|
161
|
+
const rel = relative(controllersDir, file).replace(/\.controller\.ts$/, ".controller.mjs");
|
|
162
|
+
const outPath = join(outDir, rel);
|
|
163
|
+
mkdirSync(dirname(outPath), { recursive: true });
|
|
164
|
+
writeFileSync(outPath, code);
|
|
165
|
+
modules.push(`${CONTROLLER_OUT_DIR}/${rel.split("\\").join("/")}`);
|
|
166
|
+
emitted.push({ modulePath: outPath, sourceFile: file });
|
|
167
|
+
}
|
|
168
|
+
const loaded = await loadEmittedControllers(emitted);
|
|
169
|
+
assertControllerPathsReachable(loaded);
|
|
170
|
+
assertControllerAccessDeclared(loaded);
|
|
171
|
+
const manifest = { version: 1, modules };
|
|
172
|
+
writeFileSync(
|
|
173
|
+
resolve(opts.distDir, CONTROLLER_MANIFEST_FILE),
|
|
174
|
+
JSON.stringify(manifest, null, 2) + "\n"
|
|
175
|
+
);
|
|
176
|
+
return manifest;
|
|
177
|
+
}
|
|
178
|
+
function describeControllerArtifacts(manifest) {
|
|
179
|
+
if (manifest === null) return "controllers: none";
|
|
180
|
+
const names = manifest.modules.map((m) => basename(m, ".mjs")).join(", ");
|
|
181
|
+
return `controllers: ${manifest.modules.length} compiled (${names})`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
CONTROLLER_MANIFEST_FILE,
|
|
186
|
+
emitControllerArtifacts,
|
|
187
|
+
describeControllerArtifacts
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=chunk-CLBJTDI6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/build/emit-controllers.ts"],"sourcesContent":["import 'reflect-metadata'\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { basename, dirname, join, relative, resolve } from 'node:path'\nimport { pathToFileURL } from 'node:url'\n\nimport {\n CONTROLLER_PREFIX,\n ROUTE_METHODS,\n USE_GUARDS,\n getMeta,\n isControllerClass,\n transformControllerSource,\n} from '@theokit/http'\n\nimport { findControllerFiles } from '../../../server/http/controller-dispatch.js'\n\n/**\n * theokit#123 — compile `server/controllers/**` into `dist` so production can serve them.\n *\n * ## Why production needed anything at all\n *\n * #122 made decorator controllers first-class in `theokit dev`, where a Vite `enforce:'pre'` swc\n * transform compiles them on the fly — parameter decorators (`@Body`/`@Param`/`@Query`) emit\n * metadata esbuild cannot produce. `theokit start` has no Vite and no transform, so an uncompiled\n * `.controller.ts` simply cannot load, and controller routes 404'd in production while working in\n * dev. That split is the whole issue.\n *\n * ## Why compile at BUILD time rather than load with swc at runtime\n *\n * `loadControllerWithSwc` would work in production and was the smaller diff. It is refused on\n * purpose: `@swc/core` is a peer dependency and a native binary, so that path makes every deployed\n * app carry a compiler it only needs once, and turns a missing optional peer into a runtime 404\n * instead of a build failure. Compilation belongs where the rest of the build already is — and it\n * is what the issue's root-cause note asks for.\n *\n * ## Why NOT in `generateManifest`\n *\n * ADR-5 keeps controllers out of the manifest, and that is preserved here: the manifest is the\n * deploy-adapter contract, and adding a parallel route source to it would ripple through every\n * adapter. This emits a SEPARATE artifact (`dist/controllers.json` + `dist/controllers/*.mjs`) that\n * only the Node start path reads. An adapter that knows nothing about controllers keeps working\n * exactly as before.\n */\n\n/** The build artifact `theokit start` reads to find compiled controllers. */\ninterface ControllerBuildManifest {\n version: 1\n /** Emitted module paths, relative to `distDir`, in scan order. */\n modules: string[]\n}\n\nexport const CONTROLLER_MANIFEST_FILE = 'controllers.json'\nconst CONTROLLER_OUT_DIR = 'controllers'\n\n/**\n * Compile every controller under `<serverDir>/controllers` into `<distDir>/controllers`.\n *\n * No controllers ⇒ **no artifact at all** (not an empty one). `theokit start` treats a missing\n * manifest as \"this app has no controllers\" and skips the whole branch, so a routes-only app pays\n * nothing and its `dist` is byte-identical to before — the ADR-5 posture, kept.\n */\n/**\n * Point a compiled controller's RELATIVE imports back at the app's own source tree.\n *\n * theokit#516 — controllers are compiled into `<distDir>/controllers` because parameter decorators\n * need metadata only swc emits. File routes are never compiled: in production `importUserModule`\n * loads them straight from the source, which is why THEIR relative imports resolve. A controller's\n * did not — `../auth/index.js` resolved from `dist`, where the app does not exist — so a controller\n * that imported anything of the app's worked under `theokit dev` and failed the build.\n *\n * Rewriting to an ABSOLUTE path into the source tree is the smallest fix that keeps one definition\n * of every module. The alternatives each cost more than they buy: copying the app's modules beside\n * the controller duplicates them, and bundling inlines them, so in both a module with state exists\n * twice and the two copies drift.\n *\n * The extension is mapped back to what is on disk. TypeScript source writes `./x.js` for `./x.ts`\n * (NodeNext), and the emitted module has to name the file that exists, since it is loaded by the\n * same `importUserModule` path a file route takes — `.ts` included.\n *\n * BARE specifiers are left exactly as written. `@theokit/http`, `zod` and every other package\n * resolve through `node_modules` from any directory, so rewriting them would replace something that\n * works with a path that pins a version.\n */\nfunction rewriteLocalImports(code: string, sourceFile: string): string {\n const fromDir = dirname(sourceFile)\n return code.replace(\n /(\\bfrom\\s*|\\bimport\\s*\\(\\s*)(['\"])(\\.[^'\"]*)\\2/g,\n (whole, lead: string, quote: string, spec: string) => {\n const resolved = resolve(fromDir, spec)\n const onDisk = existingSourcePath(resolved)\n if (onDisk === undefined) return whole\n return `${lead}${quote}${pathToFileURL(onDisk).href}${quote}`\n },\n )\n}\n\n/**\n * The file a compiled specifier names, as it exists on disk — or `undefined` when nothing does.\n *\n * `./x.js` may be `x.ts`, `x.tsx`, a literal `x.js`, or a directory holding `index.*`. Returning\n * `undefined` for the rest is deliberate: a specifier this cannot resolve is left UNCHANGED, so the\n * runtime reports the missing module by the name the author wrote. Substituting a guess would move\n * the error somewhere the author never typed.\n */\nfunction existingSourcePath(resolved: string): string | undefined {\n const withoutExt = resolved.replace(/\\.(js|mjs|cjs)$/, '')\n const candidates = [\n ...(resolved === withoutExt ? [] : [`${withoutExt}.ts`, `${withoutExt}.tsx`, resolved]),\n ...(resolved === withoutExt ? [`${resolved}.ts`, `${resolved}.tsx`, `${resolved}.js`] : []),\n join(withoutExt, 'index.ts'),\n join(withoutExt, 'index.tsx'),\n join(withoutExt, 'index.js'),\n ]\n return candidates.find((c) => existsSync(c))\n}\n\n/**\n * The URL prefix both runtimes gate the controller fall-through on.\n *\n * `start/handlers.ts` and `vite-plugin/api-middleware.ts` each return early unless the request URL\n * starts with `/api/`, so a controller declaring anything else describes a path that branch never\n * visits. Written here as a constant rather than a literal in the check, because the day that gate\n * moves this is the line that has to move with it.\n */\nconst SERVED_PREFIX = 'api'\n\n/**\n * A controller compiled successfully and mounted at a path the runtime never routes to.\n *\n * Its own class so a caller can tell it from a compile failure: the source is fine, the decorators\n * are fine, and the app would start — the route simply answers 404 forever. That is the failure\n * this module's docblock already refuses for compile errors, reached by a different road.\n *\n * Measured against `theokit@0.56.0`: `@Controller('probe')` built clean, emitted a module, wrote\n * the manifest, and `/api/probe` returned 404. `/probe` returned **200** — the SPA fallback serving\n * `index.html`, so the status code agreed with success while the body was a web page. A defect that\n * survives a status-code check is exactly the kind a build gate has to catch instead.\n */\nexport class UnreachableControllerPathError extends Error {\n override readonly name = 'UnreachableControllerPathError'\n constructor(\n readonly controller: string,\n readonly declaredPath: string,\n readonly file: string,\n ) {\n super(\n [\n `${controller} declares \\`@Controller('${declaredPath}')\\`, which this runtime never routes to.`,\n ``,\n ` ${file}`,\n ``,\n ` Controller routes are served from a fall-through that runs only for URLs under`,\n ` \\`/${SERVED_PREFIX}/\\` — a file-route miss is what reaches it. A path outside that`,\n ` prefix compiles, emits, and then answers 404 for the life of the app.`,\n ``,\n ` Write it as:`,\n ``,\n ` @Controller('${SERVED_PREFIX}/${declaredPath.replace(/^\\/+/, '')}')`,\n ``,\n ` Refused at build rather than left to 404, for the reason this module already refuses a`,\n ` compile error: shipping a route nothing can reach, with nothing pointing back at why.`,\n ].join('\\n'),\n )\n }\n}\n\n/**\n * Is `prefix` reachable from the served path?\n *\n * `'api'`, `'/api'`, `'api/x'` and `'/api/x'` are the same URL written four ways, so all four pass:\n * the gate is about reachability, not spelling. A prefix that merely STARTS with the letters —\n * `'apiary'` — is not, which is why the check is segment-wise rather than a `startsWith`.\n */\nfunction isReachable(prefix: string): boolean {\n const segments = prefix.split('/').filter((s) => s.length > 0)\n return segments[0] === SERVED_PREFIX\n}\n\n/**\n * Refuse any emitted controller whose declared path the runtime cannot route to.\n *\n * Reads the prefix off the COMPILED module rather than the source: the decorator metadata is what\n * the runtime will actually match on, and a regex over source text would disagree with it the first\n * time someone writes the prefix as anything other than a literal.\n */\nfunction assertControllerPathsReachable(\n loaded: readonly { cls: ControllerClass; sourceFile: string }[],\n): void {\n for (const { cls, sourceFile } of loaded) {\n const meta = getMeta<{ prefix?: string }>(CONTROLLER_PREFIX, cls)\n const prefix = meta?.prefix ?? ''\n if (isReachable(prefix)) continue\n throw new UnreachableControllerPathError(cls.name || 'a controller', prefix, sourceFile)\n }\n}\n\n/**\n * The metadata key an explicitly-open controller route sets.\n *\n * The counterpart of `'public'` on the file path, and it exists for the same routes: a health\n * check a load balancer calls with no session, an OAuth callback the provider redirects to.\n *\n * An app writes the STRING, not this constant: `@SetMetadata('theokit:public', true)`. The docblock\n * used to show `@SetMetadata(PUBLIC_ROUTE_METADATA, true)`, which no consumer can write — this\n * module lives under `cli/commands/build/` and no entry point reaches it. Exporting it so the\n * example became true would publish a new surface for a string that appears once per open route and\n * whose mistyping fails this very gate loudly, so the example is corrected instead. `@theokit/http`\n * already ships `SetMetadata`, so no new decorator is needed either (parsimony-ladder.md rung 4).\n *\n * It is an opt-out, never a default. A route that is open says so in the file, where review sees\n * it; a route nobody thought about is the one that ships open, which is the whole reason ADR 0001\n * made absence stop meaning open on the file path.\n */\nconst PUBLIC_ROUTE_METADATA = 'theokit:public'\n\n/**\n * A controller route that declares no access decision at all.\n *\n * Distinct from a guard REFUSING a request — that is the system working. This is a route where\n * nobody wrote down whether it should be reachable, which on the file path is a build failure and\n * on the decorator path was, until now, silence.\n *\n * Measured against theokit@0.56.0: a `@Controller` with no guard answered 200 to a request with no\n * session, while the file route it would replace answered 403, on the same server in the same\n * second. The mechanism was never missing — `@UseGuards` works and returns `403 FORBIDDEN`. Only\n * the refusal of absence was.\n */\nexport class UndeclaredControllerAccessError extends Error {\n override readonly name = 'UndeclaredControllerAccessError'\n constructor(\n readonly controller: string,\n readonly method: string,\n readonly verb: string,\n readonly file: string,\n ) {\n super(\n [\n `${controller}.${method}() serves ${verb} and declares no access decision.`,\n ``,\n ` ${file}`,\n ``,\n ` A file route with no \\`.policy\\` fails this build for the same reason (ADR 0001): a route`,\n ` nobody thought about is the one that ships open. The decorator path now says the same.`,\n ``,\n ` Require a session:`,\n ``,\n ` @UseGuards(AuthGuard) // on the method, or on the @Controller to cover all of them`,\n ``,\n ` Or state that it is open on purpose — a health check, an OAuth callback:`,\n ``,\n ` @SetMetadata('${PUBLIC_ROUTE_METADATA}', true)`,\n ``,\n ` Both are declarations. What is refused is neither.`,\n ].join('\\n'),\n )\n }\n}\n\n/**\n * Refuse any controller route whose access decision nobody wrote down.\n *\n * A guard on the CLASS covers every method under it, which is the shape most controllers want and\n * mirrors how `@UseGuards` already behaves at runtime — the gate must agree with the dispatcher or\n * it would refuse code that works.\n *\n * Read off the compiled module for the reason the prefix check is: decorator metadata is what the\n * runtime matches on. The per-method key lives on the CLASS with the property name, not on the\n * prototype and not on the descriptor — measured, after both of those returned `undefined`.\n */\nfunction assertControllerAccessDeclared(\n loaded: readonly { cls: ControllerClass; sourceFile: string }[],\n): void {\n for (const { cls, sourceFile } of loaded) {\n // Class level covers every method under it — for BOTH forms. A guard on the class already\n // behaves that way at runtime, and a controller whose routes are all open (a health group, an\n // OAuth callback group) must be declarable once for the same reason. Checking one at class\n // level and not the other would refuse code that is correct.\n if (getMeta<unknown[]>(USE_GUARDS, cls) !== undefined) continue\n if (Reflect.getMetadata(PUBLIC_ROUTE_METADATA, cls) === true) continue\n\n const routes = getMeta<{ verb: string; propertyKey: string }[]>(ROUTE_METHODS, cls) ?? []\n for (const { verb, propertyKey } of routes) {\n if (getMeta<unknown[]>(USE_GUARDS, cls, propertyKey) !== undefined) continue\n // `Reflect` directly, not `getMeta`: `@SetMetadata` writes through `Reflect.defineMetadata`\n // with the key as given, and `getMeta` is typed for the symbol keys this package defines.\n if (Reflect.getMetadata(PUBLIC_ROUTE_METADATA, cls, propertyKey) === true) continue\n throw new UndeclaredControllerAccessError(\n cls.name || 'a controller',\n propertyKey,\n verb,\n sourceFile,\n )\n }\n }\n}\n\n/**\n * Load every emitted controller class once, for both checks below.\n *\n * One pass rather than one per check: the alternative loads each module twice and doubles the\n * surface on which a stale import could fool a gate.\n *\n * The `?t=` is a cache-bust. `emitControllerArtifacts` runs once per build process today, so it\n * changes nothing now — it is here because these are SECURITY gates, and the failure mode if a\n * watch mode is ever added is one that reads metadata from a version of the file that no longer\n * exists and passes it. `parsimony-ladder.md` is explicit that security is not what the ladder\n * trims, and the cost is a query parameter.\n */\nasync function loadEmittedControllers(\n emitted: readonly { modulePath: string; sourceFile: string }[],\n): Promise<{ cls: ControllerClass; sourceFile: string }[]> {\n const out: { cls: ControllerClass; sourceFile: string }[] = []\n for (const { modulePath, sourceFile } of emitted) {\n const url = `${pathToFileURL(modulePath).href}?t=${Date.now()}`\n const mod: Record<string, unknown> = await import(url)\n for (const exported of Object.values(mod)) {\n if (typeof exported !== 'function' || !isControllerClass(exported)) continue\n out.push({ cls: exported as ControllerClass, sourceFile })\n }\n }\n return out\n}\n\n/** A class carrying `@Controller` metadata — narrowed once so both checks read the same shape. */\ntype ControllerClass = (new (...args: never[]) => unknown) & { name: string }\n\nexport async function emitControllerArtifacts(opts: {\n serverDir: string\n distDir: string\n}): Promise<ControllerBuildManifest | null> {\n const controllersDir = resolve(opts.serverDir, CONTROLLER_OUT_DIR)\n const files = findControllerFiles(controllersDir)\n if (files.length === 0) return null\n\n const outDir = resolve(opts.distDir, CONTROLLER_OUT_DIR)\n mkdirSync(outDir, { recursive: true })\n\n const modules: string[] = []\n const emitted: { modulePath: string; sourceFile: string }[] = []\n for (const file of files) {\n // Errors are NOT caught. A controller that fails to compile must fail the BUILD — swallowing it\n // here would ship an app whose routes 404 at runtime with nothing pointing back at the cause,\n // which is the exact failure mode this issue reports (error-handling.md § 2).\n const compiled = await transformControllerSource(readFileSync(file, 'utf-8'), file)\n const code = rewriteLocalImports(compiled, file)\n\n // Mirror the source tree under `dist/controllers` so two files with the same basename in\n // different folders cannot overwrite each other.\n const rel = relative(controllersDir, file).replace(/\\.controller\\.ts$/, '.controller.mjs')\n const outPath = join(outDir, rel)\n mkdirSync(dirname(outPath), { recursive: true })\n writeFileSync(outPath, code)\n modules.push(`${CONTROLLER_OUT_DIR}/${rel.split('\\\\').join('/')}`)\n emitted.push({ modulePath: outPath, sourceFile: file })\n }\n\n // AFTER writing, because reading the prefix means loading the compiled module — and a module that\n // failed to compile has already thrown above. Before the manifest, so a refused build leaves no\n // artifact claiming a route that does not answer.\n const loaded = await loadEmittedControllers(emitted)\n assertControllerPathsReachable(loaded)\n assertControllerAccessDeclared(loaded)\n\n const manifest: ControllerBuildManifest = { version: 1, modules }\n writeFileSync(\n resolve(opts.distDir, CONTROLLER_MANIFEST_FILE),\n JSON.stringify(manifest, null, 2) + '\\n',\n )\n return manifest\n}\n\n/** Human-facing summary for the build log (mirrors the cron/job emitters). */\nexport function describeControllerArtifacts(manifest: ControllerBuildManifest | null): string {\n if (manifest === null) return 'controllers: none'\n const names = manifest.modules.map((m) => basename(m, '.mjs')).join(', ')\n return `controllers: ${manifest.modules.length} compiled (${names})`\n}\n"],"mappings":";;;;;;;AAAA,OAAO;AAEP,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,UAAU,SAAS,MAAM,UAAU,eAAe;AAC3D,SAAS,qBAAqB;AAE9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAuCA,IAAM,2BAA2B;AACxC,IAAM,qBAAqB;AA+B3B,SAAS,oBAAoB,MAAc,YAA4B;AACrE,QAAM,UAAU,QAAQ,UAAU;AAClC,SAAO,KAAK;AAAA,IACV;AAAA,IACA,CAAC,OAAO,MAAc,OAAe,SAAiB;AACpD,YAAM,WAAW,QAAQ,SAAS,IAAI;AACtC,YAAM,SAAS,mBAAmB,QAAQ;AAC1C,UAAI,WAAW,OAAW,QAAO;AACjC,aAAO,GAAG,IAAI,GAAG,KAAK,GAAG,cAAc,MAAM,EAAE,IAAI,GAAG,KAAK;AAAA,IAC7D;AAA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AACA,SAAO;AACT;AAGO,SAAS,4BAA4B,UAAkD;AAC5F,MAAI,aAAa,KAAM,QAAO;AAC9B,QAAM,QAAQ,SAAS,QAAQ,IAAI,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,EAAE,KAAK,IAAI;AACxE,SAAO,gBAAgB,SAAS,QAAQ,MAAM,cAAc,KAAK;AACnE;","names":[]}
|
|
@@ -65,8 +65,8 @@ async function writeControllerResponse(res, response) {
|
|
|
65
65
|
const setCookies = response.headers.getSetCookie();
|
|
66
66
|
if (setCookies.length > 0) res.setHeader("Set-Cookie", setCookies);
|
|
67
67
|
res.writeHead(response.status, headersBag);
|
|
68
|
-
const body = response.body ? await response.
|
|
69
|
-
res.end(body
|
|
68
|
+
const body = response.body ? Buffer.from(await response.arrayBuffer()) : void 0;
|
|
69
|
+
res.end(body !== void 0 && body.length > 0 ? body : void 0);
|
|
70
70
|
}
|
|
71
71
|
async function dispatchControllerRequest(args) {
|
|
72
72
|
const { req, res, csrfMode, disallowed, requestId } = args;
|
|
@@ -108,4 +108,4 @@ export {
|
|
|
108
108
|
scanControllerModules,
|
|
109
109
|
dispatchControllerRequest
|
|
110
110
|
};
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
111
|
+
//# sourceMappingURL=chunk-CMCEGW3B.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/http/controller-dispatch.ts"],"mappings":";;;;;;;;;;AAIA,SAAS,mBAAgC;AAEzC,SAAS,YAAY;AAErB,SAAS,wBAAwB,yBAA0C;AAyB3E,IAAM,yBAAyB,oBAAI,IAAI,CAAC,QAAQ,OAAO,SAAS,QAAQ,CAAC;AAQlE,SAAS,oBAAoB,KAAuB;AACzD,QAAM,QAAkB,CAAC;AACzB,QAAM,OAAO,CAAC,YAA0B;AACtC,QAAI;AACJ,QAAI;AACF,gBAAU,YAAY,SAAS,EAAE,eAAe,KAAK,CAAC;AAAA,IACxD,QAAQ;AACN;AAAA,IACF;AACA,e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,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,WAAW,MAAM,WAAW,SAAS,UAAU;AACrD,MAAI,aAAa,KAAM,QAAO;AAC9B,QAAM,wBAAwB,KAAK,QAAQ;AAC3C,SAAO;AACT;","names":[]}
|
|
@@ -309,8 +309,8 @@ async function writeControllerResponse(res, response) {
|
|
|
309
309
|
const setCookies = response.headers.getSetCookie();
|
|
310
310
|
if (setCookies.length > 0) res.setHeader("Set-Cookie", setCookies);
|
|
311
311
|
res.writeHead(response.status, headersBag);
|
|
312
|
-
const body = response.body ? await response.
|
|
313
|
-
res.end(body
|
|
312
|
+
const body = response.body ? Buffer.from(await response.arrayBuffer()) : void 0;
|
|
313
|
+
res.end(body !== void 0 && body.length > 0 ? body : void 0);
|
|
314
314
|
}
|
|
315
315
|
async function dispatchControllerRequest(args) {
|
|
316
316
|
const { req, res, csrfMode, disallowed, requestId } = args;
|
|
@@ -361,4 +361,4 @@ export {
|
|
|
361
361
|
scanControllerModules,
|
|
362
362
|
dispatchControllerRequest
|
|
363
363
|
};
|
|
364
|
-
//# sourceMappingURL=chunk-
|
|
364
|
+
//# sourceMappingURL=chunk-CTRVTBGY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/contracts/client-safe-error.ts","../src/server/http/send-response.ts","../src/server/http/node-request.ts","../src/server/http/controller-dispatch.ts","../src/server/security/csrf-warn-dispatch.ts","../src/server/observability/audit-log.ts","../src/server/security/csrf.ts"],"sourcesContent":["import type { TheoErrorEnvelope } from './error-envelope.js'\n\n/**\n * What an error is allowed to tell the caller.\n *\n * Most error codes describe something the caller did and can fix, so their message is the useful\n * part of the response. An *internal* failure is the opposite: its message describes the server —\n * a connection string, an upstream host, a stack of internal names — and the caller can act on\n * none of it. In production it is redacted; in development it is exactly what makes the framework\n * debuggable, so it stays.\n *\n * This lives in one place because it was previously stated in two and missing from a third. The\n * Node runner redacted, the Web error builder redacted, and an exception escaping a Web handler\n * took a hand-built path that did neither — same route, same failure, more disclosure depending\n * on which transport served it. That is the \"one contract, three transports\" rule in\n * `rules/three-target-parity.md` being broken by duplication rather than by design.\n */\n\n/** Both spellings the codebase uses for \"this is our fault, and the detail is ours too\". */\nconst INTERNAL_CODES: ReadonlySet<string> = new Set(['INTERNAL_ERROR', 'INTERNAL_SERVER_ERROR'])\n\nconst GENERIC_INTERNAL_MESSAGE = 'Internal server error'\n\nfunction redacts(code: string): boolean {\n return INTERNAL_CODES.has(code) && process.env.NODE_ENV === 'production'\n}\n\n/** The message this code may carry to the caller. */\nexport function clientSafeErrorMessage(code: string, message: string): string {\n return redacts(code) ? GENERIC_INTERNAL_MESSAGE : message\n}\n\n/**\n * The envelope this code may carry to the caller.\n *\n * When it redacts, `cause`, `meta` and `ext` go with the message rather than being filtered\n * field by field: they exist to describe the failure, and the whole point is that this failure is\n * not describable to the caller. Keeping the code is what lets a client branch on it.\n */\nexport function clientSafeErrorEnvelope(envelope: TheoErrorEnvelope): TheoErrorEnvelope {\n if (!redacts(envelope.code)) return envelope\n return { code: envelope.code, message: GENERIC_INTERNAL_MESSAGE }\n}\n","import type { ServerResponse } from 'node:http'\n\nimport { clientSafeErrorMessage } from '../../core/contracts/client-safe-error.js'\nimport type { TheoTransformer } from '../transformer.js'\n\n/**\n * Canonical HTTP response helpers (T5.1 extraction).\n *\n * Moved out of execute.ts so request-pipeline stages (execute-stages.ts,\n * handle-request-error.ts, etc.) can depend on these helpers without\n * creating a cycle through execute.ts.\n *\n * Public surface re-exported from execute.ts for backward compat — every\n * existing caller of `sendError` / `sendJson` continues to work via the\n * `theokit/server` barrel.\n */\n\nexport function sendJson(\n res: ServerResponse,\n data: unknown,\n status = 200,\n transformer?: TheoTransformer,\n): void {\n // T1.2 — transformer-aware serialization. Default (no transformer) uses\n // JSON.stringify direct for backward compat.\n const body = transformer ? transformer.serialize(data) : JSON.stringify(data)\n res.writeHead(status, {\n 'Content-Type': 'application/json',\n 'Content-Length': Buffer.byteLength(body),\n })\n res.end(body)\n}\n\n/** Render anything that would end the log line as a visible escape, so one call logs one line. */\nfunction oneLine(value: string): string {\n return value.replace(/[\\r\\n]/g, '\\\\n')\n}\n\nexport interface SendErrorOptions {\n custom404Html?: string\n custom500Html?: string\n}\n\n/**\n * Canonical error response.\n *\n * T6.3 (PV-17): the positional 7-param signature is preserved for backward\n * compat. New call sites should use the options-bag form:\n *\n * sendError(res, { code, message, status, issues?, requestId?, options? })\n *\n * Both shapes resolve to the same implementation.\n */\nexport interface SendErrorInput {\n code: string\n message: string\n status: number\n issues?: unknown[]\n requestId?: string\n options?: SendErrorOptions\n}\n\nexport function sendError(res: ServerResponse, input: SendErrorInput): void\n/* eslint-disable-next-line max-params -- T6.3: positional overload preserved\n for backward compat (callers across cli/server still use positional). The\n options-bag overload above is the recommended path. */\nexport function sendError(\n res: ServerResponse,\n code: string,\n message: string,\n status: number,\n issues?: unknown[],\n requestId?: string,\n options?: SendErrorOptions,\n): void\n/* eslint-disable-next-line max-params -- delegates to two surface overloads above; the parameter\n count mirrors the back-compat contract, not internal complexity. The `complexity` half of this\n suppression went away when the redaction rule stopped being restated inline. */\nexport function sendError(\n res: ServerResponse,\n codeOrInput: string | SendErrorInput,\n message?: string,\n status?: number,\n issues?: unknown[],\n requestId?: string,\n options?: SendErrorOptions,\n): void {\n let code: string\n if (typeof codeOrInput === 'string') {\n code = codeOrInput\n message = message ?? ''\n status = status ?? 500\n } else {\n code = codeOrInput.code\n message = codeOrInput.message\n status = codeOrInput.status\n issues = codeOrInput.issues\n requestId = codeOrInput.requestId\n options = codeOrInput.options\n }\n const errorMessage = clientSafeErrorMessage(code, message)\n\n if (code === 'INTERNAL_ERROR') {\n // One log entry per call, whatever the message contains. An exception message can be built\n // from request data and can therefore carry a newline; unescaped, that lets a caller append\n // whatever lines it likes to the log — including a plausible entry attributed to something\n // else (CodeQL `js/log-injection`).\n console.error(`[${oneLine(requestId ?? 'no-id')}] ${oneLine(message)}`)\n }\n\n if (status === 404 && options?.custom404Html) {\n const body = options.custom404Html\n res.writeHead(404, {\n 'Content-Type': 'text/html; charset=utf-8',\n 'Content-Length': Buffer.byteLength(body),\n })\n res.end(body)\n return\n }\n if (status === 500 && options?.custom500Html) {\n const body = options.custom500Html\n res.writeHead(500, {\n 'Content-Type': 'text/html; charset=utf-8',\n 'Content-Length': Buffer.byteLength(body),\n })\n res.end(body)\n return\n }\n\n sendJson(\n res,\n {\n error: {\n code,\n message: errorMessage,\n ...(requestId ? { requestId } : {}),\n ...(issues ? { issues } : {}),\n },\n },\n status,\n )\n}\n\n/**\n * T5a.2 Phase G slice 4/N — Web-Standards response helpers.\n *\n * Mirror of `sendJson` + `sendError` for the Web `Request`/`Response`\n * shape. Returns a native `Response` directly instead of mutating a\n * `ServerResponse`.\n *\n * v1.0 § Phase G.\n *\n * **Difference vs IncomingMessage path:**\n * - No `Content-Length` set explicitly — the runtime computes it from\n * the body when needed. CF Workers / Bun / Deno all do this; setting\n * it manually risks conflict if the body is a stream rather than a\n * fixed string.\n * - Custom 404/500 HTML options preserved (same opts shape).\n * - `requestId` flows into the response body's error envelope AND\n * surfaces as `x-request-id` header (parity with handleWebRequestError\n * Phase G slice 3/N).\n */\nexport function buildJsonResponse(\n data: unknown,\n status = 200,\n transformer?: TheoTransformer,\n): Response {\n const body = transformer ? transformer.serialize(data) : JSON.stringify(data)\n return new Response(body, {\n status,\n headers: { 'content-type': 'application/json' },\n })\n}\n\nexport function buildErrorResponse(input: SendErrorInput): Response {\n const { code, message, status, issues, requestId, options } = input\n const errorMessage = clientSafeErrorMessage(code, message)\n\n if (code === 'INTERNAL_ERROR') {\n // One log entry per call, whatever the message contains. An exception message can be built\n // from request data and can therefore carry a newline; unescaped, that lets a caller append\n // whatever lines it likes to the log — including a plausible entry attributed to something\n // else (CodeQL `js/log-injection`).\n console.error(`[${oneLine(requestId ?? 'no-id')}] ${oneLine(message)}`)\n }\n\n const headers: Record<string, string> = {}\n if (requestId !== undefined) headers['x-request-id'] = requestId\n\n if (status === 404 && options?.custom404Html !== undefined) {\n headers['content-type'] = 'text/html; charset=utf-8'\n return new Response(options.custom404Html, { status: 404, headers })\n }\n if (status === 500 && options?.custom500Html !== undefined) {\n headers['content-type'] = 'text/html; charset=utf-8'\n return new Response(options.custom500Html, { status: 500, headers })\n }\n\n headers['content-type'] = 'application/json'\n const body = JSON.stringify({\n error: {\n code,\n message: errorMessage,\n ...(requestId ? { requestId } : {}),\n ...(issues ? { issues } : {}),\n },\n })\n return new Response(body, { status, headers })\n}\n","/**\n * Pure Node `IncomingMessage` → Web `Request` converters.\n *\n * Kept free of any dependency on `web-handler.js` / `execute*.js` so the\n * executor (`execute.ts`) can build the handler-facing Web `Request` without\n * pulling the Web dispatch pipeline into its import graph (ADR-0028 R3a — the\n * Node adapter is the ONLY place IncomingMessage ↔ Request conversion lives;\n * these are the primitive converters it and the executor share).\n */\nimport type { IncomingMessage } from 'node:http'\nimport { Readable } from 'node:stream'\n\n/** Pick the first usable string from Node's `string | string[] | undefined` headers. */\nfunction pickHeaderString(value: string | string[] | undefined): string | undefined {\n if (typeof value === 'string') return value\n if (Array.isArray(value)) {\n for (const v of value) if (typeof v === 'string' && v.length > 0) return v\n }\n return undefined\n}\n\n/** Web Request requires an absolute URL; synthesize one from the Host header. */\nfunction synthesizeAbsoluteUrl(req: IncomingMessage): string {\n const host = pickHeaderString(req.headers.host) ?? 'localhost'\n return `http://${host}${req.url ?? '/'}`\n}\n\n/**\n * Collapse Node's `string | string[]` headers into a Web `Headers`. Repeated\n * headers are comma-joined (not `.append`ed) because `Headers.append` creates\n * multi-value entries that behave differently on `.get()` (EC-1).\n */\nfunction nodeHeadersToWeb(req: IncomingMessage): Headers {\n const headers = new Headers()\n for (const [key, value] of Object.entries(req.headers)) {\n if (value === undefined) continue\n if (Array.isArray(value)) {\n headers.set(key, value.join(', '))\n } else {\n headers.set(key, value)\n }\n }\n return headers\n}\n\n/**\n * Build a Web `Request` from a Node `IncomingMessage`, body included. The Web\n * Request spec requires an absolute URL; we synthesize one from the Host header\n * (fallback `localhost` for test doubles).\n *\n * For methods with a body (POST/PUT/PATCH/DELETE), the Node Readable stream is\n * wrapped as a Web ReadableStream via `Readable.toWeb()` so downstream consumers\n * can call `request.json()` / `request.formData()` / `request.text()` natively.\n */\nexport function incomingMessageToWebRequest(req: IncomingMessage): Request {\n const url = synthesizeAbsoluteUrl(req)\n const headers = nodeHeadersToWeb(req)\n\n const method = (req.method ?? 'GET').toUpperCase()\n const hasBody = method !== 'GET' && method !== 'HEAD'\n\n if (!hasBody) {\n return new Request(url, { method, headers })\n }\n\n // Drain Node's Readable into a Web ReadableStream. `Readable.toWeb` is\n // available in Node 18+ (theokit's engines.node floor is 22+, so safe).\n const webStream = Readable.toWeb(req) as ReadableStream\n return new Request(url, {\n method,\n headers,\n body: webStream,\n // EC-2: Node 18+ requires `duplex: 'half'` when body is a stream.\n // The `RequestInit` type omits it (Web spec gap); cast accordingly.\n ...({ duplex: 'half' } as { duplex: 'half' }),\n })\n}\n\n/**\n * A Node request that has NOT been converted yet — method now, body only if someone claims it.\n *\n * theokit#400. `incomingMessageToWebRequest` drains the Node stream, and a stream drains once. A\n * dispatcher that converts in order to decide whether it owns a path has already spent the body on\n * every path it does not own: the next branch attaches to a readable that has already ended, waits\n * for an `'end'` that cannot fire twice, and the request hangs with no status at all.\n *\n * The fix is an ordering one, so the type encodes the ordering: a router reads `method` (free) and\n * calls `toRequest()` only after it has decided the request is its own. Passing the source instead\n * of a `Request` is what makes \"did you convert before deciding?\" answerable by reading a signature.\n *\n * `toRequest()` memoizes, because a second conversion of the same `IncomingMessage` yields a\n * Request whose body is an empty closed stream — a silent truncation, which is worse than the hang\n * it would replace.\n */\nexport interface WebRequestSource {\n /** Uppercase HTTP method. Available without touching the body. */\n readonly method: string\n /** Convert on demand. Idempotent: repeated calls return the same `Request`. */\n toRequest: () => Request\n}\n\n/** Wrap `req` as a {@link WebRequestSource} — the conversion is deferred and memoized. */\nexport function createWebRequestSource(req: IncomingMessage): WebRequestSource {\n let converted: Request | undefined\n return {\n method: (req.method ?? 'GET').toUpperCase(),\n toRequest: () => (converted ??= incomingMessageToWebRequest(req)),\n }\n}\n\n/**\n * Build the Web `Request` handed to a route handler as `ctx.request` in the\n * Node server path (dev + `theokit start`). Method + absolute URL + headers\n * only — NO body.\n *\n * Why no body: the Node executor parses the request body BEFORE the handler\n * runs and exposes the parsed value as `ctx.body` (the typed, documented body\n * API). By the time the handler is called the Node stream is already drained,\n * so re-wrapping it would yield an empty/closed stream. Handlers read the body\n * via `ctx.body`; `ctx.request` is for the Web-standard header/cookie/URL/method\n * surface (e.g. `createSessionManagerWeb.getSession(ctx.request)`).\n *\n * Per ADR-0028 R3a, handlers see a Web `Request` in every runtime — this closes\n * the gap where the Node path leaked the raw `IncomingMessage` (whose `.headers`\n * is a plain object, so `.headers.get(...)` threw for Web-standard consumers).\n */\nexport function incomingMessageToHandlerRequest(req: IncomingMessage): Request {\n return new Request(synthesizeAbsoluteUrl(req), {\n method: (req.method ?? 'GET').toUpperCase(),\n headers: nodeHeadersToWeb(req),\n })\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Controller files are walked from the developer's `serverDir/controllers`\n * (a build-time config path), never from HTTP input. No injection vector.\n */\nimport { readdirSync, type Dirent } from 'node:fs'\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport { join } from 'node:path'\n\nimport { createDecoratorHandler, isControllerClass, type ServeAgent } from '@theokit/http'\n\nimport { dispatchCsrfWarn } from '../security/csrf-warn-dispatch.js'\nimport { enforceCsrf, type DisallowedConfig } from '../security/csrf.js'\n\nimport { incomingMessageToWebRequest } from './node-request.js'\nimport { sendError } from './send-response.js'\n\n/** A decorator controller constructor (`@Controller` class). */\ntype ControllerClass = new (...args: never[]) => object\n\n/** Loads a controller module by absolute path. In dev this is Vite's `ssrLoadModule`\n * (the Task 1.1 swc transform has already compiled the parameter decorators); tests\n * inject `@theokit/http`'s `loadControllerWithSwc`. */\nexport type ControllerModuleLoader = (absPath: string) => Promise<Record<string, unknown>>\n\n/** A built controller route table exposed as a pure Web-Standard handler. */\ninterface ControllerDispatcher {\n /** `null` = no controller route matched — the host owns the miss (404 / fall-through). */\n dispatch(request: Request): Promise<Response | null>\n /** Non-executing route probe — true when a controller route owns `method` + `pathname`. */\n matches(method: string, pathname: string): boolean\n}\n\n// State-mutating methods get CSRF, mirroring the file-route pipeline (execute.ts).\nconst CSRF_PROTECTED_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE'])\n\n/** Recursively collect `*.controller.ts` files under `dir` (absolute paths). */\n/**\n * Every `*.controller.ts` under `dir`, recursively. Exported for theokit#123: the build emitter\n * must find exactly the same set the dev dispatcher does, and two independent walks would be two\n * definitions of \"a controller\" that drift.\n */\nexport function findControllerFiles(dir: string): string[] {\n const found: string[] = []\n const walk = (current: string): void => {\n let entries: Dirent[]\n try {\n entries = readdirSync(current, { withFileTypes: true })\n } catch {\n return // dir doesn't exist — no controllers\n }\n for (const entry of entries) {\n const full = join(current, entry.name)\n if (entry.isDirectory()) walk(full)\n // theokit#123 — `.mjs` alongside `.ts`. Dev walks the SOURCE tree; production walks the\n // COMPILED tree under `dist/controllers`, where the same files exist as `*.controller.mjs`.\n // One walk for both keeps a single definition of \"a controller file\"; two would drift, and a\n // file that counts in dev and not in production is exactly the dev/prod split this fixes.\n else if (entry.name.endsWith('.controller.ts') || entry.name.endsWith('.controller.mjs'))\n found.push(full)\n }\n }\n walk(dir)\n return found\n}\n\n/** A discovered controller: its source file + the loaded `@Controller` class. */\ninterface ControllerModule {\n filePath: string\n cls: ControllerClass\n /**\n * The module's full export namespace — theokit#124.\n *\n * Kept alongside the class because it is the ONLY place a `@Body(schema)` regains a name. The\n * schema on `WalkResult.bodySchema` is a runtime `z.ZodType` with no source identifier, but it is\n * the very object this module exported, so matching it back by reference identity recovers the\n * exported name the typed-client codegen needs to write `z.infer<typeof ...>`.\n *\n * Unused by the dispatch path, which needs only the class.\n */\n exports: Readonly<Record<string, unknown>>\n}\n\n/**\n * Load every `@Controller` class under `controllersDir` via the injected loader,\n * keeping each class paired with its source file (needed by the typed-client\n * codegen to emit `import type { X } from '<file>'`). Non-controller exports are\n * ignored (`isControllerClass` — reused from @theokit/http).\n */\nexport async function scanControllerModules(\n controllersDir: string,\n loadModule: ControllerModuleLoader,\n): Promise<ControllerModule[]> {\n const files = findControllerFiles(controllersDir)\n const modules: ControllerModule[] = []\n for (const filePath of files) {\n const mod = await loadModule(filePath)\n for (const exported of Object.values(mod)) {\n if (typeof exported === 'function' && isControllerClass(exported)) {\n modules.push({ filePath, cls: exported as ControllerClass, exports: mod })\n }\n }\n }\n return modules\n}\n\n/** Load every `@Controller` class under `controllersDir` (classes only). */\nasync function scanControllers(\n controllersDir: string,\n loadModule: ControllerModuleLoader,\n): Promise<ControllerClass[]> {\n const modules = await scanControllerModules(controllersDir, loadModule)\n return modules.map((m) => m.cls)\n}\n\n/**\n * Scan `controllersDir` and build a Web-Standard dispatcher over the decorator\n * controllers found. Returns `null` when the directory has no controllers, so\n * the host can skip the controller path entirely (zero cost for routes-only apps).\n *\n * Dispatch REUSES @theokit/http's `createDecoratorHandler` (match + `@Param`\n * binding + `@Body` validation + Response building) — never re-implemented (ADR-1).\n */\nexport async function createControllerDispatcher(opts: {\n controllersDir: string\n loadModule: ControllerModuleLoader\n /** M47 — serves `@Expose`-bound agent routes (theo supplies a `mountAgent`-backed impl). */\n serveAgent?: ServeAgent\n}): Promise<ControllerDispatcher | null> {\n const classes = await scanControllers(opts.controllersDir, opts.loadModule)\n if (classes.length === 0) return null\n const handle = createDecoratorHandler({ controllers: classes, serveAgent: opts.serveAgent })\n return {\n dispatch: (request) => handle(request),\n matches: (method, pathname) => handle.matches(method, pathname),\n }\n}\n\n/**\n * Write a controller's Web `Response` to a Node response, byte for byte.\n *\n * The body used to be read with `await response.text()`, under a comment asserting that controllers\n * never stream. The comment was true of this path and hid the real problem: `text()` decodes as\n * UTF-8, so every byte >= 0x80 became `U+FFFD`. A payload of all 256 byte values arrived as 512\n * bytes; a 55 296-byte MPEG from `@theokit/plugin-voice` arrived as 76 790 bytes beginning\n * `ef bf bd`. Status 200, correct content-type, plausible length — invisible until someone opens\n * the file. File routes were never affected: `executeRoute` pumps the stream, so this was a silent\n * divergence between two paths meant to be at parity.\n *\n * `arrayBuffer()` fixes it without changing anything else. This path stays BUFFERED, exactly as\n * before — a controller returning a streamed body still has it collected here, so a plugin that\n * promises progressive delivery does not get it through a controller. That is a real limitation and\n * a separate change: making it stream alters when bytes reach the client, which is behaviour beyond\n * the corruption this repairs.\n */\nasync function writeControllerResponse(res: ServerResponse, response: Response): Promise<void> {\n const headersBag: Record<string, string> = {}\n for (const [k, v] of response.headers) {\n if (k.toLowerCase() !== 'set-cookie') headersBag[k] = v\n }\n const setCookies = response.headers.getSetCookie()\n if (setCookies.length > 0) res.setHeader('Set-Cookie', setCookies)\n res.writeHead(response.status, headersBag)\n // `Buffer.from(ArrayBuffer)` views the bytes as they are. Any string in between is a decode, and\n // a decode of arbitrary bytes is a loss.\n const body = response.body ? Buffer.from(await response.arrayBuffer()) : undefined\n res.end(body !== undefined && body.length > 0 ? body : undefined)\n}\n\n/**\n * The `api-middleware` fall-through in one call: scan `controllersDir`, build the\n * dispatcher, and serve the request. Builds a body-ful Web `Request` (`@Body`\n * needs the body; the raw stream is undrained at a route miss) and enforces CSRF\n * with the SAME gate file routes use (parity). Returns `true` when a controller\n * handled it (or CSRF blocked it), `false` when there are no controllers OR none\n * matched (the host continues to its own 404). Built per-miss so controller edits\n * reflect via HMR.\n */\nexport async function dispatchControllerRequest(args: {\n controllersDir: string\n loadModule: ControllerModuleLoader\n req: IncomingMessage\n res: ServerResponse\n csrfMode: 'off' | 'warn' | 'strict'\n disallowed?: DisallowedConfig\n requestId: string\n /** M47 — serves `@Expose`-bound agent routes (mountAgent-backed); omit for routes-only apps. */\n serveAgent?: ServeAgent\n}): Promise<boolean> {\n const { req, res, csrfMode, disallowed, requestId } = args\n const dispatcher = await createControllerDispatcher({\n controllersDir: args.controllersDir,\n loadModule: args.loadModule,\n serveAgent: args.serveAgent,\n })\n if (!dispatcher) return false\n\n const method = (req.method ?? 'GET').toUpperCase()\n const webRequest = incomingMessageToWebRequest(req)\n const pathname = new URL(webRequest.url).pathname\n\n // CSRF parity: enforce ONLY when a protected-method controller route actually\n // owns this path (probe with the non-executing matcher — never double-dispatch,\n // which would run the handler + its side effects). An unrouted path falls\n // through to the host's own 404, not a 403.\n if (CSRF_PROTECTED_METHODS.has(method) && dispatcher.matches(method, pathname)) {\n const decision = enforceCsrf(\n req,\n csrfMode,\n { warn: dispatchCsrfWarn, path: req.url },\n disallowed,\n )\n if (!decision.allow) {\n sendError(\n res,\n 'CSRF_INVALID',\n decision.reason ?? 'CSRF check failed',\n 403,\n undefined,\n requestId,\n )\n return true\n }\n }\n\n const response = await dispatcher.dispatch(webRequest)\n if (response === null) return false\n await writeControllerResponse(res, response)\n return true\n}\n","/**\n * Canonical CSRF warn dispatcher (T3.3 of architecture-review-remediation-plan).\n *\n * Consolidates the duplicated `warn: (payload) => { warnOnce(...) }` closure\n * that previously appeared in both `http/execute.ts` and\n * `http/action-execute.ts`. Resolves PV-10 (DRY).\n *\n * `warnOnce` dedupes by `event:method:path` so a request loop with 1000 POSTs\n * doesn't flood logs with identical warnings. Apps grep for `event\":\"csrf.warn\"`\n * (stable event shape — see [[enforcement-cutover.md]]).\n */\nimport { warnOnce } from '../observability/logger.js'\n\ninterface CsrfWarnPayload {\n event: string\n method: string\n path?: string\n reason: string\n code?: string\n docsUrl?: string\n warnOnce?: boolean\n}\n\n/**\n * Build the warn callback that `enforceCsrf` invokes for soft-mode warnings.\n * Returned function is suitable for the `warn` field of `enforceCsrf`'s options.\n */\nexport function dispatchCsrfWarn(payload: CsrfWarnPayload): void {\n const key = `${payload.event}:${payload.method}:${payload.path ?? ''}`\n warnOnce(key, payload as unknown as Record<string, unknown>)\n}\n","/**\n * T4.1 — Audit logging interface + default JSON stdout sink.\n *\n * Per ADR D4: define the interface; ship a zero-dep default; reserve\n * adapter shapes for Postgres, File, OpenTelemetry, Sentry as follow-up\n * packages. Persistence has heavy deps (`pg`, `better-sqlite3`); we\n * keep core dep-free and let users opt in.\n *\n * Compatibility:\n * - Node / Bun / Deno / Vercel — console.log is sync, captured.\n * - Edge runtimes (CF Workers, Vercel Edge) — console.log is captured\n * but may be rate-limited by the platform. For high-volume edge audit,\n * implement a custom sink writing to a queue / HTTP endpoint.\n */\n\nexport interface AuditEvent {\n /** Domain-qualified verb. Convention: `<domain>.<verb>` (e.g. csrf.warn, session.rotated). */\n action: string\n /** Who triggered the event. Anonymous = no auth at time of event. */\n actor?: { type: 'user' | 'system' | 'anonymous'; id?: string }\n /** What was operated on (optional). */\n resource?: { type: string; id?: string }\n /** Arbitrary event-specific metadata. JSON-serializable. */\n metadata?: Record<string, unknown>\n /** ISO 8601 timestamp. If absent, sink fills in `new Date().toISOString()`. */\n timestamp?: string\n /** Optional trace id (populated by middleware from `x-trace-id`). */\n traceId?: string\n}\n\nexport interface AuditLogger {\n log(event: AuditEvent): void | Promise<void>\n}\n\n/**\n * Default sink: one JSON line per event to stdout. Sync. Never throws.\n *\n * EC: circular refs / BigInt values fall back to a placeholder line so\n * the event is still observable (action + traceId) without crashing the\n * request lifecycle.\n */\nexport class JsonStdoutSink implements AuditLogger {\n log(event: AuditEvent): void {\n const enriched = {\n level: 'audit' as const,\n ...event,\n timestamp: event.timestamp ?? new Date().toISOString(),\n }\n try {\n // eslint-disable-next-line no-console -- JsonStdoutSink IS the audit output\n console.log(JSON.stringify(enriched, jsonReplacer))\n } catch {\n // eslint-disable-next-line no-console -- fallback when payload won't serialize\n console.log(\n `{\"level\":\"audit\",\"action\":${JSON.stringify(event.action)},\"timestamp\":${JSON.stringify(enriched.timestamp)},\"note\":\"payload could not be serialized\"}`,\n )\n }\n }\n}\n\n/**\n * Replacer that walks BigInt → string. Circular ref handling is via the\n * outer try/catch (JSON.stringify throws TypeError on cycles; we drop to\n * the fallback line). We don't implement custom cycle-breaking walker\n * because the audit payload is meant to be JSON — if user metadata has\n * a cycle, the right answer is to fix the caller, not silently lose\n * the structure.\n */\nfunction jsonReplacer(_key: string, value: unknown): unknown {\n if (typeof value === 'bigint') return value.toString()\n return value\n}\n\n/**\n * No-op logger. Returned when `config.audit` is unset. Zero overhead;\n * framework wiring sites null-check before calling.\n */\nexport function createNoOpLogger(): AuditLogger {\n return {\n log() {\n // intentionally empty\n },\n }\n}\n\n/**\n * T4.2 — Safe-emit wrapper. Used by framework wiring sites (csrf.ts,\n * rate-limit.ts, session.ts) so a logger throw NEVER propagates into\n * the request handler.\n */\nexport function safeAudit(logger: AuditLogger | undefined, event: AuditEvent): void {\n if (!logger) return\n try {\n const r = logger.log(event)\n // Discard the Promise — async sinks are fire-and-forget by design.\n if (r && typeof r.then === 'function') {\n r.catch(() => {\n // swallow async sink failures — audit must never crash the request\n })\n }\n } catch {\n // swallow sync sink failures — audit must never crash the request\n }\n}\n","import type { IncomingMessage } from 'node:http'\n\nimport type { AuditLogger } from '../observability/audit-log.js'\nimport { safeAudit } from '../observability/audit-log.js'\n\n/**\n * CSRF enforcement mode.\n *\n * - `off` — skip CSRF entirely. Use only when you have another defense\n * (e.g. you don't ship session cookies, all auth is bearer).\n * - `warn` — log a structured warning when the check would fail, but\n * still serve the request. Default for 0.2.0. Migration mode.\n * - `strict` — reject failing requests with 403 + code `CSRF_INVALID`.\n * Will become the default in 0.3.0.\n */\nexport type CsrfMode = 'off' | 'warn' | 'strict'\n\n/**\n * Per-request structured logger surface. Only `warn` is used by enforceCsrf;\n * we don't require a full Logger here so callers can pass a mock or the\n * console directly.\n */\nexport interface CsrfLogger {\n warn: (payload: CsrfWarnPayload) => void\n /** Optional path the request was destined for — used for log correlation. */\n path?: string\n}\n\n/**\n * T5.1 — Rails-inspired per-route escalation.\n *\n * `routes` accepts string (exact match) or RegExp entries. When a request\n * path matches AND the request would otherwise emit a warning, the\n * `behavior` field decides what happens:\n *\n * - `'warn'` → normal warn dispatch (no-op vs default)\n * - `'raise'` → escalate to 403 regardless of global `csrf` mode\n *\n * `'raise'` never downgrades: when global mode is `'off'`, validation is\n * skipped entirely and disallowed dispatch never runs.\n */\nexport interface DisallowedConfig {\n routes: (string | RegExp)[]\n behavior: 'warn' | 'raise'\n}\n\n/**\n * Test whether `path` matches any of the supplied patterns. String\n * patterns are EXACT (trailing slash matters — use RegExp for tolerance).\n *\n * EC-5: when a RegExp carries the `/g` flag, `.test()` mutates\n * `lastIndex` and the next invocation may miss. We reset `lastIndex`\n * before each test so the matcher is a pure function.\n */\nexport function matchDisallowed(path: string, patterns: readonly (string | RegExp)[]): boolean {\n for (const p of patterns) {\n if (typeof p === 'string') {\n if (path === p) return true\n } else if (p instanceof RegExp) {\n p.lastIndex = 0\n if (p.test(path)) return true\n }\n // Neither string nor RegExp: ignore silently (defensive — the public\n // type forbids it but runtime data may slip past).\n }\n return false\n}\n\n/**\n * T2.2 — Stable cutover identifier shipped with every csrf.warn payload.\n *\n * Convention borrowed from Vite's `deprecations.ts:74` — a `code` plus a\n * `docsUrl` lets users (a) grep their logs for a single stable identifier\n * to find every csrf.warn line, and (b) click through directly to the\n * migration guide. Strings are exported constants so the analyzer (T2.3)\n * and migration guide can reference the same source of truth.\n */\nexport const CSRF_WARN_CODE = 'CSRF_STRICT_CUTOVER' as const\nexport const CSRF_WARN_DOCS_URL = 'https://theokit.dev/upgrade/csrf-strict-cutover' as const\n\n/**\n * Pick a header value, choosing the first entry when an array (Node sets\n * arrays for headers that legitimately appear multiple times). Returns\n * `''` when the header is absent or empty — callers treat `''` as \"skip\".\n */\nfunction pickHeader(value: string | string[] | undefined): string {\n if (typeof value === 'string') return value\n if (Array.isArray(value) && value.length > 0) return value[0]\n return ''\n}\n\nexport interface CsrfWarnPayload {\n event: 'csrf.warn'\n method: string\n path: string | undefined\n reason: string\n /**\n * Stable identifier for the 0.2 → 0.3 CSRF strict cutover. Always\n * `'CSRF_STRICT_CUTOVER'`. Grep-able from prod logs.\n */\n code: string\n /**\n * Link to the section of the migration guide explaining how to clear\n * this specific warning class.\n */\n docsUrl: string\n}\n\n/**\n * T5a.2 Phase B (slice 1/6): pure header-only CSRF check extracted from\n * `validateCsrf(req: IncomingMessage)` so it can be re-used by the Web-\n * Standards `validateCsrfRequest(request: Request)` sibling. Per the T5a.2\n * plan v1.0 § Phase B, header-only leaves are first to migrate. This is\n * the dual-signature pattern (anti-pattern #2 avoidance): IncomingMessage\n * consumers unchanged; new Request consumers go through the same logic\n * via the shared helper.\n *\n * Pure logic — accepts pre-extracted header values as strings or null.\n */\nfunction isCsrfValidFromHeaders(opts: {\n csrfActionHeader: string | null\n origin: string | null\n host: string | null\n}): { valid: true } | { valid: false; reason: string } {\n // 1. Custom header must be present (primary defense — simple form posts\n // cannot set custom headers, browsers gate via CORS preflight)\n if (opts.csrfActionHeader !== '1') {\n return { valid: false, reason: 'Missing X-Theo-Action header' }\n }\n\n // 2. Origin matching (secondary defense)\n if (opts.origin === null || opts.origin === '') {\n // Browsers omit Origin for same-origin requests — treat as valid\n return { valid: true }\n }\n\n if (opts.host === null || opts.host === '') {\n return { valid: true }\n }\n\n try {\n const originHost = new URL(opts.origin).host\n if (originHost !== opts.host) {\n return { valid: false, reason: `Origin ${opts.origin} does not match host ${opts.host}` }\n }\n } catch {\n return { valid: false, reason: `Invalid origin: ${opts.origin}` }\n }\n\n return { valid: true }\n}\n\nexport function validateCsrf(\n req: IncomingMessage,\n): { valid: true } | { valid: false; reason: string } {\n // IncomingMessage adapter — normalize Node header shape to the pure\n // helper's input shape (string|null).\n const action = req.headers['x-theo-action']\n const origin = req.headers.origin\n const host = req.headers.host\n\n // RFC 6454: Origin is single-valued. A caller that synthesizes an\n // IncomingMessage — an adapter, a shim, a proxy library — can hand us an\n // array, and choosing one of two conflicting origins is a decision the\n // request never authorized. The disagreement IS the rejection.\n //\n // `node:http` itself joins a repeated Origin with `, ` rather than\n // producing an array, and that string already fails to parse as a URL\n // below. This branch covers the shape the type allows and `pickHeader`\n // used to resolve silently.\n if (Array.isArray(origin)) {\n return { valid: false, reason: 'Multiple Origin headers (RFC 6454 violation)' }\n }\n\n return isCsrfValidFromHeaders({\n csrfActionHeader: typeof action === 'string' ? action : null,\n origin: origin !== undefined ? origin || null : null,\n host: host !== undefined ? pickHeader(host) || null : null,\n })\n}\n\n/**\n * T5a.2 Phase B (slice 1/6) — Web-Standards-shaped CSRF validator.\n *\n * Mirror of `validateCsrf(req: IncomingMessage)` for the Web `Request`\n * shape. Consumes `request.headers.get(name)` (native Web `Headers` API)\n * instead of `req.headers[name]` (Node `IncomingMessage` indexer). Same\n * CSRF policy + same return shape — the difference is only the input\n * extraction.\n *\n * Used by `executeWebRequest` (T5a.2 Phase A) to enforce CSRF on the\n * Web-Standards request handler entry-point.\n */\nexport function validateCsrfRequest(\n request: Request,\n): { valid: true } | { valid: false; reason: string } {\n return isCsrfValidFromHeaders({\n csrfActionHeader: request.headers.get('x-theo-action'),\n origin: request.headers.get('origin'),\n host: request.headers.get('host'),\n })\n}\n\n/**\n * Enforce CSRF policy with mode-aware behavior. Wrapper over `validateCsrf`\n * that turns the boolean valid/invalid into a request-level allow decision,\n * gated by mode + structured warning in warn mode.\n *\n * Phase 5 — CSRF warn-first (EC-1).\n */\n/**\n * Dispatch the csrf.warn payload to both the structured logger and the\n * audit sink (when configured). Extracted from `enforceCsrf` to keep that\n * function's complexity within ceiling.\n */\nfunction dispatchCsrfWarn(\n req: IncomingMessage,\n reason: string,\n logger: CsrfLogger | undefined,\n auditLogger: AuditLogger | undefined,\n pathFallback = '',\n): void {\n const payload: CsrfWarnPayload = {\n event: 'csrf.warn',\n method: req.method ?? 'UNKNOWN',\n path: logger?.path ?? pathFallback,\n reason,\n code: CSRF_WARN_CODE,\n docsUrl: CSRF_WARN_DOCS_URL,\n }\n logger?.warn(payload)\n // `metadata` is typed as Record<string, unknown>; CsrfWarnPayload is a\n // structurally-equivalent shape but lacks the index signature.\n safeAudit(auditLogger, {\n action: 'csrf.warn',\n actor: { type: 'anonymous' },\n metadata: { ...payload },\n })\n}\n\nexport function enforceCsrf(\n req: IncomingMessage,\n mode: CsrfMode,\n logger?: CsrfLogger,\n disallowed?: DisallowedConfig,\n auditLogger?: AuditLogger,\n): { allow: boolean; reason?: string } {\n if (mode === 'off') {\n // `off` short-circuits before disallowed dispatch — users who set\n // csrf: 'off' globally have explicitly turned validation off, and\n // disallowed must never re-introduce it. The escape hatch is to\n // set csrf: 'warn' and use disallowed for surgical strict pockets.\n return { allow: true }\n }\n\n const check = validateCsrf(req)\n if (check.valid) {\n return { allow: true }\n }\n\n // T5.1 — disallowed dispatch: when the failing request matches a\n // disallowed pattern AND behavior is 'raise', escalate to 403 even if\n // global mode is 'warn'. Strict mode would 403 anyway, so the branch\n // is a no-op there.\n if (disallowed?.behavior === 'raise') {\n const path = logger?.path ?? req.url ?? ''\n if (matchDisallowed(path, disallowed.routes)) {\n return { allow: false, reason: check.reason }\n }\n }\n\n if (mode === 'warn') {\n // T2.1: emit via warnOnce by default — callers can override via the\n // injected logger.warn (tests, custom log routers).\n // T2.2: include the stable cutover code + docsUrl so logs are\n // grep-able and click-through-able.\n dispatchCsrfWarn(req, check.reason, logger, auditLogger)\n return { allow: true, reason: check.reason }\n }\n\n // strict — 403 the request, AND emit a warn payload so the dev (and\n // devtools UI) sees WHY it was blocked + the docsUrl to fix it.\n // Without this, strict-mode users get a silent 403 with no context.\n dispatchCsrfWarn(req, check.reason, logger, auditLogger)\n return { allow: false, reason: check.reason }\n}\n"],"mappings":";;;;;;;AAmBA,IAAM,iBAAsC,oBAAI,IAAI,CAAC,kBAAkB,uBAAuB,CAAC;AAE/F,IAAM,2BAA2B;AAEjC,SAAS,QAAQ,MAAuB;AACtC,SAAO,eAAe,IAAI,IAAI,KAAK,QAAQ,IAAI,aAAa;AAC9D;AAGO,SAAS,uBAAuB,MAAc,SAAyB;AAC5E,SAAO,QAAQ,IAAI,IAAI,2BAA2B;AACpD;;;ACbO,SAAS,SACd,KACA,MACA,SAAS,KACT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
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
sendError,
|
|
13
13
|
sendJson,
|
|
14
14
|
validateCsrfRequest
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CTRVTBGY.js";
|
|
16
16
|
import {
|
|
17
17
|
buildSecurityHeaders
|
|
18
18
|
} from "./chunk-RPET332G.js";
|
|
@@ -2616,4 +2616,4 @@ export {
|
|
|
2616
2616
|
CsrfReadinessStore,
|
|
2617
2617
|
applySecurityHeaders
|
|
2618
2618
|
};
|
|
2619
|
-
//# sourceMappingURL=chunk-
|
|
2619
|
+
//# sourceMappingURL=chunk-G5JYB2LO.js.map
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
serveMatchedAuxRoute,
|
|
13
13
|
serveThroughPluginLifecycle,
|
|
14
14
|
setupSsrDevMiddleware
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-OKDCBENR.js";
|
|
16
16
|
import {
|
|
17
17
|
resolveTheoRootDir
|
|
18
18
|
} from "./chunk-FDOOBTXJ.js";
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
mountAgent,
|
|
39
39
|
readAgentPolicy,
|
|
40
40
|
writeWebResponseToServerResponse
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-G5JYB2LO.js";
|
|
42
42
|
import {
|
|
43
43
|
getApprovalRegistry,
|
|
44
44
|
resolveProvider
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
dispatchControllerRequest,
|
|
49
49
|
incomingMessageToHandlerRequest,
|
|
50
50
|
sendError
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-CTRVTBGY.js";
|
|
52
52
|
import {
|
|
53
53
|
TRACE_HEADER,
|
|
54
54
|
createObservabilityPluginFromConfig,
|
|
@@ -2179,19 +2179,19 @@ async function theoPluginAsync(rootOrOptions) {
|
|
|
2179
2179
|
})
|
|
2180
2180
|
);
|
|
2181
2181
|
}
|
|
2182
|
-
const { appTypedClientPlugin } = await import("./app-typed-client-
|
|
2182
|
+
const { appTypedClientPlugin } = await import("./app-typed-client-NMKJ4DR7.js");
|
|
2183
2183
|
const appClientPlugin = appTypedClientPlugin({
|
|
2184
2184
|
cwd: projectRoot,
|
|
2185
2185
|
serverDir: serverDirAbs,
|
|
2186
2186
|
distDir: resolve5(projectRoot, ".theokit")
|
|
2187
2187
|
});
|
|
2188
|
-
const { actionsVirtualModule } = await import("./actions-virtual-module-
|
|
2188
|
+
const { actionsVirtualModule } = await import("./actions-virtual-module-XAWZOWSY.js");
|
|
2189
2189
|
const actionsPlugin = actionsVirtualModule({
|
|
2190
2190
|
serverDir: serverDirAbs,
|
|
2191
2191
|
distDir: resolve5(projectRoot, ".theokit")
|
|
2192
2192
|
});
|
|
2193
2193
|
const { agentsTypedClientPlugin } = await import("./agents-typed-client-D4OA2TXB.js");
|
|
2194
|
-
const { generateManifest } = await import("./internal-api-
|
|
2194
|
+
const { generateManifest } = await import("./internal-api-732K3H75.js");
|
|
2195
2195
|
const agentsClientPlugin = agentsTypedClientPlugin({
|
|
2196
2196
|
projectRoot,
|
|
2197
2197
|
agentsDir: agentsDirName,
|
|
@@ -2208,7 +2208,7 @@ async function theoPluginAsync(rootOrOptions) {
|
|
|
2208
2208
|
const controllerTransformPlugin = controllerSwcTransformPlugin({
|
|
2209
2209
|
serverDir: serverDirAbs
|
|
2210
2210
|
});
|
|
2211
|
-
const { serverOnlyImportBoundary } = await import("./server-boundary-
|
|
2211
|
+
const { serverOnlyImportBoundary } = await import("./server-boundary-B6U4DRRH.js");
|
|
2212
2212
|
const serverBoundaryPlugin = serverOnlyImportBoundary({
|
|
2213
2213
|
projectRoot,
|
|
2214
2214
|
serverDir: serverDirAbs
|
|
@@ -2383,4 +2383,4 @@ export {
|
|
|
2383
2383
|
theoPluginAsync,
|
|
2384
2384
|
theoPlugin
|
|
2385
2385
|
};
|
|
2386
|
-
//# sourceMappingURL=chunk-
|
|
2386
|
+
//# sourceMappingURL=chunk-KEDRCI2L.js.map
|
|
@@ -178,7 +178,7 @@ async function agentCommand(name, message, deps = {}) {
|
|
|
178
178
|
async function createAgentSsrLoader(projectRoot) {
|
|
179
179
|
const { createServer } = await import("vite");
|
|
180
180
|
const react = (await import("@vitejs/plugin-react")).default;
|
|
181
|
-
const { theoPluginAsync } = await import("./vite-plugin-
|
|
181
|
+
const { theoPluginAsync } = await import("./vite-plugin-ABJIDKE6.js");
|
|
182
182
|
const { loadConfig } = await import("./load-config-BKUAMGO5.js");
|
|
183
183
|
const config = await loadConfig(projectRoot);
|
|
184
184
|
const theoPlugins = await theoPluginAsync({
|
|
@@ -212,4 +212,4 @@ export {
|
|
|
212
212
|
agentCommand,
|
|
213
213
|
createAgentSsrLoader
|
|
214
214
|
};
|
|
215
|
-
//# sourceMappingURL=chunk-
|
|
215
|
+
//# sourceMappingURL=chunk-NC2OPE22.js.map
|