@proveanything/smartlinks-auth-ui 0.3.11 → 0.3.13

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":"SmartlinksAuthUI.d.ts","sourceRoot":"","sources":["../../src/components/SmartlinksAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAY5D,OAAO,KAAK,EAAE,qBAAqB,EAAyF,MAAM,UAAU,CAAC;AA0I7I,QAAA,MAAM,mBAAmB,QAAa,OAAO,CAAC,IAAI,CAmCjD,CAAC;AAwEF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAK/B,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA0mD5D,CAAC"}
1
+ {"version":3,"file":"SmartlinksAuthUI.d.ts","sourceRoot":"","sources":["../../src/components/SmartlinksAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAY5D,OAAO,KAAK,EAAE,qBAAqB,EAAyF,MAAM,UAAU,CAAC;AA8I7I,QAAA,MAAM,mBAAmB,QAAa,OAAO,CAAC,IAAI,CAmCjD,CAAC;AAwEF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAK/B,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA0mD5D,CAAC"}
@@ -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;
@@ -12311,7 +12321,7 @@ const getExpirationFromResponse = (response) => {
12311
12321
  // Default Smartlinks Google OAuth Client ID (public - safe to expose)
12312
12322
  const DEFAULT_GOOGLE_CLIENT_ID = '696509063554-jdlbjl8vsjt7cr0vgkjkjf3ffnvi3a70.apps.googleusercontent.com';
12313
12323
  // Default Google OAuth proxy URL (hosted on our whitelisted domain)
12314
- const DEFAULT_GOOGLE_PROXY_URL = 'https://smartlinks-auth-kit.lovable.app/google-proxy.html';
12324
+ const DEFAULT_GOOGLE_PROXY_URL = 'https://smartlinks.app/apps/account/stable/google-proxy.html';
12315
12325
  // Exact hostnames where Google OAuth is registered and inline/OneTap flow works directly.
12316
12326
  // Only specific registered origins — NOT broad wildcards like *.lovable.app
12317
12327
  const WHITELISTED_GOOGLE_OAUTH_HOSTS = [
@@ -12323,11 +12333,15 @@ const WHITELISTED_GOOGLE_OAUTH_HOSTS = [
12323
12333
  /**
12324
12334
  * Check if the current domain is whitelisted for direct Google OAuth.
12325
12335
  * Uses exact hostname match (plus subdomain match for smartlinks.app production).
12336
+ * Merges the hardcoded list with any additional domains from auth kit config.
12326
12337
  * Returns true if OneTap/inline flow can work without a proxy.
12327
12338
  */
12328
- const isWhitelistedGoogleDomain = () => {
12339
+ const isWhitelistedGoogleDomain = (additionalDomains) => {
12329
12340
  const hostname = window.location.hostname;
12330
- return WHITELISTED_GOOGLE_OAUTH_HOSTS.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));
12341
+ const allDomains = additionalDomains?.length
12342
+ ? [...WHITELISTED_GOOGLE_OAUTH_HOSTS, ...additionalDomains]
12343
+ : WHITELISTED_GOOGLE_OAUTH_HOSTS;
12344
+ return allDomains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));
12331
12345
  };
12332
12346
  // Default auth UI configuration when no clientId is provided
12333
12347
  const DEFAULT_AUTH_CONFIG = {
@@ -13108,7 +13122,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
13108
13122
  // - If user has their own Google Client ID, they've registered their domains — no proxy needed
13109
13123
  // - If on a whitelisted SmartLinks domain, inline flow works directly
13110
13124
  // - Otherwise, auto-use the default proxy URL
13111
- const isWhitelisted = isWhitelistedGoogleDomain();
13125
+ const isWhitelisted = isWhitelistedGoogleDomain(config?.whitelistedGoogleDomains);
13112
13126
  const googleProxyUrl = config?.googleOAuthProxyUrl
13113
13127
  || (!hasCustomGoogleClientId && !isWhitelisted ? DEFAULT_GOOGLE_PROXY_URL : undefined);
13114
13128
  log.log('Google Auth initiated:', {