feat: improve cookie chunk handling via base64url+length encoding#90
Merged
Conversation
35f4b68 to
af6e190
Compare
af6e190 to
92e1bef
Compare
This was referenced Jan 31, 2025
kangmingtay
reviewed
Feb 4, 2025
Member
There was a problem hiding this comment.
Due to bad uses of this package, some cookie chunks are not being properly deleted.
Do we know what causes the chunks to not be properly deleted? From a DX perspective, it seems rather confusing to have to deal with knowing whether to set the encoding to base64url or base64url+length
update: discussed that this won't really be an issue because we set this internally - users won't have to manually configure this. once this PR is merged, future versions of supabase/ssr will start using the new base64url+length encoding
kangmingtay
approved these changes
Feb 27, 2025
kangmingtay
pushed a commit
that referenced
this pull request
Mar 16, 2025
🤖 I have created a release *beep* *boop* --- ## [0.6.0](v0.5.2...v0.6.0) (2025-02-27) ### Features * improve cookie chunk handling via base64url+length encoding ([#90](#90)) ([6deb687](6deb687)) * upgrade cookie dependency and cleanup imports ([#77](#77)) ([9524528](9524528)) ### Bug Fixes * add `create*Client` string in `x-client-info` ([#85](#85)) ([f271acc](f271acc)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kangmingtay
added a commit
that referenced
this pull request
Mar 16, 2025
kangmingtay
pushed a commit
that referenced
this pull request
Mar 16, 2025
🤖 I have created a release *beep* *boop* --- ## [0.6.1](v0.6.0...v0.6.1) (2025-03-16) ### Bug Fixes * force release ([#98](#98)) ([66710e8](66710e8)) * **revert:** "feat: improve cookie chunk handling via base64url+length encoding ([#90](#90))" ([#100](#100)) ([2ea8e23](2ea8e23)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This was referenced Mar 16, 2025
7 tasks
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.
Improves cookie chunk handling by introducing a new cookie encoding scheme that includes the length of the encoded Base64 value. It will prevent reconstructing data from stale cookies.
Due to bad uses of this package, some cookie chunks are not being properly deleted. Meaning that if a session was encoded in 3 chunks now suddenly goes down to 2 chunks, the last chunk is not being deleted. When it gets reconstructed, all the 3 chunks get concatenated and parsed. In some situations this leads to an invalid UTF-8 sequence (mainly because Base64 packs 6 bits into 8).
This PR addresses this by implementing a different Base64 encoding of the chunks. Instead of just splitting up a Base64 string into chunks, the first chunk will now contain the length of the string that follows. This will prevent a leftover chunk from being parsed as valid.
The encoding is as follows:
base64l-<length of base64 encoded string as base 36>-<base64 encoding>The library now checks for these conditions and emits warnings to let the developer know that they have a bug in their integration.