Skip to content

Commit

Permalink
refactor: update allow list error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Oct 25, 2023
1 parent f56464b commit fe8114c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/jwe/flattened/decrypt.ts
Expand Up @@ -163,11 +163,11 @@ export async function flattenedDecrypt(
validateAlgorithms('contentEncryptionAlgorithms', options.contentEncryptionAlgorithms)

if (keyManagementAlgorithms && !keyManagementAlgorithms.has(alg)) {
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter not allowed')
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed')
}

if (contentEncryptionAlgorithms && !contentEncryptionAlgorithms.has(enc)) {
throw new JOSEAlgNotAllowed('"enc" (Encryption Algorithm) Header Parameter not allowed')
throw new JOSEAlgNotAllowed('"enc" (Encryption Algorithm) Header Parameter value not allowed')
}

let encryptedKey!: Uint8Array
Expand Down
2 changes: 1 addition & 1 deletion src/jws/flattened/verify.ts
Expand Up @@ -145,7 +145,7 @@ export async function flattenedVerify(
const algorithms = options && validateAlgorithms('algorithms', options.algorithms)

if (algorithms && !algorithms.has(alg)) {
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter not allowed')
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed')
}

if (b64) {
Expand Down
4 changes: 2 additions & 2 deletions test/jwt/decrypt.test.mjs
Expand Up @@ -99,7 +99,7 @@ test('contentEncryptionAlgorithms and keyManagementAlgorithms options', async (t
}),
{
code: 'ERR_JOSE_ALG_NOT_ALLOWED',
message: '"alg" (Algorithm) Header Parameter not allowed',
message: '"alg" (Algorithm) Header Parameter value not allowed',
},
)
await t.throwsAsync(
Expand All @@ -117,7 +117,7 @@ test('contentEncryptionAlgorithms and keyManagementAlgorithms options', async (t
}),
{
code: 'ERR_JOSE_ALG_NOT_ALLOWED',
message: '"enc" (Encryption Algorithm) Header Parameter not allowed',
message: '"enc" (Encryption Algorithm) Header Parameter value not allowed',
},
)
await t.throwsAsync(
Expand Down
2 changes: 1 addition & 1 deletion test/jwt/verify.test.mjs
Expand Up @@ -109,7 +109,7 @@ test('algorithms options', async (t) => {
}),
{
code: 'ERR_JOSE_ALG_NOT_ALLOWED',
message: '"alg" (Algorithm) Header Parameter not allowed',
message: '"alg" (Algorithm) Header Parameter value not allowed',
},
)
await t.throwsAsync(
Expand Down

0 comments on commit fe8114c

Please sign in to comment.