mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-23 23:52:05 -05:00
fix(jwt): expose jwt options to plugins (#3726)
This commit is contained in:
5
.changeset/slimy-paws-sin.md
Normal file
5
.changeset/slimy-paws-sin.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"better-auth": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(jwt): add options to plugin
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -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>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user