@neondatabase/auth 0.1.0-beta.2 → 0.1.0-beta.21

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 (45) hide show
  1. package/README.md +112 -18
  2. package/dist/{adapter-core-BDOw-gBC.mjs → adapter-core-PD5NQpLE.mjs} +392 -69
  3. package/dist/{adapter-core-C12KoaiU.d.mts → adapter-core-y53SWo8w.d.mts} +181 -627
  4. package/dist/{better-auth-react-adapter-FnBHa2nr.mjs → better-auth-react-adapter-B0XIXPUH.mjs} +10 -8
  5. package/dist/better-auth-react-adapter-B7zoQmoL.d.mts +2170 -0
  6. package/dist/chunk-VCZJYX65-CLnrj1o7-D6ZQkcc_.mjs +543 -0
  7. package/dist/constants-2bpp2_-f.mjs +30 -0
  8. package/dist/index.d.mts +4 -98
  9. package/dist/index.mjs +2 -1
  10. package/dist/{neon-auth-C9XTFffv.mjs → neon-auth-DUbqaO2v.mjs} +7 -4
  11. package/dist/neon-auth-oDgy6lQm.d.mts +107 -0
  12. package/dist/next/index.d.mts +76 -303
  13. package/dist/next/index.mjs +6 -174
  14. package/dist/next/server/index.d.mts +433 -0
  15. package/dist/next/server/index.mjs +731 -0
  16. package/dist/react/adapters/index.d.mts +4 -4
  17. package/dist/react/adapters/index.mjs +2 -1
  18. package/dist/react/index.d.mts +5 -5
  19. package/dist/react/index.mjs +5 -92
  20. package/dist/react/ui/index.d.mts +1 -1
  21. package/dist/react/ui/index.mjs +3 -91
  22. package/dist/react/ui/server.mjs +1 -1
  23. package/dist/{supabase-adapter-ggmqWgPe.mjs → supabase-adapter-Bdw6aPGx.mjs} +72 -167
  24. package/dist/supabase-adapter-Dm56RKRF.d.mts +2258 -0
  25. package/dist/types/index.d.mts +3 -0
  26. package/dist/types/index.mjs +3 -0
  27. package/dist/ui/.safelist.html +3 -0
  28. package/dist/ui/css.css +2 -2
  29. package/dist/ui/tailwind.css +4 -3
  30. package/dist/ui/theme-inline.css +44 -0
  31. package/dist/ui/theme.css +221 -118
  32. package/dist/ui-CrxGg6vQ.mjs +12113 -0
  33. package/dist/vanilla/adapters/index.d.mts +3 -3
  34. package/dist/vanilla/adapters/index.mjs +2 -1
  35. package/dist/vanilla/index.d.mts +3 -3
  36. package/dist/vanilla/index.mjs +2 -1
  37. package/llms.txt +172 -0
  38. package/package.json +22 -11
  39. package/dist/better-auth-react-adapter-BXL48HIU.d.mts +0 -722
  40. package/dist/supabase-adapter-crabDnl2.d.mts +0 -128
  41. package/dist/ui-CNFBSekF.mjs +0 -401
  42. /package/dist/{adapters-Dkx0zoMR.mjs → adapters-B7YKkjaL.mjs} +0 -0
  43. /package/dist/{index-C-svZlpj.d.mts → index-CPnFzULh.d.mts} +0 -0
  44. /package/dist/{index-DuDD6cIY.d.mts → index-CzsGMS7C.d.mts} +0 -0
  45. /package/dist/{index-UW23fDSn.d.mts → index-OEBbnNdr.d.mts} +0 -0
package/dist/index.d.mts CHANGED
@@ -1,99 +1,5 @@
1
- import { r as SupportedBetterAuthClientPlugins } from "./adapter-core-C12KoaiU.mjs";
2
- import { r as BetterAuthReactAdapterInstance } from "./better-auth-react-adapter-BXL48HIU.mjs";
3
- import { r as SupabaseAuthAdapterInstance, s as BetterAuthVanillaAdapterInstance } from "./supabase-adapter-crabDnl2.mjs";
4
- import { createAuthClient as createAuthClient$1 } from "better-auth/react";
5
- import { createAuthClient as createAuthClient$2 } 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$1<{
13
- plugins: SupportedBetterAuthClientPlugins;
14
- }>>;
15
- /**`
16
- * Type representing the Better Auth Vanilla client
17
- */
18
- type VanillaBetterAuthClient = ReturnType<typeof createAuthClient$2<{
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) => T;
31
- }
32
- /**
33
- * Resolves the public API type for an adapter.
34
- * - SupabaseAuthAdapter: exposes its own methods directly (Supabase-compatible API)
35
- * - BetterAuth adapters: expose the Better Auth client directly
36
- */
37
- type NeonAuthPublicApi<T extends NeonAuthAdapter> = T extends BetterAuthVanillaAdapterInstance ? VanillaBetterAuthClient : T extends BetterAuthReactAdapterInstance ? ReactBetterAuthClient : T;
38
- /**
39
- * NeonAuth type - combines base functionality with the appropriate public API
40
- * This is the return type of createAuthClient()
41
- *
42
- * For SupabaseAuthAdapter: exposes Supabase-compatible methods (signInWithPassword, getSession, etc.)
43
- * For BetterAuth adapters: exposes the Better Auth client directly (signIn.email, signUp.email, etc.)
44
- */
45
- type NeonAuth<T extends NeonAuthAdapter> = {
46
- adapter: NeonAuthPublicApi<T>;
47
- getJWTToken: () => Promise<string | null>;
48
- };
49
- /**
50
- * Create a NeonAuth instance that exposes the appropriate API based on the adapter.
51
- *
52
- * @param url - The auth service URL (e.g., 'https://auth.example.com')
53
- * @param config - Configuration with adapter builder
54
- * @returns NeonAuth instance with the adapter's API exposed directly
55
- *
56
- * @example SupabaseAuthAdapter - Supabase-compatible API
57
- * ```typescript
58
- * import { createAuthClient, SupabaseAuthAdapter } from '@neondatabase/auth';
59
- *
60
- * const auth = createAuthClient('https://auth.example.com', {
61
- * adapter: SupabaseAuthAdapter(),
62
- * });
63
- *
64
- * // Supabase-compatible methods
65
- * await auth.signInWithPassword({ email, password });
66
- * await auth.getSession();
67
- * ```
68
- *
69
- * @example BetterAuthVanillaAdapter - Direct Better Auth API
70
- * ```typescript
71
- * import { createAuthClient, BetterAuthVanillaAdapter } from '@neondatabase/auth';
72
- *
73
- * const auth = createAuthClient('https://auth.example.com', {
74
- * adapter: BetterAuthVanillaAdapter(),
75
- * });
76
- *
77
- * // Direct Better Auth API access
78
- * await auth.signIn.email({ email, password });
79
- * await auth.signUp.email({ email, password, name: 'John' });
80
- * await auth.getSession();
81
- * ```
82
- *
83
- * @example BetterAuthReactAdapter - Better Auth with React hooks
84
- * ```typescript
85
- * import { createAuthClient, BetterAuthReactAdapter } from '@neondatabase/auth';
86
- *
87
- * const auth = createAuthClient('https://auth.example.com', {
88
- * adapter: BetterAuthReactAdapter(),
89
- * });
90
- *
91
- * // Direct Better Auth API with React hooks
92
- * await auth.signIn.email({ email, password });
93
- * const session = auth.useSession(); // React hook
94
- * ```
95
- */
96
- declare function createInternalNeonAuth<T extends NeonAuthAdapter = BetterAuthVanillaAdapterInstance>(url: string, config?: NeonAuthConfig<T>): NeonAuth<T>;
97
- declare function createAuthClient<T extends NeonAuthAdapter = BetterAuthVanillaAdapterInstance>(url: string, config?: NeonAuthConfig<T>): NeonAuthPublicApi<T>;
98
- //#endregion
1
+ import "./adapter-core-y53SWo8w.mjs";
2
+ import "./better-auth-react-adapter-B7zoQmoL.mjs";
3
+ import "./supabase-adapter-Dm56RKRF.mjs";
4
+ import { a as ReactBetterAuthClient, c as createInternalNeonAuth, i as NeonAuthPublicApi, n as NeonAuthAdapter, o as VanillaBetterAuthClient, r as NeonAuthConfig, s as createAuthClient, t as NeonAuth } from "./neon-auth-oDgy6lQm.mjs";
99
5
  export { type NeonAuth, type NeonAuthAdapter, type NeonAuthConfig, type NeonAuthPublicApi, type ReactBetterAuthClient, type VanillaBetterAuthClient, createAuthClient, createInternalNeonAuth };
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
- import { n as createInternalNeonAuth, t as createAuthClient } from "./neon-auth-C9XTFffv.mjs";
1
+ import "./adapter-core-PD5NQpLE.mjs";
2
+ import { n as createInternalNeonAuth, t as createAuthClient } from "./neon-auth-DUbqaO2v.mjs";
2
3
 
3
4
  export { createAuthClient, createInternalNeonAuth };
@@ -1,4 +1,4 @@
1
- import { n as BetterAuthVanillaAdapter } from "./supabase-adapter-ggmqWgPe.mjs";
1
+ import { n as BetterAuthVanillaAdapter } from "./supabase-adapter-Bdw6aPGx.mjs";
2
2
 
3
3
  //#region src/neon-auth.ts
4
4
  /**
@@ -49,13 +49,16 @@ import { n as BetterAuthVanillaAdapter } from "./supabase-adapter-ggmqWgPe.mjs";
49
49
  * ```
50
50
  */
51
51
  function createInternalNeonAuth(url, config) {
52
- const adapter = (config?.adapter ?? BetterAuthVanillaAdapter())(url);
52
+ const adapterBuilder = config?.adapter ?? BetterAuthVanillaAdapter();
53
+ const { fetchOptions } = config ?? {};
54
+ const adapter = adapterBuilder(url, fetchOptions);
55
+ const allowAnonymous = config?.allowAnonymous ?? false;
53
56
  if (!(typeof adapter.initialize === "function")) return {
54
- getJWTToken: adapter.getJWTToken.bind(adapter),
57
+ getJWTToken: () => adapter.getJWTToken(allowAnonymous),
55
58
  adapter: adapter.getBetterAuthInstance()
56
59
  };
57
60
  return {
58
- getJWTToken: adapter.getJWTToken.bind(adapter),
61
+ getJWTToken: () => adapter.getJWTToken(allowAnonymous),
59
62
  adapter
60
63
  };
61
64
  }
@@ -0,0 +1,107 @@
1
+ import { r as SupportedBetterAuthClientPlugins } from "./adapter-core-y53SWo8w.mjs";
2
+ import { n as BetterAuthReactAdapterInstance } from "./better-auth-react-adapter-B7zoQmoL.mjs";
3
+ import { r as SupabaseAuthAdapterInstance, s as BetterAuthVanillaAdapterInstance } from "./supabase-adapter-Dm56RKRF.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 };