Skip to content

Commit ffc1b8c

Browse files
authored
chore: add type for cacheKeyBuilder (#546)
relates to #504
1 parent cd12d28 commit ffc1b8c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export interface VerifierOptions {
140140
clockTolerance?: number
141141
requiredClaims?: Array<string>
142142
checkTyp?: string
143+
cacheKeyBuilder?: (token: string) => string
143144
}
144145

145146
export interface PrivateKey {

test/types.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ createVerifier<Record<string, number>>({
9393
checkTyp: 'JWT'
9494
})({ key: 1 }).then(console.log, console.log)
9595

96+
// Verifier with cacheKeyBuilder
97+
createVerifier<Record<string, number>>({
98+
key: 'KEY',
99+
algorithms: ['RS256'],
100+
requiredClaims: ['aud'],
101+
checkTyp: 'JWT',
102+
cacheKeyBuilder: (token: string) => token
103+
})({ key: 1 }).then(console.log, console.log)
104+
96105
// Errors
97106
const wrapped = TokenError.wrap(new Error('ORIGINAL'), 'FAST_JWT_INVALID_TYPE', 'MESSAGE')
98107
wrapped.code === 'FAST_JWT_INVALID_TYPE'

0 commit comments

Comments
 (0)