@indice/ng-auth
Version:
Indice extensions for Angular v20 using oidc-client
153 lines (142 loc) • 6.35 kB
TypeScript
import * as i0 from '@angular/core';
import { OnInit, ElementRef, ModuleWithProviders, InjectionToken } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { User, IdTokenClaims, SignoutResponse } from 'oidc-client-ts';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http';
interface IAuthSettings {
authority: string;
client_id: string;
redirect_uri: string;
post_logout_redirect_uri: string;
response_type: string;
scope: string;
filterProtocolClaims: boolean;
loadUserInfo: boolean;
silent_redirect_uri: string;
extraQueryParams: any;
acr_values?: string;
}
declare class DefaultAuthSettings implements IAuthSettings {
constructor();
authority: string;
client_id: string;
redirect_uri: string;
post_logout_redirect_uri: string;
response_type: string;
scope: string;
filterProtocolClaims: boolean;
loadUserInfo: boolean;
silent_redirect_uri: string;
extraQueryParams: {};
}
declare class SignInRedirectOptions {
location?: string;
promptRegister?: boolean;
tenant?: string;
}
declare class ImgUserPictureDirective implements OnInit {
private authSettings;
private _userId;
private _size;
private _displayName;
private _color;
private _img;
private _version;
private _initialized;
constructor(authSettings: IAuthSettings, element: ElementRef);
ngOnInit(): void;
set setUserId(value: string);
set setSize(value: number);
set setVersion(value: number);
set setDisplayName(value: BaseUser | string);
set setColor(value: string | undefined | null);
private setProfileSrc;
private generateSHA256Hash;
static ɵfac: i0.ɵɵFactoryDeclaration<ImgUserPictureDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<ImgUserPictureDirective, "img[userPicture]", never, { "setUserId": { "alias": "userPicture"; "required": false; }; "setSize": { "alias": "size"; "required": false; }; "setVersion": { "alias": "version"; "required": false; }; "setDisplayName": { "alias": "displayName"; "required": false; }; "setColor": { "alias": "color"; "required": false; }; }, {}, never, never, false, never>;
}
interface BaseUser {
given_name?: string | undefined;
family_name?: string | undefined;
firstName?: string | undefined;
lastName?: string | undefined;
email?: string | undefined;
name?: string | undefined;
userName?: string | undefined;
}
declare class IndiceAuthModule {
static forRoot(): ModuleWithProviders<IndiceAuthModule>;
static ɵfac: i0.ɵɵFactoryDeclaration<IndiceAuthModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<IndiceAuthModule, [typeof ImgUserPictureDirective], never, [typeof ImgUserPictureDirective]>;
static ɵinj: i0.ɵɵInjectorDeclaration<IndiceAuthModule>;
}
/** https://github.com/IdentityModel/oidc-client-js/wiki */
declare class AuthService {
private _userManager;
private _user;
private _userSubject;
constructor(authSettings: IAuthSettings);
user$: Observable<User | null>;
loadUser(): Observable<User | null>;
isLoggedIn(): Observable<boolean>;
getUserProfile(): IdTokenClaims | undefined;
getEmail(): string | undefined;
hasVerifiedEmail(): boolean | undefined;
getSubjectId(): string | undefined;
getFullName(): string | undefined;
getUserName(): string | undefined;
getDisplayName(): string;
getCurrentUser(): User;
isAdmin(): boolean;
getAuthorizationHeaderValue(): string;
getAccessTokenValue(): string;
signoutRedirect(): void;
removeUser(): Observable<void>;
signoutRedirectCallback(): Observable<SignoutResponse>;
signinRedirect(signInRedirectOptions?: SignInRedirectOptions): void;
signinRedirectCallback(): Observable<User>;
signinSilent(): Observable<User>;
signinSilentCallback(): Observable<User | undefined>;
hasRole(roleName: string): boolean;
static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
}
declare class AuthGuardService {
private authService;
constructor(authService: AuthService);
canActivate(route: ActivatedRouteSnapshot | undefined, state: RouterStateSnapshot | undefined): Observable<boolean> | Promise<boolean> | boolean;
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | UrlTree | Observable<boolean | UrlTree> | Promise<boolean | UrlTree>;
canLoad(): Observable<boolean> | Promise<boolean> | boolean;
static ɵfac: i0.ɵɵFactoryDeclaration<AuthGuardService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<AuthGuardService>;
}
declare class AuthHttpInterceptor implements HttpInterceptor {
private authService;
private router;
constructor(authService: AuthService, router: Router);
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
static ɵfac: i0.ɵɵFactoryDeclaration<AuthHttpInterceptor, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<AuthHttpInterceptor>;
}
declare class TenantService {
private _tenantSubject;
constructor();
storeTenant(tenant: string): void;
getTenant(): Observable<string>;
getTenantValue(): string;
static ɵfac: i0.ɵɵFactoryDeclaration<TenantService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TenantService>;
}
declare class TenantHeaderInterceptor implements HttpInterceptor {
private tenantPrefixUrl;
private tenantStore;
constructor(tenantPrefixUrl: string, tenantStore: TenantService);
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
static ɵfac: i0.ɵɵFactoryDeclaration<TenantHeaderInterceptor, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TenantHeaderInterceptor>;
}
declare const AUTH_SETTINGS: InjectionToken<IAuthSettings>;
declare const TENANT_PREFIX_URL: InjectionToken<string>;
export { AUTH_SETTINGS, AuthGuardService, AuthHttpInterceptor, AuthService, DefaultAuthSettings, ImgUserPictureDirective, IndiceAuthModule, SignInRedirectOptions, TENANT_PREFIX_URL, TenantHeaderInterceptor, TenantService };
export type { IAuthSettings };