@graphql-mesh/plugin-jwt-auth
Version:
29 lines (28 loc) • 1.35 kB
TypeScript
import { type Plugin as YogaPlugin } from 'graphql-yoga';
import type { MeshServePlugin } from '@graphql-mesh/serve-runtime';
import { type JWTExtendContextFields, type JwtPluginOptions } from '@graphql-yoga/plugin-jwt';
export { createInlineSigningKeyProvider, createRemoteJwksSigningKeyProvider, extractFromCookie, extractFromHeader, type GetSigningKeyFunction, type JWTExtendContextFields, type JwtPluginOptions, type ExtractTokenFunction, } from '@graphql-yoga/plugin-jwt';
export type JWTAuthPluginOptions = Omit<JwtPluginOptions, 'extendContext'> & {
forward?: {
payload?: boolean | string;
token?: boolean | string;
extensionsFieldName?: string;
};
};
/**
* This Yoga plugin is used to extracted the forwarded (from Mesh gateway) the JWT token and claims.
* Use this plugin in your Yoga server to extract the JWT token and claims from the forwarded extensions.
*/
export declare function useForwardedJWT(config: {
extensionsFieldName?: string;
extendContextFieldName?: string;
}): YogaPlugin<{
jwt?: JWTExtendContextFields;
}>;
/**
* This Mesh Gateway plugin is used to extract the JWT token and payload from the request and forward it to the subgraph.
*/
export declare function useJWT(options: JWTAuthPluginOptions): MeshServePlugin<{
jwt?: JWTExtendContextFields;
}>;
export default useJWT;