@proveanything/smartlinks-auth-ui 0.1.14 → 0.1.15

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
@@ -11267,18 +11267,15 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
11267
11267
  const initializeAuth = async () => {
11268
11268
  try {
11269
11269
  if (proxyMode) {
11270
- // PROXY MODE: Initialize from URL params and parent via SDK
11271
- const params = new URLSearchParams(window.location.search);
11272
- const userId = params.get('userId');
11273
- if (userId) {
11274
- console.log('[AuthContext] Proxy mode: userId detected, fetching account from parent');
11275
- try {
11276
- // Fetch account details from parent via proxied API call
11277
- const accountResponse = await smartlinks__namespace.auth.getAccount();
11270
+ // PROXY MODE: Check for existing session via parent's auth.getAccount()
11271
+ console.log('[AuthContext] Proxy mode: checking for existing session via auth.getAccount()');
11272
+ try {
11273
+ const accountResponse = await smartlinks__namespace.auth.getAccount();
11274
+ if (accountResponse) {
11278
11275
  // Build user object from account response
11279
11276
  const accountAny = accountResponse;
11280
11277
  const userFromAccount = {
11281
- uid: userId,
11278
+ uid: accountAny?.uid || accountAny?.id || accountAny?.userId,
11282
11279
  email: accountAny?.email,
11283
11280
  displayName: accountAny?.displayName || accountAny?.name,
11284
11281
  phoneNumber: accountAny?.phoneNumber,
@@ -11289,13 +11286,13 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
11289
11286
  console.log('[AuthContext] Proxy mode: initialized from parent account');
11290
11287
  notifyAuthStateChange('LOGIN', userFromAccount, null, accountResponse, accountResponse);
11291
11288
  }
11292
- catch (error) {
11293
- console.warn('[AuthContext] Proxy mode: failed to fetch account from parent:', error);
11294
- // No session - that's ok, user may need to login
11289
+ else {
11290
+ console.log('[AuthContext] Proxy mode: no existing session, awaiting login');
11295
11291
  }
11296
11292
  }
11297
- else {
11298
- console.log('[AuthContext] Proxy mode: no userId in URL, awaiting login');
11293
+ 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
11299
11296
  }
11300
11297
  setIsLoading(false);
11301
11298
  return;