@demiurgejs/core 0.2.0-beta.4 → 0.2.0-beta.6
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/README.md +37 -0
- package/bin/demiurge.mjs +23 -1
- package/dist/adapter/index.d.ts +1 -1
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/browser/file-router.d.ts +1 -1
- package/dist/chunks/{document-shell-CpJnFtSC.js → document-shell-C0aPrkhd.js} +2 -2
- package/dist/chunks/{document-shell-CpJnFtSC.js.map → document-shell-C0aPrkhd.js.map} +1 -1
- package/dist/chunks/image-CRerJ5BY.js +145 -0
- package/dist/chunks/image-CRerJ5BY.js.map +1 -0
- package/dist/chunks/{image-codec-BmzWnH6W.js → image-codec-CQ8Cwxwb.js} +2 -2
- package/dist/chunks/{image-codec-BmzWnH6W.js.map → image-codec-CQ8Cwxwb.js.map} +1 -1
- package/dist/chunks/{images-BQ80950B.js → images-QgdmLyQ3.js} +11 -11
- package/dist/chunks/{images-BQ80950B.js.map → images-QgdmLyQ3.js.map} +1 -1
- package/dist/chunks/{index-BVk9zWbe.js → index-LYve1rQp.js} +287 -351
- package/dist/chunks/index-LYve1rQp.js.map +1 -0
- package/dist/chunks/links-iU22QkCE.js +68 -0
- package/dist/chunks/links-iU22QkCE.js.map +1 -0
- package/dist/chunks/plugin-bkP6WwrS.js +2311 -0
- package/dist/chunks/plugin-bkP6WwrS.js.map +1 -0
- package/dist/chunks/runtime-BH519j2t.js +294 -0
- package/dist/chunks/runtime-BH519j2t.js.map +1 -0
- package/dist/chunks/streaming-BlKlC3nw.js +427 -0
- package/dist/chunks/streaming-BlKlC3nw.js.map +1 -0
- package/dist/chunks/{testing-DueXbMo4.js → testing-BEW1nchS.js} +2161 -1562
- package/dist/chunks/testing-BEW1nchS.js.map +1 -0
- package/dist/chunks/{vite-DO70kZA6.js → vite-BADZA8Fl.js} +90 -87
- package/dist/chunks/vite-BADZA8Fl.js.map +1 -0
- package/dist/cli.d.ts +10 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +277 -87
- package/dist/cli.js.map +1 -1
- package/dist/config/index.js +2 -2
- package/dist/config/types.d.ts +14 -2
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/validate.d.ts.map +1 -1
- package/dist/data/cache.d.ts +5 -0
- package/dist/data/cache.d.ts.map +1 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/testing.d.ts.map +1 -1
- package/dist/data/testing.js +101 -67
- package/dist/data/testing.js.map +1 -1
- package/dist/data/tiered.d.ts.map +1 -1
- package/dist/edge/index.js +27 -26
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/stores.d.ts.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +158 -135
- package/dist/index.js.map +1 -1
- package/dist/inspect/command.d.ts +28 -0
- package/dist/inspect/command.d.ts.map +1 -0
- package/dist/inspect/index.d.ts +9 -0
- package/dist/inspect/index.d.ts.map +1 -0
- package/dist/inspect/redact.d.ts +35 -0
- package/dist/inspect/redact.d.ts.map +1 -0
- package/dist/inspect/report.d.ts +24 -0
- package/dist/inspect/report.d.ts.map +1 -0
- package/dist/inspect/types.d.ts +102 -0
- package/dist/inspect/types.d.ts.map +1 -0
- package/dist/internal/testing.js +12 -12
- package/dist/kv/index.js +7 -6
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/store.d.ts.map +1 -1
- package/dist/node/http.d.ts +7 -0
- package/dist/node/http.d.ts.map +1 -1
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +31 -28
- package/dist/node/index.js.map +1 -1
- package/dist/node/serve.d.ts +4 -0
- package/dist/node/serve.d.ts.map +1 -1
- package/dist/redis/index.js +29 -28
- package/dist/redis/index.js.map +1 -1
- package/dist/redis/store.d.ts.map +1 -1
- package/dist/route/index.d.ts +1 -0
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/mutation.d.ts.map +1 -1
- package/dist/route/serialization.d.ts +24 -0
- package/dist/route/serialization.d.ts.map +1 -0
- package/dist/route/webhook.d.ts +6 -1
- package/dist/route/webhook.d.ts.map +1 -1
- package/dist/router/manifest.d.ts.map +1 -1
- package/dist/security/audit.d.ts +2 -1
- package/dist/security/audit.d.ts.map +1 -1
- package/dist/security/authorization.d.ts +36 -0
- package/dist/security/authorization.d.ts.map +1 -0
- package/dist/security/csrf.d.ts.map +1 -1
- package/dist/security/env-startup.d.ts +0 -2
- package/dist/security/env-startup.d.ts.map +1 -1
- package/dist/security/env.d.ts +27 -8
- package/dist/security/env.d.ts.map +1 -1
- package/dist/security/exceptions.d.ts +29 -0
- package/dist/security/exceptions.d.ts.map +1 -0
- package/dist/security/finding-codes.d.ts +56 -0
- package/dist/security/finding-codes.d.ts.map +1 -0
- package/dist/security/index.d.ts +5 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/policy.d.ts +2 -5
- package/dist/security/policy.d.ts.map +1 -1
- package/dist/security/report.d.ts +2 -1
- package/dist/security/report.d.ts.map +1 -1
- package/dist/security/request.d.ts +1 -0
- package/dist/security/request.d.ts.map +1 -1
- package/dist/security/types.d.ts +138 -5
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/upload.d.ts +3 -3
- package/dist/security/upload.d.ts.map +1 -1
- package/dist/security/verification.d.ts.map +1 -1
- package/dist/server/request-handler.d.ts +3 -2
- package/dist/server/request-handler.d.ts.map +1 -1
- package/dist/server-only/browser.d.ts +2 -0
- package/dist/server-only/browser.d.ts.map +1 -0
- package/dist/server-only/browser.js +4 -0
- package/dist/server-only/browser.js.map +1 -0
- package/dist/server-only/index.d.ts +2 -0
- package/dist/server-only/index.d.ts.map +1 -0
- package/dist/server-only/index.js +2 -0
- package/dist/server-only/index.js.map +1 -0
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +255 -255
- package/dist/static/index.js.map +1 -1
- package/dist/static/testing.d.ts +26 -0
- package/dist/static/testing.d.ts.map +1 -0
- package/dist/static/testing.js +76 -0
- package/dist/static/testing.js.map +1 -0
- package/dist/testing/index.d.ts +47 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +99 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/vercel/build.d.ts +31 -0
- package/dist/vercel/build.d.ts.map +1 -0
- package/dist/vercel/config.d.ts +15 -0
- package/dist/vercel/config.d.ts.map +1 -0
- package/dist/vercel/index.d.ts +7 -0
- package/dist/vercel/index.d.ts.map +1 -0
- package/dist/vercel/index.js +11 -0
- package/dist/vercel/index.js.map +1 -0
- package/dist/vercel/runtime.d.ts +29 -0
- package/dist/vercel/runtime.d.ts.map +1 -0
- package/dist/vite/index.d.ts +9 -4
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +28 -21
- package/dist/vite/plugin.d.ts +18 -2
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/policy-verification.d.ts +33 -2
- package/dist/vite/policy-verification.d.ts.map +1 -1
- package/dist/vite/route-audit.d.ts +14 -2
- package/dist/vite/route-audit.d.ts.map +1 -1
- package/dist/vite/server-only-boundary.d.ts +8 -0
- package/dist/vite/server-only-boundary.d.ts.map +1 -0
- package/package.json +18 -1
- package/dist/chunks/env-startup-DOBYWlZD.js +0 -257
- package/dist/chunks/env-startup-DOBYWlZD.js.map +0 -1
- package/dist/chunks/index-BVk9zWbe.js.map +0 -1
- package/dist/chunks/plugin-BQgMiHxa.js +0 -1827
- package/dist/chunks/plugin-BQgMiHxa.js.map +0 -1
- package/dist/chunks/streaming-BEbPN7Uk.js +0 -469
- package/dist/chunks/streaming-BEbPN7Uk.js.map +0 -1
- package/dist/chunks/testing-DueXbMo4.js.map +0 -1
- package/dist/chunks/vite-DO70kZA6.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type RequestHandler, type RequestHandlerOptions } from "../server";
|
|
2
|
+
export type ApplicationTest = {
|
|
3
|
+
request(input: Request | string | URL): Promise<Response>;
|
|
4
|
+
};
|
|
5
|
+
export type TestClock = {
|
|
6
|
+
advance: (milliseconds: number) => number;
|
|
7
|
+
now: () => number;
|
|
8
|
+
set: (epochMilliseconds: number) => number;
|
|
9
|
+
};
|
|
10
|
+
type ExpectedValue = RegExp | string;
|
|
11
|
+
export type DocumentAssertion = {
|
|
12
|
+
title?: ExpectedValue;
|
|
13
|
+
scripts?: readonly {
|
|
14
|
+
src?: ExpectedValue;
|
|
15
|
+
strategy?: ExpectedValue;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export type SecurityAssertion = {
|
|
19
|
+
cacheControl?: ExpectedValue;
|
|
20
|
+
csp?: ExpectedValue;
|
|
21
|
+
nonce?: boolean;
|
|
22
|
+
headers?: Readonly<Record<string, ExpectedValue>>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Creates a runner-neutral application request test boundary.
|
|
26
|
+
*
|
|
27
|
+
* A pathname uses https://demiurge.test as its origin. A URL keeps its origin.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createApplicationTest(input: RequestHandler | RequestHandlerOptions): ApplicationTest;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a standard Request with the application test origin.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createTestRequest(input: string | URL, init?: RequestInit): Request;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a deterministic clock for time-dependent application tests.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createTestClock(initial?: number): TestClock;
|
|
38
|
+
/**
|
|
39
|
+
* Asserts document metadata and framework-managed scripts in a response.
|
|
40
|
+
*/
|
|
41
|
+
export declare function assertDocument(response: Response, expected: DocumentAssertion): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Asserts security headers and their document cache and nonce compatibility.
|
|
44
|
+
*/
|
|
45
|
+
export declare function assertSecurity(response: Response, expected: SecurityAssertion): Promise<void>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sour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ACjB,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAI,GAAG,SAAS,CAkBtD;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { c as h } from "../chunks/testing-BEW1nchS.js";
|
|
2
|
+
import "react-dom/server";
|
|
3
|
+
import "../chunks/index-LYve1rQp.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import "react/jsx-runtime";
|
|
6
|
+
const f = "https://demiurge.test";
|
|
7
|
+
function S(t) {
|
|
8
|
+
const e = typeof t == "function" ? t : h(t);
|
|
9
|
+
return {
|
|
10
|
+
async request(r) {
|
|
11
|
+
return await e(d(r));
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function l(t, e) {
|
|
16
|
+
return new Request(new URL(t, f), e);
|
|
17
|
+
}
|
|
18
|
+
function C(t = 0) {
|
|
19
|
+
a(t, "initial time");
|
|
20
|
+
let e = t;
|
|
21
|
+
return {
|
|
22
|
+
advance(r) {
|
|
23
|
+
return a(r, "clock advance"), e += r, a(e, "clock time"), e;
|
|
24
|
+
},
|
|
25
|
+
now: () => e,
|
|
26
|
+
set(r) {
|
|
27
|
+
return a(r, "clock time"), e = r, e;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async function k(t, e) {
|
|
32
|
+
const r = await t.clone().text();
|
|
33
|
+
if (e.title !== void 0) {
|
|
34
|
+
const n = /<title>([\s\S]*?)<\/title>/i.exec(r)?.[1] ?? "";
|
|
35
|
+
o(n, e.title, "document title");
|
|
36
|
+
}
|
|
37
|
+
for (const n of e.scripts ?? []) {
|
|
38
|
+
const c = [...r.matchAll(/<script\b([^>]*)>/gi)].filter(
|
|
39
|
+
([, s]) => /(?:^|\s)data-demiurge-document-contribution(?:\s|=|$)/i.test(s)
|
|
40
|
+
), i = c.find(([, s]) => (!n.src || m(u(s, "src") ?? "", n.src)) && (!n.strategy || m(u(s, "data-demiurge-script-strategy") ?? "", n.strategy)));
|
|
41
|
+
if (!i)
|
|
42
|
+
throw c.length === 0 ? new Error("Expected a framework-managed script, but the document has none.") : new Error(`Expected a matching framework-managed script${g(n)}, but none matched.`);
|
|
43
|
+
n.src && o(u(i[1], "src") ?? "", n.src, "managed script source"), n.strategy && o(u(i[1], "data-demiurge-script-strategy") ?? "", n.strategy, "managed script strategy");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function R(t, e) {
|
|
47
|
+
e.csp !== void 0 && o(t.headers.get("content-security-policy") ?? "", e.csp, "Content-Security-Policy header"), e.cacheControl !== void 0 && o(t.headers.get("cache-control") ?? "", e.cacheControl, "cache-control header");
|
|
48
|
+
for (const [c, i] of Object.entries(e.headers ?? {}))
|
|
49
|
+
o(t.headers.get(c) ?? "", i, `${c} header`);
|
|
50
|
+
if (e.nonce === void 0) return;
|
|
51
|
+
const r = await t.clone().text(), n = /\snonce="([^"]+)"/i.exec(r)?.[1];
|
|
52
|
+
if (e.nonce && !n)
|
|
53
|
+
throw new Error("Expected a document nonce, but the document has none.");
|
|
54
|
+
if (!e.nonce && n)
|
|
55
|
+
throw new Error("Expected no document nonce, but the document has one.");
|
|
56
|
+
if (n && !w(t.headers.get("content-security-policy") ?? "", n))
|
|
57
|
+
throw new Error("The document nonce is absent from the Content-Security-Policy header.");
|
|
58
|
+
if (n && !y(t.headers.get("cache-control") ?? ""))
|
|
59
|
+
throw new Error("A nonce-backed document must use a private or no-store cache policy.");
|
|
60
|
+
}
|
|
61
|
+
function d(t) {
|
|
62
|
+
return t instanceof Request ? t : l(t);
|
|
63
|
+
}
|
|
64
|
+
function a(t, e) {
|
|
65
|
+
if (!Number.isFinite(t))
|
|
66
|
+
throw new Error(`Demiurge test ${e} must be finite.`);
|
|
67
|
+
}
|
|
68
|
+
function o(t, e, r) {
|
|
69
|
+
if (!m(t, e))
|
|
70
|
+
throw new Error(`Expected ${r} to match ${String(e)}, but it was ${JSON.stringify(t)}.`);
|
|
71
|
+
}
|
|
72
|
+
function m(t, e) {
|
|
73
|
+
return typeof e == "string" ? t === e : (e.lastIndex = 0, e.test(t));
|
|
74
|
+
}
|
|
75
|
+
function u(t, e) {
|
|
76
|
+
const r = new RegExp(`\\s${e}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`, "i").exec(t);
|
|
77
|
+
return r?.[1]?.replaceAll("&", "&") ?? r?.[2]?.replaceAll("&", "&");
|
|
78
|
+
}
|
|
79
|
+
function g(t) {
|
|
80
|
+
return [t.src && ` source ${String(t.src)}`, t.strategy && ` strategy ${String(t.strategy)}`].filter(Boolean).join(" with");
|
|
81
|
+
}
|
|
82
|
+
function w(t, e) {
|
|
83
|
+
return t.split(";").some(
|
|
84
|
+
(r) => r.trim().split(/\s+/).slice(1).includes(`'nonce-${e}'`)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
function y(t) {
|
|
88
|
+
return t.split(",").some(
|
|
89
|
+
(e) => ["private", "no-store"].includes(e.trim().split("=", 1)[0]?.toLowerCase() ?? "")
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
k as assertDocument,
|
|
94
|
+
R as assertSecurity,
|
|
95
|
+
S as createApplicationTest,
|
|
96
|
+
C as createTestClock,
|
|
97
|
+
l as createTestRequest
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/testing/index.ts"],"sourcesContent":["import {\n createRequestHandler,\n type RequestHandler,\n type RequestHandlerOptions,\n} from \"../server\";\n\nconst testOrigin = \"https://demiurge.test\";\n\nexport type ApplicationTest = {\n request(input: Request | string | URL): Promise<Response>;\n};\n\nexport type TestClock = {\n advance: (milliseconds: number) => number;\n now: () => number;\n set: (epochMilliseconds: number) => number;\n};\n\ntype ExpectedValue = RegExp | string;\n\nexport type DocumentAssertion = {\n title?: ExpectedValue;\n scripts?: readonly {\n src?: ExpectedValue;\n strategy?: ExpectedValue;\n }[];\n};\n\nexport type SecurityAssertion = {\n cacheControl?: ExpectedValue;\n csp?: ExpectedValue;\n nonce?: boolean;\n headers?: Readonly<Record<string, ExpectedValue>>;\n};\n\n/**\n * Creates a runner-neutral application request test boundary.\n *\n * A pathname uses https://demiurge.test as its origin. A URL keeps its origin.\n */\nexport function createApplicationTest(\n input: RequestHandler | RequestHandlerOptions,\n): ApplicationTest {\n const handler = typeof input === \"function\" ? input : createRequestHandler(input);\n\n return {\n async request(input) {\n return await handler(toRequest(input));\n },\n };\n}\n\n/**\n * Creates a standard Request with the application test origin.\n */\nexport function createTestRequest(\n input: string | URL,\n init?: RequestInit,\n): Request {\n return new Request(new URL(input, testOrigin), init);\n}\n\n/**\n * Creates a deterministic clock for time-dependent application tests.\n */\nexport function createTestClock(initial = 0): TestClock {\n assertTestTime(initial, \"initial time\");\n let current = initial;\n\n return {\n advance(milliseconds) {\n assertTestTime(milliseconds, \"clock advance\");\n current += milliseconds;\n assertTestTime(current, \"clock time\");\n return current;\n },\n now: () => current,\n set(epochMilliseconds) {\n assertTestTime(epochMilliseconds, \"clock time\");\n current = epochMilliseconds;\n return current;\n },\n };\n}\n\n/**\n * Asserts document metadata and framework-managed scripts in a response.\n */\nexport async function assertDocument(\n response: Response,\n expected: DocumentAssertion,\n): Promise<void> {\n const document = await response.clone().text();\n\n if (expected.title !== undefined) {\n const title = /<title>([\\s\\S]*?)<\\/title>/i.exec(document)?.[1] ?? \"\";\n assertValue(title, expected.title, \"document title\");\n }\n\n for (const script of expected.scripts ?? []) {\n const managedScripts = [...document.matchAll(/<script\\b([^>]*)>/gi)].filter(([, attributes]) =>\n /(?:^|\\s)data-demiurge-document-contribution(?:\\s|=|$)/i.test(attributes),\n );\n const match = managedScripts.find(([, attributes]) => {\n return (!script.src || matchesValue(readAttribute(attributes, \"src\") ?? \"\", script.src)) &&\n (!script.strategy || matchesValue(readAttribute(attributes, \"data-demiurge-script-strategy\") ?? \"\", script.strategy));\n });\n if (!match) {\n if (managedScripts.length === 0) {\n throw new Error(\"Expected a framework-managed script, but the document has none.\");\n }\n throw new Error(`Expected a matching framework-managed script${describeScript(script)}, but none matched.`);\n }\n\n if (script.src) assertValue(readAttribute(match[1], \"src\") ?? \"\", script.src, \"managed script source\");\n if (script.strategy) assertValue(readAttribute(match[1], \"data-demiurge-script-strategy\") ?? \"\", script.strategy, \"managed script strategy\");\n }\n}\n\n/**\n * Asserts security headers and their document cache and nonce compatibility.\n */\nexport async function assertSecurity(\n response: Response,\n expected: SecurityAssertion,\n): Promise<void> {\n if (expected.csp !== undefined) {\n assertValue(response.headers.get(\"content-security-policy\") ?? \"\", expected.csp, \"Content-Security-Policy header\");\n }\n if (expected.cacheControl !== undefined) {\n assertValue(response.headers.get(\"cache-control\") ?? \"\", expected.cacheControl, \"cache-control header\");\n }\n for (const [name, value] of Object.entries(expected.headers ?? {})) {\n assertValue(response.headers.get(name) ?? \"\", value, `${name} header`);\n }\n if (expected.nonce === undefined) return;\n\n const document = await response.clone().text();\n const nonce = /\\snonce=\"([^\"]+)\"/i.exec(document)?.[1];\n if (expected.nonce && !nonce) {\n throw new Error(\"Expected a document nonce, but the document has none.\");\n }\n if (!expected.nonce && nonce) {\n throw new Error(\"Expected no document nonce, but the document has one.\");\n }\n if (nonce && !hasCspNonce(response.headers.get(\"content-security-policy\") ?? \"\", nonce)) {\n throw new Error(\"The document nonce is absent from the Content-Security-Policy header.\");\n }\n if (nonce && !hasPrivateNonceCache(response.headers.get(\"cache-control\") ?? \"\")) {\n throw new Error(\"A nonce-backed document must use a private or no-store cache policy.\");\n }\n}\n\nfunction toRequest(input: Request | string | URL): Request {\n if (input instanceof Request) {\n return input;\n }\n\n return createTestRequest(input);\n}\n\nfunction assertTestTime(value: number, subject: string) {\n if (!Number.isFinite(value)) {\n throw new Error(`Demiurge test ${subject} must be finite.`);\n }\n}\n\nfunction assertValue(actual: string, expected: ExpectedValue, subject: string) {\n const matched = matchesValue(actual, expected);\n if (!matched) {\n throw new Error(`Expected ${subject} to match ${String(expected)}, but it was ${JSON.stringify(actual)}.`);\n }\n}\n\nfunction matchesValue(actual: string, expected: ExpectedValue) {\n if (typeof expected === \"string\") return actual === expected;\n expected.lastIndex = 0;\n return expected.test(actual);\n}\n\nfunction readAttribute(attributes: string, name: string) {\n const match = new RegExp(`\\\\s${name}\\\\s*=\\\\s*(?:\"([^\"]*)\"|'([^']*)')`, \"i\").exec(attributes);\n return match?.[1]?.replaceAll(\"&\", \"&\") ?? match?.[2]?.replaceAll(\"&\", \"&\");\n}\n\nfunction describeScript(script: NonNullable<DocumentAssertion[\"scripts\"]>[number]) {\n const parts = [script.src && ` source ${String(script.src)}`, script.strategy && ` strategy ${String(script.strategy)}`].filter(Boolean);\n return parts.join(\" with\");\n}\n\nfunction hasCspNonce(csp: string, nonce: string) {\n return csp.split(\";\").some((directive) =>\n directive.trim().split(/\\s+/).slice(1).includes(`'nonce-${nonce}'`),\n );\n}\n\nfunction hasPrivateNonceCache(cacheControl: string) {\n return cacheControl.split(\",\").some((directive) =>\n [\"private\", \"no-store\"].includes(directive.trim().split(\"=\", 1)[0]?.toLowerCase() ?? \"\"),\n );\n}\n"],"names":["testOrigin","createApplicationTest","input","handler","createRequestHandler","toRequest","createTestRequest","init","createTestClock","initial","assertTestTime","current","milliseconds","epochMilliseconds","assertDocument","response","expected","document","title","assertValue","script","managedScripts","attributes","match","matchesValue","readAttribute","describeScript","assertSecurity","name","value","nonce","hasCspNonce","hasPrivateNonceCache","subject","actual","csp","directive","cacheControl"],"mappings":";;;;;AAMA,MAAMA,IAAa;AAkCZ,SAASC,EAC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AM,GAAG,EAAE;AAAA,IAAK,CAACD,MACnC,CAAC,WAAW,UAAU,EAAE,SAASA,EAAU,KAAA,EAAO,MAAM,KAAK,CAAC,EAAE,CAAC,GAAG,YAAA,KAAiB,EAAE;AAAA,EAAA;AAE3F;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { VercelNodeDeployment } from "./config";
|
|
2
|
+
export type GenerateVercelNodeOutputOptions = {
|
|
3
|
+
clientDir: string;
|
|
4
|
+
deployment: VercelNodeDeployment;
|
|
5
|
+
projectRoot: string;
|
|
6
|
+
serverDir: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function generateVercelNodeOutput(options: GenerateVercelNodeOutputOptions): Promise<string>;
|
|
9
|
+
export declare function createFunctionConfig(deployment: VercelNodeDeployment): {
|
|
10
|
+
regions?: string[] | undefined;
|
|
11
|
+
maxDuration?: number | undefined;
|
|
12
|
+
handler: string;
|
|
13
|
+
launcherType: string;
|
|
14
|
+
runtime: "nodejs22.x";
|
|
15
|
+
shouldAddHelpers: boolean;
|
|
16
|
+
supportsCancellation: boolean;
|
|
17
|
+
supportsResponseStreaming: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function createOutputConfig(): {
|
|
20
|
+
routes: ({
|
|
21
|
+
handle: string;
|
|
22
|
+
dest?: undefined;
|
|
23
|
+
src?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
dest: string;
|
|
26
|
+
src: string;
|
|
27
|
+
handle?: undefined;
|
|
28
|
+
})[];
|
|
29
|
+
version: number;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/vercel/build.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,oBAAoB,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,mBAkDzC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,oBAAoB;;;;;;;;;EAapE;AAED,wBAAgB,kBAAkB;;;;;;;;;;;EAQjC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type VercelNodeRuntime = "nodejs22.x";
|
|
2
|
+
export type VercelNodeOptions = {
|
|
3
|
+
maxDuration?: number;
|
|
4
|
+
regions?: readonly string[];
|
|
5
|
+
runtime?: VercelNodeRuntime;
|
|
6
|
+
};
|
|
7
|
+
export type VercelNodeDeployment = {
|
|
8
|
+
adapter: "vercel-node";
|
|
9
|
+
maxDuration?: number;
|
|
10
|
+
regions?: string[];
|
|
11
|
+
runtime: VercelNodeRuntime;
|
|
12
|
+
};
|
|
13
|
+
export declare function vercelNode(options?: VercelNodeOptions): VercelNodeDeployment;
|
|
14
|
+
export declare function validateVercelNodeDeployment(deployment: VercelNodeDeployment): void;
|
|
15
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/vercel/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAE7C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAEF,wBAAgB,UAAU,CACxB,OAAO,GAAE,iBAAsB,GAC9B,oBAAoB,CActB;AAED,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,oBAAoB,QA2BjC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createFunctionConfig, createOutputConfig, generateVercelNodeOutput, } from "./build";
|
|
2
|
+
export type { GenerateVercelNodeOutputOptions } from "./build";
|
|
3
|
+
export { validateVercelNodeDeployment, vercelNode } from "./config";
|
|
4
|
+
export type { VercelNodeDeployment, VercelNodeOptions, VercelNodeRuntime, } from "./config";
|
|
5
|
+
export { createVercelFunction, vercelNodeAdapter, } from "./runtime";
|
|
6
|
+
export type { VercelBuildContext, VercelFunctionEnvironment, VercelFunctionOptions, VercelRequestListener, } from "./runtime";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vercel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACpE,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { c as t, a as r, b as c, g as o, v as n, d, e as l } from "../chunks/runtime-BH519j2t.js";
|
|
2
|
+
export {
|
|
3
|
+
t as createFunctionConfig,
|
|
4
|
+
r as createOutputConfig,
|
|
5
|
+
c as createVercelFunction,
|
|
6
|
+
o as generateVercelNodeOutput,
|
|
7
|
+
n as validateVercelNodeDeployment,
|
|
8
|
+
d as vercelNode,
|
|
9
|
+
l as vercelNodeAdapter
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { type Adapter } from "../adapter";
|
|
3
|
+
import type { ClientBuildManifest } from "../manifest";
|
|
4
|
+
import { type PageRenderer, type RequestCacheStoreOptions, type RequestHandler } from "../server";
|
|
5
|
+
import type { RateLimitStore } from "../security";
|
|
6
|
+
export declare const vercelNodeAdapter: Adapter;
|
|
7
|
+
export type VercelBuildPageOptions = {
|
|
8
|
+
adapter: Adapter;
|
|
9
|
+
cacheStore: RequestCacheStoreOptions;
|
|
10
|
+
clientEntry: string;
|
|
11
|
+
rateLimitStore: RateLimitStore;
|
|
12
|
+
renderPage: PageRenderer;
|
|
13
|
+
styles: string[];
|
|
14
|
+
};
|
|
15
|
+
export type VercelBuildContext = {
|
|
16
|
+
page: VercelBuildPageOptions;
|
|
17
|
+
root?: string;
|
|
18
|
+
};
|
|
19
|
+
export type VercelFunctionEnvironment = Record<string, string | undefined>;
|
|
20
|
+
export type VercelFunctionOptions = {
|
|
21
|
+
allowedHosts?: readonly string[];
|
|
22
|
+
createHandler: (context: VercelBuildContext) => RequestHandler | Promise<RequestHandler>;
|
|
23
|
+
env?: VercelFunctionEnvironment;
|
|
24
|
+
manifest: ClientBuildManifest;
|
|
25
|
+
onError?: (error: unknown, request: IncomingMessage) => void;
|
|
26
|
+
};
|
|
27
|
+
export type VercelRequestListener = (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
28
|
+
export declare function createVercelFunction(options: VercelFunctionOptions): VercelRequest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AK,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,KACrB,OAAO,CAAC,IAAI,CAAC,CAAC;AAQnB,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CAyDvB"}
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
export { assertRootNotFoundRoute as unstable_assertRootNotFoundRoute,
|
|
1
|
+
export { assertRootNotFoundRoute as unstable_assertRootNotFoundRoute, createClientEntrySource as unstable_createClientEntrySource, createClientEnvSource as unstable_createClientEnvSource, createServerEntrySource as unstable_createServerEntrySource, createDocumentHtml as unstable_createDocumentHtml, createDevRouteImporters as unstable_createDevRouteImporters, handleDevRequest as unstable_handleDevRequest, stripClientPageData as unstable_stripClientPageData, verifyRoutePolicies as unstable_verifyRoutePolicies, formatStaticPolicyFindings as unstable_formatStaticPolicyFindings, } from "./plugin";
|
|
2
2
|
export { isRouteAuditEnabled as unstable_isRouteAuditEnabled, } from "./plugin";
|
|
3
|
-
export { verifyRoutePolicySource as unstable_verifyRoutePolicySource, } from "./policy-verification";
|
|
3
|
+
export { auditRouteAccessCoverage as unstable_auditRouteAccessCoverage, declaresPageRoute as unstable_declaresPageRoute, inspectRouteFile as unstable_inspectRouteFile, verifyRoutePolicySource as unstable_verifyRoutePolicySource, } from "./policy-verification";
|
|
4
|
+
export type { DocumentCspState as unstable_DocumentCspState, RouteAccessState as unstable_RouteAccessState, RouteFileInspection as unstable_RouteFileInspection, StaticPolicyFinding as unstable_StaticPolicyFinding, } from "./policy-verification";
|
|
4
5
|
export { findEnvKeyReferences as unstable_findEnvKeyReferences, findImportPath as unstable_findEnvImportPath, findServerEnvKeys as unstable_findServerEnvKeys, formatEnvBoundaryFindings as unstable_formatEnvBoundaryFindings, } from "./env-boundary";
|
|
5
6
|
export type { EnvBoundaryFinding as unstable_EnvBoundaryFinding, } from "./env-boundary";
|
|
6
|
-
export {
|
|
7
|
+
export { formatServerOnlyBoundaryFindings as unstable_formatServerOnlyBoundaryFindings, formatServerOnlyDevError as unstable_formatServerOnlyDevError, importsServerOnlyMarker as unstable_importsServerOnlyMarker, } from "./server-only-boundary";
|
|
8
|
+
export type { ServerOnlyBoundaryFinding as unstable_ServerOnlyBoundaryFinding, } from "./server-only-boundary";
|
|
9
|
+
export { createRouteAudit as unstable_createRouteAudit, renderRouteAuditDocument as unstable_renderRouteAuditDocument, ROUTE_AUDIT_PATH as unstable_ROUTE_AUDIT_PATH, ROUTE_AUDIT_VERSION as unstable_ROUTE_AUDIT_VERSION, } from "./route-audit";
|
|
7
10
|
export { demiurge as unstable_demiurge, } from "./plugin";
|
|
8
11
|
export type { DemiurgeVitePluginApi as unstable_DemiurgeVitePluginApi, DemiurgeVitePluginOptions as unstable_DemiurgeVitePluginOptions, } from "./plugin";
|
|
9
|
-
export type { RouteAudit, RouteAuditCacheRead, RouteAuditRoute, RouteAuditScript, } from "./route-audit";
|
|
12
|
+
export type { RouteAudit as unstable_RouteAudit, RouteAuditCacheRead as unstable_RouteAuditCacheRead, RouteAuditRoute as unstable_RouteAuditRoute, RouteAuditScript as unstable_RouteAuditScript, RouteAuditSection as unstable_RouteAuditSection, } from "./route-audit";
|
|
13
|
+
export { inspectRoutePolicies as unstable_inspectRoutePolicies, } from "./plugin";
|
|
14
|
+
export type { RoutePolicyInspection as unstable_RoutePolicyInspection, } from "./plugin";
|
|
10
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/vite/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,IAAI,gCAAgC,EAC3D,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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gB,IAAI,yBAAyB,EAC7C,mBAAmB,IAAI,4BAA4B,GACpD,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,QAAQ,IAAI,iBAAiB,GAC9B,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,qBAAqB,IAAI,8BAA8B,EACvD,yBAAyB,IAAI,kCAAkC,GAChE,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,UAAU,IAAI,mBAAmB,EACjC,mBAAmB,IAAI,4BAA4B,EACnD,eAAe,IAAI,wBAAwB,EAC3C,gBAAgB,IAAI,yBAAyB,EAC7C,iBAAiB,IAAI,0BAA0B,GAChD,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,IAAI,6BAA6B,GACtD,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,qBAAqB,IAAI,8BAA8B,GACxD,MAAM,UAAU,CAAC"}
|
package/dist/vite/index.js
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import { R as t, a as s,
|
|
1
|
+
import { R as t, a as s, b as n, c as u, d as r, e as l, f as o, g as i, h as _, i as b, j as c, k as d, l as R, m as v, n as y, o as m, p as f, q as E, r as S, s as g, t as p, u as A, v as D, w as P, x as O, y as F, z as I, A as T } from "../chunks/plugin-bkP6WwrS.js";
|
|
2
2
|
export {
|
|
3
3
|
t as unstable_ROUTE_AUDIT_PATH,
|
|
4
|
-
s as
|
|
5
|
-
n as
|
|
6
|
-
u as
|
|
7
|
-
r as
|
|
8
|
-
l as
|
|
9
|
-
o as
|
|
10
|
-
i as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
c as
|
|
14
|
-
d as
|
|
15
|
-
R as
|
|
16
|
-
v as
|
|
17
|
-
|
|
18
|
-
m as
|
|
19
|
-
|
|
20
|
-
E as
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
s as unstable_ROUTE_AUDIT_VERSION,
|
|
5
|
+
n as unstable_assertRootNotFoundRoute,
|
|
6
|
+
u as unstable_auditRouteAccessCoverage,
|
|
7
|
+
r as unstable_createClientEntrySource,
|
|
8
|
+
l as unstable_createClientEnvSource,
|
|
9
|
+
o as unstable_createDevRouteImporters,
|
|
10
|
+
i as unstable_createDocumentHtml,
|
|
11
|
+
_ as unstable_createRouteAudit,
|
|
12
|
+
b as unstable_createServerEntrySource,
|
|
13
|
+
c as unstable_declaresPageRoute,
|
|
14
|
+
d as unstable_demiurge,
|
|
15
|
+
R as unstable_findEnvImportPath,
|
|
16
|
+
v as unstable_findEnvKeyReferences,
|
|
17
|
+
y as unstable_findServerEnvKeys,
|
|
18
|
+
m as unstable_formatEnvBoundaryFindings,
|
|
19
|
+
f as unstable_formatServerOnlyBoundaryFindings,
|
|
20
|
+
E as unstable_formatServerOnlyDevError,
|
|
21
|
+
S as unstable_formatStaticPolicyFindings,
|
|
22
|
+
g as unstable_handleDevRequest,
|
|
23
|
+
p as unstable_importsServerOnlyMarker,
|
|
24
|
+
A as unstable_inspectRouteFile,
|
|
25
|
+
D as unstable_inspectRoutePolicies,
|
|
26
|
+
P as unstable_isRouteAuditEnabled,
|
|
27
|
+
O as unstable_renderRouteAuditDocument,
|
|
28
|
+
F as unstable_stripClientPageData,
|
|
29
|
+
I as unstable_verifyRoutePolicies,
|
|
30
|
+
T as unstable_verifyRoutePolicySource
|
|
24
31
|
};
|
|
25
32
|
//# sourceMappingURL=index.js.map
|
package/dist/vite/plugin.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type RouteImporter } from "../route";
|
|
|
6
6
|
import type { FontContribution } from "../platform/fonts";
|
|
7
7
|
import type { ImagePolicy } from "../platform/images";
|
|
8
8
|
import type { EnvSchema, EnvSource } from "../security/env";
|
|
9
|
-
import { type StaticPolicyFinding } from "./policy-verification";
|
|
9
|
+
import { type RouteFileInspection, type StaticPolicyFinding } from "./policy-verification";
|
|
10
10
|
import type { StaticFileHeaderPatternRule, VercelStaticDeployment } from "../static";
|
|
11
11
|
import { type LocaleConfiguration } from "../routing";
|
|
12
12
|
export type DemiurgeVitePluginOptions = {
|
|
@@ -44,7 +44,6 @@ export declare function createServerEntrySource(root: string, options?: Demiurge
|
|
|
44
44
|
export declare function isRouteAuditEnabled(options: DemiurgeVitePluginOptions): boolean;
|
|
45
45
|
export declare function createDevImageOptimizer(server: ViteDevServer, options: DemiurgeVitePluginOptions): import("../node").StaticFileHandler;
|
|
46
46
|
export declare function assertRootNotFoundRoute(root: string, options?: DemiurgeVitePluginOptions): Promise<void>;
|
|
47
|
-
export declare function declaresPageRoute(source: string): boolean;
|
|
48
47
|
export declare function missingRootNotFoundBuildMessage(routesDir: string, pageRoute: string): string;
|
|
49
48
|
export declare function missingRootNotFoundMessage(notFoundFile: string): string;
|
|
50
49
|
export declare function createDocumentHtml({ entrySrc, lang, links, metadata, nonce, scripts, styles, title, }: {
|
|
@@ -59,6 +58,23 @@ export declare function createDocumentHtml({ entrySrc, lang, links, metadata, no
|
|
|
59
58
|
}): string;
|
|
60
59
|
export declare function createDevRouteImporters(server: ViteDevServer, routesDir: string): Promise<Record<string, RouteImporter>>;
|
|
61
60
|
export declare function handleDevRequest(manifest: RouteManifest, request: Request, options?: Parameters<typeof handleRequestWithManifest>[2]): Promise<Response | "next">;
|
|
61
|
+
/** The result of one static pass over the route tree. */
|
|
62
|
+
export type RoutePolicyInspection = {
|
|
63
|
+
/** Every finding of the pass, in a stable order. */
|
|
64
|
+
findings: StaticPolicyFinding[];
|
|
65
|
+
/** The inspection of each route file, in the order that the walk found. */
|
|
66
|
+
inspections: RouteFileInspection[];
|
|
67
|
+
/** The absolute path of the route directory. */
|
|
68
|
+
routesDir: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Reads the route tree once and returns the findings and the inspections.
|
|
72
|
+
*
|
|
73
|
+
* The build verifier and the `demiurge inspect` command both call this
|
|
74
|
+
* function, so one pass gives one answer for the route tree.
|
|
75
|
+
*/
|
|
76
|
+
export declare function inspectRoutePolicies(root: string, options?: DemiurgeVitePluginOptions): Promise<RoutePolicyInspection>;
|
|
62
77
|
export declare function verifyRoutePolicies(root: string, options?: DemiurgeVitePluginOptions): Promise<StaticPolicyFinding[]>;
|
|
63
78
|
export declare function formatStaticPolicyFindings(findings: StaticPolicyFinding[]): string;
|
|
79
|
+
export declare function formatStaticPolicyFinding(finding: StaticPolicyFinding): string;
|
|
64
80
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,MAAM,EAEX,KAAK,aAAa,EACnB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EACV,OAAO,EACP,gBAAgB,EAChB,SAAS,EACV,MAAM,aAAa,CAAC;AAGrB,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,yBAAyB,EAI1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,UAAU,CAAC;AAUlB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,MAAM,EAEX,KAAK,aAAa,EACnB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EACV,OAAO,EACP,gBAAgB,EAChB,SAAS,EACV,MAAM,aAAa,CAAC;AAGrB,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,yBAAyB,EAI1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,UAAU,CAAC;AAUlB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AAiCD,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,MAAM,0CAalB;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAM,8BAU9D;AA0CD,yDAAyD;AACzD,MAAM,MAAM,qBAAqB,GAAG;IAClC,oDAAoD;IACpD,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,2EAA2E;IAC3E,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,qBAAqB,CAAC,CAyBhC;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,yBAA8B,kCAGxC;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,mBAAmB,EAAE,UAKzE;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,UAKrE"}
|
|
@@ -1,10 +1,41 @@
|
|
|
1
|
+
import type { HttpMethod } from "../route";
|
|
2
|
+
import { type StaticPolicyFindingCode } from "../security";
|
|
1
3
|
export type StaticPolicyFinding = {
|
|
2
|
-
code:
|
|
4
|
+
code: StaticPolicyFindingCode;
|
|
3
5
|
exportName?: string;
|
|
4
6
|
file: string;
|
|
5
7
|
message: string;
|
|
6
|
-
severity: "error";
|
|
8
|
+
severity: "error" | "warning";
|
|
7
9
|
};
|
|
10
|
+
export type RouteFileInspection = {
|
|
11
|
+
/** The statically provable access state of the route policy. */
|
|
12
|
+
accessState: RouteAccessState;
|
|
13
|
+
/** `true` when the file exports at least one HTTP method capability. */
|
|
14
|
+
declaresRoute: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* `true` when the file declares a document policy, and also when the policy
|
|
17
|
+
* expression is not statically readable. An unreadable expression is not
|
|
18
|
+
* evidence of an absent policy.
|
|
19
|
+
*/
|
|
20
|
+
declaresDocumentPolicy: boolean;
|
|
21
|
+
/** The statically provable CSP state of the route policy. */
|
|
22
|
+
documentCspState: DocumentCspState;
|
|
23
|
+
declaresPageRoute: boolean;
|
|
24
|
+
file: string;
|
|
25
|
+
findings: StaticPolicyFinding[];
|
|
26
|
+
/** The HTTP methods that the file exports, in a stable order. */
|
|
27
|
+
methods: HttpMethod[];
|
|
28
|
+
};
|
|
29
|
+
export type DocumentCspState = "present" | "false" | "absent" | "unknown";
|
|
30
|
+
/**
|
|
31
|
+
* `declared` means the file states access. `unknown` means the expression is
|
|
32
|
+
* not statically readable, which is not evidence of an absent declaration.
|
|
33
|
+
*/
|
|
34
|
+
export type RouteAccessState = "declared" | "absent" | "unknown";
|
|
8
35
|
export declare function verifyRoutePolicyFile(file: string): Promise<StaticPolicyFinding[]>;
|
|
36
|
+
export declare function inspectRouteFile(file: string): Promise<RouteFileInspection>;
|
|
9
37
|
export declare function verifyRoutePolicySource(source: string, file: string): Promise<StaticPolicyFinding[]>;
|
|
38
|
+
export declare function auditDocumentPolicyCoverage(routesDir: string, inspections: readonly RouteFileInspection[]): StaticPolicyFinding[];
|
|
39
|
+
export declare function auditRouteAccessCoverage(routesDir: string, inspections: readonly RouteFileInspection[]): StaticPolicyFinding[];
|
|
40
|
+
export declare function declaresPageRoute(source: string): boolean;
|
|
10
41
|
//# sourceMappingURL=policy-verification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-verification.d.ts","sourceRoot":"","sources":["../../src/vite/policy-verification.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"policy-verification.d.ts","sourceRoot":"","sources":["../../src/vite/policy-verification.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CA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W,EAAE,SAAS,mBAAmB,EAAE,GAC1C,mBAAmB,EAAE,CAgCvB;AA0GD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,WAsB/C"}
|
|
@@ -2,7 +2,13 @@ import { type CacheScope } from "../data";
|
|
|
2
2
|
import type { ResolvedMetadata } from "../document";
|
|
3
3
|
import { type RouteManifest } from "../router";
|
|
4
4
|
import type { HttpMethod, PageRenderMode, PathVars } from "../route";
|
|
5
|
-
import { type
|
|
5
|
+
import { type MergedRoutePolicy, type SecurityAudit, type SecurityAuditFinding } from "../security";
|
|
6
|
+
import type { InspectionResolution } from "../inspect/types";
|
|
7
|
+
/**
|
|
8
|
+
* The version of the route report. ADR 0019 raises this integer when the
|
|
9
|
+
* framework removes a field or changes the meaning of a field.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ROUTE_AUDIT_VERSION = 1;
|
|
6
12
|
export declare const ROUTE_AUDIT_PATH = "/_demiurge/audit";
|
|
7
13
|
export type RouteAuditCacheRead = {
|
|
8
14
|
key: string;
|
|
@@ -30,6 +36,8 @@ export type RouteAuditRoute = {
|
|
|
30
36
|
policies: string[];
|
|
31
37
|
render?: PageRenderMode;
|
|
32
38
|
};
|
|
39
|
+
/** The named sections of the route report. */
|
|
40
|
+
export type RouteAuditSection = "audit" | "cacheReads" | "metadata" | "policy" | "route" | "scripts";
|
|
33
41
|
export type RouteAudit = {
|
|
34
42
|
audit: SecurityAudit;
|
|
35
43
|
cacheControl?: string;
|
|
@@ -39,9 +47,13 @@ export type RouteAudit = {
|
|
|
39
47
|
method: HttpMethod;
|
|
40
48
|
nonce?: string;
|
|
41
49
|
pathname: string;
|
|
42
|
-
policy:
|
|
50
|
+
policy: MergedRoutePolicy;
|
|
51
|
+
/** The resolution of each section of the report. */
|
|
52
|
+
resolutions: Record<RouteAuditSection, InspectionResolution>;
|
|
43
53
|
route?: RouteAuditRoute;
|
|
44
54
|
scripts: RouteAuditScript[];
|
|
55
|
+
/** The version of this report shape. */
|
|
56
|
+
version: number;
|
|
45
57
|
};
|
|
46
58
|
export declare function isRouteAuditRequest(request: Request): boolean;
|
|
47
59
|
export declare function createRouteAuditResponse(manifest: RouteManifest, request: Request): Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-audit.d.ts","sourceRoot":"","sources":["../../src/vite/route-audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,gBAAgB,EAAa,MAAM,aAAa,CAAC;AAC/D,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,QAAQ,EAET,MAAM,UAAU,CAAC;AAElB,OAAO,EAGL,KAAK,
|
|
1
|
+
{"version":3,"file":"route-audit.d.ts","sourceRoot":"","sources":["../../src/vite/route-audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,gBAAgB,EAAa,MAAM,aAAa,CAAC;AAC/D,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,QAAQ,EAET,MAAM,UAAU,CAAC;AAElB,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAIrC,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAYnD,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,UAAU,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,IAAI,EAAE,MAA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K,CAAC,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,WAEnD;AAED,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,OAAO,qBA4BjB;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,UAAU,CAAC,CA6ErB;AAkHD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,UAAU,UA8B1D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ServerOnlyBoundaryFinding = {
|
|
2
|
+
importPath: string[];
|
|
3
|
+
module: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function importsServerOnlyMarker(code: string): boolean;
|
|
6
|
+
export declare function formatServerOnlyBoundaryFindings(findings: ServerOnlyBoundaryFinding[]): string;
|
|
7
|
+
export declare function formatServerOnlyDevError(module: string): string;
|
|
8
|
+
//# sourceMappingURL=server-only-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-only-boundary.d.ts","sourceRoot":"","sources":["../../src/vite/server-only-boundary.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAcF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI7D;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,yBAAyB,EAAE,UAOtC;AAKD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,UAItD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@demiurgejs/core",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.6",
|
|
4
4
|
"description": "A React framework for secure routing, server rendering, and framework-managed HTML documents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "North Shore Software Labs",
|
|
@@ -49,6 +49,10 @@
|
|
|
49
49
|
"types": "./dist/deployment/testing.d.ts",
|
|
50
50
|
"default": "./dist/deployment/testing.js"
|
|
51
51
|
},
|
|
52
|
+
"./testing": {
|
|
53
|
+
"types": "./dist/testing/index.d.ts",
|
|
54
|
+
"default": "./dist/testing/index.js"
|
|
55
|
+
},
|
|
52
56
|
"./internal/testing": {
|
|
53
57
|
"types": "./dist/internal/testing.d.ts",
|
|
54
58
|
"default": "./dist/internal/testing.js"
|
|
@@ -73,6 +77,10 @@
|
|
|
73
77
|
"types": "./dist/edge/index.d.ts",
|
|
74
78
|
"default": "./dist/edge/index.js"
|
|
75
79
|
},
|
|
80
|
+
"./vercel": {
|
|
81
|
+
"types": "./dist/vercel/index.d.ts",
|
|
82
|
+
"default": "./dist/vercel/index.js"
|
|
83
|
+
},
|
|
76
84
|
"./kv": {
|
|
77
85
|
"types": "./dist/kv/index.d.ts",
|
|
78
86
|
"default": "./dist/kv/index.js"
|
|
@@ -84,6 +92,15 @@
|
|
|
84
92
|
"./static": {
|
|
85
93
|
"types": "./dist/static/index.d.ts",
|
|
86
94
|
"default": "./dist/static/index.js"
|
|
95
|
+
},
|
|
96
|
+
"./static/testing": {
|
|
97
|
+
"types": "./dist/static/testing.d.ts",
|
|
98
|
+
"default": "./dist/static/testing.js"
|
|
99
|
+
},
|
|
100
|
+
"./server-only": {
|
|
101
|
+
"types": "./dist/server-only/index.d.ts",
|
|
102
|
+
"browser": "./dist/server-only/browser.js",
|
|
103
|
+
"default": "./dist/server-only/index.js"
|
|
87
104
|
}
|
|
88
105
|
},
|
|
89
106
|
"scripts": {
|