@neondatabase/auth 0.1.0-beta.2 → 0.1.0-beta.20
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/README.md +112 -18
- package/dist/{adapter-core-C12KoaiU.d.mts → adapter-core-23fYTUxT.d.mts} +175 -627
- package/dist/{adapter-core-BDOw-gBC.mjs → adapter-core-8s6XdCco.mjs} +392 -69
- package/dist/{better-auth-react-adapter-FnBHa2nr.mjs → better-auth-react-adapter-D9tIaEyQ.mjs} +10 -8
- package/dist/better-auth-react-adapter-QFe5RtaM.d.mts +2170 -0
- package/dist/better-auth-types-BUiggBfa.d.mts +9 -0
- package/dist/chunk-VCZJYX65-CLnrj1o7-D6ZQkcc_.mjs +543 -0
- package/dist/constants-2bpp2_-f.mjs +30 -0
- package/dist/index-Bga0CzOO.d.mts +49 -0
- package/dist/index.d.mts +5 -98
- package/dist/index.mjs +2 -1
- package/dist/middleware-C7jHeulu.mjs +303 -0
- package/dist/{neon-auth-C9XTFffv.mjs → neon-auth-2f58U8_-.mjs} +7 -4
- package/dist/neon-auth-CDYpC_O1.d.mts +107 -0
- package/dist/next/index.d.mts +139 -303
- package/dist/next/index.mjs +37 -174
- package/dist/next/server/index.d.mts +389 -0
- package/dist/next/server/index.mjs +432 -0
- package/dist/react/adapters/index.d.mts +5 -4
- package/dist/react/adapters/index.mjs +2 -1
- package/dist/react/index.d.mts +6 -5
- package/dist/react/index.mjs +5 -92
- package/dist/react/ui/index.d.mts +1 -1
- package/dist/react/ui/index.mjs +3 -91
- package/dist/react/ui/server.mjs +1 -1
- package/dist/{supabase-adapter-ggmqWgPe.mjs → supabase-adapter-BYMJSxOT.mjs} +72 -167
- package/dist/supabase-adapter-Dr-pKvPt.d.mts +2258 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/types/index.mjs +3 -0
- package/dist/ui/.safelist.html +3 -0
- package/dist/ui/css.css +2 -2
- package/dist/ui/tailwind.css +3 -2
- package/dist/ui/theme-inline.css +39 -0
- package/dist/ui/theme.css +125 -49
- package/dist/ui-Cg1EZzGG.mjs +12104 -0
- package/dist/vanilla/adapters/index.d.mts +4 -3
- package/dist/vanilla/adapters/index.mjs +2 -1
- package/dist/vanilla/index.d.mts +4 -3
- package/dist/vanilla/index.mjs +2 -1
- package/llms.txt +172 -0
- package/package.json +21 -10
- package/dist/better-auth-react-adapter-BXL48HIU.d.mts +0 -722
- package/dist/supabase-adapter-crabDnl2.d.mts +0 -128
- package/dist/ui-CNFBSekF.mjs +0 -401
- /package/dist/{adapters-Dkx0zoMR.mjs → adapters-B7YKkjaL.mjs} +0 -0
- /package/dist/{index-C-svZlpj.d.mts → index-BHI9uOzY.d.mts} +0 -0
- /package/dist/{index-DuDD6cIY.d.mts → index-CSe4aQIZ.d.mts} +0 -0
- /package/dist/{index-UW23fDSn.d.mts → index-LhFpnU-f.d.mts} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import
|
|
3
|
-
import "../../
|
|
1
|
+
import "../../better-auth-types-BUiggBfa.mjs";
|
|
2
|
+
import "../../adapter-core-23fYTUxT.mjs";
|
|
3
|
+
import { a as BetterAuthVanillaAdapter, c as BetterAuthVanillaAdapterOptions, i as SupabaseAuthAdapterOptions, n as SupabaseAuthAdapterBuilder, o as BetterAuthVanillaAdapterBuilder, r as SupabaseAuthAdapterInstance, s as BetterAuthVanillaAdapterInstance, t as SupabaseAuthAdapter } from "../../supabase-adapter-Dr-pKvPt.mjs";
|
|
4
|
+
import "../../index-LhFpnU-f.mjs";
|
|
4
5
|
export { BetterAuthVanillaAdapter, BetterAuthVanillaAdapterBuilder, BetterAuthVanillaAdapterInstance, BetterAuthVanillaAdapterOptions, SupabaseAuthAdapter, SupabaseAuthAdapterBuilder, SupabaseAuthAdapterInstance, SupabaseAuthAdapterOptions };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../adapter-core-8s6XdCco.mjs";
|
|
2
|
+
import { n as BetterAuthVanillaAdapter, t as SupabaseAuthAdapter } from "../../supabase-adapter-BYMJSxOT.mjs";
|
|
2
3
|
|
|
3
4
|
export { BetterAuthVanillaAdapter, SupabaseAuthAdapter };
|
package/dist/vanilla/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import
|
|
3
|
-
import "../
|
|
1
|
+
import "../better-auth-types-BUiggBfa.mjs";
|
|
2
|
+
import "../adapter-core-23fYTUxT.mjs";
|
|
3
|
+
import { a as BetterAuthVanillaAdapter, c as BetterAuthVanillaAdapterOptions, i as SupabaseAuthAdapterOptions, n as SupabaseAuthAdapterBuilder, o as BetterAuthVanillaAdapterBuilder, r as SupabaseAuthAdapterInstance, s as BetterAuthVanillaAdapterInstance, t as SupabaseAuthAdapter } from "../supabase-adapter-Dr-pKvPt.mjs";
|
|
4
|
+
import "../index-LhFpnU-f.mjs";
|
|
4
5
|
export { BetterAuthVanillaAdapter, BetterAuthVanillaAdapterBuilder, BetterAuthVanillaAdapterInstance, BetterAuthVanillaAdapterOptions, SupabaseAuthAdapter, SupabaseAuthAdapterBuilder, SupabaseAuthAdapterInstance, SupabaseAuthAdapterOptions };
|
package/dist/vanilla/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../adapter-core-8s6XdCco.mjs";
|
|
2
|
+
import { n as BetterAuthVanillaAdapter, t as SupabaseAuthAdapter } from "../supabase-adapter-BYMJSxOT.mjs";
|
|
2
3
|
|
|
3
4
|
export { BetterAuthVanillaAdapter, SupabaseAuthAdapter };
|
package/llms.txt
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# @neondatabase/auth
|
|
2
|
+
|
|
3
|
+
> TypeScript SDK for Neon Auth - authentication adapters for PostgreSQL with session caching, request deduplication, and optional anonymous access.
|
|
4
|
+
|
|
5
|
+
`@neondatabase/auth` provides authentication for applications using Neon Auth. It uses the Better Auth API by default, with optional adapters for different API styles (Supabase-compatible, React hooks).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @neondatabase/auth
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { createAuthClient } from '@neondatabase/auth';
|
|
17
|
+
|
|
18
|
+
const auth = createAuthClient('https://your-auth-server.com');
|
|
19
|
+
|
|
20
|
+
// Sign up
|
|
21
|
+
await auth.signUp.email({
|
|
22
|
+
email: 'user@example.com',
|
|
23
|
+
password: 'secure-password',
|
|
24
|
+
name: 'John Doe',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Sign in
|
|
28
|
+
await auth.signIn.email({
|
|
29
|
+
email: 'user@example.com',
|
|
30
|
+
password: 'secure-password',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Get session
|
|
34
|
+
const session = await auth.getSession();
|
|
35
|
+
|
|
36
|
+
// Sign out
|
|
37
|
+
await auth.signOut();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## OAuth Authentication
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
await auth.signIn.social({
|
|
44
|
+
provider: 'google',
|
|
45
|
+
callbackURL: '/dashboard',
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Adapters
|
|
50
|
+
|
|
51
|
+
### SupabaseAuthAdapter
|
|
52
|
+
|
|
53
|
+
Supabase-compatible API for migrations:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { createAuthClient, SupabaseAuthAdapter } from '@neondatabase/auth';
|
|
57
|
+
|
|
58
|
+
const auth = createAuthClient('https://your-auth-server.com', {
|
|
59
|
+
adapter: SupabaseAuthAdapter(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
await auth.signUp({
|
|
63
|
+
email: 'user@example.com',
|
|
64
|
+
password: 'secure-password',
|
|
65
|
+
options: { data: { name: 'John Doe' } },
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await auth.signInWithPassword({
|
|
69
|
+
email: 'user@example.com',
|
|
70
|
+
password: 'secure-password',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
await auth.signInWithOAuth({
|
|
74
|
+
provider: 'google',
|
|
75
|
+
options: { redirectTo: '/dashboard' },
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const { data: session } = await auth.getSession();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### BetterAuthReactAdapter
|
|
82
|
+
|
|
83
|
+
React hooks support:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { createAuthClient } from '@neondatabase/auth';
|
|
87
|
+
import { BetterAuthReactAdapter } from '@neondatabase/auth/react/adapters';
|
|
88
|
+
|
|
89
|
+
const auth = createAuthClient('https://your-auth-server.com', {
|
|
90
|
+
adapter: BetterAuthReactAdapter(),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
function MyComponent() {
|
|
94
|
+
const session = auth.useSession();
|
|
95
|
+
|
|
96
|
+
if (session.isPending) return <div>Loading...</div>;
|
|
97
|
+
if (!session.data) return <div>Not logged in</div>;
|
|
98
|
+
|
|
99
|
+
return <div>Hello, {session.data.user.name}</div>;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Anonymous Access
|
|
104
|
+
|
|
105
|
+
Enable RLS-based data access for unauthenticated users:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const auth = createAuthClient('https://your-auth-server.com', {
|
|
109
|
+
allowAnonymous: true,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Returns anonymous token if no user session exists
|
|
113
|
+
const token = await auth.getJWTToken?.();
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## API Reference
|
|
117
|
+
|
|
118
|
+
### createAuthClient(url, config?)
|
|
119
|
+
|
|
120
|
+
- `url` - Auth service URL (required)
|
|
121
|
+
- `config.adapter` - Optional adapter factory (`SupabaseAuthAdapter()`, `BetterAuthReactAdapter()`)
|
|
122
|
+
- `config.allowAnonymous` - Enable anonymous tokens (default: `false`)
|
|
123
|
+
|
|
124
|
+
### Default API (Better Auth)
|
|
125
|
+
|
|
126
|
+
- `signIn.email(credentials)` - Sign in with email/password
|
|
127
|
+
- `signIn.social(options)` - Sign in with OAuth provider
|
|
128
|
+
- `signUp.email(credentials)` - Create new user account
|
|
129
|
+
- `signOut()` - Sign out current user
|
|
130
|
+
- `getSession()` - Get current session
|
|
131
|
+
|
|
132
|
+
### SupabaseAuthAdapter API
|
|
133
|
+
|
|
134
|
+
- `signUp(credentials)` - Create user with Supabase-style options
|
|
135
|
+
- `signInWithPassword(credentials)` - Email/password sign in
|
|
136
|
+
- `signInWithOAuth(options)` - OAuth with Supabase-style options
|
|
137
|
+
- `getSession()` - Returns `{ data: session }`
|
|
138
|
+
- `getUser()` - Returns `{ data: user }`
|
|
139
|
+
- `updateUser(attributes)` - Update user metadata
|
|
140
|
+
- `resetPasswordForEmail(email, options)` - Password reset
|
|
141
|
+
- `onAuthStateChange(callback)` - Auth state listener
|
|
142
|
+
|
|
143
|
+
### BetterAuthReactAdapter API
|
|
144
|
+
|
|
145
|
+
Same as default API, plus:
|
|
146
|
+
- `useSession()` - React hook for session state
|
|
147
|
+
|
|
148
|
+
## Performance
|
|
149
|
+
|
|
150
|
+
- **Session Caching**: 60-second TTL, automatic JWT expiration handling
|
|
151
|
+
- **Request Deduplication**: Concurrent calls share single network request
|
|
152
|
+
- **Cold start**: ~200ms (single request) vs ~2000ms (without deduplication)
|
|
153
|
+
|
|
154
|
+
## CSS for UI Components
|
|
155
|
+
|
|
156
|
+
Choose based on your project setup:
|
|
157
|
+
|
|
158
|
+
```css
|
|
159
|
+
/* Without Tailwind - pre-built bundle (~47KB) */
|
|
160
|
+
@import '@neondatabase/auth/ui/css';
|
|
161
|
+
|
|
162
|
+
/* With Tailwind CSS v4 - theme tokens only */
|
|
163
|
+
@import 'tailwindcss';
|
|
164
|
+
@import '@neondatabase/auth/ui/tailwind';
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Never import both paths - causes duplicate styles.
|
|
168
|
+
|
|
169
|
+
## Optional
|
|
170
|
+
|
|
171
|
+
- [Next.js Integration](https://github.com/neondatabase/neon-js/blob/main/packages/auth/NEXT-JS.md): Setup guide for Next.js 15+ with middleware and RSC support
|
|
172
|
+
- [Better Auth Documentation](https://www.better-auth.com/docs): Underlying auth library documentation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neondatabase/auth",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.20",
|
|
4
4
|
"description": "TypeScript SDK for Neon Auth - authentication for PostgreSQL with multiple adapter support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"react",
|
|
19
19
|
"nextjs"
|
|
20
20
|
],
|
|
21
|
-
"homepage": "https://github.com/neondatabase
|
|
21
|
+
"homepage": "https://github.com/neondatabase/neon-js/tree/main/packages/auth#readme",
|
|
22
22
|
"bugs": {
|
|
23
|
-
"url": "https://github.com/neondatabase
|
|
23
|
+
"url": "https://github.com/neondatabase/neon-js/issues"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
|
-
"url": "git+https://github.com/neondatabase
|
|
27
|
+
"url": "git+https://github.com/neondatabase/neon-js.git",
|
|
28
28
|
"directory": "packages/auth"
|
|
29
29
|
},
|
|
30
30
|
"funding": {
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"types": "./dist/index.d.mts",
|
|
40
40
|
"default": "./dist/index.mjs"
|
|
41
41
|
},
|
|
42
|
+
"./types": {
|
|
43
|
+
"types": "./dist/types/index.d.mts",
|
|
44
|
+
"default": "./dist/types/index.mjs"
|
|
45
|
+
},
|
|
42
46
|
"./react": {
|
|
43
47
|
"types": "./dist/react/index.d.mts",
|
|
44
48
|
"default": "./dist/react/index.mjs"
|
|
@@ -67,6 +71,10 @@
|
|
|
67
71
|
"types": "./dist/next/index.d.mts",
|
|
68
72
|
"default": "./dist/next/index.mjs"
|
|
69
73
|
},
|
|
74
|
+
"./next/server": {
|
|
75
|
+
"types": "./dist/next/server/index.d.mts",
|
|
76
|
+
"default": "./dist/next/server/index.mjs"
|
|
77
|
+
},
|
|
70
78
|
"./ui/css": {
|
|
71
79
|
"types": "./dist/ui/css.d.ts",
|
|
72
80
|
"default": "./dist/ui/css.css"
|
|
@@ -76,7 +84,8 @@
|
|
|
76
84
|
}
|
|
77
85
|
},
|
|
78
86
|
"files": [
|
|
79
|
-
"dist"
|
|
87
|
+
"dist",
|
|
88
|
+
"llms.txt"
|
|
80
89
|
],
|
|
81
90
|
"publishConfig": {
|
|
82
91
|
"access": "public"
|
|
@@ -95,19 +104,21 @@
|
|
|
95
104
|
"release": "bun run build && bumpp --tag 'auth-v%s' && bun publish --tag latest"
|
|
96
105
|
},
|
|
97
106
|
"devDependencies": {
|
|
98
|
-
"
|
|
107
|
+
"@neondatabase/internal": "0.0.1",
|
|
108
|
+
"msw": "2.6.8",
|
|
109
|
+
"next": "16.0.6"
|
|
99
110
|
},
|
|
100
111
|
"dependencies": {
|
|
112
|
+
"@neondatabase/auth-ui": "0.1.0-alpha.10",
|
|
101
113
|
"@supabase/auth-js": "2.79.0",
|
|
102
|
-
"better-auth": "1.4.6
|
|
103
|
-
"zod": "4.1.12",
|
|
114
|
+
"better-auth": "1.4.6",
|
|
104
115
|
"jose": "6.1.2",
|
|
105
|
-
"
|
|
116
|
+
"zod": "4.1.12"
|
|
106
117
|
},
|
|
107
118
|
"peerDependencies": {
|
|
108
119
|
"react": ">=18.0.0",
|
|
109
120
|
"react-dom": ">=18.0.0",
|
|
110
|
-
"next": "
|
|
121
|
+
"next": ">=16.0.6"
|
|
111
122
|
},
|
|
112
123
|
"peerDependenciesMeta": {
|
|
113
124
|
"react": {
|