import type { CSPDirectives, CSPSourceValue, CSPSandboxValue } from './types.js';
/**
 * CSP preset type
 */
export type CSPPreset = 'strict' | 'moderate' | 'relaxed' | 'api';
/**
 * CSP validation error
 */
export interface CSPValidationError {
    directive: string;
    issue: string;
    severity: 'error' | 'warning';
}
/**
 * CSP build result
 */
export interface CSPBuildResult {
    /** The policy string to set in the header */
    policy: string;
    /** Generated nonce (if any) */
    nonce?: string;
    /** Whether the policy is in report-only mode */
    reportOnly: boolean;
    /** Validation errors/warnings */
    validationIssues: CSPValidationError[];
}
/**
 * Generate a cryptographically secure nonce for CSP
 *
 * @returns Base64-encoded nonce string
 */
export declare function generateNonce(): string;
/**
 * Format nonce for CSP header
 *
 * @param nonce - The nonce value
 * @returns Formatted nonce string for CSP
 */
export declare function formatNonce(nonce: string): CSPSourceValue;
/**
 * Strict CSP preset - Maximum security for production
 *
 * - No inline scripts/styles (use nonces)
 * - No eval
 * - Self-only by default
 * - Strict frame ancestors
 */
export declare const STRICT_CSP_PRESET: CSPDirectives;
/**
 * Moderate CSP preset - Balanced security
 *
 * - Allows some common CDN patterns
 * - Still blocks eval
 * - Allows same-origin frames
 */
export declare const MODERATE_CSP_PRESET: CSPDirectives;
/**
 * Relaxed CSP preset - Development/legacy compatibility
 *
 * WARNING: Only use in development!
 * - Allows unsafe-inline for easier development
 * - Allows more external sources
 */
export declare const RELAXED_CSP_PRESET: CSPDirectives;
/**
 * API-only CSP preset - For pure API services
 *
 * - Minimal directives
 * - No frame embedding
 * - Strict connection rules
 */
export declare const API_CSP_PRESET: CSPDirectives;
/**
 * Get CSP preset by name
 */
export declare function getCSPPreset(preset: CSPPreset): CSPDirectives;
/**
 * Fluent builder for Content Security Policy
 *
 * @example
 * ```typescript
 * const csp = new CSPBuilder()
 *   .preset('strict')
 *   .addScriptSrc('https://cdn.example.com')
 *   .withNonce()
 *   .reportTo('csp-violations')
 *   .build();
 *
 * // Use in response
 * res.setHeader('Content-Security-Policy', csp.policy);
 * // Pass nonce to templates for inline scripts
 * res.locals.nonce = csp.nonce;
 * ```
 */
export declare class CSPBuilder {
    private directives;
    private nonce;
    private reportOnly;
    private reporting;
    /**
     * Start from a preset configuration
     */
    preset(preset: CSPPreset): this;
    /**
     * Set default-src directive
     */
    defaultSrc(...sources: CSPSourceValue[]): this;
    /**
     * Set script-src directive
     */
    scriptSrc(...sources: CSPSourceValue[]): this;
    /**
     * Add source to script-src
     */
    addScriptSrc(...sources: CSPSourceValue[]): this;
    /**
     * Set style-src directive
     */
    styleSrc(...sources: CSPSourceValue[]): this;
    /**
     * Add source to style-src
     */
    addStyleSrc(...sources: CSPSourceValue[]): this;
    /**
     * Set img-src directive
     */
    imgSrc(...sources: CSPSourceValue[]): this;
    /**
     * Add source to img-src
     */
    addImgSrc(...sources: CSPSourceValue[]): this;
    /**
     * Set font-src directive
     */
    fontSrc(...sources: CSPSourceValue[]): this;
    /**
     * Set connect-src directive
     */
    connectSrc(...sources: CSPSourceValue[]): this;
    /**
     * Add source to connect-src
     */
    addConnectSrc(...sources: CSPSourceValue[]): this;
    /**
     * Set frame-src directive
     */
    frameSrc(...sources: CSPSourceValue[]): this;
    /**
     * Set frame-ancestors directive
     */
    frameAncestors(...sources: CSPSourceValue[]): this;
    /**
     * Set object-src directive
     */
    objectSrc(...sources: CSPSourceValue[]): this;
    /**
     * Set base-uri directive
     */
    baseUri(...sources: CSPSourceValue[]): this;
    /**
     * Set form-action directive
     */
    formAction(...sources: CSPSourceValue[]): this;
    /**
     * Set worker-src directive
     */
    workerSrc(...sources: CSPSourceValue[]): this;
    /**
     * Set sandbox directive
     */
    sandbox(...values: CSPSandboxValue[]): this;
    /**
     * Enable upgrade-insecure-requests
     */
    upgradeInsecureRequests(): this;
    /**
     * Enable block-all-mixed-content
     */
    blockAllMixedContent(): this;
    /**
     * Generate and add a nonce for inline scripts
     *
     * The generated nonce will be added to script-src and returned in the build result.
     */
    withNonce(): this;
    /**
     * Use a specific nonce value
     */
    useNonce(nonce: string): this;
    /**
     * Set report-to endpoint
     */
    reportTo(groupName: string): this;
    /**
     * Set report-uri endpoints (deprecated but still needed for some browsers)
     */
    reportUri(...uris: string[]): this;
    /**
     * Configure reporting endpoints
     */
    reportingEndpoints(endpoints: Record<string, string>): this;
    /**
     * Set policy to report-only mode
     */
    asReportOnly(): this;
    /**
     * Set a custom directive
     */
    directive<K extends keyof CSPDirectives>(name: K, value: CSPDirectives[K]): this;
    /**
     * Merge additional directives
     */
    merge(directives: Partial<CSPDirectives>): this;
    /**
     * Validate the CSP configuration
     */
    validate(): CSPValidationError[];
    /**
     * Build the CSP header value
     */
    build(): CSPBuildResult;
    /**
     * Get the header name based on report-only mode
     */
    getHeaderName(): string;
    /**
     * Get the current directives (for inspection)
     */
    getDirectives(): CSPDirectives;
}
/**
 * Create a CSP builder with strict defaults
 */
export declare function createStrictCSP(): CSPBuilder;
/**
 * Create a CSP builder with moderate defaults
 */
export declare function createModerateCSP(): CSPBuilder;
/**
 * Create a CSP builder for API services
 */
export declare function createAPICSP(): CSPBuilder;
/**
 * Create a CSP builder for development (relaxed)
 *
 * WARNING: Only use in development!
 */
export declare function createDevelopmentCSP(): CSPBuilder;
/**
 * Build a CSP string directly from directives
 */
export declare function buildCSPString(directives: CSPDirectives, nonce?: string): string;
/**
 * Parse a CSP string into directives (for analysis)
 */
export declare function parseCSPString(policy: string): CSPDirectives;
//# sourceMappingURL=csp.d.ts.map