passport-fast-jwt
Version:
Passport authentication strategy for JSON Web Tokens using Fast-Jwt with support for EdDSA algorithm among others
40 lines (39 loc) • 1.58 kB
TypeScript
import { Request } from "express";
import { TokenExtractor } from "./types";
/**
* Constructs a token extractor function with the given authentication scheme
* and authentication header name.
*
* @param authScheme
* @param authHeaderName
* @returns
*/
export declare const fromAuthHeaderWithScheme: (authHeaderName: string, authScheme: string) => TokenExtractor;
export declare const fromHeader: (paramName: string) => TokenExtractor;
export declare const fromBodyField: (paramName: string) => TokenExtractor;
export declare const fromQueryParam: (paramName: string) => TokenExtractor;
/**
* A ready made token extractor for 'Authorization' header
* with 'Bearer' scheme. This is shorthand for
*
* @example
* fromAuthHeaderWithScheme('authorization', 'bearer')
*
* @returns Token extractor for bearer authorization scheme
*/
export declare const fromAuthHeaderAsBearerToken: () => TokenExtractor;
/**
* Takes in an array of valid extractors and returns an extractor that runs all the given extractors
* against the request and tries to find a token. Returns the first token found. Extractors are
* run in the order they are given in the array.
* @param extractors An array of valid extractor functions
* @returns token as string if some of the extractors finds a token, otherwise null
*
* @example
* fromExtractors([
* fromAuthHeaderAsBearerToken(),
* fromAuthHeaderWithScheme('x-authorization', 'bearer'),
* fromBodyField('token')
* ])
*/
export declare const fromExtractors: (extractors: TokenExtractor[]) => (request: Request) => string | null;