@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.esm.js CHANGED
@@ -14410,18 +14410,21 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, pref
14410
14410
  catch (err) {
14411
14411
  // Debug: log the raw error shape to help diagnose SDK error wrapping issues
14412
14412
  log.error('handleEmailAuth error:', typeof err, err instanceof Error ? `Error.message=${err.message}` : '', JSON.stringify(err, Object.getOwnPropertyNames(err || {})));
14413
- // Check if error requires email verification (403 EMAIL_NOT_VERIFIED, ACCOUNT_LOCKED, etc.)
14413
+ const errorCode = getErrorCode(err);
14414
+ // 1. Explicit "email exists AND is unverified" → go straight to resend.
14415
+ // Also catches generic EMAIL_NOT_VERIFIED / ACCOUNT_LOCKED / etc.
14414
14416
  if (requiresEmailVerification(err)) {
14415
14417
  setShowResendVerification(true);
14416
14418
  setResendEmail(data.email);
14417
14419
  setError(getFriendlyErrorMessage(err) + ' Click below to resend the verification link.');
14418
14420
  }
14419
- // Check if error is about email already registered (409 conflict)
14420
- else if (mode === 'register' && (isConflictError(err) ||
14421
- (err instanceof Error && /already (registered|exists)/i.test(err.message)))) {
14422
- setShowResendVerification(true);
14423
- setResendEmail(data.email);
14424
- setError('This email is already registered. If you didn\'t receive the verification email, you can resend it below.');
14421
+ // 2. Explicit "email already exists" (verified account) on register → send to login.
14422
+ else if (mode === 'register' && (errorCode === 'EMAIL_ALREADY_EXISTS' ||
14423
+ errorCode === 'EMAIL_ALREADY_IN_USE' ||
14424
+ isConflictError(err) ||
14425
+ (err instanceof Error && /already (registered|exists|in use)/i.test(err.message)))) {
14426
+ setMode('login');
14427
+ setError('An account with this email already exists. Please sign in instead.');
14425
14428
  }
14426
14429
  else {
14427
14430
  setError(getFriendlyErrorMessage(err));
@@ -15423,16 +15426,17 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, pref
15423
15426
  boxSizing: 'border-box',
15424
15427
  backgroundColor: resolvedTheme === 'dark' ? '#0f172a' : '#f8fafc',
15425
15428
  color: resolvedTheme === 'dark' ? '#f1f5f9' : '#1e293b'
15426
- } }), jsxs("div", { style: { display: 'flex', gap: '0.75rem' }, children: [jsx("button", { onClick: handleResendVerification, disabled: loading || !resendEmail, className: config?.branding?.inheritHostStyles ? 'auth-button auth-button-primary' : undefined, style: config?.branding?.inheritHostStyles ? {
15427
- flex: 1,
15429
+ } }), jsxs("div", { style: { display: 'flex', gap: '0.75rem', flexWrap: 'wrap' }, children: [jsx("button", { onClick: handleResendVerification, disabled: loading || !resendEmail, className: config?.branding?.inheritHostStyles ? 'auth-button auth-button-primary' : undefined, style: config?.branding?.inheritHostStyles ? {
15430
+ flex: '2 1 12rem',
15428
15431
  padding: '0.625rem 1rem',
15429
15432
  borderRadius: '0.375rem',
15430
15433
  fontSize: '0.875rem',
15431
15434
  fontWeight: 500,
15435
+ whiteSpace: 'nowrap',
15432
15436
  opacity: (loading || !resendEmail) ? 0.6 : 1,
15433
15437
  cursor: (loading || !resendEmail) ? 'not-allowed' : 'pointer',
15434
15438
  } : {
15435
- flex: 1,
15439
+ flex: '2 1 12rem',
15436
15440
  padding: '0.625rem 1rem',
15437
15441
  backgroundColor: 'var(--auth-primary-color, #4F46E5)',
15438
15442
  color: 'white',
@@ -15441,19 +15445,23 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, pref
15441
15445
  cursor: (loading || !resendEmail) ? 'not-allowed' : 'pointer',
15442
15446
  fontSize: '0.875rem',
15443
15447
  fontWeight: 500,
15448
+ whiteSpace: 'nowrap',
15444
15449
  opacity: (loading || !resendEmail) ? 0.6 : 1
15445
15450
  }, children: loading ? 'Sending...' : 'Send New Verification Link' }), jsx("button", { onClick: () => {
15446
15451
  setShowResendVerification(false);
15447
15452
  setResendEmail('');
15448
15453
  setError(undefined);
15449
15454
  }, disabled: loading, className: config?.branding?.inheritHostStyles ? 'auth-button auth-button-secondary' : undefined, style: config?.branding?.inheritHostStyles ? {
15455
+ flex: '0 0 auto',
15450
15456
  padding: '0.625rem 1rem',
15451
15457
  borderRadius: '0.375rem',
15452
15458
  fontSize: '0.875rem',
15453
15459
  fontWeight: 500,
15460
+ whiteSpace: 'nowrap',
15454
15461
  opacity: loading ? 0.6 : 1,
15455
15462
  cursor: loading ? 'not-allowed' : 'pointer',
15456
15463
  } : {
15464
+ flex: '0 0 auto',
15457
15465
  padding: '0.625rem 1rem',
15458
15466
  backgroundColor: 'transparent',
15459
15467
  color: resolvedTheme === 'dark' ? '#94a3b8' : '#6B7280',
@@ -15462,6 +15470,7 @@ const SmartlinksAuthUI = ({ apiEndpoint, clientId, clientName, accountData, pref
15462
15470
  cursor: loading ? 'not-allowed' : 'pointer',
15463
15471
  fontSize: '0.875rem',
15464
15472
  fontWeight: 500,
15473
+ whiteSpace: 'nowrap',
15465
15474
  opacity: loading ? 0.6 : 1
15466
15475
  }, children: "Cancel" })] })] })) : showRequestNewReset ? (jsxs("div", { style: {
15467
15476
  marginTop: '1rem',