config.ts — astro Source File
Architecture documentation for config.ts, a typescript file in the astro codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 12361455_4ce4_1b8b_4844_c147f4e9ca5e["config.ts"] f8c9251e_f535_6281_2118_9e79a4155212["v4"] 12361455_4ce4_1b8b_4844_c147f4e9ca5e --> f8c9251e_f535_6281_2118_9e79a4155212 style 12361455_4ce4_1b8b_4844_c147f4e9ca5e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as z from 'zod/v4';
type UnionToIntersection<U> = (U extends never ? never : (arg: U) => never) extends (
arg: infer I,
) => void
? I
: never;
type UnionToTuple<T> = UnionToIntersection<T extends never ? never : (t: T) => T> extends (
_: never,
) => infer W
? [...UnionToTuple<Exclude<T, W>>, W]
: [];
export const ALGORITHMS = {
'SHA-256': 'sha256-',
'SHA-384': 'sha384-',
'SHA-512': 'sha512-',
} as const;
type Algorithms = typeof ALGORITHMS;
export type CspAlgorithm = keyof Algorithms;
type CspAlgorithmValue = Algorithms[keyof Algorithms];
const ALGORITHM_VALUES = Object.values(ALGORITHMS) as UnionToTuple<CspAlgorithmValue>;
export const cspAlgorithmSchema = z
.enum(Object.keys(ALGORITHMS) as UnionToTuple<CspAlgorithm>)
.optional()
.default('SHA-256');
export const cspHashSchema = z.custom<`${CspAlgorithmValue}${string}`>((value) => {
if (typeof value !== 'string') {
return false;
}
return ALGORITHM_VALUES.some((allowedValue) => {
return value.startsWith(allowedValue);
});
});
export type CspHash = z.infer<typeof cspHashSchema>;
const ALLOWED_DIRECTIVES = [
'base-uri',
'child-src',
'connect-src',
'default-src',
'fenced-frame-src',
'font-src',
'form-action',
'frame-ancestors',
'frame-src',
'img-src',
'manifest-src',
'media-src',
'object-src',
'referrer',
'report-to',
'report-uri',
'require-trusted-types-for',
'sandbox',
'trusted-types',
'upgrade-insecure-requests',
'worker-src',
] as const;
type AllowedDirectives = (typeof ALLOWED_DIRECTIVES)[number];
export type CspDirective = `${AllowedDirectives}${string | undefined}`;
export const allowedDirectivesSchema = z.custom<CspDirective>((value) => {
if (typeof value !== 'string') {
return false;
}
return ALLOWED_DIRECTIVES.some((allowedValue) => {
return value.startsWith(allowedValue);
});
});
Domain
Subdomains
Types
Dependencies
- v4
Source
Frequently Asked Questions
What does config.ts do?
config.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in config.ts?
config.ts defines 5 function(s): T, _, allowedDirectivesSchema, arg, cspHashSchema.
What does config.ts depend on?
config.ts imports 1 module(s): v4.
Where is config.ts in the architecture?
config.ts is located at packages/astro/src/core/csp/config.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/core/csp).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free