diff --git a/src/client/index.ts b/src/client/index.ts index b461fa4..1ee5333 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -19,7 +19,7 @@ import { } from "convex/server"; import { type GenericId, Infer, v } from "convex/values"; import { convexAdapter } from "./adapter"; -import { AdapterInstance, betterAuth } from "better-auth"; +import { AdapterInstance, betterAuth, type Auth, type BetterAuthOptions } from "better-auth"; import { asyncMap } from "convex-helpers"; import { partial } from "convex-helpers/validators"; import { @@ -44,16 +44,19 @@ export type CreateAdapter = >( ctx: Ctx ) => AdapterInstance; -export type CreateAuth = - | ((ctx: GenericCtx) => ReturnType) - | (( - ctx: GenericCtx, - opts?: { optionsOnly?: boolean } - ) => ReturnType); +export type CreateAuth< + DataModel extends GenericDataModel, + Options extends BetterAuthOptions = any +> = + | ((ctx: GenericCtx) => Auth) + | ((ctx: GenericCtx, opts?: { optionsOnly?: boolean }) => Auth); -export const getStaticAuth = ( - createAuth: CreateAuth -) => { +export const getStaticAuth = < + DataModel extends GenericDataModel, + Options extends BetterAuthOptions = any +>( + createAuth: CreateAuth +): Auth => { return createAuth({} as any, { optionsOnly: true }); };