From 7c99153a9e8ae45a35de7eff45fcf6e60e1b088b Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Tue, 22 Feb 2022 10:38:49 +0100 Subject: [PATCH] fix(typescript): allow synchronous get key functions --- src/types.d.ts | 2 +- test-deno/jwks.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/types.d.ts b/src/types.d.ts index bf675eba..739dfc32 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -164,7 +164,7 @@ export interface JWK { * @param token The consumed JWE or JWS token. */ export interface GetKeyFunction { - (protectedHeader: T, token: T2): Promise + (protectedHeader: T, token: T2): Promise | KeyLike | Uint8Array } /** diff --git a/test-deno/jwks.test.ts b/test-deno/jwks.test.ts index 034d4d17..6ecdef13 100644 --- a/test-deno/jwks.test.ts +++ b/test-deno/jwks.test.ts @@ -10,12 +10,12 @@ Deno.test('fetches the JWKSet', async () => { const { alg, kid } = response.keys[0] const jwks = createRemoteJWKSet(new URL(jwksUri)) await assertThrowsAsync( - () => jwks({ alg: 'RS256' }, {}), + async () => jwks({ alg: 'RS256' }, {}), errors.JWKSMultipleMatchingKeys, 'multiple matching keys found in the JSON Web Key Set', ) await assertThrowsAsync( - () => jwks({ kid: 'foo', alg: 'RS256' }, {}), + async () => jwks({ kid: 'foo', alg: 'RS256' }, {}), errors.JWKSNoMatchingKey, 'no applicable key found in the JSON Web Key Set', )