@neondatabase/auth 0.4.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.
- package/dist/{adapter-core-Bt4M5I2g.mjs → adapter-core-BFMM3lwe.mjs} +1 -1
- package/dist/{adapter-core-BWM7cWOp.d.mts → adapter-core-ClY-p_AI.d.mts} +159 -159
- package/dist/{better-auth-react-adapter-aMv8WeDb.mjs → better-auth-react-adapter-DZTZVVnk.mjs} +1 -1
- package/dist/{supabase-adapter-BGwV0Vu2.d.mts → better-auth-react-adapter-iJMZCLUI.d.mts} +367 -424
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/{neon-auth-CS4FpK2X.mjs → neon-auth-VDrC3GwX.mjs} +1 -1
- package/dist/next/index.mjs +3 -3
- package/dist/next/server/index.d.mts +108 -13
- package/dist/next/server/index.mjs +351 -31
- package/dist/react/adapters/index.d.mts +2 -2
- package/dist/react/adapters/index.mjs +2 -2
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.mjs +2 -2
- package/dist/{supabase-adapter-DBt4LJJd.mjs → supabase-adapter-CAyBFrNn.mjs} +1 -1
- package/dist/{better-auth-react-adapter-BDxJ65mF.d.mts → supabase-adapter-cuLnmLDs.d.mts} +176 -119
- package/dist/types/index.d.mts +1 -1
- package/dist/vanilla/adapters/index.d.mts +2 -2
- package/dist/vanilla/adapters/index.mjs +2 -2
- package/dist/vanilla/index.d.mts +2 -2
- package/dist/vanilla/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ReactBetterAuthClient, k as VanillaBetterAuthClient } from "./adapter-core-
|
|
2
|
-
import { n as BetterAuthReactAdapterInstance } from "./better-auth-react-adapter-
|
|
3
|
-
import { r as SupabaseAuthAdapterInstance, s as BetterAuthVanillaAdapterInstance } from "./supabase-adapter-
|
|
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
4
|
import { a as isAuthError, i as isAuthApiError, n as AuthError, t as AuthApiError } from "./auth-interface-Clz-oWq1.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/neon-auth.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./adapter-core-
|
|
1
|
+
import "./adapter-core-BFMM3lwe.mjs";
|
|
2
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-
|
|
3
|
+
import { n as createInternalNeonAuth, t as createAuthClient } from "./neon-auth-VDrC3GwX.mjs";
|
|
4
4
|
|
|
5
5
|
export { AuthApiError, AuthError, createAuthClient, createInternalNeonAuth, isAuthApiError, isAuthError };
|
package/dist/next/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../adapter-core-
|
|
1
|
+
import "../adapter-core-BFMM3lwe.mjs";
|
|
2
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-
|
|
4
|
-
import { t as createAuthClient$1 } from "../neon-auth-
|
|
3
|
+
import { t as BetterAuthReactAdapter } from "../better-auth-react-adapter-DZTZVVnk.mjs";
|
|
4
|
+
import { t as createAuthClient$1 } from "../neon-auth-VDrC3GwX.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/next/index.ts
|
|
7
7
|
function createAuthClient() {
|
|
@@ -1,11 +1,49 @@
|
|
|
1
|
-
import { k as VanillaBetterAuthClient } from "../../adapter-core-
|
|
1
|
+
import { k as VanillaBetterAuthClient } from "../../adapter-core-ClY-p_AI.mjs";
|
|
2
2
|
import { a as isAuthError, i as isAuthApiError, n as AuthError, t as AuthApiError } from "../../auth-interface-Clz-oWq1.mjs";
|
|
3
3
|
import { NextRequest, NextResponse } from "next/server";
|
|
4
4
|
|
|
5
|
-
//#region src/server/
|
|
5
|
+
//#region src/server/logger.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Framework-agnostic logging for Neon Auth server-side proxy and middleware.
|
|
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
|
+
};
|
|
6
38
|
/**
|
|
7
|
-
*
|
|
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.
|
|
8
43
|
*/
|
|
44
|
+
declare function resolveNeonAuthLogging(input?: NeonAuthLoggingInput): ResolvedNeonAuthLogging;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/server/config.d.ts
|
|
9
47
|
/** Allowed values for the `SameSite` attribute on Neon Auth cookies. */
|
|
10
48
|
type SessionCookieSameSite = 'strict' | 'lax' | 'none';
|
|
11
49
|
/**
|
|
@@ -54,10 +92,7 @@ interface SessionCookieConfig {
|
|
|
54
92
|
*/
|
|
55
93
|
sameSite?: SessionCookieSameSite;
|
|
56
94
|
}
|
|
57
|
-
|
|
58
|
-
* Base configuration for Neon Auth server utilities
|
|
59
|
-
*/
|
|
60
|
-
interface NeonAuthConfig {
|
|
95
|
+
type NeonAuthBase = {
|
|
61
96
|
/**
|
|
62
97
|
* Base URL for the Neon Auth server
|
|
63
98
|
* @example 'https://ep-xxxx.neonauth.us-east-1.aws.neon.tech'
|
|
@@ -67,18 +102,27 @@ interface NeonAuthConfig {
|
|
|
67
102
|
* Cookie configuration
|
|
68
103
|
*/
|
|
69
104
|
cookies: SessionCookieConfig;
|
|
70
|
-
}
|
|
105
|
+
};
|
|
71
106
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
107
|
+
* Base configuration for Neon Auth server utilities.
|
|
108
|
+
*
|
|
109
|
+
* Combines connection settings with {@link NeonAuthLoggingInput} (`logger`, `logLevel`, including `'silent'`).
|
|
74
110
|
*/
|
|
75
|
-
|
|
111
|
+
type NeonAuthConfig = NeonAuthBase & NeonAuthLoggingInput;
|
|
112
|
+
/**
|
|
113
|
+
* Configuration for Neon Auth middleware.
|
|
114
|
+
*/
|
|
115
|
+
type NeonAuthMiddlewareConfig = NeonAuthConfig & {
|
|
76
116
|
/**
|
|
77
117
|
* URL to redirect to when user is not authenticated
|
|
78
118
|
* @default '/auth/sign-in'
|
|
79
119
|
*/
|
|
80
120
|
loginUrl?: string;
|
|
81
|
-
|
|
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
|
+
};
|
|
82
126
|
//#endregion
|
|
83
127
|
//#region src/next/server/handler.d.ts
|
|
84
128
|
type Params = {
|
|
@@ -148,6 +192,9 @@ declare function authApiHandler(config: NeonAuthConfig): {
|
|
|
148
192
|
* @param config.cookies - Cookie configuration
|
|
149
193
|
* @param config.cookies.secret - Secret for signing session cookies (minimum 32 characters)
|
|
150
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})
|
|
151
198
|
* @param config.loginUrl - The URL to redirect to when the user is not authenticated (default: '/auth/sign-in')
|
|
152
199
|
* @returns A middleware function that can be used in the Next.js app.
|
|
153
200
|
* @throws Error if `cookies.secret` is less than 32 characters
|
|
@@ -443,7 +490,53 @@ declare const API_ENDPOINTS: {
|
|
|
443
490
|
};
|
|
444
491
|
};
|
|
445
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;
|
|
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;
|
|
528
|
+
//#endregion
|
|
446
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
|
+
};
|
|
447
540
|
/**
|
|
448
541
|
* Extract top-level keys from API_ENDPOINTS.
|
|
449
542
|
* For nested endpoints like signIn.email, this extracts 'signIn' (not 'email').
|
|
@@ -476,6 +569,8 @@ type NeonAuthServer = Pick<VanillaBetterAuthClient, ServerAuthMethods>;
|
|
|
476
569
|
* @param config.cookies.secret - Secret for signing session cookies (minimum 32 characters)
|
|
477
570
|
* @param config.cookies.sessionDataTtl - Optional TTL for session cache in seconds (default: 300)
|
|
478
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`)
|
|
479
574
|
* @returns Unified auth instance with server methods, handler, and middleware
|
|
480
575
|
* @throws Error if `cookies.secret` is less than 32 characters
|
|
481
576
|
*
|
|
@@ -555,4 +650,4 @@ type NeonAuth = NeonAuthServer & {
|
|
|
555
650
|
middleware: (middlewareConfig?: Pick<NeonAuthMiddlewareConfig, 'loginUrl'>) => ReturnType<typeof neonAuthMiddleware>;
|
|
556
651
|
};
|
|
557
652
|
//#endregion
|
|
558
|
-
export { AuthApiError, AuthError, NeonAuth, createNeonAuth, isAuthApiError, isAuthError };
|
|
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 };
|