import type { AuthClient } from '../abstract/auth/authClient';
import { ICredentials } from './credentials';
import { LoginTicket } from './loginTicket';
export declare const MAX_RETRY_NUM = 2;
export interface IGenerateAuthUrlOpts {
    scopes: string[];
    state: string;
    codeVerifier?: string;
}
type IOnTokenRefreshedParams = Pick<ICredentials, 'access_token' | 'expiry_date' | 'id_token' | 'token_type' | 'refresh_token'>;
type IOnTokenRefreshed = (params: IOnTokenRefreshedParams) => Promise<void>;
interface IPreFetchParams {
    url: string;
    options: RequestInit;
}
type IPreFetch = (params: IPreFetchParams) => Promise<{
    options: RequestInit;
}>;
export type IIAPHeaderGenerator = () => Promise<string>;
export interface IOptions {
    domain: string;
    clientId?: string;
    clientSecret?: string;
    redirectUri?: string;
    logoutUri?: string;
    responseType?: string;
    responseMode?: string;
    scopes?: string[];
    state?: string;
    nonce?: string | null;
    audience?: string;
    tokenIssuer?: string;
    /**
     * Google IAP認証ヘッダー生成関数
     */
    iapHeaderGenerator?: IIAPHeaderGenerator;
}
export interface IVerifyIdTokenOptions {
    audience?: string | string[];
    maxExpiry?: number;
}
/**
 * OAuth2 client
 */
export declare class OAuth2client implements AuthClient {
    /**
     * The base URL for auth endpoints.
     */
    protected static readonly OAUTH2_AUTH_BASE_URI: string;
    /**
     * The base endpoint for token retrieval.
     */
    protected static readonly OAUTH2_TOKEN_URI: string;
    /**
     * The base endpoint to revoke tokens.
     */
    protected static readonly OAUTH2_LOGOUT_URI: string;
    /**
     * certificates.
     */
    credentials: ICredentials;
    options: IOptions;
    /**
     * 認証クライアントインスタンス内で発生するイベント
     */
    private readonly events;
    constructor(options: IOptions);
    static BASE64URLENCODE(str: Buffer): string;
    static SHA256(buffer: string): NonSharedBuffer;
    /**
     * Generates URL for consent page landing.
     */
    generateAuthUrl(optOpts: IGenerateAuthUrlOpts): string;
    /**
     * Generates URL for logout.
     */
    generateLogoutUrl(): string;
    /**
     * Gets the access token for the given code.
     * @param code The authorization code.
     */
    getToken(code: string, codeVerifier?: string): Promise<ICredentials>;
    /**
     * OAuthクライアントに認証情報をセットします。
     */
    setCredentials(credentials: ICredentials): void;
    refreshAccessToken(): Promise<ICredentials>;
    /**
     * 期限の切れていないアクセストークンを取得します。
     * 必要であれば更新してから取得します。
     */
    getAccessToken(): Promise<string>;
    /**
     * Revokes the access given to token.
     * @param token The existing token to be revoked.
     */
    /**
     * Provides a request implementation with OAuth 2.0 flow.
     * If credentials have a refresh_token, in cases of HTTP
     * 401 and 403 responses, it automatically asks for a new
     * access token and replays the unsuccessful request.
     */
    fetch(url: string, options: RequestInit, expectedStatusCodes: number[], retryableStatusCodes: number[]): Promise<Response>;
    /**
     * IDトークンを検証する
     * 結果にはIDトークンの付加情報が含まれます。
     */
    verifyIdToken(options: IVerifyIdTokenOptions): LoginTicket;
    /**
     * トークン更新イベントハンドラを登録する
     */
    onTokenRefreshed(params: IOnTokenRefreshed): void;
    /**
     * リクエスト送信前イベントハンドラを登録する
     */
    preFetch(params: IPreFetch): void;
    /**
     * Provides a request implementation with OAuth 2.0 flow.
     * If credentials have a refresh_token, in cases of HTTP
     * 401 and 403 responses, it automatically asks for a new
     * access token and replays the unsuccessful request.
     * @param options Request options.
     */
    /**
     * Makes a request without paying attention to refreshing or anything
     * Assumes that all credentials are set correctly.
     * @param opts Options for request
     * @param callback callback function
     */
    /**
     * Makes a request without paying attention to refreshing or anything
     * Assumes that all credentials are set correctly.
     */
    protected makeFetch(url: string, options: RequestInit, expectedStatusCodes: number[]): Promise<Response>;
    /**
     * Refreshes the access token.
     */
    protected refreshToken(refreshToken: string): Promise<ICredentials>;
    /**
     * Verify the id token is signed with the correct certificate
     * and is from the correct audience.
     * @param jwt The jwt to verify (The ID Token in this case).
     * @param requiredAudience The audience to test the jwt against.
     * @param issuers The allowed issuers of the jwt (Optional).
     */
    private verifySignedJwt;
}
export {};
