@studiohyperdrive/ngx-auth
Version:
A library of core authentication functionality used with @studiohyperdrive/types-auth.
44 lines (43 loc) • 1.75 kB
TypeScript
import { ChangeDetectorRef, OnDestroy, PipeTransform } from '@angular/core';
import { NgxAuthenticationAbstractService } from '../../abstracts';
import * as i0 from "@angular/core";
/**
* A pipe that returns whether a (list of) permission(s) has been provided
*/
export declare class NgxHasPermissionPipe<PermissionType extends string> implements PipeTransform, OnDestroy {
private readonly authenticationService;
private readonly cdRef;
/**
* Subject to hold the destroyed state of the current observable
*/
private destroyed$;
/**
* The latest value of the Observable, whether or not the permission is provided
*/
private hasPermission;
/**
* Instance of the change detector ref, implemented like this according to the async pipe implementation
* https://github.com/angular/angular/blob/main/packages/common/src/pipes/async_pipe.ts
*/
private changeDetectorRef;
constructor(authenticationService: NgxAuthenticationAbstractService, cdRef: ChangeDetectorRef);
ngOnDestroy(): void;
/**
* Returns whether or not a permission is provided for the environment
*
* @param permission - The provided permission
*/
transform(permission: PermissionType | PermissionType[]): boolean;
/**
* Handles the changeDetection, latest value and dispose of the hasPermission observable
*
* @param observable - The hasPermission observable
*/
private subscribe;
/**
* Dispose of the permission observable when existing
*/
private dispose;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxHasPermissionPipe<any>, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<NgxHasPermissionPipe<any>, "ngxHasPermission", true>;
}