@berachain/config 0.1.25 → 0.1.26-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.
- package/dist/{chunk-OA5M6XYF.cjs → chunk-2JZ7QJEW.cjs} +0 -7
- package/dist/{chunk-4WAGOEXT.mjs → chunk-AP2XG6GJ.mjs} +0 -7
- package/dist/internal/header-sources.cjs +21 -5
- package/dist/internal/header-sources.d.ts +15 -3
- package/dist/internal/header-sources.d.ts.map +1 -1
- package/dist/internal/header-sources.mjs +21 -5
- package/dist/internal/nextjs/const.d.ts.map +1 -1
- package/dist/internal/nextjs/index.cjs +2 -2
- package/dist/internal/nextjs/index.mjs +1 -1
- package/dist/internal/nextjs/utils/index.cjs +2 -2
- package/dist/internal/nextjs/utils/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -76,13 +76,6 @@ var IMAGE_REMOTE_PATTERNS = [
|
|
|
76
76
|
hostname: "imagedelivery.net",
|
|
77
77
|
port: "",
|
|
78
78
|
pathname: "/qNj7Q3MCke89zoKzav7eDQ/**"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
protocol: "https",
|
|
82
|
-
hostname: "www.clearstar.xyz",
|
|
83
|
-
// bend curator logo
|
|
84
|
-
port: "",
|
|
85
|
-
pathname: "/logo.png"
|
|
86
79
|
}
|
|
87
80
|
];
|
|
88
81
|
|
|
@@ -76,13 +76,6 @@ var IMAGE_REMOTE_PATTERNS = [
|
|
|
76
76
|
hostname: "imagedelivery.net",
|
|
77
77
|
port: "",
|
|
78
78
|
pathname: "/qNj7Q3MCke89zoKzav7eDQ/**"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
protocol: "https",
|
|
82
|
-
hostname: "www.clearstar.xyz",
|
|
83
|
-
// bend curator logo
|
|
84
|
-
port: "",
|
|
85
|
-
pathname: "/logo.png"
|
|
86
79
|
}
|
|
87
80
|
];
|
|
88
81
|
|
|
@@ -127,6 +127,7 @@ var modules = {
|
|
|
127
127
|
// /api/honey/* and /api/pol/* (covered by 'self'), not direct browser
|
|
128
128
|
// requests to the upstream URLs.
|
|
129
129
|
config.pol.bribeBoostApi,
|
|
130
|
+
_chunkYT7WZDGIcjs.getUriFromLink.call(void 0, config.beep),
|
|
130
131
|
_chunkYT7WZDGIcjs.getUriFromLink.call(void 0, config.api),
|
|
131
132
|
_chunkAU3LYJABcjs.jsonRpcUrl,
|
|
132
133
|
_chunkAU3LYJABcjs.publicJsonRpcUrl,
|
|
@@ -274,8 +275,8 @@ var modules = {
|
|
|
274
275
|
var headerSourceModules = modules;
|
|
275
276
|
function getContentSecurityPolicy({
|
|
276
277
|
isDevelopment,
|
|
277
|
-
nonce,
|
|
278
278
|
cspReporting,
|
|
279
|
+
dynamicScriptCsp = {},
|
|
279
280
|
modules: enabledModules = {},
|
|
280
281
|
...args
|
|
281
282
|
}) {
|
|
@@ -315,12 +316,21 @@ function getContentSecurityPolicy({
|
|
|
315
316
|
const mediaSources = dedupeCspSources(
|
|
316
317
|
collect("media").concat(_nullishCoalesce(args.mediaSources, () => ( [])))
|
|
317
318
|
);
|
|
319
|
+
const scriptSources = dynamicScriptCsp === "disabled" ? dedupeCspSources(collect("script").concat(_nullishCoalesce(args.scriptSources, () => ( [])))) : dedupeCspSources(
|
|
320
|
+
[
|
|
321
|
+
"'strict-dynamic'",
|
|
322
|
+
isDevelopment ? "'unsafe-eval'" : "",
|
|
323
|
+
"'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o='",
|
|
324
|
+
dynamicScriptCsp.nonce ? `'nonce-${dynamicScriptCsp.nonce}'` : "",
|
|
325
|
+
..._nullishCoalesce(dynamicScriptCsp.sha, () => ( []))
|
|
326
|
+
].filter((source) => source !== "")
|
|
327
|
+
);
|
|
318
328
|
let cspHeader = `
|
|
319
329
|
default-src 'self' ${defaultSrc.join(" ")};
|
|
320
330
|
base-uri 'self';
|
|
321
331
|
frame-src 'self' ${frameSources.join(" ")};
|
|
322
332
|
frame-ancestors 'self' https://*.posthog.com;
|
|
323
|
-
script-src 'self'
|
|
333
|
+
script-src 'self' ${scriptSources.join(" ")};
|
|
324
334
|
worker-src 'self' blob: data: ${workerSources.join(" ")};
|
|
325
335
|
font-src 'self' ${fontSources.join(" ")};
|
|
326
336
|
style-src 'self' ${styleSources.join(" ")} 'unsafe-inline';
|
|
@@ -353,16 +363,19 @@ function cspMiddleware({
|
|
|
353
363
|
csp
|
|
354
364
|
}) {
|
|
355
365
|
const sentryCspEndpoint = _optionalChain([getSentryKeys, 'call', _5 => _5(), 'optionalAccess', _6 => _6.cspEndpoint]);
|
|
356
|
-
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
|
|
366
|
+
const nonce = _optionalChain([csp, 'optionalAccess', _7 => _7.dynamicScriptCsp]) !== "disabled" ? _nullishCoalesce(_optionalChain([csp, 'optionalAccess', _8 => _8.dynamicScriptCsp, 'optionalAccess', _9 => _9.nonce]), () => ( Buffer.from(crypto.randomUUID()).toString("base64"))) : void 0;
|
|
357
367
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
358
368
|
const headers = [
|
|
359
369
|
{
|
|
360
370
|
key: "Content-Security-Policy",
|
|
361
371
|
value: getContentSecurityPolicy({
|
|
362
372
|
...csp,
|
|
373
|
+
dynamicScriptCsp: _optionalChain([csp, 'optionalAccess', _10 => _10.dynamicScriptCsp]) === "disabled" ? csp.dynamicScriptCsp : {
|
|
374
|
+
..._optionalChain([csp, 'optionalAccess', _11 => _11.dynamicScriptCsp]),
|
|
375
|
+
nonce
|
|
376
|
+
},
|
|
363
377
|
isDevelopment,
|
|
364
|
-
cspReporting: _optionalChain([sentryCspEndpoint, 'optionalAccess',
|
|
365
|
-
nonce
|
|
378
|
+
cspReporting: _optionalChain([sentryCspEndpoint, 'optionalAccess', _12 => _12.toString, 'call', _13 => _13()])
|
|
366
379
|
})
|
|
367
380
|
},
|
|
368
381
|
{
|
|
@@ -389,6 +402,9 @@ function cspMiddleware({
|
|
|
389
402
|
});
|
|
390
403
|
}
|
|
391
404
|
for (const header of headers) {
|
|
405
|
+
if (!header.value) {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
392
408
|
response.headers.set(header.key, header.value);
|
|
393
409
|
}
|
|
394
410
|
return response;
|
|
@@ -19,10 +19,12 @@ interface HeaderSources {
|
|
|
19
19
|
worker?: string[];
|
|
20
20
|
/** media-src */
|
|
21
21
|
media?: string[];
|
|
22
|
+
/** script-src (if csp is not dynamic) */
|
|
23
|
+
script?: string[];
|
|
22
24
|
}
|
|
23
25
|
declare const modules: {
|
|
24
26
|
readonly berachain: {
|
|
25
|
-
readonly connect: ["https://*.berachain.com/", "https://*.berachain-staging.com/", "https://raw.githubusercontent.com/berachain/metadata/", "https://imagedelivery.net/qNj7Q3MCke89zoKzav7eDQ/", "https://*.quiknode.pro", "https://api.goldsky.com/api/public/project_clq1h5ct0g4a201x18tfte5iv/subgraphs/", string, string, string, string, string | undefined, "https://api.routescan.io/v2/network/"];
|
|
27
|
+
readonly connect: ["https://*.berachain.com/", "https://*.berachain-staging.com/", "https://raw.githubusercontent.com/berachain/metadata/", "https://imagedelivery.net/qNj7Q3MCke89zoKzav7eDQ/", "https://*.quiknode.pro", "https://api.goldsky.com/api/public/project_clq1h5ct0g4a201x18tfte5iv/subgraphs/", string, string, string, string, string, string | undefined, "https://api.routescan.io/v2/network/"];
|
|
26
28
|
readonly img: ["https://imagedelivery.net/qNj7Q3MCke89zoKzav7eDQ/", "https://raw.githubusercontent.com/berachain/metadata/"];
|
|
27
29
|
};
|
|
28
30
|
readonly beranames: {
|
|
@@ -109,7 +111,18 @@ export type HeaderSourceModule = keyof typeof modules;
|
|
|
109
111
|
export interface CspOptions {
|
|
110
112
|
/** per-module toggle; all modules default to `true`, set `false` to exclude one from every directive */
|
|
111
113
|
modules?: Partial<Record<HeaderSourceModule, boolean>>;
|
|
114
|
+
/**
|
|
115
|
+
* `script-src` strategy. Omit (or pass an object) to keep the `strict-dynamic`
|
|
116
|
+
* policy — the fixed hash plus an optional per-request `nonce` and extra
|
|
117
|
+
* `sha` hashes. Pass `"disabled"` to fall back to a host-allowlist built from
|
|
118
|
+
* the `script` module sources instead.
|
|
119
|
+
*/
|
|
120
|
+
dynamicScriptCsp?: "disabled" | {
|
|
121
|
+
sha?: string[];
|
|
122
|
+
nonce?: string;
|
|
123
|
+
};
|
|
112
124
|
frameSources?: string[];
|
|
125
|
+
scriptSources?: string[];
|
|
113
126
|
fontSources?: string[];
|
|
114
127
|
pictureSources?: string[];
|
|
115
128
|
connectionSources?: string[];
|
|
@@ -123,9 +136,8 @@ export interface CspOptions {
|
|
|
123
136
|
* {@link getContentSecurityPolicy} / {@link cspMiddleware}.
|
|
124
137
|
*/
|
|
125
138
|
export declare const headerSourceModules: Record<HeaderSourceModule, HeaderSources>;
|
|
126
|
-
export declare function getContentSecurityPolicy({ isDevelopment,
|
|
139
|
+
export declare function getContentSecurityPolicy({ isDevelopment, cspReporting, dynamicScriptCsp, modules: enabledModules, ...args }: CspOptions & {
|
|
127
140
|
isDevelopment: boolean;
|
|
128
|
-
nonce: string;
|
|
129
141
|
cspReporting?: string;
|
|
130
142
|
}): string;
|
|
131
143
|
/**
|
|
@@ -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;AAgB7D;;;;GAIG;AACH,UAAU,aAAa;IACrB,kBAAkB;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACpC,cAAc;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,eAAe;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,iBAAiB;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,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;AAgB7D;;;;GAIG;AACH,UAAU,aAAa;IACrB,kBAAkB;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACpC,cAAc;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,eAAe;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,iBAAiB;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6JqC,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,OAAO,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,wGAAwG;IACxG,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD;;;;;OAKG;IACH,gBAAgB,CAAC,EACb,UAAU,GACV;QACE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACN,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,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,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CACjE,CAAC;AAEV,wBAAgB,wBAAwB,CAAC,EACvC,aAAa,EACb,YAAY,EACZ,gBAAqB,EACrB,OAAO,EAAE,cAAmB,EAC5B,GAAG,IAAI,EACR,EAAE,UAAU,GAAG;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,MAAM,CAyFT;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAWvC,CAAC;AAEH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,mGAAmG;IACnG,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB,yBA2DA"}
|
|
@@ -127,6 +127,7 @@ var modules = {
|
|
|
127
127
|
// /api/honey/* and /api/pol/* (covered by 'self'), not direct browser
|
|
128
128
|
// requests to the upstream URLs.
|
|
129
129
|
config.pol.bribeBoostApi,
|
|
130
|
+
getUriFromLink(config.beep),
|
|
130
131
|
getUriFromLink(config.api),
|
|
131
132
|
jsonRpcUrl,
|
|
132
133
|
publicJsonRpcUrl,
|
|
@@ -274,8 +275,8 @@ var modules = {
|
|
|
274
275
|
var headerSourceModules = modules;
|
|
275
276
|
function getContentSecurityPolicy({
|
|
276
277
|
isDevelopment,
|
|
277
|
-
nonce,
|
|
278
278
|
cspReporting,
|
|
279
|
+
dynamicScriptCsp = {},
|
|
279
280
|
modules: enabledModules = {},
|
|
280
281
|
...args
|
|
281
282
|
}) {
|
|
@@ -315,12 +316,21 @@ function getContentSecurityPolicy({
|
|
|
315
316
|
const mediaSources = dedupeCspSources(
|
|
316
317
|
collect("media").concat(args.mediaSources ?? [])
|
|
317
318
|
);
|
|
319
|
+
const scriptSources = dynamicScriptCsp === "disabled" ? dedupeCspSources(collect("script").concat(args.scriptSources ?? [])) : dedupeCspSources(
|
|
320
|
+
[
|
|
321
|
+
"'strict-dynamic'",
|
|
322
|
+
isDevelopment ? "'unsafe-eval'" : "",
|
|
323
|
+
"'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o='",
|
|
324
|
+
dynamicScriptCsp.nonce ? `'nonce-${dynamicScriptCsp.nonce}'` : "",
|
|
325
|
+
...dynamicScriptCsp.sha ?? []
|
|
326
|
+
].filter((source) => source !== "")
|
|
327
|
+
);
|
|
318
328
|
let cspHeader = `
|
|
319
329
|
default-src 'self' ${defaultSrc.join(" ")};
|
|
320
330
|
base-uri 'self';
|
|
321
331
|
frame-src 'self' ${frameSources.join(" ")};
|
|
322
332
|
frame-ancestors 'self' https://*.posthog.com;
|
|
323
|
-
script-src 'self'
|
|
333
|
+
script-src 'self' ${scriptSources.join(" ")};
|
|
324
334
|
worker-src 'self' blob: data: ${workerSources.join(" ")};
|
|
325
335
|
font-src 'self' ${fontSources.join(" ")};
|
|
326
336
|
style-src 'self' ${styleSources.join(" ")} 'unsafe-inline';
|
|
@@ -353,16 +363,19 @@ function cspMiddleware({
|
|
|
353
363
|
csp
|
|
354
364
|
}) {
|
|
355
365
|
const sentryCspEndpoint = getSentryKeys()?.cspEndpoint;
|
|
356
|
-
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
|
|
366
|
+
const nonce = csp?.dynamicScriptCsp !== "disabled" ? csp?.dynamicScriptCsp?.nonce ?? Buffer.from(crypto.randomUUID()).toString("base64") : void 0;
|
|
357
367
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
358
368
|
const headers = [
|
|
359
369
|
{
|
|
360
370
|
key: "Content-Security-Policy",
|
|
361
371
|
value: getContentSecurityPolicy({
|
|
362
372
|
...csp,
|
|
373
|
+
dynamicScriptCsp: csp?.dynamicScriptCsp === "disabled" ? csp.dynamicScriptCsp : {
|
|
374
|
+
...csp?.dynamicScriptCsp,
|
|
375
|
+
nonce
|
|
376
|
+
},
|
|
363
377
|
isDevelopment,
|
|
364
|
-
cspReporting: sentryCspEndpoint?.toString()
|
|
365
|
-
nonce
|
|
378
|
+
cspReporting: sentryCspEndpoint?.toString()
|
|
366
379
|
})
|
|
367
380
|
},
|
|
368
381
|
{
|
|
@@ -389,6 +402,9 @@ function cspMiddleware({
|
|
|
389
402
|
});
|
|
390
403
|
}
|
|
391
404
|
for (const header of headers) {
|
|
405
|
+
if (!header.value) {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
392
408
|
response.headers.set(header.key, header.value);
|
|
393
409
|
}
|
|
394
410
|
return response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../src/internal/nextjs/const.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAC7C,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../src/internal/nextjs/const.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAC7C,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CA2EpD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk2JZ7QJEWcjs = require('../../chunk-2JZ7QJEW.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkSHM2VD4Acjs = require('../../chunk-SHM2VD4A.cjs');
|
|
@@ -53,7 +53,7 @@ function withBeraConfig(config, {
|
|
|
53
53
|
...config,
|
|
54
54
|
images: {
|
|
55
55
|
...config.images,
|
|
56
|
-
remotePatterns: [...
|
|
56
|
+
remotePatterns: [..._chunk2JZ7QJEWcjs.IMAGE_REMOTE_PATTERNS]
|
|
57
57
|
},
|
|
58
58
|
async rewrites() {
|
|
59
59
|
if (!withPostHogReverseProxy) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk2JZ7QJEWcjs = require('../../../chunk-2JZ7QJEW.cjs');
|
|
4
4
|
|
|
5
5
|
// src/internal/nextjs/utils/index.ts
|
|
6
6
|
function globToRegExp(glob) {
|
|
@@ -19,7 +19,7 @@ function isAllowedImageUrl(urlString) {
|
|
|
19
19
|
try {
|
|
20
20
|
if (!urlString) return false;
|
|
21
21
|
const url = new URL(urlString);
|
|
22
|
-
for (const pattern of
|
|
22
|
+
for (const pattern of _chunk2JZ7QJEWcjs.IMAGE_REMOTE_PATTERNS) {
|
|
23
23
|
if (pattern.protocol && url.protocol.replace(":", "") !== pattern.protocol)
|
|
24
24
|
continue;
|
|
25
25
|
if (normalizeHostname(url.hostname) !== normalizeHostname(pattern.hostname))
|