@greatapps/greatauth-ui 0.1.2 → 0.1.5

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.d.ts CHANGED
@@ -3,12 +3,13 @@ import { ReactNode, ComponentType } from 'react';
3
3
  import * as nanostores from 'nanostores';
4
4
  import * as _better_fetch_fetch from '@better-fetch/fetch';
5
5
  import * as better_auth from 'better-auth';
6
- import { NextRequest, NextResponse } from 'next/server';
6
+ export { AuthMiddlewareConfig, authMiddlewareConfig, createAuthMiddleware } from './middleware.js';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
8
  import * as class_variance_authority_types from 'class-variance-authority/types';
9
9
  import { VariantProps } from 'class-variance-authority';
10
10
  import { Tooltip } from 'radix-ui';
11
11
  import { ClassValue } from 'clsx';
12
+ import 'next/server';
12
13
 
13
14
  interface AppShellConfig {
14
15
  appName: string;
@@ -1042,15 +1043,6 @@ declare const signOut: <FetchOptions extends better_auth.ClientFetchOption<never
1042
1043
  message?: string | undefined;
1043
1044
  }, FetchOptions["throw"] extends true ? true : false>>;
1044
1045
 
1045
- interface AuthMiddlewareConfig {
1046
- publicPaths: string[];
1047
- preserveSearchParams?: boolean;
1048
- }
1049
- declare function createAuthMiddleware(config: AuthMiddlewareConfig): (request: NextRequest) => NextResponse<unknown>;
1050
- declare const authMiddlewareConfig: {
1051
- matcher: string[];
1052
- };
1053
-
1054
1046
  interface JwtClaimsConfig {
1055
1047
  [jwtClaimName: string]: string;
1056
1048
  }
@@ -1115,4 +1107,4 @@ declare function SidebarInset({ className, ...props }: React.ComponentProps<"mai
1115
1107
 
1116
1108
  declare function cn(...inputs: ClassValue[]): string;
1117
1109
 
1118
- export { AppHeader, AppShell, type AppShellConfig, AppSidebar, type AuthMiddlewareConfig, type HeaderConfig, LoginForm, type LoginFormConfig, type MenuGroup, type MenuItem, SidebarInset, SidebarProvider, SidebarTrigger, ThemeToggle, TooltipProvider, authClient, authMiddlewareConfig, cn, createAuthMiddleware, createUseAuth, signIn, signOut, signUp, useSession, useSidebar };
1110
+ export { AppHeader, AppShell, type AppShellConfig, AppSidebar, type HeaderConfig, LoginForm, type LoginFormConfig, type MenuGroup, type MenuItem, SidebarInset, SidebarProvider, SidebarTrigger, ThemeToggle, TooltipProvider, authClient, cn, createUseAuth, signIn, signOut, signUp, useSession, useSidebar };
@@ -0,0 +1,12 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+
3
+ interface AuthMiddlewareConfig {
4
+ publicPaths: string[];
5
+ preserveSearchParams?: boolean;
6
+ }
7
+ declare function createAuthMiddleware(config: AuthMiddlewareConfig): (request: NextRequest) => NextResponse<unknown>;
8
+ declare const authMiddlewareConfig: {
9
+ matcher: string[];
10
+ };
11
+
12
+ export { type AuthMiddlewareConfig, authMiddlewareConfig, createAuthMiddleware };
@@ -0,0 +1,27 @@
1
+ // src/auth/middleware.ts
2
+ import { NextResponse } from "next/server";
3
+ function createAuthMiddleware(config) {
4
+ const { publicPaths, preserveSearchParams = false } = config;
5
+ return function middleware(request) {
6
+ const { pathname, search } = request.nextUrl;
7
+ if (publicPaths.some((path) => pathname.startsWith(path))) {
8
+ return NextResponse.next();
9
+ }
10
+ const sessionToken = request.cookies.get("better-auth.session_token")?.value || request.cookies.get("__Secure-better-auth.session_token")?.value;
11
+ if (!sessionToken) {
12
+ const callbackUrl = preserveSearchParams ? pathname + search : pathname;
13
+ const loginUrl = new URL("/login", request.url);
14
+ loginUrl.searchParams.set("callbackUrl", callbackUrl);
15
+ return NextResponse.redirect(loginUrl);
16
+ }
17
+ return NextResponse.next();
18
+ };
19
+ }
20
+ var authMiddlewareConfig = {
21
+ matcher: ["/((?!_next/static|_next/image|favicon.ico|api/auth).*)"]
22
+ };
23
+ export {
24
+ authMiddlewareConfig,
25
+ createAuthMiddleware
26
+ };
27
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/auth/middleware.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from \"next/server\";\n\nexport interface AuthMiddlewareConfig {\n publicPaths: string[];\n preserveSearchParams?: boolean;\n}\n\nexport function createAuthMiddleware(config: AuthMiddlewareConfig) {\n const { publicPaths, preserveSearchParams = false } = config;\n\n return function middleware(request: NextRequest) {\n const { pathname, search } = request.nextUrl;\n\n if (publicPaths.some((path) => pathname.startsWith(path))) {\n return NextResponse.next();\n }\n\n const sessionToken =\n request.cookies.get(\"better-auth.session_token\")?.value ||\n request.cookies.get(\"__Secure-better-auth.session_token\")?.value;\n\n if (!sessionToken) {\n const callbackUrl = preserveSearchParams\n ? pathname + search\n : pathname;\n\n const loginUrl = new URL(\"/login\", request.url);\n loginUrl.searchParams.set(\"callbackUrl\", callbackUrl);\n return NextResponse.redirect(loginUrl);\n }\n\n return NextResponse.next();\n };\n}\n\nexport const authMiddlewareConfig = {\n matcher: [\"/((?!_next/static|_next/image|favicon.ico|api/auth).*)\"],\n};\n"],"mappings":";AAAA,SAAS,oBAAsC;AAOxC,SAAS,qBAAqB,QAA8B;AACjE,QAAM,EAAE,aAAa,uBAAuB,MAAM,IAAI;AAEtD,SAAO,SAAS,WAAW,SAAsB;AAC/C,UAAM,EAAE,UAAU,OAAO,IAAI,QAAQ;AAErC,QAAI,YAAY,KAAK,CAAC,SAAS,SAAS,WAAW,IAAI,CAAC,GAAG;AACzD,aAAO,aAAa,KAAK;AAAA,IAC3B;AAEA,UAAM,eACJ,QAAQ,QAAQ,IAAI,2BAA2B,GAAG,SAClD,QAAQ,QAAQ,IAAI,oCAAoC,GAAG;AAE7D,QAAI,CAAC,cAAc;AACjB,YAAM,cAAc,uBAChB,WAAW,SACX;AAEJ,YAAM,WAAW,IAAI,IAAI,UAAU,QAAQ,GAAG;AAC9C,eAAS,aAAa,IAAI,eAAe,WAAW;AACpD,aAAO,aAAa,SAAS,QAAQ;AAAA,IACvC;AAEA,WAAO,aAAa,KAAK;AAAA,EAC3B;AACF;AAEO,IAAM,uBAAuB;AAAA,EAClC,SAAS,CAAC,wDAAwD;AACpE;","names":[]}
package/package.json CHANGED
@@ -1,16 +1,26 @@
1
1
  {
2
2
  "name": "@greatapps/greatauth-ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js"
11
- }
10
+ "import": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./middleware": {
14
+ "types": "./dist/middleware.d.ts",
15
+ "import": "./dist/middleware.js",
16
+ "default": "./dist/middleware.js"
17
+ },
18
+ "./theme.css": "./src/theme.css"
12
19
  },
13
- "files": ["dist", "src"],
20
+ "files": [
21
+ "dist",
22
+ "src"
23
+ ],
14
24
  "scripts": {
15
25
  "build": "tsup",
16
26
  "dev": "tsup --watch"
@@ -0,0 +1,2 @@
1
+ export { createAuthMiddleware, authMiddlewareConfig } from "./auth/middleware";
2
+ export type { AuthMiddlewareConfig } from "./auth/middleware";
package/src/theme.css ADDED
@@ -0,0 +1,131 @@
1
+ /*
2
+ * @greatapps/greatauth-ui — Shared Design Tokens
3
+ *
4
+ * Import this file in your app's globals.css:
5
+ * @import "@greatapps/greatauth-ui/theme.css";
6
+ *
7
+ * Font: Apps must load Inter via next/font and set --font-sans CSS variable.
8
+ */
9
+
10
+ @custom-variant dark (&:is(.dark *));
11
+
12
+ @theme inline {
13
+ --color-background: var(--background);
14
+ --color-foreground: var(--foreground);
15
+ --font-sans: var(--font-sans);
16
+ --font-mono: var(--font-mono);
17
+ --color-sidebar-ring: var(--sidebar-ring);
18
+ --color-sidebar-border: var(--sidebar-border);
19
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
20
+ --color-sidebar-accent: var(--sidebar-accent);
21
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
22
+ --color-sidebar-primary: var(--sidebar-primary);
23
+ --color-sidebar-foreground: var(--sidebar-foreground);
24
+ --color-sidebar: var(--sidebar);
25
+ --color-chart-5: var(--chart-5);
26
+ --color-chart-4: var(--chart-4);
27
+ --color-chart-3: var(--chart-3);
28
+ --color-chart-2: var(--chart-2);
29
+ --color-chart-1: var(--chart-1);
30
+ --color-ring: var(--ring);
31
+ --color-input: var(--input);
32
+ --color-border: var(--border);
33
+ --color-destructive: var(--destructive);
34
+ --color-accent-foreground: var(--accent-foreground);
35
+ --color-accent: var(--accent);
36
+ --color-muted-foreground: var(--muted-foreground);
37
+ --color-muted: var(--muted);
38
+ --color-secondary-foreground: var(--secondary-foreground);
39
+ --color-secondary: var(--secondary);
40
+ --color-primary-foreground: var(--primary-foreground);
41
+ --color-primary: var(--primary);
42
+ --color-popover-foreground: var(--popover-foreground);
43
+ --color-popover: var(--popover);
44
+ --color-card-foreground: var(--card-foreground);
45
+ --color-card: var(--card);
46
+ --radius-sm: calc(var(--radius) - 4px);
47
+ --radius-md: calc(var(--radius) - 2px);
48
+ --radius-lg: var(--radius);
49
+ --radius-xl: calc(var(--radius) + 4px);
50
+ --radius-2xl: calc(var(--radius) + 8px);
51
+ --radius-3xl: calc(var(--radius) + 12px);
52
+ --radius-4xl: calc(var(--radius) + 16px);
53
+ }
54
+
55
+ :root {
56
+ --background: oklch(1 0 0);
57
+ --foreground: oklch(0.141 0.005 285.823);
58
+ --card: oklch(1 0 0);
59
+ --card-foreground: oklch(0.141 0.005 285.823);
60
+ --popover: oklch(1 0 0);
61
+ --popover-foreground: oklch(0.141 0.005 285.823);
62
+ --primary: oklch(0.21 0.006 285.885);
63
+ --primary-foreground: oklch(0.985 0 0);
64
+ --secondary: oklch(0.967 0.001 286.375);
65
+ --secondary-foreground: oklch(0.21 0.006 285.885);
66
+ --muted: oklch(0.967 0.001 286.375);
67
+ --muted-foreground: oklch(0.552 0.016 285.938);
68
+ --accent: oklch(0.967 0.001 286.375);
69
+ --accent-foreground: oklch(0.21 0.006 285.885);
70
+ --destructive: oklch(0.577 0.245 27.325);
71
+ --border: oklch(0.92 0.004 286.32);
72
+ --input: oklch(0.92 0.004 286.32);
73
+ --ring: oklch(0.705 0.015 286.067);
74
+ --chart-1: oklch(0.646 0.222 41.116);
75
+ --chart-2: oklch(0.6 0.118 184.704);
76
+ --chart-3: oklch(0.398 0.07 227.392);
77
+ --chart-4: oklch(0.828 0.189 84.429);
78
+ --chart-5: oklch(0.769 0.188 70.08);
79
+ --radius: 0.625rem;
80
+ --sidebar: oklch(0.985 0 0);
81
+ --sidebar-foreground: oklch(0.141 0.005 285.823);
82
+ --sidebar-primary: oklch(0.21 0.006 285.885);
83
+ --sidebar-primary-foreground: oklch(0.985 0 0);
84
+ --sidebar-accent: oklch(0.967 0.001 286.375);
85
+ --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
86
+ --sidebar-border: oklch(0.92 0.004 286.32);
87
+ --sidebar-ring: oklch(0.705 0.015 286.067);
88
+ }
89
+
90
+ .dark {
91
+ --background: oklch(0.141 0.005 285.823);
92
+ --foreground: oklch(0.985 0 0);
93
+ --card: oklch(0.21 0.006 285.885);
94
+ --card-foreground: oklch(0.985 0 0);
95
+ --popover: oklch(0.21 0.006 285.885);
96
+ --popover-foreground: oklch(0.985 0 0);
97
+ --primary: oklch(0.92 0.004 286.32);
98
+ --primary-foreground: oklch(0.21 0.006 285.885);
99
+ --secondary: oklch(0.274 0.006 286.033);
100
+ --secondary-foreground: oklch(0.985 0 0);
101
+ --muted: oklch(0.274 0.006 286.033);
102
+ --muted-foreground: oklch(0.705 0.015 286.067);
103
+ --accent: oklch(0.274 0.006 286.033);
104
+ --accent-foreground: oklch(0.985 0 0);
105
+ --destructive: oklch(0.704 0.191 22.216);
106
+ --border: oklch(1 0 0 / 10%);
107
+ --input: oklch(1 0 0 / 15%);
108
+ --ring: oklch(0.552 0.016 285.938);
109
+ --chart-1: oklch(0.488 0.243 264.376);
110
+ --chart-2: oklch(0.696 0.17 162.48);
111
+ --chart-3: oklch(0.769 0.188 70.08);
112
+ --chart-4: oklch(0.627 0.265 303.9);
113
+ --chart-5: oklch(0.645 0.246 16.439);
114
+ --sidebar: oklch(0.21 0.006 285.885);
115
+ --sidebar-foreground: oklch(0.985 0 0);
116
+ --sidebar-primary: oklch(0.488 0.243 264.376);
117
+ --sidebar-primary-foreground: oklch(0.985 0 0);
118
+ --sidebar-accent: oklch(0.274 0.006 286.033);
119
+ --sidebar-accent-foreground: oklch(0.985 0 0);
120
+ --sidebar-border: oklch(1 0 0 / 10%);
121
+ --sidebar-ring: oklch(0.552 0.016 285.938);
122
+ }
123
+
124
+ @layer base {
125
+ * {
126
+ @apply border-border outline-ring/50;
127
+ }
128
+ body {
129
+ @apply bg-background text-foreground;
130
+ }
131
+ }