[PR #8025] [MERGED] chore(electron): fix race condition #24594

Closed
opened 2026-04-15 22:27:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8025
Author: @jslno
Created: 2/17/2026
Status: Merged
Merged: 2/17/2026
Merged by: @Bekacru

Base: canaryHead: 02-17-2026/electron-race-condition


📝 Commits (2)

📊 Changes

4 files changed (+87 additions, -57 deletions)

View changed files

📝 packages/electron/src/authenticate.ts (+18 -17)
📝 packages/electron/src/index.ts (+6 -1)
📝 packages/electron/test/electron.test.ts (+56 -39)
📝 packages/electron/test/utils.ts (+7 -0)

📄 Description

Summary by cubic

Fix Electron auth race condition by scoping code_verifier to the auth state and bundling state with the identifier in a base64url redirect token. This makes concurrent sign-ins reliable, prevents state mismatches, and hardens token parsing.

  • Bug Fixes
    • Replace global kCodeVerifier/kState with kElectron Map(state → code_verifier); entries are cleared after use.
    • Redirect cookie now stores a base64url token of { identifier, state }; authenticate safely decodes it (safeJSONParse) and sends identifier + state.
    • Tightened state validation; mismatches return BAD_REQUEST with “state mismatch”.
    • Updated tests and added encodeRedirectToken helper.

Written for commit 108adb89e6. Summary will update on new commits.


🔄 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/8025 **Author:** [@jslno](https://github.com/jslno) **Created:** 2/17/2026 **Status:** ✅ Merged **Merged:** 2/17/2026 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `02-17-2026/electron-race-condition` --- ### 📝 Commits (2) - [`1bdcb75`](https://github.com/better-auth/better-auth/commit/1bdcb756632ae6997183a5758b37706194eacc87) chore(electron: fix race condition - [`108adb8`](https://github.com/better-auth/better-auth/commit/108adb89e6e73d15bbce30501b09f78d3b1e3f45) chore: cleanup ### 📊 Changes **4 files changed** (+87 additions, -57 deletions) <details> <summary>View changed files</summary> 📝 `packages/electron/src/authenticate.ts` (+18 -17) 📝 `packages/electron/src/index.ts` (+6 -1) 📝 `packages/electron/test/electron.test.ts` (+56 -39) 📝 `packages/electron/test/utils.ts` (+7 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fix Electron auth race condition by scoping code_verifier to the auth state and bundling state with the identifier in a base64url redirect token. This makes concurrent sign-ins reliable, prevents state mismatches, and hardens token parsing. - **Bug Fixes** - Replace global kCodeVerifier/kState with kElectron Map(state → code_verifier); entries are cleared after use. - Redirect cookie now stores a base64url token of { identifier, state }; authenticate safely decodes it (safeJSONParse) and sends identifier + state. - Tightened state validation; mismatches return BAD_REQUEST with “state mismatch”. - Updated tests and added encodeRedirectToken helper. <sup>Written for commit 108adb89e6e73d15bbce30501b09f78d3b1e3f45. Summary will update on new commits.</sup> <!-- 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-04-15 22:27:17 -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#24594