@proveanything/smartlinks-auth-ui 0.1.15 → 0.1.17

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
@@ -11271,11 +11271,14 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
11271
11271
  console.log('[AuthContext] Proxy mode: checking for existing session via auth.getAccount()');
11272
11272
  try {
11273
11273
  const accountResponse = await smartlinks__namespace.auth.getAccount();
11274
- if (accountResponse) {
11275
- // Build user object from account response
11276
- const accountAny = accountResponse;
11274
+ // auth.getAccount() always returns a response object, but uid will be
11275
+ // empty/undefined if no user is logged in
11276
+ const accountAny = accountResponse;
11277
+ const hasValidSession = accountAny?.uid && accountAny.uid.length > 0;
11278
+ if (hasValidSession) {
11279
+ // User is logged in with valid account
11277
11280
  const userFromAccount = {
11278
- uid: accountAny?.uid || accountAny?.id || accountAny?.userId,
11281
+ uid: accountAny.uid,
11279
11282
  email: accountAny?.email,
11280
11283
  displayName: accountAny?.displayName || accountAny?.name,
11281
11284
  phoneNumber: accountAny?.phoneNumber,
@@ -11283,16 +11286,15 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
11283
11286
  setUser(userFromAccount);
11284
11287
  setAccountData(accountResponse);
11285
11288
  setAccountInfo(accountResponse);
11286
- console.log('[AuthContext] Proxy mode: initialized from parent account');
11289
+ console.log('[AuthContext] Proxy mode: initialized from parent account, uid:', accountAny.uid);
11287
11290
  notifyAuthStateChange('LOGIN', userFromAccount, null, accountResponse, accountResponse);
11288
11291
  }
11289
11292
  else {
11290
- console.log('[AuthContext] Proxy mode: no existing session, awaiting login');
11293
+ console.log('[AuthContext] Proxy mode: no valid session (no uid), awaiting login');
11291
11294
  }
11292
11295
  }
11293
11296
  catch (error) {
11294
- console.log('[AuthContext] Proxy mode: no existing session (auth.getAccount returned error), awaiting login');
11295
- // No session - that's ok, user may need to login
11297
+ console.log('[AuthContext] Proxy mode: auth.getAccount() failed, awaiting login:', error);
11296
11298
  }
11297
11299
  setIsLoading(false);
11298
11300
  return;