valtech-components 2.0.428 → 2.0.430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/esm2022/lib/components/organisms/data-table/data-table.component.mjs +17 -3
  2. package/esm2022/lib/components/organisms/data-table/types.mjs +1 -1
  3. package/esm2022/lib/services/auth/auth-state.service.mjs +173 -0
  4. package/esm2022/lib/services/auth/auth.service.mjs +432 -0
  5. package/esm2022/lib/services/auth/config.mjs +76 -0
  6. package/esm2022/lib/services/auth/guards.mjs +194 -0
  7. package/esm2022/lib/services/auth/index.mjs +70 -0
  8. package/esm2022/lib/services/auth/interceptor.mjs +98 -0
  9. package/esm2022/lib/services/auth/storage.service.mjs +138 -0
  10. package/esm2022/lib/services/auth/sync.service.mjs +146 -0
  11. package/esm2022/lib/services/auth/token.service.mjs +113 -0
  12. package/esm2022/lib/services/auth/types.mjs +29 -0
  13. package/esm2022/public-api.mjs +4 -1
  14. package/fesm2022/valtech-components.mjs +1465 -8
  15. package/fesm2022/valtech-components.mjs.map +1 -1
  16. package/lib/components/organisms/data-table/types.d.ts +8 -0
  17. package/lib/services/auth/auth-state.service.d.ts +85 -0
  18. package/lib/services/auth/auth.service.d.ts +123 -0
  19. package/lib/services/auth/config.d.ts +38 -0
  20. package/lib/services/auth/guards.d.ts +123 -0
  21. package/lib/services/auth/index.d.ts +63 -0
  22. package/lib/services/auth/interceptor.d.ts +22 -0
  23. package/lib/services/auth/storage.service.d.ts +48 -0
  24. package/lib/services/auth/sync.service.d.ts +49 -0
  25. package/lib/services/auth/token.service.d.ts +51 -0
  26. package/lib/services/auth/types.d.ts +264 -0
  27. package/package.json +1 -9
  28. package/public-api.d.ts +1 -0
@@ -182,6 +182,14 @@ export interface DataTableMetadata<T = any> {
182
182
  headerColor?: Color;
183
183
  /** Row click enabled */
184
184
  rowClickable?: boolean;
185
+ /** Elevation level for box shadow */
186
+ elevation?: 'none' | 'low' | 'medium' | 'high';
187
+ /** Show gradient accent on top border */
188
+ headerGradient?: boolean;
189
+ /** Checkbox style variant */
190
+ checkboxStyle?: 'default' | 'circular';
191
+ /** Row selection highlight style */
192
+ rowHighlightStyle?: 'background' | 'border-left' | 'both';
185
193
  /** Row actions template */
186
194
  actionsTemplate?: TemplateRef<any>;
187
195
  /** Actions column width */
@@ -0,0 +1,85 @@
1
+ import { AuthState, AuthUser, AuthError, MFAPendingState, StoredAuthState } from './types';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Servicio para manejo de estado de autenticación con Angular Signals.
5
+ * Proporciona estado reactivo inmutable.
6
+ */
7
+ export declare class AuthStateService {
8
+ private _state;
9
+ private _mfaPending;
10
+ /** Estado completo de autenticación */
11
+ readonly state: import("@angular/core").Signal<AuthState>;
12
+ /** Estado de MFA pendiente */
13
+ readonly mfaPending: import("@angular/core").Signal<MFAPendingState>;
14
+ /** Usuario está autenticado */
15
+ readonly isAuthenticated: import("@angular/core").Signal<boolean>;
16
+ /** Estado de carga */
17
+ readonly isLoading: import("@angular/core").Signal<boolean>;
18
+ /** Token de acceso */
19
+ readonly accessToken: import("@angular/core").Signal<string>;
20
+ /** Roles del usuario */
21
+ readonly roles: import("@angular/core").Signal<string[]>;
22
+ /** Permisos del usuario */
23
+ readonly permissions: import("@angular/core").Signal<string[]>;
24
+ /** Usuario es super admin */
25
+ readonly isSuperAdmin: import("@angular/core").Signal<boolean>;
26
+ /** Error actual */
27
+ readonly error: import("@angular/core").Signal<AuthError>;
28
+ /** Información del usuario */
29
+ readonly user: import("@angular/core").Signal<AuthUser>;
30
+ /**
31
+ * Establece el estado de carga.
32
+ */
33
+ setLoading(isLoading: boolean): void;
34
+ /**
35
+ * Establece el estado de autenticación exitosa.
36
+ */
37
+ setAuthenticated(data: {
38
+ accessToken: string;
39
+ refreshToken: string;
40
+ userId?: string;
41
+ email?: string;
42
+ roles: string[];
43
+ permissions: string[];
44
+ isSuperAdmin: boolean;
45
+ expiresAt: number;
46
+ }): void;
47
+ /**
48
+ * Actualiza solo el access token (después de refresh).
49
+ */
50
+ updateAccessToken(accessToken: string, expiresIn: number): void;
51
+ /**
52
+ * Actualiza los permisos.
53
+ */
54
+ updatePermissions(roles: string[], permissions: string[], isSuperAdmin: boolean): void;
55
+ /**
56
+ * Establece un error de autenticación.
57
+ */
58
+ setError(error: AuthError): void;
59
+ /**
60
+ * Limpia el error.
61
+ */
62
+ clearError(): void;
63
+ /**
64
+ * Establece estado de MFA pendiente.
65
+ */
66
+ setMFAPending(mfaState: MFAPendingState): void;
67
+ /**
68
+ * Limpia el estado de MFA pendiente.
69
+ */
70
+ clearMFAPending(): void;
71
+ /**
72
+ * Resetea todo el estado a valores iniciales.
73
+ */
74
+ reset(): void;
75
+ /**
76
+ * Restaura estado desde datos almacenados.
77
+ */
78
+ restoreFromStorage(stored: Partial<StoredAuthState>): void;
79
+ /**
80
+ * Actualiza el userId y email (después de parsear el token).
81
+ */
82
+ updateUserInfo(userId: string, email: string): void;
83
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthStateService, never>;
84
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthStateService>;
85
+ }
@@ -0,0 +1,123 @@
1
+ import { OnDestroy } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
+ import { SigninRequest, SigninResponse, MFAVerifyResponse, RefreshResponse, GetPermissionsResponse, MFASetupResponse, MFAConfirmResponse, MFADisableResponse, MFAMethod, AuthError } from './types';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Servicio principal de autenticación.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { AuthService } from 'valtech-components';
11
+ *
12
+ * @Component({...})
13
+ * export class LoginComponent {
14
+ * private auth = inject(AuthService);
15
+ *
16
+ * async login() {
17
+ * await firstValueFrom(this.auth.signin({ email, password }));
18
+ * if (this.auth.mfaPending().required) {
19
+ * // Mostrar UI de MFA
20
+ * } else {
21
+ * this.router.navigate(['/']);
22
+ * }
23
+ * }
24
+ * }
25
+ * ```
26
+ */
27
+ export declare class AuthService implements OnDestroy {
28
+ private config;
29
+ private http;
30
+ private router;
31
+ private stateService;
32
+ private tokenService;
33
+ private storageService;
34
+ private syncService;
35
+ private refreshTimerId;
36
+ private syncSubscription;
37
+ /** Estado completo de autenticación */
38
+ readonly state: import("@angular/core").Signal<import("./types").AuthState>;
39
+ /** Usuario está autenticado */
40
+ readonly isAuthenticated: import("@angular/core").Signal<boolean>;
41
+ /** Estado de carga */
42
+ readonly isLoading: import("@angular/core").Signal<boolean>;
43
+ /** Información del usuario */
44
+ readonly user: import("@angular/core").Signal<import("./types").AuthUser>;
45
+ /** Token de acceso */
46
+ readonly accessToken: import("@angular/core").Signal<string>;
47
+ /** Roles del usuario */
48
+ readonly roles: import("@angular/core").Signal<string[]>;
49
+ /** Permisos del usuario */
50
+ readonly permissions: import("@angular/core").Signal<string[]>;
51
+ /** Usuario es super admin */
52
+ readonly isSuperAdmin: import("@angular/core").Signal<boolean>;
53
+ /** Estado de MFA pendiente */
54
+ readonly mfaPending: import("@angular/core").Signal<import("./types").MFAPendingState>;
55
+ /** Error actual */
56
+ readonly error: import("@angular/core").Signal<AuthError>;
57
+ /**
58
+ * Inicializa el servicio de autenticación.
59
+ * Llamado automáticamente por provideValtechAuth.
60
+ */
61
+ initialize(): Promise<void>;
62
+ ngOnDestroy(): void;
63
+ /**
64
+ * Inicia sesión con email y contraseña.
65
+ */
66
+ signin(request: SigninRequest): Observable<SigninResponse>;
67
+ /**
68
+ * Verifica código MFA.
69
+ */
70
+ verifyMFA(code: string): Observable<MFAVerifyResponse>;
71
+ /**
72
+ * Refresca el token de acceso.
73
+ */
74
+ refreshAccessToken(): Observable<RefreshResponse>;
75
+ /**
76
+ * Cierra sesión.
77
+ */
78
+ logout(): void;
79
+ /**
80
+ * Configura MFA para el usuario.
81
+ */
82
+ setupMFA(method: MFAMethod, phone?: string): Observable<MFASetupResponse>;
83
+ /**
84
+ * Confirma la configuración de MFA.
85
+ */
86
+ confirmMFA(code: string): Observable<MFAConfirmResponse>;
87
+ /**
88
+ * Deshabilita MFA.
89
+ */
90
+ disableMFA(password: string): Observable<MFADisableResponse>;
91
+ /**
92
+ * Obtiene los permisos actualizados del backend.
93
+ */
94
+ fetchPermissions(): Observable<GetPermissionsResponse>;
95
+ /**
96
+ * Verifica si el usuario tiene un permiso específico.
97
+ * Formato: "resource:action" (ej: "templates:edit")
98
+ */
99
+ hasPermission(permission: string): boolean;
100
+ /**
101
+ * Verifica si el usuario tiene alguno de los permisos dados.
102
+ */
103
+ hasAnyPermission(permissions: string[]): boolean;
104
+ /**
105
+ * Verifica si el usuario tiene todos los permisos dados.
106
+ */
107
+ hasAllPermissions(permissions: string[]): boolean;
108
+ /**
109
+ * Verifica si el usuario tiene un rol específico.
110
+ */
111
+ hasRole(role: string): boolean;
112
+ private get baseUrl();
113
+ private handleSuccessfulAuth;
114
+ private clearState;
115
+ private startRefreshTimer;
116
+ private stopRefreshTimer;
117
+ private handleSyncEvent;
118
+ private handleAuthError;
119
+ private signInWithFirebase;
120
+ private signOutFirebase;
121
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
122
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
123
+ }
@@ -0,0 +1,38 @@
1
+ import { EnvironmentProviders, InjectionToken } from '@angular/core';
2
+ import { ValtechAuthConfig } from './types';
3
+ /**
4
+ * Token de inyección para la configuración de Auth.
5
+ */
6
+ export declare const VALTECH_AUTH_CONFIG: InjectionToken<ValtechAuthConfig>;
7
+ /**
8
+ * Configuración por defecto.
9
+ */
10
+ export declare const DEFAULT_AUTH_CONFIG: Partial<ValtechAuthConfig>;
11
+ /**
12
+ * Provee el servicio de autenticación a la aplicación Angular.
13
+ *
14
+ * @param config - Configuración de autenticación
15
+ * @returns EnvironmentProviders para usar en bootstrapApplication
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // main.ts
20
+ * import { bootstrapApplication } from '@angular/platform-browser';
21
+ * import { provideValtechAuth } from 'valtech-components';
22
+ * import { environment } from './environments/environment';
23
+ *
24
+ * bootstrapApplication(AppComponent, {
25
+ * providers: [
26
+ * provideValtechAuth({
27
+ * apiUrl: environment.apiUrl,
28
+ * enableFirebaseIntegration: true,
29
+ * }),
30
+ * ],
31
+ * });
32
+ * ```
33
+ */
34
+ export declare function provideValtechAuth(config: ValtechAuthConfig): EnvironmentProviders;
35
+ /**
36
+ * Provee solo el interceptor (para apps que ya tienen AuthService configurado manualmente).
37
+ */
38
+ export declare function provideValtechAuthInterceptor(): EnvironmentProviders;
@@ -0,0 +1,123 @@
1
+ import { CanActivateFn } from '@angular/router';
2
+ /**
3
+ * Guard que verifica si el usuario está autenticado.
4
+ * Redirige a loginRoute si no está autenticado.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { authGuard } from 'valtech-components';
9
+ *
10
+ * const routes: Routes = [
11
+ * {
12
+ * path: 'dashboard',
13
+ * canActivate: [authGuard],
14
+ * loadComponent: () => import('./dashboard.page'),
15
+ * },
16
+ * ];
17
+ * ```
18
+ */
19
+ export declare const authGuard: CanActivateFn;
20
+ /**
21
+ * Guard que verifica si el usuario NO está autenticado.
22
+ * Redirige a homeRoute si ya está autenticado.
23
+ * Útil para páginas de login/registro.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * import { guestGuard } from 'valtech-components';
28
+ *
29
+ * const routes: Routes = [
30
+ * {
31
+ * path: 'login',
32
+ * canActivate: [guestGuard],
33
+ * loadComponent: () => import('./login.page'),
34
+ * },
35
+ * ];
36
+ * ```
37
+ */
38
+ export declare const guestGuard: CanActivateFn;
39
+ /**
40
+ * Factory para crear guard de permisos.
41
+ * Verifica si el usuario tiene el permiso especificado.
42
+ *
43
+ * @param permissions - Permiso o lista de permisos requeridos (OR)
44
+ * @returns Guard function
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { authGuard, permissionGuard } from 'valtech-components';
49
+ *
50
+ * const routes: Routes = [
51
+ * {
52
+ * path: 'templates',
53
+ * canActivate: [authGuard, permissionGuard('templates:read')],
54
+ * loadComponent: () => import('./templates.page'),
55
+ * },
56
+ * {
57
+ * path: 'admin',
58
+ * canActivate: [authGuard, permissionGuard(['admin:*', 'super_admin'])],
59
+ * loadComponent: () => import('./admin.page'),
60
+ * },
61
+ * ];
62
+ * ```
63
+ */
64
+ export declare function permissionGuard(permissions: string | string[]): CanActivateFn;
65
+ /**
66
+ * Guard que lee permisos desde route.data.
67
+ * Permite configurar permisos directamente en la definición de rutas.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * import { authGuard, permissionGuardFromRoute } from 'valtech-components';
72
+ *
73
+ * const routes: Routes = [
74
+ * {
75
+ * path: 'admin/users',
76
+ * canActivate: [authGuard, permissionGuardFromRoute],
77
+ * data: {
78
+ * permissions: ['users:read', 'users:manage'],
79
+ * requireAll: false // true = AND, false = OR (default)
80
+ * },
81
+ * loadComponent: () => import('./users.page'),
82
+ * },
83
+ * ];
84
+ * ```
85
+ */
86
+ export declare const permissionGuardFromRoute: CanActivateFn;
87
+ /**
88
+ * Guard que verifica si el usuario es super admin.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * import { authGuard, superAdminGuard } from 'valtech-components';
93
+ *
94
+ * const routes: Routes = [
95
+ * {
96
+ * path: 'super-admin',
97
+ * canActivate: [authGuard, superAdminGuard],
98
+ * loadComponent: () => import('./super-admin.page'),
99
+ * },
100
+ * ];
101
+ * ```
102
+ */
103
+ export declare const superAdminGuard: CanActivateFn;
104
+ /**
105
+ * Guard que verifica si el usuario tiene un rol específico.
106
+ *
107
+ * @param roles - Rol o lista de roles requeridos (OR)
108
+ * @returns Guard function
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * import { authGuard, roleGuard } from 'valtech-components';
113
+ *
114
+ * const routes: Routes = [
115
+ * {
116
+ * path: 'editor',
117
+ * canActivate: [authGuard, roleGuard(['editor', 'admin'])],
118
+ * loadComponent: () => import('./editor.page'),
119
+ * },
120
+ * ];
121
+ * ```
122
+ */
123
+ export declare function roleGuard(roles: string | string[]): CanActivateFn;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Valtech Auth Service
3
+ *
4
+ * Servicio de autenticación reutilizable para aplicaciones Angular.
5
+ * Proporciona autenticación con AuthV2, MFA, sincronización entre pestañas,
6
+ * y refresh proactivo de tokens.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // En main.ts
11
+ * import { bootstrapApplication } from '@angular/platform-browser';
12
+ * import { provideValtechAuth } from 'valtech-components';
13
+ * import { environment } from './environments/environment';
14
+ *
15
+ * bootstrapApplication(AppComponent, {
16
+ * providers: [
17
+ * provideValtechAuth({
18
+ * apiUrl: environment.apiUrl,
19
+ * enableFirebaseIntegration: true,
20
+ * }),
21
+ * ],
22
+ * });
23
+ *
24
+ * // En app.routes.ts
25
+ * import { authGuard, guestGuard, permissionGuard } from 'valtech-components';
26
+ *
27
+ * const routes: Routes = [
28
+ * { path: 'login', canActivate: [guestGuard], loadComponent: () => import('./login.page') },
29
+ * { path: 'dashboard', canActivate: [authGuard], loadComponent: () => import('./dashboard.page') },
30
+ * { path: 'admin', canActivate: [authGuard, permissionGuard('admin:*')], loadComponent: () => import('./admin.page') },
31
+ * ];
32
+ *
33
+ * // En componentes
34
+ * import { AuthService } from 'valtech-components';
35
+ *
36
+ * @Component({...})
37
+ * export class LoginComponent {
38
+ * private auth = inject(AuthService);
39
+ *
40
+ * async login() {
41
+ * await firstValueFrom(this.auth.signin({ email, password }));
42
+ * if (this.auth.mfaPending().required) {
43
+ * // Mostrar UI de MFA
44
+ * } else {
45
+ * this.router.navigate(['/dashboard']);
46
+ * }
47
+ * }
48
+ *
49
+ * // En template: usar signals directamente
50
+ * // {{ auth.user()?.email }}
51
+ * // @if (auth.hasPermission('templates:edit')) { ... }
52
+ * }
53
+ * ```
54
+ */
55
+ export * from './types';
56
+ export { VALTECH_AUTH_CONFIG, provideValtechAuth, provideValtechAuthInterceptor, DEFAULT_AUTH_CONFIG, } from './config';
57
+ export { AuthService } from './auth.service';
58
+ export { authGuard, guestGuard, permissionGuard, permissionGuardFromRoute, superAdminGuard, roleGuard, } from './guards';
59
+ export { authInterceptor } from './interceptor';
60
+ export { AuthStateService } from './auth-state.service';
61
+ export { TokenService } from './token.service';
62
+ export { AuthStorageService } from './storage.service';
63
+ export { AuthSyncService } from './sync.service';
@@ -0,0 +1,22 @@
1
+ import { HttpInterceptorFn } from '@angular/common/http';
2
+ /**
3
+ * Interceptor HTTP que:
4
+ * 1. Agrega header Authorization con Bearer token a requests API
5
+ * 2. Maneja errores 401 refrescando el token automáticamente
6
+ * 3. Encola requests durante el refresco para evitar múltiples refresh
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Incluido automáticamente por provideValtechAuth()
11
+ * // Para uso manual:
12
+ * import { provideHttpClient, withInterceptors } from '@angular/common/http';
13
+ * import { authInterceptor } from 'valtech-components';
14
+ *
15
+ * bootstrapApplication(AppComponent, {
16
+ * providers: [
17
+ * provideHttpClient(withInterceptors([authInterceptor])),
18
+ * ],
19
+ * });
20
+ * ```
21
+ */
22
+ export declare const authInterceptor: HttpInterceptorFn;
@@ -0,0 +1,48 @@
1
+ import { StoredAuthState, GetPermissionsResponse } from './types';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Servicio para persistencia de estado de autenticación en localStorage.
5
+ */
6
+ export declare class AuthStorageService {
7
+ private config;
8
+ private keys;
9
+ constructor();
10
+ /**
11
+ * Guarda el estado completo de autenticación.
12
+ */
13
+ saveState(state: StoredAuthState): void;
14
+ /**
15
+ * Carga el estado de autenticación desde storage.
16
+ */
17
+ loadState(): Partial<StoredAuthState>;
18
+ /**
19
+ * Guarda solo el access token.
20
+ */
21
+ saveAccessToken(token: string, expiresAt?: number): void;
22
+ /**
23
+ * Guarda los permisos actualizados.
24
+ */
25
+ savePermissions(response: GetPermissionsResponse): void;
26
+ /**
27
+ * Carga los permisos desde storage.
28
+ */
29
+ loadPermissions(): {
30
+ roles: string[];
31
+ permissions: string[];
32
+ isSuperAdmin: boolean;
33
+ };
34
+ /**
35
+ * Obtiene el refresh token.
36
+ */
37
+ getRefreshToken(): string | null;
38
+ /**
39
+ * Limpia todo el estado de autenticación.
40
+ */
41
+ clear(): void;
42
+ /**
43
+ * Verifica si hay estado guardado.
44
+ */
45
+ hasStoredState(): boolean;
46
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthStorageService, never>;
47
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthStorageService>;
48
+ }
@@ -0,0 +1,49 @@
1
+ import { OnDestroy } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
+ import { AuthSyncEvent } from './types';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Servicio para sincronización de estado de autenticación entre pestañas.
7
+ * Usa BroadcastChannel API con fallback a storage events.
8
+ */
9
+ export declare class AuthSyncService implements OnDestroy {
10
+ private config;
11
+ private channel;
12
+ private channelName;
13
+ private eventSubject;
14
+ private storageListener;
15
+ /** Observable de eventos de sincronización */
16
+ readonly onEvent$: Observable<AuthSyncEvent>;
17
+ constructor();
18
+ /**
19
+ * Inicia la sincronización entre pestañas.
20
+ */
21
+ start(): void;
22
+ /**
23
+ * Detiene la sincronización.
24
+ */
25
+ stop(): void;
26
+ /**
27
+ * Envía un evento a otras pestañas.
28
+ */
29
+ broadcast(event: Omit<AuthSyncEvent, 'timestamp'>): void;
30
+ ngOnDestroy(): void;
31
+ /**
32
+ * Inicializa BroadcastChannel API.
33
+ */
34
+ private initBroadcastChannel;
35
+ /**
36
+ * Inicializa fallback con storage events.
37
+ */
38
+ private initStorageEvents;
39
+ /**
40
+ * Envía evento via localStorage (fallback).
41
+ */
42
+ private broadcastViaStorage;
43
+ /**
44
+ * Maneja un evento recibido.
45
+ */
46
+ private handleEvent;
47
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthSyncService, never>;
48
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthSyncService>;
49
+ }
@@ -0,0 +1,51 @@
1
+ import { JWTClaims } from './types';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Servicio para manejo de tokens JWT.
5
+ * Parseo y validación de tokens sin dependencias externas.
6
+ */
7
+ export declare class TokenService {
8
+ /**
9
+ * Parsea un token JWT y extrae los claims.
10
+ * @param token - Token JWT
11
+ * @returns Claims del token o null si es inválido
12
+ */
13
+ parseToken(token: string): JWTClaims | null;
14
+ /**
15
+ * Verifica si un token es válido (no expirado).
16
+ * @param token - Token JWT
17
+ * @returns true si el token es válido
18
+ */
19
+ isTokenValid(token: string): boolean;
20
+ /**
21
+ * Obtiene el tiempo restante del token en segundos.
22
+ * @param token - Token JWT
23
+ * @returns Segundos restantes o 0 si expirado
24
+ */
25
+ getTimeToExpiry(token: string): number;
26
+ /**
27
+ * Obtiene el timestamp de expiración del token.
28
+ * @param token - Token JWT
29
+ * @returns Timestamp en milisegundos o null
30
+ */
31
+ getExpirationTime(token: string): number | null;
32
+ /**
33
+ * Extrae el user ID del token.
34
+ * @param token - Token JWT
35
+ * @returns User ID o null
36
+ */
37
+ getUserId(token: string): string | null;
38
+ /**
39
+ * Extrae el email del token.
40
+ * @param token - Token JWT
41
+ * @returns Email o null
42
+ */
43
+ getEmail(token: string): string | null;
44
+ /**
45
+ * Decodifica base64url a string.
46
+ * Base64url usa - y _ en lugar de + y /
47
+ */
48
+ private base64UrlDecode;
49
+ static ɵfac: i0.ɵɵFactoryDeclaration<TokenService, never>;
50
+ static ɵprov: i0.ɵɵInjectableDeclaration<TokenService>;
51
+ }