@proveanything/smartlinks-auth-ui 0.4.11 → 0.4.12

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
@@ -12617,6 +12617,18 @@ const useAuth = () => {
12617
12617
  // VERSION: Update this when making changes to help identify which version is running
12618
12618
  const AUTH_UI_VERSION = '46';
12619
12619
  const LOG_PREFIX = `[SmartlinksAuthUI:v${AUTH_UI_VERSION}]`;
12620
+ // Normalize malformed query strings where a second '?' is used instead of '&'.
12621
+ // Some host platforms append "?mode=...&token=..." to a URL that already has a "?pageId=...",
12622
+ // resulting in "?pageId=xxx?mode=resetPassword&token=yyy". Convert any extra '?' to '&'
12623
+ // so URLSearchParams can parse mode/token correctly.
12624
+ const normalizeQueryString = (query) => {
12625
+ // Strip a single leading '?' if present, then replace any remaining '?' with '&'
12626
+ const withoutLead = query.startsWith('?') ? query.slice(1) : query;
12627
+ return withoutLead.replace(/\?/g, '&');
12628
+ };
12629
+ const buildSearchParams = (rawQuery) => {
12630
+ return new URLSearchParams(normalizeQueryString(rawQuery));
12631
+ };
12620
12632
  // Helper to check for URL auth params synchronously (runs during initialization)
12621
12633
  // This prevents the form from flashing before detecting deep-link flows
12622
12634
  const getInitialUrlAuthParams = () => {
@@ -12624,8 +12636,8 @@ const getInitialUrlAuthParams = () => {
12624
12636
  const hash = window.location.hash;
12625
12637
  const hashQueryIndex = hash.indexOf('?');
12626
12638
  const params = hashQueryIndex !== -1
12627
- ? new URLSearchParams(hash.substring(hashQueryIndex + 1))
12628
- : new URLSearchParams(window.location.search);
12639
+ ? buildSearchParams(hash.substring(hashQueryIndex + 1))
12640
+ : buildSearchParams(window.location.search);
12629
12641
  return {
12630
12642
  mode: params.get('mode'),
12631
12643
  token: params.get('token'),
@@ -13101,10 +13113,10 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
13101
13113
  if (hashQueryIndex !== -1) {
13102
13114
  // Extract query string from hash (e.g., #/test?mode=verifyEmail&token=abc)
13103
13115
  const hashQuery = hash.substring(hashQueryIndex + 1);
13104
- return new URLSearchParams(hashQuery);
13116
+ return buildSearchParams(hashQuery);
13105
13117
  }
13106
13118
  // Fall back to regular search params (for non-hash routing)
13107
- return new URLSearchParams(window.location.search);
13119
+ return buildSearchParams(window.location.search);
13108
13120
  };
13109
13121
  const params = getUrlParams();
13110
13122
  const urlMode = params.get('mode');