@kephas/ngx-oidc
Version:
Provides the integration of the OIDC API with Kephas and Angular 12+.
102 lines (101 loc) • 3.88 kB
TypeScript
import { Profile, User, UserManager } from 'oidc-client';
import { BehaviorSubject, Observable } from 'rxjs';
import { AuthenticationSettingsProvider } from './authentication.settings';
import * as i0 from "@angular/core";
export declare type IAuthenticationResult = SuccessAuthenticationResult | FailureAuthenticationResult | RedirectAuthenticationResult;
export interface SuccessAuthenticationResult {
status: AuthenticationResultStatus.Success;
state: any;
}
export interface FailureAuthenticationResult {
status: AuthenticationResultStatus.Fail;
message: string | Error;
}
export interface RedirectAuthenticationResult {
status: AuthenticationResultStatus.Redirect;
}
export declare enum AuthenticationResultStatus {
Success = 0,
Redirect = 1,
Fail = 2
}
export interface IUser extends Profile {
name?: string;
}
export declare class AuthenticationService {
protected readonly settingsProvider: AuthenticationSettingsProvider;
private _lastActivityTime?;
/**
* Creates an instance of AuthorizeService.
* @param {AuthenticationSettingsProvider} settingsProvider The settings provider.
* @memberof AuthorizeService
*/
constructor(settingsProvider: AuthenticationSettingsProvider);
protected userManager?: UserManager;
protected readonly userSubject: BehaviorSubject<IUser | null>;
protected readonly rawUserSubject: BehaviorSubject<User | null>;
/**
* Gets the time of user's last activity.
*
* @readonly
* @type {(Date | undefined)}
* @memberof AuthorizeService
*/
get lastActivityTime(): Date | undefined;
/**
* Gets an observable indicating whether the user is authenticated.
*
* @return {*} {Observable<boolean>}
* @memberof AuthorizeService
*/
isAuthenticated(): Observable<boolean>;
/**
* Gets an observable retrieving the user.
*
* @return {*} {(Observable<IUser | null | undefined>)}
* @memberof AuthorizeService
*/
getUser(): Observable<IUser | null | undefined>;
/**
* Gets an observable containing the access token of the signed-in user.
*
* @return {*} {(Observable<string | undefined>)}
* @memberof AuthorizeService
*/
getAccessToken(): Observable<string | undefined>;
/**
* Notifies the authorization service that the user is active.
*
* @memberof AuthorizeService
*/
touch(): void;
/**
* Sign in the user.
* We try to authenticate the user in three different ways:
* 1) We try to see if we can authenticate the user silently. This happens
* when the user is already logged in on the IdP and is done using a hidden iframe
* on the client.
* 2) We try to authenticate the user using a PopUp Window. This might fail if there is a
* Pop-Up blocker or the user has disabled PopUps.
* 3) If the two methods above fail, we redirect the browser to the IdP to perform a traditional
* redirect flow.
*
* @param {*} state
* @return {*} {Promise<IAuthenticationResult>}
* @memberof AuthorizeService
*/
signIn(state: any): Promise<IAuthenticationResult>;
completeSignIn(url: string): Promise<IAuthenticationResult>;
signOut(state: any): Promise<IAuthenticationResult>;
completeSignOut(url: string): Promise<IAuthenticationResult>;
protected ensureUserManagerInitialized(): Promise<void>;
private ensurePopupEnabled;
private createArguments;
private error;
private success;
private redirect;
private getUserFromStorage;
private setUser;
static ɵfac: i0.ɵɵFactoryDeclaration<AuthenticationService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<AuthenticationService>;
}