@main12/auth-login 0.3.3 → 0.3.6

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.
@@ -18,17 +18,17 @@ function DefaultLogo() {
18
18
  });
19
19
  return null;
20
20
  }
21
- export const AuthLayout = ({ children, logo, title, subtitle, footer, poweredBy, cardClassName = '', backgroundClass = 'bg-white md:bg-[#191919]' })=>{
21
+ export const AuthLayout = ({ children, logo, title, subtitle, footer, poweredBy, cardClassName = '', backgroundClass = 'bg-accent' })=>{
22
22
  const displayLogo = logo || /*#__PURE__*/ _jsx(DefaultLogo, {});
23
23
  const header = (displayLogo || title) && /*#__PURE__*/ _jsxs("div", {
24
- className: "flex flex-col items-center gap-2 pt-6 pb-2 px-6",
24
+ className: "flex flex-col items-center gap-2 pt-8 pb-4 px-8",
25
25
  children: [
26
26
  displayLogo && /*#__PURE__*/ _jsx("div", {
27
- className: "flex justify-center mb-2",
27
+ className: "flex justify-center mb-3",
28
28
  children: displayLogo
29
29
  }),
30
30
  title && /*#__PURE__*/ _jsx("h1", {
31
- className: "text-xl font-semibold text-gray-900 text-center",
31
+ className: "text-2xl font-bold text-gray-900 text-center tracking-tight",
32
32
  children: title
33
33
  }),
34
34
  subtitle && /*#__PURE__*/ _jsx("p", {
@@ -41,19 +41,19 @@ export const AuthLayout = ({ children, logo, title, subtitle, footer, poweredBy,
41
41
  className: `flex flex-col min-h-screen ${backgroundClass}`,
42
42
  children: [
43
43
  /*#__PURE__*/ _jsxs("div", {
44
- className: "md:hidden flex flex-col w-full max-w-md mx-auto light [color-scheme:light]",
44
+ className: "md:hidden flex flex-col w-full max-w-md mx-auto light [color-scheme:light] px-4 py-8",
45
45
  "data-theme": "light",
46
46
  style: {
47
- maxWidth: '400px'
47
+ maxWidth: '448px'
48
48
  },
49
49
  children: [
50
50
  header,
51
51
  /*#__PURE__*/ _jsx("div", {
52
- className: "px-6 pb-4",
52
+ className: "px-8 pb-6",
53
53
  children: children
54
54
  }),
55
55
  footer && /*#__PURE__*/ _jsx("div", {
56
- className: "px-6 pb-6 flex justify-center",
56
+ className: "px-8 pb-8 flex justify-center",
57
57
  children: footer
58
58
  }),
59
59
  /*#__PURE__*/ _jsx(PoweredBy, {
@@ -64,9 +64,9 @@ export const AuthLayout = ({ children, logo, title, subtitle, footer, poweredBy,
64
64
  /*#__PURE__*/ _jsx("div", {
65
65
  className: "hidden md:flex min-h-screen items-center justify-center px-4 py-12",
66
66
  children: /*#__PURE__*/ _jsxs("div", {
67
- className: "w-full max-w-md max-w-[400px] animate-[fadeIn_0.5s_ease-out]",
67
+ className: "w-full max-w-md animate-[fadeIn_0.5s_ease-out]",
68
68
  style: {
69
- maxWidth: '400px'
69
+ maxWidth: '448px'
70
70
  },
71
71
  children: [
72
72
  /*#__PURE__*/ _jsxs(Card, {
@@ -2,8 +2,10 @@ import type { AuthPagesProps } from './AuthPages';
2
2
  export type { AuthPagesProps };
3
3
  /**
4
4
  * Server component wrapper for AuthPages.
5
- * Reads plugin config via env vars (set by the plugin at init time)
6
- * and passes it to the client component automatically.
5
+ * Reads plugin config directly from the shared `pluginConfig` singleton
6
+ * (set by the plugin factory at Payload config build time) and passes it
7
+ * down to the client component. No env vars involved — the plugin's
8
+ * `style`, `googleOAuthEnabled`, etc. options are the single source of truth.
7
9
  *
8
10
  * ```tsx
9
11
  * // app/(auth)/auth/[...slug]/page.tsx (NO 'use client' needed!)
@@ -1,9 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import AuthPagesClient from './AuthPages.js';
3
+ import { pluginConfig } from '../config.js';
3
4
  /**
4
5
  * Server component wrapper for AuthPages.
5
- * Reads plugin config via env vars (set by the plugin at init time)
6
- * and passes it to the client component automatically.
6
+ * Reads plugin config directly from the shared `pluginConfig` singleton
7
+ * (set by the plugin factory at Payload config build time) and passes it
8
+ * down to the client component. No env vars involved — the plugin's
9
+ * `style`, `googleOAuthEnabled`, etc. options are the single source of truth.
7
10
  *
8
11
  * ```tsx
9
12
  * // app/(auth)/auth/[...slug]/page.tsx (NO 'use client' needed!)
@@ -14,17 +17,12 @@ import AuthPagesClient from './AuthPages.js';
14
17
  * }
15
18
  * ```
16
19
  */ export default function AuthPages(props) {
17
- const googleOAuthEnabled = process.env.AUTH_PLUGIN_GOOGLE_OAUTH === 'true';
18
- const style = process.env.AUTH_PLUGIN_STYLE || 'tailwind';
19
- const allowSignup = process.env.AUTH_PLUGIN_ALLOW_SIGNUP !== 'false';
20
- const passwordLogin = process.env.AUTH_PLUGIN_PASSWORD_LOGIN !== 'false';
21
- const otpLogin = process.env.AUTH_PLUGIN_OTP_LOGIN !== 'false';
22
20
  return /*#__PURE__*/ _jsx(AuthPagesClient, {
23
21
  ...props,
24
- showGoogleOAuth: props.showGoogleOAuth ?? googleOAuthEnabled,
25
- style: props.style ?? style,
26
- allowSignup: props.allowSignup ?? allowSignup,
27
- passwordLogin: passwordLogin,
28
- otpLogin: otpLogin
22
+ showGoogleOAuth: props.showGoogleOAuth ?? pluginConfig.googleOAuthEnabled,
23
+ style: props.style ?? pluginConfig.style,
24
+ allowSignup: props.allowSignup ?? pluginConfig.allowSignup,
25
+ passwordLogin: pluginConfig.passwordLogin,
26
+ otpLogin: pluginConfig.otpLogin
29
27
  });
30
28
  }
@@ -61,6 +61,7 @@ function LoginHeroContent({ onPasswordLogin, redirectTo = '/', showGoogleOAuth =
61
61
  fullWidth: true,
62
62
  variant: "secondary",
63
63
  onPress: handleGoogleLogin,
64
+ className: "[--button-fg:var(--foreground)]",
64
65
  children: [
65
66
  /*#__PURE__*/ _jsx(Icon, {
66
67
  icon: "flat-color-icons:google",
@@ -49,8 +49,9 @@ export default function SignupPageHero({ onSignup, showGoogleOAuth = true, login
49
49
  children: [
50
50
  /*#__PURE__*/ _jsxs(Button, {
51
51
  fullWidth: true,
52
+ variant: "secondary",
52
53
  size: "lg",
53
- className: "mb-4 h-12 rounded-full",
54
+ className: "mb-4 h-12 rounded-full [--button-fg:var(--foreground)]",
54
55
  children: [
55
56
  /*#__PURE__*/ _jsx(Icon, {
56
57
  icon: "flat-color-icons:google",
@@ -54,20 +54,20 @@ export const Card = ({ children, className = '' })=>/*#__PURE__*/ _jsx("div", {
54
54
  className: `bg-white text-gray-900 rounded-2xl shadow-2xl w-full light [color-scheme:light] ${className}`,
55
55
  "data-theme": "light",
56
56
  style: {
57
- maxWidth: '400px'
57
+ maxWidth: '448px'
58
58
  },
59
59
  children: children
60
60
  });
61
61
  export const CardHeader = ({ children, className = '' })=>/*#__PURE__*/ _jsx("div", {
62
- className: `flex flex-col items-center gap-2 pt-8 pb-2 px-6 ${className}`,
62
+ className: `flex flex-col items-center gap-2 pt-8 pb-4 px-8 ${className}`,
63
63
  children: children
64
64
  });
65
65
  export const CardContent = ({ children, className = '' })=>/*#__PURE__*/ _jsx("div", {
66
- className: `px-6 pb-4 ${className}`,
66
+ className: `px-8 pb-6 ${className}`,
67
67
  children: children
68
68
  });
69
69
  export const CardFooter = ({ children, className = '' })=>/*#__PURE__*/ _jsx("div", {
70
- className: `px-6 pb-6 flex justify-center ${className}`,
70
+ className: `px-8 pb-8 flex justify-center ${className}`,
71
71
  children: children
72
72
  });
73
73
  export const CardTitle = ({ children, className = '' })=>/*#__PURE__*/ _jsx("h1", {
package/dist/config.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare const pluginConfig: {
13
13
  authBasePath: string;
14
14
  passwordLogin: boolean;
15
15
  otpLogin: boolean;
16
+ allowSignup: boolean;
16
17
  };
17
18
  /** Call this client-side to mirror the server plugin config. */
18
19
  export declare function initClientConfig(opts: {
package/dist/config.js CHANGED
@@ -4,7 +4,8 @@ export const pluginConfig = {
4
4
  routeRedirects: false,
5
5
  authBasePath: '/auth',
6
6
  passwordLogin: true,
7
- otpLogin: true
7
+ otpLogin: true,
8
+ allowSignup: true
8
9
  };
9
10
  /** Call this client-side to mirror the server plugin config. */ export function initClientConfig(opts) {
10
11
  if (opts.style) pluginConfig.style = opts.style;
@@ -1,6 +1,7 @@
1
1
  import crypto from 'crypto';
2
2
  import { generateOtp, hashOtp, verifyOtp, getOtpExpiry, isOtpExpired } from '../auth/domain/otp.js';
3
3
  import { generateWelcomeEmail, generateOtpEmail } from '../components/email/index.js';
4
+ import { pluginConfig } from '../config.js';
4
5
  /**
5
6
  * POST /api/auth/check-email — Check if user exists and has password
6
7
  */ export const checkEmailEndpoint = {
@@ -352,7 +353,7 @@ import { generateWelcomeEmail, generateOtpEmail } from '../components/email/inde
352
353
  path: '/auth/signup',
353
354
  method: 'post',
354
355
  handler: async (req)=>{
355
- if (process.env.AUTH_PLUGIN_ALLOW_SIGNUP === 'false') {
356
+ if (!pluginConfig.allowSignup) {
356
357
  return Response.json({
357
358
  success: false,
358
359
  message: 'Signups are currently disabled'
package/dist/index.js CHANGED
@@ -53,7 +53,9 @@ export const authLoginPlugin = (options = {})=>async (config)=>{
53
53
  // Resolve provider config
54
54
  const googleConfig = resolveGoogleConfig(options.providers);
55
55
  setOAuthEnv(googleConfig);
56
- // Set global config — all components read this at render time
56
+ // Set global config — all components (server and client) read this
57
+ // shared singleton directly at render time. This is the single source
58
+ // of truth; no env vars are used to propagate these settings.
57
59
  pluginConfig.style = options.style || 'tailwind';
58
60
  if (typeof options.logo === 'string') {
59
61
  pluginConfig.logoUrl = options.logo;
@@ -61,15 +63,9 @@ export const authLoginPlugin = (options = {})=>async (config)=>{
61
63
  pluginConfig.Logo = options.logo;
62
64
  }
63
65
  pluginConfig.googleOAuthEnabled = googleConfig.enabled;
64
- // Set env vars so RSC components can read config across module boundaries
65
- process.env.AUTH_PLUGIN_STYLE = pluginConfig.style;
66
- process.env.AUTH_PLUGIN_GOOGLE_OAUTH = String(pluginConfig.googleOAuthEnabled);
67
- process.env.AUTH_PLUGIN_ALLOW_SIGNUP = String(options.allowSignup !== false);
68
- process.env.AUTH_PLUGIN_PASSWORD_LOGIN = String(options.passwordLogin !== false);
69
- process.env.AUTH_PLUGIN_OTP_LOGIN = String(options.otpLogin !== false);
66
+ pluginConfig.allowSignup = options.allowSignup !== false;
70
67
  pluginConfig.passwordLogin = options.passwordLogin !== false;
71
68
  pluginConfig.otpLogin = options.otpLogin !== false;
72
- process.env.AUTH_PLUGIN_ROUTE_REDIRECTS = String(pluginConfig.routeRedirects);
73
69
  // Route redirects config
74
70
  if (options.routeRedirects) {
75
71
  pluginConfig.routeRedirects = true;
package/dist/proxy.js CHANGED
@@ -29,8 +29,8 @@ const AUTH_ROUTES = [
29
29
  const base = (basePath ?? pluginConfig.authBasePath).replace(/\/$/, '');
30
30
  const routeSet = new Set(routes);
31
31
  return function proxy(request) {
32
- // Check route redirects — use env var (set by plugin) as it survives module boundaries
33
- const redirectsEnabled = pluginConfig.routeRedirects || process.env.AUTH_PLUGIN_ROUTE_REDIRECTS === 'true';
32
+ // Check route redirects directly from the shared plugin config singleton
33
+ const redirectsEnabled = pluginConfig.routeRedirects;
34
34
  if (!redirectsEnabled && !basePath) {
35
35
  return NextResponse.next();
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@main12/auth-login",
3
- "version": "0.3.3",
3
+ "version": "0.3.6",
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",
@@ -19,6 +19,11 @@
19
19
  "import": "./dist/exports/rsc.js",
20
20
  "types": "./dist/exports/rsc.d.ts",
21
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
29
  "main": "./dist/index.js",
@@ -26,6 +31,21 @@
26
31
  "files": [
27
32
  "dist"
28
33
  ],
34
+ "scripts": {
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",
37
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
38
+ "build:types": "tsc --outDir dist",
39
+ "clean": "rimraf {dist,*.tsbuildinfo}",
40
+ "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
41
+ "dev": "next dev dev --turbo",
42
+ "dev:generate-importmap": "pnpm dev:payload generate:importmap",
43
+ "dev:generate-types": "pnpm dev:payload generate:types",
44
+ "dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
45
+ "lint": "eslint",
46
+ "lint:fix": "eslint ./src --fix",
47
+ "test": "vitest"
48
+ },
29
49
  "devDependencies": {
30
50
  "@eslint/eslintrc": "^3.2.0",
31
51
  "@heroui/react": "^3.2.2",
@@ -57,7 +77,10 @@
57
77
  "vitest": "4.1.6"
58
78
  },
59
79
  "peerDependencies": {
80
+ "@heroui/react": ">=3.2.0",
81
+ "framer-motion": ">=12.0.0",
60
82
  "next": "^16.0.0",
83
+ "next-intl": "*",
61
84
  "payload": "^3.82.0",
62
85
  "react": "^19.0.0"
63
86
  },
@@ -75,26 +98,39 @@
75
98
  "engines": {
76
99
  "node": ">=18.20.2"
77
100
  },
101
+ "publishConfig": {
102
+ "exports": {
103
+ ".": {
104
+ "import": "./dist/index.js",
105
+ "types": "./dist/index.d.ts",
106
+ "default": "./dist/index.js"
107
+ },
108
+ "./client": {
109
+ "import": "./dist/exports/client.js",
110
+ "types": "./dist/exports/client.d.ts",
111
+ "default": "./dist/exports/client.js"
112
+ },
113
+ "./rsc": {
114
+ "import": "./dist/exports/rsc.js",
115
+ "types": "./dist/exports/rsc.d.ts",
116
+ "default": "./dist/exports/rsc.js"
117
+ }
118
+ },
119
+ "main": "./dist/index.js",
120
+ "types": "./dist/index.d.ts"
121
+ },
122
+ "pnpm": {
123
+ "onlyBuiltDependencies": [
124
+ "@swc/core",
125
+ "sharp",
126
+ "esbuild"
127
+ ]
128
+ },
78
129
  "registry": "https://registry.npmjs.org/",
79
130
  "dependencies": {
80
131
  "@main12/brevo-adapter": "^0.1.1",
81
132
  "axios": "^1.20.0",
82
133
  "jose": "^6.2.12",
83
134
  "payload-oauth2": "^1.0.21"
84
- },
85
- "scripts": {
86
- "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc && pnpm build:fix-esm-imports",
87
- "build:fix-esm-imports": "node ./scripts/fix-esm-imports.mjs",
88
- "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
89
- "build:types": "tsc --outDir dist",
90
- "clean": "rimraf {dist,*.tsbuildinfo}",
91
- "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
92
- "dev": "next dev dev --turbo",
93
- "dev:generate-importmap": "pnpm dev:payload generate:importmap",
94
- "dev:generate-types": "pnpm dev:payload generate:types",
95
- "dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
96
- "lint": "eslint",
97
- "lint:fix": "eslint ./src --fix",
98
- "test": "vitest"
99
135
  }
100
- }
136
+ }