@proveanything/smartlinks-auth-ui 0.5.18 → 0.5.20
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/components/WhatsAppAuthForm.d.ts.map +1 -1
- package/dist/context/AuthContext.d.ts.map +1 -1
- package/dist/index.esm.js +45 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +45 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11049,11 +11049,12 @@ const WhatsAppAuthForm = ({ onSend, onPollStatus, onVerified, onBack, loading =
|
|
|
11049
11049
|
const displayedError = pollError || error;
|
|
11050
11050
|
const awaitingNameInput = collectName && !sent;
|
|
11051
11051
|
const awaitingAutoSend = !collectName && !sent;
|
|
11052
|
+
const hasLaunchLink = !!sent?.waLink;
|
|
11052
11053
|
return (jsxRuntime.jsxs("form", { className: "auth-form", onSubmit: awaitingNameInput ? handleNameSubmit : (e) => e.preventDefault(), children: [jsxRuntime.jsxs("div", { className: "auth-form-header", children: [jsxRuntime.jsx("h2", { className: "auth-form-title", children: "Continue with WhatsApp" }), jsxRuntime.jsx("p", { className: "auth-form-subtitle", children: sent
|
|
11053
11054
|
? "Tap below to open WhatsApp and send us the pre-filled message — that's how we confirm your number. We'll log you in the moment we receive it."
|
|
11054
11055
|
: awaitingNameInput
|
|
11055
11056
|
? "We'll open WhatsApp with a pre-filled message. Just hit send to confirm your number — no SMS code, no typing."
|
|
11056
|
-
: 'Preparing your WhatsApp link…' })] }), displayedError && (jsxRuntime.jsxs("div", { className: "auth-error", role: "alert", children: [jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: jsxRuntime.jsx("path", { d: "M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm1 13H7v-2h2v2zm0-3H7V4h2v6z" }) }), displayedError] })), awaitingNameInput && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "auth-form-group", children: [jsxRuntime.jsx("label", { htmlFor: "waName", className: "auth-label", children: "Name" }), jsxRuntime.jsx("input", { id: "waName", type: "text", value: displayName, onChange: (e) => setDisplayName(e.target.value), className: "auth-input", placeholder: "John Smith", disabled: loading, autoComplete: "name", autoFocus: true })] }), jsxRuntime.jsx("button", { type: "submit", className: "auth-button auth-button-primary", disabled: loading, children: loading ? jsxRuntime.jsx("span", { className: "auth-spinner" }) : 'Continue' })] })), awaitingAutoSend && (jsxRuntime.jsx("div", { style: { textAlign: 'center', padding: '1.5rem' }, children: jsxRuntime.jsx("span", { className: "auth-spinner" }) })), sent && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!showOnDesktop && (jsxRuntime.jsxs("a", { href: sent.waLink, target: "_blank", rel: "noopener noreferrer", className: "auth-button auth-button-primary", style: {
|
|
11057
|
+
: 'Preparing your WhatsApp link…' })] }), displayedError && (jsxRuntime.jsxs("div", { className: "auth-error", role: "alert", children: [jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: jsxRuntime.jsx("path", { d: "M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm1 13H7v-2h2v2zm0-3H7V4h2v6z" }) }), displayedError] })), awaitingNameInput && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "auth-form-group", children: [jsxRuntime.jsx("label", { htmlFor: "waName", className: "auth-label", children: "Name" }), jsxRuntime.jsx("input", { id: "waName", type: "text", value: displayName, onChange: (e) => setDisplayName(e.target.value), className: "auth-input", placeholder: "John Smith", disabled: loading, autoComplete: "name", autoFocus: true })] }), jsxRuntime.jsx("button", { type: "submit", className: "auth-button auth-button-primary", disabled: loading, children: loading ? jsxRuntime.jsx("span", { className: "auth-spinner" }) : 'Continue' })] })), awaitingAutoSend && (jsxRuntime.jsx("div", { style: { textAlign: 'center', padding: '1.5rem' }, children: jsxRuntime.jsx("span", { className: "auth-spinner" }) })), sent && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!showOnDesktop && hasLaunchLink && (jsxRuntime.jsxs("a", { href: sent.waLink, target: "_blank", rel: "noopener noreferrer", className: "auth-button auth-button-primary", style: {
|
|
11057
11058
|
display: 'flex',
|
|
11058
11059
|
alignItems: 'center',
|
|
11059
11060
|
justifyContent: 'center',
|
|
@@ -11071,7 +11072,7 @@ const WhatsAppAuthForm = ({ onSend, onPollStatus, onVerified, onBack, loading =
|
|
|
11071
11072
|
fontSize: '0.8125rem',
|
|
11072
11073
|
color: '#6B7280',
|
|
11073
11074
|
marginTop: '0.5rem',
|
|
11074
|
-
}, children: "Scan with your phone \u2014 your WhatsApp will open with a pre-filled message. Just hit send." })] })), showOnDesktop && (jsxRuntime.jsx("a", { href: sent.waLink, target: "_blank", rel: "noopener noreferrer", className: "auth-button auth-button-secondary", style: { display: 'block', textAlign: 'center', textDecoration: 'none' }, children: "Or send the message from this device" })), jsxRuntime.jsxs("div", { style: {
|
|
11075
|
+
}, children: "Scan with your phone \u2014 your WhatsApp will open with a pre-filled message. Just hit send." })] })), showOnDesktop && hasLaunchLink && (jsxRuntime.jsx("a", { href: sent.waLink, target: "_blank", rel: "noopener noreferrer", className: "auth-button auth-button-secondary", style: { display: 'block', textAlign: 'center', textDecoration: 'none' }, children: "Or send the message from this device" })), jsxRuntime.jsxs("div", { style: {
|
|
11075
11076
|
marginTop: '1rem',
|
|
11076
11077
|
padding: '0.75rem',
|
|
11077
11078
|
borderRadius: '0.5rem',
|
|
@@ -11080,7 +11081,12 @@ const WhatsAppAuthForm = ({ onSend, onPollStatus, onVerified, onBack, loading =
|
|
|
11080
11081
|
fontSize: '0.8125rem',
|
|
11081
11082
|
color: '#374151',
|
|
11082
11083
|
textAlign: 'center',
|
|
11083
|
-
}, children: [jsxRuntime.jsx("span", { className: "auth-spinner", style: { marginRight: '0.5rem' } }), "Waiting for your message \u2014 we'll log you in automatically\u2026", jsxRuntime.jsxs("div", { style: { marginTop: '0.25rem', fontSize: '0.75rem', opacity: 0.7 }, children: ["Code: ", jsxRuntime.jsx("code", { children: sent.code })] })] }), jsxRuntime.jsx("
|
|
11084
|
+
}, children: [jsxRuntime.jsx("span", { className: "auth-spinner", style: { marginRight: '0.5rem' } }), "Waiting for your message \u2014 we'll log you in automatically\u2026", jsxRuntime.jsxs("div", { style: { marginTop: '0.25rem', fontSize: '0.75rem', opacity: 0.7 }, children: ["Code: ", jsxRuntime.jsx("code", { children: sent.code })] })] }), !hasLaunchLink && (jsxRuntime.jsx("div", { style: {
|
|
11085
|
+
marginTop: '0.75rem',
|
|
11086
|
+
fontSize: '0.8125rem',
|
|
11087
|
+
color: '#6B7280',
|
|
11088
|
+
textAlign: 'center',
|
|
11089
|
+
}, children: "Resume link detected \u2014 checking your WhatsApp verification status\u2026" })), jsxRuntime.jsx("button", { type: "button", className: "auth-link", onClick: handleSendNew, disabled: loading, style: {
|
|
11084
11090
|
marginTop: '0.75rem',
|
|
11085
11091
|
background: 'none',
|
|
11086
11092
|
border: 'none',
|
|
@@ -12820,15 +12826,31 @@ collectionId, enableContactSync, enableInteractionTracking, interactionAppId, in
|
|
|
12820
12826
|
// NOW set isVerified - after parent has acknowledged and session is ready
|
|
12821
12827
|
setIsVerified(true);
|
|
12822
12828
|
notifyAuthStateChange('LOGIN', authUser, authToken, authAccountData || null, authAccountData || null, true);
|
|
12823
|
-
// Sync contact (non-blocking)
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12829
|
+
// Sync contact + track interaction (truly non-blocking - never block login success)
|
|
12830
|
+
syncContact(authUser, authAccountData)
|
|
12831
|
+
.then((newContactId) => {
|
|
12832
|
+
trackInteraction(isNewUser ? 'signup' : 'login', authUser.uid, newContactId, {
|
|
12833
|
+
provider: authUser.email ? 'email' : 'phone',
|
|
12834
|
+
});
|
|
12835
|
+
})
|
|
12836
|
+
.catch((err) => {
|
|
12837
|
+
console.warn('[AuthContext] Post-login contact sync failed (non-fatal):', err);
|
|
12828
12838
|
});
|
|
12829
12839
|
// Optionally preload account info on login (standalone mode only)
|
|
12840
|
+
// NOTE: We call the SDK directly here instead of getAccount(true) because
|
|
12841
|
+
// the memoized getAccount closure still sees token=null (state just set,
|
|
12842
|
+
// not yet committed), which would throw "Not authenticated" spuriously.
|
|
12830
12843
|
if (!proxyMode && preloadAccountInfo) {
|
|
12831
|
-
|
|
12844
|
+
(async () => {
|
|
12845
|
+
try {
|
|
12846
|
+
const fresh = await smartlinks__namespace.auth.getAccount();
|
|
12847
|
+
await tokenStorage.saveAccountInfo(fresh, accountCacheTTL);
|
|
12848
|
+
setAccountInfo(fresh);
|
|
12849
|
+
}
|
|
12850
|
+
catch {
|
|
12851
|
+
/* non-fatal preload */
|
|
12852
|
+
}
|
|
12853
|
+
})();
|
|
12832
12854
|
}
|
|
12833
12855
|
}
|
|
12834
12856
|
catch (error) {
|
|
@@ -14756,7 +14778,20 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
14756
14778
|
const pending = await loadPendingWhatsAppSession();
|
|
14757
14779
|
if (!pending || cancelled) {
|
|
14758
14780
|
if (resumeMode === 'whatsapp') {
|
|
14759
|
-
|
|
14781
|
+
// A WhatsApp resume link can legitimately be opened in a fresh tab,
|
|
14782
|
+
// another browser, or after storage has been cleared. In that case
|
|
14783
|
+
// we still need to surface the WhatsApp resume UI so polling/status
|
|
14784
|
+
// handling can continue instead of silently stripping the URL and
|
|
14785
|
+
// dumping the user back at the generic login screen.
|
|
14786
|
+
setMode('whatsapp');
|
|
14787
|
+
setRestoredWhatsAppSend(resumeToken
|
|
14788
|
+
? {
|
|
14789
|
+
waLink: '',
|
|
14790
|
+
code: '',
|
|
14791
|
+
token: resumeToken,
|
|
14792
|
+
expiresAt: '',
|
|
14793
|
+
}
|
|
14794
|
+
: null);
|
|
14760
14795
|
}
|
|
14761
14796
|
return;
|
|
14762
14797
|
}
|