From ea3b3dd9f42c6b3524cbbd8ae2852956e3ec3e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Correa=20Casablanca?= Date: Tue, 17 Sep 2024 17:38:31 +0200 Subject: [PATCH] fix: decouple netlify headers from hashesModule Signed-off-by: Andres Correa Casablanca --- @kindspells/astro-shield/package.json | 2 +- @kindspells/astro-shield/src/core.mts | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/@kindspells/astro-shield/package.json b/@kindspells/astro-shield/package.json index dfa8cfd..6df89a4 100644 --- a/@kindspells/astro-shield/package.json +++ b/@kindspells/astro-shield/package.json @@ -1,6 +1,6 @@ { "name": "@kindspells/astro-shield", - "version": "1.5.0", + "version": "1.5.1", "description": "Astro integration to enhance your website's security with SubResource Integrity hashes, Content-Security-Policy headers, and other techniques.", "private": false, "type": "module", diff --git a/@kindspells/astro-shield/src/core.mts b/@kindspells/astro-shield/src/core.mts index 06e94e9..bcc6b6f 100644 --- a/@kindspells/astro-shield/src/core.mts +++ b/@kindspells/astro-shield/src/core.mts @@ -753,17 +753,6 @@ export const processStaticFiles = async ( sri, ) - if (!sri.hashesModule) { - return - } - - await generateSRIHashesModule( - logger, - h, - sri.hashesModule, - sri.enableMiddleware, - ) - if (securityHeaders?.enableOnStaticPages !== undefined) { const provider = securityHeaders.enableOnStaticPages.provider switch (provider) { @@ -789,6 +778,15 @@ export const processStaticFiles = async ( exhaustiveGuard(provider, 'provider') } } + + if (sri.hashesModule) { + await generateSRIHashesModule( + logger, + h, + sri.hashesModule, + sri.enableMiddleware, + ) + } } export const getMiddlewareHandler = (