import { AuthTenant } from '@codiac.io/codiac-common/security/auth-entities';
import { ProjectConfig, UserContext } from '@codiac.io/codiac-relay-contracts';
import { IBetterLogger } from '@codiac.io/codiac-common/IBetterLogger';
import { IUserInputProvider, IOutputStyler } from '../ops';
import { ProjectContextRepo } from '../ops/data';
import { CliEnviro } from '../ops/entities';
import { IAuthClient } from '../apis/auth-client/i-auth-client';
/** Interfaces with CLI user to establish a tenant context.  */
export declare class TenantContextualizer {
    private cliEnviro;
    private projCfg;
    private authClient;
    private _projCfgRepo;
    private ui;
    private styler;
    private logger;
    static readonly CODE_FOR_NEW_TENANT = "** create new **";
    /**
     * @param projCfg The In-memory representation of the project's thaulconfig file.
     */
    constructor(cliEnviro: CliEnviro, projCfg: ProjectConfig | undefined, authClient: IAuthClient, _projCfgRepo: ProjectContextRepo | undefined, ui: IUserInputProvider, styler: IOutputStyler, logger: IBetterLogger);
    private userContextLoader;
    private userContextRepo;
    /** An authenticated user, freshly retrieved during this process. */
    private _user;
    /** Ensures that a valid tenant is assigned
     * and the user has a valid tenant contributor token.
     *
     * @param currentContext The Machine-user context.  It's just the starting point, not necessarily the right one.  ie: Project config enforcement may switch it on you.
    */
    establishTenantContext(currentContext?: UserContext): Promise<UserContext>;
    /** Checks the given user context and then the machine user configuration for a user profile with the given tenant.
     *
     * Returns a principal user context (undefined currentTenantCode properties) if it doesnt have a matching tenant profile.
     * Returns `undefined` if no context found at all.
     *
     * DOES NOT throw encountered exceptions, so that a login prompt can follow in case something is corrupted.
     *
     * DOES NOT validate or authenticate - merely loads whatever is the local cache.
     */
    private tryMatchGivenOrCached;
    /** Returns a valid tenant context if the given tenant is already current on the given context and the token isnt expired. */
    tryUseCurrentToken(currentContext: UserContext, tenantCode: string): UserContext | undefined;
    /** Attempts to switch the userContext to a locally cached profile for the given tenant,
     * and if not found, requests a switch from the auth service.
     * The current userContext will only be modified if the switch is successfully made.
     * throws is the userContext does not already contain at least one token that will identify the user (regardless of tenant).
     * SIDE-EFFECT:  This may refresh the currentToken on the current user context and cache it to the user context file. */
    trySwitchTenant(currentContext: UserContext, newTenantCode: string): Promise<UserContext | undefined>;
    /** Only diff betw this an authenticate is that
     * this method only returns a valid tenant context
     * (whereas authenticate returns a user or tenant context). */
    private tryAuthenticateUnderTenant;
    trySelectFromMyTenants(currentContext: UserContext | undefined, allowAddNew?: boolean): Promise<UserContext | undefined>;
    /** Side effect: Overwrites this._user if it s able to refresh it from the auth api */
    establishPrincipalContext(context: UserContext | undefined): Promise<UserContext | undefined>;
    private getUserTenants;
    /** Prompts the user to select a tenant from the given list of tenantCodes.
     * Returns undefined if cancelled, and TenantContextualizer.CODE_FOR_NEW_TENANT if "register new" is selected.
     * @param tenants List of tenants from which to select.
     * @param allowAddNew Inserts an option to add a new tenant.  (NOTE: this method DOES NOT perform the add new action itself!)
    */
    promptToSelectTenant(tenants: AuthTenant[], allowAddNew?: boolean): Promise<string | undefined>;
    /** Returns a tenant context, a user context, or undefined if operation cancelled.
     * Caches the new user context.
     * Throws any exceptions.
     *
     * `unregistered` tenant code gets ignored.
     *
     * @param login
     * @param silent (optional: defaults to false) When set to true, suppresses the prompts to confirm the given defaults.  Requires defaultLogin and defaultPassword to be set.  Also requires tenantCode if the current user has more than one tenant profile and it cannot be derived decisively from the current context.
     */
    authenticate(tenantCode?: string, login?: string, password?: string, silent?: boolean): Promise<UserContext | undefined>;
    private isNullOrEmpty;
    tryRegisterNewTenant(currentContext: UserContext | undefined, companyName?: string, tenantCode?: string): Promise<UserContext | undefined>;
    cancel(): void;
    /** logs a user message stating that the current user
     * is not a member of the given tenant,
     * with instructions for what to do next.  */
    private renderNotAMember;
}
