import type { OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth.js";
import type { McpAuthorizationProof, McpClientRegistration, McpStoredAuth } from "./token-store.ts";
export type McpGrantRecord = Pick<McpStoredAuth, "accessToken" | "refreshToken" | "issuer" | "resource" | "scope" | "refreshScope"> & {
    readonly authorization?: unknown;
    readonly clientInfo?: Pick<McpClientRegistration, "client_id" | "client_secret" | "token_endpoint_auth_method" | "issuer">;
    readonly discoveryState?: {
        readonly authorizationServerUrl?: string | URL;
    };
};
export interface McpGrantContext {
    readonly serverName: string;
    readonly serverUrl: string;
    readonly agentDir: string;
    readonly clientId?: string;
    readonly clientMetadataUrl?: string;
}
export declare function storedGrantIssuer(record: McpGrantRecord | undefined): string | undefined;
export declare function freezeGrantAttribution(record: McpStoredAuth | undefined): McpStoredAuth;
export declare function storedAuthToTokens(record: McpStoredAuth | undefined, now?: number): OAuthTokens | undefined;
/** Maps one response; the caller decides which preceding fields it is entitled to inherit. */
export declare function mergeTokensIntoStoredAuth(current: McpStoredAuth, tokens: OAuthTokens): McpStoredAuth;
export interface McpTokenResponse {
    readonly tokens: OAuthTokens;
    readonly resource: string;
    readonly fresh: boolean;
    readonly presented?: McpStoredAuth;
    readonly clientInfo?: McpClientRegistration;
}
/** An SDK response has no locked predecessor; only explicit fresh acquisition can establish its initial proof. */
export declare function mergeOAuthTokenResponse(current: McpStoredAuth, context: McpGrantContext, response: McpTokenResponse): McpStoredAuth;
/** Active binding excludes pending registrations and display/redirect metadata. */
export declare function grantBinding(record: McpGrantRecord, context: McpGrantContext): {
    issuer: string | undefined;
    resource: string | undefined;
    clientIdentity: string | undefined;
    scope: string | undefined;
    refreshScope: string | undefined;
};
export declare function validGrantProof(record: McpGrantRecord, context: McpGrantContext): McpAuthorizationProof | undefined;
/** Only the refresh transaction passes a predecessor, read while holding its existing token-store lock. */
export declare function withGrantAuthorization(record: McpStoredAuth, context: McpGrantContext, previous?: McpStoredAuth): McpStoredAuth;
export declare function oauthGrantIdentity(record: McpGrantRecord, context: McpGrantContext): string;
//# sourceMappingURL=oauth-grant.d.ts.map