@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.
Files changed (48) hide show
  1. package/README.md +112 -18
  2. package/dist/{adapter-core-C12KoaiU.d.mts → adapter-core-23fYTUxT.d.mts} +175 -627
  3. package/dist/{adapter-core-BDOw-gBC.mjs → adapter-core-8s6XdCco.mjs} +392 -69
  4. package/dist/{better-auth-react-adapter-FnBHa2nr.mjs → better-auth-react-adapter-D9tIaEyQ.mjs} +10 -8
  5. package/dist/better-auth-react-adapter-QFe5RtaM.d.mts +2170 -0
  6. package/dist/better-auth-types-BUiggBfa.d.mts +9 -0
  7. package/dist/chunk-VCZJYX65-CLnrj1o7-D6ZQkcc_.mjs +543 -0
  8. package/dist/constants-2bpp2_-f.mjs +30 -0
  9. package/dist/index-Bga0CzOO.d.mts +49 -0
  10. package/dist/index.d.mts +5 -98
  11. package/dist/index.mjs +2 -1
  12. package/dist/middleware-C7jHeulu.mjs +303 -0
  13. package/dist/{neon-auth-C9XTFffv.mjs → neon-auth-2f58U8_-.mjs} +7 -4
  14. package/dist/neon-auth-CDYpC_O1.d.mts +107 -0
  15. package/dist/next/index.d.mts +139 -303
  16. package/dist/next/index.mjs +37 -174
  17. package/dist/next/server/index.d.mts +389 -0
  18. package/dist/next/server/index.mjs +432 -0
  19. package/dist/react/adapters/index.d.mts +5 -4
  20. package/dist/react/adapters/index.mjs +2 -1
  21. package/dist/react/index.d.mts +6 -5
  22. package/dist/react/index.mjs +5 -92
  23. package/dist/react/ui/index.d.mts +1 -1
  24. package/dist/react/ui/index.mjs +3 -91
  25. package/dist/react/ui/server.mjs +1 -1
  26. package/dist/{supabase-adapter-ggmqWgPe.mjs → supabase-adapter-BYMJSxOT.mjs} +72 -167
  27. package/dist/supabase-adapter-Dr-pKvPt.d.mts +2258 -0
  28. package/dist/types/index.d.mts +4 -0
  29. package/dist/types/index.mjs +3 -0
  30. package/dist/ui/.safelist.html +3 -0
  31. package/dist/ui/css.css +2 -2
  32. package/dist/ui/tailwind.css +3 -2
  33. package/dist/ui/theme-inline.css +39 -0
  34. package/dist/ui/theme.css +125 -49
  35. package/dist/ui-Cg1EZzGG.mjs +12104 -0
  36. package/dist/vanilla/adapters/index.d.mts +4 -3
  37. package/dist/vanilla/adapters/index.mjs +2 -1
  38. package/dist/vanilla/index.d.mts +4 -3
  39. package/dist/vanilla/index.mjs +2 -1
  40. package/llms.txt +172 -0
  41. package/package.json +21 -10
  42. package/dist/better-auth-react-adapter-BXL48HIU.d.mts +0 -722
  43. package/dist/supabase-adapter-crabDnl2.d.mts +0 -128
  44. package/dist/ui-CNFBSekF.mjs +0 -401
  45. /package/dist/{adapters-Dkx0zoMR.mjs → adapters-B7YKkjaL.mjs} +0 -0
  46. /package/dist/{index-C-svZlpj.d.mts → index-BHI9uOzY.d.mts} +0 -0
  47. /package/dist/{index-DuDD6cIY.d.mts → index-CSe4aQIZ.d.mts} +0 -0
  48. /package/dist/{index-UW23fDSn.d.mts → index-LhFpnU-f.d.mts} +0 -0
@@ -1,179 +1,42 @@
1
- import { t as BetterAuthReactAdapter } from "../better-auth-react-adapter-FnBHa2nr.mjs";
2
- import { t as createAuthClient$1 } from "../neon-auth-C9XTFffv.mjs";
3
- import { NextRequest, NextResponse } from "next/server";
1
+ import "../adapter-core-8s6XdCco.mjs";
2
+ import { t as BetterAuthReactAdapter } from "../better-auth-react-adapter-D9tIaEyQ.mjs";
3
+ import { t as createAuthClient$1 } from "../neon-auth-2f58U8_-.mjs";
4
+ import { n as neonAuth$1, r as authApiHandler$1, t as neonAuthMiddleware$1 } from "../middleware-C7jHeulu.mjs";
4
5
 
5
- //#region src/next/constants.ts
6
- const NEON_AUTH_COOKIE_PREFIX = "__Secure-neon-auth";
7
- const NEON_AUTH_SESSION_COOKIE_NAME = `${NEON_AUTH_COOKIE_PREFIX}.session_token`;
8
- const NEON_AUTH_SESSION_CHALLENGE_COOKIE_NAME = `${NEON_AUTH_COOKIE_PREFIX}.session_challange`;
9
- /** Name of the session verifier parameter in the URL, used for the OAUTH flow */
10
- const NEON_AUTH_SESSION_VERIFIER_PARAM_NAME = "neon_auth_session_verifier";
11
-
12
- //#endregion
13
- //#region src/next/handler/request.ts
14
- const PROXY_HEADERS = [
15
- "user-agent",
16
- "authorization",
17
- "referer"
18
- ];
19
- const handleAuthRequest = async (baseUrl, request, path) => {
20
- const upstreamURL = `${baseUrl}/${path}${new URL(request.url).search}`;
21
- const headers = prepareRequestHeaders(request);
22
- const body = await parseRequestBody(request);
23
- try {
24
- return await fetch(upstreamURL, {
25
- method: request.method,
26
- headers,
27
- body
28
- });
29
- } catch (error) {
30
- const message = error instanceof Error ? error.message : "Internal Server Error";
31
- console.error(`[AuthError] ${message}`, error);
32
- return new Response(`[AuthError] ${message}`, { status: 500 });
33
- }
34
- };
35
- const prepareRequestHeaders = (request) => {
36
- const headers = new Headers();
37
- headers.set("Content-Type", "application/json");
38
- for (const header of PROXY_HEADERS) if (request.headers.get(header)) headers.set(header, request.headers.get(header));
39
- headers.set("Origin", getOrigin(request));
40
- headers.set("Cookie", extractRequestCookies(request.headers));
41
- headers.set("X-Neon-Auth-Next", "true");
42
- return headers;
43
- };
44
- const getOrigin = (request) => {
45
- return request.headers.get("origin") || request.headers.get("referer")?.split("/").slice(0, 3).join("/") || new URL(request.url).origin;
46
- };
47
- const extractRequestCookies = (headers) => {
48
- const cookieHeader = headers.get("cookie");
49
- if (!cookieHeader) return "";
50
- const cookies = cookieHeader.split(";").map((c) => c.trim());
51
- const result = [];
52
- for (const cookie of cookies) {
53
- const [name] = cookie.split("=");
54
- if (name.startsWith(NEON_AUTH_COOKIE_PREFIX)) result.push(cookie);
55
- }
56
- return result.join(";");
57
- };
58
- const parseRequestBody = async (request) => {
59
- if (request.body) return request.text();
60
- };
61
-
62
- //#endregion
63
- //#region src/next/handler/response.ts
64
- const RESPONSE_HEADERS_ALLOWLIST = [
65
- "content-type",
66
- "content-length",
67
- "content-encoding",
68
- "transfer-encoding",
69
- "connection",
70
- "date",
71
- "set-cookie",
72
- "set-auth-jwt",
73
- "set-auth-token",
74
- "x-neon-ret-request-id"
75
- ];
76
- const handleAuthResponse = async (response) => {
77
- return new Response(response.body, {
78
- status: response.status,
79
- statusText: response.statusText,
80
- headers: prepareResponseHeaders(response)
81
- });
82
- };
83
- const prepareResponseHeaders = (response) => {
84
- const headers = new Headers();
85
- for (const header of RESPONSE_HEADERS_ALLOWLIST) {
86
- const value = response.headers.get(header);
87
- if (value) headers.set(header, value);
88
- }
89
- return headers;
90
- };
91
-
92
- //#endregion
93
- //#region src/next/handler/index.ts
94
- const toNextJsHandler = (baseUrl) => {
95
- const baseURL = baseUrl || process.env.NEON_AUTH_BASE_URL;
96
- if (!baseURL) throw new Error("You must provide a Neon Auth base URL in the handler options or in the environment variables");
97
- const handler = async (request, { params }) => {
98
- return await handleAuthResponse(await handleAuthRequest(baseURL, request, (await params).path.join("/")));
99
- };
100
- return {
101
- GET: handler,
102
- POST: handler,
103
- PUT: handler,
104
- DELETE: handler,
105
- PATCH: handler
106
- };
107
- };
108
-
109
- //#endregion
110
- //#region src/next/middleware/oauth.ts
111
- const needsSessionVerification = (request) => {
112
- const hasVerifier = request.nextUrl.searchParams.has(NEON_AUTH_SESSION_VERIFIER_PARAM_NAME);
113
- const hasChallenge = request.cookies.get(NEON_AUTH_SESSION_CHALLENGE_COOKIE_NAME);
114
- const hasSession = request.cookies.get(NEON_AUTH_SESSION_COOKIE_NAME);
115
- return hasVerifier && hasChallenge && !hasSession;
116
- };
117
- const verifySession = async (request, baseUrl) => {
118
- const url = request.nextUrl;
119
- const verifier = url.searchParams.get(NEON_AUTH_SESSION_VERIFIER_PARAM_NAME);
120
- const challenge = request.cookies.get(NEON_AUTH_SESSION_CHALLENGE_COOKIE_NAME);
121
- if (!verifier || !challenge) return null;
122
- const response = await getSession(request, baseUrl);
123
- if (response.ok) {
124
- const headers = new Headers();
125
- const cookies = extractResponseCookies(response.headers);
126
- for (const cookie of cookies) headers.append("Set-Cookie", cookie);
127
- url.searchParams.delete(NEON_AUTH_SESSION_VERIFIER_PARAM_NAME);
128
- return NextResponse.redirect(url, { headers });
129
- }
130
- return null;
131
- };
132
- const getSession = async (request, baseUrl) => {
133
- return handleAuthResponse(await handleAuthRequest(baseUrl, new Request(request.url, {
134
- method: "GET",
135
- headers: request.headers,
136
- body: null
137
- }), "get-session"));
138
- };
139
- const extractResponseCookies = (headers) => {
140
- const cookieHeader = headers.get("set-cookie");
141
- if (!cookieHeader) return [];
142
- return cookieHeader.split(", ").map((c) => c.trim());
143
- };
144
-
145
- //#endregion
146
- //#region src/next/middleware/index.ts
147
- const SKIP_ROUTES = [
148
- "/api/auth",
149
- "/auth/callback",
150
- "/auth/sign-in",
151
- "/auth/sign-up",
152
- "/auth/magic-link",
153
- "/auth/email-otp",
154
- "/auth/forgot-password"
155
- ];
156
- const neonAuthMiddleware = ({ loginUrl = "/auth/sign-in", authBaseUrl }) => {
157
- const baseURL = authBaseUrl || process.env.NEON_AUTH_BASE_URL;
158
- if (!baseURL) throw new Error("You must provide a Neon Auth base URL in the middleware options or in the environment variables");
159
- return async (request) => {
160
- const { pathname } = request.nextUrl;
161
- if (pathname.startsWith(loginUrl)) return NextResponse.next();
162
- if (needsSessionVerification(request)) {
163
- const response = await verifySession(request, baseURL);
164
- if (response !== null) return response;
165
- }
166
- if (SKIP_ROUTES.some((route) => pathname.startsWith(route))) return NextResponse.next();
167
- if (!request.cookies.get(NEON_AUTH_SESSION_COOKIE_NAME)) return NextResponse.redirect(new URL(loginUrl, request.url));
168
- return NextResponse.next();
169
- };
170
- };
171
-
172
- //#endregion
173
6
  //#region src/next/index.ts
174
- const createAuthClient = () => {
7
+ function createAuthClient() {
175
8
  return createAuthClient$1(void 0, { adapter: BetterAuthReactAdapter() });
176
- };
9
+ }
10
+ /**
11
+ * @deprecated
12
+ * - Moved to `@neondatabase/auth/next/server` and
13
+ * - Moved to `@neondatabase/neon-js/auth/next/server`
14
+ *
15
+ * An API route handler to handle the auth requests from the client and proxy them to the Neon Auth.
16
+ */
17
+ function authApiHandler() {
18
+ return authApiHandler$1();
19
+ }
20
+ /**
21
+ * @deprecated
22
+ * - Moved to `@neondatabase/auth/next/server` and
23
+ * - Moved to `@neondatabase/neon-js/auth/next/server`
24
+ *
25
+ * A Next.js middleware to protect routes from unauthenticated requests and refresh the session if required.
26
+ */
27
+ function neonAuthMiddleware(args) {
28
+ return neonAuthMiddleware$1(args);
29
+ }
30
+ /**
31
+ * @deprecated
32
+ * - Moved to `@neondatabase/auth/next/server` and
33
+ * - Moved to `@neondatabase/neon-js/auth/next/server`
34
+ *
35
+ * A utility function to be used in react server components fetch the session details from the Neon Auth API, if session token is available in cookie.
36
+ */
37
+ function neonAuth() {
38
+ return neonAuth$1();
39
+ }
177
40
 
178
41
  //#endregion
179
- export { createAuthClient, neonAuthMiddleware, toNextJsHandler };
42
+ export { authApiHandler, createAuthClient, neonAuth, neonAuthMiddleware };
@@ -0,0 +1,389 @@
1
+ import "../../better-auth-types-BUiggBfa.mjs";
2
+ import "../../adapter-core-23fYTUxT.mjs";
3
+ import "../../better-auth-react-adapter-QFe5RtaM.mjs";
4
+ import "../../supabase-adapter-Dr-pKvPt.mjs";
5
+ import { o as VanillaBetterAuthClient } from "../../neon-auth-CDYpC_O1.mjs";
6
+ import { r as neonAuth, t as neonAuthMiddleware } from "../../index-Bga0CzOO.mjs";
7
+
8
+ //#region src/server/endpoints.d.ts
9
+
10
+ declare const API_ENDPOINTS: {
11
+ readonly getSession: {
12
+ readonly path: "get-session";
13
+ readonly method: "GET";
14
+ };
15
+ readonly getAccessToken: {
16
+ readonly path: "get-access-token";
17
+ readonly method: "GET";
18
+ };
19
+ readonly listSessions: {
20
+ readonly path: "list-sessions";
21
+ readonly method: "GET";
22
+ };
23
+ readonly revokeSession: {
24
+ readonly path: "revoke-session";
25
+ readonly method: "POST";
26
+ };
27
+ readonly revokeSessions: {
28
+ readonly path: "revoke-sessions";
29
+ readonly method: "POST";
30
+ };
31
+ readonly revokeOtherSessions: {
32
+ readonly path: "revoke-all-sessions";
33
+ readonly method: "POST";
34
+ };
35
+ readonly refreshToken: {
36
+ readonly path: "refresh-token";
37
+ readonly method: "POST";
38
+ };
39
+ readonly signIn: {
40
+ readonly email: {
41
+ readonly path: "sign-in/email";
42
+ readonly method: "POST";
43
+ };
44
+ readonly social: {
45
+ readonly path: "sign-in/social";
46
+ readonly method: "POST";
47
+ };
48
+ readonly emailOtp: {
49
+ readonly path: "sign-in/email-otp";
50
+ readonly method: "POST";
51
+ };
52
+ };
53
+ readonly signUp: {
54
+ readonly email: {
55
+ readonly path: "sign-up/email";
56
+ readonly method: "POST";
57
+ };
58
+ };
59
+ readonly signOut: {
60
+ readonly path: "sign-out";
61
+ readonly method: "POST";
62
+ };
63
+ readonly listAccounts: {
64
+ readonly path: "list-accounts";
65
+ readonly method: "GET";
66
+ };
67
+ readonly accountInfo: {
68
+ readonly path: "account-info";
69
+ readonly method: "GET";
70
+ };
71
+ readonly updateUser: {
72
+ readonly path: "update-user";
73
+ readonly method: "POST";
74
+ };
75
+ readonly deleteUser: {
76
+ readonly path: "delete-user";
77
+ readonly method: "POST";
78
+ };
79
+ readonly changePassword: {
80
+ readonly path: "change-password";
81
+ readonly method: "POST";
82
+ };
83
+ readonly sendVerificationEmail: {
84
+ readonly path: "send-verification-email";
85
+ readonly method: "POST";
86
+ };
87
+ readonly verifyEmail: {
88
+ readonly path: "verify-email";
89
+ readonly method: "POST";
90
+ };
91
+ readonly resetPassword: {
92
+ readonly path: "reset-password";
93
+ readonly method: "POST";
94
+ };
95
+ readonly requestPasswordReset: {
96
+ readonly path: "request-password-reset";
97
+ readonly method: "POST";
98
+ };
99
+ readonly token: {
100
+ readonly path: "token";
101
+ readonly method: "GET";
102
+ };
103
+ readonly jwks: {
104
+ readonly path: "jwt";
105
+ readonly method: "GET";
106
+ };
107
+ readonly getAnonymousToken: {
108
+ readonly path: "token/anonymous";
109
+ readonly method: "GET";
110
+ };
111
+ readonly admin: {
112
+ readonly createUser: {
113
+ readonly path: "admin/create-user";
114
+ readonly method: "POST";
115
+ };
116
+ readonly listUsers: {
117
+ readonly path: "admin/list-users";
118
+ readonly method: "GET";
119
+ };
120
+ readonly setRole: {
121
+ readonly path: "admin/set-role";
122
+ readonly method: "POST";
123
+ };
124
+ readonly setUserPassword: {
125
+ readonly path: "admin/set-user-password";
126
+ readonly method: "POST";
127
+ };
128
+ readonly updateUser: {
129
+ readonly path: "admin/update-user";
130
+ readonly method: "POST";
131
+ };
132
+ readonly banUser: {
133
+ readonly path: "admin/ban-user";
134
+ readonly method: "POST";
135
+ };
136
+ readonly unbanUser: {
137
+ readonly path: "admin/unban-user";
138
+ readonly method: "POST";
139
+ };
140
+ readonly listUserSessions: {
141
+ readonly path: "admin/list-user-sessions";
142
+ readonly method: "GET";
143
+ };
144
+ readonly revokeUserSession: {
145
+ readonly path: "admin/revoke-user-session";
146
+ readonly method: "POST";
147
+ };
148
+ readonly revokeUserSessions: {
149
+ readonly path: "admin/revoke-user-sessions";
150
+ readonly method: "POST";
151
+ };
152
+ readonly impersonateUser: {
153
+ readonly path: "admin/impersonate-user";
154
+ readonly method: "POST";
155
+ };
156
+ readonly stopImpersonating: {
157
+ readonly path: "admin/stop-impersonating";
158
+ readonly method: "POST";
159
+ };
160
+ readonly removeUser: {
161
+ readonly path: "admin/remove-user";
162
+ readonly method: "POST";
163
+ };
164
+ readonly hasPermission: {
165
+ readonly path: "admin/has-permission";
166
+ readonly method: "POST";
167
+ };
168
+ };
169
+ readonly organization: {
170
+ readonly create: {
171
+ readonly path: "organization/create";
172
+ readonly method: "POST";
173
+ };
174
+ readonly update: {
175
+ readonly path: "organization/update";
176
+ readonly method: "POST";
177
+ };
178
+ readonly delete: {
179
+ readonly path: "organization/delete";
180
+ readonly method: "POST";
181
+ };
182
+ readonly list: {
183
+ readonly path: "organization/list";
184
+ readonly method: "GET";
185
+ };
186
+ readonly getFullOrganization: {
187
+ readonly path: "organization/get-full-organization";
188
+ readonly method: "GET";
189
+ };
190
+ readonly setActive: {
191
+ readonly path: "organization/set-active";
192
+ readonly method: "POST";
193
+ };
194
+ readonly checkSlug: {
195
+ readonly path: "organization/check-slug";
196
+ readonly method: "GET";
197
+ };
198
+ readonly listMembers: {
199
+ readonly path: "organization/list-members";
200
+ readonly method: "GET";
201
+ };
202
+ readonly removeMember: {
203
+ readonly path: "organization/remove-member";
204
+ readonly method: "POST";
205
+ };
206
+ readonly updateMemberRole: {
207
+ readonly path: "organization/update-member-role";
208
+ readonly method: "POST";
209
+ };
210
+ readonly leave: {
211
+ readonly path: "organization/leave";
212
+ readonly method: "POST";
213
+ };
214
+ readonly getActiveMember: {
215
+ readonly path: "organization/get-active-member";
216
+ readonly method: "GET";
217
+ };
218
+ readonly getActiveMemberRole: {
219
+ readonly path: "organization/get-active-member-role";
220
+ readonly method: "GET";
221
+ };
222
+ readonly inviteMember: {
223
+ readonly path: "organization/invite-member";
224
+ readonly method: "POST";
225
+ };
226
+ readonly acceptInvitation: {
227
+ readonly path: "organization/accept-invitation";
228
+ readonly method: "POST";
229
+ };
230
+ readonly rejectInvitation: {
231
+ readonly path: "organization/reject-invitation";
232
+ readonly method: "POST";
233
+ };
234
+ readonly cancelInvitation: {
235
+ readonly path: "organization/cancel-invitation";
236
+ readonly method: "POST";
237
+ };
238
+ readonly getInvitation: {
239
+ readonly path: "organization/get-invitation";
240
+ readonly method: "GET";
241
+ };
242
+ readonly listInvitations: {
243
+ readonly path: "organization/list-invitations";
244
+ readonly method: "GET";
245
+ };
246
+ readonly listUserInvitations: {
247
+ readonly path: "organization/list-user-invitations";
248
+ readonly method: "GET";
249
+ };
250
+ readonly hasPermission: {
251
+ readonly path: "organization/has-permission";
252
+ readonly method: "POST";
253
+ };
254
+ };
255
+ readonly emailOtp: {
256
+ readonly sendVerificationOtp: {
257
+ readonly path: "email-otp/send-verification-otp";
258
+ readonly method: "POST";
259
+ };
260
+ readonly verifyEmail: {
261
+ readonly path: "email-otp/verify-email";
262
+ readonly method: "POST";
263
+ };
264
+ readonly checkVerificationOtp: {
265
+ readonly path: "email-otp/check-verification-otp";
266
+ readonly method: "POST";
267
+ };
268
+ readonly resetPassword: {
269
+ readonly path: "email-otp/passcode";
270
+ readonly method: "POST";
271
+ };
272
+ };
273
+ };
274
+ //#endregion
275
+ //#region src/server/types.d.ts
276
+ /**
277
+ * Extract top-level keys from API_ENDPOINTS.
278
+ * For nested endpoints like signIn.email, this extracts 'signIn' (not 'email').
279
+ */
280
+ type TopLevelEndpointKeys<T> = { [K in keyof T]: K }[keyof T];
281
+ type ServerAuthMethods = TopLevelEndpointKeys<typeof API_ENDPOINTS>;
282
+ type NeonAuthServer = Pick<VanillaBetterAuthClient, ServerAuthMethods>;
283
+ //#endregion
284
+ //#region src/next/handler/index.d.ts
285
+ type Params = {
286
+ path: string[];
287
+ };
288
+ /**
289
+ *
290
+ * An API route handler to handle the auth requests from the client and proxy them to the Neon Auth.
291
+ *
292
+ * @returns A Next.js API handler functions those can be used in a Next.js route.
293
+ *
294
+ * @example
295
+ * Mount the `authApiHandler` to an API route. Create a route file inside `/api/auth/[...all]/route.ts` directory.
296
+ * And add the following code:
297
+ *
298
+ * ```ts
299
+ * // app/api/auth/[...all]/route.ts
300
+ * import { authApiHandler } from '@neondatabase/auth/next';
301
+ *
302
+ * export const { GET, POST } = authApiHandler();
303
+ * ```
304
+ */
305
+ declare function authApiHandler(): {
306
+ GET: (request: Request, {
307
+ params
308
+ }: {
309
+ params: Promise<Params>;
310
+ }) => Promise<Response>;
311
+ POST: (request: Request, {
312
+ params
313
+ }: {
314
+ params: Promise<Params>;
315
+ }) => Promise<Response>;
316
+ PUT: (request: Request, {
317
+ params
318
+ }: {
319
+ params: Promise<Params>;
320
+ }) => Promise<Response>;
321
+ DELETE: (request: Request, {
322
+ params
323
+ }: {
324
+ params: Promise<Params>;
325
+ }) => Promise<Response>;
326
+ PATCH: (request: Request, {
327
+ params
328
+ }: {
329
+ params: Promise<Params>;
330
+ }) => Promise<Response>;
331
+ };
332
+ //#endregion
333
+ //#region src/next/server/index.d.ts
334
+ /**
335
+ * Creates a server-side auth API client for Next.js.
336
+ *
337
+ * This client exposes the Neon Auth APIs including authentication, user management, organizations, and admin operations.
338
+ *
339
+ * **Where to use:**
340
+ * - React Server Components
341
+ * - Server Actions
342
+ * - Route Handlers
343
+ *
344
+ * **Requirements:**
345
+ * - `NEON_AUTH_BASE_URL` environment variable must be set
346
+ * - Cookies are automatically read/written via `next/headers`
347
+ *
348
+ * @returns Auth server API client for Next.js
349
+ * @throws Error if `NEON_AUTH_BASE_URL` environment variable is not set
350
+ *
351
+ * @example
352
+ * ```typescript
353
+ * // lib/auth/server.ts - Create a singleton instance
354
+ * import { createAuthServer } from '@neondatabase/auth/next/server';
355
+ * export const authServer = createAuthServer();
356
+ * ```
357
+ *
358
+ * @example
359
+ * ```typescript
360
+ * // Server Component - Reading session
361
+ * import { authServer } from '@/lib/auth/server';
362
+ *
363
+ * export default async function Page() {
364
+ * const { data: session } = await authServer.getSession();
365
+ * if (!session?.user) return <div>Not logged in</div>;
366
+ * return <div>Hello {session.user.name}</div>;
367
+ * }
368
+ * ```
369
+ *
370
+ * @example
371
+ * ```typescript
372
+ * // Server Action - Sign in
373
+ * 'use server';
374
+ * import { authServer } from '@/lib/auth/server';
375
+ * import { redirect } from 'next/navigation';
376
+ *
377
+ * export async function signIn(formData: FormData) {
378
+ * const { error } = await authServer.signIn.email({
379
+ * email: formData.get('email') as string,
380
+ * password: formData.get('password') as string,
381
+ * });
382
+ * if (error) return { error: error.message };
383
+ * redirect('/dashboard');
384
+ * }
385
+ * ```
386
+ */
387
+ declare function createAuthServer(): NeonAuthServer;
388
+ //#endregion
389
+ export { authApiHandler, createAuthServer, neonAuth, neonAuthMiddleware };