import { Router } from '@angular/router'; import { BehaviorSubject, ReplaySubject, Observable } from 'rxjs'; import { ApiService, TokenService } from '../../api'; import { Environment } from '../../interfaces'; import { EnvironmentService } from '../../services/environment.service'; import { HttpClient } from '@angular/common/http'; import { TokenResponse } from '../../api/interfaces/token.response'; import { LoginBase } from '../models'; import { AuthenticationUserResponse } from '../interfaces/authentication-user.response'; export declare abstract class AuthenticationService { protected readonly environmentService: EnvironmentService; protected readonly tokenService: TokenService; protected readonly apiService: ApiService; protected readonly router: Router; protected readonly http: HttpClient; /** * The current, loged in user. * * @type {(T | null)} * @memberof UserAuthenticationService */ currentUser: Observable; currentUserResponse: Observable; /** * Defines if the client is authenticated. * * @type {Observable} * @memberof UserAuthenticationService */ isAuthenticated: Observable; /** * Internal user subject. * * @protected * @memberof UserAuthenticationService */ currentUserSubject: BehaviorSubject; currentUserResponseSubject: BehaviorSubject; constructor(environmentService: EnvironmentService, tokenService: TokenService, apiService: ApiService, router: Router, http: HttpClient); /** * Redirect Uri. * * @protected * @memberof AuthenticationService */ protected redirectUri: string; /** * Internal authentication flag. * * @protected * @memberof UserAuthenticationService */ protected readonly isAuthenticatedSubject: ReplaySubject; /** * Environment from the CoreModule. * * @protected * @type {Environment} * @memberof UserAuthenticationService */ protected readonly environment: Environment; /** * Headers. * * @protected * @memberof UserAuthenticationService */ protected readonly header: {}; /** * This runs once on application startup. * * @param {boolean} [navigation=true] Defines, if you would like to navigate to login. * @returns {Observable} * @memberof UserAuthenticationService */ initialize(navigation?: boolean, params?: Object): void; /** * This function does the logout. Removes the tokens, and removes the user. * * @param {boolean} [navigation=true] * @memberof UserAuthenticationService */ purgeAuth(navigation?: boolean): void; /** * This function registrate one user to the API. * * @abstract * @param {{ * firstName: string; * lastName: string; * email: string; * password: string; * passwordConfirmation: string; * }} user * @returns {Observable} * @memberof UserAuthenticationService */ abstract registrateUser(user: { firstName: string; lastName: string; email: string; password: string; passwordConfirmation: string; }): Observable; /** * This function gains the Tokens from the API. * * @abstract * @param {LoginBase} loginData * @returns {Observable} * @memberof UserAuthenticationService */ abstract obtainAccessToken(loginData: LoginBase): Observable; /** * This function resets the Access token. * * @protected * @abstract * @param {string} token * @returns {Observable} * @memberof UserAuthenticationService */ protected abstract refreshAccessToken(token: string): Observable; /** * This function handles the actions after a successful authentication. * * @protected * @param {boolean} res * @returns * @memberof UserAuthenticationService */ protected handleSuccess(res: TokenResponse): boolean; /** * This method stores the tokens, and fires the logged in events. * * @protected * @param {T} user * @memberof UserAuthenticationService */ protected setAuth(user: T): void; }