@berachain/config 0.1.24-beta.6 → 0.1.25
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/internal/header-sources.cjs +16 -8
- package/dist/internal/header-sources.d.ts +28 -12
- package/dist/internal/header-sources.d.ts.map +1 -1
- package/dist/internal/header-sources.mjs +16 -8
- package/dist/internal/nextjs/index.cjs +3 -3
- package/dist/internal/nextjs/index.mjs +3 -3
- package/package.json +1 -1
|
@@ -155,7 +155,8 @@ var modules = {
|
|
|
155
155
|
"https://open-api.openocean.finance/",
|
|
156
156
|
"https://api.haiku.trade/",
|
|
157
157
|
"https://api.fly.trade/",
|
|
158
|
-
"https://api.enso.finance/"
|
|
158
|
+
"https://api.enso.finance/",
|
|
159
|
+
"https://api.enso.build/"
|
|
159
160
|
]
|
|
160
161
|
},
|
|
161
162
|
walletConnect: {
|
|
@@ -258,7 +259,8 @@ var modules = {
|
|
|
258
259
|
img: ["https://*.posthog.com"],
|
|
259
260
|
frame: ["https://*.posthog.com"],
|
|
260
261
|
font: ["https://*.posthog.com"],
|
|
261
|
-
style: ["https://*.posthog.com"]
|
|
262
|
+
style: ["https://*.posthog.com"],
|
|
263
|
+
media: ["https://*.posthog.com"]
|
|
262
264
|
},
|
|
263
265
|
vercel: {
|
|
264
266
|
// toolbar + live comments
|
|
@@ -307,18 +309,24 @@ function getContentSecurityPolicy({
|
|
|
307
309
|
const styleSources = dedupeCspSources(
|
|
308
310
|
collect("style").concat(_nullishCoalesce(args.styleSources, () => ( [])))
|
|
309
311
|
);
|
|
312
|
+
const workerSources = dedupeCspSources(
|
|
313
|
+
collect("worker").concat(_nullishCoalesce(args.workerSources, () => ( [])))
|
|
314
|
+
);
|
|
315
|
+
const mediaSources = dedupeCspSources(
|
|
316
|
+
collect("media").concat(_nullishCoalesce(args.mediaSources, () => ( [])))
|
|
317
|
+
);
|
|
310
318
|
let cspHeader = `
|
|
311
319
|
default-src 'self' ${defaultSrc.join(" ")};
|
|
312
320
|
base-uri 'self';
|
|
313
321
|
frame-src 'self' ${frameSources.join(" ")};
|
|
314
322
|
frame-ancestors 'self' https://*.posthog.com;
|
|
315
|
-
script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}'
|
|
316
|
-
worker-src 'self' blob: data
|
|
323
|
+
script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}' 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
|
|
324
|
+
worker-src 'self' blob: data: ${workerSources.join(" ")};
|
|
317
325
|
font-src 'self' ${fontSources.join(" ")};
|
|
318
326
|
style-src 'self' ${styleSources.join(" ")} 'unsafe-inline';
|
|
319
327
|
img-src 'self' data: ${pictureSources.join(" ")};
|
|
320
328
|
connect-src 'self' ${connectionSources.join(" ")};
|
|
321
|
-
media-src
|
|
329
|
+
media-src 'self' ${mediaSources.join(" ")};
|
|
322
330
|
`;
|
|
323
331
|
if (cspReporting) {
|
|
324
332
|
cspHeader += `
|
|
@@ -342,7 +350,7 @@ var staticPictureSources = [
|
|
|
342
350
|
});
|
|
343
351
|
function cspMiddleware({
|
|
344
352
|
response,
|
|
345
|
-
|
|
353
|
+
csp
|
|
346
354
|
}) {
|
|
347
355
|
const sentryCspEndpoint = _optionalChain([getSentryKeys, 'call', _5 => _5(), 'optionalAccess', _6 => _6.cspEndpoint]);
|
|
348
356
|
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
|
|
@@ -351,10 +359,10 @@ function cspMiddleware({
|
|
|
351
359
|
{
|
|
352
360
|
key: "Content-Security-Policy",
|
|
353
361
|
value: getContentSecurityPolicy({
|
|
362
|
+
...csp,
|
|
354
363
|
isDevelopment,
|
|
355
364
|
cspReporting: _optionalChain([sentryCspEndpoint, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]),
|
|
356
|
-
nonce
|
|
357
|
-
modules: modules2
|
|
365
|
+
nonce
|
|
358
366
|
})
|
|
359
367
|
},
|
|
360
368
|
{
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { NextRequest, NextResponse } from "next/server";
|
|
2
2
|
/**
|
|
3
|
-
* CSP allowlists contributed by one integration, keyed by directive.
|
|
3
|
+
* CSP allowlists contributed by one integration, keyed by directive. Each
|
|
4
|
+
* directive's fixed policy tokens (`'self'`, `data:`, nonces, …) live in the
|
|
5
|
+
* template; these are the integration-specific hosts appended to them.
|
|
4
6
|
*/
|
|
5
7
|
interface HeaderSources {
|
|
6
8
|
/** connect-src */
|
|
@@ -13,6 +15,10 @@ interface HeaderSources {
|
|
|
13
15
|
font?: string[];
|
|
14
16
|
/** style-src */
|
|
15
17
|
style?: string[];
|
|
18
|
+
/** worker-src */
|
|
19
|
+
worker?: string[];
|
|
20
|
+
/** media-src */
|
|
21
|
+
media?: string[];
|
|
16
22
|
}
|
|
17
23
|
declare const modules: {
|
|
18
24
|
readonly berachain: {
|
|
@@ -24,7 +30,7 @@ declare const modules: {
|
|
|
24
30
|
readonly img: ["https://beranames-assets-berachain.s3.eu-central-003.backblazeb2.com/"];
|
|
25
31
|
};
|
|
26
32
|
readonly swapAggregators: {
|
|
27
|
-
readonly connect: [`${string}/`, "https://open-api.openocean.finance/", "https://api.haiku.trade/", "https://api.fly.trade/", "https://api.enso.finance/"];
|
|
33
|
+
readonly connect: [`${string}/`, "https://open-api.openocean.finance/", "https://api.haiku.trade/", "https://api.fly.trade/", "https://api.enso.finance/", "https://api.enso.build/"];
|
|
28
34
|
};
|
|
29
35
|
readonly walletConnect: {
|
|
30
36
|
readonly connect: ["wss://relay.walletconnect.com/", "wss://relay.walletconnect.org/", "https://verify.walletconnect.org/v3/public-key"];
|
|
@@ -84,6 +90,7 @@ declare const modules: {
|
|
|
84
90
|
readonly frame: ["https://*.posthog.com"];
|
|
85
91
|
readonly font: ["https://*.posthog.com"];
|
|
86
92
|
readonly style: ["https://*.posthog.com"];
|
|
93
|
+
readonly media: ["https://*.posthog.com"];
|
|
87
94
|
};
|
|
88
95
|
readonly vercel: {
|
|
89
96
|
readonly connect: ["https://vercel.live", "wss://ws-us3.pusher.com"];
|
|
@@ -95,14 +102,11 @@ declare const modules: {
|
|
|
95
102
|
};
|
|
96
103
|
export type HeaderSourceModule = keyof typeof modules;
|
|
97
104
|
/**
|
|
98
|
-
* CSP
|
|
99
|
-
*
|
|
100
|
-
*
|
|
105
|
+
* Per-request CSP customization a consumer can pass to
|
|
106
|
+
* {@link getContentSecurityPolicy} / {@link cspMiddleware}: toggle whole
|
|
107
|
+
* integration modules off, and/or append extra allowlist entries per directive.
|
|
101
108
|
*/
|
|
102
|
-
export
|
|
103
|
-
export declare function getContentSecurityPolicy({ isDevelopment, nonce, cspReporting, modules: enabledModules, ...args }: {
|
|
104
|
-
isDevelopment: boolean;
|
|
105
|
-
nonce: string;
|
|
109
|
+
export interface CspOptions {
|
|
106
110
|
/** per-module toggle; all modules default to `true`, set `false` to exclude one from every directive */
|
|
107
111
|
modules?: Partial<Record<HeaderSourceModule, boolean>>;
|
|
108
112
|
frameSources?: string[];
|
|
@@ -110,17 +114,29 @@ export declare function getContentSecurityPolicy({ isDevelopment, nonce, cspRepo
|
|
|
110
114
|
pictureSources?: string[];
|
|
111
115
|
connectionSources?: string[];
|
|
112
116
|
styleSources?: string[];
|
|
117
|
+
workerSources?: string[];
|
|
118
|
+
mediaSources?: string[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* CSP sources grouped by the integration that needs them. All modules are
|
|
122
|
+
* enabled by default; consumers opt out per module via `modules` on
|
|
123
|
+
* {@link getContentSecurityPolicy} / {@link cspMiddleware}.
|
|
124
|
+
*/
|
|
125
|
+
export declare const headerSourceModules: Record<HeaderSourceModule, HeaderSources>;
|
|
126
|
+
export declare function getContentSecurityPolicy({ isDevelopment, nonce, cspReporting, modules: enabledModules, ...args }: CspOptions & {
|
|
127
|
+
isDevelopment: boolean;
|
|
128
|
+
nonce: string;
|
|
113
129
|
cspReporting?: string;
|
|
114
130
|
}): string;
|
|
115
131
|
/**
|
|
116
132
|
* Static picture sources that are used in static-monobera.
|
|
117
133
|
*/
|
|
118
134
|
export declare const staticPictureSources: string[];
|
|
119
|
-
export declare function cspMiddleware({ response,
|
|
135
|
+
export declare function cspMiddleware({ response, csp, }: {
|
|
120
136
|
request: NextRequest;
|
|
121
137
|
response: NextResponse;
|
|
122
|
-
/** per-
|
|
123
|
-
|
|
138
|
+
/** per-request CSP customization — toggle modules off and/or append extra sources per directive */
|
|
139
|
+
csp?: CspOptions;
|
|
124
140
|
}): NextResponse<unknown>;
|
|
125
141
|
export {};
|
|
126
142
|
//# sourceMappingURL=header-sources.d.ts.map
|
|
@@ -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
|
|
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,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A8CA"}
|
|
@@ -155,7 +155,8 @@ var modules = {
|
|
|
155
155
|
"https://open-api.openocean.finance/",
|
|
156
156
|
"https://api.haiku.trade/",
|
|
157
157
|
"https://api.fly.trade/",
|
|
158
|
-
"https://api.enso.finance/"
|
|
158
|
+
"https://api.enso.finance/",
|
|
159
|
+
"https://api.enso.build/"
|
|
159
160
|
]
|
|
160
161
|
},
|
|
161
162
|
walletConnect: {
|
|
@@ -258,7 +259,8 @@ var modules = {
|
|
|
258
259
|
img: ["https://*.posthog.com"],
|
|
259
260
|
frame: ["https://*.posthog.com"],
|
|
260
261
|
font: ["https://*.posthog.com"],
|
|
261
|
-
style: ["https://*.posthog.com"]
|
|
262
|
+
style: ["https://*.posthog.com"],
|
|
263
|
+
media: ["https://*.posthog.com"]
|
|
262
264
|
},
|
|
263
265
|
vercel: {
|
|
264
266
|
// toolbar + live comments
|
|
@@ -307,18 +309,24 @@ function getContentSecurityPolicy({
|
|
|
307
309
|
const styleSources = dedupeCspSources(
|
|
308
310
|
collect("style").concat(args.styleSources ?? [])
|
|
309
311
|
);
|
|
312
|
+
const workerSources = dedupeCspSources(
|
|
313
|
+
collect("worker").concat(args.workerSources ?? [])
|
|
314
|
+
);
|
|
315
|
+
const mediaSources = dedupeCspSources(
|
|
316
|
+
collect("media").concat(args.mediaSources ?? [])
|
|
317
|
+
);
|
|
310
318
|
let cspHeader = `
|
|
311
319
|
default-src 'self' ${defaultSrc.join(" ")};
|
|
312
320
|
base-uri 'self';
|
|
313
321
|
frame-src 'self' ${frameSources.join(" ")};
|
|
314
322
|
frame-ancestors 'self' https://*.posthog.com;
|
|
315
|
-
script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}'
|
|
316
|
-
worker-src 'self' blob: data
|
|
323
|
+
script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}' 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
|
|
324
|
+
worker-src 'self' blob: data: ${workerSources.join(" ")};
|
|
317
325
|
font-src 'self' ${fontSources.join(" ")};
|
|
318
326
|
style-src 'self' ${styleSources.join(" ")} 'unsafe-inline';
|
|
319
327
|
img-src 'self' data: ${pictureSources.join(" ")};
|
|
320
328
|
connect-src 'self' ${connectionSources.join(" ")};
|
|
321
|
-
media-src
|
|
329
|
+
media-src 'self' ${mediaSources.join(" ")};
|
|
322
330
|
`;
|
|
323
331
|
if (cspReporting) {
|
|
324
332
|
cspHeader += `
|
|
@@ -342,7 +350,7 @@ var staticPictureSources = [
|
|
|
342
350
|
});
|
|
343
351
|
function cspMiddleware({
|
|
344
352
|
response,
|
|
345
|
-
|
|
353
|
+
csp
|
|
346
354
|
}) {
|
|
347
355
|
const sentryCspEndpoint = getSentryKeys()?.cspEndpoint;
|
|
348
356
|
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
|
|
@@ -351,10 +359,10 @@ function cspMiddleware({
|
|
|
351
359
|
{
|
|
352
360
|
key: "Content-Security-Policy",
|
|
353
361
|
value: getContentSecurityPolicy({
|
|
362
|
+
...csp,
|
|
354
363
|
isDevelopment,
|
|
355
364
|
cspReporting: sentryCspEndpoint?.toString(),
|
|
356
|
-
nonce
|
|
357
|
-
modules: modules2
|
|
365
|
+
nonce
|
|
358
366
|
})
|
|
359
367
|
},
|
|
360
368
|
{
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var _chunkZTYHPIUWcjs = require('../../chunk-ZTYHPIUW.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
3
|
var _chunkOA5M6XYFcjs = require('../../chunk-OA5M6XYF.cjs');
|
|
7
4
|
|
|
8
5
|
|
|
@@ -12,6 +9,9 @@ require('../../chunk-ZJEZCW5Z.cjs');
|
|
|
12
9
|
require('../../chunk-AU3LYJAB.cjs');
|
|
13
10
|
require('../../chunk-EYYJ2UZT.cjs');
|
|
14
11
|
|
|
12
|
+
|
|
13
|
+
var _chunkZTYHPIUWcjs = require('../../chunk-ZTYHPIUW.cjs');
|
|
14
|
+
|
|
15
15
|
// src/internal/nextjs/index.ts
|
|
16
16
|
var _dotenv = require('dotenv'); var _dotenv2 = _interopRequireDefault(_dotenv);
|
|
17
17
|
_dotenv2.default.config({ path: ["../../.env.local", "../../.env"] });
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
withSentryConfig
|
|
3
|
-
} from "../../chunk-XA5DMTFW.mjs";
|
|
4
1
|
import {
|
|
5
2
|
IMAGE_REMOTE_PATTERNS
|
|
6
3
|
} from "../../chunk-4WAGOEXT.mjs";
|
|
@@ -11,6 +8,9 @@ import "../../chunk-KPZI7IXR.mjs";
|
|
|
11
8
|
import "../../chunk-5SH7AT43.mjs";
|
|
12
9
|
import "../../chunk-VWRKCGMU.mjs";
|
|
13
10
|
import "../../chunk-KJXYSGNH.mjs";
|
|
11
|
+
import {
|
|
12
|
+
withSentryConfig
|
|
13
|
+
} from "../../chunk-XA5DMTFW.mjs";
|
|
14
14
|
|
|
15
15
|
// src/internal/nextjs/index.ts
|
|
16
16
|
import dotenv from "dotenv";
|