import { type OAuthProviderConfig, type TokenSet } from "./types.js"; export interface MailOAuthService { /** Exchange an authorization code for a token set. */ exchangeCode(code: string, redirectUri: string, codeVerifier?: string): Promise; /** Refresh an access token using a refresh token. Throws RefreshTokenError on failure. */ refresh(refreshToken: string): Promise; /** Build the OAuth2 authorization URL to redirect the user to. */ buildAuthorizationUrl(opts: { redirectUri: string; state: string; loginHint?: string; }): string; /** * Return a valid access token for the given cache key, refreshing if needed. * Concurrent callers for the same key share a single in-flight refresh (single-flight). * * Rotation contract: if the provider rotates the refresh token, the new value is * surfaced in the returned `TokenSet.refreshToken`. The caller is responsible for * persisting it — this service never persists tokens. */ getAccessToken(cacheKey: string, refreshToken: string): Promise; } export declare function createMailOAuthService(config: OAuthProviderConfig): MailOAuthService;