@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.
@@ -0,0 +1,451 @@
1
+ import { z } from 'zod';
2
+
3
+ /** Friendly resource names mapped to CSP directives. */
4
+ declare const resourceDirectives: {
5
+ readonly scripts: "script-src";
6
+ readonly connect: "connect-src";
7
+ readonly images: "img-src";
8
+ readonly styles: "style-src";
9
+ readonly fonts: "font-src";
10
+ readonly frames: "frame-src";
11
+ readonly forms: "form-action";
12
+ readonly media: "media-src";
13
+ readonly workers: "worker-src";
14
+ readonly manifest: "manifest-src";
15
+ };
16
+ declare const baseDirectives: {
17
+ readonly default: "default-src";
18
+ readonly objects: "object-src";
19
+ readonly baseUri: "base-uri";
20
+ readonly frameAncestors: "frame-ancestors";
21
+ };
22
+ /** Nonce placeholder, replaced only when rendering a header. */
23
+ declare const NONCE_PLACEHOLDER = "'nonce-{nonce}'";
24
+ /** A source string, or a source annotated with a human-readable reason. Risky keywords require a reason. */
25
+ declare const sourceEntrySchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
26
+ source: z.ZodString;
27
+ reason: z.ZodString;
28
+ }, z.core.$strict>]>;
29
+ /** Rule-set permissions. At least one directive must be supplied. */
30
+ declare const rulesSchema: z.ZodObject<{
31
+ directives: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
32
+ source: z.ZodString;
33
+ reason: z.ZodString;
34
+ }, z.core.$strict>]>>>>;
35
+ scripts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
36
+ source: z.ZodString;
37
+ reason: z.ZodString;
38
+ }, z.core.$strict>]>>>;
39
+ connect: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
40
+ source: z.ZodString;
41
+ reason: z.ZodString;
42
+ }, z.core.$strict>]>>>;
43
+ images: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
44
+ source: z.ZodString;
45
+ reason: z.ZodString;
46
+ }, z.core.$strict>]>>>;
47
+ styles: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
48
+ source: z.ZodString;
49
+ reason: z.ZodString;
50
+ }, z.core.$strict>]>>>;
51
+ fonts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
52
+ source: z.ZodString;
53
+ reason: z.ZodString;
54
+ }, z.core.$strict>]>>>;
55
+ frames: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
56
+ source: z.ZodString;
57
+ reason: z.ZodString;
58
+ }, z.core.$strict>]>>>;
59
+ forms: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
60
+ source: z.ZodString;
61
+ reason: z.ZodString;
62
+ }, z.core.$strict>]>>>;
63
+ media: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
64
+ source: z.ZodString;
65
+ reason: z.ZodString;
66
+ }, z.core.$strict>]>>>;
67
+ workers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
68
+ source: z.ZodString;
69
+ reason: z.ZodString;
70
+ }, z.core.$strict>]>>>;
71
+ manifest: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
72
+ source: z.ZodString;
73
+ reason: z.ZodString;
74
+ }, z.core.$strict>]>>>;
75
+ }, z.core.$strict>;
76
+ /** Site-wide directives. */
77
+ declare const baseSchema: z.ZodObject<{
78
+ default: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
79
+ source: z.ZodString;
80
+ reason: z.ZodString;
81
+ }, z.core.$strict>]>>>;
82
+ objects: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
83
+ source: z.ZodString;
84
+ reason: z.ZodString;
85
+ }, z.core.$strict>]>>>;
86
+ baseUri: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
87
+ source: z.ZodString;
88
+ reason: z.ZodString;
89
+ }, z.core.$strict>]>>>;
90
+ frameAncestors: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
91
+ source: z.ZodString;
92
+ reason: z.ZodString;
93
+ }, z.core.$strict>]>>>;
94
+ upgradeInsecureRequests: z.ZodOptional<z.ZodBoolean>;
95
+ directives: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
96
+ source: z.ZodString;
97
+ reason: z.ZodString;
98
+ }, z.core.$strict>]>>>>;
99
+ scripts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
100
+ source: z.ZodString;
101
+ reason: z.ZodString;
102
+ }, z.core.$strict>]>>>;
103
+ connect: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
104
+ source: z.ZodString;
105
+ reason: z.ZodString;
106
+ }, z.core.$strict>]>>>;
107
+ images: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
108
+ source: z.ZodString;
109
+ reason: z.ZodString;
110
+ }, z.core.$strict>]>>>;
111
+ styles: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
112
+ source: z.ZodString;
113
+ reason: z.ZodString;
114
+ }, z.core.$strict>]>>>;
115
+ fonts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
116
+ source: z.ZodString;
117
+ reason: z.ZodString;
118
+ }, z.core.$strict>]>>>;
119
+ frames: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
120
+ source: z.ZodString;
121
+ reason: z.ZodString;
122
+ }, z.core.$strict>]>>>;
123
+ forms: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
124
+ source: z.ZodString;
125
+ reason: z.ZodString;
126
+ }, z.core.$strict>]>>>;
127
+ media: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
128
+ source: z.ZodString;
129
+ reason: z.ZodString;
130
+ }, z.core.$strict>]>>>;
131
+ workers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
132
+ source: z.ZodString;
133
+ reason: z.ZodString;
134
+ }, z.core.$strict>]>>>;
135
+ manifest: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
136
+ source: z.ZodString;
137
+ reason: z.ZodString;
138
+ }, z.core.$strict>]>>>;
139
+ }, z.core.$strict>;
140
+ /** A named, documented and optionally disabled group of permissions. */
141
+ declare const ruleSetSchema: z.ZodObject<{
142
+ name: z.ZodString;
143
+ purpose: z.ZodString;
144
+ owner: z.ZodOptional<z.ZodString>;
145
+ docs: z.ZodOptional<z.ZodURL>;
146
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
147
+ reviewBy: z.ZodOptional<z.ZodISODate>;
148
+ enabled: z.ZodDefault<z.ZodBoolean>;
149
+ rules: z.ZodObject<{
150
+ directives: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
151
+ source: z.ZodString;
152
+ reason: z.ZodString;
153
+ }, z.core.$strict>]>>>>;
154
+ scripts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
155
+ source: z.ZodString;
156
+ reason: z.ZodString;
157
+ }, z.core.$strict>]>>>;
158
+ connect: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
159
+ source: z.ZodString;
160
+ reason: z.ZodString;
161
+ }, z.core.$strict>]>>>;
162
+ images: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
163
+ source: z.ZodString;
164
+ reason: z.ZodString;
165
+ }, z.core.$strict>]>>>;
166
+ styles: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
167
+ source: z.ZodString;
168
+ reason: z.ZodString;
169
+ }, z.core.$strict>]>>>;
170
+ fonts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
171
+ source: z.ZodString;
172
+ reason: z.ZodString;
173
+ }, z.core.$strict>]>>>;
174
+ frames: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
175
+ source: z.ZodString;
176
+ reason: z.ZodString;
177
+ }, z.core.$strict>]>>>;
178
+ forms: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
179
+ source: z.ZodString;
180
+ reason: z.ZodString;
181
+ }, z.core.$strict>]>>>;
182
+ media: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
183
+ source: z.ZodString;
184
+ reason: z.ZodString;
185
+ }, z.core.$strict>]>>>;
186
+ workers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
187
+ source: z.ZodString;
188
+ reason: z.ZodString;
189
+ }, z.core.$strict>]>>>;
190
+ manifest: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
191
+ source: z.ZodString;
192
+ reason: z.ZodString;
193
+ }, z.core.$strict>]>>>;
194
+ }, z.core.$strict>;
195
+ }, z.core.$strict>;
196
+ /** Complete configuration. Zod catches duplicate names and invalid rule sets. */
197
+ declare const policyConfigSchema: z.ZodObject<{
198
+ base: z.ZodDefault<z.ZodObject<{
199
+ default: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
200
+ source: z.ZodString;
201
+ reason: z.ZodString;
202
+ }, z.core.$strict>]>>>;
203
+ objects: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
204
+ source: z.ZodString;
205
+ reason: z.ZodString;
206
+ }, z.core.$strict>]>>>;
207
+ baseUri: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
208
+ source: z.ZodString;
209
+ reason: z.ZodString;
210
+ }, z.core.$strict>]>>>;
211
+ frameAncestors: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
212
+ source: z.ZodString;
213
+ reason: z.ZodString;
214
+ }, z.core.$strict>]>>>;
215
+ upgradeInsecureRequests: z.ZodOptional<z.ZodBoolean>;
216
+ directives: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
217
+ source: z.ZodString;
218
+ reason: z.ZodString;
219
+ }, z.core.$strict>]>>>>;
220
+ scripts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
221
+ source: z.ZodString;
222
+ reason: z.ZodString;
223
+ }, z.core.$strict>]>>>;
224
+ connect: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
225
+ source: z.ZodString;
226
+ reason: z.ZodString;
227
+ }, z.core.$strict>]>>>;
228
+ images: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
229
+ source: z.ZodString;
230
+ reason: z.ZodString;
231
+ }, z.core.$strict>]>>>;
232
+ styles: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
233
+ source: z.ZodString;
234
+ reason: z.ZodString;
235
+ }, z.core.$strict>]>>>;
236
+ fonts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
237
+ source: z.ZodString;
238
+ reason: z.ZodString;
239
+ }, z.core.$strict>]>>>;
240
+ frames: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
241
+ source: z.ZodString;
242
+ reason: z.ZodString;
243
+ }, z.core.$strict>]>>>;
244
+ forms: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
245
+ source: z.ZodString;
246
+ reason: z.ZodString;
247
+ }, z.core.$strict>]>>>;
248
+ media: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
249
+ source: z.ZodString;
250
+ reason: z.ZodString;
251
+ }, z.core.$strict>]>>>;
252
+ workers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
253
+ source: z.ZodString;
254
+ reason: z.ZodString;
255
+ }, z.core.$strict>]>>>;
256
+ manifest: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
257
+ source: z.ZodString;
258
+ reason: z.ZodString;
259
+ }, z.core.$strict>]>>>;
260
+ }, z.core.$strict>>;
261
+ ruleSets: z.ZodDefault<z.ZodArray<z.ZodObject<{
262
+ name: z.ZodString;
263
+ purpose: z.ZodString;
264
+ owner: z.ZodOptional<z.ZodString>;
265
+ docs: z.ZodOptional<z.ZodURL>;
266
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
267
+ reviewBy: z.ZodOptional<z.ZodISODate>;
268
+ enabled: z.ZodDefault<z.ZodBoolean>;
269
+ rules: z.ZodObject<{
270
+ directives: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
271
+ source: z.ZodString;
272
+ reason: z.ZodString;
273
+ }, z.core.$strict>]>>>>;
274
+ scripts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
275
+ source: z.ZodString;
276
+ reason: z.ZodString;
277
+ }, z.core.$strict>]>>>;
278
+ connect: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
279
+ source: z.ZodString;
280
+ reason: z.ZodString;
281
+ }, z.core.$strict>]>>>;
282
+ images: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
283
+ source: z.ZodString;
284
+ reason: z.ZodString;
285
+ }, z.core.$strict>]>>>;
286
+ styles: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
287
+ source: z.ZodString;
288
+ reason: z.ZodString;
289
+ }, z.core.$strict>]>>>;
290
+ fonts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
291
+ source: z.ZodString;
292
+ reason: z.ZodString;
293
+ }, z.core.$strict>]>>>;
294
+ frames: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
295
+ source: z.ZodString;
296
+ reason: z.ZodString;
297
+ }, z.core.$strict>]>>>;
298
+ forms: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
299
+ source: z.ZodString;
300
+ reason: z.ZodString;
301
+ }, z.core.$strict>]>>>;
302
+ media: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
303
+ source: z.ZodString;
304
+ reason: z.ZodString;
305
+ }, z.core.$strict>]>>>;
306
+ workers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
307
+ source: z.ZodString;
308
+ reason: z.ZodString;
309
+ }, z.core.$strict>]>>>;
310
+ manifest: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
311
+ source: z.ZodString;
312
+ reason: z.ZodString;
313
+ }, z.core.$strict>]>>>;
314
+ }, z.core.$strict>;
315
+ }, z.core.$strict>>>;
316
+ reporting: z.ZodOptional<z.ZodObject<{
317
+ uri: z.ZodOptional<z.ZodURL>;
318
+ to: z.ZodOptional<z.ZodString>;
319
+ }, z.core.$strict>>;
320
+ mode: z.ZodDefault<z.ZodEnum<{
321
+ enforce: "enforce";
322
+ "report-only": "report-only";
323
+ }>>;
324
+ }, z.core.$strict>;
325
+ type SourceEntry = z.output<typeof sourceEntrySchema>;
326
+ type Rules = z.output<typeof rulesSchema>;
327
+ type ResourceKey = keyof typeof resourceDirectives;
328
+ type RuleSetInput = z.input<typeof ruleSetSchema>;
329
+ type RuleSet = z.output<typeof ruleSetSchema>;
330
+ type PolicyConfig = z.input<typeof policyConfigSchema>;
331
+ type NormalizedPolicyConfig = z.output<typeof policyConfigSchema>;
332
+ type DirectiveName = (typeof resourceDirectives)[ResourceKey] | (typeof baseDirectives)[keyof typeof baseDirectives] | 'upgrade-insecure-requests' | 'report-uri' | 'report-to';
333
+
334
+ /** Request metadata needed to evaluate checks which cannot be decided from a URL alone. */
335
+ interface MatchOptions {
336
+ /** Origin of the protected document, required for 'self' and schemeless sources. */
337
+ origin?: string;
338
+ /** Number of redirects before this URL; paths are not checked after a redirect. */
339
+ redirectCount?: number;
340
+ /** Nonce on the request; supply an empty string if the request has none. */
341
+ nonce?: string;
342
+ /** Rendered policy nonce for a dynamic nonce placeholder. */
343
+ policyNonce?: string;
344
+ /** Integrity metadata tokens on the request; supply an empty array if absent. */
345
+ integrity?: readonly string[];
346
+ /** Whether a script was parser-inserted. */
347
+ parserInserted?: boolean;
348
+ }
349
+ /** A conservative CSP decision. `indeterminate` never implies browser permission. */
350
+ interface AllowsResult {
351
+ status: 'allowed' | 'blocked' | 'indeterminate';
352
+ allowed: boolean | null;
353
+ effectiveDirective?: string;
354
+ matchedSource?: string;
355
+ reason?: string;
356
+ }
357
+ /**
358
+ * Evaluate a URL against a CSP directive. This deliberately returns indeterminate when
359
+ * relevant request context is unavailable. It is not a full browser simulation.
360
+ * Algorithms: https://www.w3.org/TR/CSP3/#match-url-to-source-list and #directive-fallback-list
361
+ */
362
+ declare function matchPolicy(directives: Readonly<Record<string, readonly string[]>>, directive: string, input: string, options?: MatchOptions): AllowsResult;
363
+
364
+ /** Relevant fields from a CSP violation. Reports do not always include enough context to replay. */
365
+ interface ViolationReport {
366
+ directive: string;
367
+ blockedURL: string;
368
+ documentURL?: string;
369
+ }
370
+ interface ReplayResult {
371
+ report: ViolationReport;
372
+ result: AllowsResult;
373
+ }
374
+ /** Parse CSP legacy reports or Reporting API envelopes. Unsupported formats fail explicitly. */
375
+ declare function parseViolationReports(input: unknown): ViolationReport[];
376
+ /** Replay without inventing nonce, redirect, integrity or parser metadata. */
377
+ declare function replayReports(directives: Readonly<Record<string, readonly string[]>>, reports: readonly ViolationReport[]): ReplayResult[];
378
+
379
+ /** Reject literal risky strings in input lists while allowing annotated source objects.
380
+ * Dynamic strings remain subject to runtime Zod validation. */
381
+ type RequireRiskReasons<T> = T extends {
382
+ source: string;
383
+ } ? T : T extends string ? Lowercase<T> extends "'unsafe-inline'" | "'unsafe-eval'" | "'unsafe-hashes'" ? never : T : T extends object ? {
384
+ [K in keyof T]: K extends 'name' | 'purpose' | 'owner' | 'docs' | 'tags' | 'reviewBy' | 'enabled' | 'mode' | 'reporting' ? T[K] : RequireRiskReasons<T[K]>;
385
+ } : T;
386
+ interface ExplainRow {
387
+ directive: string;
388
+ source: string;
389
+ ruleSet: string;
390
+ reason?: string;
391
+ }
392
+ interface HeaderOptions {
393
+ nonce?: string;
394
+ pretty?: boolean;
395
+ }
396
+ /** Validate and freeze a rule set. */
397
+ declare function defineRuleSet<const T extends RuleSetInput>(input: T & RequireRiskReasons<T>): RuleSet;
398
+ /** Immutable CSP configuration and its deterministic merged representation. */
399
+ declare class Policy {
400
+ readonly config: NormalizedPolicyConfig;
401
+ readonly headerName: 'Content-Security-Policy' | 'Content-Security-Policy-Report-Only';
402
+ constructor(input: PolicyConfig);
403
+ /** Sources and their contributing rule sets. Duplicate values retain all contributors. */
404
+ explain(): ExplainRow[];
405
+ /** Merged sources, deduplicated without changing path syntax. */
406
+ toObject(): Record<string, string[]>;
407
+ /** Evaluate a URL with explicit uncertainty when browser context is missing. */
408
+ allows(directive: string, url: string, options?: MatchOptions): AllowsResult & {
409
+ contributors?: ExplainRow[];
410
+ };
411
+ /** Replay supported violation report JSON without inventing missing request context. */
412
+ check(reports: unknown): ReplayResult[];
413
+ /** Render a header value. Pretty output is for display only and is not a valid HTTP header value. */
414
+ toHeader(options?: HeaderOptions): string;
415
+ private render;
416
+ /** Render a meta policy; report-only is not supported in meta delivery. */
417
+ toMetaContent(options?: HeaderOptions): string;
418
+ withRuleSet<const T extends RuleSetInput>(ruleSet: T & RequireRiskReasons<T>): Policy;
419
+ without(name: string): Policy;
420
+ }
421
+ /** Validate and construct a policy. */
422
+ declare function definePolicy<const T extends PolicyConfig>(input: T & RequireRiskReasons<T>): Policy;
423
+
424
+ type Severity = 'high' | 'medium' | 'low' | 'info';
425
+ interface AuditFinding {
426
+ ruleId: string;
427
+ severity: Severity;
428
+ message: string;
429
+ fix: string;
430
+ directive?: string;
431
+ source?: string;
432
+ ruleSet?: string;
433
+ }
434
+ interface AuditRule {
435
+ id: string;
436
+ check(policy: Policy): readonly AuditFinding[];
437
+ }
438
+ interface AuditSuppression {
439
+ ruleId: string;
440
+ ruleSet: string;
441
+ reason: string;
442
+ }
443
+ interface AuditOptions {
444
+ rules?: readonly AuditRule[];
445
+ suppressions?: readonly AuditSuppression[];
446
+ now?: Date;
447
+ }
448
+ /** Inspect known dangerous policy patterns. Findings are advisory and do not prove a policy safe. */
449
+ declare function audit(policy: Policy, options?: AuditOptions): AuditFinding[];
450
+
451
+ export { type AllowsResult as A, type DirectiveName as D, type ExplainRow as E, type HeaderOptions as H, type MatchOptions as M, NONCE_PLACEHOLDER as N, Policy as P, type ReplayResult as R, type Severity as S, type ViolationReport as V, type PolicyConfig as a, type AuditFinding as b, type AuditOptions as c, type AuditRule as d, type AuditSuppression as e, type NormalizedPolicyConfig as f, type RequireRiskReasons as g, type ResourceKey as h, type RuleSet as i, type RuleSetInput as j, type Rules as k, type SourceEntry as l, audit as m, baseDirectives as n, baseSchema as o, definePolicy as p, defineRuleSet as q, matchPolicy as r, parseViolationReports as s, policyConfigSchema as t, replayReports as u, resourceDirectives as v, ruleSetSchema as w, rulesSchema as x, sourceEntrySchema as y };