UNPKG

1.37 kBTypeScriptView Raw
1import { ModuleMetadata, Provider, Type } from '@nestjs/common';
2import * as jwt from 'jsonwebtoken';
3export declare enum JwtSecretRequestType {
4 SIGN = 0,
5 VERIFY = 1
6}
7export interface JwtModuleOptions {
8 global?: boolean;
9 signOptions?: jwt.SignOptions;
10 secret?: string | Buffer;
11 publicKey?: string | Buffer;
12 privateKey?: jwt.Secret;
13 secretOrPrivateKey?: jwt.Secret;
14 secretOrKeyProvider?: (requestType: JwtSecretRequestType, tokenOrPayload: string | object | Buffer, options?: jwt.VerifyOptions | jwt.SignOptions) => jwt.Secret | Promise<jwt.Secret>;
15 verifyOptions?: jwt.VerifyOptions;
16}
17export interface JwtOptionsFactory {
18 createJwtOptions(): Promise<JwtModuleOptions> | JwtModuleOptions;
19}
20export interface JwtModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
21 global?: boolean;
22 useExisting?: Type<JwtOptionsFactory>;
23 useClass?: Type<JwtOptionsFactory>;
24 useFactory?: (...args: any[]) => Promise<JwtModuleOptions> | JwtModuleOptions;
25 inject?: any[];
26 extraProviders?: Provider[];
27}
28export interface JwtSignOptions extends jwt.SignOptions {
29 secret?: string | Buffer;
30 privateKey?: jwt.Secret;
31}
32export interface JwtVerifyOptions extends jwt.VerifyOptions {
33 secret?: string | Buffer;
34 publicKey?: string | Buffer;
35}
36export type GetSecretKeyResult = string | Buffer | jwt.Secret;