@proveanything/smartlinks-auth-ui 0.1.7 → 0.1.8

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
@@ -10674,11 +10674,15 @@ class AuthAPI {
10674
10674
  });
10675
10675
  }
10676
10676
  async fetchConfig() {
10677
+ console.log('[AuthAPI] fetchConfig called with clientId:', this.clientId);
10677
10678
  try {
10678
- return await smartlinks__namespace.authKit.load(this.clientId);
10679
+ console.log('[AuthAPI] Calling smartlinks.authKit.load...');
10680
+ const result = await smartlinks__namespace.authKit.load(this.clientId);
10681
+ console.log('[AuthAPI] smartlinks.authKit.load returned:', result);
10682
+ return result;
10679
10683
  }
10680
10684
  catch (error) {
10681
- console.warn('Failed to fetch UI config, using defaults:', error);
10685
+ console.warn('[AuthAPI] Failed to fetch UI config, using defaults:', error);
10682
10686
  return {
10683
10687
  branding: {
10684
10688
  title: 'Smartlinks Auth',
@@ -11509,8 +11513,10 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
11509
11513
  // Reinitialize Smartlinks SDK when apiEndpoint changes (for test/dev scenarios)
11510
11514
  // IMPORTANT: Preserve bearer token during reinitialization
11511
11515
  React.useEffect(() => {
11516
+ console.log('[SmartlinksAuthUI] SDK reinitialize useEffect triggered', { apiEndpoint });
11512
11517
  const reinitializeWithToken = async () => {
11513
11518
  if (apiEndpoint) {
11519
+ console.log('[SmartlinksAuthUI] Reinitializing SDK with baseURL:', apiEndpoint);
11514
11520
  // Get current token before reinitializing
11515
11521
  const currentToken = await auth.getToken();
11516
11522
  smartlinks__namespace.initializeApi({
@@ -11525,6 +11531,9 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
11525
11531
  });
11526
11532
  }
11527
11533
  }
11534
+ else {
11535
+ console.log('[SmartlinksAuthUI] No apiEndpoint, skipping SDK reinitialize');
11536
+ }
11528
11537
  };
11529
11538
  reinitializeWithToken();
11530
11539
  }, [apiEndpoint, auth]);
@@ -11539,13 +11548,22 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
11539
11548
  };
11540
11549
  // Fetch UI configuration
11541
11550
  React.useEffect(() => {
11551
+ console.log('[SmartlinksAuthUI] Config fetch useEffect triggered', {
11552
+ skipConfigFetch,
11553
+ clientId,
11554
+ clientIdType: typeof clientId,
11555
+ clientIdTruthy: !!clientId,
11556
+ apiEndpoint
11557
+ });
11542
11558
  if (skipConfigFetch) {
11559
+ console.log('[SmartlinksAuthUI] Skipping config fetch - skipConfigFetch is true');
11543
11560
  setConfig(customization || {});
11544
11561
  return;
11545
11562
  }
11546
11563
  const fetchConfig = async () => {
11547
11564
  // If no clientId provided, use default config immediately without API call
11548
11565
  if (!clientId) {
11566
+ console.log('[SmartlinksAuthUI] No clientId provided, using default config');
11549
11567
  const defaultConfig = {
11550
11568
  ...DEFAULT_AUTH_CONFIG,
11551
11569
  enabledProviders: enabledProviders || ['email', 'google', 'phone']
@@ -11576,7 +11594,9 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
11576
11594
  }
11577
11595
  }
11578
11596
  // Fetch from API
11597
+ console.log('[SmartlinksAuthUI] Fetching config from API for clientId:', clientId);
11579
11598
  const fetchedConfig = await api.fetchConfig();
11599
+ console.log('[SmartlinksAuthUI] Received config:', fetchedConfig);
11580
11600
  // Merge with customization props (props take precedence)
11581
11601
  const mergedConfig = { ...fetchedConfig, ...customization };
11582
11602
  setConfig(mergedConfig);