Skip to content

Commit

Permalink
chore: add type for cacheKeyBuilder
Browse files Browse the repository at this point in the history
relates to #504
  • Loading branch information
aheckmann committed Feb 10, 2025
1 parent cd12d28 commit 985409b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export interface VerifierOptions {
clockTolerance?: number
requiredClaims?: Array<string>
checkTyp?: string
cacheKeyBuilder?: (token: string) => string
}

export interface PrivateKey {
Expand Down
9 changes: 9 additions & 0 deletions test/types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ createVerifier<Record<string, number>>({
checkTyp: 'JWT'
})({ key: 1 }).then(console.log, console.log)

// Verifier with cacheKeyBuilder
createVerifier<Record<string, number>>({
key: 'KEY',
algorithms: ['RS256'],
requiredClaims: ['aud'],
checkTyp: 'JWT',
cacheKeyBuilder: (token: string) => token
})({ key: 1 }).then(console.log, console.log)

// Errors
const wrapped = TokenError.wrap(new Error('ORIGINAL'), 'FAST_JWT_INVALID_TYPE', 'MESSAGE')
wrapped.code === 'FAST_JWT_INVALID_TYPE'
Expand Down

0 comments on commit 985409b

Please sign in to comment.