Skip to content

Commit

Permalink
refactor: form flattened jws explicitly in general verify
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Dec 17, 2020
1 parent 47d7001 commit f511889
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/jws/general/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,18 @@ export default async function generalVerify(

// eslint-disable-next-line no-restricted-syntax
for (const signature of jws.signatures) {
const flattened = { payload: jws.payload, ...signature }
try {
// eslint-disable-next-line no-await-in-loop
return await verify(flattened, <Parameters<typeof verify>[1]>key, options)
return await verify(
{
header: signature.header,
payload: jws.payload,
protected: signature.protected,
signature: signature.signature,
},
<Parameters<typeof verify>[1]>key,
options,
)
} catch {
//
}
Expand Down

0 comments on commit f511889

Please sign in to comment.