@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.
@@ -300,6 +300,8 @@ customization={{
300
300
  | `enabledProviders` | `AuthProvider[]` | No | `['email', 'google', 'phone']` | Auth methods |
301
301
  | `redirectUrl` | string | No | - | Post-auth redirect URL |
302
302
  | `accountData` | `Record<string, any>` | No | - | Additional account data |
303
+ | `prefillEmail` | string | No | - | Pre-fill email in the email/password form |
304
+ | `prefillDisplayName` | string | No | - | Pre-fill full name in the registration form |
303
305
  | `onAuthSuccess` | function | Yes | - | Success callback |
304
306
  | `onAuthError` | function | No | - | Error callback |
305
307
  | `className` | string | No | `''` | Additional CSS class |
package/README.md CHANGED
@@ -126,6 +126,8 @@ Main authentication component with login, registration, password reset, and prov
126
126
  | `clientId` | string | **Yes** | Client identifier for your application |
127
127
  | `clientName` | string | No | Client name for branded emails |
128
128
  | `accountData` | Record<string, any> | No | Custom metadata to store on registration |
129
+ | `prefillEmail` | string | No | Pre-fill email in the email/password form |
130
+ | `prefillDisplayName` | string | No | Pre-fill full name in the registration form |
129
131
  | `onAuthSuccess` | (response: AuthResponse) => void | No | Callback when authentication succeeds |
130
132
  | `onAuthError` | (error: Error) => void | No | Callback when authentication fails |
131
133
  | `onRedirect` | (url: string, reason: RedirectReason) => void | No | Callback for navigation after deep-link auth. When provided, disables automatic redirects. |
@@ -12,6 +12,8 @@ interface EmailAuthFormProps {
12
12
  error?: string;
13
13
  signupProminence?: SignupProminence;
14
14
  signupRedirectUrl?: string;
15
+ prefillEmail?: string;
16
+ prefillDisplayName?: string;
15
17
  schema?: ContactSchemaResponse | null;
16
18
  registrationFieldsConfig?: RegistrationFieldConfig[];
17
19
  /** @deprecated Use schema + registrationFieldsConfig instead */
@@ -1 +1 @@
1
- {"version":3,"file":"EmailAuthForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailAuthForm.tsx"],"names":[],"mappings":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UAAU,kBAAkB;IAC1B,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,MAAM,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACtC,wBAAwB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAErD,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,UAAU,EAAE,CAAC;CACjC;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA2RtD,CAAC"}
@@ -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;AAwW7I,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,CA63E5D,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;AAwW7I,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,CA84E5D,CAAC"}
package/dist/index.esm.js CHANGED
@@ -257,11 +257,11 @@ const AuthModeToggle = ({ mode, onModeChange, disabled = false, }) => {
257
257
  return (jsxs("div", { className: "auth-mode-toggle", role: "tablist", "aria-label": "Authentication mode", children: [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" }), 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" })] }));
258
258
  };
259
259
 
260
- const EmailAuthForm = ({ mode, onSubmit, onModeSwitch, onForgotPassword, loading, error, signupProminence = 'minimal', signupRedirectUrl, schema, registrationFieldsConfig = [], additionalFields = [], }) => {
260
+ const EmailAuthForm = ({ mode, onSubmit, onModeSwitch, onForgotPassword, loading, error, signupProminence = 'minimal', signupRedirectUrl, prefillEmail, prefillDisplayName, schema, registrationFieldsConfig = [], additionalFields = [], }) => {
261
261
  const [formData, setFormData] = useState({
262
- email: '',
262
+ email: prefillEmail || '',
263
263
  password: '',
264
- displayName: '',
264
+ displayName: prefillDisplayName || '',
265
265
  });
266
266
  const [customFieldValues, setCustomFieldValues] = useState({});
267
267
  // Get schema-driven registration fields
@@ -13713,7 +13713,7 @@ const checkSilentGoogleSignIn = async (clientId, googleClientId) => {
13713
13713
  });
13714
13714
  };
13715
13715
  // getFriendlyErrorMessage is now imported from ../utils/errorHandling
13716
- 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, }) => {
13716
+ 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, }) => {
13717
13717
  // Resolve signup prominence from props, customization, config, or default
13718
13718
  const resolvedSignupProminence = signupProminence || customization?.signupProminence || 'minimal';
13719
13719
  // Determine initial mode based on signupProminence setting
@@ -14123,7 +14123,13 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
14123
14123
  if (urlMode === 'verifyEmail') {
14124
14124
  log.log('Verifying email with token:', token);
14125
14125
  const response = await api.verifyEmailWithToken(token);
14126
- log.log('Email verification response:', { hasToken: !!response.token, hasUser: !!response.user, emailVerificationMode: response.emailVerificationMode, isNewUser: response.isNewUser });
14126
+ log.log('Email verification response:', { hasToken: !!response?.token, hasUser: !!response?.user, emailVerificationMode: response?.emailVerificationMode, isNewUser: response?.isNewUser });
14127
+ // Detect resolved-error shapes (proxy mode serializes errors instead of throwing).
14128
+ // Common case: sign-up intent claim / verification token already consumed → route to login.
14129
+ const resolvedErrorMessage = getActionResultErrorMessage(response);
14130
+ if (resolvedErrorMessage || !response) {
14131
+ throw new Error(resolvedErrorMessage || 'This verification link has already been used or has expired.');
14132
+ }
14127
14133
  // Get email verification mode from response or config
14128
14134
  const verificationMode = response.emailVerificationMode || config?.emailVerification?.mode || 'verify-auto-login';
14129
14135
  if ((verificationMode === 'verify-auto-login' || verificationMode === 'immediate') && response.token) {
@@ -14185,7 +14191,12 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
14185
14191
  else if (urlMode === 'magicLink') {
14186
14192
  log.log('Verifying magic link token:', token);
14187
14193
  const response = await api.verifyMagicLink(token);
14188
- log.log('Magic link verification response:', { hasToken: !!response.token, hasUser: !!response.user, isNewUser: response.isNewUser });
14194
+ log.log('Magic link verification response:', { hasToken: !!response?.token, hasUser: !!response?.user, isNewUser: response?.isNewUser });
14195
+ // Detect resolved-error shapes (proxy mode serializes errors instead of throwing).
14196
+ const resolvedMagicError = getActionResultErrorMessage(response);
14197
+ if (resolvedMagicError || !response) {
14198
+ throw new Error(resolvedMagicError || 'This magic link has already been used or has expired.');
14199
+ }
14189
14200
  // Auto-login with magic link if token is provided
14190
14201
  if (response.token) {
14191
14202
  // Always await - auth.login now waits for parent ack automatically in iframe mode
@@ -15640,7 +15651,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
15640
15651
  setShowResendVerification(false);
15641
15652
  setShowRequestNewReset(false);
15642
15653
  setError(undefined);
15643
- }, 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 && (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 }))] }));
15654
+ }, 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 && (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 }))] }));
15644
15655
  })()] })) })) : null }));
15645
15656
  };
15646
15657