@berachain/config 0.1.23 → 0.1.24-beta.0
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.
|
@@ -208,7 +208,7 @@ function getContentSecurityPolicy({
|
|
|
208
208
|
base-uri 'self';
|
|
209
209
|
frame-src 'self' ${frameSources.join(" ")};
|
|
210
210
|
frame-ancestors 'self' https://*.posthog.com;
|
|
211
|
-
script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}' https://*.posthog.com 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
|
|
211
|
+
script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' ${nonce ? `'nonce-${nonce}'` : ""} https://*.posthog.com 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
|
|
212
212
|
worker-src 'self' blob: data:;
|
|
213
213
|
font-src 'self' ${fontSources.join(" ")};
|
|
214
214
|
style-src 'self' ${styleSources.join(" ")} 'unsafe-inline';
|
|
@@ -237,10 +237,11 @@ var staticPictureSources = [
|
|
|
237
237
|
return true;
|
|
238
238
|
});
|
|
239
239
|
function cspMiddleware({
|
|
240
|
+
useDynamicCsp = true,
|
|
240
241
|
response
|
|
241
242
|
}) {
|
|
242
243
|
const sentryCspEndpoint = _optionalChain([getSentryKeys, 'call', _3 => _3(), 'optionalAccess', _4 => _4.cspEndpoint]);
|
|
243
|
-
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
|
|
244
|
+
const nonce = useDynamicCsp ? Buffer.from(crypto.randomUUID()).toString("base64") : void 0;
|
|
244
245
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
245
246
|
const headers = [
|
|
246
247
|
{
|
|
@@ -259,10 +260,7 @@ function cspMiddleware({
|
|
|
259
260
|
key: "X-Content-Type-Options",
|
|
260
261
|
value: "nosniff"
|
|
261
262
|
},
|
|
262
|
-
{
|
|
263
|
-
key: "X-Nonce",
|
|
264
|
-
value: nonce
|
|
265
|
-
}
|
|
263
|
+
...nonce ? [{ key: "X-Nonce", value: nonce }] : []
|
|
266
264
|
];
|
|
267
265
|
if (sentryCspEndpoint) {
|
|
268
266
|
headers.push({
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { NextRequest, NextResponse } from "next/server";
|
|
2
|
+
/** Builds the Content-Security-Policy header value. */
|
|
2
3
|
export declare function getContentSecurityPolicy({ isDevelopment, nonce, cspReporting, ...args }: {
|
|
3
4
|
isDevelopment: boolean;
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Per-request nonce for `script-src`. Required for dynamic CSP; omit it for
|
|
7
|
+
* static CSP (no per-request header), in which case the `'nonce-...'` token
|
|
8
|
+
* is dropped and scripts are gated by `'strict-dynamic'` plus the inlined
|
|
9
|
+
* sha256 hash instead.
|
|
10
|
+
*/
|
|
11
|
+
nonce?: string;
|
|
5
12
|
frameSources?: string[];
|
|
6
13
|
fontSources?: string[];
|
|
7
14
|
pictureSources?: string[];
|
|
@@ -13,7 +20,8 @@ export declare function getContentSecurityPolicy({ isDevelopment, nonce, cspRepo
|
|
|
13
20
|
* Static picture sources that are used in static-monobera.
|
|
14
21
|
*/
|
|
15
22
|
export declare const staticPictureSources: string[];
|
|
16
|
-
export declare function cspMiddleware({ response, }: {
|
|
23
|
+
export declare function cspMiddleware({ useDynamicCsp, response, }: {
|
|
24
|
+
useDynamicCsp?: boolean;
|
|
17
25
|
request: NextRequest;
|
|
18
26
|
response: NextResponse;
|
|
19
27
|
}): NextResponse<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header-sources.d.ts","sourceRoot":"","sources":["../../src/internal/header-sources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAa7D,wBAAgB,wBAAwB,CAAC,EACvC,aAAa,EACb,KAAK,EACL,YAAY,EACZ,GAAG,IAAI,EACR,EAAE;IACD,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"header-sources.d.ts","sourceRoot":"","sources":["../../src/internal/header-sources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAa7D,uDAAuD;AACvD,wBAAgB,wBAAwB,CAAC,EACvC,aAAa,EACb,KAAK,EACL,YAAY,EACZ,GAAG,IAAI,EACR,EAAE;IACD,aAAa,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,MAAM,CA2LT;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAWvC,CAAC;AAEH,wBAAgB,aAAa,CAAC,EAC5B,aAAoB,EACpB,QAAQ,GACT,EAAE;IACD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;CACxB,yBA4CA"}
|
|
@@ -208,7 +208,7 @@ function getContentSecurityPolicy({
|
|
|
208
208
|
base-uri 'self';
|
|
209
209
|
frame-src 'self' ${frameSources.join(" ")};
|
|
210
210
|
frame-ancestors 'self' https://*.posthog.com;
|
|
211
|
-
script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}' https://*.posthog.com 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
|
|
211
|
+
script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' ${nonce ? `'nonce-${nonce}'` : ""} https://*.posthog.com 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
|
|
212
212
|
worker-src 'self' blob: data:;
|
|
213
213
|
font-src 'self' ${fontSources.join(" ")};
|
|
214
214
|
style-src 'self' ${styleSources.join(" ")} 'unsafe-inline';
|
|
@@ -237,10 +237,11 @@ var staticPictureSources = [
|
|
|
237
237
|
return true;
|
|
238
238
|
});
|
|
239
239
|
function cspMiddleware({
|
|
240
|
+
useDynamicCsp = true,
|
|
240
241
|
response
|
|
241
242
|
}) {
|
|
242
243
|
const sentryCspEndpoint = getSentryKeys()?.cspEndpoint;
|
|
243
|
-
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
|
|
244
|
+
const nonce = useDynamicCsp ? Buffer.from(crypto.randomUUID()).toString("base64") : void 0;
|
|
244
245
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
245
246
|
const headers = [
|
|
246
247
|
{
|
|
@@ -259,10 +260,7 @@ function cspMiddleware({
|
|
|
259
260
|
key: "X-Content-Type-Options",
|
|
260
261
|
value: "nosniff"
|
|
261
262
|
},
|
|
262
|
-
{
|
|
263
|
-
key: "X-Nonce",
|
|
264
|
-
value: nonce
|
|
265
|
-
}
|
|
263
|
+
...nonce ? [{ key: "X-Nonce", value: nonce }] : []
|
|
266
264
|
];
|
|
267
265
|
if (sentryCspEndpoint) {
|
|
268
266
|
headers.push({
|