mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-07 23:37:35 +08:00
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
// Type definitions for koa-jwt 3.2
|
|
// Project: https://github.com/koajs/jwt
|
|
// Definitions by: Bruno Krebs <https://github.com/brunokrebs>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
import Koa = require("koa");
|
|
|
|
export = jwt;
|
|
|
|
declare function jwt(options: jwt.Options): jwt.Middleware;
|
|
|
|
declare namespace jwt {
|
|
interface Options {
|
|
secret: string | Buffer | SecretProvider;
|
|
key?: string;
|
|
getToken?(opts: Options): string;
|
|
passthrough?: boolean;
|
|
cookie?: string;
|
|
debug?: boolean;
|
|
}
|
|
|
|
interface UnlessOptions {
|
|
method?: string | string[];
|
|
path?: string | string[] | RegExp | RegExp[];
|
|
ext?: string| string[];
|
|
custom?(ctx?: Koa.Context): boolean;
|
|
useOriginalUrl?: boolean;
|
|
}
|
|
|
|
type Middleware = Koa.Middleware & {
|
|
unless(options?: UnlessOptions): any;
|
|
};
|
|
|
|
type SecretProvider = (header: TokenHeader) => Promise<string>;
|
|
|
|
interface TokenHeader {
|
|
alg: string;
|
|
kid: string;
|
|
typ: string;
|
|
}
|
|
}
|