fix(jwt): expose jwt options to plugins (#3726)

This commit is contained in:
Grant G
2025-07-31 22:27:26 -07:00
committed by GitHub
parent b27221b356
commit 60c92fab0b
3 changed files with 8 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"better-auth": patch
---
fix(jwt): add options to plugin

View File

@@ -142,6 +142,7 @@ export async function generateExportedKeyPair(
export const jwt = (options?: JwtOptions) => { export const jwt = (options?: JwtOptions) => {
return { return {
id: "jwt", id: "jwt",
options,
endpoints: { endpoints: {
getJwks: createAuthEndpoint( getJwks: createAuthEndpoint(
"/jwks", "/jwks",

View File

@@ -26,13 +26,13 @@ import { parseSetCookieHeader } from "../../cookies";
import { createHash } from "@better-auth/utils/hash"; import { createHash } from "@better-auth/utils/hash";
import { base64 } from "@better-auth/utils/base64"; import { base64 } from "@better-auth/utils/base64";
import { getJwtToken } from "../jwt/sign"; import { getJwtToken } from "../jwt/sign";
import type { JwtOptions } from "../jwt"; import type { jwt } from "../jwt";
import { defaultClientSecretHasher } from "./utils"; import { defaultClientSecretHasher } from "./utils";
const getJwtPlugin = (ctx: GenericEndpointContext) => { const getJwtPlugin = (ctx: GenericEndpointContext) => {
return ctx.context.options.plugins?.find( return ctx.context.options.plugins?.find(
(plugin) => plugin.id === "jwt", (plugin) => plugin.id === "jwt",
) as Omit<BetterAuthPlugin, "options"> & { options?: JwtOptions }; ) as ReturnType<typeof jwt>;
}; };
/** /**