@blackcode_sa/metaestetics-api 1.14.15 → 1.14.16

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.d.mts CHANGED
@@ -8321,16 +8321,6 @@ declare class AuthService extends BaseService {
8321
8321
  private googleProvider;
8322
8322
  private userService;
8323
8323
  constructor(db: Firestore, auth: Auth, app: FirebaseApp, userService: UserService);
8324
- /**
8325
- * Waits for Firebase Auth state to settle after sign-in.
8326
- * In React Native with Firebase JS SDK, auth.currentUser doesn't update synchronously
8327
- * after signInWithCredential. This causes Firestore permission issues.
8328
- *
8329
- * @param expectedUid - The UID we expect to see in auth.currentUser
8330
- * @param timeoutMs - Maximum time to wait (default 10 seconds)
8331
- * @returns Promise that resolves when auth state is ready
8332
- */
8333
- private waitForAuthState;
8334
8324
  /**
8335
8325
  * Registruje novog korisnika sa email-om i lozinkom
8336
8326
  */
package/dist/index.d.ts CHANGED
@@ -8321,16 +8321,6 @@ declare class AuthService extends BaseService {
8321
8321
  private googleProvider;
8322
8322
  private userService;
8323
8323
  constructor(db: Firestore, auth: Auth, app: FirebaseApp, userService: UserService);
8324
- /**
8325
- * Waits for Firebase Auth state to settle after sign-in.
8326
- * In React Native with Firebase JS SDK, auth.currentUser doesn't update synchronously
8327
- * after signInWithCredential. This causes Firestore permission issues.
8328
- *
8329
- * @param expectedUid - The UID we expect to see in auth.currentUser
8330
- * @param timeoutMs - Maximum time to wait (default 10 seconds)
8331
- * @returns Promise that resolves when auth state is ready
8332
- */
8333
- private waitForAuthState;
8334
8324
  /**
8335
8325
  * Registruje novog korisnika sa email-om i lozinkom
8336
8326
  */
package/dist/index.js CHANGED
@@ -15388,45 +15388,19 @@ var AuthService = class extends BaseService {
15388
15388
  super(db, auth, app);
15389
15389
  this.googleProvider = new import_auth8.GoogleAuthProvider();
15390
15390
  this.userService = userService || new UserService(db, auth, app);
15391
- if (!this.auth.__authServiceId) {
15392
- this.auth.__authServiceId = "auth-service-" + Date.now();
15393
- }
15394
- console.log("[AUTH] AuthService constructor - auth ID:", this.auth.__authServiceId);
15395
- console.log("[AUTH] AuthService constructor - userService.auth ID:", ((_a = this.userService.auth) == null ? void 0 : _a.__authServiceId) || "NOT SET");
15396
- }
15397
- /**
15398
- * Waits for Firebase Auth state to settle after sign-in.
15399
- * In React Native with Firebase JS SDK, auth.currentUser doesn't update synchronously
15400
- * after signInWithCredential. This causes Firestore permission issues.
15401
- *
15402
- * @param expectedUid - The UID we expect to see in auth.currentUser
15403
- * @param timeoutMs - Maximum time to wait (default 10 seconds)
15404
- * @returns Promise that resolves when auth state is ready
15405
- */
15406
- waitForAuthState(expectedUid, timeoutMs = 1e4) {
15407
- return new Promise((resolve, reject) => {
15408
- var _a;
15409
- if (((_a = this.auth.currentUser) == null ? void 0 : _a.uid) === expectedUid) {
15410
- console.log("[AUTH] Auth state already settled for:", expectedUid);
15411
- resolve();
15412
- return;
15413
- }
15414
- console.log("[AUTH] Waiting for auth state to settle for:", expectedUid);
15415
- const timeout = setTimeout(() => {
15416
- unsubscribe();
15417
- console.error("[AUTH] Timeout waiting for auth state");
15418
- reject(new Error("Timeout waiting for auth state to settle"));
15419
- }, timeoutMs);
15420
- const unsubscribe = (0, import_auth8.onAuthStateChanged)(this.auth, (user) => {
15421
- console.log("[AUTH] Auth state changed:", (user == null ? void 0 : user.uid) || "null");
15422
- if ((user == null ? void 0 : user.uid) === expectedUid) {
15423
- clearTimeout(timeout);
15424
- unsubscribe();
15425
- console.log("[AUTH] Auth state settled successfully for:", expectedUid);
15426
- resolve();
15427
- }
15428
- });
15391
+ (0, import_auth8.onAuthStateChanged)(this.auth, (user) => {
15392
+ var _a2, _b;
15393
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
15394
+ const stackTrace = ((_a2 = new Error().stack) == null ? void 0 : _a2.split("\n").slice(2, 5).join("\n")) || "N/A";
15395
+ console.log(`[AUTH STATE CHANGE] ${timestamp}`);
15396
+ console.log(`[AUTH STATE CHANGE] User: ${(user == null ? void 0 : user.uid) || "NULL"} (email: ${(user == null ? void 0 : user.email) || "N/A"})`);
15397
+ console.log(`[AUTH STATE CHANGE] auth.currentUser: ${((_b = this.auth.currentUser) == null ? void 0 : _b.uid) || "NULL"}`);
15398
+ console.log(`[AUTH STATE CHANGE] Stack trace (first 3 frames):
15399
+ ${stackTrace}`);
15400
+ console.log("[AUTH STATE CHANGE] ---");
15429
15401
  });
15402
+ console.log("[AUTH] AuthService initialized");
15403
+ console.log("[AUTH] Initial auth.currentUser:", ((_a = this.auth.currentUser) == null ? void 0 : _a.uid) || "NULL");
15430
15404
  }
15431
15405
  /**
15432
15406
  * Registruje novog korisnika sa email-om i lozinkom
package/dist/index.mjs CHANGED
@@ -15475,45 +15475,19 @@ var AuthService = class extends BaseService {
15475
15475
  super(db, auth, app);
15476
15476
  this.googleProvider = new GoogleAuthProvider();
15477
15477
  this.userService = userService || new UserService(db, auth, app);
15478
- if (!this.auth.__authServiceId) {
15479
- this.auth.__authServiceId = "auth-service-" + Date.now();
15480
- }
15481
- console.log("[AUTH] AuthService constructor - auth ID:", this.auth.__authServiceId);
15482
- console.log("[AUTH] AuthService constructor - userService.auth ID:", ((_a = this.userService.auth) == null ? void 0 : _a.__authServiceId) || "NOT SET");
15483
- }
15484
- /**
15485
- * Waits for Firebase Auth state to settle after sign-in.
15486
- * In React Native with Firebase JS SDK, auth.currentUser doesn't update synchronously
15487
- * after signInWithCredential. This causes Firestore permission issues.
15488
- *
15489
- * @param expectedUid - The UID we expect to see in auth.currentUser
15490
- * @param timeoutMs - Maximum time to wait (default 10 seconds)
15491
- * @returns Promise that resolves when auth state is ready
15492
- */
15493
- waitForAuthState(expectedUid, timeoutMs = 1e4) {
15494
- return new Promise((resolve, reject) => {
15495
- var _a;
15496
- if (((_a = this.auth.currentUser) == null ? void 0 : _a.uid) === expectedUid) {
15497
- console.log("[AUTH] Auth state already settled for:", expectedUid);
15498
- resolve();
15499
- return;
15500
- }
15501
- console.log("[AUTH] Waiting for auth state to settle for:", expectedUid);
15502
- const timeout = setTimeout(() => {
15503
- unsubscribe();
15504
- console.error("[AUTH] Timeout waiting for auth state");
15505
- reject(new Error("Timeout waiting for auth state to settle"));
15506
- }, timeoutMs);
15507
- const unsubscribe = onAuthStateChanged(this.auth, (user) => {
15508
- console.log("[AUTH] Auth state changed:", (user == null ? void 0 : user.uid) || "null");
15509
- if ((user == null ? void 0 : user.uid) === expectedUid) {
15510
- clearTimeout(timeout);
15511
- unsubscribe();
15512
- console.log("[AUTH] Auth state settled successfully for:", expectedUid);
15513
- resolve();
15514
- }
15515
- });
15478
+ onAuthStateChanged(this.auth, (user) => {
15479
+ var _a2, _b;
15480
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
15481
+ const stackTrace = ((_a2 = new Error().stack) == null ? void 0 : _a2.split("\n").slice(2, 5).join("\n")) || "N/A";
15482
+ console.log(`[AUTH STATE CHANGE] ${timestamp}`);
15483
+ console.log(`[AUTH STATE CHANGE] User: ${(user == null ? void 0 : user.uid) || "NULL"} (email: ${(user == null ? void 0 : user.email) || "N/A"})`);
15484
+ console.log(`[AUTH STATE CHANGE] auth.currentUser: ${((_b = this.auth.currentUser) == null ? void 0 : _b.uid) || "NULL"}`);
15485
+ console.log(`[AUTH STATE CHANGE] Stack trace (first 3 frames):
15486
+ ${stackTrace}`);
15487
+ console.log("[AUTH STATE CHANGE] ---");
15516
15488
  });
15489
+ console.log("[AUTH] AuthService initialized");
15490
+ console.log("[AUTH] Initial auth.currentUser:", ((_a = this.auth.currentUser) == null ? void 0 : _a.uid) || "NULL");
15517
15491
  }
15518
15492
  /**
15519
15493
  * Registruje novog korisnika sa email-om i lozinkom
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.15",
4
+ "version": "1.14.16",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -92,54 +92,22 @@ export class AuthService extends BaseService {
92
92
  super(db, auth, app);
93
93
  this.userService = userService || new UserService(db, auth, app);
94
94
 
95
- // DEBUG: Tag the auth instances to track them
96
- // @ts-ignore
97
- if (!this.auth.__authServiceId) {
98
- // @ts-ignore
99
- this.auth.__authServiceId = 'auth-service-' + Date.now();
100
- }
101
- // @ts-ignore
102
- console.log('[AUTH] AuthService constructor - auth ID:', this.auth.__authServiceId);
103
- // @ts-ignore
104
- console.log('[AUTH] AuthService constructor - userService.auth ID:', (this.userService as any).auth?.__authServiceId || 'NOT SET');
105
- }
106
-
107
- /**
108
- * Waits for Firebase Auth state to settle after sign-in.
109
- * In React Native with Firebase JS SDK, auth.currentUser doesn't update synchronously
110
- * after signInWithCredential. This causes Firestore permission issues.
111
- *
112
- * @param expectedUid - The UID we expect to see in auth.currentUser
113
- * @param timeoutMs - Maximum time to wait (default 10 seconds)
114
- * @returns Promise that resolves when auth state is ready
115
- */
116
- private waitForAuthState(expectedUid: string, timeoutMs: number = 10000): Promise<void> {
117
- return new Promise((resolve, reject) => {
118
- // If already correct, resolve immediately
119
- if (this.auth.currentUser?.uid === expectedUid) {
120
- console.log('[AUTH] Auth state already settled for:', expectedUid);
121
- resolve();
122
- return;
123
- }
124
-
125
- console.log('[AUTH] Waiting for auth state to settle for:', expectedUid);
126
-
127
- const timeout = setTimeout(() => {
128
- unsubscribe();
129
- console.error('[AUTH] Timeout waiting for auth state');
130
- reject(new Error('Timeout waiting for auth state to settle'));
131
- }, timeoutMs);
132
-
133
- const unsubscribe = onAuthStateChanged(this.auth, (user) => {
134
- console.log('[AUTH] Auth state changed:', user?.uid || 'null');
135
- if (user?.uid === expectedUid) {
136
- clearTimeout(timeout);
137
- unsubscribe();
138
- console.log('[AUTH] Auth state settled successfully for:', expectedUid);
139
- resolve();
140
- }
141
- });
95
+ // Initialize auth state change listener for debugging
96
+ // This helps track when auth.currentUser changes, which is critical for debugging
97
+ // the permission-denied issue during user document creation
98
+ onAuthStateChanged(this.auth, (user) => {
99
+ const timestamp = new Date().toISOString();
100
+ const stackTrace = new Error().stack?.split('\n').slice(2, 5).join('\n') || 'N/A';
101
+ console.log(`[AUTH STATE CHANGE] ${timestamp}`);
102
+ console.log(`[AUTH STATE CHANGE] User: ${user?.uid || 'NULL'} (email: ${user?.email || 'N/A'})`);
103
+ console.log(`[AUTH STATE CHANGE] auth.currentUser: ${this.auth.currentUser?.uid || 'NULL'}`);
104
+ console.log(`[AUTH STATE CHANGE] Stack trace (first 3 frames):\n${stackTrace}`);
105
+ console.log('[AUTH STATE CHANGE] ---');
142
106
  });
107
+
108
+ // Log initial auth state
109
+ console.log('[AUTH] AuthService initialized');
110
+ console.log('[AUTH] Initial auth.currentUser:', this.auth.currentUser?.uid || 'NULL');
143
111
  }
144
112
 
145
113
  /**