Skip to content

Commit 935e920

Browse files
lboyntonpanva
andauthored
refactor: catch type error when decoding base64url signature (#569)
Co-authored-by: Filip Skokan <[email protected]>
1 parent f57c197 commit 935e920

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/jws/flattened/verify.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,12 @@ export async function flattenedVerify(
169169
encoder.encode('.'),
170170
typeof jws.payload === 'string' ? encoder.encode(jws.payload) : jws.payload,
171171
)
172-
const signature = base64url(jws.signature)
172+
let signature: Uint8Array
173+
try {
174+
signature = base64url(jws.signature)
175+
} catch {
176+
throw new JWSInvalid('Failed to parse the base64url encoded signature')
177+
}
173178
const verified = await verify(alg, key, signature, data)
174179

175180
if (!verified) {

0 commit comments

Comments
 (0)