valtech-components 2.0.825 → 2.0.827
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 +3 -1
- package/esm2022/lib/services/firebase/firebase.service.mjs +12 -2
- package/esm2022/lib/services/firebase/notifications.service.mjs +10 -3
- package/esm2022/lib/services/refreshable-stream/refreshable-stream.mjs +16 -4
- package/esm2022/lib/version.mjs +2 -2
- package/fesm2022/valtech-components.mjs +37 -6
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/atoms/rights-footer/rights-footer.component.d.ts +1 -1
- package/lib/components/atoms/text/text.component.d.ts +1 -1
- package/lib/components/atoms/user-avatar/user-avatar.component.d.ts +1 -1
- package/lib/components/molecules/features-list/features-list.component.d.ts +1 -1
- package/lib/components/molecules/username-input/username-input.component.d.ts +1 -1
- package/lib/components/organisms/article/article.component.d.ts +5 -5
- package/lib/components/organisms/toolbar/toolbar.component.d.ts +2 -2
- package/lib/components/templates/page-wrapper/page-wrapper.component.d.ts +2 -2
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/lib/services/firebase/firebase-messaging-sw.js +19 -8
|
@@ -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.827';
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Servicio para gestionar presets de componentes.
|
|
@@ -21509,6 +21509,7 @@ class FirebaseService {
|
|
|
21509
21509
|
// true al haber User, false en signout. Permite que los gates
|
|
21510
21510
|
// re-evalúen tras un logout/login dentro de la misma sesión de página.
|
|
21511
21511
|
this._firebaseAuthReady.set(!!user);
|
|
21512
|
+
console.log(`[FBAuth] authState emit user=${user?.uid ?? 'null'} firebaseAuthReady=${!!user}`);
|
|
21512
21513
|
this.sessionState.next({
|
|
21513
21514
|
user: user ? this.mapUser(user) : null,
|
|
21514
21515
|
isAuthenticated: !!user,
|
|
@@ -21518,6 +21519,7 @@ class FirebaseService {
|
|
|
21518
21519
|
},
|
|
21519
21520
|
error: error => {
|
|
21520
21521
|
this._firebaseAuthReady.set(false);
|
|
21522
|
+
console.error(`[FBAuth] authState ERROR: ${error instanceof Error ? error.message : String(error)}`);
|
|
21521
21523
|
this.sessionState.next({
|
|
21522
21524
|
user: null,
|
|
21523
21525
|
isAuthenticated: false,
|
|
@@ -21536,9 +21538,14 @@ class FirebaseService {
|
|
|
21536
21538
|
*/
|
|
21537
21539
|
whenFirebaseAuthReady() {
|
|
21538
21540
|
if (this._firebaseAuthReady()) {
|
|
21541
|
+
console.log('[FBAuth] whenFirebaseAuthReady resolved immediately (already ready)');
|
|
21539
21542
|
return Promise.resolve(true);
|
|
21540
21543
|
}
|
|
21541
|
-
|
|
21544
|
+
console.log('[FBAuth] whenFirebaseAuthReady waiting for Firebase Auth session...');
|
|
21545
|
+
return firstValueFrom(this.firebaseAuthReady$).then(v => {
|
|
21546
|
+
console.log('[FBAuth] whenFirebaseAuthReady resolved after wait');
|
|
21547
|
+
return v;
|
|
21548
|
+
});
|
|
21542
21549
|
}
|
|
21543
21550
|
// ===========================================================================
|
|
21544
21551
|
// AUTENTICACIÓN
|
|
@@ -21558,6 +21565,7 @@ class FirebaseService {
|
|
|
21558
21565
|
* ```
|
|
21559
21566
|
*/
|
|
21560
21567
|
async signInWithCustomToken(token) {
|
|
21568
|
+
console.log(`[FBAuth] signInWithCustomToken called tokenLen=${token?.length ?? 0}`);
|
|
21561
21569
|
try {
|
|
21562
21570
|
const credential = await signInWithCustomToken(this.auth, token);
|
|
21563
21571
|
// Forzar refresh del token para asegurar que los claims estén actualizados
|
|
@@ -21565,10 +21573,12 @@ class FirebaseService {
|
|
|
21565
21573
|
if (credential.user) {
|
|
21566
21574
|
await credential.user.getIdToken(true);
|
|
21567
21575
|
}
|
|
21576
|
+
console.log(`[FBAuth] signInWithCustomToken OK uid=${credential.user?.uid ?? 'null'}`);
|
|
21568
21577
|
return credential;
|
|
21569
21578
|
}
|
|
21570
21579
|
catch (error) {
|
|
21571
21580
|
const message = this.getErrorMessage(error);
|
|
21581
|
+
console.error(`[FBAuth] signInWithCustomToken FAILED: ${message}`);
|
|
21572
21582
|
throw new Error(message);
|
|
21573
21583
|
}
|
|
21574
21584
|
}
|
|
@@ -23766,8 +23776,11 @@ class NotificationsService {
|
|
|
23766
23776
|
return this.collectionReady$.asObservable();
|
|
23767
23777
|
}
|
|
23768
23778
|
return this.collectionReady$.pipe(switchMap(collection => {
|
|
23769
|
-
if (!collection)
|
|
23779
|
+
if (!collection) {
|
|
23780
|
+
console.log('[Notifs] collectionWhenAuthReady$ — collection is null (not initialized)');
|
|
23770
23781
|
return of(null);
|
|
23782
|
+
}
|
|
23783
|
+
console.log('[Notifs] collectionWhenAuthReady$ — collection ready, awaiting Firebase Auth');
|
|
23771
23784
|
return from(fb.whenFirebaseAuthReady()).pipe(map$1(() => collection));
|
|
23772
23785
|
}));
|
|
23773
23786
|
}
|
|
@@ -23810,6 +23823,7 @@ class NotificationsService {
|
|
|
23810
23823
|
* un userId diferente al del usuario autenticado.
|
|
23811
23824
|
*/
|
|
23812
23825
|
initialize(userId) {
|
|
23826
|
+
console.log(`[Notifs] initialize uid=${userId}`);
|
|
23813
23827
|
if (!this.collectionFactory) {
|
|
23814
23828
|
console.warn('[Notifications] FirestoreCollectionFactory not available. Ensure provideValtechFirebase() is configured.');
|
|
23815
23829
|
return;
|
|
@@ -23853,8 +23867,11 @@ class NotificationsService {
|
|
|
23853
23867
|
*/
|
|
23854
23868
|
getAll(limit = DEFAULT_LIMIT) {
|
|
23855
23869
|
return this.collectionWhenAuthReady$().pipe(switchMap(collection => {
|
|
23856
|
-
if (!collection)
|
|
23870
|
+
if (!collection) {
|
|
23871
|
+
console.warn('[Notifs] getAll — collection null → returning EMPTY (no emission)');
|
|
23857
23872
|
return EMPTY;
|
|
23873
|
+
}
|
|
23874
|
+
console.log('[Notifs] getAll — attaching Firestore watchAll listener');
|
|
23858
23875
|
return collection.watchAll({
|
|
23859
23876
|
orderBy: [{ field: 'createdAt', direction: 'desc' }],
|
|
23860
23877
|
limit,
|
|
@@ -25355,6 +25372,8 @@ class AuthService {
|
|
|
25355
25372
|
// FIREBASE INTEGRATION
|
|
25356
25373
|
// =============================================
|
|
25357
25374
|
async signInWithFirebase(firebaseToken) {
|
|
25375
|
+
console.log(`[FBAuth] auth flow → signInWithFirebase attempt tokenLen=${firebaseToken?.length ?? 0} ` +
|
|
25376
|
+
`firebaseServicePresent=${!!this.firebaseService}`);
|
|
25358
25377
|
try {
|
|
25359
25378
|
if (this.firebaseService) {
|
|
25360
25379
|
await this.firebaseService.signInWithCustomToken(firebaseToken);
|
|
@@ -38521,8 +38540,18 @@ function createRefreshableStream(factory, options) {
|
|
|
38521
38540
|
// sesión NUNCA se establece (token inválido, signInWithFirebase falló), el
|
|
38522
38541
|
// gate igual se libera tras `authGateTimeoutMs` y la factory procede: si no
|
|
38523
38542
|
// hay permiso terminará en estado `error`, jamás en skeleton infinito.
|
|
38543
|
+
// Tag los dos inputs del `race` para distinguir en logs cuál ganó: la sesión
|
|
38544
|
+
// de Firebase Auth (`auth-ready`) o el timeout de seguridad (`timeout`).
|
|
38524
38545
|
const authGate$ = firebase
|
|
38525
|
-
? race(firebase.firebaseAuthReady
|
|
38546
|
+
? race(firebase.firebaseAuthReady$.pipe(map$1(() => 'auth-ready')), timer(authGateTimeoutMs).pipe(map$1(() => 'timeout'))).pipe(take(1), tap(winner => {
|
|
38547
|
+
if (winner === 'timeout') {
|
|
38548
|
+
console.warn(`[RefreshStream] auth gate resolved by TIMEOUT after ${authGateTimeoutMs}ms ` +
|
|
38549
|
+
'(Firebase Auth session never confirmed)');
|
|
38550
|
+
}
|
|
38551
|
+
else {
|
|
38552
|
+
console.log('[RefreshStream] auth gate resolved by firebaseAuthReady$ (session ready)');
|
|
38553
|
+
}
|
|
38554
|
+
}))
|
|
38526
38555
|
: of(true);
|
|
38527
38556
|
const data = toSignal(toObservable(_reload, { injector }).pipe(tap(() => {
|
|
38528
38557
|
_loading.set(true);
|
|
@@ -38534,6 +38563,7 @@ function createRefreshableStream(factory, options) {
|
|
|
38534
38563
|
switchMap(() => authGate$.pipe(switchMap(() => factory().pipe(tap(() => {
|
|
38535
38564
|
_loading.set(false);
|
|
38536
38565
|
_error.set(false);
|
|
38566
|
+
console.log('[RefreshStream] factory emitted first value — loading=false');
|
|
38537
38567
|
}),
|
|
38538
38568
|
// Backoff corto exponencial acotado — solo red de seguridad para
|
|
38539
38569
|
// reconexiones transitorias, NO para cubrir cold start.
|
|
@@ -38546,9 +38576,10 @@ function createRefreshableStream(factory, options) {
|
|
|
38546
38576
|
// silencio), `timeout` dispara un error → `catchError` → estado
|
|
38547
38577
|
// `error`. Nunca skeleton perpetuo. Va DESPUÉS de `retry` para
|
|
38548
38578
|
// que cuente el tiempo total, no por intento.
|
|
38549
|
-
timeout({ first: firstEmitTimeoutMs }), catchError(
|
|
38579
|
+
timeout({ first: firstEmitTimeoutMs }), catchError(err => {
|
|
38550
38580
|
_loading.set(false);
|
|
38551
38581
|
_error.set(true);
|
|
38582
|
+
console.error(`[RefreshStream] factory failed/timed out → error state: ${err instanceof Error ? err.message : String(err)}`);
|
|
38552
38583
|
return of(fallback);
|
|
38553
38584
|
})))))), { initialValue: null, injector });
|
|
38554
38585
|
return {
|