/**
 * Fastify Middleware for Security Policy Engine
 *
 * Provides middleware for enforcing security policies in Fastify applications.
 * Supports policy bypass (break-glass), decision injection, and management API.
 *
 * @packageDocumentation
 */
import type { FastifyRequest, FastifyReply, FastifyPluginCallback } from 'fastify';
import { SecurityPolicyEngine, type SecurityPolicyEngineOptions } from './engine.js';
import type { PolicyContext, PolicyDecision, PolicyContextUser, PolicyContextResource, PolicyContextRisk } from './types.js';
/**
 * Policy middleware options
 */
export interface PolicyMiddlewareOptions {
    /** Security policy engine options */
    engineOptions?: SecurityPolicyEngineOptions;
    /** Existing engine instance (if not creating new) */
    engine?: SecurityPolicyEngine;
    /** Paths to skip policy enforcement */
    skipPaths?: string[];
    /** Paths to skip (regex patterns) */
    skipPathPatterns?: RegExp[];
    /** Enable break-glass support */
    enableBreakGlass?: boolean;
    /** Break-glass header name */
    breakGlassHeader?: string;
    /** User context extractor */
    extractUser?: (request: FastifyRequest) => PolicyContextUser | undefined;
    /** Resource context extractor */
    extractResource?: (request: FastifyRequest) => PolicyContextResource | undefined;
    /** Risk context extractor */
    extractRisk?: (request: FastifyRequest) => PolicyContextRisk | undefined;
    /** Custom context extractor */
    extractCustom?: (request: FastifyRequest) => Record<string, unknown> | undefined;
    /** Whether to block on policy errors */
    blockOnError?: boolean;
    /** Enable management API */
    enableManagementApi?: boolean;
    /** Management API prefix */
    managementApiPrefix?: string;
    /** Management API authentication */
    managementApiAuth?: (request: FastifyRequest) => Promise<boolean>;
}
/**
 * Extended FastifyRequest with policy decision
 */
declare module 'fastify' {
    interface FastifyRequest {
        policyDecision?: PolicyDecision;
        policyContext?: PolicyContext;
    }
}
/**
 * Create policy enforcement middleware
 */
export declare function createPolicyMiddleware(engine: SecurityPolicyEngine, options?: PolicyMiddlewareOptions): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
/**
 * Export plugin with fastify-plugin wrapper
 */
export declare const policyEnginePluginFp: FastifyPluginCallback<PolicyMiddlewareOptions>;
/**
 * Enforce policies middleware factory
 *
 * Creates a middleware that evaluates and enforces security policies.
 * Can be used standalone or with the full plugin.
 */
export declare function enforcePolicies(options?: PolicyMiddlewareOptions): {
    middleware: (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
    engine: SecurityPolicyEngine;
};
declare module 'fastify' {
    interface FastifyInstance {
        policyEngine?: SecurityPolicyEngine;
    }
}
//# sourceMappingURL=middleware.d.ts.map