Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-jwt

Package Overview
Dependencies
Maintainers
5
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-jwt - npm Package Compare versions

Comparing version 5.0.2 to 5.0.5

39

package.json
{
"name": "fast-jwt",
"version": "5.0.2",
"version": "5.0.5",
"description": "Fast JSON Web Token implementation",

@@ -42,3 +42,3 @@ "author": "NearForm Ltd",

"postpublish": "git push origin && git push origin -f --tags",
"lint": "eslint src/**/*.js test/**/*.js src/**/*.ts test/**/*.ts",
"lint": "eslint .",
"test": "node --test --experimental-test-coverage && tsd",

@@ -55,25 +55,24 @@ "test:ci": "npm run lint && npm run test",

"dependencies": {
"@lukeed/ms": "^2.0.1",
"@lukeed/ms": "^2.0.2",
"asn1.js": "^5.4.1",
"ecdsa-sig-formatter": "^1.0.11",
"mnemonist": "^0.39.5"
"mnemonist": "^0.39.8"
},
"devDependencies": {
"@node-rs/jsonwebtoken": "^0.5.6",
"@sinonjs/fake-timers": "^13.0.1",
"@types/node": "^22.0.0",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"@node-rs/jsonwebtoken": "^0.5.9",
"@types/node": "^22.10.2",
"cronometro": "^4.0.0",
"eslint": "^8.33.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-promise": "^6.1.1",
"fastify": "^5.0.0",
"jose": "^2.0.6",
"jsonwebtoken": "^9.0.0",
"prettier": "^3.0.0",
"tsd": "^0.31.0",
"typescript": "^5.0.2"
"eslint": "^9.17.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.15.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.2.1",
"fastify": "^5.2.0",
"jose": "^2.0.7",
"jsonwebtoken": "^9.0.2",
"prettier": "^3.4.2",
"tsd": "^0.31.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.0"
},

@@ -80,0 +79,0 @@ "engines": {

@@ -466,1 +466,3 @@ # fast-jwt

Licensed under the [Apache-2.0 license](http://www.apache.org/licenses/LICENSE-2.0).
[![banner](https://raw.githubusercontent.com/nearform/.github/refs/heads/master/assets/os-banner-green.svg)](https://www.nearform.com/contact/?utm_source=open-source&utm_medium=banner&utm_campaign=os-project-pages)

@@ -46,10 +46,3 @@ 'use strict'

this.key('version').int(),
this.key('algorithm')
.seq()
.obj(
this.key('algorithm').objid(),
this.key('parameters')
.optional()
.objid()
)
this.key('algorithm').seq().obj(this.key('algorithm').objid(), this.key('parameters').optional().objid())
)

@@ -60,10 +53,3 @@ })

this.seq().obj(
this.key('algorithm')
.seq()
.obj(
this.key('algorithm').objid(),
this.key('parameters')
.optional()
.objid()
)
this.key('algorithm').seq().obj(this.key('algorithm').objid(), this.key('parameters').optional().objid())
)

@@ -76,6 +62,3 @@ })

this.key('privateKey').octstr(),
this.key('parameters')
.explicit(0)
.optional()
.choice({ namedCurve: this.objid() })
this.key('parameters').explicit(0).optional().choice({ namedCurve: this.objid() })
)

@@ -214,3 +197,8 @@ })

} catch (e) {
throw cacheSet(privateKeysCache, key, null, TokenError.wrap(e, TokenError.codes.invalidKey, 'Unsupported PEM private key.'))
throw cacheSet(
privateKeysCache,
key,
null,
TokenError.wrap(e, TokenError.codes.invalidKey, 'Unsupported PEM private key.')
)
}

@@ -260,5 +248,3 @@ }

case 'HS':
raw = createHmac(alg, key)
.update(input)
.digest('base64')
raw = createHmac(alg, key).update(input).digest('base64')
break

@@ -281,6 +267,3 @@ case 'ES':

raw = createSign(alg)
.update(input)
.sign(options)
.toString('base64')
raw = createSign(alg).update(input).sign(options).toString('base64')
break

@@ -307,9 +290,4 @@ case 'Ed':

try {
return timingSafeEqual(
createHmac(alg, key)
.update(input)
.digest(),
signature
)
} catch (e) {
return timingSafeEqual(createHmac(alg, key).update(input).digest(), signature)
} catch {
return false

@@ -316,0 +294,0 @@ }

@@ -68,29 +68,33 @@ export type Algorithm =

payload: any
signature: string,
signature: string
input: string
}
type Bufferable = string | Buffer
type KeyFetcher =
| ((DecodedJwt: DecodedJwt) => Promise<string | Buffer>)
| ((DecodedJwt: DecodedJwt, cb: (err: Error | TokenError | null, key: string | Buffer) => void) => void)
| ((DecodedJwt: DecodedJwt) => Promise<Bufferable>)
| ((DecodedJwt: DecodedJwt, cb: (err: Error | TokenError | null, key: Bufferable) => void) => void)
declare function SignerSync(payload: string | Buffer | { [key: string]: any }): string
declare function SignerAsync(payload: string | Buffer | { [key: string]: any }): Promise<string>
declare function SignerAsync(payload: string | Buffer | { [key: string]: any }, cb: SignerCallback): void
type SignerPayload = Bufferable | Record<string, any>
declare function VerifierSync(token: string | Buffer): any
declare function VerifierAsync(token: string | Buffer): Promise<any>
declare function VerifierAsync(token: string | Buffer, cb: object): void
declare function SignerSync<T = SignerPayload>(payload: T): string
declare function SignerAsync<T = SignerPayload>(payload: T): Promise<string>
declare function SignerAsync<T = SignerPayload>(payload: T, cb: SignerCallback): void
declare function VerifierSync<T = Bufferable>(token: T): any
declare function VerifierAsync<T = Bufferable>(token: T): Promise<any>
declare function VerifierAsync<T = Bufferable>(token: T, cb: VerifierCallback): void
export interface JwtHeader extends Record<string, any> {
alg: string | Algorithm
typ?: string | undefined
cty?: string | undefined
crit?: Array<string | Exclude<keyof JwtHeader, 'crit'>> | undefined
kid?: string | undefined
jku?: string | undefined
x5u?: string | string[] | undefined
'x5t#S256'?: string | undefined
x5t?: string | undefined
x5c?: string | string[] | undefined
typ?: string
cty?: string
crit?: Array<string | Exclude<keyof JwtHeader, 'crit'>>
kid?: string
jku?: string
x5u?: string | string[]
'x5t#S256'?: string
x5t?: string
x5c?: string | string[]
}

@@ -119,2 +123,5 @@

type VerifierAllowedBase = string | RegExp
type VerifierAllowed = VerifierAllowedBase | Array<VerifierAllowedBase>
export interface VerifierOptions {

@@ -126,7 +133,7 @@ algorithms?: Algorithm[]

errorCacheTTL?: number | ((tokenError: TokenError) => number)
allowedJti?: string | RegExp | Array<string | RegExp>
allowedAud?: string | RegExp | Array<string | RegExp>
allowedIss?: string | RegExp | Array<string | RegExp>
allowedSub?: string | RegExp | Array<string | RegExp>
allowedNonce?: string | RegExp | Array<string | RegExp>
allowedJti?: VerifierAllowed
allowedAud?: VerifierAllowed
allowedIss?: VerifierAllowed
allowedSub?: VerifierAllowed
allowedNonce?: VerifierAllowed
ignoreExpiration?: boolean

@@ -142,12 +149,12 @@ ignoreNotBefore?: boolean

export interface PrivateKey {
key: string | Buffer
key: Bufferable
passphrase: string | undefined
}
export function createSigner(
options?: Partial<SignerOptions & { key: string | Buffer | PrivateKey }>
): typeof SignerSync
export function createSigner(options?: Partial<SignerOptions & { key: KeyFetcher }>): typeof SignerAsync
export function createDecoder(options?: Partial<DecoderOptions>): (token: string | Buffer) => any
export function createVerifier(options?: Partial<VerifierOptions & { key: string | Buffer }>): typeof VerifierSync
export function createVerifier(options?: Partial<VerifierOptions & { key: KeyFetcher }>): typeof VerifierAsync
export function createSigner<T = SignerPayload>(
options?: Partial<SignerOptions & { key: Bufferable | PrivateKey }>
): typeof SignerSync<T>
export function createSigner<T = SignerPayload>(options?: Partial<SignerOptions & { key: KeyFetcher }>): typeof SignerAsync<T>
export function createDecoder(options?: Partial<DecoderOptions>): (token: Bufferable) => any
export function createVerifier<T = Bufferable>(options?: Partial<VerifierOptions & { key: Bufferable }>): typeof VerifierSync<T>
export function createVerifier<T = Bufferable>(options?: Partial<VerifierOptions & { key: KeyFetcher }>): typeof VerifierAsync<T>

@@ -188,6 +188,3 @@ 'use strict'

// Validate options
if (
algorithm &&
!supportedAlgorithms.has(algorithm)
) {
if (algorithm && !supportedAlgorithms.has(algorithm)) {
throw new TokenError(

@@ -243,3 +240,6 @@ TokenError.codes.invalidOption,

if (typeof expiresIn !== 'number' || expiresIn < 0) {
throw new TokenError(TokenError.codes.invalidOption, 'The expiresIn option must be a positive number or a valid string.')
throw new TokenError(
TokenError.codes.invalidOption,
'The expiresIn option must be a positive number or a valid string.'
)
}

@@ -253,3 +253,6 @@ }

if (typeof notBefore !== 'number' || notBefore < 0) {
throw new TokenError(TokenError.codes.invalidOption, 'The notBefore option must be a positive number or a valid string.')
throw new TokenError(
TokenError.codes.invalidOption,
'The notBefore option must be a positive number or a valid string.'
)
}

@@ -256,0 +259,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc