@proveanything/smartlinks-auth-ui 0.6.1 → 0.6.3

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
@@ -277,11 +277,11 @@ const AuthModeToggle = ({ mode, onModeChange, disabled = false, }) => {
277
277
  return (jsxRuntime.jsxs("div", { className: "auth-mode-toggle", role: "tablist", "aria-label": "Authentication mode", children: [jsxRuntime.jsx("button", { type: "button", role: "tab", "aria-selected": mode === 'login', className: `auth-mode-toggle-button ${mode === 'login' ? 'auth-mode-toggle-button--active' : ''}`, onClick: () => onModeChange('login'), disabled: disabled, children: "Sign In" }), jsxRuntime.jsx("button", { type: "button", role: "tab", "aria-selected": mode === 'register', className: `auth-mode-toggle-button ${mode === 'register' ? 'auth-mode-toggle-button--active' : ''}`, onClick: () => onModeChange('register'), disabled: disabled, children: "Create Account" })] }));
278
278
  };
279
279
 
280
- const EmailAuthForm = ({ mode, onSubmit, onModeSwitch, onForgotPassword, loading, error, signupProminence = 'minimal', signupRedirectUrl, schema, registrationFieldsConfig = [], additionalFields = [], }) => {
280
+ const EmailAuthForm = ({ mode, onSubmit, onModeSwitch, onForgotPassword, loading, error, signupProminence = 'minimal', signupRedirectUrl, prefillEmail, prefillDisplayName, schema, registrationFieldsConfig = [], additionalFields = [], }) => {
281
281
  const [formData, setFormData] = React.useState({
282
- email: '',
282
+ email: prefillEmail || '',
283
283
  password: '',
284
- displayName: '',
284
+ displayName: prefillDisplayName || '',
285
285
  });
286
286
  const [customFieldValues, setCustomFieldValues] = React.useState({});
287
287
  // Get schema-driven registration fields
@@ -13733,7 +13733,7 @@ const checkSilentGoogleSignIn = async (clientId, googleClientId) => {
13733
13733
  });
13734
13734
  };
13735
13735
  // getFriendlyErrorMessage is now imported from ../utils/errorHandling
13736
- const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAuthSuccess, onAuthError, onRedirect, enabledProviders = ['email', 'google', 'phone'], initialMode, signupProminence, redirectUrl, theme = 'light', className, customization, skipConfigFetch = false, minimal = false, logger, proxyMode = false, collectionId, disableConfigCache = false, enableSilentGoogleSignIn = false, nativeAuth, enableSilentNativeSignIn = false, whatsappReply, whatsappPrefillMessage, }) => {
13736
+ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, prefillEmail, prefillDisplayName, onAuthSuccess, onAuthError, onRedirect, enabledProviders = ['email', 'google', 'phone'], initialMode, signupProminence, redirectUrl, theme = 'light', className, customization, skipConfigFetch = false, minimal = false, logger, proxyMode = false, collectionId, disableConfigCache = false, enableSilentGoogleSignIn = false, nativeAuth, enableSilentNativeSignIn = false, whatsappReply, whatsappPrefillMessage, }) => {
13737
13737
  // Resolve signup prominence from props, customization, config, or default
13738
13738
  const resolvedSignupProminence = signupProminence || customization?.signupProminence || 'minimal';
13739
13739
  // Determine initial mode based on signupProminence setting
@@ -14143,7 +14143,13 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
14143
14143
  if (urlMode === 'verifyEmail') {
14144
14144
  log.log('Verifying email with token:', token);
14145
14145
  const response = await api.verifyEmailWithToken(token);
14146
- log.log('Email verification response:', { hasToken: !!response.token, hasUser: !!response.user, emailVerificationMode: response.emailVerificationMode, isNewUser: response.isNewUser });
14146
+ log.log('Email verification response:', { hasToken: !!response?.token, hasUser: !!response?.user, emailVerificationMode: response?.emailVerificationMode, isNewUser: response?.isNewUser });
14147
+ // Detect resolved-error shapes (proxy mode serializes errors instead of throwing).
14148
+ // Common case: sign-up intent claim / verification token already consumed → route to login.
14149
+ const resolvedErrorMessage = getActionResultErrorMessage(response);
14150
+ if (resolvedErrorMessage || !response) {
14151
+ throw new Error(resolvedErrorMessage || 'This verification link has already been used or has expired.');
14152
+ }
14147
14153
  // Get email verification mode from response or config
14148
14154
  const verificationMode = response.emailVerificationMode || config?.emailVerification?.mode || 'verify-auto-login';
14149
14155
  if ((verificationMode === 'verify-auto-login' || verificationMode === 'immediate') && response.token) {
@@ -14205,7 +14211,12 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
14205
14211
  else if (urlMode === 'magicLink') {
14206
14212
  log.log('Verifying magic link token:', token);
14207
14213
  const response = await api.verifyMagicLink(token);
14208
- log.log('Magic link verification response:', { hasToken: !!response.token, hasUser: !!response.user, isNewUser: response.isNewUser });
14214
+ log.log('Magic link verification response:', { hasToken: !!response?.token, hasUser: !!response?.user, isNewUser: response?.isNewUser });
14215
+ // Detect resolved-error shapes (proxy mode serializes errors instead of throwing).
14216
+ const resolvedMagicError = getActionResultErrorMessage(response);
14217
+ if (resolvedMagicError || !response) {
14218
+ throw new Error(resolvedMagicError || 'This magic link has already been used or has expired.');
14219
+ }
14209
14220
  // Auto-login with magic link if token is provided
14210
14221
  if (response.token) {
14211
14222
  // Always await - auth.login now waits for parent ack automatically in iframe mode
@@ -15660,7 +15671,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
15660
15671
  setShowResendVerification(false);
15661
15672
  setShowRequestNewReset(false);
15662
15673
  setError(undefined);
15663
- }, onForgotPassword: () => setMode('reset-password'), loading: loading, error: error, signupProminence: resolvedSignupProminence, signupRedirectUrl: config?.signupRedirectUrl || customization?.signupRedirectUrl, schema: contactSchema, registrationFieldsConfig: config?.registrationFields, additionalFields: config?.signupAdditionalFields }), emailDisplayMode === 'form' && actualProviders.length > 1 && (jsxRuntime.jsx(ProviderButtons, { enabledProviders: actualProviders.filter((p) => p !== 'email'), providerOrder: providerOrder, onGoogleLogin: handleGoogleLogin, onAppleLogin: handleAppleLogin, onPhoneLogin: () => setMode('phone'), onMagicLinkLogin: () => setMode('magic-link'), onWhatsAppLogin: () => setMode('whatsapp'), loading: loading }))] }));
15674
+ }, onForgotPassword: () => setMode('reset-password'), loading: loading, error: error, signupProminence: resolvedSignupProminence, signupRedirectUrl: config?.signupRedirectUrl || customization?.signupRedirectUrl, prefillEmail: prefillEmail, prefillDisplayName: prefillDisplayName, schema: contactSchema, registrationFieldsConfig: config?.registrationFields, additionalFields: config?.signupAdditionalFields }), emailDisplayMode === 'form' && actualProviders.length > 1 && (jsxRuntime.jsx(ProviderButtons, { enabledProviders: actualProviders.filter((p) => p !== 'email'), providerOrder: providerOrder, onGoogleLogin: handleGoogleLogin, onAppleLogin: handleAppleLogin, onPhoneLogin: () => setMode('phone'), onMagicLinkLogin: () => setMode('magic-link'), onWhatsAppLogin: () => setMode('whatsapp'), loading: loading }))] }));
15664
15675
  })()] })) })) : null }));
15665
15676
  };
15666
15677