@netlify/plugin-csp-nonce 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/__csp-nonce.ts +17 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@netlify/plugin-csp-nonce",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.8",
|
|
5
5
|
"description": "Use a nonce for the script-src and style-src directives of your Content Security Policy.",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"repository": {
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"test": "vitest"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@netlify/build-info": "^
|
|
39
|
+
"@netlify/build-info": "^8.0.0"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/__csp-nonce.ts
CHANGED
|
@@ -31,11 +31,23 @@ params.https = true;
|
|
|
31
31
|
params.http = true;
|
|
32
32
|
|
|
33
33
|
const handler = async (_request: Request, context: Context) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
try {
|
|
35
|
+
const response = await context.next();
|
|
36
|
+
// for debugging which routes use this edge function
|
|
37
|
+
response.headers.set("x-debug-csp-nonce", "invoked");
|
|
38
|
+
return csp(response, params);
|
|
39
|
+
} catch {
|
|
40
|
+
/*
|
|
41
|
+
We catch all the throws and return undefined
|
|
42
|
+
The reason we do this is because returning undefined
|
|
43
|
+
will cause the next edge function in the chain to be
|
|
44
|
+
executed.
|
|
45
|
+
This is equivalent to setting the Edge Function's
|
|
46
|
+
`config.onError` property to "bypass", but is handled
|
|
47
|
+
completely by the Edge Function instead of by something else.
|
|
48
|
+
*/
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
39
51
|
};
|
|
40
52
|
|
|
41
53
|
// Top 50 most common extensions (minus .html and .htm) according to Humio
|