@berachain/config 0.1.24-beta.6 → 0.1.24

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.
@@ -258,7 +258,8 @@ var modules = {
258
258
  img: ["https://*.posthog.com"],
259
259
  frame: ["https://*.posthog.com"],
260
260
  font: ["https://*.posthog.com"],
261
- style: ["https://*.posthog.com"]
261
+ style: ["https://*.posthog.com"],
262
+ media: ["https://*.posthog.com"]
262
263
  },
263
264
  vercel: {
264
265
  // toolbar + live comments
@@ -307,18 +308,24 @@ function getContentSecurityPolicy({
307
308
  const styleSources = dedupeCspSources(
308
309
  collect("style").concat(_nullishCoalesce(args.styleSources, () => ( [])))
309
310
  );
311
+ const workerSources = dedupeCspSources(
312
+ collect("worker").concat(_nullishCoalesce(args.workerSources, () => ( [])))
313
+ );
314
+ const mediaSources = dedupeCspSources(
315
+ collect("media").concat(_nullishCoalesce(args.mediaSources, () => ( [])))
316
+ );
310
317
  let cspHeader = `
311
318
  default-src 'self' ${defaultSrc.join(" ")};
312
319
  base-uri 'self';
313
320
  frame-src 'self' ${frameSources.join(" ")};
314
321
  frame-ancestors 'self' https://*.posthog.com;
315
- script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}' https://*.posthog.com 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
316
- worker-src 'self' blob: data:;
322
+ script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}' 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
323
+ worker-src 'self' blob: data: ${workerSources.join(" ")};
317
324
  font-src 'self' ${fontSources.join(" ")};
318
325
  style-src 'self' ${styleSources.join(" ")} 'unsafe-inline';
319
326
  img-src 'self' data: ${pictureSources.join(" ")};
320
327
  connect-src 'self' ${connectionSources.join(" ")};
321
- media-src https://*.posthog.com;
328
+ media-src 'self' ${mediaSources.join(" ")};
322
329
  `;
323
330
  if (cspReporting) {
324
331
  cspHeader += `
@@ -342,7 +349,7 @@ var staticPictureSources = [
342
349
  });
343
350
  function cspMiddleware({
344
351
  response,
345
- modules: modules2
352
+ csp
346
353
  }) {
347
354
  const sentryCspEndpoint = _optionalChain([getSentryKeys, 'call', _5 => _5(), 'optionalAccess', _6 => _6.cspEndpoint]);
348
355
  const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
@@ -351,10 +358,10 @@ function cspMiddleware({
351
358
  {
352
359
  key: "Content-Security-Policy",
353
360
  value: getContentSecurityPolicy({
361
+ ...csp,
354
362
  isDevelopment,
355
363
  cspReporting: _optionalChain([sentryCspEndpoint, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]),
356
- nonce,
357
- modules: modules2
364
+ nonce
358
365
  })
359
366
  },
360
367
  {
@@ -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: {
@@ -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 sources grouped by the integration that needs them. All modules are
99
- * enabled by default; consumers opt out per module via `modules` on
100
- * {@link getContentSecurityPolicy} / {@link cspMiddleware}.
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 declare const headerSourceModules: Record<HeaderSourceModule, HeaderSources>;
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, modules, }: {
135
+ export declare function cspMiddleware({ response, csp, }: {
120
136
  request: NextRequest;
121
137
  response: NextResponse;
122
- /** per-module toggle; all modules default to `true`, set `false` to exclude one from the CSP */
123
- modules?: Partial<Record<HeaderSourceModule, boolean>>;
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;;GAEG;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;CAClB;AAED,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0JqC,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,OAAO,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CACjE,CAAC;AAEV,wBAAgB,wBAAwB,CAAC,EACvC,aAAa,EACb,KAAK,EACL,YAAY,EACZ,OAAO,EAAE,cAAmB,EAC5B,GAAG,IAAI,EACR,EAAE;IACD,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,wGAAwG;IACxG,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC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AM,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,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,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,KAAK,EACL,YAAY,EACZ,OAAO,EAAE,cAAmB,EAC5B,GAAG,IAAI,EACR,EAAE,UAAU,GAAG;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,MAAM,CA8ET;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,yBA8CA"}
@@ -258,7 +258,8 @@ var modules = {
258
258
  img: ["https://*.posthog.com"],
259
259
  frame: ["https://*.posthog.com"],
260
260
  font: ["https://*.posthog.com"],
261
- style: ["https://*.posthog.com"]
261
+ style: ["https://*.posthog.com"],
262
+ media: ["https://*.posthog.com"]
262
263
  },
263
264
  vercel: {
264
265
  // toolbar + live comments
@@ -307,18 +308,24 @@ function getContentSecurityPolicy({
307
308
  const styleSources = dedupeCspSources(
308
309
  collect("style").concat(args.styleSources ?? [])
309
310
  );
311
+ const workerSources = dedupeCspSources(
312
+ collect("worker").concat(args.workerSources ?? [])
313
+ );
314
+ const mediaSources = dedupeCspSources(
315
+ collect("media").concat(args.mediaSources ?? [])
316
+ );
310
317
  let cspHeader = `
311
318
  default-src 'self' ${defaultSrc.join(" ")};
312
319
  base-uri 'self';
313
320
  frame-src 'self' ${frameSources.join(" ")};
314
321
  frame-ancestors 'self' https://*.posthog.com;
315
- script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}' https://*.posthog.com 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
316
- worker-src 'self' blob: data:;
322
+ script-src 'self' 'sha256-k2HGvaYkGyYZxOwKGxgE1mr06tZEDcEXNZ5mdcldK0o=' 'nonce-${nonce}' 'strict-dynamic' ${isDevelopment ? "'unsafe-eval'" : ""};
323
+ worker-src 'self' blob: data: ${workerSources.join(" ")};
317
324
  font-src 'self' ${fontSources.join(" ")};
318
325
  style-src 'self' ${styleSources.join(" ")} 'unsafe-inline';
319
326
  img-src 'self' data: ${pictureSources.join(" ")};
320
327
  connect-src 'self' ${connectionSources.join(" ")};
321
- media-src https://*.posthog.com;
328
+ media-src 'self' ${mediaSources.join(" ")};
322
329
  `;
323
330
  if (cspReporting) {
324
331
  cspHeader += `
@@ -342,7 +349,7 @@ var staticPictureSources = [
342
349
  });
343
350
  function cspMiddleware({
344
351
  response,
345
- modules: modules2
352
+ csp
346
353
  }) {
347
354
  const sentryCspEndpoint = getSentryKeys()?.cspEndpoint;
348
355
  const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
@@ -351,10 +358,10 @@ function cspMiddleware({
351
358
  {
352
359
  key: "Content-Security-Policy",
353
360
  value: getContentSecurityPolicy({
361
+ ...csp,
354
362
  isDevelopment,
355
363
  cspReporting: sentryCspEndpoint?.toString(),
356
- nonce,
357
- modules: modules2
364
+ nonce
358
365
  })
359
366
  },
360
367
  {
@@ -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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berachain/config",
3
- "version": "0.1.24-beta.6",
3
+ "version": "0.1.24",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",