@proveanything/smartlinks-auth-ui 0.5.13 → 0.5.14
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/context/AuthContext.d.ts.map +1 -1
- package/dist/index.esm.js +79 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +79 -4
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmartlinksAuthUI.d.ts","sourceRoot":"","sources":["../../src/components/SmartlinksAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAcpE,OAAO,KAAK,EAAE,qBAAqB,EAAyF,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"SmartlinksAuthUI.d.ts","sourceRoot":"","sources":["../../src/components/SmartlinksAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAcpE,OAAO,KAAK,EAAE,qBAAqB,EAAyF,MAAM,UAAU,CAAC;AA6S7I,QAAA,MAAM,mBAAmB,QAAa,OAAO,CAAC,IAAI,CAqBjD,CAAC;AAqDF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAI/B,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA6qE5D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAOnG,OAAO,KAAK,EAAqC,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGvG,eAAO,MAAM,WAAW,6CAAyD,CAAC;AAGlF,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAOnG,OAAO,KAAK,EAAqC,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGvG,eAAO,MAAM,WAAW,6CAAyD,CAAC;AAGlF,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA4oCpD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,gBAM1B,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -12755,6 +12755,9 @@ collectionId, enableContactSync, enableInteractionTracking, interactionAppId, in
|
|
|
12755
12755
|
await tokenStorage.saveAccountData(authAccountData);
|
|
12756
12756
|
await tokenStorage.saveAccountInfo(authAccountData, accountCacheTTL);
|
|
12757
12757
|
}
|
|
12758
|
+
else {
|
|
12759
|
+
await tokenStorage.clearAccountData();
|
|
12760
|
+
}
|
|
12758
12761
|
smartlinks.auth.verifyToken(authToken).catch(() => { });
|
|
12759
12762
|
}
|
|
12760
12763
|
// Always update memory state (but NOT isVerified yet - wait for parent ack in iframe mode)
|
|
@@ -13099,6 +13102,22 @@ const normalizeQueryString = (query) => {
|
|
|
13099
13102
|
const buildSearchParams = (rawQuery) => {
|
|
13100
13103
|
return new URLSearchParams(normalizeQueryString(rawQuery));
|
|
13101
13104
|
};
|
|
13105
|
+
const appendWhatsAppResumeParams = (url, token) => {
|
|
13106
|
+
try {
|
|
13107
|
+
const nextUrl = new URL(url, window.location.origin);
|
|
13108
|
+
nextUrl.searchParams.set('mode', 'whatsapp');
|
|
13109
|
+
if (token) {
|
|
13110
|
+
nextUrl.searchParams.set('token', token);
|
|
13111
|
+
}
|
|
13112
|
+
else {
|
|
13113
|
+
nextUrl.searchParams.delete('token');
|
|
13114
|
+
}
|
|
13115
|
+
return nextUrl.toString();
|
|
13116
|
+
}
|
|
13117
|
+
catch {
|
|
13118
|
+
return url;
|
|
13119
|
+
}
|
|
13120
|
+
};
|
|
13102
13121
|
// Helper to check for URL auth params synchronously (runs during initialization)
|
|
13103
13122
|
// This prevents the form from flashing before detecting deep-link flows
|
|
13104
13123
|
const getInitialUrlAuthParams = () => {
|
|
@@ -13121,6 +13140,19 @@ const getExpirationFromResponse = (response) => {
|
|
|
13121
13140
|
return Date.now() + response.expiresIn;
|
|
13122
13141
|
return undefined; // Will use 7-day default in tokenStorage
|
|
13123
13142
|
};
|
|
13143
|
+
const stripWhatsAppResumeParams = (url) => {
|
|
13144
|
+
try {
|
|
13145
|
+
const urlObj = new URL(url);
|
|
13146
|
+
if (urlObj.searchParams.get('mode') === 'whatsapp') {
|
|
13147
|
+
urlObj.searchParams.delete('mode');
|
|
13148
|
+
urlObj.searchParams.delete('token');
|
|
13149
|
+
}
|
|
13150
|
+
return urlObj.toString();
|
|
13151
|
+
}
|
|
13152
|
+
catch {
|
|
13153
|
+
return url;
|
|
13154
|
+
}
|
|
13155
|
+
};
|
|
13124
13156
|
const getActionResultErrorMessage = (result) => {
|
|
13125
13157
|
if (!result || typeof result !== 'object')
|
|
13126
13158
|
return null;
|
|
@@ -13478,11 +13510,34 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13478
13510
|
// Get the full current URL including hash routes, strip query params
|
|
13479
13511
|
return window.location.href.split('?')[0];
|
|
13480
13512
|
};
|
|
13513
|
+
const syncWhatsAppResumeUrl = (pending) => {
|
|
13514
|
+
if (typeof window === 'undefined')
|
|
13515
|
+
return;
|
|
13516
|
+
try {
|
|
13517
|
+
const currentUrl = new URL(window.location.href);
|
|
13518
|
+
const isOnResumeUrl = currentUrl.searchParams.get('mode') === 'whatsapp';
|
|
13519
|
+
if (!pending) {
|
|
13520
|
+
if (!isOnResumeUrl)
|
|
13521
|
+
return;
|
|
13522
|
+
const cleanUrl = stripWhatsAppResumeParams(currentUrl.toString());
|
|
13523
|
+
window.history.replaceState({}, document.title, cleanUrl);
|
|
13524
|
+
return;
|
|
13525
|
+
}
|
|
13526
|
+
const resumedUrl = appendWhatsAppResumeParams(pending.redirectUrl || currentUrl.toString(), pending.token);
|
|
13527
|
+
if (currentUrl.toString() !== resumedUrl) {
|
|
13528
|
+
window.history.replaceState({}, document.title, resumedUrl);
|
|
13529
|
+
}
|
|
13530
|
+
}
|
|
13531
|
+
catch (err) {
|
|
13532
|
+
log.warn('Failed to sync WhatsApp resume URL state:', err);
|
|
13533
|
+
}
|
|
13534
|
+
};
|
|
13481
13535
|
const savePendingWhatsAppSession = async (session) => {
|
|
13482
13536
|
if (proxyMode)
|
|
13483
13537
|
return;
|
|
13484
13538
|
const storage = await getStorage();
|
|
13485
13539
|
await storage.setItem(WHATSAPP_PENDING_SESSION_KEY, session);
|
|
13540
|
+
syncWhatsAppResumeUrl(session);
|
|
13486
13541
|
};
|
|
13487
13542
|
const loadPendingWhatsAppSession = async () => {
|
|
13488
13543
|
if (proxyMode)
|
|
@@ -13495,6 +13550,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13495
13550
|
return;
|
|
13496
13551
|
const storage = await getStorage();
|
|
13497
13552
|
await storage.removeItem(WHATSAPP_PENDING_SESSION_KEY);
|
|
13553
|
+
syncWhatsAppResumeUrl(null);
|
|
13498
13554
|
};
|
|
13499
13555
|
const updatePendingWhatsAppSession = async (updates) => {
|
|
13500
13556
|
if (proxyMode)
|
|
@@ -13678,6 +13734,12 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
13678
13734
|
// Google OAuth redirect callback
|
|
13679
13735
|
handleGoogleAuthCodeCallback(authCode, state);
|
|
13680
13736
|
}
|
|
13737
|
+
else if (urlMode === 'whatsapp') {
|
|
13738
|
+
if (!auth.user?.uid) {
|
|
13739
|
+
setMode('whatsapp');
|
|
13740
|
+
}
|
|
13741
|
+
setUrlAuthProcessing(false);
|
|
13742
|
+
}
|
|
13681
13743
|
else if (urlMode && token) {
|
|
13682
13744
|
handleURLBasedAuth(urlMode, token);
|
|
13683
13745
|
}
|
|
@@ -14601,14 +14663,26 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
14601
14663
|
let cancelled = false;
|
|
14602
14664
|
const resumePendingWhatsAppSession = async () => {
|
|
14603
14665
|
try {
|
|
14666
|
+
const urlParams = buildSearchParams(window.location.search);
|
|
14667
|
+
const resumeMode = urlParams.get('mode');
|
|
14668
|
+
const resumeToken = urlParams.get('token');
|
|
14604
14669
|
const pending = await loadPendingWhatsAppSession();
|
|
14605
|
-
if (!pending || cancelled)
|
|
14670
|
+
if (!pending || cancelled) {
|
|
14671
|
+
if (resumeMode === 'whatsapp') {
|
|
14672
|
+
syncWhatsAppResumeUrl(null);
|
|
14673
|
+
}
|
|
14606
14674
|
return;
|
|
14675
|
+
}
|
|
14607
14676
|
// Expire stale pending sessions after 30 minutes to avoid resurrecting old attempts.
|
|
14608
14677
|
if (Date.now() - pending.createdAt > 30 * 60 * 1000) {
|
|
14609
14678
|
await clearPendingWhatsAppSession();
|
|
14610
14679
|
return;
|
|
14611
14680
|
}
|
|
14681
|
+
if (resumeMode === 'whatsapp' && resumeToken && resumeToken !== pending.token) {
|
|
14682
|
+
await clearPendingWhatsAppSession();
|
|
14683
|
+
return;
|
|
14684
|
+
}
|
|
14685
|
+
syncWhatsAppResumeUrl(pending);
|
|
14612
14686
|
whatsappSendRef.current = {
|
|
14613
14687
|
token: pending.token,
|
|
14614
14688
|
sessionKey: pending.sessionKey,
|
|
@@ -14631,7 +14705,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
14631
14705
|
}
|
|
14632
14706
|
return;
|
|
14633
14707
|
}
|
|
14634
|
-
if (status.status === 'pending') {
|
|
14708
|
+
if (resumeMode === 'whatsapp' || status.status === 'pending') {
|
|
14635
14709
|
setMode('whatsapp');
|
|
14636
14710
|
}
|
|
14637
14711
|
else if (status.status === 'failed' || status.status === 'expired' || status.status === 'unknown') {
|
|
@@ -14753,8 +14827,9 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
14753
14827
|
fontSize: '0.875rem'
|
|
14754
14828
|
}, children: initialUrlParams.mode === 'verifyEmail' ? 'Verifying your email...' :
|
|
14755
14829
|
initialUrlParams.mode === 'magicLink' ? 'Processing magic link...' :
|
|
14756
|
-
initialUrlParams.mode === '
|
|
14757
|
-
'
|
|
14830
|
+
initialUrlParams.mode === 'whatsapp' ? 'Resuming your WhatsApp sign-in...' :
|
|
14831
|
+
initialUrlParams.mode === 'resetPassword' ? 'Validating reset link...' :
|
|
14832
|
+
'Processing...' })] }) }));
|
|
14758
14833
|
}
|
|
14759
14834
|
if (configLoading) {
|
|
14760
14835
|
return (jsx(AuthContainer, { theme: resolvedTheme, className: className, minimal: minimal || config?.branding?.minimal || false, children: jsx("div", { style: { textAlign: 'center', padding: '2rem' }, children: jsx("div", { className: "auth-spinner" }) }) }));
|