import { Request, Response, NextFunction, Router } from 'express';
import { ReAuthEngine, AuthOutput, Entity, AuthToken } from '@re-auth/reauth';
import { BaseHttpConfig, FrameworkAdapter, HttpAdapterContext, RouteOverride, CustomRoute, createRouteOverride, createCustomRoute, createAutoIntrospectionConfig, introspectReAuthEngine, type AutoGeneratedRoute, type AutoIntrospectionConfig, createContextRule, OAuth2ContextRules, type ContextExtractionRule } from '../../utils/http-adapter-factory';
/**
 * Express-specific configuration
 */
export interface ExpressAdapterConfig extends BaseHttpConfig {
}
/**
 * Express framework adapter implementation
 */
declare class ExpressFrameworkAdapter implements FrameworkAdapter<ExpressAdapterConfig> {
    private router;
    private engine?;
    private contextRules;
    private adapterConfig;
    constructor(engine?: ReAuthEngine);
    /**
     * Set the ReAuth engine instance (for shared adapter pattern)
     */
    setEngine(engine: ReAuthEngine): void;
    /**
     * Set context rules (for shared adapter pattern)
     */
    setContextRules(rules: ContextExtractionRule[]): void;
    /**
     * Set adapter config (for shared adapter pattern)
     */
    setAdapterConfig(config: any): void;
    /**
     * Get expected inputs for a plugin step
     */
    private getExpectedInputs;
    setupMiddleware(context: HttpAdapterContext): void;
    createRoute(method: string, path: string, handler: any, middleware?: any[]): void;
    extractInputs(request: any, pluginName: string, stepName: string): Promise<Record<string, any>>;
    /**
     * Add configurable context inputs from cookies and headers based on context rules
     * This mirrors the implementation from the factory but is specific to Express
     */
    addConfigurableContextInputs(request: any, inputs: Record<string, any>, pluginName: string, stepName: string, contextRules: ContextExtractionRule[]): void;
    handleStepResponse(request: any, response: Response, result: AuthOutput, httpConfig: any): void;
    /**
     * Handle configurable context outputs (set cookies and headers) based on context rules
     * This mirrors the implementation from the factory but is specific to Express
     */
    handleConfigurableContextOutputs(request: any, response: Response, result: AuthOutput, pluginName: string, stepName: string, contextRules: ContextExtractionRule[]): void;
    private getStatusCode;
    extractToken(request: Request): string | null;
    requireAuth(): any;
    errorResponse(response: Response, error: Error): void;
    getAdapter(): Router;
}
/**
 * Create Express adapter using the factory pattern with shared instance
 */
export declare const createExpressAdapterV2: (engine: ReAuthEngine, config: ExpressAdapterConfig, frameworkAdapter: ExpressFrameworkAdapter) => any;
/**
 * Express adapter class with additional features
 */
export declare class ExpressAdapterV2 {
    private router;
    private engine;
    private config;
    private frameworkAdapter;
    constructor(engine: ReAuthEngine, config?: ExpressAdapterConfig, frameworkAdapter?: ExpressFrameworkAdapter);
    /**
     * Get the Express router
     */
    getRouter(): Router;
    /**
     * Add a custom route
     */
    addRoute(method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH', path: string, handler: (req: Request, res: Response, next: NextFunction) => void | Promise<void>, options?: {
        middleware?: any[];
        requireAuth?: boolean;
    }): void;
    /**
     * Protection middleware for routes
     */
    protect(options?: ProtectOptions): (req: any, res: Response, next: NextFunction) => Promise<Response<any, Record<string, any>> | undefined>;
}
/**
 * Protection options
 */
interface ProtectOptions {
    roles?: string[];
    authorize?: (entity: Entity, request: Request, response: Response, next: NextFunction) => Promise<boolean> | boolean;
}
/**
 * Convenience function to create Express adapter with options
 */
export declare function createExpressAdapter(engine: ReAuthEngine, config?: ExpressAdapterConfig): ExpressAdapterV2;
declare global {
    namespace Express {
        interface Request {
            user?: Entity;
            token?: AuthToken;
            isAuthenticated(): boolean;
        }
    }
}
export { createRouteOverride, createCustomRoute, createAutoIntrospectionConfig, introspectReAuthEngine, createContextRule, OAuth2ContextRules, };
export type { RouteOverride, CustomRoute, AutoGeneratedRoute, AutoIntrospectionConfig, ContextExtractionRule, };
//# sourceMappingURL=express-adapter-v2.d.ts.map