UNPKG

1.24 kBTypeScriptView Raw
1/// <reference types="node" />
2import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
3import * as jwt from 'jsonwebtoken';
4export declare enum JwtSecretRequestType {
5 SIGN = 0,
6 VERIFY = 1
7}
8export interface JwtModuleOptions {
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;
15 verifyOptions?: jwt.VerifyOptions;
16}
17export interface JwtOptionsFactory {
18 createJwtOptions(): Promise<JwtModuleOptions> | JwtModuleOptions;
19}
20export interface JwtModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
21 useExisting?: Type<JwtOptionsFactory>;
22 useClass?: Type<JwtOptionsFactory>;
23 useFactory?: (...args: any[]) => Promise<JwtModuleOptions> | JwtModuleOptions;
24 inject?: any[];
25}
26export interface JwtSignOptions extends jwt.SignOptions {
27 secret?: string | Buffer;
28 privateKey?: string | Buffer;
29}
30export interface JwtVerifyOptions extends jwt.VerifyOptions {
31 secret?: string | Buffer;
32 publicKey?: string | Buffer;
33}