From 985409b32a882ad67b304a54a31063cd9ef1c1c7 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Fri, 7 Feb 2025 11:25:05 -0800 Subject: [PATCH] chore: add type for cacheKeyBuilder relates to #504 --- src/index.d.ts | 1 + test/types.spec.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/index.d.ts b/src/index.d.ts index 7df6318..9c0368f 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -140,6 +140,7 @@ export interface VerifierOptions { clockTolerance?: number requiredClaims?: Array checkTyp?: string + cacheKeyBuilder?: (token: string) => string } export interface PrivateKey { diff --git a/test/types.spec.ts b/test/types.spec.ts index 6bf5178..6c43031 100644 --- a/test/types.spec.ts +++ b/test/types.spec.ts @@ -93,6 +93,15 @@ createVerifier>({ checkTyp: 'JWT' })({ key: 1 }).then(console.log, console.log) +// Verifier with cacheKeyBuilder +createVerifier>({ + 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'