import OidcConnection from "./schemas/OidcConnection"; import { OidcPluginOptions } from "./OidcPluginOptions"; /** * OIDC Plugin context API exposed via ctx.plugins.oidc * * Provides methods to manage OIDC connections for users. */ export interface OidcPluginContext { oidc: { /** * Get OIDC connection for a user and provider * * Returns the stored OIDC connection with decrypted tokens (if storeTokens enabled). * * @param userId - Application user ID * @param provider - Provider name (e.g., "acme") * @returns OIDC connection or null if not found * * Example: * ```typescript * const connection = await ctx.plugins.oidc.getConnection(user._id, 'acme'); * if (connection) { * console.log('User connected to:', connection.issuer); * console.log('Subject:', connection.subject); * if (connection.accessToken) { * // Use access token to call IdP APIs * } * } * ``` */ getConnection: (userId: string, provider: string) => Promise; /** * Get all OIDC connections for a user * * Returns all IdP connections for the user with decrypted tokens. * * @param userId - Application user ID * @returns Array of OIDC connections * * Example: * ```typescript * const connections = await ctx.plugins.oidc.getConnections(user._id); * console.log('User has', connections.length, 'IdP connections'); * connections.forEach(conn => { * console.log('- Provider:', conn.provider, 'Email:', conn.email); * }); * ``` */ getConnections: (userId: string) => Promise; /** * Delete/unlink OIDC connection for a user * * Removes the connection between the user and the IdP. * The user will need to re-authenticate with the IdP. * * @param userId - Application user ID * @param provider - Provider name (e.g., "acme") * * Example: * ```typescript * // User wants to disconnect their Acme account * await ctx.plugins.oidc.deleteConnection(user._id, 'acme'); * ``` */ deleteConnection: (userId: string, provider: string) => Promise; /** * Plugin configuration options (read-only) * Useful for checking plugin settings at runtime */ options: Readonly; }; } //# sourceMappingURL=OidcPluginContext.d.ts.map