import { NextRequest, NextResponse } from 'next/server';

/**
 * Proxy middleware for media and API endpoints
 * Use this in your middleware.ts file
 */
declare function proxyMiddleware(request: NextRequest): NextResponse<unknown>;
/**
 * Recommended matcher config for proxy middleware
 * Add this to your middleware.ts config
 */
declare const proxyMiddlewareConfig: {
    matcher: string[];
};

/**
 * Token Auto-Refresh Middleware
 *
 * Automatically refreshes access token when receiving 401 responses.
 * Implements request queuing to prevent multiple simultaneous refresh attempts.
 */
/**
 * Attempt to refresh the access token using the refresh token
 * @returns New access token or null if refresh failed
 */
declare function refreshAccessToken(): Promise<string | null>;
/**
 * Check if a response indicates an authentication error
 */
declare function isAuthenticationError(response: Response): boolean;
/**
 * Create a fetch wrapper that automatically refreshes tokens on 401
 *
 * @param originalFetch - The original fetch function to wrap
 * @returns Wrapped fetch function with auto-refresh capability
 */
declare function createAutoRefreshFetch(originalFetch: typeof fetch): typeof fetch;
/**
 * Check if token is about to expire (within threshold)
 * @param thresholdMs - Time in ms before expiry to consider "expiring soon"
 * @returns true if token expires within threshold
 */
declare function isTokenExpiringSoon(thresholdMs?: number): boolean;
/**
 * Proactively refresh token if it's expiring soon
 * Call this periodically or before important operations
 */
declare function refreshIfExpiringSoon(thresholdMs?: number): Promise<void>;

export { createAutoRefreshFetch, isAuthenticationError, isTokenExpiringSoon, proxyMiddleware, proxyMiddlewareConfig, refreshAccessToken, refreshIfExpiringSoon };
