import { OAuthEvents, OAuthService, OAuthServiceParameters, RequestFilter, WebContext } from "@webda/core";
import { Credentials, OAuth2Client } from "google-auth-library";
export interface EventGoogleOAuthToken {
    /**
     * Tokens retrieved from Google
     */
    tokens: Credentials;
    /**
     * Request context
     */
    context: WebContext;
}
/**
 * Credentials to manage Google Auth
 * https://developers.google.com/identity/protocols/oauth2
 */
export declare class GoogleParameters extends OAuthServiceParameters {
    /**
     * Google Auth Client id
     */
    client_id: string;
    /**
     * Google Auth Client secret
     */
    client_secret: string;
    /**
     * Google Project ID
     */
    project_id?: string;
    /**
     * Type of access for Google token
     *
     * online by default
     */
    access_type?: "online" | "offline";
    auth_options?: any;
    redirects: {
        use_referer: boolean;
        whitelist: string[];
        defaults: {
            [key: string]: string;
        };
    };
    constructor(params: any);
}
type GoogleAuthEvents = OAuthEvents & {
    "GoogleAuth.Tokens": EventGoogleOAuthToken;
};
/**
 * Manage Google Authentication
 *
 * @WebdaModda
 */
export default class GoogleAuthentication<T extends GoogleParameters = GoogleParameters> extends OAuthService<T, GoogleAuthEvents> implements RequestFilter<WebContext> {
    protected _client: OAuth2Client;
    /**
     * Return provider name
     * @returns
     */
    getName(): string;
    /**
     * Allow every accounts.google.
     */
    getCallbackReferer(): RegExp[];
    /**
     * Get OAuth callback query parameters
     * @returns
     */
    getCallbackQueryParams(): {
        name: string;
        required: boolean;
    }[];
    /**
     * Expose on /google by default
     */
    getDefaultUrl(): string;
    /**
     * We manage Google Auth Token
     */
    hasToken(): boolean;
    /**
     * @inheritdoc
     */
    loadParameters(params: any): GoogleParameters;
    /**
     *
     * @param redirect_uri
     * @param state
     */
    generateAuthUrl(redirect_uri: string, state: string, _ctx: WebContext): string;
    /**
     * Return a google oauth client
     * @param redirect_uri
     */
    getOAuthClient(redirect_uri?: string): OAuth2Client;
    /**
     * @inheritdoc
     */
    handleCallback(ctx: WebContext): Promise<{
        identId: any;
        profile: any;
    }>;
    /**
     * Retrieve the user profile based on the token
     * @param token
     * @returns
     */
    getUserInfo(token: string): Promise<import("google-auth-library").TokenPayload>;
    /**
     * Verify a Google Auth Token
     */
    handleToken(context: WebContext): Promise<{
        identId: string;
        profile: import("google-auth-library").TokenPayload;
    }>;
    /**
     * Retrieve Google Client
     *
     * Redirecting to the webbrowser for the OAuth validation
     * Store the token in user store afterwards
     */
    getLocalClient(token: Credentials, open: (url: string) => void, storeToken: (token: Credentials) => Promise<void>): Promise<OAuth2Client>;
}
export { GoogleAuthentication };
