[PR #3909] [MERGED] fix(cookies): use base64url for session_data and Set-Cookie parsing #5078

Closed
opened 2026-03-13 12:10:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3909
Author: @Kinfe123
Created: 8/10/2025
Status: Merged
Merged: 8/13/2025
Merged by: @Bekacru

Base: canaryHead: fix/expo-base64url-and-set-cookie-parse


📝 Commits (4)

  • 1c0acbb fix(cookies): use base64url for session_data and Set-Cookie parsing
  • 66993f1 Merge branch 'canary' into fix/expo-base64url-and-set-cookie-parse
  • 8b32cf5 chore: lint
  • c6add6c Merge branch 'canary' into fix/expo-base64url-and-set-cookie-parse

📊 Changes

4 files changed (+59 additions, -10 deletions)

View changed files

📝 packages/better-auth/src/api/routes/session.ts (+2 -2)
📝 packages/better-auth/src/cookies/cookies.test.ts (+11 -0)
📝 packages/expo/src/client.ts (+39 -8)
📝 packages/expo/src/expo.test.ts (+7 -0)

📄 Description

This fixes an issue on Base64URL/Base64 mismatch in session_data decoding and harden Set-Cookie parsing to handle Expires commas, preventing malformed/duplicate cookies from Expo clients. Add tests in core utils and Expo client for the new splitter. Resolves “Invalid Base64 character” errors.


Summary by cubic

Fixed session_data decoding to use base64url and improved Set-Cookie parsing to handle Expires commas, preventing cookie errors from Expo clients.

  • Bug Fixes
    • Switched session_data decoding to base64url to resolve "Invalid Base64 character" errors.
    • Updated Set-Cookie parsing logic to correctly split cookies with Expires attributes containing commas.
    • Added tests for the new Set-Cookie splitter in both core utils and Expo client.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/3909 **Author:** [@Kinfe123](https://github.com/Kinfe123) **Created:** 8/10/2025 **Status:** ✅ Merged **Merged:** 8/13/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/expo-base64url-and-set-cookie-parse` --- ### 📝 Commits (4) - [`1c0acbb`](https://github.com/better-auth/better-auth/commit/1c0acbb2057d682210ba5a5f6dc85b589469511a) fix(cookies): use base64url for session_data and Set-Cookie parsing - [`66993f1`](https://github.com/better-auth/better-auth/commit/66993f1721e57ac9835992ddd8c5f377d5c4a90d) Merge branch 'canary' into fix/expo-base64url-and-set-cookie-parse - [`8b32cf5`](https://github.com/better-auth/better-auth/commit/8b32cf5f0e4f48a157cacc5219078672357bfb3c) chore: lint - [`c6add6c`](https://github.com/better-auth/better-auth/commit/c6add6cff35dbdf1fc1f5208bcb52b558c911e71) Merge branch 'canary' into fix/expo-base64url-and-set-cookie-parse ### 📊 Changes **4 files changed** (+59 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/session.ts` (+2 -2) 📝 `packages/better-auth/src/cookies/cookies.test.ts` (+11 -0) 📝 `packages/expo/src/client.ts` (+39 -8) 📝 `packages/expo/src/expo.test.ts` (+7 -0) </details> ### 📄 Description This fixes an issue on Base64URL/Base64 mismatch in session_data decoding and harden Set-Cookie parsing to handle Expires commas, preventing malformed/duplicate cookies from Expo clients. Add tests in core utils and Expo client for the new splitter. Resolves “Invalid Base64 character” errors. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed session_data decoding to use base64url and improved Set-Cookie parsing to handle Expires commas, preventing cookie errors from Expo clients. - **Bug Fixes** - Switched session_data decoding to base64url to resolve "Invalid Base64 character" errors. - Updated Set-Cookie parsing logic to correctly split cookies with Expires attributes containing commas. - Added tests for the new Set-Cookie splitter in both core utils and Expo client. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:10:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5078