feat: full rewrite using getAll and setAll cookie methods#1
Merged
Conversation
e2beb93 to
d317d4b
Compare
hf
commented
May 24, 2024
hf
commented
May 24, 2024
charislam
reviewed
May 24, 2024
f535af2 to
3deeda2
Compare
Collaborator
Author
Collaborator
Author
b1d9623 to
887b42f
Compare
kangmingtay
reviewed
May 29, 2024
52d29c4 to
5ef5db3
Compare
kangmingtay
reviewed
Jun 5, 2024
This was referenced Jun 6, 2024
Closed
Member
|
@hf would be great if we can also clean up the unused imports in each file |
kangmingtay
approved these changes
Jun 12, 2024
cce4a90 to
48b0968
Compare
Collaborator
Author
Which ones? TypeScript / eslint usually yell about that. |
hf
pushed a commit
that referenced
this pull request
Jun 24, 2024
🤖 I have created a release *beep* *boop* --- ## [0.4.0](v0.3.0...v0.4.0) (2024-06-24) ### Features * full rewrite using `getAll` and `setAll` cookie methods ([#1](#1)) ([b6ae192](b6ae192)) ### Bug Fixes * allow use of `createBrowserClient` without `window` present ([#20](#20)) ([27d868d](27d868d)) * deprecate `parse`, `serialize` exports for more useful functions ([#14](#14)) ([0b5f881](0b5f881)) * fix `createBrowserClient` deprecation tsdoc ([#17](#17)) ([1df70ad](1df70ad)) --- 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 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.


Re-implements the
createServerClientandcreateBrowserClientto solve a few important problems that were not solved with the implementation previously:Cookie encoding
Cookies can't contain just any characters -- they're a limited set of US ASCII and
"is not allowed. Internally the Supabase client uses JSON to encode the session, so this must not be mapped directly to cookies. In this implementation, cookies are encoded as Base64 URL and the leading chunk contains thebase64-prefix.Cookie chunk management
There are a few state transitions when storage needs to be chunked into multiple cookies which were not handled well. This is the reason why a change of API is necessary from
get,setandremovecookie access methods togetAllandsetAll. The library must be able to see all of the cookies and manage deleting unnecessary chunks when that is required.Server-side developer ergonomics
In some SSR frameworks (notably middleware in NextJS) it can be very tricky to set cookies on objects correctly.
createServerClientonly calls thesetAllcookie access method only once and only when necessary. This reduces the number of bugs developers can introduce themselves when using the server client.For more details check the
docs/design.mddocument which contains a lot of details that can't easily be covered in the PR description.