import OAuthConnection from "./schemas/OAuthConnection"; import { OAuthPluginOptions } from "./OAuthPluginOptions"; /** * OAuth Plugin context API exposed via ctx.plugins.oauth * * Provides methods for managing OAuth connections (stored tokens) for users. * Only applicable when storeTokens option is enabled. */ export interface OAuthPluginContext { oauth: { /** * Get stored OAuth connection for a specific user and provider * * Tokens are automatically decrypted before being returned. * Returns null if no connection exists. * * @param userId - The user's unique identifier * @param provider - The OAuth provider (github or google) * @returns The OAuth connection with decrypted tokens, or null */ getConnection: (userId: string, provider: "github" | "google") => Promise; /** * Get all stored OAuth connections for a specific user * * Tokens are automatically decrypted before being returned. * Returns empty array if no connections exist. * * @param userId - The user's unique identifier * @returns Array of OAuth connections with decrypted tokens */ getConnections: (userId: string) => Promise; /** * Delete OAuth connection for a specific user and provider * * Used when unlinking an OAuth provider from a user account. * Also deletes the encrypted tokens from storage. * * @param userId - The user's unique identifier * @param provider - The OAuth provider (github or google) * @returns void */ deleteConnection: (userId: string, provider: "github" | "google") => Promise; /** * Plugin configuration (read-only) * Provides access to plugin options for custom logic */ options: Readonly; }; }