@neondatabase/auth 0.1.0-beta.1

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.
@@ -0,0 +1,49 @@
1
+ import { t as NeonAuthAdapterCore } from "./adapter-core-BDOw-gBC.mjs";
2
+ import { createAuthClient } from "better-auth/react";
3
+
4
+ //#region src/adapters/better-auth-react/better-auth-react-adapter.ts
5
+ /**
6
+ * Internal implementation class - use BetterAuthReactAdapter factory function instead
7
+ */
8
+ var BetterAuthReactAdapterImpl = class extends NeonAuthAdapterCore {
9
+ _betterAuth;
10
+ constructor(betterAuthClientOptions) {
11
+ super(betterAuthClientOptions);
12
+ this._betterAuth = createAuthClient(this.betterAuthOptions);
13
+ }
14
+ getBetterAuthInstance() {
15
+ return this._betterAuth;
16
+ }
17
+ async getJWTToken() {
18
+ const session = await this._betterAuth.getSession();
19
+ if (session.error) throw session.error;
20
+ return session.data?.session?.token ?? null;
21
+ }
22
+ };
23
+ /**
24
+ * Factory function that returns an adapter builder.
25
+ * The builder is called by createClient/createAuthClient with the URL.
26
+ *
27
+ * @param options - Optional adapter configuration (baseURL is injected separately)
28
+ * @returns A builder function that creates the adapter instance
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const client = createClient({
33
+ * auth: {
34
+ * url: 'https://auth.example.com',
35
+ * adapter: BetterAuthReactAdapter(),
36
+ * },
37
+ * dataApi: { url: 'https://data-api.example.com' },
38
+ * });
39
+ * ```
40
+ */
41
+ function BetterAuthReactAdapter(options) {
42
+ return (url) => new BetterAuthReactAdapterImpl({
43
+ baseURL: url,
44
+ ...options
45
+ });
46
+ }
47
+
48
+ //#endregion
49
+ export { BetterAuthReactAdapter as t };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,3 @@
1
+ 'use client';
2
+ import { AcceptInvitationCard, AcceptInvitationCardProps, AccountSettingsCards, AccountView, AccountViewPath, AccountViewPaths, AccountViewProps, AccountsCard, AccountsCardProps, ApiKeysCardProps, AppleIcon, AuthCallback, AuthForm, AuthFormClassNames, AuthFormProps, AuthHooks, AuthLoading, AuthLocalization, AuthMutators, AuthUIContext, AuthUIContextType, AuthUIProvider, AuthUIProviderProps, AuthView, AuthViewClassNames, AuthViewPath, AuthViewPaths, AuthViewProps, ChangeEmailCard, ChangePasswordCard, ChangePasswordCardProps, CreateOrganizationDialog, CreateOrganizationDialogProps, CreateTeamDialog, CreateTeamDialogProps, DeleteAccountCard, DeleteAccountCardProps, DeleteOrganizationCard, DiscordIcon, DropboxIcon, FacebookIcon, ForgotPasswordForm, ForgotPasswordFormProps, GitHubIcon, GitLabIcon, GoogleIcon, HuggingFaceIcon, InputFieldSkeleton, KickIcon, LinearIcon, LinkedInIcon, MagicLinkForm, MagicLinkFormProps, MicrosoftIcon, NeonAuthUIProvider, NeonAuthUIProviderProps, NotionIcon, OrganizationCellView, OrganizationInvitationsCard, OrganizationLogo, OrganizationLogoCard, OrganizationLogoCardProps, OrganizationLogoClassNames, OrganizationLogoProps, OrganizationMembersCard, OrganizationNameCard, OrganizationNameCardProps, OrganizationSettingsCards, OrganizationSettingsCardsProps, OrganizationSlugCard, OrganizationSlugCardProps, OrganizationSwitcher, OrganizationSwitcherClassNames, OrganizationSwitcherProps, OrganizationView, OrganizationViewClassNames, OrganizationViewPageProps, OrganizationViewPath, OrganizationViewPaths, OrganizationViewProps, OrganizationsCard, PasskeysCard, PasskeysCardProps, PasswordInput, Provider, ProvidersCard, ProvidersCardProps, RecoverAccountForm, RecoverAccountFormProps, RedditIcon, RedirectToSignIn, RedirectToSignUp, ResetPasswordForm, ResetPasswordFormProps, RobloxIcon, SecuritySettingsCards, SessionsCard, SessionsCardProps, SettingsCard, SettingsCardClassNames, SettingsCardProps, SettingsCellSkeleton, SignInForm, SignInFormProps, SignOut, SignUpForm, SignUpFormProps, SignedIn, SignedOut, SlackIcon, SpotifyIcon, Team, TeamCell, TeamCellProps, TeamOptions, TeamOptionsContext, TeamsCard, TikTokIcon, TwitchIcon, TwoFactorCard, TwoFactorCardProps, TwoFactorForm, TwoFactorFormProps, UpdateAvatarCard, UpdateAvatarCardProps, UpdateFieldCard, UpdateFieldCardProps, UpdateNameCard, UpdateUsernameCard, UserAvatar, UserAvatarClassNames, UserAvatarProps, UserButton, UserButtonClassNames, UserButtonProps, UserInvitationsCard, UserView, UserViewClassNames, UserViewProps, VKIcon, XIcon, ZoomIcon, accountViewPaths, authLocalization, authViewPaths, getViewByPath, organizationViewPaths, socialProviders, useAuthData, useAuthenticate, useCurrentOrganization, useTheme } from "@neondatabase/auth-ui";
3
+ export { MagicLinkFormProps as $, SignUpFormProps as $t, ChangePasswordCard as A, UserViewClassNames as An, PasswordInput as At, DropboxIcon as B, socialProviders as Bn, ResetPasswordFormProps as Bt, AuthUIProviderProps as C, UserAvatarClassNames as Cn, OrganizationViewPageProps as Ct, AuthViewPaths as D, UserButtonProps as Dn, OrganizationsCard as Dt, AuthViewPath as E, UserButtonClassNames as En, OrganizationViewProps as Et, CreateTeamDialogProps as F, accountViewPaths as Fn, RecoverAccountFormProps as Ft, GitLabIcon as G, SettingsCard as Gt, ForgotPasswordForm as H, useAuthenticate as Hn, SecuritySettingsCards as Ht, DeleteAccountCard as I, authLocalization as In, RedditIcon as It, InputFieldSkeleton as J, SettingsCellSkeleton as Jt, GoogleIcon as K, SettingsCardClassNames as Kt, DeleteAccountCardProps as L, authViewPaths as Ln, RedirectToSignIn as Lt, CreateOrganizationDialog as M, VKIcon as Mn, ProvidersCard as Mt, CreateOrganizationDialogProps as N, XIcon as Nn, ProvidersCardProps as Nt, AuthViewProps as O, UserInvitationsCard as On, PasskeysCard as Ot, CreateTeamDialog as P, ZoomIcon as Pn, RecoverAccountForm as Pt, MagicLinkForm as Q, SignUpForm as Qt, DeleteOrganizationCard as R, getViewByPath as Rn, RedirectToSignUp as Rt, AuthUIProvider as S, UserAvatar as Sn, OrganizationViewClassNames as St, AuthViewClassNames as T, UserButton as Tn, OrganizationViewPaths as Tt, ForgotPasswordFormProps as U, useCurrentOrganization as Un, SessionsCard as Ut, FacebookIcon as V, useAuthData as Vn, RobloxIcon as Vt, GitHubIcon as W, useTheme as Wn, SessionsCardProps as Wt, LinearIcon as X, SignInFormProps as Xt, KickIcon as Y, SignInForm as Yt, LinkedInIcon as Z, SignOut as Zt, AuthLoading as _, UpdateAvatarCardProps as _n, OrganizationSlugCardProps as _t, AccountViewPath as a, TeamCell as an, OrganizationInvitationsCard as at, AuthUIContext as b, UpdateNameCard as bn, OrganizationSwitcherProps as bt, AccountsCard as c, TeamOptionsContext as cn, OrganizationLogoCardProps as ct, AppleIcon as d, TwitchIcon as dn, OrganizationMembersCard as dt, SignedIn as en, MicrosoftIcon as et, AuthCallback as f, TwoFactorCard as fn, OrganizationNameCard as ft, AuthHooks as g, UpdateAvatarCard as gn, OrganizationSlugCard as gt, AuthFormProps as h, TwoFactorFormProps as hn, OrganizationSettingsCardsProps as ht, AccountView as i, Team as in, OrganizationCellView as it, ChangePasswordCardProps as j, UserViewProps as jn, Provider as jt, ChangeEmailCard as k, UserView as kn, PasskeysCardProps as kt, AccountsCardProps as l, TeamsCard as ln, OrganizationLogoClassNames as lt, AuthFormClassNames as m, TwoFactorForm as mn, OrganizationSettingsCards as mt, AcceptInvitationCardProps as n, SlackIcon as nn, NeonAuthUIProviderProps as nt, AccountViewPaths as o, TeamCellProps as on, OrganizationLogo as ot, AuthForm as p, TwoFactorCardProps as pn, OrganizationNameCardProps as pt, HuggingFaceIcon as q, SettingsCardProps as qt, AccountSettingsCards as r, SpotifyIcon as rn, NotionIcon as rt, AccountViewProps as s, TeamOptions as sn, OrganizationLogoCard as st, AcceptInvitationCard as t, SignedOut as tn, NeonAuthUIProvider as tt, ApiKeysCardProps as u, TikTokIcon as un, OrganizationLogoProps as ut, AuthLocalization as v, UpdateFieldCard as vn, OrganizationSwitcher as vt, AuthView as w, UserAvatarProps as wn, OrganizationViewPath as wt, AuthUIContextType as x, UpdateUsernameCard as xn, OrganizationView as xt, AuthMutators as y, UpdateFieldCardProps as yn, OrganizationSwitcherClassNames as yt, DiscordIcon as z, organizationViewPaths as zn, ResetPasswordForm as zt };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,99 @@
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
99
+ export { type NeonAuth, type NeonAuthAdapter, type NeonAuthConfig, type NeonAuthPublicApi, type ReactBetterAuthClient, type VanillaBetterAuthClient, createAuthClient, createInternalNeonAuth };
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { n as createInternalNeonAuth, t as createAuthClient } from "./neon-auth-C9XTFffv.mjs";
2
+
3
+ export { createAuthClient, createInternalNeonAuth };
@@ -0,0 +1,67 @@
1
+ import { n as BetterAuthVanillaAdapter } from "./supabase-adapter-ggmqWgPe.mjs";
2
+
3
+ //#region src/neon-auth.ts
4
+ /**
5
+ * Create a NeonAuth instance that exposes the appropriate API based on the adapter.
6
+ *
7
+ * @param url - The auth service URL (e.g., 'https://auth.example.com')
8
+ * @param config - Configuration with adapter builder
9
+ * @returns NeonAuth instance with the adapter's API exposed directly
10
+ *
11
+ * @example SupabaseAuthAdapter - Supabase-compatible API
12
+ * ```typescript
13
+ * import { createAuthClient, SupabaseAuthAdapter } from '@neondatabase/auth';
14
+ *
15
+ * const auth = createAuthClient('https://auth.example.com', {
16
+ * adapter: SupabaseAuthAdapter(),
17
+ * });
18
+ *
19
+ * // Supabase-compatible methods
20
+ * await auth.signInWithPassword({ email, password });
21
+ * await auth.getSession();
22
+ * ```
23
+ *
24
+ * @example BetterAuthVanillaAdapter - Direct Better Auth API
25
+ * ```typescript
26
+ * import { createAuthClient, BetterAuthVanillaAdapter } from '@neondatabase/auth';
27
+ *
28
+ * const auth = createAuthClient('https://auth.example.com', {
29
+ * adapter: BetterAuthVanillaAdapter(),
30
+ * });
31
+ *
32
+ * // Direct Better Auth API access
33
+ * await auth.signIn.email({ email, password });
34
+ * await auth.signUp.email({ email, password, name: 'John' });
35
+ * await auth.getSession();
36
+ * ```
37
+ *
38
+ * @example BetterAuthReactAdapter - Better Auth with React hooks
39
+ * ```typescript
40
+ * import { createAuthClient, BetterAuthReactAdapter } from '@neondatabase/auth';
41
+ *
42
+ * const auth = createAuthClient('https://auth.example.com', {
43
+ * adapter: BetterAuthReactAdapter(),
44
+ * });
45
+ *
46
+ * // Direct Better Auth API with React hooks
47
+ * await auth.signIn.email({ email, password });
48
+ * const session = auth.useSession(); // React hook
49
+ * ```
50
+ */
51
+ function createInternalNeonAuth(url, config) {
52
+ const adapter = (config?.adapter ?? BetterAuthVanillaAdapter())(url);
53
+ if (!(typeof adapter.initialize === "function")) return {
54
+ getJWTToken: adapter.getJWTToken.bind(adapter),
55
+ adapter: adapter.getBetterAuthInstance()
56
+ };
57
+ return {
58
+ getJWTToken: adapter.getJWTToken.bind(adapter),
59
+ adapter
60
+ };
61
+ }
62
+ function createAuthClient(url, config) {
63
+ return createInternalNeonAuth(url, config).adapter;
64
+ }
65
+
66
+ //#endregion
67
+ export { createInternalNeonAuth as n, createAuthClient as t };