export CspPolicies map so plugins can whitelist themselves

This commit is contained in:
Vendicated 2025-01-24 03:33:29 +01:00
parent 11143adb02
commit 0336ea1cb2
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -13,7 +13,7 @@ const CssSrc = ["style-src", "font-src"];
const MediaAndCssSrc = [...MediaSrc, ...CssSrc];
const MediaScriptsAndCssSrc = [...MediaAndCssSrc, "script-src", "worker-src"];
const Policies: PolicyMap = {
export const CspPolicies: PolicyMap = {
"*.github.io": MediaAndCssSrc, // github pages, used by most themes
"raw.githubusercontent.com": MediaAndCssSrc, // github raw, used by some themes
"*.gitlab.io": MediaAndCssSrc, // gitlab pages, used by some themes
@ -92,7 +92,7 @@ const patchCsp = (headers: Record<string, string[]>) => {
pushDirective("script-src", "'unsafe-inline'", "'unsafe-eval'");
for (const [host, directives] of Object.entries(Policies)) {
for (const [host, directives] of Object.entries(CspPolicies)) {
for (const directive of directives) {
pushDirective(directive, host);
}