valtech-components 2.0.828 → 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.
@@ -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.828';
56
+ const VERSION = '2.0.829';
57
57
 
58
58
  /**
59
59
  * Servicio para gestionar presets de componentes.
@@ -25286,8 +25286,15 @@ class AuthService {
25286
25286
  console.log('[ValtechAuth] Calling signInWithFirebase with token length:', response.firebaseToken.length);
25287
25287
  this.signInWithFirebase(response.firebaseToken);
25288
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
+ }
25289
25296
  else {
25290
- console.log('[ValtechAuth] Firebase signin skipped - conditions not met');
25297
+ console.log('[ValtechAuth] Firebase signin skipped - integración Firebase desactivada');
25291
25298
  }
25292
25299
  // Registro automático de dispositivo para push notifications
25293
25300
  if (this.config.enableDeviceRegistration) {
@@ -25438,13 +25445,31 @@ class AuthService {
25438
25445
  console.log('[FBAuth] bootstrap — Firebase session restored on its own');
25439
25446
  return;
25440
25447
  }
25441
- console.log('[FBAuth] bootstrap — session valid but Firebase NOT ready → refreshing to re-establish');
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})`);
25442
25467
  try {
25443
- // refreshAccessToken() ya llama signInWithFirebase() en éxito.
25444
25468
  await firstValueFrom(this.refreshAccessToken());
25469
+ console.log(`[FBAuth] fallback — /refresh OK, Firebase re-establecido (motivo: ${reason})`);
25445
25470
  }
25446
25471
  catch (e) {
25447
- console.warn('[FBAuth] bootstrap — refresh to re-establish Firebase failed:', e);
25472
+ console.warn(`[FBAuth] fallback/refresh falló (motivo: ${reason}):`, e);
25448
25473
  }
25449
25474
  }
25450
25475
  // =============================================