@main12/auth-login 0.2.1 → 0.2.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.
Files changed (48) hide show
  1. package/dist/auth/application/hooks/useLoginFlow.d.ts +1 -1
  2. package/dist/auth/application/hooks/useSetPasswordFlow.d.ts +1 -1
  3. package/dist/auth/application/services/authService.d.ts +1 -1
  4. package/dist/auth/domain/passwordRules.d.ts +1 -1
  5. package/dist/components/AuthLayout.d.ts +1 -1
  6. package/dist/components/AuthLayout.js +59 -35
  7. package/dist/components/AuthPages.d.ts +22 -0
  8. package/dist/components/AuthPages.js +83 -0
  9. package/dist/components/PoweredBy.js +40 -23
  10. package/dist/components/email/baseTemplate.d.ts +2 -2
  11. package/dist/components/email/index.d.ts +7 -7
  12. package/dist/components/email/templates/otp.d.ts +3 -3
  13. package/dist/components/email/templates/passwordChanged.d.ts +3 -3
  14. package/dist/components/email/templates/passwordReset.d.ts +3 -3
  15. package/dist/components/email/templates/welcome.d.ts +3 -3
  16. package/dist/components/pages/ForgotPasswordPage.d.ts +1 -1
  17. package/dist/components/pages/ForgotPasswordPageHero.d.ts +1 -1
  18. package/dist/components/pages/ForgotPasswordPageHero.js +24 -15
  19. package/dist/components/pages/ForgotPasswordPageTailwind.d.ts +1 -1
  20. package/dist/components/pages/LoginPage.d.ts +1 -1
  21. package/dist/components/pages/LoginPageHero.d.ts +1 -1
  22. package/dist/components/pages/LoginPageHero.js +81 -51
  23. package/dist/components/pages/LoginPageTailwind.d.ts +1 -1
  24. package/dist/components/pages/LoginPageTailwind.js +11 -20
  25. package/dist/components/pages/SetPasswordPage.d.ts +1 -1
  26. package/dist/components/pages/SetPasswordPageHero.d.ts +1 -1
  27. package/dist/components/pages/SetPasswordPageHero.js +50 -33
  28. package/dist/components/pages/SetPasswordPageTailwind.d.ts +1 -1
  29. package/dist/components/pages/SignupPage.d.ts +1 -1
  30. package/dist/components/pages/SignupPageHero.d.ts +1 -1
  31. package/dist/components/pages/SignupPageHero.js +46 -34
  32. package/dist/components/pages/SignupPageTailwind.d.ts +1 -1
  33. package/dist/components/pages/VerifyOtpPage.d.ts +1 -1
  34. package/dist/components/pages/VerifyOtpPageHero.d.ts +1 -1
  35. package/dist/components/pages/VerifyOtpPageHero.js +46 -10
  36. package/dist/components/pages/VerifyOtpPageTailwind.d.ts +1 -1
  37. package/dist/components/ui/index.d.ts +2 -1
  38. package/dist/components/ui/index.js +3 -2
  39. package/dist/config.d.ts +9 -0
  40. package/dist/config.js +8 -5
  41. package/dist/exports/client.d.ts +27 -24
  42. package/dist/exports/client.js +4 -0
  43. package/dist/exports/rsc.d.ts +6 -6
  44. package/dist/index.d.ts +15 -2
  45. package/dist/index.js +12 -1
  46. package/dist/proxy.d.ts +31 -0
  47. package/dist/proxy.js +55 -0
  48. package/package.json +23 -14
@@ -1,8 +1,8 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import React, { Suspense } from 'react';
4
4
  import { useSearchParams } from 'next/navigation';
5
- import { Button, InputOtp, Spinner as HSpinner } from '@heroui/react';
5
+ import { Button, InputOTP, Spinner } from '@heroui/react';
6
6
  import { Icon } from '@iconify/react';
7
7
  import { motion } from 'framer-motion';
8
8
  import { useVerifyOtpFlow } from '../../auth/application/hooks/useVerifyOtpFlow.js';
@@ -43,12 +43,41 @@ function VerifyOtpHeroContent({ loginUrl = '/login', logo, poweredBy, cardClassN
43
43
  className: "text-gray-700 text-sm font-medium",
44
44
  children: email
45
45
  }),
46
- /*#__PURE__*/ _jsx(InputOtp, {
47
- length: 6,
46
+ /*#__PURE__*/ _jsxs(InputOTP, {
47
+ maxLength: 6,
48
48
  value: otp,
49
- onValueChange: setOtp,
49
+ onChange: setOtp,
50
50
  isDisabled: isLoading,
51
- autoFocus: true
51
+ autoFocus: true,
52
+ children: [
53
+ /*#__PURE__*/ _jsxs(InputOTP.Group, {
54
+ children: [
55
+ /*#__PURE__*/ _jsx(InputOTP.Slot, {
56
+ index: 0
57
+ }),
58
+ /*#__PURE__*/ _jsx(InputOTP.Slot, {
59
+ index: 1
60
+ }),
61
+ /*#__PURE__*/ _jsx(InputOTP.Slot, {
62
+ index: 2
63
+ })
64
+ ]
65
+ }),
66
+ /*#__PURE__*/ _jsx(InputOTP.Separator, {}),
67
+ /*#__PURE__*/ _jsxs(InputOTP.Group, {
68
+ children: [
69
+ /*#__PURE__*/ _jsx(InputOTP.Slot, {
70
+ index: 3
71
+ }),
72
+ /*#__PURE__*/ _jsx(InputOTP.Slot, {
73
+ index: 4
74
+ }),
75
+ /*#__PURE__*/ _jsx(InputOTP.Slot, {
76
+ index: 5
77
+ })
78
+ ]
79
+ })
80
+ ]
52
81
  }),
53
82
  error && /*#__PURE__*/ _jsx(motion.div, {
54
83
  className: "w-full bg-red-50 text-red-600 border border-red-200 rounded-lg p-3 text-sm",
@@ -63,12 +92,19 @@ function VerifyOtpHeroContent({ loginUrl = '/login', logo, poweredBy, cardClassN
63
92
  /*#__PURE__*/ _jsx(Button, {
64
93
  fullWidth: true,
65
94
  size: "lg",
66
- color: "primary",
67
- isLoading: isLoading,
95
+ isPending: isLoading,
68
96
  isDisabled: otp.length !== 6,
69
97
  onPress: handleSubmit,
70
98
  className: "h-12 font-semibold",
71
- children: "Verify"
99
+ children: ({ isPending })=>/*#__PURE__*/ _jsxs(_Fragment, {
100
+ children: [
101
+ isPending && /*#__PURE__*/ _jsx(Spinner, {
102
+ color: "current",
103
+ size: "sm"
104
+ }),
105
+ "Verify"
106
+ ]
107
+ })
72
108
  }),
73
109
  /*#__PURE__*/ _jsxs("div", {
74
110
  className: "text-center",
@@ -93,7 +129,7 @@ export default function VerifyOtpPageHero(props) {
93
129
  return /*#__PURE__*/ _jsx(Suspense, {
94
130
  fallback: /*#__PURE__*/ _jsx("div", {
95
131
  className: "min-h-screen flex items-center justify-center",
96
- children: /*#__PURE__*/ _jsx(HSpinner, {
132
+ children: /*#__PURE__*/ _jsx(Spinner, {
97
133
  size: "lg"
98
134
  })
99
135
  }),
@@ -1,4 +1,4 @@
1
- import type { AuthLayoutConfig } from '../AuthLayout.js';
1
+ import type { AuthLayoutConfig } from '../AuthLayout';
2
2
  export interface VerifyOtpPageProps extends AuthLayoutConfig {
3
3
  loginUrl?: string;
4
4
  }
@@ -8,7 +8,7 @@ interface ButtonProps {
8
8
  isDisabled?: boolean;
9
9
  onPress?: () => void;
10
10
  onClick?: () => void;
11
- variant?: 'primary' | 'bordered' | 'ghost' | 'tertiary';
11
+ variant?: 'primary' | 'secondary' | 'bordered' | 'ghost' | 'tertiary';
12
12
  className?: string;
13
13
  }
14
14
  export declare const Button: React.FC<ButtonProps>;
@@ -25,6 +25,7 @@ interface InputProps {
25
25
  placeholder?: string;
26
26
  className?: string;
27
27
  name?: string;
28
+ variant?: 'default' | 'secondary';
28
29
  }
29
30
  export declare const Input: React.FC<InputProps>;
30
31
  interface CardProps {
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  const variantClasses = {
4
4
  primary: 'bg-[#D5E855] text-gray-900 hover:bg-[#C9DC4A] font-semibold',
5
+ secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200 font-medium',
5
6
  bordered: 'border border-gray-300 text-gray-700 hover:bg-gray-50 bg-white',
6
7
  ghost: 'text-gray-600 hover:text-gray-900 bg-transparent',
7
8
  tertiary: 'text-gray-600 hover:text-gray-900 bg-transparent underline'
@@ -25,7 +26,7 @@ export const Button = ({ children, type = 'button', fullWidth = true, size = 'lg
25
26
  children
26
27
  ]
27
28
  });
28
- export const Input = ({ type = 'text', label, value, onChange, onValueChange, isRequired, isDisabled, autoFocus, autoComplete, placeholder, className = '', name })=>/*#__PURE__*/ _jsxs("div", {
29
+ export const Input = ({ type = 'text', label, value, onChange, onValueChange, isRequired, isDisabled, autoFocus, autoComplete, placeholder, className = '', name, variant = 'default' })=>/*#__PURE__*/ _jsxs("div", {
29
30
  className: "w-full",
30
31
  children: [
31
32
  label && /*#__PURE__*/ _jsxs("label", {
@@ -45,7 +46,7 @@ export const Input = ({ type = 'text', label, value, onChange, onValueChange, is
45
46
  autoComplete: autoComplete,
46
47
  placeholder: placeholder,
47
48
  name: name,
48
- className: `w-full h-12 px-4 bg-white border border-gray-300 hover:border-gray-400 rounded-xl text-gray-900 text-base transition-colors outline-none focus:border-[#D5E855] focus:ring-2 focus:ring-[#D5E855]/30 ${className}`
49
+ className: `w-full h-12 px-4 ${variant === 'secondary' ? 'bg-gray-100' : 'bg-white'} border border-gray-300 hover:border-gray-400 rounded-xl text-gray-900 text-base transition-colors outline-none focus:border-[#D5E855] focus:ring-2 focus:ring-[#D5E855]/30 ${className}`
49
50
  })
50
51
  ]
51
52
  });
package/dist/config.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type React from 'react';
1
2
  /**
2
3
  * Shared plugin configuration — set by the plugin factory at init time,
3
4
  * read by all client components at render time.
@@ -6,5 +7,13 @@ export type AuthStyle = 'tailwind' | 'hero-ui';
6
7
  export declare const pluginConfig: {
7
8
  style: AuthStyle;
8
9
  logoUrl?: string;
10
+ Logo?: React.ComponentType;
9
11
  googleOAuthEnabled: boolean;
12
+ routeRedirects: boolean;
13
+ authBasePath: string;
10
14
  };
15
+ /** Call this client-side to mirror the server plugin config. */
16
+ export declare function initClientConfig(opts: {
17
+ style?: AuthStyle;
18
+ googleOAuthEnabled?: boolean;
19
+ }): void;
package/dist/config.js CHANGED
@@ -1,7 +1,10 @@
1
- /**
2
- * Shared plugin configuration — set by the plugin factory at init time,
3
- * read by all client components at render time.
4
- */ export const pluginConfig = {
1
+ export const pluginConfig = {
5
2
  style: 'tailwind',
6
- googleOAuthEnabled: true
3
+ googleOAuthEnabled: true,
4
+ routeRedirects: false,
5
+ authBasePath: '/auth'
7
6
  };
7
+ /** Call this client-side to mirror the server plugin config. */ export function initClientConfig(opts) {
8
+ if (opts.style) pluginConfig.style = opts.style;
9
+ if (opts.googleOAuthEnabled !== undefined) pluginConfig.googleOAuthEnabled = opts.googleOAuthEnabled;
10
+ }
@@ -1,24 +1,27 @@
1
- export { useLoginFlow } from '../auth/application/hooks/useLoginFlow.js';
2
- export { useVerifyOtpFlow } from '../auth/application/hooks/useVerifyOtpFlow.js';
3
- export { useForgotPasswordFlow } from '../auth/application/hooks/useForgotPasswordFlow.js';
4
- export { useSetPasswordFlow } from '../auth/application/hooks/useSetPasswordFlow.js';
5
- export { checkEmail, sendOtp, verifyOtp, setUserPassword, signup, initiateGoogleLogin, } from '../auth/application/services/authService.js';
6
- export { evaluatePasswordStrength, isPasswordValid, MIN_PASSWORD_LENGTH } from '../auth/domain/passwordRules.js';
7
- export { default as LoginPage } from '../components/pages/LoginPage.js';
8
- export { default as SignupPage } from '../components/pages/SignupPage.js';
9
- export { default as ForgotPasswordPage } from '../components/pages/ForgotPasswordPage.js';
10
- export { default as VerifyOtpPage } from '../components/pages/VerifyOtpPage.js';
11
- export { default as SetPasswordPage } from '../components/pages/SetPasswordPage.js';
12
- export { AuthLayout } from '../components/AuthLayout.js';
13
- export { PoweredBy } from '../components/PoweredBy.js';
14
- export type { LoginStep, OTPPurpose, CheckEmailResponse, SendOtpResponse, VerifyOtpResponse, SetPasswordResponse, SignupResponse, PasswordStrengthResult, } from '../auth/domain/types.js';
15
- export type { UseLoginFlowOptions } from '../auth/application/hooks/useLoginFlow.js';
16
- export type { UseVerifyOtpFlowOptions } from '../auth/application/hooks/useVerifyOtpFlow.js';
17
- export type { UseSetPasswordFlowOptions } from '../auth/application/hooks/useSetPasswordFlow.js';
18
- export type { LoginPageProps } from '../components/pages/LoginPage.js';
19
- export type { SignupPageProps } from '../components/pages/SignupPage.js';
20
- export type { ForgotPasswordPageProps } from '../components/pages/ForgotPasswordPage.js';
21
- export type { VerifyOtpPageProps } from '../components/pages/VerifyOtpPage.js';
22
- export type { SetPasswordPageProps } from '../components/pages/SetPasswordPage.js';
23
- export type { AuthLayoutConfig, AuthLayoutProps } from '../components/AuthLayout.js';
24
- export type { PoweredByProps } from '../components/PoweredBy.js';
1
+ export { initClientConfig } from '../config';
2
+ export { useLoginFlow } from '../auth/application/hooks/useLoginFlow';
3
+ export { useVerifyOtpFlow } from '../auth/application/hooks/useVerifyOtpFlow';
4
+ export { useForgotPasswordFlow } from '../auth/application/hooks/useForgotPasswordFlow';
5
+ export { useSetPasswordFlow } from '../auth/application/hooks/useSetPasswordFlow';
6
+ export { checkEmail, sendOtp, verifyOtp, setUserPassword, signup, initiateGoogleLogin, } from '../auth/application/services/authService';
7
+ export { evaluatePasswordStrength, isPasswordValid, MIN_PASSWORD_LENGTH } from '../auth/domain/passwordRules';
8
+ export { default as LoginPage } from '../components/pages/LoginPage';
9
+ export { default as SignupPage } from '../components/pages/SignupPage';
10
+ export { default as ForgotPasswordPage } from '../components/pages/ForgotPasswordPage';
11
+ export { default as VerifyOtpPage } from '../components/pages/VerifyOtpPage';
12
+ export { default as SetPasswordPage } from '../components/pages/SetPasswordPage';
13
+ export { default as AuthPages } from '../components/AuthPages';
14
+ export type { AuthPagesProps } from '../components/AuthPages';
15
+ export { AuthLayout } from '../components/AuthLayout';
16
+ export { PoweredBy } from '../components/PoweredBy';
17
+ export type { LoginStep, OTPPurpose, CheckEmailResponse, SendOtpResponse, VerifyOtpResponse, SetPasswordResponse, SignupResponse, PasswordStrengthResult, } from '../auth/domain/types';
18
+ export type { UseLoginFlowOptions } from '../auth/application/hooks/useLoginFlow';
19
+ export type { UseVerifyOtpFlowOptions } from '../auth/application/hooks/useVerifyOtpFlow';
20
+ export type { UseSetPasswordFlowOptions } from '../auth/application/hooks/useSetPasswordFlow';
21
+ export type { LoginPageProps } from '../components/pages/LoginPage';
22
+ export type { SignupPageProps } from '../components/pages/SignupPage';
23
+ export type { ForgotPasswordPageProps } from '../components/pages/ForgotPasswordPage';
24
+ export type { VerifyOtpPageProps } from '../components/pages/VerifyOtpPage';
25
+ export type { SetPasswordPageProps } from '../components/pages/SetPasswordPage';
26
+ export type { AuthLayoutConfig, AuthLayoutProps } from '../components/AuthLayout';
27
+ export type { PoweredByProps } from '../components/PoweredBy';
@@ -2,6 +2,8 @@
2
2
  // ============================================================
3
3
  // Client-side exports for @main12/auth-login/client
4
4
  // ============================================================
5
+ // Plugin client config initializer
6
+ export { initClientConfig } from '../config.js';
5
7
  // Auth hooks
6
8
  export { useLoginFlow } from '../auth/application/hooks/useLoginFlow.js';
7
9
  export { useVerifyOtpFlow } from '../auth/application/hooks/useVerifyOtpFlow.js';
@@ -17,6 +19,8 @@ export { default as SignupPage } from '../components/pages/SignupPage.js';
17
19
  export { default as ForgotPasswordPage } from '../components/pages/ForgotPasswordPage.js';
18
20
  export { default as VerifyOtpPage } from '../components/pages/VerifyOtpPage.js';
19
21
  export { default as SetPasswordPage } from '../components/pages/SetPasswordPage.js';
22
+ // Catch-all auth pages (single-file setup)
23
+ export { default as AuthPages } from '../components/AuthPages.js';
20
24
  // Layout & shared components
21
25
  export { AuthLayout } from '../components/AuthLayout.js';
22
26
  export { PoweredBy } from '../components/PoweredBy.js';
@@ -1,6 +1,6 @@
1
- export { wrapInBaseTemplate, DEFAULT_COLORS, SOCIAL_ICONS, getBaseUrl, getSenderEmail, getEmailTranslations, generateOtpEmail, generateWelcomeEmail, generatePasswordResetEmail, generatePasswordChangedEmail, } from '../components/email/index.js';
2
- export type { BaseTemplateOptions, } from '../components/email/baseTemplate.js';
3
- export type { EmailColors, SocialLink, SocialPlatform, } from '../components/email/constants.js';
4
- export type { SupportedLanguage, EmailTranslations, } from '../components/email/translations.js';
5
- export type { OtpEmailParams, OtpEmailResult, WelcomeEmailParams, WelcomeEmailResult, PasswordResetEmailParams, PasswordResetEmailResult, PasswordChangedEmailParams, PasswordChangedEmailResult, } from '../components/email/index.js';
6
- export type { AuthLoginPluginOptions } from '../index.js';
1
+ export { wrapInBaseTemplate, DEFAULT_COLORS, SOCIAL_ICONS, getBaseUrl, getSenderEmail, getEmailTranslations, generateOtpEmail, generateWelcomeEmail, generatePasswordResetEmail, generatePasswordChangedEmail, } from '../components/email/index';
2
+ export type { BaseTemplateOptions, } from '../components/email/baseTemplate';
3
+ export type { EmailColors, SocialLink, SocialPlatform, } from '../components/email/constants';
4
+ export type { SupportedLanguage, EmailTranslations, } from '../components/email/translations';
5
+ export type { OtpEmailParams, OtpEmailResult, WelcomeEmailParams, WelcomeEmailResult, PasswordResetEmailParams, PasswordResetEmailResult, PasswordChangedEmailParams, PasswordChangedEmailResult, } from '../components/email/index';
6
+ export type { AuthLoginPluginOptions } from '../index';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Config } from 'payload';
2
- import { pluginConfig, type AuthStyle } from './config.js';
2
+ import { pluginConfig, type AuthStyle } from './config';
3
3
  export interface GoogleOAuthConfig {
4
4
  /** Client ID from Google Cloud Console */
5
5
  clientId?: string;
@@ -17,7 +17,7 @@ export interface AuthLoginPluginOptions {
17
17
  contactEmail?: string;
18
18
  domain?: string;
19
19
  style?: AuthStyle;
20
- logo?: string;
20
+ logo?: string | React.ComponentType;
21
21
  /**
22
22
  * OAuth providers configuration.
23
23
  * - Omit entirely → auto-detect from env vars (GOOGLE_CLIENT_ID, etc.)
@@ -27,6 +27,19 @@ export interface AuthLoginPluginOptions {
27
27
  * - `{ google: { enabled: false } }` → temporarily disable without losing config
28
28
  */
29
29
  providers?: AuthProvidersConfig;
30
+ /**
31
+ * Enable automatic route redirects from bare paths (e.g. /login)
32
+ * to the catch-all auth path (e.g. /auth/login).
33
+ *
34
+ * - `true` → enable redirects (consumer must re-export proxy from their proxy.ts)
35
+ * - `false` → disable redirects (consumer manages their own routes)
36
+ * - `{ basePath: '/auth' }` → enable with custom base path
37
+ *
38
+ * @default false
39
+ */
40
+ routeRedirects?: boolean | {
41
+ basePath?: string;
42
+ };
30
43
  }
31
44
  export declare const authLoginPlugin: (options?: AuthLoginPluginOptions) => (config: Config) => Config;
32
45
  export { pluginConfig };
package/dist/index.js CHANGED
@@ -45,8 +45,19 @@ export const authLoginPlugin = (options = {})=>(config)=>{
45
45
  setOAuthEnv(googleConfig);
46
46
  // Set global config — all components read this at render time
47
47
  pluginConfig.style = options.style || 'tailwind';
48
- pluginConfig.logoUrl = options.logo;
48
+ if (typeof options.logo === 'string') {
49
+ pluginConfig.logoUrl = options.logo;
50
+ } else {
51
+ pluginConfig.Logo = options.logo;
52
+ }
49
53
  pluginConfig.googleOAuthEnabled = googleConfig.enabled;
54
+ // Route redirects config
55
+ if (options.routeRedirects) {
56
+ pluginConfig.routeRedirects = true;
57
+ if (typeof options.routeRedirects === 'object' && options.routeRedirects.basePath) {
58
+ pluginConfig.authBasePath = options.routeRedirects.basePath;
59
+ }
60
+ }
50
61
  // Register auth API endpoints
51
62
  config.endpoints = [
52
63
  ...config.endpoints || [],
@@ -0,0 +1,31 @@
1
+ import { NextResponse, type NextRequest } from 'next/server';
2
+ export interface AuthProxyOptions {
3
+ /** Base path where AuthPages catch-all is mounted. Defaults to '/auth' */
4
+ basePath?: string;
5
+ /** Routes to redirect. Defaults to all auth routes. */
6
+ routes?: string[];
7
+ }
8
+ /**
9
+ * Creates a proxy that redirects bare auth routes (e.g. /login)
10
+ * to the catch-all path (e.g. /auth/login).
11
+ *
12
+ * Usage in your app's proxy.ts (Next.js 16+):
13
+ * ```ts
14
+ * // One-liner — just re-export:
15
+ * export { proxy, config } from '@main12/auth-login/proxy'
16
+ * ```
17
+ * Or compose with your own logic:
18
+ * ```ts
19
+ * import { createAuthProxy } from '@main12/auth-login/proxy'
20
+ * const authProxy = createAuthProxy({ basePath: '/auth' })
21
+ * export function proxy(req) { return authProxy(req) }
22
+ * ```
23
+ *
24
+ * The basePath defaults to the value set in the plugin options
25
+ * (`routeRedirects: { basePath: '/auth' }`), or '/auth' if not configured.
26
+ */
27
+ export declare function createAuthProxy({ basePath, routes }?: AuthProxyOptions): (request: NextRequest) => NextResponse<unknown>;
28
+ export declare const proxy: (request: NextRequest) => NextResponse<unknown>;
29
+ export declare const config: {
30
+ matcher: string[];
31
+ };
package/dist/proxy.js ADDED
@@ -0,0 +1,55 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { pluginConfig } from './config.js';
3
+ const AUTH_ROUTES = [
4
+ 'login',
5
+ 'signup',
6
+ 'forgot-password',
7
+ 'verify-otp',
8
+ 'set-password'
9
+ ];
10
+ /**
11
+ * Creates a proxy that redirects bare auth routes (e.g. /login)
12
+ * to the catch-all path (e.g. /auth/login).
13
+ *
14
+ * Usage in your app's proxy.ts (Next.js 16+):
15
+ * ```ts
16
+ * // One-liner — just re-export:
17
+ * export { proxy, config } from '@main12/auth-login/proxy'
18
+ * ```
19
+ * Or compose with your own logic:
20
+ * ```ts
21
+ * import { createAuthProxy } from '@main12/auth-login/proxy'
22
+ * const authProxy = createAuthProxy({ basePath: '/auth' })
23
+ * export function proxy(req) { return authProxy(req) }
24
+ * ```
25
+ *
26
+ * The basePath defaults to the value set in the plugin options
27
+ * (`routeRedirects: { basePath: '/auth' }`), or '/auth' if not configured.
28
+ */ export function createAuthProxy({ basePath, routes = AUTH_ROUTES } = {}) {
29
+ const base = (basePath ?? pluginConfig.authBasePath).replace(/\/$/, '');
30
+ const routeSet = new Set(routes);
31
+ return function proxy(request) {
32
+ // If routeRedirects is disabled in plugin config, pass through
33
+ if (!pluginConfig.routeRedirects && !basePath) {
34
+ return NextResponse.next();
35
+ }
36
+ const { pathname } = request.nextUrl;
37
+ const segment = pathname.replace(/^\//, '').replace(/\/$/, '');
38
+ if (routeSet.has(segment) && !pathname.startsWith(`${base}/`)) {
39
+ const url = request.nextUrl.clone();
40
+ url.pathname = `${base}/${segment}`;
41
+ return NextResponse.redirect(url);
42
+ }
43
+ return NextResponse.next();
44
+ };
45
+ }
46
+ export const proxy = createAuthProxy();
47
+ export const config = {
48
+ matcher: [
49
+ '/login',
50
+ '/signup',
51
+ '/forgot-password',
52
+ '/verify-otp',
53
+ '/set-password'
54
+ ]
55
+ };
package/package.json CHANGED
@@ -1,33 +1,39 @@
1
1
  {
2
2
  "name": "@main12/auth-login",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Reusable Payload CMS auth plugin — login, signup, OTP, forgot password, branded emails, Powered by Main12",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./src/index.ts",
10
- "types": "./src/index.ts",
11
- "default": "./src/index.ts"
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
12
  },
13
13
  "./client": {
14
- "import": "./src/exports/client.ts",
15
- "types": "./src/exports/client.ts",
16
- "default": "./src/exports/client.ts"
14
+ "import": "./dist/exports/client.js",
15
+ "types": "./dist/exports/client.d.ts",
16
+ "default": "./dist/exports/client.js"
17
17
  },
18
18
  "./rsc": {
19
- "import": "./src/exports/rsc.ts",
20
- "types": "./src/exports/rsc.ts",
21
- "default": "./src/exports/rsc.ts"
19
+ "import": "./dist/exports/rsc.js",
20
+ "types": "./dist/exports/rsc.d.ts",
21
+ "default": "./dist/exports/rsc.js"
22
+ },
23
+ "./proxy": {
24
+ "import": "./dist/proxy.js",
25
+ "types": "./dist/proxy.d.ts",
26
+ "default": "./dist/proxy.js"
22
27
  }
23
28
  },
24
- "main": "./src/index.ts",
25
- "types": "./src/index.ts",
29
+ "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
26
31
  "files": [
27
32
  "dist"
28
33
  ],
29
34
  "scripts": {
30
- "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
35
+ "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc && pnpm build:fix-esm-imports",
36
+ "build:fix-esm-imports": "node ./scripts/fix-esm-imports.mjs",
31
37
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
32
38
  "build:types": "tsc --outDir dist",
33
39
  "clean": "rimraf {dist,*.tsbuildinfo}",
@@ -42,8 +48,10 @@
42
48
  },
43
49
  "devDependencies": {
44
50
  "@eslint/eslintrc": "^3.2.0",
45
- "@heroui/react": "^2.8.10",
51
+ "@heroui/react": "^3.2.2",
52
+ "@heroui/styles": "^3.2.2",
46
53
  "@iconify/react": "^6.0.2",
54
+ "@main12/auth-login": "link:.",
47
55
  "@payloadcms/db-sqlite": "3.82.1",
48
56
  "@payloadcms/next": "3.82.1",
49
57
  "@payloadcms/richtext-lexical": "3.82.1",
@@ -64,6 +72,7 @@
64
72
  "rimraf": "3.0.2",
65
73
  "sharp": "0.34.2",
66
74
  "tailwindcss": "^4.3.3",
75
+ "tw-animate-css": "^1.4.0",
67
76
  "typescript": "6.0.3",
68
77
  "vitest": "4.1.6"
69
78
  },