@proveanything/smartlinks-auth-ui 0.3.11 → 0.3.12

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
@@ -10869,7 +10869,7 @@ class AuthAPI {
10869
10869
  });
10870
10870
  // Exchange authorization code for tokens via backend
10871
10871
  // Use direct HTTP call since SDK may not have this method in authKit namespace yet
10872
- return http.post(`/api/v1/authkit/${this.clientId}/google-code`, {
10872
+ return http.post(`/authkit/${this.clientId}/google-code`, {
10873
10873
  code,
10874
10874
  redirectUri,
10875
10875
  });
@@ -11660,32 +11660,42 @@ collectionId, enableContactSync, enableInteractionTracking, interactionAppId, in
11660
11660
  const initializeAuth = async () => {
11661
11661
  try {
11662
11662
  if (proxyMode) {
11663
- try {
11664
- const accountResponse = await smartlinks__namespace.auth.getAccount();
11665
- const accountAny = accountResponse;
11666
- const hasValidSession = accountAny?.uid && accountAny.uid.length > 0;
11667
- if (hasValidSession && isMounted) {
11668
- const userFromAccount = {
11669
- uid: accountAny.uid,
11670
- email: accountAny?.email,
11671
- displayName: accountAny?.displayName || accountAny?.name,
11672
- phoneNumber: accountAny?.phoneNumber,
11673
- };
11674
- setUser(userFromAccount);
11675
- setAccountData(accountResponse);
11676
- setAccountInfo(accountResponse);
11677
- setIsVerified(true);
11678
- notifyAuthStateChange('LOGIN', userFromAccount, null, accountResponse, accountResponse, true);
11679
- // Sync contact in background (proxy mode) - use ref for stable dependency
11680
- syncContactRef.current?.(userFromAccount, accountResponse);
11663
+ // Check if credentials exist before making the API call
11664
+ const headers = http.getApiHeaders();
11665
+ const hasBearer = !!headers['Authorization'];
11666
+ const hasSdkProxy = http.isProxyEnabled();
11667
+ if (!hasBearer && !hasSdkProxy) {
11668
+ console.debug('[AuthContext] Skipping getAccount - no credentials available');
11669
+ // Fall through to "no valid session" state
11670
+ }
11671
+ else {
11672
+ try {
11673
+ const accountResponse = await smartlinks__namespace.auth.getAccount();
11674
+ const accountAny = accountResponse;
11675
+ const hasValidSession = accountAny?.uid && accountAny.uid.length > 0;
11676
+ if (hasValidSession && isMounted) {
11677
+ const userFromAccount = {
11678
+ uid: accountAny.uid,
11679
+ email: accountAny?.email,
11680
+ displayName: accountAny?.displayName || accountAny?.name,
11681
+ phoneNumber: accountAny?.phoneNumber,
11682
+ };
11683
+ setUser(userFromAccount);
11684
+ setAccountData(accountResponse);
11685
+ setAccountInfo(accountResponse);
11686
+ setIsVerified(true);
11687
+ notifyAuthStateChange('LOGIN', userFromAccount, null, accountResponse, accountResponse, true);
11688
+ // Sync contact in background (proxy mode) - use ref for stable dependency
11689
+ syncContactRef.current?.(userFromAccount, accountResponse);
11690
+ }
11691
+ else if (isMounted) {
11692
+ // No valid session, awaiting login
11693
+ }
11681
11694
  }
11682
- else if (isMounted) {
11683
- // No valid session, awaiting login
11695
+ catch (error) {
11696
+ // auth.getAccount() failed, awaiting login
11684
11697
  }
11685
- }
11686
- catch (error) {
11687
- // auth.getAccount() failed, awaiting login
11688
- }
11698
+ } // end else (has credentials)
11689
11699
  if (isMounted) {
11690
11700
  setIsLoading(false);
11691
11701
  initializingRef.current = false;