You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@fastify/jwt

Package Overview
Dependencies
Maintainers
20
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.4.0 to 6.5.0

266

jwt.d.ts

@@ -10,158 +10,168 @@ import {

} from 'fast-jwt'
import * as fastify from 'fastify'
import {
FastifyPluginCallback,
FastifyRequest
} from 'fastify'
/**
* for declaration merging
* @example
* ```
* declare module '@fastify/jwt' {
* interface FastifyJWT {
* payload: { name: string; email: string }
* }
* }
* ```
* @example
* ```
* // With `formatUser`.
* declare module '@fastify/jwt' {
* interface FastifyJWT {
* payload: { Name: string; e_mail: string }
* user: { name: string; email: string }
* }
* }
* ```
*/
export interface FastifyJWT {
// payload: ...
// user: ...
declare module 'fastify' {
interface FastifyInstance {
jwt: fastifyJwt.JWT
}
interface FastifyReply {
jwtSign(payload: fastifyJwt.SignPayloadType, options?: fastifyJwt.FastifyJwtSignOptions): Promise<string>
jwtSign(payload: fastifyJwt.SignPayloadType, callback: SignerCallback): void
jwtSign(payload: fastifyJwt.SignPayloadType, options: fastifyJwt.FastifyJwtSignOptions, callback: SignerCallback): void
jwtSign(payload: fastifyJwt.SignPayloadType, options?: Partial<fastifyJwt.SignOptions>): Promise<string>
jwtSign(payload: fastifyJwt.SignPayloadType, options: Partial<fastifyJwt.SignOptions>, callback: SignerCallback): void
}
interface FastifyRequest {
jwtVerify<Decoded extends fastifyJwt.VerifyPayloadType>(options?: fastifyJwt.FastifyJwtVerifyOptions): Promise<Decoded>
jwtVerify<Decoded extends fastifyJwt.VerifyPayloadType>(callback: VerifierCallback): void
jwtVerify<Decoded extends fastifyJwt.VerifyPayloadType>(options: fastifyJwt.FastifyJwtVerifyOptions, callback: VerifierCallback): void
jwtVerify<Decoded extends fastifyJwt.VerifyPayloadType>(options?: Partial<fastifyJwt.VerifyOptions>): Promise<Decoded>
jwtVerify<Decoded extends fastifyJwt.VerifyPayloadType>(options: Partial<fastifyJwt.VerifyOptions>, callback: VerifierCallback): void
jwtDecode<Decoded extends fastifyJwt.DecodePayloadType>(options?: fastifyJwt.FastifyJwtDecodeOptions): Promise<Decoded>
jwtDecode<Decoded extends fastifyJwt.DecodePayloadType>(callback: fastifyJwt.DecodeCallback<Decoded>): void
jwtDecode<Decoded extends fastifyJwt.DecodePayloadType>(options: fastifyJwt.FastifyJwtDecodeOptions, callback: fastifyJwt.DecodeCallback<Decoded>): void
user: fastifyJwt.UserType
}
}
export type SignPayloadType = FastifyJWT extends { payload: infer T }
? T extends string | object | Buffer
? T
: string | object | Buffer
: string | object | Buffer
type FastifyJwt = FastifyPluginCallback<fastifyJwt.FastifyJWTOptions>
export type UserType = FastifyJWT extends { user: infer T }
? T
: SignPayloadType
declare namespace fastifyJwt {
export type TokenOrHeader = JwtHeader | { header: JwtHeader; payload: any }
/**
* for declaration merging
* @example
* ```
* declare module '@fastify/jwt' {
* interface FastifyJWT {
* payload: { name: string; email: string }
* }
* }
* ```
* @example
* ```
* // With `formatUser`.
* declare module '@fastify/jwt' {
* interface FastifyJWT {
* payload: { Name: string; e_mail: string }
* user: { name: string; email: string }
* }
* }
* ```
*/
export interface FastifyJWT {
// payload: ...
// user: ...
}
export type Secret = string | Buffer | KeyFetcher | { key: Secret; passphrase: string }
| ((request: fastify.FastifyRequest, tokenOrHeader: TokenOrHeader, cb: (e: Error | null, secret: string | Buffer | undefined) => void) => void)
| ((request: fastify.FastifyRequest, tokenOrHeader: TokenOrHeader) => Promise<string | Buffer>)
export type SignPayloadType = FastifyJWT extends { payload: infer T }
? T extends string | object | Buffer
? T
: string | object | Buffer
: string | object | Buffer
export type VerifyPayloadType = object | string
export type DecodePayloadType = object | string
export type UserType = FastifyJWT extends { user: infer T }
? T
: SignPayloadType
export interface DecodeCallback<Decoded extends DecodePayloadType> {
(err: Error, decoded: Decoded): void
}
export type TokenOrHeader = JwtHeader | { header: JwtHeader; payload: any }
export interface SignOptions extends Omit<SignerOptions, "expiresIn" | "notBefore"> {
expiresIn: number | string;
notBefore: number | string;
}
export type Secret = string | Buffer | KeyFetcher | { key: Secret; passphrase: string }
| ((request: FastifyRequest, tokenOrHeader: TokenOrHeader, cb: (e: Error | null, secret: string | Buffer | undefined) => void) => void)
| ((request: FastifyRequest, tokenOrHeader: TokenOrHeader) => Promise<string | Buffer>)
export interface VerifyOptions extends Omit<VerifierOptions, "maxAge"> {
maxAge: number | string;
onlyCookie: boolean;
}
export type VerifyPayloadType = object | string
export type DecodePayloadType = object | string
export interface FastifyJWTOptions {
secret: Secret | { public: Secret; private: Secret }
decode?: Partial<DecoderOptions>
sign?: Partial<SignOptions>
verify?: Partial<VerifyOptions> & { extractToken?: (request: fastify.FastifyRequest) => string | void }
cookie?: {
cookieName: string,
signed: boolean
export interface DecodeCallback<Decoded extends DecodePayloadType> {
(err: Error, decoded: Decoded): void
}
messages?: {
badRequestErrorMessage?: string
badCookieRequestErrorMessage?: string
noAuthorizationInHeaderMessage?: string
noAuthorizationInCookieMessage?: string
authorizationTokenExpiredMessage?: string
authorizationTokenInvalid?: ((err: Error) => string) | string
authorizationTokenUntrusted?: string
export interface SignOptions extends Omit<SignerOptions, "expiresIn" | "notBefore"> {
expiresIn: number | string;
notBefore: number | string;
}
trusted?: (request: fastify.FastifyRequest, decodedToken: { [k: string]: any }) => boolean | Promise<boolean> | SignPayloadType | Promise<SignPayloadType>
formatUser?: (payload: SignPayloadType) => UserType,
jwtDecode?: boolean | string
namespace?: string
jwtVerify?: string
jwtSign?: string
decoratorName?: string
}
export interface JWT {
options: {
decode: Partial<DecoderOptions>
sign: Partial<SignOptions>
verify: Partial<VerifyOptions>
export interface VerifyOptions extends Omit<VerifierOptions, "maxAge"> {
maxAge: number | string;
onlyCookie: boolean;
}
cookie?: {
cookieName: string,
signed: boolean
export interface FastifyJWTOptions {
secret: Secret | { public: Secret; private: Secret }
decode?: Partial<DecoderOptions>
sign?: Partial<SignOptions>
verify?: Partial<VerifyOptions> & { extractToken?: (request: FastifyRequest) => string | void }
cookie?: {
cookieName: string,
signed: boolean
}
messages?: {
badRequestErrorMessage?: string
badCookieRequestErrorMessage?: string
noAuthorizationInHeaderMessage?: string
noAuthorizationInCookieMessage?: string
authorizationTokenExpiredMessage?: string
authorizationTokenInvalid?: ((err: Error) => string) | string
authorizationTokenUntrusted?: string
}
trusted?: (request: FastifyRequest, decodedToken: { [k: string]: any }) => boolean | Promise<boolean> | SignPayloadType | Promise<SignPayloadType>
formatUser?: (payload: SignPayloadType) => UserType,
jwtDecode?: boolean | string
namespace?: string
jwtVerify?: string
jwtSign?: string
decoratorName?: string
}
sign(payload: SignPayloadType, options?: Partial<SignOptions>): string
sign(payload: SignPayloadType, callback: SignerCallback): void
sign(payload: SignPayloadType, options: Partial<SignOptions>, callback: SignerCallback): void
export interface JWT {
options: {
decode: Partial<DecoderOptions>
sign: Partial<SignOptions>
verify: Partial<VerifyOptions>
}
cookie?: {
cookieName: string,
signed: boolean
}
verify<Decoded extends VerifyPayloadType>(token: string, options?: Partial<VerifyOptions>): Decoded
verify<Decoded extends VerifyPayloadType>(token: string, callback: VerifierCallback): void
verify<Decoded extends VerifyPayloadType>(token: string, options: Partial<VerifyOptions>, callback: VerifierCallback): void
sign(payload: SignPayloadType, options?: Partial<SignOptions>): string
sign(payload: SignPayloadType, callback: SignerCallback): void
sign(payload: SignPayloadType, options: Partial<SignOptions>, callback: SignerCallback): void
decode<Decoded extends DecodePayloadType>(token: string, options?: Partial<DecoderOptions>): null | Decoded
verify<Decoded extends VerifyPayloadType>(token: string, options?: Partial<VerifyOptions>): Decoded
verify<Decoded extends VerifyPayloadType>(token: string, callback: VerifierCallback): void
verify<Decoded extends VerifyPayloadType>(token: string, options: Partial<VerifyOptions>, callback: VerifierCallback): void
lookupToken(request: fastify.FastifyRequest, options?: FastifyJWTOptions['verify']): string
}
decode<Decoded extends DecodePayloadType>(token: string, options?: Partial<DecoderOptions>): null | Decoded
export type { JwtHeader } from 'fast-jwt'
lookupToken(request: FastifyRequest, options?: FastifyJWTOptions['verify']): string
}
export const fastifyJwt: fastify.FastifyPluginCallback<FastifyJWTOptions>
export type { JwtHeader }
export default fastifyJwt
export interface FastifyJwtSignOptions {
sign?: Partial<SignOptions>
}
export interface FastifyJwtSignOptions {
sign?: Partial<SignOptions>
}
export interface FastifyJwtVerifyOptions {
decode: Partial<DecoderOptions>
verify: Partial<VerifyOptions>
}
export interface FastifyJwtDecodeOptions {
decode: Partial<DecoderOptions>
verify: Partial<VerifyOptions>
}
declare module 'fastify' {
interface FastifyInstance {
jwt: JWT
export interface FastifyJwtVerifyOptions {
decode: Partial<DecoderOptions>
verify: Partial<VerifyOptions>
}
interface FastifyReply {
jwtSign(payload: SignPayloadType, options?: FastifyJwtSignOptions): Promise<string>
jwtSign(payload: SignPayloadType, callback: SignerCallback): void
jwtSign(payload: SignPayloadType, options: FastifyJwtSignOptions, callback: SignerCallback): void
jwtSign(payload: SignPayloadType, options?: Partial<SignOptions>): Promise<string>
jwtSign(payload: SignPayloadType, options: Partial<SignOptions>, callback: SignerCallback): void
export interface FastifyJwtDecodeOptions {
decode: Partial<DecoderOptions>
verify: Partial<VerifyOptions>
}
interface FastifyRequest {
jwtVerify<Decoded extends VerifyPayloadType>(options?: FastifyJwtVerifyOptions): Promise<Decoded>
jwtVerify<Decoded extends VerifyPayloadType>(callback: VerifierCallback): void
jwtVerify<Decoded extends VerifyPayloadType>(options: FastifyJwtVerifyOptions, callback: VerifierCallback): void
jwtVerify<Decoded extends VerifyPayloadType>(options?: Partial<VerifyOptions>): Promise<Decoded>
jwtVerify<Decoded extends VerifyPayloadType>(options: Partial<VerifyOptions>, callback: VerifierCallback): void
jwtDecode<Decoded extends DecodePayloadType>(options?: FastifyJwtDecodeOptions): Promise<Decoded>
jwtDecode<Decoded extends DecodePayloadType>(callback: DecodeCallback<Decoded>): void
jwtDecode<Decoded extends DecodePayloadType>(options: FastifyJwtDecodeOptions, callback: DecodeCallback<Decoded>): void
user: UserType
}
export const fastifyJwt: FastifyJwt
export { fastifyJwt as default }
}
declare function fastifyJwt(...params: Parameters<FastifyJwt>): ReturnType<FastifyJwt>
export = fastifyJwt

@@ -522,1 +522,3 @@ 'use strict'

})
module.exports.default = fastifyJwt
module.exports.fastifyJwt = fastifyJwt
{
"name": "@fastify/jwt",
"version": "6.4.0",
"version": "6.5.0",
"description": "JWT utils for Fastify",

@@ -5,0 +5,0 @@ "main": "jwt.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc