import { IncomingMessage } from 'http';
import 'reflect-metadata';
import { Subject } from 'rxjs';
import sql from 'mssql';
import { DataSourceInfo, UserPayload } from './types.js';
import type { RequestHandler } from 'express';
import { DatabaseProviderBase } from '@memberjunction/core';
/**
 * Request context for API key usage logging.
 */
export interface RequestContext {
    /** The API endpoint path (e.g., '/graphql', '/mcp') */
    endpoint: string;
    /** HTTP method (e.g., 'POST', 'GET') */
    method: string;
    /** GraphQL operation name if available */
    operationName?: string;
    /** Client IP address */
    ipAddress?: string;
    /** User-Agent header */
    userAgent?: string;
}
export declare const getUserPayload: (bearerToken: string, sessionId: string, dataSources: DataSourceInfo[], requestDomain?: string, systemApiKey?: string, userApiKey?: string, requestContext?: RequestContext) => Promise<UserPayload>;
/**
 * Creates a single Express middleware that authenticates ALL routes.
 *
 * On success, attaches `req.userPayload` (UserPayload) and `req['mjUser']` (UserInfo)
 * so downstream middleware and route handlers can read the authenticated user without
 * re-authenticating. On failure, returns 401.
 *
 * Register OAuth callback routes BEFORE this middleware so they remain unauthenticated.
 */
export declare function createUnifiedAuthMiddleware(dataSources: DataSourceInfo[]): RequestHandler;
/**
 * Creates the GraphQL context from an already-authenticated request.
 *
 * The unified auth middleware has already resolved `req.userPayload` before this runs.
 * This function reads the payload and creates per-request database providers.
 */
export declare const contextFunction: ({ setupComplete$, dataSource, dataSources }: {
    setupComplete$: Subject<unknown>;
    dataSource: sql.ConnectionPool;
    dataSources: DataSourceInfo[];
}) => ({ req }: {
    req: IncomingMessage;
}) => Promise<{
    dataSource: sql.ConnectionPool;
    dataSources: DataSourceInfo[];
    userPayload: UserPayload;
    providers: {
        provider: DatabaseProviderBase;
        type: "Read-Write" | "Read-Only";
    }[];
}>;
//# sourceMappingURL=context.d.ts.map