-
Notifications
You must be signed in to change notification settings - Fork 743
Add multi-account token support for Codex and API-key providers #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
977680e
Add token-account support for API-key providers
Minoo7 3103147
Enable multi-account token support for Codex
Minoo7 7ac95af
Add Codex manual cookie test and save-account actions
Minoo7 d2c92df
Use web source for Codex token-account switches
Minoo7 43d292b
Fix provider version probe process cleanup crash
Minoo7 3beea24
Route Codex token-account switching through web usage
Minoo7 90a5571
Make Codex cookie test action explicit and clearer
Minoo7 0717ff2
Use manual Codex cookie headers in web strategy
Minoo7 0a5c253
Differentiate invalid manual cookie vs login-required
Minoo7 2fdae50
Fix cookie normalizer truncating JWT-like values
Minoo7 6d3d7f6
Fix Codex dashboard switching across token accounts
Minoo7 645f679
Refresh menu after token account switch completes
Minoo7 6e2a9df
Clear stale menu data during account switch
Minoo7 d1e1f6e
Add OAuth-based Codex account login
Minoo7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import CodexBarCore | ||
| import Foundation | ||
|
|
||
| enum CodexOAuthAccountStore { | ||
| static func createProfileDirectory( | ||
| label: String, | ||
| rootDirectory: URL? = nil, | ||
| fileManager: FileManager = .default) throws -> URL | ||
| { | ||
| let root = rootDirectory ?? CodexBarConfigStore.defaultURL() | ||
| .deletingLastPathComponent() | ||
| .appendingPathComponent("codex-oauth-accounts", isDirectory: true) | ||
| try fileManager.createDirectory(at: root, withIntermediateDirectories: true) | ||
|
|
||
| let slug = self.slug(for: label) | ||
| let directory = root.appendingPathComponent("\(slug)-\(UUID().uuidString)", isDirectory: true) | ||
| try fileManager.createDirectory(at: directory, withIntermediateDirectories: true) | ||
| return directory | ||
| } | ||
|
|
||
| static func removeProfileDirectoryIfPresent(_ directory: URL, fileManager: FileManager = .default) { | ||
| try? fileManager.removeItem(at: directory) | ||
| } | ||
|
|
||
| private static func slug(for label: String) -> String { | ||
| let trimmed = label.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() | ||
| let slug = trimmed.unicodeScalars.map { scalar -> Character in | ||
| if CharacterSet.alphanumerics.contains(scalar) { | ||
| return Character(scalar) | ||
| } | ||
| return "-" | ||
| } | ||
| let collapsed = String(slug) | ||
| .replacingOccurrences(of: "--+", with: "-", options: .regularExpression) | ||
| .trimmingCharacters(in: CharacterSet(charactersIn: "-")) | ||
| return collapsed.isEmpty ? "codex-account" : collapsed | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeout task uses
try? await Task.sleep(...)and then unconditionally callscoordinator.cancelForTimeout(). If the task gets cancelled (e.g., because the login task completed first andgroup.cancelAll()runs),Task.sleepthrowsCancellationErrorwhich is swallowed bytry?, so this task will still runcancelForTimeout()and may cancel the HTTP listener / finish the coordinator after a successful completion. Handle cancellation explicitly (e.g.,do/try/catcharoundTask.sleepand return early on cancellation) socancelForTimeout()only runs when the sleep actually completes without cancellation.