4bnode 4.1.3 → 4.1.4

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/lib/codegen.js CHANGED
@@ -419,7 +419,28 @@ export function securityWiring(features) {
419
419
 
420
420
  if (has("helmet")) {
421
421
  imports.push("import helmet from 'helmet';");
422
- beforeRoutesParts.push("// ── Security headers ──\napp.use(helmet());");
422
+ beforeRoutesParts.push(
423
+ `// ── Security headers ──
424
+ // helmet() defaults to a strict Content-Security-Policy (script-src 'self',
425
+ // etc.) that blocks CDN-loaded scripts, inline <script> blocks, and cross-origin
426
+ // assets. We widen the policy so a typical frontend/docs page works while keeping
427
+ // the rest of helmet's protections. Tighten these directives for production.
428
+ app.use(helmet({
429
+ contentSecurityPolicy: {
430
+ directives: {
431
+ defaultSrc: ["'self'"],
432
+ scriptSrc: ["'self'", 'https:', "'unsafe-inline'"],
433
+ styleSrc: ["'self'", 'https:', "'unsafe-inline'"],
434
+ imgSrc: ["'self'", 'data:', 'https:'],
435
+ connectSrc: ["'self'"],
436
+ },
437
+ },
438
+ crossOriginEmbedderPolicy: false,
439
+ // Allow other origins (e.g. a separate frontend host) to load assets served
440
+ // by this app. Default is 'same-origin'. Tighten to 'same-site' for production.
441
+ crossOriginResourcePolicy: { policy: 'cross-origin' },
442
+ }));`
443
+ );
423
444
  }
424
445
  if (has("rateLimit")) {
425
446
  imports.push("import rateLimit from 'express-rate-limit';");
@@ -140,7 +140,8 @@ test("securityWiring composes imports + insertion blocks", () => {
140
140
  assert.ok(w.imports.includes("import helmet from 'helmet';"));
141
141
  assert.ok(w.imports.includes("import rateLimit from 'express-rate-limit';"));
142
142
  assert.ok(w.imports.some((i) => i.includes("errorHandler.js")));
143
- assert.ok(w.beforeRoutes.includes("app.use(helmet())"));
143
+ assert.ok(w.beforeRoutes.includes("app.use(helmet("));
144
+ assert.ok(w.beforeRoutes.includes("contentSecurityPolicy:"));
144
145
  assert.ok(w.beforeRoutes.includes("rateLimit({"));
145
146
  assert.ok(w.beforeListen.includes("app.use(notFound)"));
146
147
  assert.ok(w.beforeListen.includes("app.use(errorHandler)"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "4bnode",
3
- "version": "4.1.3",
3
+ "version": "4.1.4",
4
4
  "description": "4bnode is a CLI-powered backend development platform with a built-in visual dashboard to generate, manage, and test Node.js/Express APIs faster.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -419,7 +419,28 @@ export function securityWiring(features) {
419
419
 
420
420
  if (has("helmet")) {
421
421
  imports.push("import helmet from 'helmet';");
422
- beforeRoutesParts.push("// ── Security headers ──\napp.use(helmet());");
422
+ beforeRoutesParts.push(
423
+ `// ── Security headers ──
424
+ // helmet() defaults to a strict Content-Security-Policy (script-src 'self',
425
+ // etc.) that blocks CDN-loaded scripts, inline <script> blocks, and cross-origin
426
+ // assets. We widen the policy so a typical frontend/docs page works while keeping
427
+ // the rest of helmet's protections. Tighten these directives for production.
428
+ app.use(helmet({
429
+ contentSecurityPolicy: {
430
+ directives: {
431
+ defaultSrc: ["'self'"],
432
+ scriptSrc: ["'self'", 'https:', "'unsafe-inline'"],
433
+ styleSrc: ["'self'", 'https:', "'unsafe-inline'"],
434
+ imgSrc: ["'self'", 'data:', 'https:'],
435
+ connectSrc: ["'self'"],
436
+ },
437
+ },
438
+ crossOriginEmbedderPolicy: false,
439
+ // Allow other origins (e.g. a separate frontend host) to load assets served
440
+ // by this app. Default is 'same-origin'. Tighten to 'same-site' for production.
441
+ crossOriginResourcePolicy: { policy: 'cross-origin' },
442
+ }));`
443
+ );
423
444
  }
424
445
  if (has("rateLimit")) {
425
446
  imports.push("import rateLimit from 'express-rate-limit';");