Skip to content

Commit

Permalink
fix(typescript): allow synchronous get key functions
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Feb 22, 2022
1 parent 404e9e0 commit 7c99153
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export interface JWK {
* @param token The consumed JWE or JWS token.
*/
export interface GetKeyFunction<T, T2> {
(protectedHeader: T, token: T2): Promise<KeyLike | Uint8Array>
(protectedHeader: T, token: T2): Promise<KeyLike | Uint8Array> | KeyLike | Uint8Array
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test-deno/jwks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }, <FlattenedJWSInput>{}),
async () => jwks({ alg: 'RS256' }, <FlattenedJWSInput>{}),
errors.JWKSMultipleMatchingKeys,
'multiple matching keys found in the JSON Web Key Set',
)
await assertThrowsAsync(
() => jwks({ kid: 'foo', alg: 'RS256' }, <FlattenedJWSInput>{}),
async () => jwks({ kid: 'foo', alg: 'RS256' }, <FlattenedJWSInput>{}),
errors.JWKSNoMatchingKey,
'no applicable key found in the JSON Web Key Set',
)
Expand Down

0 comments on commit 7c99153

Please sign in to comment.