@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.
- package/dist/components/SmartlinksAuthUI.d.ts.map +1 -1
- package/dist/context/AuthContext.d.ts.map +1 -1
- package/dist/index.esm.js +44 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -29
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
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(`/
|
|
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
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
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
|
-
|
|
11683
|
-
//
|
|
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;
|
|
@@ -12331,7 +12341,7 @@ const getExpirationFromResponse = (response) => {
|
|
|
12331
12341
|
// Default Smartlinks Google OAuth Client ID (public - safe to expose)
|
|
12332
12342
|
const DEFAULT_GOOGLE_CLIENT_ID = '696509063554-jdlbjl8vsjt7cr0vgkjkjf3ffnvi3a70.apps.googleusercontent.com';
|
|
12333
12343
|
// Default Google OAuth proxy URL (hosted on our whitelisted domain)
|
|
12334
|
-
const DEFAULT_GOOGLE_PROXY_URL = 'https://smartlinks
|
|
12344
|
+
const DEFAULT_GOOGLE_PROXY_URL = 'https://smartlinks.app/apps/account/stable/google-proxy.html';
|
|
12335
12345
|
// Exact hostnames where Google OAuth is registered and inline/OneTap flow works directly.
|
|
12336
12346
|
// Only specific registered origins — NOT broad wildcards like *.lovable.app
|
|
12337
12347
|
const WHITELISTED_GOOGLE_OAUTH_HOSTS = [
|
|
@@ -12343,11 +12353,15 @@ const WHITELISTED_GOOGLE_OAUTH_HOSTS = [
|
|
|
12343
12353
|
/**
|
|
12344
12354
|
* Check if the current domain is whitelisted for direct Google OAuth.
|
|
12345
12355
|
* Uses exact hostname match (plus subdomain match for smartlinks.app production).
|
|
12356
|
+
* Merges the hardcoded list with any additional domains from auth kit config.
|
|
12346
12357
|
* Returns true if OneTap/inline flow can work without a proxy.
|
|
12347
12358
|
*/
|
|
12348
|
-
const isWhitelistedGoogleDomain = () => {
|
|
12359
|
+
const isWhitelistedGoogleDomain = (additionalDomains) => {
|
|
12349
12360
|
const hostname = window.location.hostname;
|
|
12350
|
-
|
|
12361
|
+
const allDomains = additionalDomains?.length
|
|
12362
|
+
? [...WHITELISTED_GOOGLE_OAUTH_HOSTS, ...additionalDomains]
|
|
12363
|
+
: WHITELISTED_GOOGLE_OAUTH_HOSTS;
|
|
12364
|
+
return allDomains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));
|
|
12351
12365
|
};
|
|
12352
12366
|
// Default auth UI configuration when no clientId is provided
|
|
12353
12367
|
const DEFAULT_AUTH_CONFIG = {
|
|
@@ -13128,7 +13142,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13128
13142
|
// - If user has their own Google Client ID, they've registered their domains — no proxy needed
|
|
13129
13143
|
// - If on a whitelisted SmartLinks domain, inline flow works directly
|
|
13130
13144
|
// - Otherwise, auto-use the default proxy URL
|
|
13131
|
-
const isWhitelisted = isWhitelistedGoogleDomain();
|
|
13145
|
+
const isWhitelisted = isWhitelistedGoogleDomain(config?.whitelistedGoogleDomains);
|
|
13132
13146
|
const googleProxyUrl = config?.googleOAuthProxyUrl
|
|
13133
13147
|
|| (!hasCustomGoogleClientId && !isWhitelisted ? DEFAULT_GOOGLE_PROXY_URL : undefined);
|
|
13134
13148
|
log.log('Google Auth initiated:', {
|