Repository navigation
fix(pairing): normalize base64 consistently across clients - #31465
Conversation
Adapt the community decoder normalization and input bounds from #12027 for current desktop, browser and mobile pairing paths. Co-authored-by: Henry Su <[email protected]> Co-authored-by: OrcaWin <[email protected]>
412c525 to
a14fe36
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
BichengWang
left a comment
There was a problem hiding this comment.
Reviewed a14fe362751472088f25bf173cdd84c918b317f9, including all eight changed files and the desktop, web, and mobile decoder call sites. No blocking findings in the Base64 validation change.
I independently reproduced acceptance of incomplete padding and nonzero trailing-bit aliases on main (5dd5294294), then verified that this head rejects both across all three parsers while preserving canonical padded and unpadded offers. The four changed test suites passed: 66 tests. I also checked every one-, two-, and three-character input over the 64-character alphabet in both standard and URL-safe spellings (532,608 cases) against canonical re-encoding, plus longer payload round trips; the normalizer matched throughout. The trailing-bit positions cover both one-byte and two-byte tails, and the input guards run before trimming or URL parsing.
The shared normalizer has no Node-only imports, keeps the offer schema and wire version unchanged, and bounds input before replacement/allocation, so I found no added platform, mixed-version remote, or unbounded-input risk in this diff. Validation ran on macOS with Node 26 and Bun, using an isolated Vitest config and the existing installed dependencies: the normal root configuration was blocked by a missing @orca/process-host package build, and the mobile configuration by missing Expo dependencies. These are parser checks; I did not run an iOS/Android app, Metro bundle, full build, full typecheck, or end-to-end network pairing.
Problem and behavior
Pairing codes could decode successfully on desktop but fail on another client because padding was handled differently. Use one bounded Base64 normalizer across desktop, mobile and web so a saved code yields the same offer everywhere.
Preserve standard/Base64URL, padded/unpadded, partially or redundantly padded codes, and nonzero unused trailing bits accepted by older clients. Remove trailing padding and restore the required amount before decoding. These spellings produce the same JSON, device token and public key; offer validation and authentication remain unchanged. Reject invalid alphabet/interior padding, impossible data lengths, and oversized input before decoding or URL parsing.
Compatibility verification
The earlier version rejected lossless historical aliases. That was an unnecessary compatibility change and has been removed. Current and historical Orca producers emit canonical unpadded Base64URL, but saved/manual spellings also deserve compatibility.
Compared production parsers before this PR with the revised parsers: 378 spellings covering all three payload byte remainders, trailing-bit aliases, 0–2 padding characters, both alphabets, and bare/query/hash forms. All four revised decoder paths return the identical offer for all 378 inputs. Every input accepted by any baseline decoder remains accepted with the same offer; no compatibility losses in this matrix. The shared browser path was exercised with Buffer absent.
69 focused desktop/browser/normalizer/mobile tests pass. Changed-code quality passes. Existing generated-offer and TLS proxy endpoint round trips remain covered. This is decoder compatibility verification; it does not claim a live pairing/authentication network session. The old simulator screenshots demonstrated the superseded strict rejection policy and have been removed from this description.
Credit
Original padding-parity work: #12027, Henry Su (@hsusul). Cross-client normalization/input bounds: OrcaWin. Both contributor trailers remain in the branch history and must be retained at squash merge.
Risk
Low. Full PR checks and the aggregate gate passed on the merged head. No protocol/schema/credential migration or host-version change. Compatibility is preserved for lossless legacy spellings; size limits and existing schema checks remain. Merged in 82512a4 with both contributor trailers verified; superseded #12027 is closed.