csp-builder
Version:
A builder tool to help generate Content Security Policies in a type-safe way
44 lines (43 loc) • 1.34 kB
TypeScript
export declare enum PredefinedSource {
None = "'none'",
ReportSample = "'report-sample'",
Self = "'self'",
StrictDynamic = "'strict-dynamic'",
UnsafeEval = "'unsafe-eval'",
UnsafeInline = "'unsafe-inline'"
}
export declare enum SchemaSource {
Blob = "blob:",
Data = "data:",
Filesystem = "filesystem:",
Http = "http:",
Https = "https:",
MediaStream = "mediastream:"
}
export declare type HostSource = string;
export declare type SourceList = PredefinedSource | SchemaSource | HostSource;
export declare enum DirectiveType {
Fetch = "fetch",
Document = "document",
Navigation = "navigation",
Reporting = "reporting",
Other = "other"
}
export declare type DirectiveName = string;
export declare type CspVersion = number;
export interface Directive {
getDirectiveName(): DirectiveName;
getDirectiveType(): DirectiveType;
getMinimumCspVersion(): CspVersion;
serialize(): string;
}
export interface MultiValueDirective extends Directive {
addValue(value: any | any[]): this;
}
export interface SingleValueDirective extends Directive {
setValue(value: any): this;
}
export interface ToggleDirective extends Directive {
toggle(value: boolean): this;
}
export declare type Directives = MultiValueDirective | SingleValueDirective | ToggleDirective;