Skip to content

Commit

Permalink
fix: throw when options are provided while in raw buffer mode
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Jul 22, 2021
1 parent eebab05 commit 5434b46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/v1/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ module.exports = async function v1Verify (token, key, { complete = false, buffer
const { m, footer } = await verify('v1.public.', token, 'sha384', 256, { key, padding, saltLength })

if (buffer) {
if (Object.keys(options).length !== 0) {
throw new TypeError('options cannot contain claims when options.buffer is true')
}
if (complete) {
return { payload: m, footer, version: 'v1', purpose: 'public' }
}
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ module.exports = async function v2Verify (token, key, { complete = false, buffer
const { m, footer } = await verify('v2.public.', token, undefined, 64, key)

if (buffer) {
if (Object.keys(options).length !== 0) {
throw new TypeError('options cannot contain claims when options.buffer is true')
}
if (complete) {
return { payload: m, footer, version: 'v2', purpose: 'public' }
}
Expand Down

0 comments on commit 5434b46

Please sign in to comment.