import { AxiosRequestConfig } from "axios";
import * as contracts from "@codiac.io/codiac-common/contracts";
import { classDef, httpRestVerb, IBetterLogger } from "@codiac.io/codiac-common";
import { TenantUser, AuthTenant } from "@codiac.io/codiac-common/security";
import { ApiClientBase } from "../api-client-base";
import { IAuthClient } from "./i-auth-client";
import { AuthConstants } from "./auth-constants";
import { TokenHolder } from "./token-holder";
/** Contains hard-coded Codiac Auth methods.
 * It is considered legacy because it is to be replaced by methods generated from an openApi spec. */
export declare class ApiAuthMethodsLegacy implements IAuthClient {
    private core;
    private logger;
    /** Hardcoded to match the current setting on the server.
     * TODO: Get this from a config that is copied from the server project to the client project on build.
     */
    static TOKEN_HEADER_PARAM: string;
    constructor(core: ApiClientBase, logger: IBetterLogger);
    /** The name of the http request header that declares the authentication token for the request.
     *  NOTE: This gets set to DEFAULT_TOKEN_HEADER_NAME in the ctor of ApiClientBase,
     *        so child classes can override it in their own ctor AFTER calling super(). */
    protected tokenHeaderName: string;
    protected authConstants: AuthConstants;
    /** Logs in remotely with the given credentials.
     * Returns a valid token in the headers of the response
     * and the user info in the body of the response.
     * NOTE: If successful, keeps the returned auth token in scope for this client instance.
     * @param login The human readable unique identifier for the user.
     * @param password the secret held for this particular user.
     * @param tenantCode (optional) Unique identifier of the tenant to activate with this authentication.
     */
    authenticate(login: string, password: string, tenantCode?: string): Promise<contracts.SingleResult<TokenHolder>>;
    /** Traps the errors thrown by axios on non-200 statuses. */
    protected executeAxiosRequest<TRequest, TResponse extends contracts.Result>(verb: httpRestVerb, responseType: classDef<TResponse>, url: string, request?: TRequest, options?: AxiosRequestConfig): Promise<{
        data: TResponse;
        headers?: any;
        status: number;
        statusText: string;
    }>;
    /** Replaces the user in the output with a TokenHolder so that they client consumer has access to the token.
     * throws if the axios response does not contain a data property. */
    private convertToTokenHolderResult;
    /** Replaces the user in the output with a TokenHolder so that they client consumer has access to the token.
     * throws if the axios response does not contain a data property.
     * @deprecated Use `convertToTokenHolderResult()` instead.*/
    private convertToTokenHolderResponse;
    /** Determines whether the given token is expired.
     * @param throwOnError throws any encountered errors, including token parsing errors.
     */
    isExpired(token: string, throwOnError?: boolean): boolean;
    extractTokenExpiration(token: string): Date | undefined;
    /** Provides the ability to extend an existing token.
     *  Returns failure for invalid or revoked tokens.
     *  Returns any errors encountered refreshing.
     *  NOTE: If successful, keeps the returned auth token in scope for this client instance.
     * @param currentToken The JWT token returned in a prior request.
     * */
    refreshToken(currentToken: string): Promise<contracts.SingleResult<TokenHolder>>;
    /** Retrieves the full account info for the current user (minus any passwords),
     *  including all tenant profiles.
     *  Returns failure for invalid or revoked tokens.
     *  Returns any errors encountered refreshing.
     *  NOTE: keeps the returned auth token in scope for this client instance.
     * @param currentToken (optional if the client instance has already authenticated) The JWT token returned in a prior request.
     */
    whoAmI(currentToken?: string): Promise<contracts.SingleResult<TenantUser>>;
    /** Provides the ability to extend an existing token.
     *  Returns failure for invalid or revoked tokens.
     *  NOTE: If successful, keeps the returned auth token in scope for this client instance.
     * @param currentToken The JWT token returned in a prior request.
     * @param tenantCode Unique identifier of the tenant being switched to.
     *  Returns any errors encountered refreshing.  */
    switchTenant(currentToken: string, tenantCode: string): Promise<contracts.SingleResult<TokenHolder>>;
    /** Declares a new organization in the toyhauler system.
     * The given user account is made the administrator for that organization,
     * and if the new user flag is given,
     * the user account will get created.
     * NOTE: If successful, keeps the returned auth token in scope for this client instance.
     * @param tenantName Human readable friendly title for the tenant.  NOT used for system identification.
     * @param newUser Flag to create a new user account with the given credentials.
     * @param userName User to be the adminstrator for the new tenant.
     * @param password Password for the given user (desired password if the newuser flag is set).
     * @param tenantCode (optional) Desired unique identifier for the new tenant (if omitted one will be generated).
     * @param currentToken The JWT token returned in a prior request.
     *  */
    registerTenant(tenantName: string, newUser: boolean, userName: string, password: string, tenantCode?: string, currentToken?: string): Promise<contracts.SingleResult<AuthTenant>>;
}
