@netlify/plugin-csp-nonce 1.3.7 → 1.3.9

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/__csp-nonce.ts +18 -6
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.7",
4
+ "version": "1.3.9",
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": "^7.15.2"
39
+ "@netlify/build-info": "^8.0.0"
40
40
  }
41
41
  }
@@ -2,7 +2,7 @@
2
2
  // @ts-ignore
3
3
  import type { Config, Context } from "netlify:edge";
4
4
  // @ts-ignore
5
- import { csp } from "https://deno.land/x/csp_nonce_html_transformer@v2.2.1/src/index-embedded-wasm.ts";
5
+ import { csp } from "https://deno.land/x/csp_nonce_html_transformer@v2.2.2/src/index-embedded-wasm.ts";
6
6
  // @ts-ignore
7
7
  import inputs from "./__csp-nonce-inputs.json" assert { type: "json" };
8
8
 
@@ -31,11 +31,23 @@ params.https = true;
31
31
  params.http = true;
32
32
 
33
33
  const handler = async (_request: Request, context: Context) => {
34
- const response = await context.next();
35
-
36
- // for debugging which routes use this edge function
37
- response.headers.set("x-debug-csp-nonce", "invoked");
38
- return csp(response, params);
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