Skip to content

Commit

Permalink
fix: ensure KeyObject type in Web API encrypt/decrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Jun 27, 2024
1 parent 32b25a5 commit b7920bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/decrypt_key_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ async function decryptKeyManagement(
joseHeader: JWEHeaderParameters,
options?: DecryptOptions,
): Promise<KeyLike | Uint8Array> {
checkKeyType(alg, key, 'decrypt')

// @ts-ignore
key = (await normalize.normalizePrivateKey?.(key, alg)) || key

checkKeyType(alg, key, 'decrypt')

switch (alg) {
case 'dir': {
// Direct Encryption
Expand Down
4 changes: 2 additions & 2 deletions src/lib/encrypt_key_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7920bd

Please sign in to comment.