@demiurgejs/core 0.2.0-beta.4 → 0.2.0-beta.5
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 +23 -0
- package/bin/demiurge.mjs +17 -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-9GPwtcTt.js} +2 -2
- package/dist/chunks/{document-shell-CpJnFtSC.js.map → document-shell-9GPwtcTt.js.map} +1 -1
- package/dist/chunks/{image-codec-BmzWnH6W.js → image-codec-Dh1POFhE.js} +2 -2
- package/dist/chunks/{image-codec-BmzWnH6W.js.map → image-codec-Dh1POFhE.js.map} +1 -1
- package/dist/chunks/{images-BQ80950B.js → images-CG7ZzayG.js} +2 -2
- package/dist/chunks/{images-BQ80950B.js.map → images-CG7ZzayG.js.map} +1 -1
- package/dist/chunks/{index-BVk9zWbe.js → index-0MNiR_wo.js} +4 -3
- package/dist/chunks/{index-BVk9zWbe.js.map → index-0MNiR_wo.js.map} +1 -1
- package/dist/chunks/plugin-BZauDxRY.js +2310 -0
- package/dist/chunks/plugin-BZauDxRY.js.map +1 -0
- package/dist/chunks/streaming-GYIsVTQH.js +560 -0
- package/dist/chunks/streaming-GYIsVTQH.js.map +1 -0
- package/dist/chunks/testing-CUwGj2ie.js +4751 -0
- package/dist/chunks/testing-CUwGj2ie.js.map +1 -0
- package/dist/chunks/{vite-DO70kZA6.js → vite-QoqrGl6f.js} +43 -43
- package/dist/chunks/vite-QoqrGl6f.js.map +1 -0
- package/dist/cli.d.ts +4 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +224 -98
- package/dist/cli.js.map +1 -1
- package/dist/config/index.js +2 -2
- package/dist/config/types.d.ts +11 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/edge/index.js +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +161 -139
- 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/node/http.d.ts +5 -0
- package/dist/node/http.d.ts.map +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +26 -24
- package/dist/node/index.js.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.js +4 -4
- 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 +6 -1
- package/dist/chunks/env-startup-DOBYWlZD.js +0 -257
- package/dist/chunks/env-startup-DOBYWlZD.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 +0 -4167
- package/dist/chunks/testing-DueXbMo4.js.map +0 -1
- package/dist/chunks/vite-DO70kZA6.js.map +0 -1
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,KA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AM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,UAWA;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,CAAC;AAC3C,OAAO,EAgBL,KAAK,uBAAuB,EAC7B,MAAM,aAAa,CAAC;AAiBrB,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,gEAAgE;IAChE,WAAW,EAAE,gBAAgB,CAAC;IAC9B,wEAAwE;IACxE,aAAa,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC,6DAA6D;IAC7D,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,iEAAiE;IACjE,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAsCjE,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,kCAEvD;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,mBAAmB,CAAC,CAmB9B;AAED,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kCAKzE;AAmBD,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,SAAS,mBAAmB,EAAE,GAC1C,mBAAmB,EAAE,CAkCvB;AAKD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,WAAW,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,KA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AM,GAAG,UAAU,GAAG,WAAW,CAAC;IACxC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;IAC7D,KAAK,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.5",
|
|
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",
|
|
@@ -84,6 +84,11 @@
|
|
|
84
84
|
"./static": {
|
|
85
85
|
"types": "./dist/static/index.d.ts",
|
|
86
86
|
"default": "./dist/static/index.js"
|
|
87
|
+
},
|
|
88
|
+
"./server-only": {
|
|
89
|
+
"types": "./dist/server-only/index.d.ts",
|
|
90
|
+
"browser": "./dist/server-only/browser.js",
|
|
91
|
+
"default": "./dist/server-only/index.js"
|
|
87
92
|
}
|
|
88
93
|
},
|
|
89
94
|
"scripts": {
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
class g extends Error {
|
|
2
|
-
issues;
|
|
3
|
-
constructor(n) {
|
|
4
|
-
super(j(n)), this.name = "EnvValidationError", this.issues = n;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
function L(e) {
|
|
8
|
-
return e;
|
|
9
|
-
}
|
|
10
|
-
function A(e, n) {
|
|
11
|
-
const r = [], t = {};
|
|
12
|
-
for (const i of Object.keys(e)) {
|
|
13
|
-
const s = e[i], a = n[String(i)];
|
|
14
|
-
if (a === void 0 || a === "") {
|
|
15
|
-
if (s.optional) {
|
|
16
|
-
t[i] = void 0;
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
r.push({
|
|
20
|
-
code: "missing",
|
|
21
|
-
key: String(i),
|
|
22
|
-
message: `Environment variable ${String(i)} is required.`
|
|
23
|
-
});
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
t[i] = s.parse(String(i), a);
|
|
28
|
-
} catch (u) {
|
|
29
|
-
r.push({
|
|
30
|
-
code: "invalid",
|
|
31
|
-
key: String(i),
|
|
32
|
-
message: u instanceof Error ? u.message : `Environment variable ${String(i)} is invalid.`
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (r.length)
|
|
37
|
-
throw new g(r);
|
|
38
|
-
return t;
|
|
39
|
-
}
|
|
40
|
-
function b(e = {}) {
|
|
41
|
-
return f(e, !1, (n, r) => {
|
|
42
|
-
if (r === "true" || r === "1")
|
|
43
|
-
return !0;
|
|
44
|
-
if (r === "false" || r === "0")
|
|
45
|
-
return !1;
|
|
46
|
-
throw new Error(`Environment variable ${n} must be true, false, 1, or 0.`);
|
|
47
|
-
}, "boolean");
|
|
48
|
-
}
|
|
49
|
-
function w(e, n = {}) {
|
|
50
|
-
return f(n, !1, (r, t) => {
|
|
51
|
-
if (e.includes(t))
|
|
52
|
-
return t;
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Environment variable ${r} must be one of: ${e.join(", ")}.`
|
|
55
|
-
);
|
|
56
|
-
}, "enum", { values: [...e] });
|
|
57
|
-
}
|
|
58
|
-
function $(e = {}) {
|
|
59
|
-
return f(e, !1, (n, r) => {
|
|
60
|
-
if (!/^-?\d+$/.test(r))
|
|
61
|
-
throw new Error(`Environment variable ${n} must be an integer.`);
|
|
62
|
-
const t = Number(r);
|
|
63
|
-
if (!Number.isSafeInteger(t))
|
|
64
|
-
throw new Error(`Environment variable ${n} must be a safe integer.`);
|
|
65
|
-
if (e.min !== void 0 && t < e.min)
|
|
66
|
-
throw new Error(
|
|
67
|
-
`Environment variable ${n} must be greater than or equal to ${e.min}.`
|
|
68
|
-
);
|
|
69
|
-
if (e.max !== void 0 && t > e.max)
|
|
70
|
-
throw new Error(
|
|
71
|
-
`Environment variable ${n} must be less than or equal to ${e.max}.`
|
|
72
|
-
);
|
|
73
|
-
return t;
|
|
74
|
-
}, "integer");
|
|
75
|
-
}
|
|
76
|
-
function p(e = {}) {
|
|
77
|
-
return f(
|
|
78
|
-
e,
|
|
79
|
-
!0,
|
|
80
|
-
(n, r) => d(n, r, e),
|
|
81
|
-
"secret"
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
function k(e = {}) {
|
|
85
|
-
return f(
|
|
86
|
-
e,
|
|
87
|
-
!1,
|
|
88
|
-
(n, r) => d(n, r, e),
|
|
89
|
-
"string"
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
function S(e = {}) {
|
|
93
|
-
return f(e, !1, (n, r) => {
|
|
94
|
-
let t;
|
|
95
|
-
try {
|
|
96
|
-
t = new URL(r);
|
|
97
|
-
} catch {
|
|
98
|
-
throw new Error(`Environment variable ${n} must be a valid URL.`);
|
|
99
|
-
}
|
|
100
|
-
if (e.protocols?.length && !e.protocols.includes(t.protocol))
|
|
101
|
-
throw new Error(
|
|
102
|
-
`Environment variable ${n} must use one of these protocols: ${e.protocols.join(", ")}.`
|
|
103
|
-
);
|
|
104
|
-
return t;
|
|
105
|
-
}, "url");
|
|
106
|
-
}
|
|
107
|
-
const l = {
|
|
108
|
-
boolean: b,
|
|
109
|
-
enum: w,
|
|
110
|
-
integer: $,
|
|
111
|
-
secret: p,
|
|
112
|
-
string: k,
|
|
113
|
-
url: S
|
|
114
|
-
};
|
|
115
|
-
function f(e, n, r, t = "string", i = {}) {
|
|
116
|
-
const s = { ...e, ...i }, { client: a = !1, critical: u = !1, optional: o = !1, ...c } = s;
|
|
117
|
-
if (a && n)
|
|
118
|
-
throw new Error(
|
|
119
|
-
"A secret environment variable cannot reach client code. Declare a separate variable for the browser."
|
|
120
|
-
);
|
|
121
|
-
return {
|
|
122
|
-
client: a,
|
|
123
|
-
critical: u,
|
|
124
|
-
kind: t,
|
|
125
|
-
optional: o,
|
|
126
|
-
options: c,
|
|
127
|
-
parse: r,
|
|
128
|
-
sensitive: n
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
function d(e, n, r) {
|
|
132
|
-
if (r.minLength !== void 0 && n.length < r.minLength)
|
|
133
|
-
throw new Error(
|
|
134
|
-
`Environment variable ${e} must be at least ${r.minLength} characters.`
|
|
135
|
-
);
|
|
136
|
-
return n;
|
|
137
|
-
}
|
|
138
|
-
function j(e) {
|
|
139
|
-
return e.length === 1 ? e[0].message : `Environment validation failed with ${e.length} issues.`;
|
|
140
|
-
}
|
|
141
|
-
const v = /* @__PURE__ */ new Map();
|
|
142
|
-
function D(e) {
|
|
143
|
-
return Object.fromEntries(
|
|
144
|
-
Object.entries(e).map(([n, r]) => [n, {
|
|
145
|
-
client: r.client,
|
|
146
|
-
critical: r.critical,
|
|
147
|
-
kind: r.kind,
|
|
148
|
-
optional: r.optional,
|
|
149
|
-
options: r.options,
|
|
150
|
-
sensitive: r.sensitive
|
|
151
|
-
}])
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
function y(e) {
|
|
155
|
-
return Object.fromEntries(
|
|
156
|
-
Object.entries(e).map(([n, r]) => [
|
|
157
|
-
n,
|
|
158
|
-
O(n, r)
|
|
159
|
-
])
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
function T(e, n = {}) {
|
|
163
|
-
const r = V(e) ? e : y(e), t = n.source ?? q(), i = [], s = [], a = {};
|
|
164
|
-
for (const [o, c] of Object.entries(r)) {
|
|
165
|
-
const m = t[o];
|
|
166
|
-
if (m === void 0 || m === "") {
|
|
167
|
-
if (a[o] = void 0, c.optional) continue;
|
|
168
|
-
E(c, i, s, {
|
|
169
|
-
code: "missing",
|
|
170
|
-
key: o,
|
|
171
|
-
message: `Environment variable ${o} is required.`
|
|
172
|
-
});
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
try {
|
|
176
|
-
a[o] = c.parse(o, m);
|
|
177
|
-
} catch (h) {
|
|
178
|
-
a[o] = void 0, E(c, i, s, {
|
|
179
|
-
code: "invalid",
|
|
180
|
-
key: o,
|
|
181
|
-
message: h instanceof Error ? h.message : `Environment variable ${o} is invalid.`
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (i.length) throw new g(i);
|
|
186
|
-
const u = n.warn ?? x;
|
|
187
|
-
for (const o of s) u(o);
|
|
188
|
-
for (const [o, c] of Object.entries(a)) v.set(o, c);
|
|
189
|
-
return { values: a, warnings: s };
|
|
190
|
-
}
|
|
191
|
-
function z(e) {
|
|
192
|
-
const n = {};
|
|
193
|
-
for (const r of Object.keys(e)) {
|
|
194
|
-
if (!v.has(r))
|
|
195
|
-
throw new Error(
|
|
196
|
-
`Demiurge did not validate the environment variable ${r}. The framework validates the schema of demiurge.config.ts when the server starts.`
|
|
197
|
-
);
|
|
198
|
-
n[r] = v.get(r);
|
|
199
|
-
}
|
|
200
|
-
return n;
|
|
201
|
-
}
|
|
202
|
-
function N() {
|
|
203
|
-
v.clear();
|
|
204
|
-
}
|
|
205
|
-
function E(e, n, r, t) {
|
|
206
|
-
if (e.critical) {
|
|
207
|
-
n.push(t);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
r.push(
|
|
211
|
-
`Demiurge started without a valid value for ${t.key}. ${t.message} A request that needs this value fails.`
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
function O(e, n) {
|
|
215
|
-
const r = {
|
|
216
|
-
...n.options,
|
|
217
|
-
client: n.client,
|
|
218
|
-
critical: n.critical,
|
|
219
|
-
optional: n.optional
|
|
220
|
-
};
|
|
221
|
-
if (n.kind === "boolean") return l.boolean(r);
|
|
222
|
-
if (n.kind === "integer") return l.integer(r);
|
|
223
|
-
if (n.kind === "secret") return l.secret(r);
|
|
224
|
-
if (n.kind === "url") return l.url(r);
|
|
225
|
-
if (n.kind === "enum") {
|
|
226
|
-
const t = n.options.values;
|
|
227
|
-
if (!Array.isArray(t) || !t.length)
|
|
228
|
-
throw new Error(
|
|
229
|
-
`The environment variable ${e} does not have the values of its enum.`
|
|
230
|
-
);
|
|
231
|
-
return l.enum(t, r);
|
|
232
|
-
}
|
|
233
|
-
return l.string(r);
|
|
234
|
-
}
|
|
235
|
-
function V(e) {
|
|
236
|
-
return Object.values(e).every(
|
|
237
|
-
(n) => "parse" in n && typeof n.parse == "function"
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
function q() {
|
|
241
|
-
return globalThis.process?.env ?? {};
|
|
242
|
-
}
|
|
243
|
-
function x(e) {
|
|
244
|
-
globalThis.console?.warn?.(e);
|
|
245
|
-
}
|
|
246
|
-
export {
|
|
247
|
-
g as E,
|
|
248
|
-
y as a,
|
|
249
|
-
N as b,
|
|
250
|
-
T as c,
|
|
251
|
-
L as d,
|
|
252
|
-
l as e,
|
|
253
|
-
z as r,
|
|
254
|
-
D as s,
|
|
255
|
-
A as v
|
|
256
|
-
};
|
|
257
|
-
//# sourceMappingURL=env-startup-DOBYWlZD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-startup-DOBYWlZD.js","sources":["../../src/security/env.ts","../../src/security/env-startup.ts"],"sourcesContent":["export type EnvSource = Record<string, string | undefined>;\n\nexport type EnvValidationIssue = {\n code: \"invalid\" | \"missing\";\n key: string;\n message: string;\n};\n\nexport class EnvValidationError extends Error {\n issues: EnvValidationIssue[];\n\n constructor(issues: EnvValidationIssue[]) {\n super(formatEnvValidationError(issues));\n this.name = \"EnvValidationError\";\n this.issues = issues;\n }\n}\n\nexport type EnvVariableKind =\n | \"boolean\"\n | \"enum\"\n | \"integer\"\n | \"secret\"\n | \"string\"\n | \"url\";\n\n// The serializable description of one variable. The framework writes this\n// description into the generated server entry, so the schema of the\n// configuration file reaches the production process without the file.\nexport type EnvVariableDescriptor = {\n // A client variable reaches the browser bundle. The build refuses a client\n // bundle that reads a variable which this field does not mark.\n client: boolean;\n critical: boolean;\n kind: EnvVariableKind;\n optional: boolean;\n options: Record<string, unknown>;\n sensitive: boolean;\n};\n\nexport type EnvSchemaDescriptor = Record<string, EnvVariableDescriptor>;\n\nexport type EnvVariable<T, Optional extends boolean = false> =\n & Omit<EnvVariableDescriptor, \"optional\">\n & {\n optional: Optional;\n parse: (key: string, value: string) => T;\n };\n\nexport type EnvSchema = Record<string, EnvVariable<unknown, boolean>>;\n\nexport type InferEnvSchema<Schema extends EnvSchema> = {\n [Key in keyof Schema]: Schema[Key] extends EnvVariable<infer Value, infer Optional>\n ? Optional extends true\n ? Value | undefined\n : Value\n : never;\n};\n\ntype SharedEnvVariableOptions = {\n // A client variable reaches the browser bundle. The build inlines its value.\n // The default value is false, and the value then stays on the server.\n client?: boolean;\n // A critical variable stops the server start when it is absent or invalid.\n critical?: boolean;\n};\n\ntype RequiredEnvVariableOptions = SharedEnvVariableOptions & {\n optional?: false;\n};\n\ntype OptionalEnvVariableOptions = SharedEnvVariableOptions & {\n optional: true;\n};\n\ntype EnvVariableOptions = RequiredEnvVariableOptions | OptionalEnvVariableOptions;\n\ntype RequiredStringEnvOptions = RequiredEnvVariableOptions & {\n minLength?: number;\n};\n\ntype OptionalStringEnvOptions = OptionalEnvVariableOptions & {\n minLength?: number;\n};\n\ntype StringEnvOptions = RequiredStringEnvOptions | OptionalStringEnvOptions;\n\n// A secret variable never reaches the browser. The option is absent from the\n// type of the builder, and the builder also refuses it at run time.\ntype RequiredSecretEnvOptions = RequiredStringEnvOptions & { client?: never };\n\ntype OptionalSecretEnvOptions = OptionalStringEnvOptions & { client?: never };\n\ntype SecretEnvOptions = RequiredSecretEnvOptions | OptionalSecretEnvOptions;\n\ntype RequiredUrlEnvOptions = RequiredEnvVariableOptions & {\n protocols?: readonly string[];\n};\n\ntype OptionalUrlEnvOptions = OptionalEnvVariableOptions & {\n protocols?: readonly string[];\n};\n\ntype UrlEnvOptions = RequiredUrlEnvOptions | OptionalUrlEnvOptions;\n\ntype RequiredIntegerEnvOptions = RequiredEnvVariableOptions & {\n max?: number;\n min?: number;\n};\n\ntype OptionalIntegerEnvOptions = OptionalEnvVariableOptions & {\n max?: number;\n min?: number;\n};\n\ntype IntegerEnvOptions = RequiredIntegerEnvOptions | OptionalIntegerEnvOptions;\n\nexport function defineEnvSchema<Schema extends EnvSchema>(schema: Schema) {\n return schema;\n}\n\nexport function validateEnv<Schema extends EnvSchema>(\n schema: Schema,\n source: EnvSource,\n): InferEnvSchema<Schema> {\n const issues: EnvValidationIssue[] = [];\n const values: Partial<Record<keyof Schema, unknown>> = {};\n\n // TYPE-EVIDENCE: Object.keys returns the schema keys as strings. The cast narrows them to the schema key type because they come from the schema.\n for (const key of Object.keys(schema) as Array<keyof Schema>) {\n const variable = schema[key];\n const rawValue = source[String(key)];\n\n if (rawValue === undefined || rawValue === \"\") {\n if (variable.optional) {\n values[key] = undefined;\n continue;\n }\n\n issues.push({\n code: \"missing\",\n key: String(key),\n message: `Environment variable ${String(key)} is required.`,\n });\n continue;\n }\n\n try {\n values[key] = variable.parse(String(key), rawValue);\n } catch (error) {\n issues.push({\n code: \"invalid\",\n key: String(key),\n message: error instanceof Error\n ? error.message\n : `Environment variable ${String(key)} is invalid.`,\n });\n }\n }\n\n if (issues.length) {\n throw new EnvValidationError(issues);\n }\n\n // TYPE-EVIDENCE: the loop above populated values from the validated schema entries. The cast restores the inferred schema type.\n return values as InferEnvSchema<Schema>;\n}\n\nfunction booleanEnv(options: OptionalEnvVariableOptions): EnvVariable<boolean, true>;\nfunction booleanEnv(options?: RequiredEnvVariableOptions): EnvVariable<boolean, false>;\nfunction booleanEnv(options: EnvVariableOptions = {}) {\n return createVariable(options, false, (key, value) => {\n if (value === \"true\" || value === \"1\") {\n return true;\n }\n\n if (value === \"false\" || value === \"0\") {\n return false;\n }\n\n throw new Error(`Environment variable ${key} must be true, false, 1, or 0.`);\n }, \"boolean\");\n}\n\nfunction enumEnv<const Values extends readonly [string, ...string[]]>(\n values: Values,\n options: OptionalEnvVariableOptions,\n): EnvVariable<Values[number], true>;\nfunction enumEnv<const Values extends readonly [string, ...string[]]>(\n values: Values,\n options?: RequiredEnvVariableOptions,\n): EnvVariable<Values[number], false>;\nfunction enumEnv<const Values extends readonly [string, ...string[]]>(\n values: Values,\n options: EnvVariableOptions = {},\n) {\n return createVariable(options, false, (key, value) => {\n if (values.includes(value)) {\n return value;\n }\n\n throw new Error(\n `Environment variable ${key} must be one of: ${values.join(\", \")}.`,\n );\n }, \"enum\", { values: [...values] });\n}\n\nfunction integerEnv(options: OptionalIntegerEnvOptions): EnvVariable<number, true>;\nfunction integerEnv(options?: RequiredIntegerEnvOptions): EnvVariable<number, false>;\nfunction integerEnv(options: IntegerEnvOptions = {}) {\n return createVariable(options, false, (key, value) => {\n if (!/^-?\\d+$/.test(value)) {\n throw new Error(`Environment variable ${key} must be an integer.`);\n }\n\n const parsed = Number(value);\n\n if (!Number.isSafeInteger(parsed)) {\n throw new Error(`Environment variable ${key} must be a safe integer.`);\n }\n\n if (options.min !== undefined && parsed < options.min) {\n throw new Error(\n `Environment variable ${key} must be greater than or equal to ${options.min}.`,\n );\n }\n\n if (options.max !== undefined && parsed > options.max) {\n throw new Error(\n `Environment variable ${key} must be less than or equal to ${options.max}.`,\n );\n }\n\n return parsed;\n }, \"integer\");\n}\n\nfunction secretEnv(options: OptionalSecretEnvOptions): EnvVariable<string, true>;\nfunction secretEnv(options?: RequiredSecretEnvOptions): EnvVariable<string, false>;\nfunction secretEnv(options: SecretEnvOptions = {}) {\n return createVariable(\n options,\n true,\n (key, value) => parseString(key, value, options),\n \"secret\",\n );\n}\n\nfunction stringEnv(options: OptionalStringEnvOptions): EnvVariable<string, true>;\nfunction stringEnv(options?: RequiredStringEnvOptions): EnvVariable<string, false>;\nfunction stringEnv(options: StringEnvOptions = {}) {\n return createVariable(\n options,\n false,\n (key, value) => parseString(key, value, options),\n \"string\",\n );\n}\n\nfunction urlEnv(options: OptionalUrlEnvOptions): EnvVariable<URL, true>;\nfunction urlEnv(options?: RequiredUrlEnvOptions): EnvVariable<URL, false>;\nfunction urlEnv(options: UrlEnvOptions = {}) {\n return createVariable(options, false, (key, value) => {\n let url: URL;\n\n try {\n url = new URL(value);\n } catch {\n throw new Error(`Environment variable ${key} must be a valid URL.`);\n }\n\n if (\n options.protocols?.length &&\n !options.protocols.includes(url.protocol)\n ) {\n throw new Error(\n `Environment variable ${key} must use one of these protocols: ${options.protocols.join(\", \")}.`,\n );\n }\n\n return url;\n }, \"url\");\n}\n\nexport const env = {\n boolean: booleanEnv,\n enum: enumEnv,\n integer: integerEnv,\n secret: secretEnv,\n string: stringEnv,\n url: urlEnv,\n};\n\nfunction createVariable<T>(\n options: EnvVariableOptions,\n sensitive: boolean,\n parse: (key: string, value: string) => T,\n kind: EnvVariableKind = \"string\",\n extra: Record<string, unknown> = {},\n): EnvVariable<T, boolean> {\n // TYPE-EVIDENCE: each builder passes its own declared options and its own extra values. The cast reads the shared options and keeps the rest as the serializable description.\n const merged = { ...options, ...extra } as\n & Record<string, unknown>\n & EnvVariableOptions\n & { client?: boolean };\n const { client = false, critical = false, optional = false, ...rest } = merged;\n\n if (client && sensitive) {\n throw new Error(\n \"A secret environment variable cannot reach client code. Declare a separate variable for the browser.\",\n );\n }\n\n return {\n client,\n critical,\n kind,\n optional,\n options: rest,\n parse,\n sensitive,\n };\n}\n\nfunction parseString(\n key: string,\n value: string,\n options: StringEnvOptions,\n) {\n if (options.minLength !== undefined && value.length < options.minLength) {\n throw new Error(\n `Environment variable ${key} must be at least ${options.minLength} characters.`,\n );\n }\n\n return value;\n}\n\nfunction formatEnvValidationError(issues: EnvValidationIssue[]) {\n if (issues.length === 1) {\n return issues[0].message;\n }\n\n return `Environment validation failed with ${issues.length} issues.`;\n}\n","import {\n env,\n EnvValidationError,\n type EnvSchema,\n type EnvSchemaDescriptor,\n type EnvSource,\n type EnvValidationIssue,\n type EnvVariable,\n type EnvVariableDescriptor,\n type InferEnvSchema,\n} from \"./env\";\n\nexport type EnvStartupOptions = {\n source?: EnvSource;\n warn?: (message: string) => void;\n};\n\nexport type EnvStartupResult = {\n values: Record<string, unknown>;\n warnings: string[];\n};\n\nconst initialized = new Map<string, unknown>();\n\n// The configuration file declares the schema. The build writes this\n// description into the generated server entry, because the production process\n// does not read the configuration file.\nexport function serializeEnvSchema(schema: EnvSchema): EnvSchemaDescriptor {\n return Object.fromEntries(\n Object.entries(schema).map(([key, variable]) => [key, {\n client: variable.client,\n critical: variable.critical,\n kind: variable.kind,\n optional: variable.optional,\n options: variable.options,\n sensitive: variable.sensitive,\n }]),\n );\n}\n\nexport function deserializeEnvSchema(\n descriptor: EnvSchemaDescriptor,\n): EnvSchema {\n return Object.fromEntries(\n Object.entries(descriptor).map(([key, variable]) => [\n key,\n createVariableFromDescriptor(key, variable),\n ]),\n );\n}\n\n// The server entry calls this function while the module graph loads. A\n// critical failure therefore stops the process before it accepts traffic.\nexport function startEnvironment(\n schema: EnvSchema | EnvSchemaDescriptor,\n options: EnvStartupOptions = {},\n): EnvStartupResult {\n const resolved = isEnvSchema(schema) ? schema : deserializeEnvSchema(schema);\n const source = options.source ?? readProcessEnvironment();\n const critical: EnvValidationIssue[] = [];\n const warnings: string[] = [];\n const values: Record<string, unknown> = {};\n\n for (const [key, variable] of Object.entries(resolved)) {\n const rawValue = source[key];\n\n if (rawValue === undefined || rawValue === \"\") {\n values[key] = undefined;\n if (variable.optional) continue;\n record(variable, critical, warnings, {\n code: \"missing\",\n key,\n message: `Environment variable ${key} is required.`,\n });\n continue;\n }\n\n try {\n values[key] = variable.parse(key, rawValue);\n } catch (error) {\n values[key] = undefined;\n record(variable, critical, warnings, {\n code: \"invalid\",\n key,\n message: error instanceof Error\n ? error.message\n : `Environment variable ${key} is invalid.`,\n });\n }\n }\n\n if (critical.length) throw new EnvValidationError(critical);\n\n const warn = options.warn ?? defaultWarn;\n for (const warning of warnings) warn(warning);\n for (const [key, value] of Object.entries(values)) initialized.set(key, value);\n\n return { values, warnings };\n}\n\n// Applications read the validated values with the types that the schema\n// declares. This function is server-only.\nexport function readEnv<Schema extends EnvSchema>(\n schema: Schema,\n): InferEnvSchema<Schema> {\n const values: Record<string, unknown> = {};\n\n for (const key of Object.keys(schema)) {\n if (!initialized.has(key)) {\n throw new Error(\n `Demiurge did not validate the environment variable ${key}. The framework validates the schema of demiurge.config.ts when the server starts.`,\n );\n }\n values[key] = initialized.get(key);\n }\n\n // TYPE-EVIDENCE: startEnvironment parsed each value with the same schema. The cast restores the inferred schema type.\n return values as InferEnvSchema<Schema>;\n}\n\nexport function resetEnvironment() {\n initialized.clear();\n}\n\nfunction record(\n variable: { critical: boolean },\n critical: EnvValidationIssue[],\n warnings: string[],\n issue: EnvValidationIssue,\n) {\n if (variable.critical) {\n critical.push(issue);\n return;\n }\n warnings.push(\n `Demiurge started without a valid value for ${issue.key}. ${issue.message} A request that needs this value fails.`,\n );\n}\n\nfunction createVariableFromDescriptor(\n key: string,\n descriptor: EnvVariableDescriptor,\n): EnvVariable<unknown, boolean> {\n // TYPE-EVIDENCE: serializeEnvSchema wrote these options from a builder call. The cast returns them to the overloaded builder parameter.\n const options = {\n ...descriptor.options,\n client: descriptor.client,\n critical: descriptor.critical,\n optional: descriptor.optional,\n } as never;\n\n if (descriptor.kind === \"boolean\") return env.boolean(options);\n if (descriptor.kind === \"integer\") return env.integer(options);\n if (descriptor.kind === \"secret\") return env.secret(options);\n if (descriptor.kind === \"url\") return env.url(options);\n if (descriptor.kind === \"enum\") {\n const values = descriptor.options.values;\n if (!Array.isArray(values) || !values.length) {\n throw new Error(\n `The environment variable ${key} does not have the values of its enum.`,\n );\n }\n // TYPE-EVIDENCE: the descriptor keeps the declared enum values. The cast restores the tuple type that the builder needs.\n return env.enum(values as [string, ...string[]], options);\n }\n return env.string(options);\n}\n\nfunction isEnvSchema(\n schema: EnvSchema | EnvSchemaDescriptor,\n): schema is EnvSchema {\n return Object.values(schema).every(\n (variable) => \"parse\" in variable && typeof variable.parse === \"function\",\n );\n}\n\nfunction readProcessEnvironment(): EnvSource {\n // TYPE-EVIDENCE: the framework runs this function on a server runtime. The cast reads the process environment without a Node type dependency here.\n const runtime = globalThis as { process?: { env?: EnvSource } };\n return runtime.process?.env ?? {};\n}\n\nfunction defaultWarn(message: string) {\n // TYPE-EVIDENCE: a server runtime supplies console. The cast keeps the warning optional.\n const runtime = globalThis as {\n console?: { warn?: (message: string) => void };\n };\n runtime.console?.warn?.(message);\n}\n"],"names":["EnvValidationError","issues","formatEnvValidationError","defineEnvSchema","schema","validateEnv","source","values","key","variable","rawValue","error","booleanEnv","options","createVariable","value","enumEnv","integerEnv","parsed","secretEnv","parseString","stringEnv","urlEnv","url","env","sensitive","parse","kind","extra","merged","client","critical","optional","rest","initialized","serializeEnvSchema","deserializeEnvSchema","descriptor","createVariableFromDescriptor","startEnvironment","resolved","isEnvSchema","readProcessEnvironment","warnings","record","warn","defaultWarn","warning","readEnv","resetEnvironment","issue","message"],"mappings":"AAQO,MAAMA,UAA2B,MAAM;AAAA,EAC5C;AAAA,EAEA,YAAYC,GAA8B;AACxC,UAAMC,EAAyBD,CAAM,CAAC,GACtC,KAAK,OAAO,sBACZ,KAAK,SAASA;AAAA,EAChB;AACF;AAqGO,SAASE,EAA0CC,GAAgB;AACxE,SAAOA;AACT;AAEO,SAASC,EACdD,GACAE,GACwB;AACxB,QAAML,IAA+B,CAAA,GAC/BM,IAAiD,CAAA;AAGvD,aAAWC,KAAO,OAAO,KAAKJ,CAAM,GAA0B;AAC5D,UAAMK,IAAWL,EAAOI,CAAG,GACrBE,IAAWJ,EAAO,OAAOE,CAAG,CAAC;AAEnC,QAAIE,MAAa,UAAaA,MAAa,IAAI;AAC7C,UAAID,EAAS,UAAU;AACrB,QAAAF,EAAOC,CAAG,IAAI;AACd;AAAA,MACF;AAEA,MAAAP,EAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,KAAK,OAAOO,CAAG;AAAA,QACf,SAAS,wBAAwB,OAAOA,CAAG,CAAC;AA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