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
feat: improve cookie chunk handling via base64url+length encoding (#90)
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.
"@supabase/ssr: Detected stale cookie data that does not decode to a UTF-8 string. Please check your integration with Supabase for bugs. This can cause your users to loose session access.",
1147
+
],
1148
+
[
1149
+
"@supabase/ssr: Detected stale cookie data that does not decode to a UTF-8 string. Please check your integration with Supabase for bugs. This can cause your users to loose session access.",
// if an invalid UTF-8 sequence is encountered, it means that reconstructing the chunkedCookie failed and the cookies don't contain useful information
33
+
console.warn(
34
+
"@supabase/ssr: Detected stale cookie data that does not decode to a UTF-8 string. Please check your integration with Supabase for bugs. This can cause your users to loose session access.",
0 commit comments