@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.
@@ -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;AA2V7I,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,CAutE5D,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;AA2V7I,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,CAouE5D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"WhatsAppAuthForm.d.ts","sourceRoot":"","sources":["../../src/components/WhatsAppAuthForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,gBAAgB,CAAC;AAExB,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAA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KAAK,CAAC,EAAE,CAAC,iBAAiB,CAoqCpD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,gBAM1B,CAAC"}
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,CAkrCpD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,gBAM1B,CAAC"}
package/dist/index.esm.js CHANGED
@@ -11029,11 +11029,12 @@ const WhatsAppAuthForm = ({ onSend, onPollStatus, onVerified, onBack, loading =
11029
11029
  const displayedError = pollError || error;
11030
11030
  const awaitingNameInput = collectName && !sent;
11031
11031
  const awaitingAutoSend = !collectName && !sent;
11032
+ const hasLaunchLink = !!sent?.waLink;
11032
11033
  return (jsxs("form", { className: "auth-form", onSubmit: awaitingNameInput ? handleNameSubmit : (e) => e.preventDefault(), children: [jsxs("div", { className: "auth-form-header", children: [jsx("h2", { className: "auth-form-title", children: "Continue with WhatsApp" }), jsx("p", { className: "auth-form-subtitle", children: sent
11033
11034
  ? "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."
11034
11035
  : awaitingNameInput
11035
11036
  ? "We'll open WhatsApp with a pre-filled message. Just hit send to confirm your number — no SMS code, no typing."
11036
- : 'Preparing your WhatsApp link…' })] }), displayedError && (jsxs("div", { className: "auth-error", role: "alert", children: [jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: 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 && (jsxs(Fragment, { children: [jsxs("div", { className: "auth-form-group", children: [jsx("label", { htmlFor: "waName", className: "auth-label", children: "Name" }), 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 })] }), jsx("button", { type: "submit", className: "auth-button auth-button-primary", disabled: loading, children: loading ? jsx("span", { className: "auth-spinner" }) : 'Continue' })] })), awaitingAutoSend && (jsx("div", { style: { textAlign: 'center', padding: '1.5rem' }, children: jsx("span", { className: "auth-spinner" }) })), sent && (jsxs(Fragment, { children: [!showOnDesktop && (jsxs("a", { href: sent.waLink, target: "_blank", rel: "noopener noreferrer", className: "auth-button auth-button-primary", style: {
11037
+ : 'Preparing your WhatsApp link…' })] }), displayedError && (jsxs("div", { className: "auth-error", role: "alert", children: [jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: 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 && (jsxs(Fragment, { children: [jsxs("div", { className: "auth-form-group", children: [jsx("label", { htmlFor: "waName", className: "auth-label", children: "Name" }), 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 })] }), jsx("button", { type: "submit", className: "auth-button auth-button-primary", disabled: loading, children: loading ? jsx("span", { className: "auth-spinner" }) : 'Continue' })] })), awaitingAutoSend && (jsx("div", { style: { textAlign: 'center', padding: '1.5rem' }, children: jsx("span", { className: "auth-spinner" }) })), sent && (jsxs(Fragment, { children: [!showOnDesktop && hasLaunchLink && (jsxs("a", { href: sent.waLink, target: "_blank", rel: "noopener noreferrer", className: "auth-button auth-button-primary", style: {
11037
11038
  display: 'flex',
11038
11039
  alignItems: 'center',
11039
11040
  justifyContent: 'center',
@@ -11051,7 +11052,7 @@ const WhatsAppAuthForm = ({ onSend, onPollStatus, onVerified, onBack, loading =
11051
11052
  fontSize: '0.8125rem',
11052
11053
  color: '#6B7280',
11053
11054
  marginTop: '0.5rem',
11054
- }, children: "Scan with your phone \u2014 your WhatsApp will open with a pre-filled message. Just hit send." })] })), showOnDesktop && (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" })), jsxs("div", { style: {
11055
+ }, children: "Scan with your phone \u2014 your WhatsApp will open with a pre-filled message. Just hit send." })] })), showOnDesktop && hasLaunchLink && (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" })), jsxs("div", { style: {
11055
11056
  marginTop: '1rem',
11056
11057
  padding: '0.75rem',
11057
11058
  borderRadius: '0.5rem',
@@ -11060,7 +11061,12 @@ const WhatsAppAuthForm = ({ onSend, onPollStatus, onVerified, onBack, loading =
11060
11061
  fontSize: '0.8125rem',
11061
11062
  color: '#374151',
11062
11063
  textAlign: 'center',
11063
- }, children: [jsx("span", { className: "auth-spinner", style: { marginRight: '0.5rem' } }), "Waiting for your message \u2014 we'll log you in automatically\u2026", jsxs("div", { style: { marginTop: '0.25rem', fontSize: '0.75rem', opacity: 0.7 }, children: ["Code: ", jsx("code", { children: sent.code })] })] }), jsx("button", { type: "button", className: "auth-link", onClick: handleSendNew, disabled: loading, style: {
11064
+ }, children: [jsx("span", { className: "auth-spinner", style: { marginRight: '0.5rem' } }), "Waiting for your message \u2014 we'll log you in automatically\u2026", jsxs("div", { style: { marginTop: '0.25rem', fontSize: '0.75rem', opacity: 0.7 }, children: ["Code: ", jsx("code", { children: sent.code })] })] }), !hasLaunchLink && (jsx("div", { style: {
11065
+ marginTop: '0.75rem',
11066
+ fontSize: '0.8125rem',
11067
+ color: '#6B7280',
11068
+ textAlign: 'center',
11069
+ }, children: "Resume link detected \u2014 checking your WhatsApp verification status\u2026" })), jsx("button", { type: "button", className: "auth-link", onClick: handleSendNew, disabled: loading, style: {
11064
11070
  marginTop: '0.75rem',
11065
11071
  background: 'none',
11066
11072
  border: 'none',
@@ -12800,15 +12806,31 @@ collectionId, enableContactSync, enableInteractionTracking, interactionAppId, in
12800
12806
  // NOW set isVerified - after parent has acknowledged and session is ready
12801
12807
  setIsVerified(true);
12802
12808
  notifyAuthStateChange('LOGIN', authUser, authToken, authAccountData || null, authAccountData || null, true);
12803
- // Sync contact (non-blocking)
12804
- const newContactId = await syncContact(authUser, authAccountData);
12805
- // Track interaction (non-blocking)
12806
- trackInteraction(isNewUser ? 'signup' : 'login', authUser.uid, newContactId, {
12807
- provider: authUser.email ? 'email' : 'phone',
12809
+ // Sync contact + track interaction (truly non-blocking - never block login success)
12810
+ syncContact(authUser, authAccountData)
12811
+ .then((newContactId) => {
12812
+ trackInteraction(isNewUser ? 'signup' : 'login', authUser.uid, newContactId, {
12813
+ provider: authUser.email ? 'email' : 'phone',
12814
+ });
12815
+ })
12816
+ .catch((err) => {
12817
+ console.warn('[AuthContext] Post-login contact sync failed (non-fatal):', err);
12808
12818
  });
12809
12819
  // Optionally preload account info on login (standalone mode only)
12820
+ // NOTE: We call the SDK directly here instead of getAccount(true) because
12821
+ // the memoized getAccount closure still sees token=null (state just set,
12822
+ // not yet committed), which would throw "Not authenticated" spuriously.
12810
12823
  if (!proxyMode && preloadAccountInfo) {
12811
- getAccount(true).catch(() => { });
12824
+ (async () => {
12825
+ try {
12826
+ const fresh = await smartlinks.auth.getAccount();
12827
+ await tokenStorage.saveAccountInfo(fresh, accountCacheTTL);
12828
+ setAccountInfo(fresh);
12829
+ }
12830
+ catch {
12831
+ /* non-fatal preload */
12832
+ }
12833
+ })();
12812
12834
  }
12813
12835
  }
12814
12836
  catch (error) {
@@ -14736,7 +14758,20 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
14736
14758
  const pending = await loadPendingWhatsAppSession();
14737
14759
  if (!pending || cancelled) {
14738
14760
  if (resumeMode === 'whatsapp') {
14739
- syncWhatsAppResumeUrl(null);
14761
+ // A WhatsApp resume link can legitimately be opened in a fresh tab,
14762
+ // another browser, or after storage has been cleared. In that case
14763
+ // we still need to surface the WhatsApp resume UI so polling/status
14764
+ // handling can continue instead of silently stripping the URL and
14765
+ // dumping the user back at the generic login screen.
14766
+ setMode('whatsapp');
14767
+ setRestoredWhatsAppSend(resumeToken
14768
+ ? {
14769
+ waLink: '',
14770
+ code: '',
14771
+ token: resumeToken,
14772
+ expiresAt: '',
14773
+ }
14774
+ : null);
14740
14775
  }
14741
14776
  return;
14742
14777
  }