mirror of
https://github.com/danbulant/jose
synced 2026-05-19 04:18:52 +00:00
fix(typescript): allow synchronous get key functions
This commit is contained in:
parent
404e9e0bc8
commit
7c99153a9e
2 changed files with 3 additions and 3 deletions
2
src/types.d.ts
vendored
2
src/types.d.ts
vendored
|
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue