From 4a0aa12de4d093b6209fcf1da8ba4a117122ffca Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 27 Jun 2024 17:43:15 +0200 Subject: [PATCH] fix: ensure KeyObject type in Web API encrypt/decrypt --- src/lib/decrypt_key_management.ts | 4 ++-- src/lib/encrypt_key_management.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/decrypt_key_management.ts b/src/lib/decrypt_key_management.ts index 86ae5994242..c56177aa271 100644 --- a/src/lib/decrypt_key_management.ts +++ b/src/lib/decrypt_key_management.ts @@ -20,11 +20,11 @@ async function decryptKeyManagement( joseHeader: JWEHeaderParameters, options?: DecryptOptions, ): Promise { + checkKeyType(alg, key, 'decrypt') + // @ts-ignore key = (await normalize.normalizePrivateKey?.(key, alg)) || key - checkKeyType(alg, key, 'decrypt') - switch (alg) { case 'dir': { // Direct Encryption diff --git a/src/lib/encrypt_key_management.ts b/src/lib/encrypt_key_management.ts index cc069214631..a96b5a3b85a 100644 --- a/src/lib/encrypt_key_management.ts +++ b/src/lib/encrypt_key_management.ts @@ -32,11 +32,11 @@ async function encryptKeyManagement( let parameters: (JWEHeaderParameters & { epk?: JWK }) | undefined let cek: KeyLike | Uint8Array + checkKeyType(alg, key, 'encrypt') + // @ts-ignore key = (await normalize.normalizePublicKey?.(key, alg)) || key - checkKeyType(alg, key, 'encrypt') - switch (alg) { case 'dir': { // Direct Encryption