import { Injector } from '@angular/core';
import { BasicAuth, CookieAuth, FetchClient, IAuthentication, ICredentials, IFetchResponse, ITenantLoginOption, Realtime, TenantLoginOptionsService, TenantService, UserService } from '@c8y/client';
import { AppStateService } from '../common/ui-state.service';
import { AlertService } from '../alert/alert.service';
import { ApiService } from '@c8y/ngx-components/api';
import { TenantUiService } from '../common/tenant-ui.service';
import { BehaviorSubject } from 'rxjs';
import { LocationStrategy } from '@angular/common';
import { TranslateService } from '@ngx-translate/core';
import { ModalService } from '../modal/modal.service';
import { SsoData } from './login.model';
import * as i0 from "@angular/core";
/**
 * Service to manage the login.
 */
export declare class LoginService {
    private injector;
    private client;
    private basicAuth;
    private cookieAuth;
    private ui;
    private user;
    private tenant;
    private realtime;
    private alert;
    private api;
    private tenantUiService;
    private tenantLoginOptionsService;
    private translateService;
    private modalService;
    private location;
    rememberMe: boolean;
    TOKEN_KEY: string;
    TFATOKEN_KEY: string;
    loginMode: ITenantLoginOption;
    managementLoginMode: ITenantLoginOption;
    oauthOptions: ITenantLoginOption;
    isFirstLogin: boolean;
    GREEN_MIN_LENGTH_DEFAULT: number;
    automaticLoginInProgress$: BehaviorSubject<boolean>;
    ERROR_MESSAGES: {
        minlength: "Password must have at least 8 characters and no more than 32.";
        password_missmatch: "Passwords do not match.";
        maxlength: "Password must have at least 8 characters and no more than 32.";
        password_strength: "Your password is not strong enough. Please include numbers, lower and upper case characters";
        remote_error: "Server error occurred.";
        email: "Invalid email address.";
        password_change: "Your password is expired. Please set a new password.";
        password_reset_token_expired: "Password reset link expired. Please enter your email address to receive a new one.";
        tfa_pin_invalid: "The code you entered is invalid. Please try again.";
        pattern_newPassword: any;
        internationalPhoneNumber: "Must be a valid phone number (only digits, spaces, slashes (\"/\"), dashes (\"-\"), and plus (\"+\") allowed, for example: +49 9 876 543 210).";
        phone_number_error: "Could not update phone number.";
        pinAlreadySent: "The verification code was already sent. For a new verification code, please click on the link above.";
        passwordConfirm: "Passwords do not match.";
        tfaExpired: "Two-factor authentication token expired.";
    };
    private SUCCESS_MESSAGES;
    private passwordStrengthSetting;
    private localhostRegExp;
    private localhostIpRegExp;
    private showTenantRegExp;
    constructor(injector: Injector, client: FetchClient, basicAuth: BasicAuth, cookieAuth: CookieAuth, ui: AppStateService, user: UserService, tenant: TenantService, realtime: Realtime, alert: AlertService, api: ApiService, tenantUiService: TenantUiService, tenantLoginOptionsService: TenantLoginOptionsService, translateService: TranslateService, modalService: ModalService, location: LocationStrategy);
    /**
     * Returns the current tenant.
     * @return The tenant name.
     */
    getTenant(): string;
    initLoginOptions(): void;
    redirectToOauth(): void;
    loginBySso({ code, sessionState }: SsoData): Promise<IFetchResponse>;
    autoLogout(): void;
    /**
     * Gets the minimal number of characters that a password should have to be considered a “green” strong one.
     * @return The min length for password or default value.
     */
    getGreenMinLength(): Promise<number>;
    /**
     * Checks if password strength is enforced for system
     * by retrieving value of `enforceStrength` property from loginOptions response
     * @param refresh boolean used to refresh the app state where result of loginOptions response is stored.
     * If false, it takes value from memory,
     * if true, it refresh the app state value and then retrives data.
     * @return boolean value, true if enforced, false otherwise.
     */
    getEnforcePasswordStrength(refresh?: any): Promise<boolean>;
    /**
     * Checks if password strength is enforced for particular tenant
     * by retrieving value of `strengthValidity` property from loginOptions response
     * @param refresh boolean used to refresh the app state where result of loginOptions response is stored.
     * If false, it takes value from memory,
     * if true, it refresh the app state value and then retrives data.
     * @return boolean value, true if enforced, false otherwise.
     */
    getPasswordStrengthValidity(refresh?: any): Promise<boolean>;
    /**
     * Function determines if enforced strength checks should be enabled for current tenant
     * based on properties retrieved from loginOptions
     * @param options object containing specific options:
     *    - {refresh: true} - refreshes values of app state and returns fresh values as result of call
     * @return boolean value, true if strength is enforced for tenant, false otherwise.
     */
    getPasswordStrengthEnforced(options?: any): Promise<boolean>;
    /**
     * Clears all backend errors.
     */
    cleanMessages(): void;
    /**
     * Adds a new success message
     * @param successKey The key of the success message as used in SUCCESS_MESSAGES
     */
    addSuccessMessage(successKey: string): void;
    /**
     * Returns the current strategy. Defaults to cookie, if a token
     * is found in local or session storage we switch to basic auth.
     * @returns The current auth strategy.
     */
    getAuthStrategy(): IAuthentication;
    /**
     * Forces the use of basic auth as strategy with this credentials.
     * @param credentials The credentials to use.
     */
    useBasicAuth(credentials: ICredentials): BasicAuth;
    /**
     * Tries to login a user with the given credentials.
     * If successful, the current tenant and user is set. If not an error
     * is thrown. It also verifies if the user is allowed to open the
     * current app.
     * @param auth The authentication strategy used.
     * @param credentials The credentials to try to login.
     */
    login(auth?: IAuthentication, credentials?: ICredentials): Promise<void>;
    /**
     * Saves tenant, user and support user info to the app state.
     * @param tenant The current tenant object.
     * @param user The current user object.
     * @param supportUserName The current support user name.
     */
    authFulfilled(tenant?: any, user?: any, supportUserName?: any): Promise<void>;
    /**
     * Switch the login mode to CookieAuth if the
     * user has configured to use it in loginOptions.
     * @param credentials The credentials for that login
     */
    switchLoginMode(credentials?: ICredentials): Promise<boolean>;
    generateOauthToken(credentials?: ICredentials): Promise<IFetchResponse>;
    isPasswordGrantLogin(credentials?: ICredentials): Promise<boolean>;
    /**
     * Verifies if the provided credentials use a support user to log in or not.
     * @param credentials Credentials to check.
     * @returns {boolean} Returns true if user is a support user.
     */
    isSupportUser(credentials?: ICredentials): boolean;
    /**
     * Verifies if the tenant input field should be shown
     * or not.
     * @returns If true, show the tenant input.
     */
    showTenant(): boolean;
    /**
     * Verifies if the tenant setup should be shown
     * or not.
     * @returns If true, show the tenant input.
     */
    showTenantSetup(): boolean;
    /**
     * Logs the user out
     * @param reload If set to false, the page will not reload
     */
    logout(reload?: boolean): Promise<void>;
    /**
     * Resets the stored auth-data
     */
    reset(): Promise<[void, IFetchResponse]>;
    /**
     * Saves the TFA token to local or session storage.
     * @param tfaToken The tfa token to save.
     * @param storage The storage to use (local or session).
     */
    saveTFAToken(tfaToken: string, storage: Storage): void;
    /**
     * Request the manifest -> on 401 user has no access to that application
     * and we throw the error up to the login form.
     */
    verifyAppAccess(): Promise<void>;
    redirectToDomain(domain: any): void;
    showSsoError(error: any): void;
    /**
     * Sets the tenant to the client and updates the credentials on the
     * auth strategy.
     * @param credentials The name of the tenant.
     * @param authStrategy The authentication strategy used.
     * @return Returns the token if basic auth, otherwise undefined.
     */
    private setCredentials;
    /**
     * Verifies if the current user is a developer or not.
     * Running on localhost means development mode.
     */
    private isLocal;
    /**
     * Save the token to local or session storage.
     * @param token The token to save.
     * @param storage The storage to use (local or session).
     */
    private saveToken;
    private storeBasicAuthToken;
    private cleanLocalStorage;
    private cleanSessionStorage;
    private isShowTenant;
    private redirect;
    private getBasicAuthLoginOption;
    /**
     * Gets support user name from credentials.
     * @param credentials Credentials object (defaults to the stored one).
     * @returns Support user name.
     */
    private getSupportUserName;
    /**
     * Gets credentials object from the stored token.
     * @returns Credentials object.
     */
    private getStoredCredentials;
    /**
     * Gets stored token from local storage or session storage.
     * @returns Stored token.
     */
    private getStoredToken;
    /**
     * Gets stored TFA token from local storage or session storage.
     * @returns Stored TFA token.
     */
    private getStoredTfaToken;
    /**
     * Decodes token to credentials object.
     * @param token Token to decode.
     * @returns Credentials object.
     */
    private decodeToken;
    private getUrlForOauth;
    private getManagementLoginMode;
    private handleErrorStatusCodes;
    static ɵfac: i0.ɵɵFactoryDeclaration<LoginService, [null, null, null, null, null, null, null, null, null, null, null, null, null, null, { optional: true; }]>;
    static ɵprov: i0.ɵɵInjectableDeclaration<LoginService>;
}
//# sourceMappingURL=login.service.d.ts.map