import type { HttpClient } from '@poppinss/oauth-client'; import type { HttpContext } from '@adonisjs/core/http'; import type { FacebookToken, FacebookScopes, LiteralStringUnion, ApiRequestContract, FacebookDriverConfig, FacebookProfileFields, RedirectRequestContract } from '../types.ts'; import { Oauth2Driver } from '../abstract_drivers/oauth2.ts'; /** * Facebook OAuth2 driver for authenticating users via Facebook. * Supports fetching user profile information including name, email, and profile picture. * * @example * ```ts * router.get('/facebook/redirect', ({ ally }) => { * return ally.use('facebook').redirect((request) => { * request.scopes(['email', 'public_profile']) * }) * }) * * router.get('/facebook/callback', async ({ ally }) => { * const facebook = ally.use('facebook') * * if (facebook.accessDenied()) { * return 'Access was denied' * } * * if (facebook.stateMisMatch()) { * return 'State mismatch error' * } * * if (facebook.hasError()) { * return facebook.getError() * } * * const user = await facebook.user() * return user * }) * ``` */ export declare class FacebookDriver extends Oauth2Driver { config: FacebookDriverConfig; /** * Facebook token endpoint URL. */ protected accessTokenUrl: string; /** * Facebook authorization endpoint URL. */ protected authorizeUrl: string; /** * Facebook profile endpoint URL. */ protected userInfoUrl: string; /** * The default set of fields to query for the user request */ protected userFields: LiteralStringUnion[]; /** * The param name for the authorization code */ protected codeParamName: string; /** * The param name for the error */ protected errorParamName: string; /** * Cookie name for storing the "facebok_oauth_state" */ protected stateCookieName: string; /** * Parameter name to be used for sending and receiving the state * from Facebok */ protected stateParamName: string; /** * Parameter name for defining the scopes */ protected scopeParamName: string; /** * Scopes separator */ protected scopesSeparator: string; /** * @param ctx - The HTTP context * @param config - Configuration for the Facebook driver */ constructor(ctx: HttpContext, config: FacebookDriverConfig); /** * Configures the redirect request with default scopes and Facebook-specific * parameters like display and auth_type. * * @param request - The redirect request to configure */ protected configureRedirectRequest(request: RedirectRequestContract): void; /** * Creates an authenticated HTTP request with the proper authorization * header for Facebook API calls. * * @param url - The API endpoint URL * @param token - The access token */ protected getAuthenticatedRequest(url: string, token: string): HttpClient; /** * Fetches the authenticated user's profile information from the Facebook API. * * @param token - The access token * @param callback - Optional callback to customize the API request * * @see https://developers.facebook.com/docs/graph-api/reference/user/ */ protected getUserInfo(token: string, callback?: (request: ApiRequestContract) => void): Promise<{ id: any; name: any; nickName: any; avatarUrl: any; email: any; emailVerificationState: "verified" | "unverified" | "unsupported"; original: any; }>; /** * Check if the error from the callback indicates that the user * denied authorization. */ accessDenied(): boolean; /** * Get the authenticated user's profile information using * the authorization code from the callback request. * * @param callback - Optional callback to customize the API request * * @example * ```ts * const user = await ally.use('facebook').user() * console.log(user.name, user.email) * ``` */ user(callback?: (request: ApiRequestContract) => void): Promise<{ token: FacebookToken; id: any; name: any; nickName: any; avatarUrl: any; email: any; emailVerificationState: "verified" | "unverified" | "unsupported"; original: any; }>; /** * Get the user's profile information using an existing * access token. * * @param token - The Facebook access token * @param callback - Optional callback to customize the API request * * @example * ```ts * const user = await ally.use('facebook').userFromToken(accessToken) * ``` */ userFromToken(token: string, callback?: (request: ApiRequestContract) => void): Promise<{ token: { token: string; type: "bearer"; }; id: any; name: any; nickName: any; avatarUrl: any; email: any; emailVerificationState: "verified" | "unverified" | "unsupported"; original: any; }>; }