@proveanything/smartlinks-auth-ui 0.1.9 → 0.1.10

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;AAW5D,OAAO,KAAK,EAAE,qBAAqB,EAAyC,MAAM,UAAU,CAAC;AAkD7F,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA06B5D,CAAC"}
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,EAAyC,MAAM,UAAU,CAAC;AAkD7F,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA27B5D,CAAC"}
package/dist/index.esm.js CHANGED
@@ -11509,6 +11509,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
11509
11509
  const [config, setConfig] = useState(null);
11510
11510
  const [configLoading, setConfigLoading] = useState(!skipConfigFetch);
11511
11511
  const [showEmailForm, setShowEmailForm] = useState(false); // Track if email form should be shown when emailDisplayMode is 'button'
11512
+ const [sdkReady, setSdkReady] = useState(false); // Track SDK initialization state
11512
11513
  const log = useMemo(() => createLoggerWrapper(logger), [logger]);
11513
11514
  const api = new AuthAPI(apiEndpoint, clientId, clientName, logger);
11514
11515
  const auth = useAuth();
@@ -11529,6 +11530,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
11529
11530
  // IMPORTANT: Preserve bearer token during reinitialization
11530
11531
  useEffect(() => {
11531
11532
  log.log('SDK reinitialize useEffect triggered', { apiEndpoint });
11533
+ setSdkReady(false); // Mark SDK as not ready during reinitialization
11532
11534
  const reinitializeWithToken = async () => {
11533
11535
  if (apiEndpoint) {
11534
11536
  log.log('Reinitializing SDK with baseURL:', apiEndpoint);
@@ -11540,15 +11542,20 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
11540
11542
  ngrokSkipBrowserWarning: true,
11541
11543
  logger: logger, // Pass logger to SDK for verbose SDK logging
11542
11544
  });
11545
+ log.log('SDK reinitialized successfully');
11543
11546
  // Restore bearer token after reinitialization using auth.verifyToken
11544
11547
  if (currentToken) {
11545
11548
  smartlinks.auth.verifyToken(currentToken).catch(err => {
11546
11549
  log.warn('Failed to restore bearer token after reinit:', err);
11547
11550
  });
11548
11551
  }
11552
+ // Mark SDK as ready
11553
+ setSdkReady(true);
11549
11554
  }
11550
11555
  else {
11551
- log.log('No apiEndpoint, skipping SDK reinitialize');
11556
+ log.log('No apiEndpoint, SDK already initialized by App');
11557
+ // SDK was initialized by App component, mark as ready
11558
+ setSdkReady(true);
11552
11559
  }
11553
11560
  };
11554
11561
  reinitializeWithToken();
@@ -11569,8 +11576,14 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
11569
11576
  clientId,
11570
11577
  clientIdType: typeof clientId,
11571
11578
  clientIdTruthy: !!clientId,
11572
- apiEndpoint
11579
+ apiEndpoint,
11580
+ sdkReady
11573
11581
  });
11582
+ // Wait for SDK to be ready before fetching config
11583
+ if (!sdkReady) {
11584
+ log.log('SDK not ready yet, waiting...');
11585
+ return;
11586
+ }
11574
11587
  if (skipConfigFetch) {
11575
11588
  log.log('Skipping config fetch - skipConfigFetch is true');
11576
11589
  setConfig(customization || {});
@@ -11631,7 +11644,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
11631
11644
  }
11632
11645
  };
11633
11646
  fetchConfig();
11634
- }, [apiEndpoint, clientId, customization, skipConfigFetch, log]);
11647
+ }, [apiEndpoint, clientId, customization, skipConfigFetch, sdkReady, log]);
11635
11648
  // Reset showEmailForm when mode changes away from login/register
11636
11649
  useEffect(() => {
11637
11650
  if (mode !== 'login' && mode !== 'register') {