@blackcode_sa/metaestetics-api 1.14.17 → 1.14.18

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/dist/index.js CHANGED
@@ -16301,8 +16301,11 @@ ${stackTrace}`);
16301
16301
  console.error("[AUTH] \u274C auth.currentUser became NULL before draft profile query!");
16302
16302
  console.error("[AUTH] Expected UID:", firebaseUser2.uid);
16303
16303
  console.error("[AUTH] Actual auth.currentUser:", ((_b = this.auth.currentUser) == null ? void 0 : _b.uid) || "NULL");
16304
- console.log("[AUTH] Waiting for auth state to recover...");
16304
+ console.log("[AUTH] Re-signing in to restore auth state before query...");
16305
+ const credential3 = import_auth8.GoogleAuthProvider.credential(idToken);
16306
+ await (0, import_auth8.signInWithCredential)(this.auth, credential3);
16305
16307
  await this.waitForAuthStateToSettle(firebaseUser2.uid, 2e3);
16308
+ console.log("[AUTH] \u2705 Auth state restored, proceeding with query");
16306
16309
  }
16307
16310
  const practitionerService2 = new PractitionerService(this.db, this.auth, this.app);
16308
16311
  const draftProfiles3 = await practitionerService2.getDraftProfilesByEmail(normalizedEmail);
package/dist/index.mjs CHANGED
@@ -16388,8 +16388,11 @@ ${stackTrace}`);
16388
16388
  console.error("[AUTH] \u274C auth.currentUser became NULL before draft profile query!");
16389
16389
  console.error("[AUTH] Expected UID:", firebaseUser2.uid);
16390
16390
  console.error("[AUTH] Actual auth.currentUser:", ((_b = this.auth.currentUser) == null ? void 0 : _b.uid) || "NULL");
16391
- console.log("[AUTH] Waiting for auth state to recover...");
16391
+ console.log("[AUTH] Re-signing in to restore auth state before query...");
16392
+ const credential3 = GoogleAuthProvider.credential(idToken);
16393
+ await signInWithCredential(this.auth, credential3);
16392
16394
  await this.waitForAuthStateToSettle(firebaseUser2.uid, 2e3);
16395
+ console.log("[AUTH] \u2705 Auth state restored, proceeding with query");
16393
16396
  }
16394
16397
  const practitionerService2 = new PractitionerService(this.db, this.auth, this.app);
16395
16398
  const draftProfiles3 = await practitionerService2.getDraftProfilesByEmail(normalizedEmail);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.14.17",
4
+ "version": "1.14.18",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -1288,15 +1288,23 @@ export class AuthService extends BaseService {
1288
1288
  });
1289
1289
 
1290
1290
  // Check for draft profiles before signing out
1291
- // CRITICAL: Verify auth.currentUser is still set before Firestore query
1292
- // AsyncStorage persistence can cause it to become NULL even after being set
1291
+ // CRITICAL: Firestore queries can trigger AsyncStorage reads which overwrite auth.currentUser
1292
+ // If auth.currentUser is NULL, re-sign in immediately to restore it before the query
1293
1293
  if (!this.auth.currentUser || this.auth.currentUser.uid !== firebaseUser.uid) {
1294
1294
  console.error('[AUTH] ❌ auth.currentUser became NULL before draft profile query!');
1295
1295
  console.error('[AUTH] Expected UID:', firebaseUser.uid);
1296
1296
  console.error('[AUTH] Actual auth.currentUser:', this.auth.currentUser?.uid || 'NULL');
1297
- console.log('[AUTH] Waiting for auth state to recover...');
1298
- // Try to wait for it to come back
1297
+ console.log('[AUTH] Re-signing in to restore auth state before query...');
1298
+
1299
+ // Re-sign in with the credential to restore auth.currentUser
1300
+ // This is the most reliable way to ensure auth state is set before Firestore queries
1301
+ const credential = GoogleAuthProvider.credential(idToken);
1302
+ await signInWithCredential(this.auth, credential);
1303
+
1304
+ // Wait for auth state to settle after re-sign-in
1299
1305
  await this.waitForAuthStateToSettle(firebaseUser.uid, 2000);
1306
+
1307
+ console.log('[AUTH] ✅ Auth state restored, proceeding with query');
1300
1308
  }
1301
1309
 
1302
1310
  const practitionerService = new PractitionerService(this.db, this.auth, this.app);