import { ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterStateSnapshot, UrlTree } from '@angular/router'; import { Observable } from 'rxjs'; import { AuthConfig } from './auth-config'; import { AuthService } from './auth.service'; import * as i0 from "@angular/core"; /** * Add to a route to perform an authorization check using roles defined in Status Web App. * * Implements `CanLoad` for use with lazy loaded routes and `CanActivate` for regular routes. * * Will first trigger the sign in flow when the user is not already authenticated. Then verifies * that the user is a member of one or more {@link AllowedRole}'s as defined in an `allowedRoles` * field on `Route.data` for the route about to be navigated to. * * Where the user is deemed unauthorized the SPA will be routed to the client-side route configured * using {@link AuthConfig.unauthorizedRoute}. * * The allowed role(s) from the matching route will be passed as query string parameters to this nominated * unauthorized route. * * @see {AuthService.hasSomeRoles$} * * @example * ```ts * // app.module.ts... * * export const routes: Routes = [ * { * path: 'product-admin', * data: { * allowedRoles: 'admin' // other ex: ['admin', ['product-reader', 'owner']] * }, * canActivate: [SwaRoleGuard], * component: AdminComponent * }, * { * path: 'user-admin', * data: { * allowedRoles: 'owner' * }, * canLoad: [SwaRoleGuard], * loadChildren: () => import('@christianacca/demo-app/user-admin').then(m => m.UserAdminModule) * } * ]; * * // unauthorized.component.ts... * * export class UnauthorizedComponent { * allowedRoles: string[]; * constructor(route: ActivatedRoute) { * this.allowedRoles = route.snapshot.queryParamMap.getAll('allowedRoles'); * } * } * ``` */ export declare class SwaRoleGuard implements CanActivate, CanLoad { private authService; private router; private config; constructor(authService: AuthService, router: Router, config: AuthConfig); private static getAllowedRoles; canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Observable; canLoad(route: Route): boolean | Observable; private ensureHasRouteRoles; private ensureHasSomeRoles; private getUnauthorizedUrl; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }