import { CanActivateFn, Router, UrlTree } from '@angular/router'; import { AuthService } from '../ngmodule/auth.service'; import type { NAuthClientConfig } from '@nauth-toolkit/client'; import * as i0 from "@angular/core"; /** * Functional route guard for authentication (Angular 17+). * * Protects routes by checking if user is authenticated. * Redirects to configured session expired route (or login) if not authenticated. * * @param redirectTo - Optional path to redirect to if not authenticated. If not provided, uses `redirects.sessionExpired` from config (defaults to '/login') * @returns CanActivateFn guard function * * @example * ```typescript * // In route configuration - uses config.redirects.sessionExpired * const routes: Routes = [ * { * path: 'home', * component: HomeComponent, * canActivate: [authGuard()] * } * ]; * * // Override with custom route * const routes: Routes = [ * { * path: 'admin', * component: AdminComponent, * canActivate: [authGuard('/admin/login')] * } * ]; * ``` */ export declare function authGuard(redirectTo?: string): CanActivateFn; /** * Class-based authentication guard for NgModule compatibility. * * **Note:** When using `NAuthModule.forRoot()`, `AuthGuard` is automatically provided * and has access to the configuration. You don't need to add it to your module's providers. * * @example * ```typescript * // app.module.ts - AuthGuard is automatically provided by NAuthModule.forRoot() * @NgModule({ * imports: [ * NAuthModule.forRoot({ * baseUrl: 'https://api.example.com/auth', * tokenDelivery: 'cookies', * redirects: { * sessionExpired: '/login?expired=true', * }, * }), * RouterModule.forRoot([ * { * path: 'home', * component: HomeComponent, * canActivate: [AuthGuard], // Uses config.redirects.sessionExpired * }, * ]), * ], * }) * export class AppModule {} * * // Or provide manually in a feature module (still has access to root config) * @NgModule({ * providers: [AuthGuard], * }) * export class FeatureModule {} * ``` */ export declare class AuthGuard { private auth; private router; private config?; /** * @param auth - Authentication service * @param router - Angular router * @param config - Optional client configuration (injected automatically) */ constructor(auth: AuthService, router: Router, config?: NAuthClientConfig); /** * Check if route can be activated. * * @returns True if authenticated, otherwise redirects to configured session expired route (or '/login') */ canActivate(): boolean | UrlTree; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }