@proveanything/smartlinks-auth-ui 0.6.3 → 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/dist/index.js CHANGED
@@ -14430,18 +14430,21 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, pref
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
- // Check if error requires email verification (403 EMAIL_NOT_VERIFIED, ACCOUNT_LOCKED, etc.)
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
- // Check if error is about email already registered (409 conflict)
14440
- else if (mode === 'register' && (isConflictError(err) ||
14441
- (err instanceof Error && /already (registered|exists)/i.test(err.message)))) {
14442
- setShowResendVerification(true);
14443
- setResendEmail(data.email);
14444
- setError('This email is already registered. If you didn\'t receive the verification email, you can resend it below.');
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, pref
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, pref
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, pref
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',