@proveanything/smartlinks-auth-ui 0.1.21 â 0.1.22
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/api.d.ts.map +1 -1
- package/dist/components/SmartlinksAuthUI.d.ts.map +1 -1
- package/dist/index.esm.js +39 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10722,14 +10722,18 @@ class AuthAPI {
|
|
|
10722
10722
|
});
|
|
10723
10723
|
}
|
|
10724
10724
|
async fetchConfig() {
|
|
10725
|
+
console.log('[AuthAPI] đ fetchConfig called with clientId:', this.clientId);
|
|
10725
10726
|
this.log.log('fetchConfig called with clientId:', this.clientId);
|
|
10726
10727
|
try {
|
|
10728
|
+
console.log('[AuthAPI] đ Calling smartlinks.authKit.load() - this uses current SDK config (including proxyMode)');
|
|
10727
10729
|
this.log.log('Calling smartlinks.authKit.load...');
|
|
10728
10730
|
const result = await smartlinks__namespace.authKit.load(this.clientId);
|
|
10731
|
+
console.log('[AuthAPI] â
smartlinks.authKit.load returned:', result);
|
|
10729
10732
|
this.log.log('smartlinks.authKit.load returned:', result);
|
|
10730
10733
|
return result;
|
|
10731
10734
|
}
|
|
10732
10735
|
catch (error) {
|
|
10736
|
+
console.log('[AuthAPI] â Failed to fetch UI config:', error);
|
|
10733
10737
|
this.log.warn('Failed to fetch UI config, using defaults:', error);
|
|
10734
10738
|
return {
|
|
10735
10739
|
branding: {
|
|
@@ -12007,10 +12011,21 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12007
12011
|
// Reinitialize Smartlinks SDK when apiEndpoint or proxyMode changes
|
|
12008
12012
|
// IMPORTANT: Preserve bearer token during reinitialization
|
|
12009
12013
|
React.useEffect(() => {
|
|
12014
|
+
console.log('[SmartlinksAuthUI] đ§ SDK INIT useEffect triggered', {
|
|
12015
|
+
apiEndpoint,
|
|
12016
|
+
proxyMode,
|
|
12017
|
+
hasLogger: !!logger,
|
|
12018
|
+
timestamp: new Date().toISOString()
|
|
12019
|
+
});
|
|
12010
12020
|
log.log('SDK reinitialize useEffect triggered', { apiEndpoint, proxyMode });
|
|
12011
12021
|
setSdkReady(false); // Mark SDK as not ready during reinitialization
|
|
12012
12022
|
const reinitializeWithToken = async () => {
|
|
12013
12023
|
if (apiEndpoint) {
|
|
12024
|
+
console.log('[SmartlinksAuthUI] đ§ Reinitializing SDK with:', {
|
|
12025
|
+
baseURL: apiEndpoint,
|
|
12026
|
+
proxyMode: proxyMode,
|
|
12027
|
+
ngrokSkipBrowserWarning: true
|
|
12028
|
+
});
|
|
12014
12029
|
log.log('Reinitializing SDK with baseURL:', apiEndpoint, 'proxyMode:', proxyMode);
|
|
12015
12030
|
// Get current token before reinitializing (only in standalone mode)
|
|
12016
12031
|
const currentToken = !proxyMode ? await auth.getToken() : null;
|
|
@@ -12020,6 +12035,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12020
12035
|
ngrokSkipBrowserWarning: true,
|
|
12021
12036
|
logger: logger, // Pass logger to SDK for verbose SDK logging
|
|
12022
12037
|
});
|
|
12038
|
+
console.log('[SmartlinksAuthUI] â
SDK reinitialized, proxyMode:', proxyMode);
|
|
12023
12039
|
log.log('SDK reinitialized successfully');
|
|
12024
12040
|
// Restore bearer token after reinitialization using auth.verifyToken (standalone mode only)
|
|
12025
12041
|
if (currentToken && !proxyMode) {
|
|
@@ -12028,14 +12044,17 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12028
12044
|
});
|
|
12029
12045
|
}
|
|
12030
12046
|
// Mark SDK as ready
|
|
12047
|
+
console.log('[SmartlinksAuthUI] â
Setting sdkReady=true (with apiEndpoint)');
|
|
12031
12048
|
setSdkReady(true);
|
|
12032
12049
|
}
|
|
12033
12050
|
else if (proxyMode) {
|
|
12034
12051
|
// In proxy mode without custom endpoint, SDK should already be initialized by parent
|
|
12052
|
+
console.log('[SmartlinksAuthUI] â ī¸ Proxy mode WITHOUT apiEndpoint - expecting SDK already initialized by parent');
|
|
12035
12053
|
log.log('Proxy mode without apiEndpoint, SDK already initialized by parent');
|
|
12036
12054
|
setSdkReady(true);
|
|
12037
12055
|
}
|
|
12038
12056
|
else {
|
|
12057
|
+
console.log('[SmartlinksAuthUI] âšī¸ No apiEndpoint, no proxyMode - SDK already initialized by App');
|
|
12039
12058
|
log.log('No apiEndpoint, SDK already initialized by App');
|
|
12040
12059
|
// SDK was initialized by App component, mark as ready
|
|
12041
12060
|
setSdkReady(true);
|
|
@@ -12054,6 +12073,14 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12054
12073
|
};
|
|
12055
12074
|
// Fetch UI configuration
|
|
12056
12075
|
React.useEffect(() => {
|
|
12076
|
+
console.log('[SmartlinksAuthUI] đ CONFIG FETCH useEffect triggered', {
|
|
12077
|
+
skipConfigFetch,
|
|
12078
|
+
clientId,
|
|
12079
|
+
apiEndpoint,
|
|
12080
|
+
sdkReady,
|
|
12081
|
+
proxyMode,
|
|
12082
|
+
timestamp: new Date().toISOString()
|
|
12083
|
+
});
|
|
12057
12084
|
log.log('Config fetch useEffect triggered', {
|
|
12058
12085
|
skipConfigFetch,
|
|
12059
12086
|
clientId,
|
|
@@ -12064,10 +12091,12 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12064
12091
|
});
|
|
12065
12092
|
// Wait for SDK to be ready before fetching config
|
|
12066
12093
|
if (!sdkReady) {
|
|
12094
|
+
console.log('[SmartlinksAuthUI] âŗ SDK not ready yet, waiting before config fetch...');
|
|
12067
12095
|
log.log('SDK not ready yet, waiting...');
|
|
12068
12096
|
return;
|
|
12069
12097
|
}
|
|
12070
12098
|
if (skipConfigFetch) {
|
|
12099
|
+
console.log('[SmartlinksAuthUI] âī¸ Skipping config fetch - skipConfigFetch is true');
|
|
12071
12100
|
log.log('Skipping config fetch - skipConfigFetch is true');
|
|
12072
12101
|
setConfig(customization || {});
|
|
12073
12102
|
return;
|
|
@@ -12075,6 +12104,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12075
12104
|
const fetchConfig = async () => {
|
|
12076
12105
|
// If no clientId provided, use default config immediately without API call
|
|
12077
12106
|
if (!clientId) {
|
|
12107
|
+
console.log('[SmartlinksAuthUI] â ī¸ No clientId provided, using default config');
|
|
12078
12108
|
log.log('No clientId provided, using default config');
|
|
12079
12109
|
const defaultConfig = {
|
|
12080
12110
|
...DEFAULT_AUTH_CONFIG,
|
|
@@ -12093,21 +12123,28 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12093
12123
|
const age = Date.now() - timestamp;
|
|
12094
12124
|
// Use cache if less than 1 hour old
|
|
12095
12125
|
if (age < 3600000) {
|
|
12126
|
+
console.log('[SmartlinksAuthUI] đĻ Using cached config (age:', Math.round(age / 1000), 'seconds)');
|
|
12096
12127
|
setConfig({ ...cachedConfig, ...customization });
|
|
12097
12128
|
setConfigLoading(false);
|
|
12098
12129
|
// Fetch in background to update cache
|
|
12130
|
+
console.log('[SmartlinksAuthUI] đ Background refresh of config via SDK...');
|
|
12099
12131
|
api.fetchConfig().then(freshConfig => {
|
|
12132
|
+
console.log('[SmartlinksAuthUI] â
Background config refresh complete');
|
|
12100
12133
|
localStorage.setItem(cacheKey, JSON.stringify({
|
|
12101
12134
|
config: freshConfig,
|
|
12102
12135
|
timestamp: Date.now()
|
|
12103
12136
|
}));
|
|
12137
|
+
}).catch(err => {
|
|
12138
|
+
console.log('[SmartlinksAuthUI] â Background config refresh failed:', err);
|
|
12104
12139
|
});
|
|
12105
12140
|
return;
|
|
12106
12141
|
}
|
|
12107
12142
|
}
|
|
12108
12143
|
// Fetch from API
|
|
12144
|
+
console.log('[SmartlinksAuthUI] đ Fetching config via SDK for clientId:', clientId, 'proxyMode:', proxyMode);
|
|
12109
12145
|
log.log('Fetching config from API for clientId:', clientId);
|
|
12110
12146
|
const fetchedConfig = await api.fetchConfig();
|
|
12147
|
+
console.log('[SmartlinksAuthUI] â
Config fetched successfully:', fetchedConfig);
|
|
12111
12148
|
log.log('Received config:', fetchedConfig);
|
|
12112
12149
|
// Merge with customization props (props take precedence)
|
|
12113
12150
|
const mergedConfig = { ...fetchedConfig, ...customization };
|
|
@@ -12119,6 +12156,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12119
12156
|
}));
|
|
12120
12157
|
}
|
|
12121
12158
|
catch (err) {
|
|
12159
|
+
console.log('[SmartlinksAuthUI] â Config fetch failed:', err);
|
|
12122
12160
|
log.error('Failed to fetch config:', err);
|
|
12123
12161
|
setConfig(customization || {});
|
|
12124
12162
|
}
|
|
@@ -12127,7 +12165,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12127
12165
|
}
|
|
12128
12166
|
};
|
|
12129
12167
|
fetchConfig();
|
|
12130
|
-
}, [apiEndpoint, clientId, customization, skipConfigFetch, sdkReady, log]);
|
|
12168
|
+
}, [apiEndpoint, clientId, customization, skipConfigFetch, sdkReady, proxyMode, log]);
|
|
12131
12169
|
// Reset showEmailForm when mode changes away from login/register
|
|
12132
12170
|
React.useEffect(() => {
|
|
12133
12171
|
if (mode !== 'login' && mode !== 'register') {
|