import { FlinkContext } from "@flink-app/flink"; import { OAuthPluginContext } from "./OAuthPluginContext"; import OAuthSessionRepo from "./repos/OAuthSessionRepo"; import OAuthConnectionRepo from "./repos/OAuthConnectionRepo"; /** * Internal context used by OAuth plugin handlers and repositories * * Extends FlinkContext with OAuth-specific repositories and plugin context. * Note: This also includes reference to jwtAuth plugin for JWT token generation. * * Example usage in onAuthSuccess callback: * ```typescript * onAuthSuccess: async ({ profile }, ctx: OAuthInternalContext) => { * // Access OAuth repos * const connection = await ctx.repos.oauthConnectionRepo.findByUserAndProvider(userId, 'github'); * * // Generate JWT token using JWT Auth Plugin * const token = await ctx.plugins.jwtAuth.createToken( * { userId: user._id, email: user.email }, * ['user'] * ); * * return { user, token }; * } * ``` */ export interface OAuthInternalContext extends FlinkContext { repos: { oauthSessionRepo: OAuthSessionRepo; oauthConnectionRepo: OAuthConnectionRepo; [key: string]: any; }; plugins: { oauth: OAuthPluginContext["oauth"]; /** * JWT Auth Plugin reference for generating JWT tokens * Required peer dependency: @flink-app/jwt-auth-plugin */ jwtAuth?: { createToken: (payload: any, roles: string[]) => Promise; [key: string]: any; }; [key: string]: any; }; }