import type { HttpContext } from '@adonisjs/core/http'; import type { HttpClient } from '@poppinss/oauth-client'; import type { TwitterXToken, TwitterXScopes, ApiRequestContract, TwitterXDriverConfig, RedirectRequestContract } from '../types.ts'; import { Oauth2Driver } from '../abstract_drivers/oauth2.ts'; /** * X OAuth2 driver for authenticating users via the OAuth 2.0 authorization * code flow with PKCE. */ export declare class TwitterXDriver extends Oauth2Driver { config: TwitterXDriverConfig; /** * X token endpoint URL. */ protected accessTokenUrl: string; /** * X authorization endpoint URL. */ protected authorizeUrl: string; /** * X user profile endpoint URL. */ protected userInfoUrl: string; /** * The param name for the authorization code */ protected codeParamName: string; /** * The param name for the error */ protected errorParamName: string; /** * Cookie name for storing the "twitter_x_oauth_state" */ protected stateCookieName: string; /** * Cookie name for storing the PKCE code verifier */ protected codeVerifierCookieName: string; /** * Parameter name to be used for sending and receiving the state from X */ protected stateParamName: string; /** * Parameter name for defining the scopes */ protected scopeParamName: string; /** * Scopes separator */ protected scopesSeparator: string; /** * Create a new X driver instance. * * @param ctx - The current HTTP context. * @param config - X driver configuration. */ constructor(ctx: HttpContext, config: TwitterXDriverConfig); /** * Configures the redirect request with X-specific requirements. * * @param request - The redirect request to configure. */ protected configureRedirectRequest(request: RedirectRequestContract): void; /** * Configures the token request with the PKCE verifier and the Basic auth * header required for confidential X clients. * * @param request - The token request to configure. */ protected configureAccessTokenRequest(request: ApiRequestContract): void; /** * Creates an authenticated request for X API calls. * * @param url - The API endpoint URL. * @param token - The access token to send. * @returns A configured HTTP client instance. */ protected getAuthenticatedRequest(url: string, token: string): HttpClient; /** * Fetches the authenticated user's profile from /2/users/me. * * @param token - The access token to use. * @param includeConfirmedEmail - Whether to request the confirmed email field. * @param callback - Optional callback to customize the API request. */ protected getUserInfo(token: string, includeConfirmedEmail: boolean, callback?: (request: ApiRequestContract) => void): Promise<{ id: any; nickName: any; name: any; email: any; emailVerificationState: "unsupported"; avatarUrl: any; original: any; }>; /** * Check if the error from the callback indicates that the user denied * authorization. * * @returns `true` when the provider reported an access-denied error. */ accessDenied(): boolean; /** * Fetches the authenticated user using the authorization code from the * callback request. * * @param callback - Optional callback to customize the API request. */ user(callback?: (request: ApiRequestContract) => void): Promise<{ token: TwitterXToken; id: any; nickName: any; name: any; email: any; emailVerificationState: "unsupported"; avatarUrl: any; original: any; }>; /** * Fetches the user profile using an existing access token. * * @param token - The access token to use. * @param callback - Optional callback to customize the API request. */ userFromToken(token: string, callback?: (request: ApiRequestContract) => void): Promise<{ token: { token: string; type: "bearer"; }; id: any; nickName: any; name: any; email: any; emailVerificationState: "unsupported"; avatarUrl: any; original: any; }>; }