You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixes two distinct HMAC signature encoding bugs and adds a hex.toBytes convenience API. The changes are well-targeted and backed by solid parameterized tests.
Hex verify bug fixed: verify previously called hex.decode, which UTF-8-decoded the raw signature bytes into a string before passing them to WebCrypto — the double-encoding corrupted the signature. It now calls hex.toBytes to keep the bytes intact.
Standard base64 signing fixed: "base64" encoding previously called base64Url.encode (URL-safe alphabet), so the output contained -/_ instead of +//. It now correctly calls base64.encode.
hex.toBytes API: New function wraps hexToBytes from @noble/hashes and is exposed on the hex object, enabling callers to obtain raw bytes from a hex string without a UTF-8 round-trip.
Confidence Score: 4/5
Safe to merge — all changes are focused bug fixes with matching expected-value tests that pin the corrected behaviour.
The logic is correct and the tests are self-consistent, but two real defects in the production signing/verification path are being fixed here and deserve a final sanity check before merging into a security-sensitive utility library.
Files Needing Attention: No files require special attention, though a quick read of src/hmac.ts verify path is worthwhile given the nature of the changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Corrects Base64 and hex signature handling and adds a reusable hex-to-bytes API