shared-lib-angular 2.0.2 → 2.0.4

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.
package/index.d.ts CHANGED
@@ -10,14 +10,14 @@ import { HttpClient } from '@angular/common/http';
10
10
  * Versión actual de la librería @dinafi/frmk
11
11
  * Sincronizada con package.json
12
12
  */
13
- declare const VERSION = "2.0.2";
13
+ declare const VERSION = "2.0.4";
14
14
  /**
15
15
  * Información completa de la versión
16
16
  */
17
17
  declare const VERSION_INFO: {
18
- readonly version: "2.0.2";
18
+ readonly version: "2.0.4";
19
19
  readonly name: "shared-lib-angular";
20
- readonly buildDate: "2026-02-05T20:47:48.315Z";
20
+ readonly buildDate: "2026-02-09T22:43:40.953Z";
21
21
  readonly angular: "^20.0.0";
22
22
  };
23
23
 
@@ -312,30 +312,79 @@ declare class FrmkConfigStore {
312
312
  static ɵprov: i0.ɵɵInjectableDeclaration<FrmkConfigStore>;
313
313
  }
314
314
 
315
+ /**
316
+ * Servicio centralizado para gestión de tokens en localStorage / sessionStorage.
317
+ *
318
+ * - Elimina las 4+ listas de keys duplicadas e inconsistentes que existían en AuthService.
319
+ * - Opera simétricamente sobre ambos storages.
320
+ * - Soporta la key dinámica `refresh_token_{clientId}` que usa angular-oauth2-oidc.
321
+ * - Expone métodos públicos para que la plantilla pueda leer tokens sin acceder a storage directamente.
322
+ *
323
+ * @example
324
+ * // Desde la librería (AuthService):
325
+ * this.tokenStorage.clearAll();
326
+ *
327
+ * // Desde la plantilla (skeleton):
328
+ * const expired = this.tokenStorage.isTokenExpired();
329
+ */
330
+ declare class TokenStorageService {
331
+ /**
332
+ * Limpia TODOS los tokens y estado OAuth de ambos storages.
333
+ * Incluye la key dinámica `refresh_token_{clientId}` si se proporciona.
334
+ *
335
+ * @param clientId — clientId de OAuth para limpiar `refresh_token_{clientId}` (opcional)
336
+ */
337
+ clearAll(clientId?: string): void;
338
+ /**
339
+ * Limpia tokens pero MANTIENE las keys de estado OAuth necesarias para
340
+ * validar el callback (nonce, PKCE_verifier, code_verifier, session_state, state).
341
+ *
342
+ * Usar durante un callback OAuth antes de procesar el authorization code.
343
+ */
344
+ clearTokensKeepState(): void;
345
+ /**
346
+ * Lee un valor de localStorage o sessionStorage (en ese orden de prioridad).
347
+ */
348
+ getItem(key: string): string | null;
349
+ /**
350
+ * Obtiene el refresh_token, incluyendo la variante dinámica `refresh_token_{clientId}`.
351
+ *
352
+ * @param clientId — clientId de OAuth (opcional)
353
+ */
354
+ getRefreshToken(clientId?: string): string | null;
355
+ /**
356
+ * Obtiene el access_token de cualquier storage.
357
+ */
358
+ getAccessToken(): string | null;
359
+ /**
360
+ * Verifica si hay un token almacenado y está expirado.
361
+ * Retorna `false` si no existe `expires_at` (no hay token, no está "expirado").
362
+ */
363
+ isTokenExpired(): boolean;
364
+ /**
365
+ * Elimina una key específica de ambos storages.
366
+ */
367
+ removeItem(key: string): void;
368
+ static ɵfac: i0.ɵɵFactoryDeclaration<TokenStorageService, never>;
369
+ static ɵprov: i0.ɵɵInjectableDeclaration<TokenStorageService>;
370
+ }
371
+
315
372
  declare class AuthService {
316
373
  private readonly oauthService;
317
374
  private readonly router;
318
375
  private readonly store;
376
+ private readonly tokenStorage;
319
377
  private readonly isAuthenticatedSubject$;
320
378
  isAuthenticated$: rxjs.Observable<boolean>;
321
379
  private readonly isDoneLoadingSubject$;
322
380
  isDoneLoading$: rxjs.Observable<boolean>;
323
381
  private isInitialLogin;
324
- constructor(oauthService: OAuthService, router: Router, store: FrmkConfigStore);
382
+ constructor(oauthService: OAuthService, router: Router, store: FrmkConfigStore, tokenStorage: TokenStorageService);
325
383
  /**
326
384
  * Limpia tokens expirados al iniciar la aplicación
327
385
  * Solo limpia si NO estamos en un callback OAuth
328
386
  */
329
387
  private clearExpiredTokensOnStartup;
330
- /**
331
- * Limpia todos los tokens del storage
332
- */
333
- private clearAllTokens;
334
- /**
335
- * Limpia tokens antiguos pero MANTIENE state, nonce y PKCE_verifier
336
- * que son necesarios para validar el callback OAuth
337
- */
338
- private clearOldTokensKeepState;
339
388
  private handleSuccessfulAuthentication;
340
389
  /**
341
390
  * Limpia los parámetros OAuth de la URL después del login exitoso
@@ -345,7 +394,7 @@ declare class AuthService {
345
394
  private handleSilentRefresh;
346
395
  private handleLogout;
347
396
  /**
348
- * Limpia todos los tokens del storage
397
+ * Limpia todos los tokens del storage y resetea OAuthService
349
398
  */
350
399
  private clearTokenStorage;
351
400
  /**
@@ -555,5 +604,5 @@ declare class DashboardComponent implements OnInit {
555
604
  static ɵcmp: i0.ɵɵComponentDeclaration<DashboardComponent, "lib-dashboard", never, { "config": { "alias": "config"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
556
605
  }
557
606
 
558
- export { AuthService, AuthorizationService, ConfigService, DEFAULT_DASHBOARD_CONFIG, DEFAULT_LIBRARY_CONFIG, DEFAULT_LOGIN_CONFIG, DashboardComponent, FrmkConfigStore, LoginComponent, VERSION, VERSION_INFO, authGuard };
607
+ export { AuthService, AuthorizationService, ConfigService, DEFAULT_DASHBOARD_CONFIG, DEFAULT_LIBRARY_CONFIG, DEFAULT_LOGIN_CONFIG, DashboardComponent, FrmkConfigStore, LoginComponent, TokenStorageService, VERSION, VERSION_INFO, authGuard };
559
608
  export type { AppConfiguration, AuthorizationRequest, AuthorizationResponse, ConfigServerResponse, DashboardConfig, FrmkLibraryConfig, LoginConfig, MenuHierarchyItem, MenuHierarchyRequest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shared-lib-angular",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Angular Librería Framework para autenticación, autorización y componentes de UI",
5
5
  "keywords": [
6
6
  "angular",