@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.
@@ -1 +1 @@
1
- {"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAMnG,OAAO,KAAK,EAAqC,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGvG,eAAO,MAAM,WAAW,6CAAyD,CAAC;AAGlF,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAq0BpD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,gBAM1B,CAAC"}
1
+ {"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAOnG,OAAO,KAAK,EAAqC,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGvG,eAAO,MAAM,WAAW,6CAAyD,CAAC;AAGlF,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA+0BpD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,gBAM1B,CAAC"}
package/dist/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import React, { useEffect, useState, useMemo, useRef, useCallback, createContext, useContext } from 'react';
3
3
  import * as smartlinks from '@proveanything/smartlinks';
4
4
  import { iframe, SmartlinksApiError } from '@proveanything/smartlinks';
5
- import { post } from '@proveanything/smartlinks/dist/http';
5
+ import { post, getApiHeaders, isProxyEnabled } from '@proveanything/smartlinks/dist/http';
6
6
 
7
7
  const AuthContainer = ({ children, theme = 'light', className = '', config, minimal = false, }) => {
8
8
  // Apply CSS variables for customization
@@ -10849,7 +10849,7 @@ class AuthAPI {
10849
10849
  });
10850
10850
  // Exchange authorization code for tokens via backend
10851
10851
  // Use direct HTTP call since SDK may not have this method in authKit namespace yet
10852
- return post(`/api/v1/authkit/${this.clientId}/google-code`, {
10852
+ return post(`/authkit/${this.clientId}/google-code`, {
10853
10853
  code,
10854
10854
  redirectUri,
10855
10855
  });
@@ -11640,32 +11640,42 @@ collectionId, enableContactSync, enableInteractionTracking, interactionAppId, in
11640
11640
  const initializeAuth = async () => {
11641
11641
  try {
11642
11642
  if (proxyMode) {
11643
- try {
11644
- const accountResponse = await smartlinks.auth.getAccount();
11645
- const accountAny = accountResponse;
11646
- const hasValidSession = accountAny?.uid && accountAny.uid.length > 0;
11647
- if (hasValidSession && isMounted) {
11648
- const userFromAccount = {
11649
- uid: accountAny.uid,
11650
- email: accountAny?.email,
11651
- displayName: accountAny?.displayName || accountAny?.name,
11652
- phoneNumber: accountAny?.phoneNumber,
11653
- };
11654
- setUser(userFromAccount);
11655
- setAccountData(accountResponse);
11656
- setAccountInfo(accountResponse);
11657
- setIsVerified(true);
11658
- notifyAuthStateChange('LOGIN', userFromAccount, null, accountResponse, accountResponse, true);
11659
- // Sync contact in background (proxy mode) - use ref for stable dependency
11660
- syncContactRef.current?.(userFromAccount, accountResponse);
11643
+ // Check if credentials exist before making the API call
11644
+ const headers = getApiHeaders();
11645
+ const hasBearer = !!headers['Authorization'];
11646
+ const hasSdkProxy = isProxyEnabled();
11647
+ if (!hasBearer && !hasSdkProxy) {
11648
+ console.debug('[AuthContext] Skipping getAccount - no credentials available');
11649
+ // Fall through to "no valid session" state
11650
+ }
11651
+ else {
11652
+ try {
11653
+ const accountResponse = await smartlinks.auth.getAccount();
11654
+ const accountAny = accountResponse;
11655
+ const hasValidSession = accountAny?.uid && accountAny.uid.length > 0;
11656
+ if (hasValidSession && isMounted) {
11657
+ const userFromAccount = {
11658
+ uid: accountAny.uid,
11659
+ email: accountAny?.email,
11660
+ displayName: accountAny?.displayName || accountAny?.name,
11661
+ phoneNumber: accountAny?.phoneNumber,
11662
+ };
11663
+ setUser(userFromAccount);
11664
+ setAccountData(accountResponse);
11665
+ setAccountInfo(accountResponse);
11666
+ setIsVerified(true);
11667
+ notifyAuthStateChange('LOGIN', userFromAccount, null, accountResponse, accountResponse, true);
11668
+ // Sync contact in background (proxy mode) - use ref for stable dependency
11669
+ syncContactRef.current?.(userFromAccount, accountResponse);
11670
+ }
11671
+ else if (isMounted) {
11672
+ // No valid session, awaiting login
11673
+ }
11661
11674
  }
11662
- else if (isMounted) {
11663
- // No valid session, awaiting login
11675
+ catch (error) {
11676
+ // auth.getAccount() failed, awaiting login
11664
11677
  }
11665
- }
11666
- catch (error) {
11667
- // auth.getAccount() failed, awaiting login
11668
- }
11678
+ } // end else (has credentials)
11669
11679
  if (isMounted) {
11670
11680
  setIsLoading(false);
11671
11681
  initializingRef.current = false;