import { PayloadRequest, Config } from 'payload';
import { BroadcastProvider, NewsletterPluginConfig } from './types.cjs';

interface NextApiRequest {
    cookies?: {
        [key: string]: string;
    };
    headers?: {
        [key: string]: string | string[] | undefined;
    };
    [key: string]: any;
}
interface GetServerSidePropsContext {
    req: {
        cookies?: {
            [key: string]: string;
        };
        headers?: {
            [key: string]: string | string[] | undefined;
        };
        [key: string]: any;
    };
    [key: string]: any;
}
interface TokenPayload {
    id: string;
    email: string;
    type?: string;
    iat?: number;
    exp?: number;
}
/**
 * Extract token from request cookies
 */
declare const getTokenFromRequest: (req: NextApiRequest | GetServerSidePropsContext["req"] | PayloadRequest) => string | null;
/**
 * Verify JWT token
 */
declare const verifyToken: (token: string, secret: string) => TokenPayload | null;
/**
 * Get authentication state for server-side rendering
 */
declare const getServerSideAuth: (context: GetServerSidePropsContext, secret?: string) => Promise<{
    subscriber: TokenPayload | null;
    isAuthenticated: boolean;
}>;
/**
 * Higher-order function for protecting pages
 */
declare const requireAuth: <P extends {
    [key: string]: any;
}>(gssp?: (context: GetServerSidePropsContext) => Promise<{
    props: P;
}>) => (context: GetServerSidePropsContext) => Promise<{
    redirect: {
        destination: string;
        permanent: boolean;
    };
    props?: undefined;
} | {
    props: P;
    redirect?: undefined;
}>;
/**
 * Check if request has valid authentication
 */
declare const isAuthenticated: (req: PayloadRequest | NextApiRequest, secret: string) => boolean;

declare module 'payload' {
    interface BasePayload {
        newsletterEmailService?: any;
        broadcastProvider?: BroadcastProvider;
        newsletterProvider?: BroadcastProvider;
    }
}
declare const newsletterPlugin: (pluginConfig: NewsletterPluginConfig) => (incomingConfig: Config) => Config;

export { newsletterPlugin as default, getServerSideAuth, getTokenFromRequest, isAuthenticated, newsletterPlugin, requireAuth, verifyToken };
