import { HttpContext } from '@adonisjs/core/http';
import Configure from '@adonisjs/core/commands/configure';
import { Oauth2DriverConfig, LiteralStringUnion, RedirectRequestContract, ApiRequestContract, AllyUserContract } from '@adonisjs/ally/types';
import * as _adonisjs_ally from '@adonisjs/ally';
import { Oauth2Driver } from '@adonisjs/ally';

/**
 * @julienbenac/ally-orange
 *
 * @author Julien Benac <contact@julienbenac.fr>
 * @license MIT
 */
declare const stubsRoot: string;

/**
 * @julienbenac/ally-orange
 *
 * @author Julien Benac <contact@julienbenac.fr>
 * @license MIT
 */

declare function configure(command: Configure): Promise<void>;

/**
 * @julienbenac/ally-orange
 *
 * @author Julien Benac <contact@julienbenac.fr>
 * @license MIT
 */

interface OrangeDriverConfig extends Oauth2DriverConfig {
    scopes?: LiteralStringUnion<OrangeScopes>[];
}
type OrangeToken = {
    /** The token value. */
    token: string;
    /** The token type. */
    type: 'bearer';
    /** The refresh token. */
    refreshToken?: string;
    /** The static time in seconds when the token will expire. */
    expiresIn: number;
    /** The timestamp at which the token expires. */
    expiresAt: Date;
    /** The identification token (JWT format) for session lifecycle. */
    idToken?: string;
} & Record<string, any>;
type OrangeScopes = 'openid';

/**
 * Orange driver to login user via Orange.
 */
declare class OrangeDriver extends Oauth2Driver<OrangeToken, OrangeScopes> {
    config: OrangeDriverConfig;
    /**
     * The authorization URL for the OAuth provider.
     * The user will be redirected to this page to authorize the request.
     */
    protected authorizeUrl: string;
    /** The URL to hit to get an access token. */
    protected accessTokenUrl: string;
    /** The URL to hit to get user details. */
    protected userInfoUrl: string;
    /** The cookie name for storing the CSRF token. */
    protected stateCookieName: string;
    /**
     * The parameter name in which to send the state to the OAuth provider.
     * The same input is used to retrieve the state post redirect as well.
     */
    protected stateParamName: string;
    /** The parameter name from which to fetch the authorization code. */
    protected codeParamName: string;
    /** The parameter name from which to fetch the error message post redirect. */
    protected errorParamName: string;
    /** The parameter name for defining the authorization scopes. */
    protected scopeParamName: string;
    /** The identifier for joining multiple scopes. */
    protected scopesSeparator: string;
    constructor(ctx: HttpContext, config: OrangeDriverConfig);
    /**
     * Configuring the redirect request with defaults.
     */
    protected configureRedirectRequest(request: RedirectRequestContract<OrangeScopes>): void;
    /**
     * Redirects user for authentication.
     */
    redirect(callback?: (request: RedirectRequestContract<OrangeScopes>) => void): Promise<void>;
    /**
     * Returns the HTTP request with the authorization header set.
     */
    protected getAuthenticatedRequest(url: string, token: string): _adonisjs_ally.ApiRequest;
    /**
     * Fetches the user details.
     */
    protected getUserInfo(token: string, callback?: (request: ApiRequestContract) => void): Promise<Omit<AllyUserContract<OrangeToken>, 'token'>>;
    /**
     * Find if the current error message is access denied.
     */
    accessDenied(): boolean;
    /**
     * Returns details of the authorized user.
     */
    user(callback?: (request: ApiRequestContract) => void): Promise<AllyUserContract<OrangeToken>>;
    /**
     * Finds the user from access token.
     */
    userFromToken(token: string, callback?: (request: ApiRequestContract) => void): Promise<AllyUserContract<{
        token: string;
        type: 'bearer';
    }>>;
}

/**
 * @julienbenac/ally-orange
 *
 * @author Julien Benac <contact@julienbenac.fr>
 * @license MIT
 */

declare function orange(config: OrangeDriverConfig): (ctx: HttpContext) => OrangeDriver;

export { type OrangeToken, configure, orange, stubsRoot };
