@neondatabase/auth 0.1.0-beta.17 → 0.1.0-beta.19
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 +84 -12
- package/dist/{adapter-core-Sx7jkLdB.d.mts → adapter-core-CiZ94eSH.d.mts} +25 -26
- package/dist/{adapter-core-BQ6ga1zK.mjs → adapter-core-J65ZBFCQ.mjs} +19 -12
- package/dist/{better-auth-react-adapter-BLKXYcWM.mjs → better-auth-react-adapter-D0YDUhsP.mjs} +1 -1
- package/dist/{better-auth-react-adapter-BWH-XVdf.d.mts → better-auth-react-adapter-f7gIfbP8.d.mts} +8 -8
- package/dist/chunk-VCZJYX65-CLnrj1o7-D6ZQkcc_.mjs +543 -0
- package/dist/{index-B4dy0AqC.d.mts → index-Bga0CzOO.d.mts} +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/dist/{neon-auth-DDPaciiS.d.mts → neon-auth-CjtW9yrE.d.mts} +3 -3
- package/dist/{neon-auth-ClDZNB9a.mjs → neon-auth-D5blqfx_.mjs} +1 -1
- package/dist/next/index.d.mts +9 -9
- package/dist/next/index.mjs +4 -4
- package/dist/next/server/index.d.mts +6 -6
- package/dist/next/server/index.mjs +1 -1
- package/dist/react/adapters/index.d.mts +4 -4
- package/dist/react/adapters/index.mjs +2 -2
- package/dist/react/index.d.mts +5 -5
- package/dist/react/index.mjs +5 -4
- package/dist/react/ui/index.d.mts +1 -1
- package/dist/react/ui/index.mjs +3 -2
- package/dist/react/ui/server.mjs +2 -2
- package/dist/{supabase-adapter-k8RBezY9.d.mts → supabase-adapter-Czd-BqPV.d.mts} +8 -8
- package/dist/{supabase-adapter-Bl576usk.mjs → supabase-adapter-VEBuV-CR.mjs} +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/ui/.safelist.html +1 -1
- package/dist/ui/css.css +2 -2
- package/dist/ui/theme.css +1 -1
- package/dist/ui-Cg1EZzGG.mjs +12104 -0
- package/dist/vanilla/adapters/index.d.mts +4 -4
- package/dist/vanilla/adapters/index.mjs +2 -2
- package/dist/vanilla/index.d.mts +4 -4
- package/dist/vanilla/index.mjs +2 -2
- package/llms.txt +15 -0
- package/package.json +4 -3
- package/dist/ui-DLtIc4wi.mjs +0 -4
- /package/dist/{adapters-CUvhsAvY.mjs → adapters-B7YKkjaL.mjs} +0 -0
- /package/dist/{better-auth-types-Kq3kGuiz.d.mts → better-auth-types-BUiggBfa.d.mts} +0 -0
- /package/dist/{index-D8dPsry7.d.mts → index-BHI9uOzY.d.mts} +0 -0
- /package/dist/{index-D_HDtZfY.d.mts → index-CSe4aQIZ.d.mts} +0 -0
- /package/dist/{index-OEBbnNdr.d.mts → index-LhFpnU-f.d.mts} +0 -0
- /package/dist/{middleware-DPLYghmx.mjs → middleware-C7jHeulu.mjs} +0 -0
package/README.md
CHANGED
|
@@ -23,6 +23,31 @@ This package is designed to work seamlessly with Neon's authentication infrastru
|
|
|
23
23
|
- **Performance optimizations** - Session caching and request deduplication
|
|
24
24
|
- **TypeScript support** - Fully typed with strict type checking
|
|
25
25
|
|
|
26
|
+
## Why @neondatabase/auth?
|
|
27
|
+
|
|
28
|
+
### vs. better-auth/client
|
|
29
|
+
|
|
30
|
+
`@neondatabase/auth` is a wrapper around Better Auth that provides:
|
|
31
|
+
|
|
32
|
+
**API Flexibility:**
|
|
33
|
+
- Multiple adapters (Supabase-compatible, React hooks, vanilla)
|
|
34
|
+
- Restricted options to match Neon Auth capabilities
|
|
35
|
+
|
|
36
|
+
**Neon Auth Integration:**
|
|
37
|
+
- Automatic `token_verifier` on OAuth callback
|
|
38
|
+
- Pre-configured plugins for Neon Auth
|
|
39
|
+
- Automatic JWT extraction from sessions
|
|
40
|
+
- Popup-based OAuth flow for iframes
|
|
41
|
+
|
|
42
|
+
**Built-in Enhancements:**
|
|
43
|
+
- Session caching (60s TTL)
|
|
44
|
+
- Request deduplication
|
|
45
|
+
- Event system
|
|
46
|
+
- Cross-tab sync
|
|
47
|
+
- Token refresh detection
|
|
48
|
+
|
|
49
|
+
If you're not using Neon Auth, you should probably use `better-auth/client` directly for more flexibility.
|
|
50
|
+
|
|
26
51
|
## Installation
|
|
27
52
|
|
|
28
53
|
```bash
|
|
@@ -244,32 +269,79 @@ For Next.js projects, this package provides built-in integration via `@neondatab
|
|
|
244
269
|
- Using `authClient.useSession()` hook in client components
|
|
245
270
|
- Server-side auth operations with `createAuthServer()` from `@neondatabase/auth/next/server`
|
|
246
271
|
|
|
247
|
-
##
|
|
272
|
+
## UI Components
|
|
248
273
|
|
|
249
|
-
|
|
274
|
+
Pre-built login forms and auth pages are included. No extra installation needed.
|
|
250
275
|
|
|
251
|
-
|
|
252
|
-
|--------|----------|
|
|
253
|
-
| `@neondatabase/auth/ui/css` | Pre-built styles (~47KB) |
|
|
254
|
-
| `@neondatabase/auth/ui/tailwind` | Tailwind-ready CSS |
|
|
276
|
+
### 1. Import CSS
|
|
255
277
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
278
|
+
**Without Tailwind CSS:**
|
|
279
|
+
```typescript
|
|
280
|
+
import '@neondatabase/auth/ui/css';
|
|
281
|
+
```
|
|
259
282
|
|
|
260
|
-
|
|
283
|
+
**With Tailwind CSS v4:**
|
|
284
|
+
```css
|
|
261
285
|
@import 'tailwindcss';
|
|
262
286
|
@import '@neondatabase/auth/ui/tailwind';
|
|
263
287
|
```
|
|
264
288
|
|
|
289
|
+
### 2. Setup Provider
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
"use client"
|
|
293
|
+
|
|
294
|
+
import { NeonAuthUIProvider } from "@neondatabase/auth/react/ui"
|
|
295
|
+
import { createAuthClient } from "@neondatabase/auth"
|
|
296
|
+
import "@neondatabase/auth/ui/css"
|
|
297
|
+
|
|
298
|
+
const authClient = createAuthClient('https://your-auth-url.com')
|
|
299
|
+
|
|
300
|
+
export function AuthProvider({ children }) {
|
|
301
|
+
return (
|
|
302
|
+
<NeonAuthUIProvider authClient={authClient} redirectTo="/dashboard">
|
|
303
|
+
{children}
|
|
304
|
+
</NeonAuthUIProvider>
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### 3. Use Components
|
|
310
|
+
|
|
311
|
+
**Option A: Full Auth Pages (Recommended)**
|
|
312
|
+
|
|
313
|
+
Use `AuthView` to render complete auth flows based on the URL path:
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
import { AuthView } from "@neondatabase/auth/react/ui"
|
|
317
|
+
|
|
318
|
+
// Renders sign-in, sign-up, forgot-password, etc. based on path
|
|
319
|
+
<AuthView path="sign-in" />
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**Option B: Individual Components**
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
import { SignInForm, UserButton } from "@neondatabase/auth/react/ui"
|
|
326
|
+
|
|
327
|
+
<SignInForm />
|
|
328
|
+
<UserButton />
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Available components: `SignInForm`, `SignUpForm`, `UserButton`, `AuthView`, `AccountView`, `OrganizationView`
|
|
332
|
+
|
|
333
|
+
For Next.js with dynamic routes, see the [Next.js Setup Guide](./NEXT-JS.md).
|
|
334
|
+
|
|
335
|
+
For full documentation and theming, see [`@neondatabase/auth-ui`](../auth-ui).
|
|
336
|
+
|
|
265
337
|
## Related Packages
|
|
266
338
|
|
|
267
339
|
- [`@neondatabase/neon-js`](../neon-js) - Full SDK with database and auth integration
|
|
268
|
-
- [`@neondatabase/postgrest-js`](../postgrest-js) -
|
|
340
|
+
- [`@neondatabase/postgrest-js`](../postgrest-js) - PostgREST client without auth
|
|
269
341
|
|
|
270
342
|
## Resources
|
|
271
343
|
|
|
272
|
-
- [Neon Auth Documentation](https://neon.
|
|
344
|
+
- [Neon Auth Documentation](https://neon.com/docs/neon-auth)
|
|
273
345
|
- [Better Auth Documentation](https://www.better-auth.com/docs)
|
|
274
346
|
|
|
275
347
|
## Support
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { createAuthClient } from "better-auth/react";
|
|
2
2
|
import * as better_auth_client23 from "better-auth/client";
|
|
3
3
|
import { BetterAuthClientOptions, createAuthClient as createAuthClient$1 } from "better-auth/client";
|
|
4
|
-
import * as better_auth_client_plugins11 from "better-auth/client/plugins";
|
|
5
4
|
import * as zod0 from "zod";
|
|
6
5
|
import * as jose1 from "jose";
|
|
7
6
|
import * as better_auth303 from "better-auth";
|
|
8
7
|
import * as _better_fetch_fetch177 from "@better-fetch/fetch";
|
|
9
8
|
import { BetterFetchError as BetterFetchError$1 } from "@better-fetch/fetch";
|
|
9
|
+
import * as better_auth_plugins11 from "better-auth/plugins";
|
|
10
10
|
import * as nanostores1 from "nanostores";
|
|
11
11
|
import * as better_call0 from "better-call";
|
|
12
|
-
import * as better_auth_plugins_email_otp0 from "better-auth/plugins/email-otp";
|
|
13
|
-
import { EmailOTPOptions } from "better-auth/plugins/email-otp";
|
|
14
12
|
import { Invitation, InvitationInput, InvitationStatus, Member, MemberInput, Organization, OrganizationInput, OrganizationRole, Team, TeamInput, TeamMember, TeamMemberInput } from "better-auth/plugins/organization";
|
|
15
13
|
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions } from "better-auth/plugins/jwt";
|
|
16
14
|
import { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole } from "better-auth/plugins/admin";
|
|
15
|
+
import { EmailOTPOptions } from "better-auth/plugins/email-otp";
|
|
17
16
|
|
|
18
17
|
//#region src/types/index.d.ts
|
|
19
18
|
type BetterAuthInstance = ReturnType<typeof createAuthClient$1<{
|
|
@@ -47,9 +46,9 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
47
46
|
};
|
|
48
47
|
} | {
|
|
49
48
|
id: "better-auth-client";
|
|
50
|
-
$InferServerPlugin: ReturnType<(options?:
|
|
49
|
+
$InferServerPlugin: ReturnType<(options?: better_auth_plugins11.JwtOptions | undefined) => {
|
|
51
50
|
id: "jwt";
|
|
52
|
-
options:
|
|
51
|
+
options: better_auth_plugins11.JwtOptions | undefined;
|
|
53
52
|
endpoints: {
|
|
54
53
|
getJwks: better_call0.StrictEndpoint<string, {
|
|
55
54
|
method: "GET";
|
|
@@ -191,7 +190,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
191
190
|
$Infer: {
|
|
192
191
|
body: {
|
|
193
192
|
payload: jose1.JWTPayload;
|
|
194
|
-
overrideOptions?:
|
|
193
|
+
overrideOptions?: better_auth_plugins11.JwtOptions | undefined;
|
|
195
194
|
};
|
|
196
195
|
};
|
|
197
196
|
};
|
|
@@ -328,7 +327,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
328
327
|
hooks: {
|
|
329
328
|
after: {
|
|
330
329
|
matcher(context: better_auth303.HookEndpointContext): boolean;
|
|
331
|
-
handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<
|
|
330
|
+
handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<better_auth_plugins11.SessionWithImpersonatedBy[] | undefined>;
|
|
332
331
|
}[];
|
|
333
332
|
};
|
|
334
333
|
endpoints: {
|
|
@@ -341,7 +340,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
341
340
|
requireHeaders: true;
|
|
342
341
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
343
342
|
session: {
|
|
344
|
-
user:
|
|
343
|
+
user: better_auth_plugins11.UserWithRole;
|
|
345
344
|
session: better_auth303.Session;
|
|
346
345
|
};
|
|
347
346
|
}>)[];
|
|
@@ -378,7 +377,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
378
377
|
} & {
|
|
379
378
|
use: any[];
|
|
380
379
|
}, {
|
|
381
|
-
user:
|
|
380
|
+
user: better_auth_plugins11.UserWithRole;
|
|
382
381
|
}>;
|
|
383
382
|
getUser: better_call0.StrictEndpoint<"/admin/get-user", {
|
|
384
383
|
method: "GET";
|
|
@@ -387,7 +386,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
387
386
|
}, better_auth303.$strip>;
|
|
388
387
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
389
388
|
session: {
|
|
390
|
-
user:
|
|
389
|
+
user: better_auth_plugins11.UserWithRole;
|
|
391
390
|
session: better_auth303.Session;
|
|
392
391
|
};
|
|
393
392
|
}>)[];
|
|
@@ -471,7 +470,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
471
470
|
} & {
|
|
472
471
|
use: any[];
|
|
473
472
|
}, {
|
|
474
|
-
user:
|
|
473
|
+
user: better_auth_plugins11.UserWithRole;
|
|
475
474
|
}>;
|
|
476
475
|
adminUpdateUser: better_call0.StrictEndpoint<"/admin/update-user", {
|
|
477
476
|
method: "POST";
|
|
@@ -481,7 +480,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
481
480
|
}, better_auth303.$strip>;
|
|
482
481
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
483
482
|
session: {
|
|
484
|
-
user:
|
|
483
|
+
user: better_auth_plugins11.UserWithRole;
|
|
485
484
|
session: better_auth303.Session;
|
|
486
485
|
};
|
|
487
486
|
}>)[];
|
|
@@ -511,12 +510,12 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
511
510
|
};
|
|
512
511
|
} & {
|
|
513
512
|
use: any[];
|
|
514
|
-
},
|
|
513
|
+
}, better_auth_plugins11.UserWithRole>;
|
|
515
514
|
listUsers: better_call0.StrictEndpoint<"/admin/list-users", {
|
|
516
515
|
method: "GET";
|
|
517
516
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
518
517
|
session: {
|
|
519
|
-
user:
|
|
518
|
+
user: better_auth_plugins11.UserWithRole;
|
|
520
519
|
session: better_auth303.Session;
|
|
521
520
|
};
|
|
522
521
|
}>)[];
|
|
@@ -590,7 +589,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
590
589
|
} & {
|
|
591
590
|
use: any[];
|
|
592
591
|
}, {
|
|
593
|
-
users:
|
|
592
|
+
users: better_auth_plugins11.UserWithRole[];
|
|
594
593
|
total: number;
|
|
595
594
|
limit: number | undefined;
|
|
596
595
|
offset: number | undefined;
|
|
@@ -602,7 +601,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
602
601
|
method: "POST";
|
|
603
602
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
604
603
|
session: {
|
|
605
|
-
user:
|
|
604
|
+
user: better_auth_plugins11.UserWithRole;
|
|
606
605
|
session: better_auth303.Session;
|
|
607
606
|
};
|
|
608
607
|
}>)[];
|
|
@@ -639,7 +638,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
639
638
|
} & {
|
|
640
639
|
use: any[];
|
|
641
640
|
}, {
|
|
642
|
-
sessions:
|
|
641
|
+
sessions: better_auth_plugins11.SessionWithImpersonatedBy[];
|
|
643
642
|
}>;
|
|
644
643
|
unbanUser: better_call0.StrictEndpoint<"/admin/unban-user", {
|
|
645
644
|
method: "POST";
|
|
@@ -648,7 +647,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
648
647
|
}, better_auth303.$strip>;
|
|
649
648
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
650
649
|
session: {
|
|
651
|
-
user:
|
|
650
|
+
user: better_auth_plugins11.UserWithRole;
|
|
652
651
|
session: better_auth303.Session;
|
|
653
652
|
};
|
|
654
653
|
}>)[];
|
|
@@ -698,7 +697,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
698
697
|
}, better_auth303.$strip>;
|
|
699
698
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
700
699
|
session: {
|
|
701
|
-
user:
|
|
700
|
+
user: better_auth_plugins11.UserWithRole;
|
|
702
701
|
session: better_auth303.Session;
|
|
703
702
|
};
|
|
704
703
|
}>)[];
|
|
@@ -746,7 +745,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
746
745
|
}, better_auth303.$strip>;
|
|
747
746
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
748
747
|
session: {
|
|
749
|
-
user:
|
|
748
|
+
user: better_auth_plugins11.UserWithRole;
|
|
750
749
|
session: better_auth303.Session;
|
|
751
750
|
};
|
|
752
751
|
}>)[];
|
|
@@ -790,7 +789,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
790
789
|
ipAddress?: string | null | undefined;
|
|
791
790
|
userAgent?: string | null | undefined;
|
|
792
791
|
};
|
|
793
|
-
user:
|
|
792
|
+
user: better_auth_plugins11.UserWithRole;
|
|
794
793
|
}>;
|
|
795
794
|
stopImpersonating: better_call0.StrictEndpoint<"/admin/stop-impersonating", {
|
|
796
795
|
method: "POST";
|
|
@@ -808,7 +807,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
808
807
|
}, better_auth303.$strip>;
|
|
809
808
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
810
809
|
session: {
|
|
811
|
-
user:
|
|
810
|
+
user: better_auth_plugins11.UserWithRole;
|
|
812
811
|
session: better_auth303.Session;
|
|
813
812
|
};
|
|
814
813
|
}>)[];
|
|
@@ -848,7 +847,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
848
847
|
}, better_auth303.$strip>;
|
|
849
848
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
850
849
|
session: {
|
|
851
|
-
user:
|
|
850
|
+
user: better_auth_plugins11.UserWithRole;
|
|
852
851
|
session: better_auth303.Session;
|
|
853
852
|
};
|
|
854
853
|
}>)[];
|
|
@@ -888,7 +887,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
888
887
|
}, better_auth303.$strip>;
|
|
889
888
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
890
889
|
session: {
|
|
891
|
-
user:
|
|
890
|
+
user: better_auth_plugins11.UserWithRole;
|
|
892
891
|
session: better_auth303.Session;
|
|
893
892
|
};
|
|
894
893
|
}>)[];
|
|
@@ -929,7 +928,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
929
928
|
}, better_auth303.$strip>;
|
|
930
929
|
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
931
930
|
session: {
|
|
932
|
-
user:
|
|
931
|
+
user: better_auth_plugins11.UserWithRole;
|
|
933
932
|
session: better_auth303.Session;
|
|
934
933
|
};
|
|
935
934
|
}>)[];
|
|
@@ -1384,7 +1383,7 @@ declare const supportedBetterAuthClientPlugins: ({
|
|
|
1384
1383
|
})[];
|
|
1385
1384
|
} | {
|
|
1386
1385
|
id: "email-otp";
|
|
1387
|
-
$InferServerPlugin: ReturnType<(options:
|
|
1386
|
+
$InferServerPlugin: ReturnType<(options: better_auth_plugins11.EmailOTPOptions) => {
|
|
1388
1387
|
id: "email-otp";
|
|
1389
1388
|
init(ctx: better_auth303.AuthContext): {
|
|
1390
1389
|
options: {
|
|
@@ -440,7 +440,7 @@ const BETTER_AUTH_METHODS_HOOKS = {
|
|
|
440
440
|
}
|
|
441
441
|
},
|
|
442
442
|
signIn: {
|
|
443
|
-
|
|
443
|
+
beforeFetch: (input, init) => {
|
|
444
444
|
if (!(typeof input === "string" ? input : input.toString()).includes("/sign-in/social") || !isIframe()) return null;
|
|
445
445
|
return handleSocialSignInViaPopup(input, init);
|
|
446
446
|
},
|
|
@@ -472,17 +472,24 @@ const BETTER_AUTH_METHODS_HOOKS = {
|
|
|
472
472
|
updateUser: {
|
|
473
473
|
onRequest: () => {},
|
|
474
474
|
onSuccess: (responseData) => {
|
|
475
|
-
if (isSessionResponseData(responseData))
|
|
476
|
-
|
|
477
|
-
data: {
|
|
475
|
+
if (isSessionResponseData(responseData)) {
|
|
476
|
+
const sessionData = {
|
|
478
477
|
session: responseData.session,
|
|
479
478
|
user: responseData.user
|
|
480
|
-
}
|
|
481
|
-
|
|
479
|
+
};
|
|
480
|
+
BETTER_AUTH_METHODS_CACHE.setCachedSession(sessionData);
|
|
481
|
+
emitAuthEvent({
|
|
482
|
+
type: "USER_UPDATE",
|
|
483
|
+
data: sessionData
|
|
484
|
+
});
|
|
485
|
+
} else {
|
|
486
|
+
BETTER_AUTH_METHODS_CACHE.clearSessionCache();
|
|
487
|
+
emitAuthEvent({ type: "USER_UPDATE" });
|
|
488
|
+
}
|
|
482
489
|
}
|
|
483
490
|
},
|
|
484
491
|
getSession: {
|
|
485
|
-
|
|
492
|
+
beforeFetch: () => {
|
|
486
493
|
const cachedData = BETTER_AUTH_METHODS_CACHE.getCachedSession();
|
|
487
494
|
if (!cachedData) return null;
|
|
488
495
|
return Response.json(cachedData, { status: 200 });
|
|
@@ -522,7 +529,7 @@ const BETTER_AUTH_METHODS_HOOKS = {
|
|
|
522
529
|
}
|
|
523
530
|
},
|
|
524
531
|
anonymousToken: {
|
|
525
|
-
|
|
532
|
+
beforeFetch: () => {
|
|
526
533
|
const cachedResponse = BETTER_AUTH_ANONYMOUS_TOKEN_CACHE.getCachedResponse();
|
|
527
534
|
if (!cachedResponse) return null;
|
|
528
535
|
return Response.json(cachedResponse, { status: 200 });
|
|
@@ -651,9 +658,9 @@ var NeonAuthAdapterCore = class {
|
|
|
651
658
|
userOnRequest?.(request);
|
|
652
659
|
},
|
|
653
660
|
customFetchImpl: async (url, init) => {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
delete
|
|
661
|
+
const headers = new Headers(init?.headers);
|
|
662
|
+
if (headers.has(FORCE_FETCH_HEADER)) {
|
|
663
|
+
headers.delete(FORCE_FETCH_HEADER);
|
|
657
664
|
const response$1 = await fetch(url, {
|
|
658
665
|
...init,
|
|
659
666
|
headers
|
|
@@ -669,7 +676,7 @@ var NeonAuthAdapterCore = class {
|
|
|
669
676
|
}
|
|
670
677
|
const betterAuthMethod = deriveBetterAuthMethodFromUrl(url.toString());
|
|
671
678
|
if (betterAuthMethod) {
|
|
672
|
-
const response$1 = await BETTER_AUTH_METHODS_HOOKS[betterAuthMethod].
|
|
679
|
+
const response$1 = await BETTER_AUTH_METHODS_HOOKS[betterAuthMethod].beforeFetch?.(url, init);
|
|
673
680
|
if (response$1) return response$1;
|
|
674
681
|
}
|
|
675
682
|
const key = `${init?.method || "GET"}:${url}:${init?.body || ""}`;
|
package/dist/{better-auth-react-adapter-BLKXYcWM.mjs → better-auth-react-adapter-D0YDUhsP.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as NeonAuthAdapterCore } from "./adapter-core-
|
|
1
|
+
import { t as NeonAuthAdapterCore } from "./adapter-core-J65ZBFCQ.mjs";
|
|
2
2
|
import { createAuthClient } from "better-auth/react";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/better-auth-react/better-auth-react-adapter.ts
|
package/dist/{better-auth-react-adapter-BWH-XVdf.d.mts → better-auth-react-adapter-f7gIfbP8.d.mts}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as NeonAuthAdapterCoreAuthOptions, t as NeonAuthAdapterCore } from "./adapter-core-
|
|
1
|
+
import { n as NeonAuthAdapterCoreAuthOptions, t as NeonAuthAdapterCore } from "./adapter-core-CiZ94eSH.mjs";
|
|
2
2
|
import * as better_auth_client11 from "better-auth/client";
|
|
3
|
-
import * as better_auth_client_plugins5 from "better-auth/client/plugins";
|
|
4
3
|
import * as jose0 from "jose";
|
|
5
4
|
import * as better_auth151 from "better-auth";
|
|
6
5
|
import * as _better_fetch_fetch88 from "@better-fetch/fetch";
|
|
6
|
+
import * as better_auth_plugins5 from "better-auth/plugins";
|
|
7
7
|
import * as nanostores0 from "nanostores";
|
|
8
8
|
|
|
9
9
|
//#region src/adapters/better-auth-react/better-auth-react-adapter.d.ts
|
|
@@ -118,7 +118,7 @@ declare class BetterAuthReactAdapterImpl extends NeonAuthAdapterCore {
|
|
|
118
118
|
} & {
|
|
119
119
|
fetchOptions?: FetchOptions | undefined;
|
|
120
120
|
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch88.BetterFetchResponse<{
|
|
121
|
-
user:
|
|
121
|
+
user: better_auth_plugins5.UserWithRole;
|
|
122
122
|
}, {
|
|
123
123
|
code?: string | undefined;
|
|
124
124
|
message?: string | undefined;
|
|
@@ -163,7 +163,7 @@ declare class BetterAuthReactAdapterImpl extends NeonAuthAdapterCore {
|
|
|
163
163
|
} & {
|
|
164
164
|
fetchOptions?: FetchOptions | undefined;
|
|
165
165
|
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch88.BetterFetchResponse<{
|
|
166
|
-
user:
|
|
166
|
+
user: better_auth_plugins5.UserWithRole;
|
|
167
167
|
}, {
|
|
168
168
|
code?: string | undefined;
|
|
169
169
|
message?: string | undefined;
|
|
@@ -179,7 +179,7 @@ declare class BetterAuthReactAdapterImpl extends NeonAuthAdapterCore {
|
|
|
179
179
|
data: Record<any, any>;
|
|
180
180
|
} & {
|
|
181
181
|
fetchOptions?: FetchOptions | undefined;
|
|
182
|
-
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch88.BetterFetchResponse<
|
|
182
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch88.BetterFetchResponse<better_auth_plugins5.UserWithRole, {
|
|
183
183
|
code?: string | undefined;
|
|
184
184
|
message?: string | undefined;
|
|
185
185
|
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
@@ -212,7 +212,7 @@ declare class BetterAuthReactAdapterImpl extends NeonAuthAdapterCore {
|
|
|
212
212
|
};
|
|
213
213
|
fetchOptions?: FetchOptions | undefined;
|
|
214
214
|
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch88.BetterFetchResponse<NonNullable<{
|
|
215
|
-
users:
|
|
215
|
+
users: better_auth_plugins5.UserWithRole[];
|
|
216
216
|
total: number;
|
|
217
217
|
limit: number | undefined;
|
|
218
218
|
offset: number | undefined;
|
|
@@ -233,7 +233,7 @@ declare class BetterAuthReactAdapterImpl extends NeonAuthAdapterCore {
|
|
|
233
233
|
} & {
|
|
234
234
|
fetchOptions?: FetchOptions | undefined;
|
|
235
235
|
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch88.BetterFetchResponse<{
|
|
236
|
-
sessions:
|
|
236
|
+
sessions: better_auth_plugins5.SessionWithImpersonatedBy[];
|
|
237
237
|
}, {
|
|
238
238
|
code?: string | undefined;
|
|
239
239
|
message?: string | undefined;
|
|
@@ -308,7 +308,7 @@ declare class BetterAuthReactAdapterImpl extends NeonAuthAdapterCore {
|
|
|
308
308
|
ipAddress?: string | null | undefined;
|
|
309
309
|
userAgent?: string | null | undefined;
|
|
310
310
|
};
|
|
311
|
-
user:
|
|
311
|
+
user: better_auth_plugins5.UserWithRole;
|
|
312
312
|
}, {
|
|
313
313
|
code?: string | undefined;
|
|
314
314
|
message?: string | undefined;
|