@lwrjs/security 0.12.0-alpha.9 → 0.12.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.
@@ -91,6 +91,15 @@ async function resolveHeaders(viewResponse, options) {
91
91
  }
92
92
  headers[headerName] = (0, import_content_security_policy.default)(headers[headerName], options.contentSecurityPolicy, hashes);
93
93
  }
94
+ if (typeof options.contentSecurityPolicy === "string") {
95
+ const parsedOptions = {
96
+ directives: options.contentSecurityPolicy,
97
+ useDefault: false
98
+ };
99
+ const headerName = "content-security-policy";
100
+ const hashes = await getResourceHashes(viewResponse);
101
+ headers[headerName] = (0, import_content_security_policy.default)(headers[headerName], parsedOptions, hashes);
102
+ }
94
103
  if (options.referrerPolicy === void 0 || typeof options.referrerPolicy === "object") {
95
104
  const headerName = "referrer-policy";
96
105
  headers[headerName] = (0, import_referrer_policy.default)(headers[headerName], options.referrerPolicy);
@@ -68,6 +68,15 @@ export async function resolveHeaders(viewResponse, options) {
68
68
  }
69
69
  headers[headerName] = contentSecurityPolicy(headers[headerName], options.contentSecurityPolicy, hashes);
70
70
  }
71
+ if (typeof options.contentSecurityPolicy === 'string') {
72
+ const parsedOptions = {
73
+ directives: options.contentSecurityPolicy,
74
+ useDefault: false,
75
+ };
76
+ const headerName = 'content-security-policy';
77
+ const hashes = await getResourceHashes(viewResponse);
78
+ headers[headerName] = contentSecurityPolicy(headers[headerName], parsedOptions, hashes);
79
+ }
71
80
  if (options.referrerPolicy === undefined || typeof options.referrerPolicy === 'object') {
72
81
  const headerName = 'referrer-policy';
73
82
  headers[headerName] = referrerPolicy(headers[headerName], options.referrerPolicy);
@@ -2,7 +2,7 @@ import type { ContentSecurityPolicy } from './headers/content-security-policy.js
2
2
  import type { ReferrerPolicy } from './headers/referrer-policy.js';
3
3
  import type { StrictTransportSecurity } from './headers/strict-transport-security.js';
4
4
  export interface SecurityOptions extends Record<string, any> {
5
- contentSecurityPolicy?: ContentSecurityPolicy | boolean;
5
+ contentSecurityPolicy?: ContentSecurityPolicy | boolean | string;
6
6
  referrerPolicy?: ReferrerPolicy | boolean;
7
7
  strictTransportSecurity?: StrictTransportSecurity | boolean;
8
8
  crossOriginEmbedderPolicy?: string | boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwrjs/security",
3
- "version": "0.12.0-alpha.9",
3
+ "version": "0.12.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "types": "build/es/index.d.ts",
@@ -29,13 +29,13 @@
29
29
  "build/**/*.d.ts"
30
30
  ],
31
31
  "dependencies": {
32
- "@lwrjs/shared-utils": "0.12.0-alpha.9"
32
+ "@lwrjs/shared-utils": "0.12.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@lwrjs/types": "0.12.0-alpha.9"
35
+ "@lwrjs/types": "0.12.0"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=18.0.0"
39
39
  },
40
- "gitHead": "58b28fbc6300b704ac17f8878423120de0e376d7"
40
+ "gitHead": "90f93604b26003e1e1eb85bb0d1f34f4fc9e9ff9"
41
41
  }