import { ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, CanActivateFn } from '@angular/router'; import { StorageOption, StorageStrategy } from '@bravobit/bb-foundation/storage'; import * as i0 from '@angular/core'; import { InjectionToken, OnInit, OnDestroy, TemplateRef, EnvironmentProviders, ModuleWithProviders } from '@angular/core'; import * as _angular_common_http from '@angular/common/http'; import { HttpClient, HttpContextToken, HttpInterceptor, HttpRequest, HttpHandler, HttpHeaders, HttpParams } from '@angular/common/http'; import * as rxjs from 'rxjs'; import { Observable } from 'rxjs'; interface AuthToken { id?: string; type?: string; audience?: string; issuer?: string; subject?: string; notValidBefore?: Date; expiresAt?: Date; issuedAt?: Date; role?: string; } type AuthStrategy = 'httpOnlyCookie' | 'browserStorage'; interface AuthConfig { applicationId: string; strategy: AuthStrategy; preferredStorageOptions?: StorageOption[]; http?: { scheme?: string; header?: string; }; redirects?: { authenticated?: string | string[]; unauthenticated?: string | string[]; }; setRedirectOnFailedAuth?: boolean; interceptActing?: boolean; providers?: string[]; autoRefresh?: boolean; } declare const AUTH_CONFIG: InjectionToken; declare const AUTH_REDIRECT_HANDLER: InjectionToken; interface AuthRedirectHandler { onFailedAuthenticated(snapshot?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): boolean | UrlTree; onFailedAnonymous(snapshot?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): boolean | UrlTree; } interface AuthProvider { authenticate(httpClient: HttpClient): Promise; } interface AuthProviderResponse { token: string; refresh_token?: string; provider?: string; verify_token?: string; user?: any; } interface AuthProviderResult { accessToken?: string; refreshToken?: string; provider?: string; verifyToken?: string; user?: any; } interface AuthSignInResponse { user?: unknown; provider?: string; verifyToken?: string; } declare const USE_AUTHORIZATION: HttpContextToken; declare class JwtHelper { decode(token: string): AuthToken; private urlDecode; private baseDecodeUnicode; private parse; private parseDate; } declare class BbAuthenticated implements OnInit, OnDestroy { private readonly _auth; private readonly _templateRef; private readonly _viewContainerRef; private _valid; private _elseTemplateRef; private _thenViewRef; private _elseViewRef; private _subscription; set bbAuthenticatedElse(templateRef: TemplateRef); ngOnInit(): void; ngOnDestroy(): void; private updateView; private assertTemplate; static ngAcceptInputType_bbAuthenticatedElse: TemplateRef; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class BbAnonymous implements OnInit, OnDestroy { private readonly _auth; private readonly _templateRef; private readonly _viewContainerRef; private _valid; private _elseTemplateRef; private _thenViewRef; private _elseViewRef; private _subscription; set bbAnonymousElse(templateRef: TemplateRef); ngOnInit(): void; ngOnDestroy(): void; private updateView; private assertTemplate; static ngAcceptInputType_bbAnonymousElse: TemplateRef; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare const bbAnonymousGuard: CanActivateFn; declare const bbAuthenticatedGuard: CanActivateFn; declare class AuthEmailProvider implements AuthProvider { private _email; private _password; private _endpoint; constructor(_email: string, _password: string, _endpoint: string); authenticate(httpClient: HttpClient): Promise; } declare class AuthVerifyProvider implements AuthProvider { private _code; private _verifyToken; private _endpoint; constructor(_code: string, _verifyToken: string, _endpoint: string); authenticate(httpClient: HttpClient): Promise; } declare class Acting { private readonly _auth; private _userId$; readonly info$: Observable<{ active?: boolean; user?: any; }>; start(userId: number): Promise; stop(): Promise; getCurrent(): number; private fetchUserDetails; private getInfo; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class ActingInterceptor implements HttpInterceptor { private readonly _acting; private readonly _headerString; intercept(request: HttpRequest, next: HttpHandler): rxjs.Observable<_angular_common_http.HttpEvent>; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class AuthSession { private readonly _jwt; private readonly _storage; private readonly _accessTokenStorageKey; private readonly _refreshTokenStorageKey; private readonly _authenticatedStorageKey; private readonly _strategy; private _authenticated; private _accessTokenString; private _refreshTokenString; private _accessTokenPayload; private _refreshTokenPayload; private _user$; user: rxjs.Observable; constructor(options?: { id?: string; storage?: StorageStrategy; strategy?: AuthStrategy; }); get snapshot(): { user: any; accessToken?: undefined; refreshToken?: undefined; } | { user: any; accessToken: string; refreshToken: string; }; get accessToken(): string; get refreshToken(): string; get accessTokenPayload(): AuthToken; get refreshTokenPayload(): AuthToken; authenticated(): boolean; setTokens(accessToken: string | null, refreshToken: string | null, persist?: boolean): void; setUser(user: unknown, persist?: boolean): void; clear(): void; private restoreFromStorage; private persistTokensInStorage; private persistAuthenticatedInStorage; private setAuthenticated; private cacheAccessToken; private cacheRefreshToken; private cacheAuthenticated; private generateKey; private isTokenValid; private getNextYearDate; } declare class Auth { private readonly _storage; private readonly _injector; private readonly _platform; private readonly _httpClient; private readonly _state?; private readonly _config?; private readonly _httpConfig?; private readonly _handler?; private readonly _authStateKey; private readonly _httpAlias; readonly session: AuthSession; readonly user: Observable; private _refreshHandler; constructor(); initialize(): Promise; me(): Observable; signIn(provider: AuthProvider, verify?: (user: T) => void): Promise; signInWithEmail(email: string, password: string, verify?: (user: T) => void): Promise; signInWithVerifyCode(code: string, verifyToken: string): Promise; resendVerifyCode(verifyToken: string): Promise; register(data: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; params?: HttpParams | { [param: string]: string | number | boolean | ReadonlyArray; }; }): Promise; logout(): void; refresh(): Observable; requestPassword(email: string, extraParams?: { [key: string]: any; }): Promise; resetPassword(token: string, newPassword: string, extraParams?: { [key: string]: any; }): Promise; clearAndRedirect(): void; private setTokens; private handleAutoRefreshing; private autoRefresh; private get router(); private getUrl; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare function provideAuthConfig(config?: AuthConfig): EnvironmentProviders; declare class AuthModule { static forRoot(config: AuthConfig): ModuleWithProviders; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { AUTH_CONFIG, AUTH_REDIRECT_HANDLER, Acting, ActingInterceptor, Auth, AuthEmailProvider, AuthModule, AuthSession, AuthVerifyProvider, BbAnonymous, BbAuthenticated, JwtHelper, USE_AUTHORIZATION, bbAnonymousGuard, bbAuthenticatedGuard, provideAuthConfig }; export type { AuthConfig, AuthProvider, AuthProviderResponse, AuthProviderResult, AuthRedirectHandler, AuthSignInResponse, AuthStrategy, AuthToken };