@blackcode_sa/metaestetics-api 1.14.9 → 1.14.10

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
@@ -15984,7 +15984,7 @@ var AuthService = class extends BaseService {
15984
15984
  * @returns Object containing user and claimed practitioner
15985
15985
  */
15986
15986
  async claimDraftProfilesWithGoogle(idToken, practitionerIds) {
15987
- var _a;
15987
+ var _a, _b;
15988
15988
  try {
15989
15989
  console.log("[AUTH] Starting claim draft profiles with Google", {
15990
15990
  practitionerIdsCount: practitionerIds.length,
@@ -15993,16 +15993,13 @@ var AuthService = class extends BaseService {
15993
15993
  if (practitionerIds.length === 0) {
15994
15994
  throw new AuthError("No practitioner profiles selected to claim", "AUTH/NO_PROFILES_SELECTED", 400);
15995
15995
  }
15996
- let firebaseUser = this.auth.currentUser;
15997
- if (!firebaseUser) {
15998
- console.log("[AUTH] No current user, re-authenticating with Google credential");
15999
- const credential = import_auth8.GoogleAuthProvider.credential(idToken);
16000
- const result = await (0, import_auth8.signInWithCredential)(this.auth, credential);
16001
- firebaseUser = result.user;
16002
- }
16003
- console.log("[AUTH] Using Firebase user:", firebaseUser.uid);
16004
- await this.waitForAuthState(firebaseUser.uid);
16005
- console.log("[AUTH] Auth state after waitForAuthState:", ((_a = this.auth.currentUser) == null ? void 0 : _a.uid) || "NULL");
15996
+ console.log("[AUTH] currentUser BEFORE sign-in:", ((_a = this.auth.currentUser) == null ? void 0 : _a.uid) || "NULL");
15997
+ console.log("[AUTH] Signing in with Google credential...");
15998
+ const credential = import_auth8.GoogleAuthProvider.credential(idToken);
15999
+ const result = await (0, import_auth8.signInWithCredential)(this.auth, credential);
16000
+ const firebaseUser = result.user;
16001
+ console.log("[AUTH] currentUser IMMEDIATELY AFTER sign-in:", ((_b = this.auth.currentUser) == null ? void 0 : _b.uid) || "NULL");
16002
+ console.log("[AUTH] User returned from signInWithCredential:", firebaseUser.uid);
16006
16003
  const practitionerService = new PractitionerService(this.db, this.auth, this.app);
16007
16004
  let user = null;
16008
16005
  try {
package/dist/index.mjs CHANGED
@@ -16071,7 +16071,7 @@ var AuthService = class extends BaseService {
16071
16071
  * @returns Object containing user and claimed practitioner
16072
16072
  */
16073
16073
  async claimDraftProfilesWithGoogle(idToken, practitionerIds) {
16074
- var _a;
16074
+ var _a, _b;
16075
16075
  try {
16076
16076
  console.log("[AUTH] Starting claim draft profiles with Google", {
16077
16077
  practitionerIdsCount: practitionerIds.length,
@@ -16080,16 +16080,13 @@ var AuthService = class extends BaseService {
16080
16080
  if (practitionerIds.length === 0) {
16081
16081
  throw new AuthError("No practitioner profiles selected to claim", "AUTH/NO_PROFILES_SELECTED", 400);
16082
16082
  }
16083
- let firebaseUser = this.auth.currentUser;
16084
- if (!firebaseUser) {
16085
- console.log("[AUTH] No current user, re-authenticating with Google credential");
16086
- const credential = GoogleAuthProvider.credential(idToken);
16087
- const result = await signInWithCredential(this.auth, credential);
16088
- firebaseUser = result.user;
16089
- }
16090
- console.log("[AUTH] Using Firebase user:", firebaseUser.uid);
16091
- await this.waitForAuthState(firebaseUser.uid);
16092
- console.log("[AUTH] Auth state after waitForAuthState:", ((_a = this.auth.currentUser) == null ? void 0 : _a.uid) || "NULL");
16083
+ console.log("[AUTH] currentUser BEFORE sign-in:", ((_a = this.auth.currentUser) == null ? void 0 : _a.uid) || "NULL");
16084
+ console.log("[AUTH] Signing in with Google credential...");
16085
+ const credential = GoogleAuthProvider.credential(idToken);
16086
+ const result = await signInWithCredential(this.auth, credential);
16087
+ const firebaseUser = result.user;
16088
+ console.log("[AUTH] currentUser IMMEDIATELY AFTER sign-in:", ((_b = this.auth.currentUser) == null ? void 0 : _b.uid) || "NULL");
16089
+ console.log("[AUTH] User returned from signInWithCredential:", firebaseUser.uid);
16093
16090
  const practitionerService = new PractitionerService(this.db, this.auth, this.app);
16094
16091
  let user = null;
16095
16092
  try {
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.9",
4
+ "version": "1.14.10",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -874,28 +874,18 @@ export class AuthService extends BaseService {
874
874
  throw new AuthError('No practitioner profiles selected to claim', 'AUTH/NO_PROFILES_SELECTED', 400);
875
875
  }
876
876
 
877
- // Check if user is currently signed in, if not re-authenticate
878
- let firebaseUser = this.auth.currentUser;
879
- if (!firebaseUser) {
880
- console.log('[AUTH] No current user, re-authenticating with Google credential');
881
- const credential = GoogleAuthProvider.credential(idToken);
882
- const result = await signInWithCredential(this.auth, credential);
883
- firebaseUser = result.user;
884
- }
885
- console.log('[AUTH] Using Firebase user:', firebaseUser.uid);
886
-
887
- // CRITICAL: Wait for auth state to settle in React Native
888
- // The Firebase JS SDK doesn't update auth.currentUser synchronously after signInWithCredential
889
- // This causes Firestore to not see the authenticated user, resulting in permission denied
890
- await this.waitForAuthState(firebaseUser.uid);
877
+ // Check auth state BEFORE sign-in
878
+ console.log('[AUTH] currentUser BEFORE sign-in:', this.auth.currentUser?.uid || 'NULL');
891
879
 
892
- // Verify auth state BEFORE any other operations
893
- console.log('[AUTH] Auth state after waitForAuthState:', this.auth.currentUser?.uid || 'NULL');
880
+ // Sign in with Google credential
881
+ console.log('[AUTH] Signing in with Google credential...');
882
+ const credential = GoogleAuthProvider.credential(idToken);
883
+ const result = await signInWithCredential(this.auth, credential);
884
+ const firebaseUser = result.user;
894
885
 
895
- // DON'T force token refresh - it might be clearing auth state in React Native!
896
- // console.log('[AUTH] Forcing token refresh...');
897
- // await firebaseUser.getIdToken(true);
898
- // console.log('[AUTH] Token refreshed successfully');
886
+ // Check auth state IMMEDIATELY AFTER sign-in
887
+ console.log('[AUTH] currentUser IMMEDIATELY AFTER sign-in:', this.auth.currentUser?.uid || 'NULL');
888
+ console.log('[AUTH] User returned from signInWithCredential:', firebaseUser.uid);
899
889
 
900
890
  const practitionerService = new PractitionerService(this.db, this.auth, this.app);
901
891