refactor(auth): build PKCE verifier from a Uint8Array and drop deprecated substr - #2514
Open
PedroHenrique0713 wants to merge 1 commit into
Open
Conversation
This was referenced Jul 23, 2026
PedroHenrique0713
force-pushed
the
fix/pkce-verifier-uint8array
branch
from
August 4, 2026 23:08
4b94e20 to
a237bd4
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe PKCE verifier generator now uses Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🔍 Description
What changed?
generatePKCEVerifier()built the PKCE code verifier from aUint32Array(56)but kept only the low byte of each element (viadec2hex). This switches it to aUint8Array(56)and replaces the deprecatedString.prototype.substrwithslice. The typed-array allocation was also moved inside thecryptobranch so the no-WebCrypto fallback no longer allocates an unused buffer.Why was this change needed?
new Uint32Array(56)draws 224 bytes fromcrypto.getRandomValues, butdec2hex(('0' + dec.toString(16)).substr(-2)) keeps only the last hex pair — the low byte — discarding 3 of every 4 bytes. AUint8Array(56)requests exactly the 56 bytes actually consumed.String.prototype.substr()is a legacy/deprecated feature;slice(-2)is the standard equivalent.No behavior change. The output is byte-for-byte equivalent: 56 bytes → two hex chars each → the same 112-character, hex-only verifier (well within RFC 7636's 43–128 range). The low byte of a uniform
Uint32is itself uniform, so the entropy distribution is identical — this only stops requesting (and discarding) 4× the randomness.🔄 Breaking changes
📋 Checklist
<type>(<scope>): <description>pnpm nx formatto ensure consistent code formatting📝 Additional notes
Added a
generatePKCEVerifiertest block (length within the RFC 7636 range, unreserved charset, uniqueness). Verified locally:jest test/helpers.test.ts→ 27 passed,tsc -p tsconfig.json→ clean,prettier --check→ clean.