UNPKG

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