fix(jwt): throw JwtTokenInvalid when the signature is not valid base64url (#5379)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* fix(jwt): throw JwtTokenInvalid when the signature is not valid base64url verify() decoded the signature part with decodeBase64Url outside any try/catch, so a token whose third part contains characters outside the base64url alphabet rejected with a raw InvalidCharacterError DOMException instead of JwtTokenInvalid, unlike the header and payload parts. Wrap the decode so the typed error is thrown consistently. * test(jwt): assert the error class for invalid base64url signatures Replace the uninitialized-variable and @ts-ignore pattern with a type-safe rejection assertion that checks the JwtTokenInvalid class and its documented message, so the test also fails if verification resolves or rejects with the raw decoding error. Add a control asserting an empty signature still reports JwtTokenSignatureMismatched. ---------
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: ndycode <ndycode@users.noreply.github.com>
Diff stats
2 files+21 added−6 removed
- tests:+14 added−0 removed
- other:+7 added−6 removed