valtech-components 2.0.827 → 2.0.829
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/esm2022/lib/services/auth/auth.service.mjs +72 -2
- package/esm2022/lib/version.mjs +2 -2
- package/fesm2022/valtech-components.mjs +72 -2
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/atoms/rights-footer/rights-footer.component.d.ts +1 -1
- package/lib/components/organisms/article/article.component.d.ts +2 -2
- package/lib/components/organisms/toolbar/toolbar.component.d.ts +1 -1
- package/lib/services/auth/auth.service.d.ts +31 -0
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ import 'prismjs/components/prism-json';
|
|
|
53
53
|
* Current version of valtech-components.
|
|
54
54
|
* This is automatically updated during the publish process.
|
|
55
55
|
*/
|
|
56
|
-
const VERSION = '2.0.
|
|
56
|
+
const VERSION = '2.0.829';
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Servicio para gestionar presets de componentes.
|
|
@@ -24626,6 +24626,14 @@ class AuthService {
|
|
|
24626
24626
|
}
|
|
24627
24627
|
// 3. Iniciar timer de refresco proactivo
|
|
24628
24628
|
this.startRefreshTimer();
|
|
24629
|
+
// 4. Re-establecer la sesión de Firebase en bootstrap.
|
|
24630
|
+
// El access token sigue válido, así que NO pasamos por la rama de
|
|
24631
|
+
// refresh — pero la persistencia IndexedDB propia de Firebase Auth no
|
|
24632
|
+
// sobrevive el contenedor de storage de una PWA standalone en iOS.
|
|
24633
|
+
// Sin esto, `firebaseAuthReady` se queda en `false` para siempre y
|
|
24634
|
+
// cualquier listener Firestore (ej. el inbox de notificaciones) cuelga.
|
|
24635
|
+
// Fire-and-forget: NO debe demorar el resolve de initialize().
|
|
24636
|
+
void this.ensureFirebaseSessionOnBootstrap();
|
|
24629
24637
|
}
|
|
24630
24638
|
else if (storedState.refreshToken) {
|
|
24631
24639
|
// 4. Token expirado pero hay refresh token - intentar refrescar
|
|
@@ -25278,8 +25286,15 @@ class AuthService {
|
|
|
25278
25286
|
console.log('[ValtechAuth] Calling signInWithFirebase with token length:', response.firebaseToken.length);
|
|
25279
25287
|
this.signInWithFirebase(response.firebaseToken);
|
|
25280
25288
|
}
|
|
25289
|
+
else if (this.config.enableFirebaseIntegration) {
|
|
25290
|
+
// El login NO trajo firebaseToken (ej. flujo OAuth que lo perdió). En vez
|
|
25291
|
+
// de quedar sin sesión de Firebase, recurrimos al fallback self-healing:
|
|
25292
|
+
// /refresh sí devuelve un firebaseToken confiable.
|
|
25293
|
+
console.log('[FBAuth] login response sin firebaseToken → recurriendo a fallback /refresh');
|
|
25294
|
+
void this.reestablishFirebaseViaRefresh('login-missing-firebase-token');
|
|
25295
|
+
}
|
|
25281
25296
|
else {
|
|
25282
|
-
console.log('[ValtechAuth] Firebase signin skipped -
|
|
25297
|
+
console.log('[ValtechAuth] Firebase signin skipped - integración Firebase desactivada');
|
|
25283
25298
|
}
|
|
25284
25299
|
// Registro automático de dispositivo para push notifications
|
|
25285
25300
|
if (this.config.enableDeviceRegistration) {
|
|
@@ -25402,6 +25417,61 @@ class AuthService {
|
|
|
25402
25417
|
console.warn('[ValtechAuth] Firebase signout failed:', error);
|
|
25403
25418
|
}
|
|
25404
25419
|
}
|
|
25420
|
+
/**
|
|
25421
|
+
* Re-establece la sesión de Firebase Auth en el bootstrap de la app cuando
|
|
25422
|
+
* el access token de la app sigue válido (la rama de initialize() que NO
|
|
25423
|
+
* pasa por refresh).
|
|
25424
|
+
*
|
|
25425
|
+
* Firebase Auth mantiene su PROPIA sesión con persistencia IndexedDB
|
|
25426
|
+
* independiente del storage de tokens de la app. En un navegador normal esa
|
|
25427
|
+
* persistencia se auto-restaura sola; en una PWA standalone en iOS el
|
|
25428
|
+
* contenedor de storage no sobrevive, y `firebaseAuthReady` se queda en
|
|
25429
|
+
* `false` indefinidamente → los listeners Firestore cuelgan (~40s timeout).
|
|
25430
|
+
*
|
|
25431
|
+
* Estrategia: dar una ventana corta a la auto-restauración de Firebase y, si
|
|
25432
|
+
* no ocurre, forzar un `refreshAccessToken()` — que ya hace `signInWithFirebase`
|
|
25433
|
+
* con el `firebaseToken` que devuelve `/refresh`.
|
|
25434
|
+
*
|
|
25435
|
+
* Fire-and-forget: se invoca con `void` para no demorar `initialize()`.
|
|
25436
|
+
*/
|
|
25437
|
+
async ensureFirebaseSessionOnBootstrap() {
|
|
25438
|
+
if (!this.config.enableFirebaseIntegration || !this.firebaseService)
|
|
25439
|
+
return;
|
|
25440
|
+
// Dar a la persistencia IndexedDB propia de Firebase Auth una oportunidad
|
|
25441
|
+
// de auto-restaurarse (navegador normal). En una PWA standalone de iOS
|
|
25442
|
+
// normalmente NO lo hará.
|
|
25443
|
+
await new Promise(r => setTimeout(r, 2500));
|
|
25444
|
+
if (this.firebaseService.firebaseAuthReady()) {
|
|
25445
|
+
console.log('[FBAuth] bootstrap — Firebase session restored on its own');
|
|
25446
|
+
return;
|
|
25447
|
+
}
|
|
25448
|
+
console.log('[FBAuth] bootstrap — session valid but Firebase NOT ready → recurriendo a fallback');
|
|
25449
|
+
await this.reestablishFirebaseViaRefresh('bootstrap-session-restore');
|
|
25450
|
+
}
|
|
25451
|
+
/**
|
|
25452
|
+
* Fallback self-healing de Firebase Auth. Pide un firebaseToken fresco vía
|
|
25453
|
+
* `/refresh` (que sí lo devuelve de forma confiable) y, en éxito,
|
|
25454
|
+
* `refreshAccessToken()` ya ejecuta `signInWithFirebase()`.
|
|
25455
|
+
*
|
|
25456
|
+
* Se invoca cuando un path de auth dejó la sesión de Firebase sin establecer:
|
|
25457
|
+
* - login OAuth/password que volvió sin `firebaseToken`,
|
|
25458
|
+
* - cold launch de PWA iOS sin persistencia de Firebase.
|
|
25459
|
+
*
|
|
25460
|
+
* `reason` aparece en los logs `[FBAuth] fallback` para poder atestiguar
|
|
25461
|
+
* desde el debug-console qué disparó el fallback.
|
|
25462
|
+
*/
|
|
25463
|
+
async reestablishFirebaseViaRefresh(reason) {
|
|
25464
|
+
if (!this.config.enableFirebaseIntegration || !this.firebaseService)
|
|
25465
|
+
return;
|
|
25466
|
+
console.log(`[FBAuth] fallback — re-estableciendo Firebase vía /refresh (motivo: ${reason})`);
|
|
25467
|
+
try {
|
|
25468
|
+
await firstValueFrom(this.refreshAccessToken());
|
|
25469
|
+
console.log(`[FBAuth] fallback — /refresh OK, Firebase re-establecido (motivo: ${reason})`);
|
|
25470
|
+
}
|
|
25471
|
+
catch (e) {
|
|
25472
|
+
console.warn(`[FBAuth] fallback — /refresh falló (motivo: ${reason}):`, e);
|
|
25473
|
+
}
|
|
25474
|
+
}
|
|
25405
25475
|
// =============================================
|
|
25406
25476
|
// DEVICE REGISTRATION (Push Notifications)
|
|
25407
25477
|
// =============================================
|