@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/components/SmartlinksAuthUI.d.ts.map +1 -1
- package/dist/index.esm.js +37 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +37 -28
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmartlinksAuthUI.d.ts","sourceRoot":"","sources":["../../src/components/SmartlinksAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAW5D,OAAO,KAAK,EAAE,qBAAqB,EAAuD,MAAM,UAAU,CAAC;AA4G3G,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"SmartlinksAuthUI.d.ts","sourceRoot":"","sources":["../../src/components/SmartlinksAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAW5D,OAAO,KAAK,EAAE,qBAAqB,EAAuD,MAAM,UAAU,CAAC;AA4G3G,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAsrC5D,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -12238,7 +12238,7 @@ const getFriendlyErrorMessage = (errorMessage) => {
|
|
|
12238
12238
|
// Return original message if no pattern matches
|
|
12239
12239
|
return errorMessage;
|
|
12240
12240
|
};
|
|
12241
|
-
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, }) => {
|
|
12241
|
+
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, }) => {
|
|
12242
12242
|
const [mode, setMode] = useState(initialMode);
|
|
12243
12243
|
const [loading, setLoading] = useState(false);
|
|
12244
12244
|
const [error, setError] = useState();
|
|
@@ -12379,31 +12379,38 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12379
12379
|
return;
|
|
12380
12380
|
}
|
|
12381
12381
|
try {
|
|
12382
|
-
// Check localStorage cache first
|
|
12383
12382
|
const cacheKey = `auth_ui_config_${clientId}`;
|
|
12384
|
-
|
|
12385
|
-
if (
|
|
12386
|
-
const
|
|
12387
|
-
|
|
12388
|
-
|
|
12389
|
-
|
|
12390
|
-
|
|
12391
|
-
|
|
12392
|
-
|
|
12393
|
-
|
|
12394
|
-
|
|
12395
|
-
|
|
12396
|
-
console.log('[SmartlinksAuthUI]
|
|
12397
|
-
|
|
12398
|
-
config
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
12383
|
+
// Check localStorage cache first (unless caching is disabled)
|
|
12384
|
+
if (!disableConfigCache) {
|
|
12385
|
+
const cached = localStorage.getItem(cacheKey);
|
|
12386
|
+
if (cached) {
|
|
12387
|
+
const { config: cachedConfig, timestamp } = JSON.parse(cached);
|
|
12388
|
+
const age = Date.now() - timestamp;
|
|
12389
|
+
// Use cache if less than 1 hour old
|
|
12390
|
+
if (age < 3600000) {
|
|
12391
|
+
console.log('[SmartlinksAuthUI] 📦 Using cached config (age:', Math.round(age / 1000), 'seconds)');
|
|
12392
|
+
setConfig({ ...cachedConfig, ...customization });
|
|
12393
|
+
setConfigLoading(false);
|
|
12394
|
+
// Fetch in background to update cache
|
|
12395
|
+
console.log('[SmartlinksAuthUI] 🔄 Background refresh of config via SDK...');
|
|
12396
|
+
api.fetchConfig().then(freshConfig => {
|
|
12397
|
+
console.log('[SmartlinksAuthUI] ✅ Background config refresh complete');
|
|
12398
|
+
localStorage.setItem(cacheKey, JSON.stringify({
|
|
12399
|
+
config: freshConfig,
|
|
12400
|
+
timestamp: Date.now()
|
|
12401
|
+
}));
|
|
12402
|
+
// Update config if it changed
|
|
12403
|
+
setConfig({ ...freshConfig, ...customization });
|
|
12404
|
+
}).catch(err => {
|
|
12405
|
+
console.log('[SmartlinksAuthUI] ❌ Background config refresh failed:', err);
|
|
12406
|
+
});
|
|
12407
|
+
return;
|
|
12408
|
+
}
|
|
12405
12409
|
}
|
|
12406
12410
|
}
|
|
12411
|
+
else {
|
|
12412
|
+
console.log('[SmartlinksAuthUI] ⚠️ Config caching disabled, fetching fresh config');
|
|
12413
|
+
}
|
|
12407
12414
|
// Fetch from API
|
|
12408
12415
|
console.log('[SmartlinksAuthUI] 🌐 Fetching config via SDK for clientId:', clientId, 'proxyMode:', proxyMode);
|
|
12409
12416
|
log.log('Fetching config from API for clientId:', clientId);
|
|
@@ -12413,11 +12420,13 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
12413
12420
|
// Merge with customization props (props take precedence)
|
|
12414
12421
|
const mergedConfig = { ...fetchedConfig, ...customization };
|
|
12415
12422
|
setConfig(mergedConfig);
|
|
12416
|
-
// Cache the fetched config
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12423
|
+
// Cache the fetched config (unless caching is disabled)
|
|
12424
|
+
if (!disableConfigCache) {
|
|
12425
|
+
localStorage.setItem(cacheKey, JSON.stringify({
|
|
12426
|
+
config: fetchedConfig,
|
|
12427
|
+
timestamp: Date.now()
|
|
12428
|
+
}));
|
|
12429
|
+
}
|
|
12421
12430
|
}
|
|
12422
12431
|
catch (err) {
|
|
12423
12432
|
console.log('[SmartlinksAuthUI] ❌ Config fetch failed:', err);
|