csprefabricate
Version:
Generate valid and secure Content Security Policies (CSP) with TypeScript.
59 lines (58 loc) • 2.43 kB
TypeScript
declare enum Directive {
DEFAULT_SRC = "default-src",
SCRIPT_SRC = "script-src",
STYLE_SRC = "style-src",
IMG_SRC = "img-src",
CONNECT_SRC = "connect-src",
FONT_SRC = "font-src",
OBJECT_SRC = "object-src",
MEDIA_SRC = "media-src",
FRAME_SRC = "frame-src",
SANDBOX = "sandbox",
REPORT_URI = "report-uri",
CHILD_SRC = "child-src",
FORM_ACTION = "form-action",
FRAME_ANCESTORS = "frame-ancestors",
PLUGIN_TYPES = "plugin-types",
BASE_URI = "base-uri",
REPORT_TO = "report-to",
WORKER_SRC = "worker-src",
MANIFEST_SRC = "manifest-src",
PREFETCH_SRC = "prefetch-src",
NAVIGATE_TO = "navigate-to",
REQUIRE_TRUSTED_TYPES_FOR = "require-trusted-types-for",
TRUSTED_TYPES = "trusted-types",
UPGRADE_INSECURE_REQUESTS = "upgrade-insecure-requests",
BLOCK_ALL_MIXED_CONTENT = "block-all-mixed-content"
}
type BasicDirectiveRule = Array<string | Record<string, Array<string>>>;
type BlankDirectiveRule = null;
type Rules = BasicDirectiveRule | BlankDirectiveRule;
interface ContentSecurityPolicy {
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BasicDirectiveRule;
[ ]?: BlankDirectiveRule;
[ ]?: BlankDirectiveRule;
}
export { ContentSecurityPolicy, Rules, Directive, BasicDirectiveRule };