@jamesbrightman/pretty-csp 0.0.0-stage → 0.1.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/index.cjs ADDED
@@ -0,0 +1,1146 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ NONCE_PLACEHOLDER: () => NONCE_PLACEHOLDER,
24
+ Policy: () => Policy,
25
+ audit: () => audit,
26
+ baseDirectives: () => baseDirectives,
27
+ baseSchema: () => baseSchema,
28
+ cspHash: () => cspHash,
29
+ definePolicy: () => definePolicy,
30
+ defineRuleSet: () => defineRuleSet,
31
+ diffPolicies: () => diffPolicies,
32
+ generateNonce: () => generateNonce,
33
+ importHeader: () => importHeader,
34
+ importedPolicyToDraft: () => importedPolicyToDraft,
35
+ matchPolicy: () => matchPolicy,
36
+ parseViolationReports: () => parseViolationReports,
37
+ policyConfigSchema: () => policyConfigSchema,
38
+ replayReports: () => replayReports,
39
+ resourceDirectives: () => resourceDirectives,
40
+ ruleSetSchema: () => ruleSetSchema,
41
+ rulesSchema: () => rulesSchema,
42
+ serializeImportedPolicy: () => serializeImportedPolicy,
43
+ sourceEntrySchema: () => sourceEntrySchema,
44
+ sourceExpressions: () => sourceExpressions,
45
+ unsafeEval: () => unsafeEval,
46
+ unsafeHashes: () => unsafeHashes,
47
+ unsafeInline: () => unsafeInline
48
+ });
49
+ module.exports = __toCommonJS(src_exports);
50
+
51
+ // src/schemas.ts
52
+ var import_zod = require("zod");
53
+ var resourceDirectives = {
54
+ scripts: "script-src",
55
+ connect: "connect-src",
56
+ images: "img-src",
57
+ styles: "style-src",
58
+ fonts: "font-src",
59
+ frames: "frame-src",
60
+ forms: "form-action",
61
+ media: "media-src",
62
+ workers: "worker-src",
63
+ manifest: "manifest-src"
64
+ };
65
+ var baseDirectives = {
66
+ default: "default-src",
67
+ objects: "object-src",
68
+ baseUri: "base-uri",
69
+ frameAncestors: "frame-ancestors"
70
+ };
71
+ var risky = /* @__PURE__ */ new Set(["'unsafe-inline'", "'unsafe-eval'", "'unsafe-hashes'"]);
72
+ var keywords = /* @__PURE__ */ new Set([
73
+ "'self'",
74
+ "'none'",
75
+ "'strict-dynamic'",
76
+ "'report-sample'",
77
+ "'wasm-unsafe-eval'",
78
+ ...risky
79
+ ]);
80
+ var NONCE_PLACEHOLDER = "'nonce-{nonce}'";
81
+ function isSource(value) {
82
+ if (!value || /[\x00-\x20\x7f;,]/.test(value) || /^[a-z][a-z0-9+.-]*\/\//i.test(value))
83
+ return false;
84
+ if (keywords.has(value.toLowerCase()) || value === NONCE_PLACEHOLDER || value === "*" || /^[a-z][a-z0-9+.-]*:\/\/\*(?::(?:\d+|\*))?(?:\/[^\s;,#?]*)?$/i.test(value))
85
+ return true;
86
+ if (/^'(nonce-[A-Za-z0-9+/_-]+={0,2}|sha(256|384|512)-[A-Za-z0-9+/_-]+={0,2})'$/i.test(
87
+ value
88
+ ))
89
+ return true;
90
+ if (/^[a-zA-Z][a-zA-Z0-9+.-]*:$/.test(value)) return true;
91
+ return /^(?:[a-z][a-z0-9+.-]*:\/\/)?(?:\*\.)?(?:[a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+(?::(?:\d+|\*))?(?:\/[^\s;,#?]*)?$/i.test(
92
+ value
93
+ );
94
+ }
95
+ var sourceStringSchema = import_zod.z.string().refine(isSource, "Invalid CSP source expression");
96
+ var sourceEntrySchema = import_zod.z.union([
97
+ sourceStringSchema.refine(
98
+ (s) => !risky.has(s.toLowerCase()),
99
+ "Risky keyword requires a reason"
100
+ ),
101
+ import_zod.z.object({ source: sourceStringSchema, reason: import_zod.z.string().trim().min(1) }).strict()
102
+ ]);
103
+ var sourceList = import_zod.z.array(sourceEntrySchema).min(1);
104
+ var sourceListDirectives = /* @__PURE__ */ new Set([
105
+ ...Object.values(resourceDirectives),
106
+ ...Object.values(baseDirectives),
107
+ "script-src-elem",
108
+ "script-src-attr",
109
+ "style-src-elem",
110
+ "style-src-attr",
111
+ "child-src"
112
+ ]);
113
+ var rawDirectives = import_zod.z.record(
114
+ import_zod.z.string().regex(/^[a-z][a-z0-9-]*$/).refine(
115
+ (name) => sourceListDirectives.has(name),
116
+ "Unsupported raw directive; only known source-list directives are supported"
117
+ ),
118
+ sourceList
119
+ );
120
+ var reserved = /* @__PURE__ */ new Set([
121
+ "report-uri",
122
+ "report-to",
123
+ "upgrade-insecure-requests"
124
+ ]);
125
+ var baseOnly = /* @__PURE__ */ new Set([...Object.values(baseDirectives), ...reserved]);
126
+ var ruleShape = Object.fromEntries(
127
+ Object.keys(resourceDirectives).map((key) => [key, sourceList.optional()])
128
+ );
129
+ var rulesSchema = import_zod.z.object({ ...ruleShape, directives: rawDirectives.optional() }).strict().refine(
130
+ (rules) => Object.entries(rules).some(
131
+ ([key, value]) => key === "directives" ? Object.keys(value ?? {}).length > 0 : value !== void 0
132
+ ),
133
+ "At least one resource directive is required"
134
+ ).superRefine((rules, ctx) => {
135
+ for (const directive of Object.keys(rules.directives ?? {})) {
136
+ if (baseOnly.has(directive))
137
+ ctx.addIssue({
138
+ code: "custom",
139
+ path: ["directives", directive],
140
+ message: "Base-only or reserved directive"
141
+ });
142
+ }
143
+ });
144
+ var baseSchema = import_zod.z.object({
145
+ ...ruleShape,
146
+ default: sourceList.optional(),
147
+ objects: sourceList.optional(),
148
+ baseUri: sourceList.optional(),
149
+ frameAncestors: sourceList.optional(),
150
+ upgradeInsecureRequests: import_zod.z.boolean().optional(),
151
+ directives: rawDirectives.optional()
152
+ }).strict().superRefine((base, ctx) => {
153
+ for (const directive of Object.keys(base.directives ?? {})) {
154
+ if (reserved.has(directive))
155
+ ctx.addIssue({
156
+ code: "custom",
157
+ path: ["directives", directive],
158
+ message: "Use the dedicated configuration field for this directive"
159
+ });
160
+ }
161
+ });
162
+ var ruleSetSchema = import_zod.z.object({
163
+ name: import_zod.z.string().trim().min(1),
164
+ purpose: import_zod.z.string().trim().min(1),
165
+ owner: import_zod.z.string().trim().min(1).optional(),
166
+ docs: import_zod.z.url().optional(),
167
+ tags: import_zod.z.array(import_zod.z.string().trim().min(1)).optional(),
168
+ reviewBy: import_zod.z.iso.date().optional(),
169
+ enabled: import_zod.z.boolean().default(true),
170
+ rules: rulesSchema
171
+ }).strict();
172
+ var reportingSchema = import_zod.z.object({
173
+ uri: import_zod.z.url().refine(
174
+ (value) => !/[\x00-\x20\x7f;,]/.test(value),
175
+ "Invalid reporting value"
176
+ ).optional(),
177
+ to: import_zod.z.string().regex(/^[A-Za-z0-9_-]+$/).optional()
178
+ }).strict();
179
+ var policyConfigSchema = import_zod.z.object({
180
+ base: baseSchema.default({}),
181
+ ruleSets: import_zod.z.array(ruleSetSchema).default([]),
182
+ reporting: reportingSchema.optional(),
183
+ mode: import_zod.z.enum(["enforce", "report-only"]).default("enforce")
184
+ }).strict().superRefine((config, ctx) => {
185
+ const names = /* @__PURE__ */ new Set();
186
+ config.ruleSets.forEach((rule, i) => {
187
+ if (names.has(rule.name))
188
+ ctx.addIssue({
189
+ code: "custom",
190
+ path: ["ruleSets", i, "name"],
191
+ message: `Duplicate rule set name: ${rule.name}`
192
+ });
193
+ names.add(rule.name);
194
+ });
195
+ });
196
+
197
+ // src/keywords.ts
198
+ var sourceExpressions = {
199
+ self: "'self'",
200
+ none: "'none'",
201
+ nonce: NONCE_PLACEHOLDER,
202
+ strictDynamic: "'strict-dynamic'",
203
+ reportSample: "'report-sample'",
204
+ wasmUnsafeEval: "'wasm-unsafe-eval'"
205
+ };
206
+ function generateNonce() {
207
+ const bytes = new Uint8Array(16);
208
+ globalThis.crypto.getRandomValues(bytes);
209
+ return btoa(String.fromCharCode(...bytes));
210
+ }
211
+ var unsafeInline = ({ reason }) => ({
212
+ source: "'unsafe-inline'",
213
+ reason
214
+ });
215
+ var unsafeEval = ({ reason }) => ({
216
+ source: "'unsafe-eval'",
217
+ reason
218
+ });
219
+ var unsafeHashes = ({ reason }) => ({
220
+ source: "'unsafe-hashes'",
221
+ reason
222
+ });
223
+ var cspHash = (algorithm, digest) => `'${algorithm}-${digest}'`;
224
+
225
+ // src/matching/index.ts
226
+ var friendly = {
227
+ scripts: "script-src",
228
+ connect: "connect-src",
229
+ images: "img-src",
230
+ styles: "style-src",
231
+ fonts: "font-src",
232
+ frames: "frame-src",
233
+ forms: "form-action",
234
+ media: "media-src",
235
+ workers: "worker-src",
236
+ manifest: "manifest-src",
237
+ default: "default-src",
238
+ objects: "object-src",
239
+ baseUri: "base-uri",
240
+ frameAncestors: "frame-ancestors"
241
+ };
242
+ var fallbacks = {
243
+ "script-src-elem": ["script-src-elem", "script-src", "default-src"],
244
+ "script-src-attr": ["script-src-attr", "script-src", "default-src"],
245
+ "style-src-elem": ["style-src-elem", "style-src", "default-src"],
246
+ "style-src-attr": ["style-src-attr", "style-src", "default-src"],
247
+ "worker-src": ["worker-src", "child-src", "script-src", "default-src"],
248
+ "frame-src": ["frame-src", "child-src", "default-src"]
249
+ };
250
+ for (const name of [
251
+ "script-src",
252
+ "style-src",
253
+ "child-src",
254
+ "connect-src",
255
+ "font-src",
256
+ "img-src",
257
+ "manifest-src",
258
+ "media-src",
259
+ "object-src"
260
+ ]) {
261
+ fallbacks[name] = [name, "default-src"];
262
+ }
263
+ for (const name of [
264
+ "default-src",
265
+ "form-action",
266
+ "base-uri",
267
+ "frame-ancestors"
268
+ ])
269
+ fallbacks[name] = [name];
270
+ function decision(status, effectiveDirective, reason, matchedSource) {
271
+ return {
272
+ status,
273
+ allowed: status === "indeterminate" ? null : status === "allowed",
274
+ ...effectiveDirective && { effectiveDirective },
275
+ ...reason && { reason },
276
+ ...matchedSource && { matchedSource }
277
+ };
278
+ }
279
+ function schemeMatches(source, target) {
280
+ source = source.toLowerCase();
281
+ target = target.toLowerCase();
282
+ return source === target || source === "http" && target === "https" || source === "ws" && ["wss", "http", "https"].includes(target) || source === "wss" && target === "https";
283
+ }
284
+ function scheme(url) {
285
+ return url.protocol.slice(0, -1).toLowerCase();
286
+ }
287
+ function defaultPort(s) {
288
+ return { http: "80", https: "443", ws: "80", wss: "443", ftp: "21" }[s];
289
+ }
290
+ function selfMatches(url, origin) {
291
+ if (scheme(url) === "blob") return false;
292
+ if (origin.origin !== "null" && origin.origin === url.origin) return true;
293
+ const os = scheme(origin), us = scheme(url);
294
+ const portsMatch = origin.port === url.port || !origin.port && !url.port;
295
+ return origin.hostname !== "" && origin.hostname === url.hostname && portsMatch && (us === "https" || us === "wss" || os === "http" && (us === "http" || us === "ws"));
296
+ }
297
+ function segmentBytes(segment) {
298
+ const bytes = [];
299
+ for (let i = 0; i < segment.length; ) {
300
+ const encoded = segment.slice(i).match(/^%([0-9a-f]{2})/i);
301
+ if (encoded) {
302
+ bytes.push(parseInt(encoded[1], 16));
303
+ i += 3;
304
+ continue;
305
+ }
306
+ const point = segment.codePointAt(i);
307
+ const character = String.fromCodePoint(point);
308
+ bytes.push(...new TextEncoder().encode(character));
309
+ i += character.length;
310
+ }
311
+ return bytes.join(",");
312
+ }
313
+ function pathMatches(pattern, target) {
314
+ if (!pattern || pattern === "/" && !target) return true;
315
+ const a = pattern.split("/"), b = target.split("/");
316
+ if (a.length > b.length || !pattern.endsWith("/") && a.length !== b.length)
317
+ return false;
318
+ if (pattern.endsWith("/")) a.pop();
319
+ return a.every((part, i) => segmentBytes(part) === segmentBytes(b[i]));
320
+ }
321
+ function sourceMatches(source, url, origin, redirectCount) {
322
+ const lower = source.toLowerCase(), targetScheme = scheme(url);
323
+ if (lower === "'self'")
324
+ return origin ? selfMatches(url, origin) ? "yes" : "no" : "unknown";
325
+ if (source === "*")
326
+ return ["http", "https"].includes(targetScheme) ? "yes" : origin ? scheme(origin) === targetScheme ? "yes" : "no" : "unknown";
327
+ const schemeOnly = source.match(/^([a-z][a-z0-9+.-]*):$/i);
328
+ if (schemeOnly)
329
+ return schemeMatches(schemeOnly[1], targetScheme) ? "yes" : "no";
330
+ const host = source.match(
331
+ /^(?:([a-z][a-z0-9+.-]*):\/\/)?(\*|(?:\*\.)?[a-z0-9.-]+)(?::(\*|[0-9]+))?(\/[^?#]*)?$/i
332
+ );
333
+ if (!host) return "no";
334
+ const [, explicitScheme, patternHost, port, path] = host;
335
+ if (!url.hostname || /^\[/.test(url.hostname) || /^\d+(?:\.\d+){3}$/.test(url.hostname))
336
+ return "no";
337
+ if (!explicitScheme && !origin) return "unknown";
338
+ if (!schemeMatches(explicitScheme ?? scheme(origin), targetScheme))
339
+ return "no";
340
+ const domain = url.hostname.toLowerCase(), pattern = patternHost.toLowerCase();
341
+ if (pattern !== "*" && !(pattern.startsWith("*.") ? domain.endsWith(pattern.slice(1)) : domain === pattern))
342
+ return "no";
343
+ if (port !== "*") {
344
+ const targetPort = url.port || void 0;
345
+ if (port === void 0 ? targetPort !== void 0 : Number(port) !== Number(targetPort ?? defaultPort(targetScheme)))
346
+ return "no";
347
+ }
348
+ if (path && !pathMatches(path, url.pathname)) {
349
+ if (redirectCount === void 0) return "unknown";
350
+ if (redirectCount === 0) return "no";
351
+ }
352
+ return "yes";
353
+ }
354
+ function matchPolicy(directives, directive, input, options = {}) {
355
+ const requested = friendly[directive] ?? directive.toLowerCase();
356
+ const name = requested === "script-src" ? "script-src-elem" : requested === "style-src" ? "style-src-elem" : requested;
357
+ const chain = fallbacks[name];
358
+ if (!chain)
359
+ return decision(
360
+ "indeterminate",
361
+ void 0,
362
+ "Unsupported directive or inline check"
363
+ );
364
+ const effective = chain.find(
365
+ (key) => Object.prototype.hasOwnProperty.call(directives, key)
366
+ );
367
+ if (!effective)
368
+ return decision("allowed", void 0, "No applicable directive");
369
+ if (name.endsWith("-attr"))
370
+ return decision(
371
+ "indeterminate",
372
+ effective,
373
+ "Inline checks require element content and context"
374
+ );
375
+ if (name === "frame-ancestors")
376
+ return decision(
377
+ "indeterminate",
378
+ effective,
379
+ "Frame enforcement depends on the complete ancestor chain"
380
+ );
381
+ if (options.redirectCount !== void 0 && (!Number.isInteger(options.redirectCount) || options.redirectCount < 0))
382
+ throw new TypeError("redirectCount must be a non-negative integer");
383
+ let url, origin;
384
+ try {
385
+ url = new URL(input);
386
+ if (options.origin !== void 0) {
387
+ origin = new URL(options.origin);
388
+ if (origin.origin === "null") throw new Error("opaque");
389
+ }
390
+ } catch {
391
+ throw new TypeError("Expected an absolute URL and a non-opaque origin");
392
+ }
393
+ const sources = directives[effective];
394
+ const script = name === "script-src" || name === "script-src-elem";
395
+ const style = name === "style-src" || name === "style-src-elem";
396
+ const hasNoncePlaceholder = sources.includes("'nonce-{nonce}'");
397
+ const nonceSources = sources.filter(
398
+ (s) => /^'nonce-[a-z0-9+/_=-]+'$/i.test(s)
399
+ );
400
+ const hashes = sources.filter(
401
+ (s) => /^'sha(256|384|512)-[a-z0-9+/_=-]+'$/i.test(s)
402
+ );
403
+ if ((script || style) && options.nonce && (nonceSources.some((s) => s.slice(7, -1) === options.nonce) || hasNoncePlaceholder && options.policyNonce !== void 0 && options.nonce === options.policyNonce))
404
+ return decision("allowed", effective, "Matching request nonce");
405
+ if (script && options.integrity?.length && options.integrity.every(
406
+ (token) => hashes.some((hash) => {
407
+ const [hashAlg, hashDigest] = hash.slice(1, -1).split("-", 2);
408
+ const [tokenAlg, tokenDigest] = token.split("-", 2);
409
+ return hashAlg?.toLowerCase() === tokenAlg?.toLowerCase() && hashDigest !== void 0 && hashDigest === tokenDigest;
410
+ })
411
+ ))
412
+ return decision("allowed", effective, "Matching integrity metadata");
413
+ const missingNonce = (script || style) && (nonceSources.length > 0 && options.nonce === void 0 || hasNoncePlaceholder && (options.nonce === void 0 || options.nonce !== "" && options.policyNonce === void 0));
414
+ const missingIntegrity = script && hashes.length > 0 && options.integrity === void 0;
415
+ if (script && sources.some((s) => s.toLowerCase() === "'strict-dynamic'")) {
416
+ if (options.parserInserted === false)
417
+ return decision(
418
+ "allowed",
419
+ effective,
420
+ "Non-parser-inserted script under strict-dynamic"
421
+ );
422
+ if (options.parserInserted === void 0 || missingNonce || missingIntegrity)
423
+ return decision(
424
+ "indeterminate",
425
+ effective,
426
+ "Script nonce, integrity or parser metadata is missing"
427
+ );
428
+ return decision(
429
+ "blocked",
430
+ effective,
431
+ "Parser-inserted script has no matching nonce or integrity metadata"
432
+ );
433
+ }
434
+ let unknown = false;
435
+ for (const source of sources) {
436
+ const match = sourceMatches(source, url, origin, options.redirectCount);
437
+ if (match === "yes")
438
+ return decision("allowed", effective, void 0, source);
439
+ if (match === "unknown") unknown = true;
440
+ }
441
+ if (unknown || missingNonce || missingIntegrity)
442
+ return decision(
443
+ "indeterminate",
444
+ effective,
445
+ "Origin, redirect count, nonce or integrity metadata is missing"
446
+ );
447
+ return decision("blocked", effective, "No source matched");
448
+ }
449
+
450
+ // src/reports/index.ts
451
+ function record(value) {
452
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
453
+ }
454
+ function field(obj, ...keys) {
455
+ for (const key of keys)
456
+ if (typeof obj[key] === "string" && obj[key]) return obj[key];
457
+ return void 0;
458
+ }
459
+ function parseViolationReports(input) {
460
+ if (typeof input === "string") {
461
+ try {
462
+ input = JSON.parse(input);
463
+ } catch {
464
+ throw new Error("Invalid report JSON");
465
+ }
466
+ }
467
+ const items = Array.isArray(input) ? input : [input];
468
+ return items.map((item, index) => {
469
+ const envelope = record(item);
470
+ if (!envelope) throw new Error(`Unsupported report at index ${index}`);
471
+ const body = (envelope.type === "csp" ? record(envelope.csp) : void 0) ?? record(envelope["csp-report"]) ?? (envelope.type === "csp-violation" ? record(envelope.body) : void 0) ?? envelope;
472
+ const directive = field(
473
+ body,
474
+ "effective-directive",
475
+ "effectiveDirective",
476
+ "effective_directive",
477
+ "violated-directive",
478
+ "violatedDirective",
479
+ "violated_directive"
480
+ );
481
+ const blockedURL = field(
482
+ body,
483
+ "blocked-uri",
484
+ "blockedURL",
485
+ "blockedUri",
486
+ "blocked_uri"
487
+ );
488
+ const documentURL = field(
489
+ body,
490
+ "document-uri",
491
+ "documentURL",
492
+ "documentUri",
493
+ "document_uri"
494
+ );
495
+ if (!directive || !blockedURL)
496
+ throw new Error(`Unsupported or incomplete report at index ${index}`);
497
+ return {
498
+ directive: directive.split(" ")[0],
499
+ blockedURL,
500
+ ...documentURL ? { documentURL } : {}
501
+ };
502
+ });
503
+ }
504
+ function replayReports(directives, reports) {
505
+ return reports.map((report) => {
506
+ let origin;
507
+ try {
508
+ if (report.documentURL) {
509
+ const parsedOrigin = new URL(report.documentURL).origin;
510
+ if (parsedOrigin !== "null") origin = parsedOrigin;
511
+ }
512
+ } catch {
513
+ }
514
+ let blocked;
515
+ try {
516
+ blocked = new URL(report.blockedURL);
517
+ } catch {
518
+ return {
519
+ report,
520
+ result: {
521
+ status: "indeterminate",
522
+ allowed: null,
523
+ reason: "Report does not contain a replayable URL"
524
+ }
525
+ };
526
+ }
527
+ if (!["http:", "https:", "ws:", "wss:"].includes(blocked.protocol)) {
528
+ return {
529
+ report,
530
+ result: {
531
+ status: "indeterminate",
532
+ allowed: null,
533
+ reason: "Report does not contain a replayable network URL"
534
+ }
535
+ };
536
+ }
537
+ const result = matchPolicy(
538
+ directives,
539
+ report.directive,
540
+ report.blockedURL,
541
+ origin ? { origin } : {}
542
+ );
543
+ if (result.status === "allowed" && result.matchedSource && result.matchedSource.replace(/^[a-z]+:\/\//i, "").includes("/")) {
544
+ return {
545
+ report,
546
+ result: {
547
+ status: "indeterminate",
548
+ allowed: null,
549
+ reason: "Report may omit the request path"
550
+ }
551
+ };
552
+ }
553
+ return { report, result };
554
+ });
555
+ }
556
+
557
+ // src/core.ts
558
+ var import_zod2 = require("zod");
559
+ function freeze(value) {
560
+ if (value && typeof value === "object" && !Object.isFrozen(value)) {
561
+ Object.values(value).forEach(freeze);
562
+ Object.freeze(value);
563
+ }
564
+ return value;
565
+ }
566
+ function defineRuleSet(input) {
567
+ const parsed = ruleSetSchema.safeParse(input);
568
+ if (!parsed.success) {
569
+ const name = typeof input?.name === "string" ? input.name : "<unnamed>";
570
+ const detail = parsed.error.issues.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`).join("; ");
571
+ throw new import_zod2.z.ZodError(
572
+ parsed.error.issues.map((issue) => ({
573
+ ...issue,
574
+ message: `RuleSet "${name}" - ${detail}`
575
+ }))
576
+ );
577
+ }
578
+ return freeze(parsed.data);
579
+ }
580
+ function entryValue(entry) {
581
+ return typeof entry === "string" ? entry : entry.source;
582
+ }
583
+ function entryReason(entry) {
584
+ return typeof entry === "string" ? void 0 : entry.reason;
585
+ }
586
+ var Policy = class _Policy {
587
+ config;
588
+ headerName;
589
+ constructor(input) {
590
+ const result = policyConfigSchema.safeParse(input);
591
+ if (!result.success) {
592
+ throw new import_zod2.z.ZodError(
593
+ result.error.issues.map((issue) => {
594
+ const index = issue.path[0] === "ruleSets" && typeof issue.path[1] === "number" ? issue.path[1] : void 0;
595
+ const name = index === void 0 ? void 0 : input.ruleSets?.[index]?.name;
596
+ return name ? {
597
+ ...issue,
598
+ message: `RuleSet "${name}" - ${issue.path.slice(2).join(".")}: ${issue.message}`
599
+ } : issue;
600
+ })
601
+ );
602
+ }
603
+ const config = result.data;
604
+ this.config = freeze(config);
605
+ this.headerName = config.mode === "enforce" ? "Content-Security-Policy" : "Content-Security-Policy-Report-Only";
606
+ Object.freeze(this);
607
+ }
608
+ /** Sources and their contributing rule sets. Duplicate values retain all contributors. */
609
+ explain() {
610
+ const rows = [];
611
+ const add = (directive, entries, ruleSet) => {
612
+ for (const entry of entries) {
613
+ const reason = entryReason(entry);
614
+ rows.push({
615
+ directive,
616
+ source: entryValue(entry),
617
+ ruleSet,
618
+ ...reason === void 0 ? {} : { reason }
619
+ });
620
+ }
621
+ };
622
+ const collect = (rules, name) => {
623
+ for (const [key, value] of Object.entries(rules)) {
624
+ if (key === "directives" && value) {
625
+ for (const [directive, entries] of Object.entries(
626
+ value
627
+ ))
628
+ add(directive, entries, name);
629
+ } else if (Array.isArray(value)) {
630
+ const directive = resourceDirectives[key] ?? baseDirectives[key];
631
+ if (directive) add(directive, value, name);
632
+ }
633
+ }
634
+ };
635
+ collect(this.config.base, "base");
636
+ for (const set of this.config.ruleSets)
637
+ if (set.enabled) collect(set.rules, set.name);
638
+ return rows.sort(
639
+ (a, b) => a.directive.localeCompare(b.directive, "en") || a.source.localeCompare(b.source, "en") || a.ruleSet.localeCompare(b.ruleSet, "en") || (a.reason ?? "").localeCompare(b.reason ?? "", "en")
640
+ );
641
+ }
642
+ /** Merged sources, deduplicated without changing path syntax. */
643
+ toObject() {
644
+ const map = /* @__PURE__ */ Object.create(null);
645
+ for (const row of this.explain())
646
+ (map[row.directive] ??= /* @__PURE__ */ new Set()).add(row.source);
647
+ if (this.config.base.upgradeInsecureRequests)
648
+ map["upgrade-insecure-requests"] = /* @__PURE__ */ new Set();
649
+ if (this.config.reporting?.uri)
650
+ map["report-uri"] = /* @__PURE__ */ new Set([this.config.reporting.uri]);
651
+ if (this.config.reporting?.to)
652
+ map["report-to"] = /* @__PURE__ */ new Set([this.config.reporting.to]);
653
+ return Object.fromEntries(
654
+ Object.entries(map).sort(([a], [b]) => a.localeCompare(b, "en")).map(([key, values]) => [key, Array.from(values).sort()])
655
+ );
656
+ }
657
+ /** Evaluate a URL with explicit uncertainty when browser context is missing. */
658
+ allows(directive, url, options = {}) {
659
+ const result = matchPolicy(this.toObject(), directive, url, options);
660
+ const contributors = result.matchedSource && result.effectiveDirective ? this.explain().filter(
661
+ (row) => row.directive === result.effectiveDirective && row.source === result.matchedSource
662
+ ) : [];
663
+ return contributors.length ? { ...result, contributors } : result;
664
+ }
665
+ /** Replay supported violation report JSON without inventing missing request context. */
666
+ check(reports) {
667
+ return replayReports(this.toObject(), parseViolationReports(reports));
668
+ }
669
+ /** Render a header value. Pretty output is for display only and is not a valid HTTP header value. */
670
+ toHeader(options = {}) {
671
+ return this.render(this.toObject(), options);
672
+ }
673
+ render(directives, options) {
674
+ const hasNonce = Object.values(directives).some(
675
+ (sources) => sources.includes(NONCE_PLACEHOLDER)
676
+ );
677
+ if (hasNonce && (!options.nonce || !/^[A-Za-z0-9+/_-]+={0,2}$/.test(options.nonce)))
678
+ throw new Error("A valid base64 nonce is required");
679
+ return Object.entries(directives).map(([directive, values]) => {
680
+ const rendered = values.map(
681
+ (value) => value === NONCE_PLACEHOLDER ? `'nonce-${options.nonce}'` : value
682
+ );
683
+ return directive + (rendered.length ? ` ${rendered.join(" ")}` : "");
684
+ }).join(options.pretty ? ";\n" : "; ");
685
+ }
686
+ /** Render a meta policy; report-only is not supported in meta delivery. */
687
+ toMetaContent(options = {}) {
688
+ if (this.config.mode === "report-only")
689
+ throw new Error(
690
+ "Report-only policies cannot be delivered in a meta element"
691
+ );
692
+ const directives = this.toObject();
693
+ delete directives["frame-ancestors"];
694
+ delete directives["report-uri"];
695
+ delete directives["report-to"];
696
+ delete directives.sandbox;
697
+ return this.render(directives, options);
698
+ }
699
+ withRuleSet(ruleSet) {
700
+ return new _Policy({
701
+ ...this.config,
702
+ ruleSets: [...this.config.ruleSets, ruleSet]
703
+ });
704
+ }
705
+ without(name) {
706
+ return new _Policy({
707
+ ...this.config,
708
+ ruleSets: this.config.ruleSets.filter((set) => set.name !== name)
709
+ });
710
+ }
711
+ };
712
+ function definePolicy(input) {
713
+ return new Policy(input);
714
+ }
715
+
716
+ // src/audit/index.ts
717
+ var sourceFindings = (policy, directive, source, ruleId, severity, message, fix) => {
718
+ const owners = policy.explain().filter((row) => row.directive === directive && row.source === source);
719
+ return owners.length ? owners.map(({ ruleSet }) => ({
720
+ ruleId,
721
+ severity,
722
+ message,
723
+ fix,
724
+ directive,
725
+ source,
726
+ ruleSet
727
+ })) : [{ ruleId, severity, message, fix, directive, source }];
728
+ };
729
+ function audit(policy, options = {}) {
730
+ const object = policy.toObject();
731
+ const findings = [];
732
+ const add = (id, severity, message, fix, directive) => findings.push({
733
+ ruleId: id,
734
+ severity,
735
+ message,
736
+ fix,
737
+ ...directive ? { directive } : {}
738
+ });
739
+ if (!object["script-src"] && !object["default-src"])
740
+ add(
741
+ "missing-script-src",
742
+ "high",
743
+ "Some script execution is unrestricted.",
744
+ "Restrict script-src or default-src.",
745
+ "script-src"
746
+ );
747
+ for (const directive of [
748
+ "script-src",
749
+ "script-src-elem",
750
+ "script-src-attr",
751
+ "default-src"
752
+ ]) {
753
+ const sources = object[directive];
754
+ if (!sources) continue;
755
+ const isFallback = directive === "default-src" && object["script-src"] !== void 0;
756
+ if (isFallback) continue;
757
+ const hasNonceOrHash = sources.some(
758
+ (s) => /^'(nonce-|sha(?:256|384|512)-)/i.test(s)
759
+ );
760
+ for (const source of sources.filter(
761
+ (s) => s.toLowerCase() === "'unsafe-inline'" && !hasNonceOrHash
762
+ ))
763
+ findings.push(
764
+ ...sourceFindings(
765
+ policy,
766
+ directive,
767
+ source,
768
+ "script-unsafe-inline",
769
+ "high",
770
+ "Inline scripts are permitted.",
771
+ "Use nonces or hashes and remove unsafe-inline."
772
+ )
773
+ );
774
+ for (const source of sources.filter(
775
+ (s) => s.toLowerCase() === "'unsafe-eval'"
776
+ ))
777
+ findings.push(
778
+ ...sourceFindings(
779
+ policy,
780
+ directive,
781
+ source,
782
+ "script-unsafe-eval",
783
+ "high",
784
+ "Dynamic JavaScript evaluation is permitted.",
785
+ "Remove unsafe-eval and replace dynamic evaluation."
786
+ )
787
+ );
788
+ if (directive !== "script-src-attr" && sources.some((source) => source.toLowerCase() === "'strict-dynamic'")) {
789
+ for (const source of sources) {
790
+ if (source.toLowerCase() === "'self'" || source === "*" || /^[a-z][a-z0-9+.-]*:$/i.test(source) || /^(?:[a-z][a-z0-9+.-]*:\/\/)?(?:\*|[a-z0-9*.-]+)(?::(?:\*|\d+))?(?:\/[^\s]*)?$/i.test(
791
+ source
792
+ )) {
793
+ findings.push(
794
+ ...sourceFindings(
795
+ policy,
796
+ directive,
797
+ source,
798
+ "ignored-by-strict-dynamic",
799
+ "info",
800
+ "Modern browsers ignore this source for scripts under strict-dynamic.",
801
+ "Remove it if legacy browser fallback is not needed."
802
+ )
803
+ );
804
+ }
805
+ }
806
+ }
807
+ for (const source of sources)
808
+ if (["*", "https:", "http:", "data:"].includes(source.toLowerCase()) || /^(?:https?:\/\/)?\*(?::(?:\*|\d+))?(?:\/[^\s]*)?$/i.test(source))
809
+ findings.push(
810
+ ...sourceFindings(
811
+ policy,
812
+ directive,
813
+ source,
814
+ "script-wildcard",
815
+ "high",
816
+ "A broad script source may permit attacker-controlled scripts.",
817
+ "Restrict script sources and prefer nonces or hashes."
818
+ )
819
+ );
820
+ }
821
+ const objects = object["object-src"] ?? object["default-src"];
822
+ if (!objects || objects.length !== 1 || objects[0]?.toLowerCase() !== "'none'")
823
+ add(
824
+ "missing-object-src",
825
+ "high",
826
+ "Object embedding is not explicitly blocked.",
827
+ "Set object-src to 'none'.",
828
+ "object-src"
829
+ );
830
+ const broad = (sources) => !sources || sources.some(
831
+ (source) => source === "*" || /^[a-z][a-z0-9+.-]*:$/i.test(source) || /^(?:https?:\/\/)?\*(?::(?:\*|\d+))?(?:\/[^\s]*)?$/i.test(source)
832
+ );
833
+ if (broad(object["base-uri"]))
834
+ add(
835
+ "missing-base-uri",
836
+ "medium",
837
+ "The document base URL is not sufficiently restricted.",
838
+ "Set base-uri to 'none' or 'self'.",
839
+ "base-uri"
840
+ );
841
+ if (broad(object["frame-ancestors"]))
842
+ add(
843
+ "missing-frame-ancestors",
844
+ "medium",
845
+ "Embedding by other sites is not sufficiently restricted.",
846
+ "Restrict frame-ancestors to trusted origins.",
847
+ "frame-ancestors"
848
+ );
849
+ const knownBypassDomains = [
850
+ "google.com",
851
+ "googleapis.com",
852
+ "googleusercontent.com",
853
+ "gstatic.com"
854
+ ];
855
+ for (const row of policy.explain()) {
856
+ if (["script-src", "script-src-elem", "default-src"].includes(row.directive)) {
857
+ const host = row.source.match(/^(?:https?:\/\/)?(?:\*\.)?([a-z0-9.-]+)/i)?.[1]?.toLowerCase();
858
+ if (host && knownBypassDomains.some(
859
+ (domain) => host === domain || host.endsWith(`.${domain}`)
860
+ )) {
861
+ findings.push({
862
+ ruleId: "bypass-host",
863
+ severity: "medium",
864
+ directive: row.directive,
865
+ source: row.source,
866
+ ruleSet: row.ruleSet,
867
+ message: "This script host may expose JSONP or script gadgets that weaken host allowlists.",
868
+ fix: "Review the host for JSONP endpoints and script gadgets; prefer nonce or hash authorization."
869
+ });
870
+ }
871
+ }
872
+ if (/^http:/i.test(row.source))
873
+ findings.push({
874
+ ruleId: "insecure-scheme",
875
+ severity: "medium",
876
+ directive: row.directive,
877
+ source: row.source,
878
+ ruleSet: row.ruleSet,
879
+ message: "An insecure HTTP source is permitted.",
880
+ fix: "Use HTTPS where possible."
881
+ });
882
+ if (/^(?:https?:\/\/)?\*\.[a-z0-9-]+(?::(?:\*|\d+))?(?:\/|$)/i.test(
883
+ row.source
884
+ ) || /^https?:\/\/\*\.(?:amazonaws\.com|azurewebsites\.net)(?:[/:]|$)/i.test(
885
+ row.source
886
+ ))
887
+ findings.push({
888
+ ruleId: "broad-wildcard",
889
+ severity: "medium",
890
+ directive: row.directive,
891
+ source: row.source,
892
+ ruleSet: row.ruleSet,
893
+ message: "A wildcard covers an unusually broad or shared domain.",
894
+ fix: "List the specific trusted hosts."
895
+ });
896
+ }
897
+ if (!object["report-uri"] && !object["report-to"])
898
+ add(
899
+ "no-reporting",
900
+ "low",
901
+ "No reporting destination is configured.",
902
+ "Configure reporting and its endpoint."
903
+ );
904
+ const today = (options.now ?? /* @__PURE__ */ new Date()).toISOString().slice(0, 10);
905
+ for (const set of policy.config.ruleSets.filter((s) => s.enabled)) {
906
+ if (!set.owner)
907
+ findings.push({
908
+ ruleId: "ruleset-metadata",
909
+ severity: "low",
910
+ ruleSet: set.name,
911
+ message: "Rule set has no owner.",
912
+ fix: "Assign an owner."
913
+ });
914
+ if (set.reviewBy && set.reviewBy < today)
915
+ findings.push({
916
+ ruleId: "ruleset-metadata",
917
+ severity: "low",
918
+ ruleSet: set.name,
919
+ message: "Rule set review date has passed.",
920
+ fix: "Review permissions regularly."
921
+ });
922
+ }
923
+ for (const rule of options.rules ?? []) findings.push(...rule.check(policy));
924
+ for (const suppression of options.suppressions ?? [])
925
+ if (!suppression.reason.trim() || !suppression.ruleId || !suppression.ruleSet)
926
+ throw new Error(
927
+ "Audit suppressions require a rule id, rule set and reason"
928
+ );
929
+ return findings.filter(
930
+ (finding) => !(options.suppressions ?? []).some(
931
+ (s) => s.ruleId === finding.ruleId && s.ruleSet === finding.ruleSet
932
+ )
933
+ );
934
+ }
935
+
936
+ // src/diff.ts
937
+ function diffPolicies(before, after) {
938
+ const key = (row) => JSON.stringify([
939
+ row.directive,
940
+ row.source,
941
+ row.ruleSet,
942
+ row.reason ?? null
943
+ ]);
944
+ const oldRows = new Map(before.explain().map((row) => [key(row), row]));
945
+ const newRows = new Map(after.explain().map((row) => [key(row), row]));
946
+ const changes = [];
947
+ for (const [id, row] of oldRows)
948
+ if (!newRows.has(id))
949
+ changes.push({
950
+ directive: row.directive,
951
+ source: row.source,
952
+ ruleSet: row.ruleSet,
953
+ change: "removed",
954
+ ...row.reason ? { detail: row.reason } : {}
955
+ });
956
+ for (const [id, row] of newRows)
957
+ if (!oldRows.has(id))
958
+ changes.push({
959
+ directive: row.directive,
960
+ source: row.source,
961
+ ruleSet: row.ruleSet,
962
+ change: "added",
963
+ ...row.reason ? { detail: row.reason } : {}
964
+ });
965
+ const beforeObj = before.toObject(), afterObj = after.toObject();
966
+ for (const directive of /* @__PURE__ */ new Set([
967
+ ...Object.keys(beforeObj),
968
+ ...Object.keys(afterObj)
969
+ ])) {
970
+ if (JSON.stringify(beforeObj[directive]) !== JSON.stringify(afterObj[directive]) && !changes.some((c) => c.directive === directive))
971
+ changes.push({
972
+ directive,
973
+ source: "",
974
+ ruleSet: "base",
975
+ change: "modified",
976
+ detail: "Directive value changed"
977
+ });
978
+ }
979
+ if (before.config.mode !== after.config.mode)
980
+ changes.push({
981
+ directive: "(mode)",
982
+ source: "",
983
+ ruleSet: "base",
984
+ change: "modified",
985
+ detail: `${before.config.mode} \u2192 ${after.config.mode}`
986
+ });
987
+ changes.sort(
988
+ (a, b) => a.directive.localeCompare(b.directive) || a.source.localeCompare(b.source) || a.ruleSet.localeCompare(b.ruleSet) || a.change.localeCompare(b.change)
989
+ );
990
+ const headersChanged = JSON.stringify(beforeObj) !== JSON.stringify(afterObj) || before.config.mode !== after.config.mode;
991
+ const dangerous = changes.some(
992
+ (change) => change.change === "added" && !(beforeObj[change.directive] ?? []).includes(change.source) && /^(?:\*|https?:|data:|'unsafe-(?:inline|eval|hashes)')$/.test(
993
+ change.source
994
+ )
995
+ );
996
+ return {
997
+ changes,
998
+ risk: dangerous ? "increased" : headersChanged ? "unknown" : "unchanged"
999
+ };
1000
+ }
1001
+
1002
+ // src/importer/index.ts
1003
+ function importHeader(header) {
1004
+ if (/[\x00-\x08\x0a-\x1f\x7f,]/.test(header))
1005
+ throw new Error(
1006
+ "Header contains a control character or multiple policies; import one policy at a time"
1007
+ );
1008
+ const seen = /* @__PURE__ */ new Set();
1009
+ const warnings = [];
1010
+ const directives = [];
1011
+ for (const segment of header.split(";")) {
1012
+ const trimmed = segment.trim();
1013
+ if (!trimmed) continue;
1014
+ const [rawName, ...values] = trimmed.split(/[ \t]+/);
1015
+ if (!rawName || !/^[a-zA-Z][a-zA-Z0-9-]*$/.test(rawName))
1016
+ throw new Error(`Invalid directive name: ${rawName ?? ""}`);
1017
+ const name = rawName.toLowerCase();
1018
+ const ignored = seen.has(name);
1019
+ if (ignored)
1020
+ warnings.push(`Duplicate ${name} is ignored by CSP; retained for review`);
1021
+ seen.add(name);
1022
+ directives.push({ name, values, ignored });
1023
+ }
1024
+ return { directives, warnings };
1025
+ }
1026
+ function serializeImportedPolicy(policy) {
1027
+ return policy.directives.map(({ name, values }) => {
1028
+ if (!/^[a-z][a-z0-9-]*$/.test(name) || values.some((value) => !value || /[\x00-\x20\x7f;,]/.test(value))) {
1029
+ throw new Error("Invalid imported directive or value");
1030
+ }
1031
+ return [name, ...values].join(" ");
1032
+ }).join("; ");
1033
+ }
1034
+ function importedPolicyToDraft(policy) {
1035
+ if (policy.directives.some((directive) => directive.ignored))
1036
+ throw new Error(
1037
+ "Duplicate directives require manual review before conversion"
1038
+ );
1039
+ const base = {};
1040
+ const baseRaw = {};
1041
+ const ruleRaw = {};
1042
+ const baseOnly2 = /* @__PURE__ */ new Set([
1043
+ "default-src",
1044
+ "object-src",
1045
+ "base-uri",
1046
+ "frame-ancestors"
1047
+ ]);
1048
+ const supported = /* @__PURE__ */ new Set([
1049
+ "default-src",
1050
+ "object-src",
1051
+ "base-uri",
1052
+ "frame-ancestors",
1053
+ "script-src",
1054
+ "script-src-elem",
1055
+ "script-src-attr",
1056
+ "style-src",
1057
+ "style-src-elem",
1058
+ "style-src-attr",
1059
+ "img-src",
1060
+ "connect-src",
1061
+ "font-src",
1062
+ "frame-src",
1063
+ "child-src",
1064
+ "form-action",
1065
+ "media-src",
1066
+ "worker-src",
1067
+ "manifest-src"
1068
+ ]);
1069
+ const risky2 = /* @__PURE__ */ new Set([
1070
+ "'unsafe-inline'",
1071
+ "'unsafe-eval'",
1072
+ "'unsafe-hashes'"
1073
+ ]);
1074
+ for (const directive of policy.directives) {
1075
+ if (directive.name === "upgrade-insecure-requests") {
1076
+ if (directive.values.length)
1077
+ throw new Error(
1078
+ "upgrade-insecure-requests with values requires manual review"
1079
+ );
1080
+ base.upgradeInsecureRequests = true;
1081
+ continue;
1082
+ }
1083
+ if (!supported.has(directive.name) || directive.values.some(
1084
+ (value) => value.toLowerCase() === "'nonce-{nonce}'"
1085
+ )) {
1086
+ throw new Error(
1087
+ `Directive ${directive.name} contains unsupported syntax; review manually`
1088
+ );
1089
+ }
1090
+ if (directive.values.length === 0 || ["report-uri", "report-to", "sandbox"].includes(directive.name)) {
1091
+ throw new Error(
1092
+ `Directive ${directive.name} requires manual review before conversion`
1093
+ );
1094
+ }
1095
+ const entries = directive.values.map(
1096
+ (source) => risky2.has(source.toLowerCase()) ? { source, reason: "Imported legacy policy; review required" } : source
1097
+ );
1098
+ (baseOnly2.has(directive.name) ? baseRaw : ruleRaw)[directive.name] = entries;
1099
+ }
1100
+ if (Object.keys(baseRaw).length) base.directives = baseRaw;
1101
+ const draft = {
1102
+ base,
1103
+ ruleSets: Object.keys(ruleRaw).length ? [
1104
+ {
1105
+ name: "Imported policy",
1106
+ purpose: "Imported sources awaiting ownership review",
1107
+ rules: { directives: ruleRaw }
1108
+ }
1109
+ ] : []
1110
+ };
1111
+ const result = policyConfigSchema.safeParse(draft);
1112
+ if (!result.success)
1113
+ throw new Error(
1114
+ `Imported policy contains unsupported sources: ${result.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}`
1115
+ );
1116
+ return draft;
1117
+ }
1118
+ // Annotate the CommonJS export names for ESM import in node:
1119
+ 0 && (module.exports = {
1120
+ NONCE_PLACEHOLDER,
1121
+ Policy,
1122
+ audit,
1123
+ baseDirectives,
1124
+ baseSchema,
1125
+ cspHash,
1126
+ definePolicy,
1127
+ defineRuleSet,
1128
+ diffPolicies,
1129
+ generateNonce,
1130
+ importHeader,
1131
+ importedPolicyToDraft,
1132
+ matchPolicy,
1133
+ parseViolationReports,
1134
+ policyConfigSchema,
1135
+ replayReports,
1136
+ resourceDirectives,
1137
+ ruleSetSchema,
1138
+ rulesSchema,
1139
+ serializeImportedPolicy,
1140
+ sourceEntrySchema,
1141
+ sourceExpressions,
1142
+ unsafeEval,
1143
+ unsafeHashes,
1144
+ unsafeInline
1145
+ });
1146
+ //# sourceMappingURL=index.cjs.map