@proveanything/smartlinks-auth-ui 0.4.10 → 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/components/SmartlinksAuthUI.d.ts.map +1 -1
- package/dist/index.esm.js +20 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
?
|
|
12628
|
-
:
|
|
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'),
|
|
@@ -12671,7 +12683,9 @@ const WHITELISTED_GOOGLE_OAUTH_HOSTS = [
|
|
|
12671
12683
|
];
|
|
12672
12684
|
/**
|
|
12673
12685
|
* Check if the current domain is whitelisted for direct Google OAuth.
|
|
12674
|
-
* Uses
|
|
12686
|
+
* Uses EXACT hostname match only — subdomains (e.g. hubdev.smartlinks.app)
|
|
12687
|
+
* are NOT auto-whitelisted because they're not registered with Google Cloud Console.
|
|
12688
|
+
* Unregistered domains must route through the Google OAuth proxy.
|
|
12675
12689
|
* Merges the hardcoded list with any additional domains from auth kit config.
|
|
12676
12690
|
* Returns true if OneTap/inline flow can work without a proxy.
|
|
12677
12691
|
*/
|
|
@@ -12680,7 +12694,7 @@ const isWhitelistedGoogleDomain = (additionalDomains) => {
|
|
|
12680
12694
|
const allDomains = additionalDomains?.length
|
|
12681
12695
|
? [...WHITELISTED_GOOGLE_OAUTH_HOSTS, ...additionalDomains]
|
|
12682
12696
|
: WHITELISTED_GOOGLE_OAUTH_HOSTS;
|
|
12683
|
-
return allDomains.some(domain => hostname === domain
|
|
12697
|
+
return allDomains.some(domain => hostname === domain);
|
|
12684
12698
|
};
|
|
12685
12699
|
// Default auth UI configuration when no clientId is provided
|
|
12686
12700
|
const DEFAULT_AUTH_CONFIG = {
|
|
@@ -13099,10 +13113,10 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13099
13113
|
if (hashQueryIndex !== -1) {
|
|
13100
13114
|
// Extract query string from hash (e.g., #/test?mode=verifyEmail&token=abc)
|
|
13101
13115
|
const hashQuery = hash.substring(hashQueryIndex + 1);
|
|
13102
|
-
return
|
|
13116
|
+
return buildSearchParams(hashQuery);
|
|
13103
13117
|
}
|
|
13104
13118
|
// Fall back to regular search params (for non-hash routing)
|
|
13105
|
-
return
|
|
13119
|
+
return buildSearchParams(window.location.search);
|
|
13106
13120
|
};
|
|
13107
13121
|
const params = getUrlParams();
|
|
13108
13122
|
const urlMode = params.get('mode');
|