UNPKG

better-auth

Version:

The most comprehensive authentication framework for TypeScript.

1 lines 1.3 kB
{"version":3,"file":"client.mjs","names":[],"sources":["../../../src/plugins/jwt/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"@better-auth/core\";\nimport type { JSONWebKeySet } from \"jose\";\nimport type { jwt } from \"./index\";\n\ninterface JwtClientOptions {\n\tjwks?: {\n\t\t/**\n\t\t * The path of the endpoint exposing the JWKS.\n\t\t * Must match the server configuration.\n\t\t *\n\t\t * @default /jwks\n\t\t */\n\t\tjwksPath?: string;\n\t};\n}\n\nexport const jwtClient = (options?: JwtClientOptions) => {\n\tconst jwksPath = options?.jwks?.jwksPath ?? \"/jwks\";\n\n\treturn {\n\t\tid: \"better-auth-client\",\n\t\t$InferServerPlugin: {} as ReturnType<typeof jwt>,\n\t\tpathMethods: {\n\t\t\t[jwksPath]: \"GET\",\n\t\t},\n\t\tgetActions: ($fetch) => ({\n\t\t\tjwks: async (fetchOptions?: any) => {\n\t\t\t\treturn await $fetch<JSONWebKeySet>(jwksPath, {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t...fetchOptions,\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t} satisfies BetterAuthClientPlugin;\n};\n\nexport type * from \"./types\";\n"],"mappings":";AAgBA,MAAa,aAAa,YAA+B;CACxD,MAAM,WAAW,SAAS,MAAM,YAAY;AAE5C,QAAO;EACN,IAAI;EACJ,oBAAoB,EAAE;EACtB,aAAa,GACX,WAAW,OACZ;EACD,aAAa,YAAY,EACxB,MAAM,OAAO,iBAAuB;AACnC,UAAO,MAAM,OAAsB,UAAU;IAC5C,QAAQ;IACR,GAAG;IACH,CAAC;KAEH;EACD"}