import * as i0 from '@angular/core';
import { InjectionToken, Provider } from '@angular/core';
import * as rxjs from 'rxjs';
import { Observable } from 'rxjs';
import { RouterStateSnapshot } from '@angular/router';
import { AuthProvider, UserInfo } from '@dbg-riskit/common';

type AuthFlowNames = 'openid-connect/authorization-code' | 'openid-connect/implicit' | 'openid-connect/hybrid' | 'openid-connect/direct';
declare class AuthFlow {
    private readonly _type;
    private static readonly CONSTANTS_MAP;
    static readonly AUTHORIZATION_CODE: AuthFlow;
    static readonly IMPLICIT: AuthFlow;
    static readonly HYBRID: AuthFlow;
    static readonly DIRECT: AuthFlow;
    private constructor();
    get type(): string;
    static byType(type: AuthFlowNames): AuthFlow;
}
type AuthSpecScopes = 'profile' | 'group' | 'email' | 'address' | 'phone';
interface AuthConfig {
    loginRoute: string;
    afterLoginRedirectRoute: string;
    wellKnown: string;
    clientID: string;
    clientSecret?: string;
    flow: AuthFlow;
    useNonce?: boolean;
    scope?: Array<AuthSpecScopes | string>;
}
declare const AUTH_CONFIG: InjectionToken<AuthConfig>;

declare function provideAuthService(config: () => AuthConfig): Provider[];

declare const authGuard: () => rxjs.Observable<boolean>;

type PartialAuthConfig = Pick<AuthConfig, Exclude<keyof AuthConfig, 'loginRoute' | 'afterLoginRedirectRoute'>>;
declare function readAuthConfig(): PartialAuthConfig;

declare class AuthRoutingFlowService {
    private readonly router;
    private readonly http;
    private readonly authService;
    private readonly storage;
    private readonly authConfig;
    private readonly wellKnownService;
    constructor();
    get authFlow(): AuthFlow;
    get authorizationCodeFlow(): boolean;
    get implicitFlow(): boolean;
    get hybridFlow(): boolean;
    get directFlow(): boolean;
    logout(state?: RouterStateSnapshot): Observable<boolean>;
    login(username?: string, password?: string): Observable<boolean>;
    loginViaService(): Observable<boolean>;
    storeRequestedPath(state?: RouterStateSnapshot): void;
    private loginRedirect;
    private doLogin;
    static ɵfac: i0.ɵɵFactoryDeclaration<AuthRoutingFlowService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<AuthRoutingFlowService>;
}

interface AuthResponse {
    id_token?: string | null;
    access_token?: string | null;
    refresh_token?: string | null;
    nonce?: string;
    token_type?: string;
}

declare class AuthService implements AuthProvider {
    private readonly authConfig;
    private readonly wellKnownService;
    private readonly http;
    private readonly storage;
    private readonly _loggedInStream;
    private tokenData?;
    private refreshTimeout?;
    private authCheckInterval?;
    private readonly redirectURL;
    private readonly openIDScope;
    private readonly _initService;
    constructor();
    get loggedIn(): Observable<boolean>;
    get userProfile(): Observable<UserInfo | undefined>;
    get loggedInStream(): Observable<boolean>;
    emitLoginStatusChange(status: boolean): void;
    loginViaAuthService(): Observable<boolean>;
    checkLocationForLoginData(): Observable<boolean>;
    private checkParametersHybridFlow;
    private checkParametersAuthCodeFlow;
    private checkParametersImplicitFlow;
    private requestTokenBasedOnCode;
    directLogin(username: string, password: string): Observable<boolean>;
    processToken(response: AuthResponse, syncTime?: boolean): Observable<boolean>;
    private validateResponseNonce;
    private static validateResponseTokenType;
    private storeTokensIfValid;
    private afterLogin;
    logout(): Observable<never>;
    private setupAuthCheck;
    private disableAuthCheck;
    private checkAuth;
    private setupTokenRefresh;
    private disableTokenRefresh;
    private tryToRefresh;
    refreshToken(): void;
    private validateToken;
    private static checkTokenExpiration;
    private checkTokenNonce;
    private static checkTokenIssuer;
    private checkTokenAudience;
    static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
}

declare class AuthStorageService {
    private readonly logger;
    idToken?: string | null;
    accessToken?: string | null;
    refreshToken?: string | null;
    private _timeSyncDiff?;
    nonce?: string | null;
    authRequestedPath?: string | null;
    syncTime(): void;
    private get exp();
    get refresh_in(): number;
    clear(): void;
    static ɵfac: i0.ɵɵFactoryDeclaration<AuthStorageService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<AuthStorageService>;
}

interface WellKnown {
    endpoints: {
        auth: string;
        token: string;
        logout: string;
    };
    issuer: string;
}

export { AUTH_CONFIG, AuthFlow, AuthRoutingFlowService, AuthService, AuthStorageService, authGuard, provideAuthService, readAuthConfig };
export type { AuthConfig, WellKnown };
