@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.
- package/dist/components/SmartlinksAuthUI.d.ts.map +1 -1
- package/dist/index.esm.js +16 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11530,6 +11530,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11530
11530
|
const [config, setConfig] = React.useState(null);
|
|
11531
11531
|
const [configLoading, setConfigLoading] = React.useState(!skipConfigFetch);
|
|
11532
11532
|
const [showEmailForm, setShowEmailForm] = React.useState(false); // Track if email form should be shown when emailDisplayMode is 'button'
|
|
11533
|
+
const [sdkReady, setSdkReady] = React.useState(false); // Track SDK initialization state
|
|
11533
11534
|
const log = React.useMemo(() => createLoggerWrapper(logger), [logger]);
|
|
11534
11535
|
const api = new AuthAPI(apiEndpoint, clientId, clientName, logger);
|
|
11535
11536
|
const auth = useAuth();
|
|
@@ -11550,6 +11551,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11550
11551
|
// IMPORTANT: Preserve bearer token during reinitialization
|
|
11551
11552
|
React.useEffect(() => {
|
|
11552
11553
|
log.log('SDK reinitialize useEffect triggered', { apiEndpoint });
|
|
11554
|
+
setSdkReady(false); // Mark SDK as not ready during reinitialization
|
|
11553
11555
|
const reinitializeWithToken = async () => {
|
|
11554
11556
|
if (apiEndpoint) {
|
|
11555
11557
|
log.log('Reinitializing SDK with baseURL:', apiEndpoint);
|
|
@@ -11561,15 +11563,20 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11561
11563
|
ngrokSkipBrowserWarning: true,
|
|
11562
11564
|
logger: logger, // Pass logger to SDK for verbose SDK logging
|
|
11563
11565
|
});
|
|
11566
|
+
log.log('SDK reinitialized successfully');
|
|
11564
11567
|
// Restore bearer token after reinitialization using auth.verifyToken
|
|
11565
11568
|
if (currentToken) {
|
|
11566
11569
|
smartlinks__namespace.auth.verifyToken(currentToken).catch(err => {
|
|
11567
11570
|
log.warn('Failed to restore bearer token after reinit:', err);
|
|
11568
11571
|
});
|
|
11569
11572
|
}
|
|
11573
|
+
// Mark SDK as ready
|
|
11574
|
+
setSdkReady(true);
|
|
11570
11575
|
}
|
|
11571
11576
|
else {
|
|
11572
|
-
log.log('No apiEndpoint,
|
|
11577
|
+
log.log('No apiEndpoint, SDK already initialized by App');
|
|
11578
|
+
// SDK was initialized by App component, mark as ready
|
|
11579
|
+
setSdkReady(true);
|
|
11573
11580
|
}
|
|
11574
11581
|
};
|
|
11575
11582
|
reinitializeWithToken();
|
|
@@ -11590,8 +11597,14 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11590
11597
|
clientId,
|
|
11591
11598
|
clientIdType: typeof clientId,
|
|
11592
11599
|
clientIdTruthy: !!clientId,
|
|
11593
|
-
apiEndpoint
|
|
11600
|
+
apiEndpoint,
|
|
11601
|
+
sdkReady
|
|
11594
11602
|
});
|
|
11603
|
+
// Wait for SDK to be ready before fetching config
|
|
11604
|
+
if (!sdkReady) {
|
|
11605
|
+
log.log('SDK not ready yet, waiting...');
|
|
11606
|
+
return;
|
|
11607
|
+
}
|
|
11595
11608
|
if (skipConfigFetch) {
|
|
11596
11609
|
log.log('Skipping config fetch - skipConfigFetch is true');
|
|
11597
11610
|
setConfig(customization || {});
|
|
@@ -11652,7 +11665,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
11652
11665
|
}
|
|
11653
11666
|
};
|
|
11654
11667
|
fetchConfig();
|
|
11655
|
-
}, [apiEndpoint, clientId, customization, skipConfigFetch, log]);
|
|
11668
|
+
}, [apiEndpoint, clientId, customization, skipConfigFetch, sdkReady, log]);
|
|
11656
11669
|
// Reset showEmailForm when mode changes away from login/register
|
|
11657
11670
|
React.useEffect(() => {
|
|
11658
11671
|
if (mode !== 'login' && mode !== 'register') {
|