@proveanything/smartlinks-auth-ui 0.1.29 → 0.1.30

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
@@ -12258,7 +12258,7 @@ const getFriendlyErrorMessage = (errorMessage) => {
12258
12258
  // Return original message if no pattern matches
12259
12259
  return errorMessage;
12260
12260
  };
12261
- const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAuthSuccess, onAuthError, enabledProviders = ['email', 'google', 'phone'], initialMode = 'login', redirectUrl, theme = 'auto', className, customization, skipConfigFetch = false, minimal = false, logger, proxyMode = false, collectionId, }) => {
12261
+ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAuthSuccess, onAuthError, enabledProviders = ['email', 'google', 'phone'], initialMode = 'login', redirectUrl, theme = 'auto', className, customization, skipConfigFetch = false, minimal = false, logger, proxyMode = false, collectionId, disableConfigCache = false, }) => {
12262
12262
  const [mode, setMode] = React.useState(initialMode);
12263
12263
  const [loading, setLoading] = React.useState(false);
12264
12264
  const [error, setError] = React.useState();
@@ -12399,31 +12399,38 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
12399
12399
  return;
12400
12400
  }
12401
12401
  try {
12402
- // Check localStorage cache first
12403
12402
  const cacheKey = `auth_ui_config_${clientId}`;
12404
- const cached = localStorage.getItem(cacheKey);
12405
- if (cached) {
12406
- const { config: cachedConfig, timestamp } = JSON.parse(cached);
12407
- const age = Date.now() - timestamp;
12408
- // Use cache if less than 1 hour old
12409
- if (age < 3600000) {
12410
- console.log('[SmartlinksAuthUI] 📦 Using cached config (age:', Math.round(age / 1000), 'seconds)');
12411
- setConfig({ ...cachedConfig, ...customization });
12412
- setConfigLoading(false);
12413
- // Fetch in background to update cache
12414
- console.log('[SmartlinksAuthUI] 🔄 Background refresh of config via SDK...');
12415
- api.fetchConfig().then(freshConfig => {
12416
- console.log('[SmartlinksAuthUI] Background config refresh complete');
12417
- localStorage.setItem(cacheKey, JSON.stringify({
12418
- config: freshConfig,
12419
- timestamp: Date.now()
12420
- }));
12421
- }).catch(err => {
12422
- console.log('[SmartlinksAuthUI] ❌ Background config refresh failed:', err);
12423
- });
12424
- return;
12403
+ // Check localStorage cache first (unless caching is disabled)
12404
+ if (!disableConfigCache) {
12405
+ const cached = localStorage.getItem(cacheKey);
12406
+ if (cached) {
12407
+ const { config: cachedConfig, timestamp } = JSON.parse(cached);
12408
+ const age = Date.now() - timestamp;
12409
+ // Use cache if less than 1 hour old
12410
+ if (age < 3600000) {
12411
+ console.log('[SmartlinksAuthUI] 📦 Using cached config (age:', Math.round(age / 1000), 'seconds)');
12412
+ setConfig({ ...cachedConfig, ...customization });
12413
+ setConfigLoading(false);
12414
+ // Fetch in background to update cache
12415
+ console.log('[SmartlinksAuthUI] 🔄 Background refresh of config via SDK...');
12416
+ api.fetchConfig().then(freshConfig => {
12417
+ console.log('[SmartlinksAuthUI] ✅ Background config refresh complete');
12418
+ localStorage.setItem(cacheKey, JSON.stringify({
12419
+ config: freshConfig,
12420
+ timestamp: Date.now()
12421
+ }));
12422
+ // Update config if it changed
12423
+ setConfig({ ...freshConfig, ...customization });
12424
+ }).catch(err => {
12425
+ console.log('[SmartlinksAuthUI] ❌ Background config refresh failed:', err);
12426
+ });
12427
+ return;
12428
+ }
12425
12429
  }
12426
12430
  }
12431
+ else {
12432
+ console.log('[SmartlinksAuthUI] ⚠️ Config caching disabled, fetching fresh config');
12433
+ }
12427
12434
  // Fetch from API
12428
12435
  console.log('[SmartlinksAuthUI] 🌐 Fetching config via SDK for clientId:', clientId, 'proxyMode:', proxyMode);
12429
12436
  log.log('Fetching config from API for clientId:', clientId);
@@ -12433,11 +12440,13 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
12433
12440
  // Merge with customization props (props take precedence)
12434
12441
  const mergedConfig = { ...fetchedConfig, ...customization };
12435
12442
  setConfig(mergedConfig);
12436
- // Cache the fetched config
12437
- localStorage.setItem(cacheKey, JSON.stringify({
12438
- config: fetchedConfig,
12439
- timestamp: Date.now()
12440
- }));
12443
+ // Cache the fetched config (unless caching is disabled)
12444
+ if (!disableConfigCache) {
12445
+ localStorage.setItem(cacheKey, JSON.stringify({
12446
+ config: fetchedConfig,
12447
+ timestamp: Date.now()
12448
+ }));
12449
+ }
12441
12450
  }
12442
12451
  catch (err) {
12443
12452
  console.log('[SmartlinksAuthUI] ❌ Config fetch failed:', err);