@proveanything/smartlinks-auth-ui 0.6.2 → 0.6.4
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/CUSTOMIZATION_GUIDE.md +2 -0
- package/README.md +2 -0
- package/dist/components/EmailAuthForm.d.ts +2 -0
- package/dist/components/EmailAuthForm.d.ts.map +1 -1
- package/dist/components/SmartlinksAuthUI.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.css.map +1 -1
- package/dist/index.esm.js +24 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +24 -15
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
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
|
|
@@ -14430,18 +14430,21 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
14430
14430
|
catch (err) {
|
|
14431
14431
|
// Debug: log the raw error shape to help diagnose SDK error wrapping issues
|
|
14432
14432
|
log.error('handleEmailAuth error:', typeof err, err instanceof Error ? `Error.message=${err.message}` : '', JSON.stringify(err, Object.getOwnPropertyNames(err || {})));
|
|
14433
|
-
|
|
14433
|
+
const errorCode = getErrorCode(err);
|
|
14434
|
+
// 1. Explicit "email exists AND is unverified" → go straight to resend.
|
|
14435
|
+
// Also catches generic EMAIL_NOT_VERIFIED / ACCOUNT_LOCKED / etc.
|
|
14434
14436
|
if (requiresEmailVerification(err)) {
|
|
14435
14437
|
setShowResendVerification(true);
|
|
14436
14438
|
setResendEmail(data.email);
|
|
14437
14439
|
setError(getFriendlyErrorMessage(err) + ' Click below to resend the verification link.');
|
|
14438
14440
|
}
|
|
14439
|
-
//
|
|
14440
|
-
else if (mode === 'register' && (
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14441
|
+
// 2. Explicit "email already exists" (verified account) on register → send to login.
|
|
14442
|
+
else if (mode === 'register' && (errorCode === 'EMAIL_ALREADY_EXISTS' ||
|
|
14443
|
+
errorCode === 'EMAIL_ALREADY_IN_USE' ||
|
|
14444
|
+
isConflictError(err) ||
|
|
14445
|
+
(err instanceof Error && /already (registered|exists|in use)/i.test(err.message)))) {
|
|
14446
|
+
setMode('login');
|
|
14447
|
+
setError('An account with this email already exists. Please sign in instead.');
|
|
14445
14448
|
}
|
|
14446
14449
|
else {
|
|
14447
14450
|
setError(getFriendlyErrorMessage(err));
|
|
@@ -15443,16 +15446,17 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
15443
15446
|
boxSizing: 'border-box',
|
|
15444
15447
|
backgroundColor: resolvedTheme === 'dark' ? '#0f172a' : '#f8fafc',
|
|
15445
15448
|
color: resolvedTheme === 'dark' ? '#f1f5f9' : '#1e293b'
|
|
15446
|
-
} }), jsxRuntime.jsxs("div", { style: { display: 'flex', gap: '0.75rem' }, children: [jsxRuntime.jsx("button", { onClick: handleResendVerification, disabled: loading || !resendEmail, className: config?.branding?.inheritHostStyles ? 'auth-button auth-button-primary' : undefined, style: config?.branding?.inheritHostStyles ? {
|
|
15447
|
-
flex: 1,
|
|
15449
|
+
} }), jsxRuntime.jsxs("div", { style: { display: 'flex', gap: '0.75rem', flexWrap: 'wrap' }, children: [jsxRuntime.jsx("button", { onClick: handleResendVerification, disabled: loading || !resendEmail, className: config?.branding?.inheritHostStyles ? 'auth-button auth-button-primary' : undefined, style: config?.branding?.inheritHostStyles ? {
|
|
15450
|
+
flex: '2 1 12rem',
|
|
15448
15451
|
padding: '0.625rem 1rem',
|
|
15449
15452
|
borderRadius: '0.375rem',
|
|
15450
15453
|
fontSize: '0.875rem',
|
|
15451
15454
|
fontWeight: 500,
|
|
15455
|
+
whiteSpace: 'nowrap',
|
|
15452
15456
|
opacity: (loading || !resendEmail) ? 0.6 : 1,
|
|
15453
15457
|
cursor: (loading || !resendEmail) ? 'not-allowed' : 'pointer',
|
|
15454
15458
|
} : {
|
|
15455
|
-
flex: 1,
|
|
15459
|
+
flex: '2 1 12rem',
|
|
15456
15460
|
padding: '0.625rem 1rem',
|
|
15457
15461
|
backgroundColor: 'var(--auth-primary-color, #4F46E5)',
|
|
15458
15462
|
color: 'white',
|
|
@@ -15461,19 +15465,23 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
15461
15465
|
cursor: (loading || !resendEmail) ? 'not-allowed' : 'pointer',
|
|
15462
15466
|
fontSize: '0.875rem',
|
|
15463
15467
|
fontWeight: 500,
|
|
15468
|
+
whiteSpace: 'nowrap',
|
|
15464
15469
|
opacity: (loading || !resendEmail) ? 0.6 : 1
|
|
15465
15470
|
}, children: loading ? 'Sending...' : 'Send New Verification Link' }), jsxRuntime.jsx("button", { onClick: () => {
|
|
15466
15471
|
setShowResendVerification(false);
|
|
15467
15472
|
setResendEmail('');
|
|
15468
15473
|
setError(undefined);
|
|
15469
15474
|
}, disabled: loading, className: config?.branding?.inheritHostStyles ? 'auth-button auth-button-secondary' : undefined, style: config?.branding?.inheritHostStyles ? {
|
|
15475
|
+
flex: '0 0 auto',
|
|
15470
15476
|
padding: '0.625rem 1rem',
|
|
15471
15477
|
borderRadius: '0.375rem',
|
|
15472
15478
|
fontSize: '0.875rem',
|
|
15473
15479
|
fontWeight: 500,
|
|
15480
|
+
whiteSpace: 'nowrap',
|
|
15474
15481
|
opacity: loading ? 0.6 : 1,
|
|
15475
15482
|
cursor: loading ? 'not-allowed' : 'pointer',
|
|
15476
15483
|
} : {
|
|
15484
|
+
flex: '0 0 auto',
|
|
15477
15485
|
padding: '0.625rem 1rem',
|
|
15478
15486
|
backgroundColor: 'transparent',
|
|
15479
15487
|
color: resolvedTheme === 'dark' ? '#94a3b8' : '#6B7280',
|
|
@@ -15482,6 +15490,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
15482
15490
|
cursor: loading ? 'not-allowed' : 'pointer',
|
|
15483
15491
|
fontSize: '0.875rem',
|
|
15484
15492
|
fontWeight: 500,
|
|
15493
|
+
whiteSpace: 'nowrap',
|
|
15485
15494
|
opacity: loading ? 0.6 : 1
|
|
15486
15495
|
}, children: "Cancel" })] })] })) : showRequestNewReset ? (jsxRuntime.jsxs("div", { style: {
|
|
15487
15496
|
marginTop: '1rem',
|
|
@@ -15671,7 +15680,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, onAu
|
|
|
15671
15680
|
setShowResendVerification(false);
|
|
15672
15681
|
setShowRequestNewReset(false);
|
|
15673
15682
|
setError(undefined);
|
|
15674
|
-
}, 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 }))] }));
|
|
15683
|
+
}, 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 }))] }));
|
|
15675
15684
|
})()] })) })) : null }));
|
|
15676
15685
|
};
|
|
15677
15686
|
|