@neondatabase/auth 0.2.0-beta.1 → 0.4.0-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 (44) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +22 -7
  3. package/codemods/migrate-auth-ui-imports.mjs +439 -0
  4. package/dist/{adapter-core-CnrOXh1T.d.mts → adapter-core-BWM7cWOp.d.mts} +465 -401
  5. package/dist/{adapter-core-CtmnMMJ7.mjs → adapter-core-Bt4M5I2g.mjs} +21 -11
  6. package/dist/auth-interface-Clz-oWq1.d.mts +8 -0
  7. package/dist/better-auth-helpers-Bkezghej.mjs +541 -0
  8. package/dist/{better-auth-react-adapter-DNi5PC5D.d.mts → better-auth-react-adapter-BDxJ65mF.d.mts} +389 -302
  9. package/dist/{better-auth-react-adapter-Dv-o6A6O.mjs → better-auth-react-adapter-aMv8WeDb.mjs} +1 -1
  10. package/dist/{index-CzsGMS7C.d.mts → index-DHryUj7e.d.mts} +0 -1
  11. package/dist/index.d.mts +94 -5
  12. package/dist/index.mjs +4 -3
  13. package/dist/{neon-auth-Cs2cWh1B.mjs → neon-auth-CS4FpK2X.mjs} +1 -1
  14. package/dist/next/index.d.mts +161 -73
  15. package/dist/next/index.mjs +5 -4
  16. package/dist/next/server/index.d.mts +25 -5
  17. package/dist/next/server/index.mjs +369 -251
  18. package/dist/react/adapters/index.d.mts +3 -3
  19. package/dist/react/adapters/index.mjs +2 -2
  20. package/dist/react/index.d.mts +6 -5
  21. package/dist/react/index.mjs +5 -5
  22. package/dist/react/ui/index.d.mts +1 -2
  23. package/dist/react/ui/index.mjs +2 -4
  24. package/dist/react/ui/server.mjs +2 -2
  25. package/dist/{supabase-adapter-DUqw2fw8.d.mts → supabase-adapter-BGwV0Vu2.d.mts} +429 -373
  26. package/dist/{supabase-adapter-BlcGPyOf.mjs → supabase-adapter-DBt4LJJd.mjs} +3 -514
  27. package/dist/types/index.d.mts +2 -2
  28. package/dist/ui/.safelist.html +1 -1
  29. package/dist/ui/css.css +2 -2
  30. package/dist/ui/theme.css +1 -1
  31. package/dist/ui-CnVnqGns.mjs +3 -0
  32. package/dist/vanilla/adapters/index.d.mts +4 -3
  33. package/dist/vanilla/adapters/index.mjs +2 -2
  34. package/dist/vanilla/index.d.mts +4 -3
  35. package/dist/vanilla/index.mjs +2 -2
  36. package/llms.txt +2 -2
  37. package/package.json +27 -21
  38. package/dist/chunk-VCZJYX65-CLnrj1o7-D6ZQkcc_.mjs +0 -543
  39. package/dist/constants-Cupc_bln.mjs +0 -28
  40. package/dist/neon-auth-BEGCfAe6.d.mts +0 -107
  41. package/dist/ui-COLWzDsu.mjs +0 -12469
  42. /package/dist/{adapters-B7YKkjaL.mjs → adapters-CUvhsAvY.mjs} +0 -0
  43. /package/dist/{index-CPnFzULh.d.mts → index-B0Pd4HOH.d.mts} +0 -0
  44. /package/dist/{index-OEBbnNdr.d.mts → index-CzpoWrv9.d.mts} +0 -0
@@ -1,107 +0,0 @@
1
- import { r as SupportedBetterAuthClientPlugins } from "./adapter-core-CnrOXh1T.mjs";
2
- import { n as BetterAuthReactAdapterInstance } from "./better-auth-react-adapter-DNi5PC5D.mjs";
3
- import { r as SupabaseAuthAdapterInstance, s as BetterAuthVanillaAdapterInstance } from "./supabase-adapter-DUqw2fw8.mjs";
4
- import { createAuthClient } from "better-auth/react";
5
- import { createAuthClient as createAuthClient$1 } from "better-auth/client";
6
-
7
- //#region src/neon-auth.d.ts
8
-
9
- /**
10
- * Type representing the Better Auth React client
11
- */
12
- type ReactBetterAuthClient = ReturnType<typeof createAuthClient<{
13
- plugins: SupportedBetterAuthClientPlugins;
14
- }>>;
15
- /**
16
- * Type representing the Better Auth Vanilla client
17
- */
18
- type VanillaBetterAuthClient = ReturnType<typeof createAuthClient$1<{
19
- plugins: SupportedBetterAuthClientPlugins;
20
- }>>;
21
- /**
22
- * Union type of all supported auth adapter instances
23
- */
24
- type NeonAuthAdapter = BetterAuthVanillaAdapterInstance | BetterAuthReactAdapterInstance | SupabaseAuthAdapterInstance;
25
- /**
26
- * Configuration for createAuthClient
27
- */
28
- interface NeonAuthConfig<T extends NeonAuthAdapter> {
29
- /** The adapter builder to use. Defaults to BetterAuthVanillaAdapter() if not specified. */
30
- adapter?: (url: string, fetchOptions?: {
31
- headers?: Record<string, string>;
32
- }) => T;
33
- /**
34
- * When true, automatically uses an anonymous token when no user session exists.
35
- * This enables RLS-based data access for users with the anonymous role.
36
- * @default false
37
- */
38
- allowAnonymous?: boolean;
39
- }
40
- /**
41
- * Resolves the public API type for an adapter.
42
- * - SupabaseAuthAdapter: exposes its own methods directly (Supabase-compatible API)
43
- * - BetterAuth adapters: expose the Better Auth client directly
44
- */
45
- type NeonAuthPublicApi<T extends NeonAuthAdapter> = T extends BetterAuthVanillaAdapterInstance ? VanillaBetterAuthClient : T extends BetterAuthReactAdapterInstance ? ReactBetterAuthClient : T;
46
- /**
47
- * NeonAuth type - combines base functionality with the appropriate public API
48
- * This is the return type of createAuthClient()
49
- *
50
- * For SupabaseAuthAdapter: exposes Supabase-compatible methods (signInWithPassword, getSession, etc.)
51
- * For BetterAuth adapters: exposes the Better Auth client directly (signIn.email, signUp.email, etc.)
52
- */
53
- type NeonAuth<T extends NeonAuthAdapter> = {
54
- adapter: NeonAuthPublicApi<T>;
55
- getJWTToken: () => Promise<string | null>;
56
- };
57
- /**
58
- * Create a NeonAuth instance that exposes the appropriate API based on the adapter.
59
- *
60
- * @param url - The auth service URL (e.g., 'https://auth.example.com')
61
- * @param config - Configuration with adapter builder
62
- * @returns NeonAuth instance with the adapter's API exposed directly
63
- *
64
- * @example SupabaseAuthAdapter - Supabase-compatible API
65
- * ```typescript
66
- * import { createAuthClient, SupabaseAuthAdapter } from '@neondatabase/auth';
67
- *
68
- * const auth = createAuthClient('https://auth.example.com', {
69
- * adapter: SupabaseAuthAdapter(),
70
- * });
71
- *
72
- * // Supabase-compatible methods
73
- * await auth.signInWithPassword({ email, password });
74
- * await auth.getSession();
75
- * ```
76
- *
77
- * @example BetterAuthVanillaAdapter - Direct Better Auth API
78
- * ```typescript
79
- * import { createAuthClient, BetterAuthVanillaAdapter } from '@neondatabase/auth';
80
- *
81
- * const auth = createAuthClient('https://auth.example.com', {
82
- * adapter: BetterAuthVanillaAdapter(),
83
- * });
84
- *
85
- * // Direct Better Auth API access
86
- * await auth.signIn.email({ email, password });
87
- * await auth.signUp.email({ email, password, name: 'John' });
88
- * await auth.getSession();
89
- * ```
90
- *
91
- * @example BetterAuthReactAdapter - Better Auth with React hooks
92
- * ```typescript
93
- * import { createAuthClient, BetterAuthReactAdapter } from '@neondatabase/auth';
94
- *
95
- * const auth = createAuthClient('https://auth.example.com', {
96
- * adapter: BetterAuthReactAdapter(),
97
- * });
98
- *
99
- * // Direct Better Auth API with React hooks
100
- * await auth.signIn.email({ email, password });
101
- * const session = auth.useSession(); // React hook
102
- * ```
103
- */
104
- declare function createInternalNeonAuth<T extends NeonAuthAdapter = BetterAuthVanillaAdapterInstance>(url: string, config?: NeonAuthConfigInternal<T>): NeonAuth<T>;
105
- declare function createAuthClient$2<T extends NeonAuthAdapter = BetterAuthVanillaAdapterInstance>(url: string, config?: NeonAuthConfig<T>): NeonAuthPublicApi<T>;
106
- //#endregion
107
- export { ReactBetterAuthClient as a, createInternalNeonAuth as c, NeonAuthPublicApi as i, NeonAuthAdapter as n, VanillaBetterAuthClient as o, NeonAuthConfig as r, createAuthClient$2 as s, NeonAuth as t };