@neondatabase/auth 0.3.0-beta → 0.4.1-beta

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 (33) hide show
  1. package/README.md +22 -7
  2. package/codemods/migrate-auth-ui-imports.mjs +439 -0
  3. package/dist/{adapter-core-D00qcqMo.mjs → adapter-core-BFMM3lwe.mjs} +21 -11
  4. package/dist/{adapter-core-B9uDhoYq.d.mts → adapter-core-ClY-p_AI.d.mts} +325 -190
  5. package/dist/auth-interface-Clz-oWq1.d.mts +8 -0
  6. package/dist/better-auth-helpers-Bkezghej.mjs +541 -0
  7. package/dist/{better-auth-react-adapter-Xdj-69i9.mjs → better-auth-react-adapter-DZTZVVnk.mjs} +1 -1
  8. package/dist/{better-auth-react-adapter-BO4jLN4H.d.mts → better-auth-react-adapter-iJMZCLUI.d.mts} +388 -301
  9. package/dist/index.d.mts +5 -4
  10. package/dist/index.mjs +4 -3
  11. package/dist/{neon-auth-DBOB8sXF.mjs → neon-auth-VDrC3GwX.mjs} +1 -1
  12. package/dist/next/index.d.mts +144 -56
  13. package/dist/next/index.mjs +5 -4
  14. package/dist/next/server/index.d.mts +131 -14
  15. package/dist/next/server/index.mjs +402 -52
  16. package/dist/react/adapters/index.d.mts +3 -3
  17. package/dist/react/adapters/index.mjs +2 -2
  18. package/dist/react/index.d.mts +4 -4
  19. package/dist/react/index.mjs +2 -2
  20. package/dist/react/ui/index.d.mts +1 -1
  21. package/dist/{supabase-adapter-CIBMebXB.mjs → supabase-adapter-CAyBFrNn.mjs} +3 -514
  22. package/dist/{supabase-adapter-CSDRL1ZU.d.mts → supabase-adapter-cuLnmLDs.d.mts} +390 -303
  23. package/dist/types/index.d.mts +2 -2
  24. package/dist/vanilla/adapters/index.d.mts +4 -3
  25. package/dist/vanilla/adapters/index.mjs +2 -2
  26. package/dist/vanilla/index.d.mts +4 -3
  27. package/dist/vanilla/index.mjs +2 -2
  28. package/llms.txt +2 -2
  29. package/package.json +6 -2
  30. package/dist/constants-Cupc_bln.mjs +0 -28
  31. /package/dist/{index-CPnFzULh.d.mts → index-B0Pd4HOH.d.mts} +0 -0
  32. /package/dist/{index-UW23fDSn.d.mts → index-CzpoWrv9.d.mts} +0 -0
  33. /package/dist/{index-B_Q0Tp1D.d.mts → index-DHryUj7e.d.mts} +0 -0
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- import { O as VanillaBetterAuthClient, x as ReactBetterAuthClient } from "./adapter-core-B9uDhoYq.mjs";
2
- import { n as BetterAuthReactAdapterInstance } from "./better-auth-react-adapter-BO4jLN4H.mjs";
3
- import { r as SupabaseAuthAdapterInstance, s as BetterAuthVanillaAdapterInstance } from "./supabase-adapter-CSDRL1ZU.mjs";
1
+ import { S as ReactBetterAuthClient, k as VanillaBetterAuthClient } from "./adapter-core-ClY-p_AI.mjs";
2
+ import { n as BetterAuthReactAdapterInstance } from "./better-auth-react-adapter-iJMZCLUI.mjs";
3
+ import { r as SupabaseAuthAdapterInstance, s as BetterAuthVanillaAdapterInstance } from "./supabase-adapter-cuLnmLDs.mjs";
4
+ import { a as isAuthError, i as isAuthApiError, n as AuthError, t as AuthApiError } from "./auth-interface-Clz-oWq1.mjs";
4
5
 
5
6
  //#region src/neon-auth.d.ts
6
7
 
@@ -90,4 +91,4 @@ type NeonAuth<T extends NeonAuthAdapter> = {
90
91
  declare function createInternalNeonAuth<T extends NeonAuthAdapter = BetterAuthVanillaAdapterInstance>(url: string, config?: NeonAuthConfigInternal<T>): NeonAuth<T>;
91
92
  declare function createAuthClient<T extends NeonAuthAdapter = BetterAuthVanillaAdapterInstance>(url: string, config?: NeonAuthConfig<T>): NeonAuthPublicApi<T>;
92
93
  //#endregion
93
- export { type NeonAuth, type NeonAuthAdapter, type NeonAuthConfig, type NeonAuthPublicApi, type ReactBetterAuthClient, type VanillaBetterAuthClient, createAuthClient, createInternalNeonAuth };
94
+ export { AuthApiError, AuthError, type NeonAuth, type NeonAuthAdapter, type NeonAuthConfig, type NeonAuthPublicApi, type ReactBetterAuthClient, type VanillaBetterAuthClient, createAuthClient, createInternalNeonAuth, isAuthApiError, isAuthError };
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import "./adapter-core-D00qcqMo.mjs";
2
- import { n as createInternalNeonAuth, t as createAuthClient } from "./neon-auth-DBOB8sXF.mjs";
1
+ import "./adapter-core-BFMM3lwe.mjs";
2
+ import { c as isAuthApiError, l as isAuthError, o as AuthApiError, s as AuthError } from "./better-auth-helpers-Bkezghej.mjs";
3
+ import { n as createInternalNeonAuth, t as createAuthClient } from "./neon-auth-VDrC3GwX.mjs";
3
4
 
4
- export { createAuthClient, createInternalNeonAuth };
5
+ export { AuthApiError, AuthError, createAuthClient, createInternalNeonAuth, isAuthApiError, isAuthError };
@@ -1,4 +1,4 @@
1
- import { n as BetterAuthVanillaAdapter } from "./supabase-adapter-CIBMebXB.mjs";
1
+ import { n as BetterAuthVanillaAdapter } from "./supabase-adapter-CAyBFrNn.mjs";
2
2
 
3
3
  //#region src/neon-auth.ts
4
4
  /**
@@ -1,3 +1,4 @@
1
+ import { a as isAuthError, i as isAuthApiError, n as AuthError, t as AuthApiError } from "../auth-interface-Clz-oWq1.mjs";
1
2
  import * as better_auth_react0 from "better-auth/react";
2
3
  import * as jose0 from "jose";
3
4
  import * as better_auth_plugins0 from "better-auth/plugins";
@@ -124,15 +125,7 @@ declare function createAuthClient(): {
124
125
  id: string;
125
126
  };
126
127
  fetchOptions?: FetchOptions | undefined;
127
- }>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<{
128
- id: string;
129
- createdAt: Date;
130
- updatedAt: Date;
131
- email: string;
132
- emailVerified: boolean;
133
- name: string;
134
- image?: string | null | undefined;
135
- }, {
128
+ }>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<better_auth_plugins0.UserWithRole, {
136
129
  code?: string | undefined;
137
130
  message?: string | undefined;
138
131
  }, FetchOptions["throw"] extends true ? true : false>>;
@@ -141,13 +134,13 @@ declare function createAuthClient(): {
141
134
  admin: {
142
135
  createUser: <FetchOptions extends better_auth0.ClientFetchOption<Partial<{
143
136
  email: string;
144
- password: string;
137
+ password?: string | undefined;
145
138
  name: string;
146
139
  role?: "user" | "admin" | ("user" | "admin")[] | undefined;
147
140
  data?: Record<string, any> | undefined;
148
141
  }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth0.Prettify<{
149
142
  email: string;
150
- password: string;
143
+ password?: string | undefined;
151
144
  name: string;
152
145
  role?: "user" | "admin" | ("user" | "admin")[] | undefined;
153
146
  data?: Record<string, any> | undefined;
@@ -239,15 +232,7 @@ declare function createAuthClient(): {
239
232
  } & {
240
233
  fetchOptions?: FetchOptions | undefined;
241
234
  }>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<{
242
- user: {
243
- id: string;
244
- createdAt: Date;
245
- updatedAt: Date;
246
- email: string;
247
- emailVerified: boolean;
248
- name: string;
249
- image?: string | null | undefined;
250
- } & Record<string, any>;
235
+ user: better_auth_plugins0.UserWithRole;
251
236
  }, {
252
237
  code?: string | undefined;
253
238
  message?: string | undefined;
@@ -266,15 +251,7 @@ declare function createAuthClient(): {
266
251
  } & {
267
252
  fetchOptions?: FetchOptions | undefined;
268
253
  }>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<{
269
- user: {
270
- id: string;
271
- createdAt: Date;
272
- updatedAt: Date;
273
- email: string;
274
- emailVerified: boolean;
275
- name: string;
276
- image?: string | null | undefined;
277
- } & Record<string, any>;
254
+ user: better_auth_plugins0.UserWithRole;
278
255
  }, {
279
256
  code?: string | undefined;
280
257
  message?: string | undefined;
@@ -311,8 +288,25 @@ declare function createAuthClient(): {
311
288
  query?: Record<string, any> | undefined;
312
289
  fetchOptions?: FetchOptions | undefined;
313
290
  }> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<{
314
- session: better_auth0.Session & Record<string, any>;
315
- user: better_auth0.User & Record<string, any>;
291
+ session: {
292
+ id: string;
293
+ createdAt: Date;
294
+ updatedAt: Date;
295
+ userId: string;
296
+ expiresAt: Date;
297
+ token: string;
298
+ ipAddress?: string | null | undefined;
299
+ userAgent?: string | null | undefined;
300
+ } & Record<string, any>;
301
+ user: {
302
+ id: string;
303
+ createdAt: Date;
304
+ updatedAt: Date;
305
+ email: string;
306
+ emailVerified: boolean;
307
+ name: string;
308
+ image?: string | null | undefined;
309
+ } & Record<string, any>;
316
310
  }, {
317
311
  code?: string | undefined;
318
312
  message?: string | undefined;
@@ -488,8 +482,6 @@ declare function createAuthClient(): {
488
482
  createdAt: Date;
489
483
  logo?: string | null | undefined | undefined;
490
484
  metadata?: any;
491
- } & {
492
- metadata: Record<string, any> | undefined;
493
485
  }, {
494
486
  code?: string | undefined;
495
487
  message?: string | undefined;
@@ -641,7 +633,7 @@ declare function createAuthClient(): {
641
633
  resend?: boolean | undefined;
642
634
  } & {
643
635
  fetchOptions?: FetchOptions | undefined;
644
- }>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<{
636
+ }>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<NonNullable<{
645
637
  id: string;
646
638
  organizationId: string;
647
639
  email: string;
@@ -650,7 +642,16 @@ declare function createAuthClient(): {
650
642
  inviterId: string;
651
643
  expiresAt: Date;
652
644
  createdAt: Date;
653
- }, {
645
+ } | {
646
+ id: string;
647
+ organizationId: string;
648
+ email: string;
649
+ role: "admin" | "member" | "owner";
650
+ status: better_auth_plugins0.InvitationStatus;
651
+ inviterId: string;
652
+ expiresAt: Date;
653
+ createdAt: Date;
654
+ }>, {
654
655
  code?: string | undefined;
655
656
  message?: string | undefined;
656
657
  }, FetchOptions["throw"] extends true ? true : false>>;
@@ -1130,25 +1131,25 @@ declare function createAuthClient(): {
1130
1131
  token: string;
1131
1132
  user: {
1132
1133
  id: string;
1134
+ createdAt: Date;
1135
+ updatedAt: Date;
1133
1136
  email: string;
1134
1137
  emailVerified: boolean;
1135
1138
  name: string;
1136
- image: string | null | undefined;
1137
- createdAt: Date;
1138
- updatedAt: Date;
1139
- };
1139
+ image?: string | null | undefined;
1140
+ } & Record<string, any>;
1140
1141
  } | {
1141
1142
  status: boolean;
1142
1143
  token: null;
1143
1144
  user: {
1144
1145
  id: string;
1146
+ createdAt: Date;
1147
+ updatedAt: Date;
1145
1148
  email: string;
1146
1149
  emailVerified: boolean;
1147
1150
  name: string;
1148
- image: string | null | undefined;
1149
- createdAt: Date;
1150
- updatedAt: Date;
1151
- };
1151
+ image?: string | null | undefined;
1152
+ } & Record<string, any>;
1152
1153
  }>, {
1153
1154
  code?: string | undefined;
1154
1155
  message?: string | undefined;
@@ -1168,18 +1169,33 @@ declare function createAuthClient(): {
1168
1169
  token: string;
1169
1170
  user: {
1170
1171
  id: string;
1172
+ createdAt: Date;
1173
+ updatedAt: Date;
1171
1174
  email: string;
1172
1175
  emailVerified: boolean;
1173
1176
  name: string;
1174
- image: string | null | undefined;
1175
- createdAt: Date;
1176
- updatedAt: Date;
1177
+ image?: string | null | undefined;
1177
1178
  };
1178
1179
  }, {
1179
1180
  code?: string | undefined;
1180
1181
  message?: string | undefined;
1181
1182
  }, FetchOptions["throw"] extends true ? true : false>>;
1182
1183
  };
1184
+ } & {
1185
+ emailOtp: {
1186
+ requestPasswordReset: <FetchOptions extends better_auth0.ClientFetchOption<Partial<{
1187
+ email: string;
1188
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth0.Prettify<{
1189
+ email: string;
1190
+ } & {
1191
+ fetchOptions?: FetchOptions | undefined;
1192
+ }>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<{
1193
+ success: boolean;
1194
+ }, {
1195
+ code?: string | undefined;
1196
+ message?: string | undefined;
1197
+ }, FetchOptions["throw"] extends true ? true : false>>;
1198
+ };
1183
1199
  } & {
1184
1200
  forgetPassword: {
1185
1201
  emailOtp: <FetchOptions extends better_auth0.ClientFetchOption<Partial<{
@@ -1214,6 +1230,60 @@ declare function createAuthClient(): {
1214
1230
  message?: string | undefined;
1215
1231
  }, FetchOptions["throw"] extends true ? true : false>>;
1216
1232
  };
1233
+ } & {
1234
+ signIn: {
1235
+ magicLink: <FetchOptions extends better_auth0.ClientFetchOption<Partial<{
1236
+ email: string;
1237
+ name?: string | undefined;
1238
+ callbackURL?: string | undefined;
1239
+ newUserCallbackURL?: string | undefined;
1240
+ errorCallbackURL?: string | undefined;
1241
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth0.Prettify<{
1242
+ email: string;
1243
+ name?: string | undefined;
1244
+ callbackURL?: string | undefined;
1245
+ newUserCallbackURL?: string | undefined;
1246
+ errorCallbackURL?: string | undefined;
1247
+ } & {
1248
+ fetchOptions?: FetchOptions | undefined;
1249
+ }>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<{
1250
+ status: boolean;
1251
+ }, {
1252
+ code?: string | undefined;
1253
+ message?: string | undefined;
1254
+ }, FetchOptions["throw"] extends true ? true : false>>;
1255
+ };
1256
+ } & {
1257
+ magicLink: {
1258
+ verify: <FetchOptions extends better_auth0.ClientFetchOption<never, Partial<{
1259
+ token: string;
1260
+ callbackURL?: string | undefined;
1261
+ errorCallbackURL?: string | undefined;
1262
+ newUserCallbackURL?: string | undefined;
1263
+ }> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth0.Prettify<{
1264
+ query: {
1265
+ token: string;
1266
+ callbackURL?: string | undefined;
1267
+ errorCallbackURL?: string | undefined;
1268
+ newUserCallbackURL?: string | undefined;
1269
+ };
1270
+ fetchOptions?: FetchOptions | undefined;
1271
+ }>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<{
1272
+ token: string;
1273
+ user: {
1274
+ id: string;
1275
+ createdAt: Date;
1276
+ updatedAt: Date;
1277
+ email: string;
1278
+ emailVerified: boolean;
1279
+ name: string;
1280
+ image?: string | null | undefined;
1281
+ };
1282
+ }, {
1283
+ code?: string | undefined;
1284
+ message?: string | undefined;
1285
+ }, FetchOptions["throw"] extends true ? true : false>>;
1286
+ };
1217
1287
  } & {
1218
1288
  signIn: {
1219
1289
  social: <FetchOptions extends better_auth0.ClientFetchOption<Partial<{
@@ -1436,13 +1506,13 @@ declare function createAuthClient(): {
1436
1506
  token: string | null;
1437
1507
  user: {
1438
1508
  id: string;
1439
- email: string;
1440
- name: string;
1441
- image: string | null | undefined;
1442
- emailVerified: boolean;
1443
1509
  createdAt: Date;
1444
1510
  updatedAt: Date;
1445
- };
1511
+ email: string;
1512
+ emailVerified: boolean;
1513
+ name: string;
1514
+ image?: string | null | undefined;
1515
+ } & Record<string, any>;
1446
1516
  }, {
1447
1517
  code?: string | undefined;
1448
1518
  message?: string | undefined;
@@ -1606,13 +1676,13 @@ declare function createAuthClient(): {
1606
1676
  query?: Record<string, any> | undefined;
1607
1677
  fetchOptions?: FetchOptions | undefined;
1608
1678
  }> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch0.BetterFetchResponse<{
1679
+ scopes: string[];
1609
1680
  id: string;
1610
- providerId: string;
1611
1681
  createdAt: Date;
1612
1682
  updatedAt: Date;
1613
- accountId: string;
1614
1683
  userId: string;
1615
- scopes: string[];
1684
+ providerId: string;
1685
+ accountId: string;
1616
1686
  }[], {
1617
1687
  code?: string | undefined;
1618
1688
  message?: string | undefined;
@@ -1975,6 +2045,7 @@ declare function createAuthClient(): {
1975
2045
  })[];
1976
2046
  cache?: RequestCache | undefined;
1977
2047
  method: string;
2048
+ window?: null | undefined;
1978
2049
  headers?: (HeadersInit & (HeadersInit | {
1979
2050
  accept: "application/json" | "text/plain" | "application/octet-stream";
1980
2051
  "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
@@ -1989,7 +2060,6 @@ declare function createAuthClient(): {
1989
2060
  referrer?: string | undefined;
1990
2061
  referrerPolicy?: ReferrerPolicy | undefined;
1991
2062
  signal?: (AbortSignal | null) | undefined;
1992
- window?: null | undefined;
1993
2063
  onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
1994
2064
  hookOptions?: {
1995
2065
  cloneResponse?: boolean;
@@ -2130,7 +2200,25 @@ declare function createAuthClient(): {
2130
2200
  readonly FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account";
2131
2201
  readonly ACCOUNT_NOT_FOUND: "Account not found";
2132
2202
  readonly USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account.";
2203
+ readonly CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: "Cross-site navigation login blocked. This request appears to be a CSRF attack.";
2204
+ readonly VERIFICATION_EMAIL_NOT_ENABLED: "Verification email isn't enabled";
2205
+ readonly EMAIL_ALREADY_VERIFIED: "Email is already verified";
2206
+ readonly EMAIL_MISMATCH: "Email mismatch";
2207
+ readonly SESSION_NOT_FRESH: "Session is not fresh";
2208
+ readonly LINKED_ACCOUNT_ALREADY_EXISTS: "Linked account already exists";
2209
+ readonly INVALID_ORIGIN: "Invalid origin";
2210
+ readonly INVALID_CALLBACK_URL: "Invalid callbackURL";
2211
+ readonly INVALID_REDIRECT_URL: "Invalid redirectURL";
2212
+ readonly INVALID_ERROR_CALLBACK_URL: "Invalid errorCallbackURL";
2213
+ readonly INVALID_NEW_USER_CALLBACK_URL: "Invalid newUserCallbackURL";
2214
+ readonly MISSING_OR_NULL_ORIGIN: "Missing or null Origin";
2215
+ readonly CALLBACK_URL_REQUIRED: "callbackURL is required";
2216
+ readonly FAILED_TO_CREATE_VERIFICATION: "Unable to create verification";
2217
+ readonly FIELD_NOT_ALLOWED: "Field not allowed to be set";
2218
+ readonly ASYNC_VALIDATION_NOT_SUPPORTED: "Async validation is not supported";
2219
+ readonly VALIDATION_ERROR: "Validation Error";
2220
+ readonly MISSING_FIELD: "Field is required";
2133
2221
  };
2134
2222
  };
2135
2223
  //#endregion
2136
- export { createAuthClient };
2224
+ export { AuthApiError, AuthError, createAuthClient, isAuthApiError, isAuthError };
@@ -1,6 +1,7 @@
1
- import "../adapter-core-D00qcqMo.mjs";
2
- import { t as BetterAuthReactAdapter } from "../better-auth-react-adapter-Xdj-69i9.mjs";
3
- import { t as createAuthClient$1 } from "../neon-auth-DBOB8sXF.mjs";
1
+ import "../adapter-core-BFMM3lwe.mjs";
2
+ import { c as isAuthApiError, l as isAuthError, o as AuthApiError, s as AuthError } from "../better-auth-helpers-Bkezghej.mjs";
3
+ import { t as BetterAuthReactAdapter } from "../better-auth-react-adapter-DZTZVVnk.mjs";
4
+ import { t as createAuthClient$1 } from "../neon-auth-VDrC3GwX.mjs";
4
5
 
5
6
  //#region src/next/index.ts
6
7
  function createAuthClient() {
@@ -8,4 +9,4 @@ function createAuthClient() {
8
9
  }
9
10
 
10
11
  //#endregion
11
- export { createAuthClient };
12
+ export { AuthApiError, AuthError, createAuthClient, isAuthApiError, isAuthError };
@@ -1,11 +1,51 @@
1
- import { O as VanillaBetterAuthClient } from "../../adapter-core-B9uDhoYq.mjs";
1
+ import { k as VanillaBetterAuthClient } from "../../adapter-core-ClY-p_AI.mjs";
2
+ import { a as isAuthError, i as isAuthApiError, n as AuthError, t as AuthApiError } from "../../auth-interface-Clz-oWq1.mjs";
2
3
  import { NextRequest, NextResponse } from "next/server";
3
4
 
4
- //#region src/server/config.d.ts
5
-
5
+ //#region src/server/logger.d.ts
6
6
  /**
7
- * Framework-agnostic configuration types for Neon Auth
7
+ * Framework-agnostic logging for Neon Auth server-side proxy and middleware.
8
8
  */
9
+ /** Supported Neon Auth log levels (`'silent'` disables all Neon Auth SDK `console` output). */
10
+ type NeonAuthLogLevel = 'error' | 'warn' | 'info' | 'debug' | 'silent';
11
+ /**
12
+ * Optional injectable logger. Omitted methods fall back to `console`.
13
+ *
14
+ * Custom implementations may receive structured fields such as `err` (the raw caught value)
15
+ * alongside `detail` for richer sinks (Sentry, OTel).
16
+ */
17
+ type NeonAuthLogger = Partial<{
18
+ error(message: string, meta?: Record<string, unknown>): void;
19
+ warn(message: string, meta?: Record<string, unknown>): void;
20
+ info(message: string, meta?: Record<string, unknown>): void;
21
+ debug(message: string, meta?: Record<string, unknown>): void;
22
+ }>;
23
+ /** Resolved sink after merging defaults and level filtering (same shape as {@link NeonAuthLogger} with all methods required). */
24
+ type ResolvedNeonAuthLogging = Required<NeonAuthLogger>;
25
+ /**
26
+ * Logger / level options for Neon Auth server surfaces.
27
+ *
28
+ * When **`logLevel`** is **`'silent'`**, any **`logger`** is ignored at runtime (full mute).
29
+ */
30
+ type NeonAuthLoggingInput = {
31
+ logger?: NeonAuthLogger;
32
+ /**
33
+ * Minimum level for Neon Auth logs. **`'silent'`** disables all Neon Auth `console` output.
34
+ * @default 'warn' — emits `error` and `warn` only
35
+ */
36
+ logLevel?: NeonAuthLogLevel;
37
+ };
38
+ /**
39
+ * Merges user logger with `console`, applies {@link NeonAuthLoggingInput} level rules.
40
+ *
41
+ * **Opt-out:** Defaults to `warn` (structured `error` / `warn` to `console`). Set **`logLevel: 'silent'`**
42
+ * to disable completely. Custom **`logger`** overrides `console` per level when not silent.
43
+ */
44
+ declare function resolveNeonAuthLogging(input?: NeonAuthLoggingInput): ResolvedNeonAuthLogging;
45
+ //#endregion
46
+ //#region src/server/config.d.ts
47
+ /** Allowed values for the `SameSite` attribute on Neon Auth cookies. */
48
+ type SessionCookieSameSite = 'strict' | 'lax' | 'none';
9
49
  /**
10
50
  * Session cookie configuration
11
51
  */
@@ -41,11 +81,18 @@ interface SessionCookieConfig {
41
81
  * @example '.example.com' // Share across subdomains
42
82
  */
43
83
  domain?: string;
84
+ /**
85
+ * `SameSite` for cookies set or rewritten by the server proxy (API route, middleware, RSC).
86
+ *
87
+ * - **`strict` (default)** — cookies are not sent on cross-site requests (strongest default).
88
+ * - **`lax`** — previous hard-coded behavior; cookies sent on top-level cross-site navigations.
89
+ * - **`none`** — use for third-party contexts (for example your app embedded in another site’s iframe); requires `Secure` (always applied for these cookies).
90
+ *
91
+ * @default 'strict'
92
+ */
93
+ sameSite?: SessionCookieSameSite;
44
94
  }
45
- /**
46
- * Base configuration for Neon Auth server utilities
47
- */
48
- interface NeonAuthConfig {
95
+ type NeonAuthBase = {
49
96
  /**
50
97
  * Base URL for the Neon Auth server
51
98
  * @example 'https://ep-xxxx.neonauth.us-east-1.aws.neon.tech'
@@ -55,18 +102,27 @@ interface NeonAuthConfig {
55
102
  * Cookie configuration
56
103
  */
57
104
  cookies: SessionCookieConfig;
58
- }
105
+ };
59
106
  /**
60
- * Configuration for Neon Auth middleware
61
- * Extends base config with middleware-specific options
107
+ * Base configuration for Neon Auth server utilities.
108
+ *
109
+ * Combines connection settings with {@link NeonAuthLoggingInput} (`logger`, `logLevel`, including `'silent'`).
62
110
  */
63
- interface NeonAuthMiddlewareConfig extends NeonAuthConfig {
111
+ type NeonAuthConfig = NeonAuthBase & NeonAuthLoggingInput;
112
+ /**
113
+ * Configuration for Neon Auth middleware.
114
+ */
115
+ type NeonAuthMiddlewareConfig = NeonAuthConfig & {
64
116
  /**
65
117
  * URL to redirect to when user is not authenticated
66
118
  * @default '/auth/sign-in'
67
119
  */
68
120
  loginUrl?: string;
69
- }
121
+ /**
122
+ * Pre-resolved sink from {@link resolveNeonAuthLogging}. Set by {@link createNeonAuth} so middleware shares the same logging configuration as the API handler without resolving per request.
123
+ */
124
+ log?: ResolvedNeonAuthLogging;
125
+ };
70
126
  //#endregion
71
127
  //#region src/next/server/handler.d.ts
72
128
  type Params = {
@@ -136,6 +192,9 @@ declare function authApiHandler(config: NeonAuthConfig): {
136
192
  * @param config.cookies - Cookie configuration
137
193
  * @param config.cookies.secret - Secret for signing session cookies (minimum 32 characters)
138
194
  * @param config.cookies.sessionDataTtl - Optional TTL for session cache in seconds (default: 300)
195
+ * @param config.logger - Optional structured logger; omitted methods fall back to `console`
196
+ * @param config.logLevel - Minimum log level; `'silent'` disables Neon Auth console output (default: `warn`)
197
+ * @param config.log - Pre-resolved logging sink (set by {@link createNeonAuth})
139
198
  * @param config.loginUrl - The URL to redirect to when the user is not authenticated (default: '/auth/sign-in')
140
199
  * @returns A middleware function that can be used in the Next.js app.
141
200
  * @throws Error if `cookies.secret` is less than 32 characters
@@ -198,6 +257,10 @@ declare const API_ENDPOINTS: {
198
257
  readonly path: "sign-in/email-otp";
199
258
  readonly method: "POST";
200
259
  };
260
+ readonly magicLink: {
261
+ readonly path: "sign-in/magic-link";
262
+ readonly method: "POST";
263
+ };
201
264
  };
202
265
  readonly signUp: {
203
266
  readonly email: {
@@ -419,9 +482,61 @@ declare const API_ENDPOINTS: {
419
482
  readonly method: "POST";
420
483
  };
421
484
  };
485
+ readonly magicLink: {
486
+ readonly verify: {
487
+ readonly path: "magic-link/verify";
488
+ readonly method: "GET";
489
+ };
490
+ };
491
+ };
492
+ //#endregion
493
+ //#region src/server/network-error.d.ts
494
+ /**
495
+ * Classifies failed upstream `fetch` calls for clearer client responses and logs.
496
+ */
497
+ /**
498
+ * Semver-stable transport error codes surfaced as JSON `code` on synthetic HTTP responses
499
+ * (for example 502 from the proxy) and in logs. Treat adding values as non-breaking;
500
+ * renaming or removing values is a breaking change.
501
+ */
502
+ declare const NEON_AUTH_NETWORK_ERROR_CODES: readonly ["NETWORK_ERROR", "NETWORK_DNS", "NETWORK_REFUSED", "NETWORK_TIMEOUT", "NETWORK_TLS", "NETWORK_RESET", "NETWORK_ABORT"];
503
+ /** @see NEON_AUTH_NETWORK_ERROR_CODES */
504
+ type NeonAuthNetworkErrorCode = (typeof NEON_AUTH_NETWORK_ERROR_CODES)[number];
505
+ /**
506
+ * Result of {@link classifyFetchFailure}: a transport failure with a stable
507
+ * {@link NeonAuthNetworkErrorCode}, or an internal/unclassified error (detail for logs only).
508
+ */
509
+ type ClassifiedFetchFailure = {
510
+ kind: 'transport';
511
+ code: NeonAuthNetworkErrorCode;
512
+ /** Safe short detail for logs (no secrets) */
513
+ detail?: string;
514
+ /** Safe message for JSON bodies returned to clients */
515
+ clientMessage: string;
516
+ } | {
517
+ kind: 'internal';
518
+ /** Truncated detail for server-side logs only */
519
+ detail?: string;
520
+ /** Generic message for JSON bodies — never echo raw `Error.message` */
521
+ clientMessage: string;
422
522
  };
523
+ /**
524
+ * Inspects an error from `fetch` (including `cause` and aggregate errors) and
525
+ * returns a stable code for responses and observability.
526
+ */
527
+ declare function classifyFetchFailure(error: unknown): ClassifiedFetchFailure;
423
528
  //#endregion
424
529
  //#region src/server/types.d.ts
530
+ /**
531
+ * Error shape returned from Neon Auth server API helpers (`auth.signIn`, `getSession`, etc.)
532
+ * when the upstream call fails. `code` is a transport code, `'INTERNAL_ERROR'`, or a Better Auth HTTP error code string.
533
+ */
534
+ type NeonAuthServerApiError = {
535
+ message: string;
536
+ status: number;
537
+ statusText: string;
538
+ code: NeonAuthNetworkErrorCode | 'INTERNAL_ERROR' | (string & {});
539
+ };
425
540
  /**
426
541
  * Extract top-level keys from API_ENDPOINTS.
427
542
  * For nested endpoints like signIn.email, this extracts 'signIn' (not 'email').
@@ -454,6 +569,8 @@ type NeonAuthServer = Pick<VanillaBetterAuthClient, ServerAuthMethods>;
454
569
  * @param config.cookies.secret - Secret for signing session cookies (minimum 32 characters)
455
570
  * @param config.cookies.sessionDataTtl - Optional TTL for session cache in seconds (default: 300)
456
571
  * @param config.cookies.domain - Optional cookie domain (default: current domain)
572
+ * @param config.logger - Optional structured logger; omitted methods fall back to `console` (see {@link NeonAuthLogger})
573
+ * @param config.logLevel - Minimum level; `'silent'` disables Neon Auth server console logs (default: `warn`)
457
574
  * @returns Unified auth instance with server methods, handler, and middleware
458
575
  * @throws Error if `cookies.secret` is less than 32 characters
459
576
  *
@@ -533,4 +650,4 @@ type NeonAuth = NeonAuthServer & {
533
650
  middleware: (middlewareConfig?: Pick<NeonAuthMiddlewareConfig, 'loginUrl'>) => ReturnType<typeof neonAuthMiddleware>;
534
651
  };
535
652
  //#endregion
536
- export { NeonAuth, createNeonAuth };
653
+ export { AuthApiError, AuthError, type ClassifiedFetchFailure, NEON_AUTH_NETWORK_ERROR_CODES, NeonAuth, type NeonAuthLogLevel, type NeonAuthLogger, type NeonAuthLoggingInput, type NeonAuthNetworkErrorCode, type NeonAuthServerApiError, type ResolvedNeonAuthLogging, classifyFetchFailure, createNeonAuth, isAuthApiError, isAuthError, resolveNeonAuthLogging };