Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -44,16 +44,19 @@ export type CreateAdapter = <Ctx extends GenericCtx<GenericDataModel>>(
ctx: Ctx
) => AdapterInstance;

export type CreateAuth<DataModel extends GenericDataModel> =
| ((ctx: GenericCtx<DataModel>) => ReturnType<typeof betterAuth>)
| ((
ctx: GenericCtx<DataModel>,
opts?: { optionsOnly?: boolean }
) => ReturnType<typeof betterAuth>);
export type CreateAuth<
DataModel extends GenericDataModel,
Options extends BetterAuthOptions = any
> =
| ((ctx: GenericCtx<DataModel>) => Auth<Options>)
| ((ctx: GenericCtx<DataModel>, opts?: { optionsOnly?: boolean }) => Auth<Options>);

export const getStaticAuth = <DataModel extends GenericDataModel>(
createAuth: CreateAuth<DataModel>
) => {
export const getStaticAuth = <
DataModel extends GenericDataModel,
Options extends BetterAuthOptions = any
>(
createAuth: CreateAuth<DataModel, Options>
): Auth<Options> => {
return createAuth({} as any, { optionsOnly: true });
};

Expand Down