import { FlinkPlugin } from "@flink-app/flink"; import { OAuthPluginOptions } from "./OAuthPluginOptions"; /** * OAuth Plugin Factory Function * * Creates a Flink plugin for OAuth 2.0 authentication with GitHub and Google providers. * Integrates with JWT Auth Plugin for token generation. * * @param options - OAuth plugin configuration options * @returns FlinkPlugin instance * * @example * ```typescript * import { jwtAuthPlugin } from '@flink-app/jwt-auth-plugin'; * import { oauthPlugin } from '@flink-app/oauth-plugin'; * * const app = new FlinkApp({ * plugins: [ * // JWT Auth Plugin must be registered first * jwtAuthPlugin({ * secret: process.env.JWT_SECRET!, * getUser: async (tokenData) => { * return ctx.repos.userRepo.getById(tokenData.userId); * }, * rolePermissions: { * user: ['read:own'], * admin: ['read:all', 'write:all'] * } * }), * * // OAuth Plugin uses JWT Auth Plugin in callbacks * oauthPlugin({ * providers: { * github: { * clientId: process.env.GITHUB_CLIENT_ID!, * clientSecret: process.env.GITHUB_CLIENT_SECRET!, * callbackUrl: 'https://myapp.com/oauth/github/callback' * } * }, * onAuthSuccess: async ({ profile, provider }, ctx) => { * // Find or create user * let user = await ctx.repos.userRepo.getOne({ email: profile.email }); * * if (!user) { * user = await ctx.repos.userRepo.create({ * email: profile.email, * name: profile.name, * oauthProvider: provider, * oauthProviderId: profile.id * }); * } * * // Generate JWT token using JWT Auth Plugin * const token = await ctx.plugins.jwtAuth.createToken( * { userId: user._id, email: user.email }, * ['user'] * ); * * return { * user, * token, * redirectUrl: 'https://myapp.com/dashboard' * }; * } * }) * ] * }); * ``` */ export declare function oauthPlugin(options: OAuthPluginOptions): FlinkPlugin;