@demiurgejs/core 0.0.0 → 0.1.1

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.
Files changed (157) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -2
  3. package/dist/adapter/index.d.ts +20 -0
  4. package/dist/adapter/index.d.ts.map +1 -0
  5. package/dist/browser/file-router.d.ts +35 -0
  6. package/dist/browser/file-router.d.ts.map +1 -0
  7. package/dist/browser/index.d.ts +3 -0
  8. package/dist/browser/index.d.ts.map +1 -0
  9. package/dist/chunks/index-BnX9Qxbm.js +44 -0
  10. package/dist/chunks/index-BnX9Qxbm.js.map +1 -0
  11. package/dist/chunks/ssr-BJejKlkZ.js +275 -0
  12. package/dist/chunks/ssr-BJejKlkZ.js.map +1 -0
  13. package/dist/chunks/static-files-DUjHw-4H.js +11 -0
  14. package/dist/chunks/static-files-DUjHw-4H.js.map +1 -0
  15. package/dist/chunks/streaming-DN1DnbRE.js +343 -0
  16. package/dist/chunks/streaming-DN1DnbRE.js.map +1 -0
  17. package/dist/chunks/testing-DR3eQAvY.js +2872 -0
  18. package/dist/chunks/testing-DR3eQAvY.js.map +1 -0
  19. package/dist/data/cache.d.ts +95 -0
  20. package/dist/data/cache.d.ts.map +1 -0
  21. package/dist/data/idempotency.d.ts +24 -0
  22. package/dist/data/idempotency.d.ts.map +1 -0
  23. package/dist/data/index.d.ts +5 -0
  24. package/dist/data/index.d.ts.map +1 -0
  25. package/dist/data/testing.d.ts +7 -0
  26. package/dist/data/testing.d.ts.map +1 -0
  27. package/dist/data/testing.js +134 -0
  28. package/dist/data/testing.js.map +1 -0
  29. package/dist/document/hydration.d.ts +13 -0
  30. package/dist/document/hydration.d.ts.map +1 -0
  31. package/dist/document/index.d.ts +13 -0
  32. package/dist/document/index.d.ts.map +1 -0
  33. package/dist/document/links.d.ts +17 -0
  34. package/dist/document/links.d.ts.map +1 -0
  35. package/dist/document/metadata.d.ts +62 -0
  36. package/dist/document/metadata.d.ts.map +1 -0
  37. package/dist/document/render.d.ts +29 -0
  38. package/dist/document/render.d.ts.map +1 -0
  39. package/dist/document/scripts.d.ts +24 -0
  40. package/dist/document/scripts.d.ts.map +1 -0
  41. package/dist/document/seo.d.ts +42 -0
  42. package/dist/document/seo.d.ts.map +1 -0
  43. package/dist/index.d.ts +23 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +1328 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/internal/testing.d.ts +3 -0
  48. package/dist/internal/testing.d.ts.map +1 -0
  49. package/dist/internal/testing.js +22 -0
  50. package/dist/internal/testing.js.map +1 -0
  51. package/dist/node/http.d.ts +28 -0
  52. package/dist/node/http.d.ts.map +1 -0
  53. package/dist/node/index.d.ts +45 -0
  54. package/dist/node/index.d.ts.map +1 -0
  55. package/dist/node/index.js +386 -0
  56. package/dist/node/index.js.map +1 -0
  57. package/dist/node/static.d.ts +9 -0
  58. package/dist/node/static.d.ts.map +1 -0
  59. package/dist/node/streaming.d.ts +5 -0
  60. package/dist/node/streaming.d.ts.map +1 -0
  61. package/dist/package-name.d.ts +2 -0
  62. package/dist/package-name.d.ts.map +1 -0
  63. package/dist/platform/analytics.d.ts +20 -0
  64. package/dist/platform/analytics.d.ts.map +1 -0
  65. package/dist/platform/fonts.d.ts +35 -0
  66. package/dist/platform/fonts.d.ts.map +1 -0
  67. package/dist/platform/images.d.ts +49 -0
  68. package/dist/platform/images.d.ts.map +1 -0
  69. package/dist/platform/index.d.ts +9 -0
  70. package/dist/platform/index.d.ts.map +1 -0
  71. package/dist/platform/observability.d.ts +60 -0
  72. package/dist/platform/observability.d.ts.map +1 -0
  73. package/dist/route/action.d.ts +33 -0
  74. package/dist/route/action.d.ts.map +1 -0
  75. package/dist/route/http-error.d.ts +24 -0
  76. package/dist/route/http-error.d.ts.map +1 -0
  77. package/dist/route/index.d.ts +10 -0
  78. package/dist/route/index.d.ts.map +1 -0
  79. package/dist/route/page.d.ts +5 -0
  80. package/dist/route/page.d.ts.map +1 -0
  81. package/dist/route/response.d.ts +100 -0
  82. package/dist/route/response.d.ts.map +1 -0
  83. package/dist/route/types.d.ts +186 -0
  84. package/dist/route/types.d.ts.map +1 -0
  85. package/dist/route/webhook.d.ts +25 -0
  86. package/dist/route/webhook.d.ts.map +1 -0
  87. package/dist/router/index.d.ts +5 -0
  88. package/dist/router/index.d.ts.map +1 -0
  89. package/dist/router/manifest.d.ts +119 -0
  90. package/dist/router/manifest.d.ts.map +1 -0
  91. package/dist/router/navigation-data.d.ts +9 -0
  92. package/dist/router/navigation-data.d.ts.map +1 -0
  93. package/dist/routing/generate.d.ts +14 -0
  94. package/dist/routing/generate.d.ts.map +1 -0
  95. package/dist/routing/index.d.ts +3 -0
  96. package/dist/routing/index.d.ts.map +1 -0
  97. package/dist/routing/types.d.ts +38 -0
  98. package/dist/routing/types.d.ts.map +1 -0
  99. package/dist/security/audit.d.ts +16 -0
  100. package/dist/security/audit.d.ts.map +1 -0
  101. package/dist/security/cors.d.ts +7 -0
  102. package/dist/security/cors.d.ts.map +1 -0
  103. package/dist/security/csrf.d.ts +15 -0
  104. package/dist/security/csrf.d.ts.map +1 -0
  105. package/dist/security/env.d.ts +69 -0
  106. package/dist/security/env.d.ts.map +1 -0
  107. package/dist/security/index.d.ts +17 -0
  108. package/dist/security/index.d.ts.map +1 -0
  109. package/dist/security/policy.d.ts +18 -0
  110. package/dist/security/policy.d.ts.map +1 -0
  111. package/dist/security/rate-limit.d.ts +6 -0
  112. package/dist/security/rate-limit.d.ts.map +1 -0
  113. package/dist/security/report.d.ts +13 -0
  114. package/dist/security/report.d.ts.map +1 -0
  115. package/dist/security/request.d.ts +11 -0
  116. package/dist/security/request.d.ts.map +1 -0
  117. package/dist/security/types.d.ts +137 -0
  118. package/dist/security/types.d.ts.map +1 -0
  119. package/dist/security/upload.d.ts +23 -0
  120. package/dist/security/upload.d.ts.map +1 -0
  121. package/dist/security/websocket.d.ts +13 -0
  122. package/dist/security/websocket.d.ts.map +1 -0
  123. package/dist/server/errors.d.ts +13 -0
  124. package/dist/server/errors.d.ts.map +1 -0
  125. package/dist/server/failure-site.d.ts +2 -0
  126. package/dist/server/failure-site.d.ts.map +1 -0
  127. package/dist/server/fallbacks.d.ts +10 -0
  128. package/dist/server/fallbacks.d.ts.map +1 -0
  129. package/dist/server/index.d.ts +14 -0
  130. package/dist/server/index.d.ts.map +1 -0
  131. package/dist/server/negotiate.d.ts +3 -0
  132. package/dist/server/negotiate.d.ts.map +1 -0
  133. package/dist/server/not-found.d.ts +11 -0
  134. package/dist/server/not-found.d.ts.map +1 -0
  135. package/dist/server/problem.d.ts +18 -0
  136. package/dist/server/problem.d.ts.map +1 -0
  137. package/dist/server/render-tree.d.ts +4 -0
  138. package/dist/server/render-tree.d.ts.map +1 -0
  139. package/dist/server/request-handler.d.ts +40 -0
  140. package/dist/server/request-handler.d.ts.map +1 -0
  141. package/dist/server/request-metadata.d.ts +7 -0
  142. package/dist/server/request-metadata.d.ts.map +1 -0
  143. package/dist/server/ssr.d.ts +17 -0
  144. package/dist/server/ssr.d.ts.map +1 -0
  145. package/dist/static/index.d.ts +28 -0
  146. package/dist/static/index.d.ts.map +1 -0
  147. package/dist/static/index.js +377 -0
  148. package/dist/static/index.js.map +1 -0
  149. package/dist/static-files.d.ts +5 -0
  150. package/dist/static-files.d.ts.map +1 -0
  151. package/dist/vite/index.d.ts +4 -0
  152. package/dist/vite/index.d.ts.map +1 -0
  153. package/dist/vite/index.js +746 -0
  154. package/dist/vite/index.js.map +1 -0
  155. package/dist/vite/plugin.d.ts +37 -0
  156. package/dist/vite/plugin.d.ts.map +1 -0
  157. package/package.json +93 -4
@@ -0,0 +1,9 @@
1
+ export declare const NAVIGATION_DATA_HEADER = "x-demiurge-navigation";
2
+ export declare const NAVIGATION_DATA_REQUEST = "data";
3
+ export declare const NAVIGATION_DATA_RESPONSE = "data";
4
+ export declare const NAVIGATION_ERROR_RESPONSE = "error";
5
+ export declare const NAVIGATION_NOT_FOUND_RESPONSE = "not-found";
6
+ export declare function isNavigationDataRequest(request: Request): boolean;
7
+ export declare function createNavigationDataResponse(data: unknown): Response;
8
+ export declare function markNavigationResponse(response: Response, kind: typeof NAVIGATION_ERROR_RESPONSE | typeof NAVIGATION_NOT_FOUND_RESPONSE): Response;
9
+ //# sourceMappingURL=navigation-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-data.d.ts","sourceRoot":"","sources":["../../src/router/navigation-data.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAC9D,eAAO,MAAM,uBAAuB,SAAS,CAAC;AAC9C,eAAO,MAAM,wBAAwB,SAAS,CAAC;AAC/C,eAAO,MAAM,yBAAyB,UAAU,CAAC;AACjD,eAAO,MAAM,6BAA6B,cAAc,CAAC;AAEzD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,WAEvD;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,OAAO,YAWzD;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,OAAO,yBAAyB,GAAG,OAAO,6BAA6B,YAM9E"}
@@ -0,0 +1,14 @@
1
+ export type GenerateRoutesOptions = {
2
+ outputFile: string;
3
+ routesDir: string;
4
+ };
5
+ type RouteInfo = {
6
+ pathVars: string[];
7
+ pattern: string;
8
+ };
9
+ export declare function generateRoutes(options: GenerateRoutesOptions): Promise<{
10
+ routes: RouteInfo[];
11
+ source: string;
12
+ }>;
13
+ export {};
14
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/routing/generate.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB;;;GAgBlE"}
@@ -0,0 +1,3 @@
1
+ export { href } from "./types";
2
+ export type { AppHref, AppPath, LinkTarget, LinkTo, PathValue, PathVarsFor, RouteParamsFor, RouteConcretePaths, RoutePathVars, SearchValue, SearchValues, } from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,YAAY,EACV,OAAO,EACP,OAAO,EACP,UAAU,EACV,MAAM,EACN,SAAS,EACT,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,YAAY,GACb,MAAM,SAAS,CAAC"}
@@ -0,0 +1,38 @@
1
+ export type PathValue = string | number | boolean;
2
+ export type SearchValue = PathValue | null | undefined;
3
+ export type SearchValues = Record<string, SearchValue | readonly SearchValue[]>;
4
+ export type PathVars = Record<string, string>;
5
+ export interface RoutePathVars {
6
+ }
7
+ export interface RouteConcretePaths {
8
+ }
9
+ type KnownRoutePath = keyof RoutePathVars & string;
10
+ type KnownConcretePath = RouteConcretePaths[keyof RouteConcretePaths] & string;
11
+ type HasGeneratedRoutes = [KnownRoutePath] extends [never] ? false : true;
12
+ type WithUrlSuffix<TPath extends string> = TPath | `${TPath}?${string}` | `${TPath}#${string}` | `${TPath}?${string}#${string}`;
13
+ type PathnameOf<THref extends string> = THref extends `${infer TWithoutHash}#${string}` ? TWithoutHash extends `${infer TPath}?${string}` ? TPath : TWithoutHash : THref extends `${infer TPath}?${string}` ? TPath : THref;
14
+ export type AppPath = HasGeneratedRoutes extends true ? KnownRoutePath : string;
15
+ export type AppHref = HasGeneratedRoutes extends true ? WithUrlSuffix<KnownRoutePath | KnownConcretePath> : string;
16
+ export type PathVarsFor<TPath extends string> = TPath extends KnownRoutePath ? RoutePathVars[TPath] : never;
17
+ export type RouteParamsFor<TPath extends string> = TPath extends KnownRoutePath ? {
18
+ [K in keyof RoutePathVars[TPath]]: string;
19
+ } : PathVars;
20
+ type HasPathVars<TPath extends string> = keyof PathVarsFor<TPath> extends never ? false : true;
21
+ type LinkOptions = {
22
+ hash?: string;
23
+ search?: string | URLSearchParams | SearchValues;
24
+ };
25
+ export type LinkTo<TTo extends AppHref = AppHref> = LinkOptions & (PathnameOf<TTo> extends KnownRoutePath ? HasPathVars<PathnameOf<TTo>> extends true ? {
26
+ to: TTo;
27
+ path: PathVarsFor<PathnameOf<TTo>>;
28
+ } : {
29
+ to: TTo;
30
+ path?: never;
31
+ } : {
32
+ to: TTo;
33
+ path?: never;
34
+ });
35
+ export type LinkTarget<TTo extends AppHref = AppHref> = TTo | LinkTo<TTo>;
36
+ export declare function href<const TTo extends AppHref>(target: LinkTarget<TTo>): string;
37
+ export {};
38
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/routing/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAClD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;AACvD,MAAM,MAAM,YAAY,GAAG,MAAM,CAC/B,MAAM,EACN,WAAW,GAAG,SAAS,WAAW,EAAE,CACrC,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,WAAW,aAAa;CAAG;AAEjC,MAAM,WAAW,kBAAkB;CAAG;AAEtC,KAAK,cAAc,GAAG,MAAM,aAAa,GAAG,MAAM,CAAC;AACnD,KAAK,iBAAiB,GAAG,kBAAkB,CAAC,MAAM,kBAAkB,CAAC,GAAG,MAAM,CAAC;AAC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AAG,eAAe,GAAG,YAAY,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,GAAG,SAAS,OAAO,GAAG,OAAO,IAAI,WAAW,GAAG,CAChE,UAAU,CAAC,GAAG,CAAC,SAAS,cAAc,GAClC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,IAAI,GACvC;IAAE,EAAE,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;CAAE,GAC/C;IAAE,EAAE,EAAE,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,GAC3B;IAAE,EAAE,EAAE,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,CAC9B,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,GAAG,SAAS,OAAO,GAAG,OAAO,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AAE1E,wBAAgB,IAAI,CAAC,KAAK,CAAC,GAAG,SAAS,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,UAmBtE"}
@@ -0,0 +1,16 @@
1
+ import type { HttpMethod } from "../route/types";
2
+ import type { ScriptTag } from "../document/scripts";
3
+ import type { CorsPolicy, RouteSecurityPolicy, ScriptDependencyAuditOptions, SecurityAuditFinding, SecurityAuditOptions } from "./types";
4
+ export declare function createSecurityAudit(options?: SecurityAuditOptions): {
5
+ findings: SecurityAuditFinding[];
6
+ headers: {
7
+ [k: string]: string;
8
+ };
9
+ route: {
10
+ cors: CorsPolicy | undefined;
11
+ method: HttpMethod;
12
+ security: RouteSecurityPolicy | undefined;
13
+ } | undefined;
14
+ };
15
+ export declare function auditScriptDependencies(scripts: readonly ScriptTag[], options?: ScriptDependencyAuditOptions): SecurityAuditFinding[];
16
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/security/audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAEV,UAAU,EAEV,mBAAmB,EACnB,4BAA4B,EAE5B,oBAAoB,EACpB,oBAAoB,EAGrB,MAAM,SAAS,CAAC;AAIjB,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB;;;;;;;;;;EAqCrE;AA2BD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,SAAS,EAAE,EAC7B,OAAO,GAAE,4BAAiC,0BAkD3C"}
@@ -0,0 +1,7 @@
1
+ import type { RouteModule } from "../route/types";
2
+ import type { CorsPolicy, CorsRequestContext, CorsResponseOptions } from "./types";
3
+ export declare function createCorsHeaders(policy: CorsPolicy, context: CorsRequestContext, options?: CorsResponseOptions): Headers;
4
+ export declare function applyCorsHeaders(response: Response, policy: CorsPolicy | undefined, request: Request): Response;
5
+ export declare function createCorsPreflightResponse(routeModule: RouteModule, request: Request): Response | null;
6
+ export declare function validateCorsPolicy(policy: CorsPolicy): void;
7
+ //# sourceMappingURL=cors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../src/security/cors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkC,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,GAAE,mBAAwB,WAqDlC;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,OAAO,EAAE,OAAO,YAcjB;AAED,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,mBAgCjB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,QAwBpD"}
@@ -0,0 +1,15 @@
1
+ import type { CsrfPolicy } from "./types";
2
+ export type CsrfCookieOptions = {
3
+ cookie?: string;
4
+ secure?: boolean;
5
+ };
6
+ export type IssuedCsrfToken = {
7
+ cookie: string;
8
+ token: string;
9
+ };
10
+ export declare function createCsrfToken(): string;
11
+ export declare function createCsrfCookie(token: string, options?: CsrfCookieOptions): string;
12
+ export declare function issueCsrfToken(options?: CsrfCookieOptions): IssuedCsrfToken;
13
+ export declare function enforceCsrfProtection(policy: CsrfPolicy | undefined, request: Request): Response | null;
14
+ export declare function parseCookieHeader(header: string | null): Map<string, string>;
15
+ //# sourceMappingURL=csrf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csrf.d.ts","sourceRoot":"","sources":["../../src/security/csrf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,eAAe,WAQ9B;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,iBAAsB,UAuBhC;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,iBAAsB,GAAG,eAAe,CAO/E;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,OAAO,EAAE,OAAO,mBA2BjB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,uBAuBtD"}
@@ -0,0 +1,69 @@
1
+ export type EnvSource = Record<string, string | undefined>;
2
+ export type EnvValidationIssue = {
3
+ code: "invalid" | "missing";
4
+ key: string;
5
+ message: string;
6
+ };
7
+ export declare class EnvValidationError extends Error {
8
+ issues: EnvValidationIssue[];
9
+ constructor(issues: EnvValidationIssue[]);
10
+ }
11
+ export type EnvVariable<T, Optional extends boolean = false> = {
12
+ optional: Optional;
13
+ parse: (key: string, value: string) => T;
14
+ sensitive: boolean;
15
+ };
16
+ export type EnvSchema = Record<string, EnvVariable<unknown, boolean>>;
17
+ export type InferEnvSchema<Schema extends EnvSchema> = {
18
+ [Key in keyof Schema]: Schema[Key] extends EnvVariable<infer Value, infer Optional> ? Optional extends true ? Value | undefined : Value : never;
19
+ };
20
+ type RequiredEnvVariableOptions = {
21
+ optional?: false;
22
+ };
23
+ type OptionalEnvVariableOptions = {
24
+ optional: true;
25
+ };
26
+ type RequiredStringEnvOptions = RequiredEnvVariableOptions & {
27
+ minLength?: number;
28
+ };
29
+ type OptionalStringEnvOptions = OptionalEnvVariableOptions & {
30
+ minLength?: number;
31
+ };
32
+ type RequiredUrlEnvOptions = RequiredEnvVariableOptions & {
33
+ protocols?: readonly string[];
34
+ };
35
+ type OptionalUrlEnvOptions = OptionalEnvVariableOptions & {
36
+ protocols?: readonly string[];
37
+ };
38
+ type RequiredIntegerEnvOptions = RequiredEnvVariableOptions & {
39
+ max?: number;
40
+ min?: number;
41
+ };
42
+ type OptionalIntegerEnvOptions = OptionalEnvVariableOptions & {
43
+ max?: number;
44
+ min?: number;
45
+ };
46
+ export declare function defineEnvSchema<Schema extends EnvSchema>(schema: Schema): Schema;
47
+ export declare function validateEnv<Schema extends EnvSchema>(schema: Schema, source: EnvSource): InferEnvSchema<Schema>;
48
+ declare function booleanEnv(options: OptionalEnvVariableOptions): EnvVariable<boolean, true>;
49
+ declare function booleanEnv(options?: RequiredEnvVariableOptions): EnvVariable<boolean, false>;
50
+ declare function enumEnv<const Values extends readonly [string, ...string[]]>(values: Values, options: OptionalEnvVariableOptions): EnvVariable<Values[number], true>;
51
+ declare function enumEnv<const Values extends readonly [string, ...string[]]>(values: Values, options?: RequiredEnvVariableOptions): EnvVariable<Values[number], false>;
52
+ declare function integerEnv(options: OptionalIntegerEnvOptions): EnvVariable<number, true>;
53
+ declare function integerEnv(options?: RequiredIntegerEnvOptions): EnvVariable<number, false>;
54
+ declare function secretEnv(options: OptionalStringEnvOptions): EnvVariable<string, true>;
55
+ declare function secretEnv(options?: RequiredStringEnvOptions): EnvVariable<string, false>;
56
+ declare function stringEnv(options: OptionalStringEnvOptions): EnvVariable<string, true>;
57
+ declare function stringEnv(options?: RequiredStringEnvOptions): EnvVariable<string, false>;
58
+ declare function urlEnv(options: OptionalUrlEnvOptions): EnvVariable<URL, true>;
59
+ declare function urlEnv(options?: RequiredUrlEnvOptions): EnvVariable<URL, false>;
60
+ export declare const env: {
61
+ boolean: typeof booleanEnv;
62
+ enum: typeof enumEnv;
63
+ integer: typeof integerEnv;
64
+ secret: typeof secretEnv;
65
+ string: typeof stringEnv;
66
+ url: typeof urlEnv;
67
+ };
68
+ export {};
69
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/security/env.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAE3D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,MAAM,EAAE,kBAAkB,EAAE,CAAC;gBAEjB,MAAM,EAAE,kBAAkB,EAAE;CAKzC;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,QAAQ,SAAS,OAAO,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O,CAAC,EAAE,wBAAwB,GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAOnF,iBAAS,SAAS,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACjF,iBAAS,SAAS,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAOnF,iBAAS,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACxE,iBAAS,MAAM,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAwB1E,eAAO,MAAM,GAAG;;;;;;;CAOf,CAAC"}
@@ -0,0 +1,17 @@
1
+ export { auditScriptDependencies, createSecurityAudit, } from "./audit";
2
+ export { applyCorsHeaders, createCorsHeaders, createCorsPreflightResponse, validateCorsPolicy, } from "./cors";
3
+ export { createCsrfCookie, createCsrfToken, enforceCsrfProtection, issueCsrfToken, parseCookieHeader, } from "./csrf";
4
+ export type { CsrfCookieOptions, IssuedCsrfToken } from "./csrf";
5
+ export { EnvValidationError, defineEnvSchema, env, validateEnv, } from "./env";
6
+ export { createSecurityHeaders, cspHash, defineRoutePolicy, defineSecurityPolicy, mergeRoutePolicies, mergeRouteSecurityPolicies, mergeSecurityPolicies, security, } from "./policy";
7
+ export { createMemoryRateLimitStore, enforceRateLimit, parseRateLimitWindow, validateRateLimitPolicy, } from "./rate-limit";
8
+ export { createSecurityReportHandler, } from "./report";
9
+ export { enforceAllowedMethods, enforceRequestSecurity, parseBodySize, } from "./request";
10
+ export { validateUploads, } from "./upload";
11
+ export { checkWebSocketOrigin, enforceWebSocketOrigin, } from "./websocket";
12
+ export type { ContentSecurityPolicy, CorsPolicy, CorsRequestContext, CorsResponseOptions, CsrfPolicy, CspHashAlgorithm, CspDirectiveValue, CspSource, MemoryRateLimitStoreOptions, RateLimitKey, RateLimitPolicy, RateLimitResult, RateLimitStore, ReferrerPolicy, ReportingEndpointUrl, ReportingEndpoints, SecurityAudit, SecurityAuditFinding, SecurityAuditOptions, ScriptDependencyAuditOptions, RequestSecurityPolicy, RoutePolicy, RouteSecurityPolicy, SecurityHeadersOptions, SecurityHeaderPolicy, SecurityPolicy, SecurityPreset, StrictTransportSecurityPolicy, TrustedTypesPolicy, } from "./types";
13
+ export type { UploadFilePolicy, UploadPolicy, UploadValidationIssue, UploadValidationResult, } from "./upload";
14
+ export type { EnvSchema, EnvSource, EnvValidationIssue, EnvVariable, InferEnvSchema, } from "./env";
15
+ export type { SecurityReportContext, SecurityReportHandlerOptions, SecurityReportPayload, } from "./report";
16
+ export type { WebSocketOriginCheck, WebSocketOriginPolicy, } from "./websocket";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,iBAAiB,GAClB,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,GAAG,EACH,WAAW,GACZ,MAAM,OAAO,CAAC;AACf,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,QAAQ,GACT,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,2BAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EACrB,WAAW,EACX,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,cAAc,GACf,MAAM,OAAO,CAAC;AACf,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { CspHashAlgorithm, RoutePolicy, RouteSecurityPolicy, SecurityHeadersOptions, SecurityPolicy, SecurityPreset } from "./types";
2
+ export declare const security: {
3
+ api(options?: SecurityPolicy): SecurityPolicy;
4
+ preset(name: SecurityPreset, options?: SecurityPolicy): SecurityPolicy;
5
+ static(options?: SecurityPolicy): SecurityPolicy;
6
+ strict(options?: SecurityPolicy): SecurityPolicy;
7
+ crossOriginIsolated(options?: SecurityPolicy): SecurityPolicy;
8
+ };
9
+ export declare function defineSecurityPolicy(policy: SecurityPolicy): SecurityPolicy;
10
+ export declare function defineRoutePolicy(policy: RoutePolicy): RoutePolicy;
11
+ export declare function mergeSecurityPolicies(...policies: Array<SecurityPolicy | false | undefined>): SecurityPolicy;
12
+ export declare function mergeRoutePolicies(...policies: Array<RoutePolicy | false | undefined>): RoutePolicy;
13
+ export declare function mergeRouteSecurityPolicies(...policies: Array<RouteSecurityPolicy | false | undefined>): RouteSecurityPolicy;
14
+ export declare function cspHash(source: string, algorithm?: CspHashAlgorithm): Promise<string>;
15
+ export declare function createSecurityHeaders(policy: SecurityPolicy, options?: SecurityHeadersOptions): Headers;
16
+ export declare function securityPolicyRequiresNonce(policy: SecurityPolicy | false | undefined): boolean;
17
+ export declare function createCspNonce(): string;
18
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/security/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAEhB,WAAW,EACX,mBAAmB,EACnB,sBAAsB,EAEtB,cAAc,EACd,cAAc,EAGf,MAAM,SAAS,CAAC;AA2CjB,eAAO,MAAM,QAAQ;kBACN,cAAc;iBAQd,cAAc,YAAW,cAAc;qBAepC,cAAc;qBASd,cAAc;kCASD,cAAc;CAW5C,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,kBAE1D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,eAEpD;AAED,wBAAgB,qBAAqB,CACnC,GAAG,QAAQ,EAAE,KAAK,CAAC,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC,kBASvD;AAED,wBAAgB,kBAAkB,CAChC,GAAG,QAAQ,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,GAAG,SAAS,CAAC,eAYpD;AAED,wBAAgB,0BAA0B,CACxC,GAAG,QAAQ,EAAE,KAAK,CAAC,mBAAmB,GAAG,KAAK,GAAG,SAAS,CAAC,uBAa5D;AAED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,gBAA2B,mBAQvC;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,sBAA2B,WAkCrC;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,cAAc,GAAG,KAAK,GAAG,SAAS,WAS3C;AAED,wBAAgB,cAAc,WAK7B"}
@@ -0,0 +1,6 @@
1
+ import type { MemoryRateLimitStoreOptions, RateLimitPolicy, RateLimitStore } from "./types";
2
+ export declare function createMemoryRateLimitStore(options?: MemoryRateLimitStoreOptions): RateLimitStore;
3
+ export declare function enforceRateLimit(policy: RateLimitPolicy | undefined, request: Request, store: RateLimitStore, now?: number): Response | null;
4
+ export declare function parseRateLimitWindow(value: number | string): number;
5
+ export declare function validateRateLimitPolicy(policy: RateLimitPolicy): void;
6
+ //# sourceMappingURL=rate-limit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../src/security/rate-limit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAE3B,eAAe,EACf,cAAc,EACf,MAAM,SAAS,CAAC;AAgBjB,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,2BAAgC,GACxC,cAAc,CAwChB;AA+BD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,cAAc,EACrB,GAAG,SAAa,mBA2BjB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,UAwB1D;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,QAM9D"}
@@ -0,0 +1,13 @@
1
+ type MaybePromise<T> = Promise<T> | T;
2
+ export type SecurityReportPayload = unknown;
3
+ export type SecurityReportHandlerOptions = {
4
+ maxBodySize?: number | `${number}${"b" | "gb" | "kb" | "mb"}`;
5
+ onReport?: (report: SecurityReportPayload, context: SecurityReportContext) => MaybePromise<void>;
6
+ };
7
+ export type SecurityReportContext = {
8
+ index: number;
9
+ request: Request;
10
+ };
11
+ export declare function createSecurityReportHandler(options?: SecurityReportHandlerOptions): (request: Request) => Promise<Response>;
12
+ export {};
13
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/security/report.ts"],"names":[],"mappings":"AAMA,KAAK,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEtC,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE5C,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;IAC9D,QAAQ,CAAC,EAAE,CACT,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,qBAAqB,KAC3B,YAAY,CAAC,IAAI,CAAC,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,4BAAiC,IAEC,SAAS,OAAO,uBAqD5D"}
@@ -0,0 +1,11 @@
1
+ import type { HttpMethod } from "../route/types";
2
+ import type { RequestSecurityPolicy } from "./types";
3
+ export declare function enforceRequestSecurity(policy: RequestSecurityPolicy | undefined, request: Request, method: HttpMethod): Response | null;
4
+ export declare class RequestBodyTooLargeError extends Error {
5
+ constructor();
6
+ }
7
+ export declare function limitRequestBody(policy: RequestSecurityPolicy | undefined, request: Request): Request;
8
+ export declare function requestBodyTooLargeResponse(): Response;
9
+ export declare function enforceAllowedMethods(policy: RequestSecurityPolicy | undefined, method: HttpMethod): Response | null;
10
+ export declare function parseBodySize(value: number | string): number;
11
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/security/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAUrD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,qBAAqB,GAAG,SAAS,EACzC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,UAAU,mBAmCnB;AAED,qBAAa,wBAAyB,SAAQ,KAAK;;CAKlD;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,qBAAqB,GAAG,SAAS,EACzC,OAAO,EAAE,OAAO,WAmDjB;AAED,wBAAgB,2BAA2B,aAE1C;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB,GAAG,SAAS,EACzC,MAAM,EAAE,UAAU,mBAgBnB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,UA0BnD"}
@@ -0,0 +1,137 @@
1
+ import type { ScriptTag } from "../document/scripts";
2
+ import type { HttpMethod } from "../route/types";
3
+ export type CspSource = "'self'" | "'none'" | "'unsafe-inline'" | "'unsafe-eval'" | "'strict-dynamic'" | "data:" | "blob:" | "https:" | "http:" | string;
4
+ export type CspDirectiveValue = readonly CspSource[] | boolean;
5
+ export type ContentSecurityPolicy = {
6
+ baseUri?: readonly CspSource[];
7
+ connectSrc?: readonly CspSource[];
8
+ defaultSrc?: readonly CspSource[];
9
+ fontSrc?: readonly CspSource[];
10
+ formAction?: readonly CspSource[];
11
+ frameAncestors?: readonly CspSource[];
12
+ imgSrc?: readonly CspSource[];
13
+ objectSrc?: readonly CspSource[];
14
+ /** Deprecated compatibility targets used alongside `reportTo`. */
15
+ reportUri?: readonly ReportingEndpointUrl[];
16
+ /** A named member of `headers.reportingEndpoints`. */
17
+ reportTo?: string;
18
+ scriptSrc?: readonly CspSource[];
19
+ styleSrc?: readonly CspSource[];
20
+ upgradeInsecureRequests?: boolean;
21
+ };
22
+ export type ReportingEndpointUrl = `/${string}` | `https://${string}`;
23
+ export type ReportingEndpoints = Readonly<Record<string, ReportingEndpointUrl>>;
24
+ export type ReferrerPolicy = "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
25
+ export type StrictTransportSecurityPolicy = {
26
+ includeSubDomains?: boolean;
27
+ maxAge: number;
28
+ preload?: boolean;
29
+ };
30
+ export type TrustedTypesPolicy = {
31
+ mode: "enforce" | "report-only";
32
+ policies: readonly string[];
33
+ requireFor?: readonly ["script"];
34
+ };
35
+ export type CorsPolicy = {
36
+ credentials?: boolean;
37
+ exposeHeaders?: readonly string[];
38
+ headers?: readonly string[];
39
+ maxAge?: number;
40
+ methods?: readonly HttpMethod[];
41
+ origins: "*" | readonly string[];
42
+ };
43
+ export type CorsRequestContext = {
44
+ request: Request;
45
+ };
46
+ export type CorsResponseOptions = {
47
+ methods: readonly HttpMethod[];
48
+ preflight: true;
49
+ } | {
50
+ methods?: readonly HttpMethod[];
51
+ preflight?: false;
52
+ };
53
+ export type CsrfPolicy = false | true | {
54
+ cookie?: string;
55
+ header?: string;
56
+ };
57
+ export type RequestSecurityPolicy = {
58
+ allowedMethods?: readonly HttpMethod[];
59
+ maxBodySize?: number | `${number}${"b" | "gb" | "kb" | "mb"}`;
60
+ };
61
+ export type RateLimitKey = "ip" | {
62
+ header: string;
63
+ };
64
+ export type RateLimitPolicy = {
65
+ key: RateLimitKey;
66
+ limit: number;
67
+ window: number | `${number}${"h" | "m" | "s"}`;
68
+ };
69
+ export type RateLimitResult = {
70
+ count: number;
71
+ resetAt: number;
72
+ };
73
+ export type MemoryRateLimitStoreOptions = {
74
+ maximumEntries?: number;
75
+ };
76
+ export type RateLimitStore = {
77
+ increment: (key: string, windowMs: number, now: number) => RateLimitResult;
78
+ };
79
+ export type RouteSecurityPolicy = {
80
+ csrf?: CsrfPolicy;
81
+ rateLimit?: RateLimitPolicy;
82
+ request?: RequestSecurityPolicy;
83
+ };
84
+ export type RoutePolicy = {
85
+ document?: SecurityPolicy;
86
+ security?: RouteSecurityPolicy;
87
+ };
88
+ export type SecurityAuditFinding = {
89
+ code: string;
90
+ message: string;
91
+ severity: "error" | "info" | "warning";
92
+ };
93
+ export type SecurityAuditOptions = {
94
+ document?: {
95
+ headers?: SecurityHeadersOptions;
96
+ policy: SecurityPolicy;
97
+ scriptDependencies?: boolean | ScriptDependencyAuditOptions;
98
+ scripts?: readonly ScriptTag[];
99
+ };
100
+ route?: {
101
+ cors?: CorsPolicy;
102
+ method: HttpMethod;
103
+ security?: RouteSecurityPolicy;
104
+ };
105
+ };
106
+ export type SecurityAudit = {
107
+ findings: SecurityAuditFinding[];
108
+ headers: Record<string, string>;
109
+ route?: SecurityAuditOptions["route"];
110
+ };
111
+ export type ScriptDependencyAuditOptions = {
112
+ allowBeforeInteractiveThirdParty?: boolean;
113
+ requireIntegrity?: boolean;
114
+ requirePurpose?: boolean;
115
+ };
116
+ export type SecurityHeaderPolicy = {
117
+ contentTypeOptions?: "nosniff" | false;
118
+ crossOriginEmbedderPolicy?: "require-corp" | "credentialless" | false;
119
+ crossOriginOpenerPolicy?: "same-origin" | "same-origin-allow-popups" | false;
120
+ crossOriginResourcePolicy?: "same-origin" | "same-site" | "cross-origin" | false;
121
+ permissionsPolicy?: string | false;
122
+ referrerPolicy?: ReferrerPolicy | false;
123
+ reportingEndpoints?: ReportingEndpoints | false;
124
+ strictTransportSecurity?: StrictTransportSecurityPolicy | false;
125
+ };
126
+ export type SecurityPolicy = {
127
+ csp?: ContentSecurityPolicy | false;
128
+ headers?: SecurityHeaderPolicy;
129
+ trustedTypes?: TrustedTypesPolicy | false;
130
+ };
131
+ export type SecurityPreset = "api" | "cross-origin-isolated" | "static" | "strict";
132
+ export type CspHashAlgorithm = "sha256" | "sha384" | "sha512";
133
+ export type SecurityHeadersOptions = {
134
+ nonce?: string;
135
+ request?: Request;
136
+ };
137
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/security/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,QAAQ,GACR,iBAAiB,GACjB,eAAe,GACf,kBAAkB,GAClB,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,MAAM,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,SAAS,SAAS,EAAE,GAAG,OAAO,CAAC;AAE/D,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAClC,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAClC,OAAO,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAClC,cAAc,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,MAAM,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IACjC,kEAAkE;IAClE,SAAS,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC5C,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,S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G,0BAA0B,GAAG,KAAK,CAAC;IAC7E,yBAAyB,CAAC,EAAE,aAAa,GAAG,WAAW,GAAG,cAAc,GAAG,KAAK,CAAC;IACjF,iBAAiB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACnC,cAAc,CAAC,EAAE,cAAc,GAAG,KAAK,CAAC;IACxC,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,KAAK,CAAC;IAChD,uBAAuB,CAAC,EAAE,6BAA6B,GAAG,KAAK,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,qBAAqB,GAAG,KAAK,CAAC;IACpC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,YAAY,CAAC,EAAE,kBAAkB,GAAG,KAAK,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,uBAAuB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACnF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE9D,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { RequestSecurityPolicy } from "./types";
2
+ export type UploadFilePolicy = {
3
+ maxSize?: RequestSecurityPolicy["maxBodySize"];
4
+ required?: boolean;
5
+ types?: readonly string[];
6
+ };
7
+ export type UploadPolicy = {
8
+ files: Record<string, UploadFilePolicy>;
9
+ maxTotalSize?: RequestSecurityPolicy["maxBodySize"];
10
+ };
11
+ export type UploadValidationIssue = {
12
+ code: "file-missing" | "file-too-large" | "file-type-not-allowed" | "total-upload-too-large";
13
+ field: string;
14
+ message: string;
15
+ };
16
+ export type UploadValidationResult = {
17
+ files: Record<string, File[]>;
18
+ issues: UploadValidationIssue[];
19
+ ok: boolean;
20
+ totalSize: number;
21
+ };
22
+ export declare function validateUploads(formData: FormData, policy: UploadPolicy): UploadValidationResult;
23
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/security/upload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EACA,cAAc,GACd,gBAAgB,GAChB,uBAAuB,GACvB,wBAAwB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9B,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,YAAY,GACnB,sBAAsB,CAwCxB"}
@@ -0,0 +1,13 @@
1
+ export type WebSocketOriginPolicy = {
2
+ allowMissingOrigin?: boolean;
3
+ origins: "same-origin" | readonly string[];
4
+ };
5
+ export type WebSocketOriginCheck = {
6
+ allowed: boolean;
7
+ expected: "same-origin" | readonly string[];
8
+ origin: string | null;
9
+ reason?: "invalid-origin" | "missing-origin" | "origin-not-allowed";
10
+ };
11
+ export declare function checkWebSocketOrigin(policy: WebSocketOriginPolicy, request: Request): WebSocketOriginCheck;
12
+ export declare function enforceWebSocketOrigin(policy: WebSocketOriginPolicy | undefined, request: Request): Response | null;
13
+ //# sourceMappingURL=websocket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/security/websocket.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,EAAE,aAAa,GAAG,SAAS,MAAM,EAAE,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,aAAa,GAAG,SAAS,MAAM,EAAE,CAAC;IAC5C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,oBAAoB,CAAC;CACrE,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,OAAO,GACf,oBAAoB,CA+BtB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,qBAAqB,GAAG,SAAS,EACzC,OAAO,EAAE,OAAO,mBAejB"}
@@ -0,0 +1,13 @@
1
+ import { type RouteManifest } from "../router";
2
+ import type { FailureSite } from "./failure-site";
3
+ import type { SsrRenderOptions } from "./ssr";
4
+ export type ErrorRenderOptions = SsrRenderOptions & {
5
+ dev?: boolean;
6
+ onError?: (error: unknown, site: FailureSite) => void;
7
+ transformDocument?: (html: string) => string | Promise<string>;
8
+ };
9
+ export declare function isDevErrorRendering(dev: boolean | undefined): boolean;
10
+ export declare function renderFailureResponse(manifest: RouteManifest, request: Request, error: unknown, site: FailureSite, options?: ErrorRenderOptions): Promise<Response>;
11
+ export declare function createErrorProblemResponse(url: URL, error: unknown, options?: ErrorRenderOptions): Response;
12
+ export declare function createPlainTextErrorResponse(): Response;
13
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/server/errors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAIlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACtD,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAChE,CAAC;AAMF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,WAE3D;AAED,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE,kBAAuB,qBAiBjC;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,kBAAuB,YA0BjC;AAqCD,wBAAgB,4BAA4B,aAK3C"}
@@ -0,0 +1,2 @@
1
+ export type FailureSite = "middleware" | "page" | "route";
2
+ //# sourceMappingURL=failure-site.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure-site.d.ts","sourceRoot":"","sources":["../../src/server/failure-site.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { NotFoundProps, RouteErrorProps } from "../route";
2
+ export declare function BuiltInNotFound({ pathname }: NotFoundProps): import("react").JSX.Element;
3
+ export declare function BuiltInError({ status }: RouteErrorProps): import("react").JSX.Element;
4
+ export declare function DevError({ error, pathname, status }: RouteErrorProps): import("react").JSX.Element;
5
+ export declare function describeError(error: unknown): {
6
+ message: string;
7
+ name: string;
8
+ stack: string | undefined;
9
+ };
10
+ //# sourceMappingURL=fallbacks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallbacks.d.ts","sourceRoot":"","sources":["../../src/server/fallbacks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAK/D,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE,aAAa,+BAO1D;AAED,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,+BAOvD;AAID,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,eAAe,+BAYpE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO;;;;EAc3C"}
@@ -0,0 +1,14 @@
1
+ export { createRequestHandler, handleRequestWithManifest, } from "./request-handler";
2
+ export { renderPageDocument, renderPageResponse } from "./ssr";
3
+ export { createErrorProblemResponse, createPlainTextErrorResponse, isDevErrorRendering, renderFailureResponse, } from "./errors";
4
+ export { BuiltInError, BuiltInNotFound, DevError } from "./fallbacks";
5
+ export { acceptsHtmlDocument, prefersHtmlDocument } from "./negotiate";
6
+ export { createNotFoundProblemResponse, renderNotFoundDocument, renderNotFoundResponse, } from "./not-found";
7
+ export { createProblemDetails, createProblemResponse, PROBLEM_CONTENT_TYPE, } from "./problem";
8
+ export type { SsrOptions, SsrRenderOptions } from "./ssr";
9
+ export type { ErrorRenderOptions } from "./errors";
10
+ export type { FailureSite } from "./failure-site";
11
+ export type { NotFoundRenderOptions } from "./not-found";
12
+ export type { ProblemDetails } from "./problem";
13
+ export type { PageRenderer, RequestCacheStoreOptions, RequestErrorReporter, RequestHandler, RequestHandlerOptions, } from "./request-handler";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,YAAY,EACZ,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,GACtB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function prefersHtmlDocument(request: Request): boolean;
2
+ export declare function acceptsHtmlDocument(header: string | null): boolean;
3
+ //# sourceMappingURL=negotiate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"negotiate.d.ts","sourceRoot":"","sources":["../../src/server/negotiate.ts"],"names":[],"mappings":"AAeA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,WAEnD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,WAQxD"}
@@ -0,0 +1,11 @@
1
+ import { type LoadedNotFoundMatch, type RouteManifest } from "../router";
2
+ import type { FailureSite } from "./failure-site";
3
+ import type { SsrRenderOptions } from "./ssr";
4
+ export type NotFoundRenderOptions = SsrRenderOptions & {
5
+ onError?: (error: unknown, site: FailureSite) => void;
6
+ transformDocument?: (html: string) => string | Promise<string>;
7
+ };
8
+ export declare function createNotFoundProblemResponse(url: URL): Response;
9
+ export declare function renderNotFoundResponse(manifest: RouteManifest, request: Request, options?: NotFoundRenderOptions): Promise<Response>;
10
+ export declare function renderNotFoundDocument(match: LoadedNotFoundMatch, options?: NotFoundRenderOptions): string;
11
+ //# sourceMappingURL=not-found.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-found.d.ts","sourceRoot":"","sources":["../../src/server/not-found.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG;IACrD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAGtD,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAChE,CAAC;AAEF,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,GAAG,YAMrD;AAKD,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,qBAA0B,qBA6BpC;AAaD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE,qBAA0B,UAoBpC"}