From aaed64484c9530758e2f0a576c91c2958dfa7f97 Mon Sep 17 00:00:00 2001 From: superdooper86 Date: Mon, 11 May 2026 09:49:57 +0200 Subject: [PATCH] fix: include anthropic.com cookies in all auth checks and API requests Claude session cookies are on anthropic.com, not claude.ai. The login window was not detecting auth (Cancel stayed, no Done) and API calls were sent without the actual session token. - claudeCookieHeader: include anthropic.com cookies so the token is sent to the usage/bootstrap endpoints - checkInitialSignInState: detect anthropic.com cookies on startup - didFinish in LoginView: fire auth when anthropic.com cookies found - signOut: clear anthropic.com data alongside claude.ai - notAuthenticated catch: set isSignedIn = false so Settings stays in sync with the main panel --- ClaudeChecker/Info.plist | 4 ++-- ClaudeChecker/LoginView.swift | 2 +- ClaudeChecker/UsageViewModel.swift | 7 ++++--- RELEASE_NOTES.md | 4 +++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ClaudeChecker/Info.plist b/ClaudeChecker/Info.plist index 486b9e4..5ae3940 100644 --- a/ClaudeChecker/Info.plist +++ b/ClaudeChecker/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.2.1-beta.6 + 1.2.1-beta.7 CFBundleVersion - 54 + 55 LSMinimumSystemVersion 13.0 LSUIElement diff --git a/ClaudeChecker/LoginView.swift b/ClaudeChecker/LoginView.swift index 470d879..26830cb 100644 --- a/ClaudeChecker/LoginView.swift +++ b/ClaudeChecker/LoginView.swift @@ -38,7 +38,7 @@ struct LoginWebView: NSViewRepresentable { // URL is not a login/auth page, so if any claude.ai cookie exists we're signed in WKWebsiteDataStore.default().httpCookieStore.getAllCookies { cookies in - let hasAnyCookie = cookies.contains { $0.domain.contains("claude.ai") } + let hasAnyCookie = cookies.contains { $0.domain.contains("claude.ai") || $0.domain.contains("anthropic.com") } guard hasAnyCookie, !self.didAuthenticate else { return } self.didAuthenticate = true DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { diff --git a/ClaudeChecker/UsageViewModel.swift b/ClaudeChecker/UsageViewModel.swift index 24f5f28..b96caf6 100644 --- a/ClaudeChecker/UsageViewModel.swift +++ b/ClaudeChecker/UsageViewModel.swift @@ -43,7 +43,7 @@ class UsageViewModel: ObservableObject { private func checkInitialSignInState() async { let cookies = await WKWebsiteDataStore.default().httpCookieStore.allCookies() - let hasAnyCookie = cookies.contains { $0.domain.contains("claude.ai") } + let hasAnyCookie = cookies.contains { $0.domain.contains("claude.ai") || $0.domain.contains("anthropic.com") } if hasAnyCookie { isSignedIn = true } } @@ -51,7 +51,7 @@ class UsageViewModel: ObservableObject { let store = WKWebsiteDataStore.default() let types = WKWebsiteDataStore.allWebsiteDataTypes() let records = await store.dataRecords(ofTypes: types) - let claudeRecords = records.filter { $0.displayName.contains("claude.ai") } + let claudeRecords = records.filter { $0.displayName.contains("claude.ai") || $0.displayName.contains("anthropic.com") } await store.removeData(ofTypes: types, for: claudeRecords) UserDefaults.standard.removeObject(forKey: "claude_org_id") isSignedIn = false @@ -109,6 +109,7 @@ class UsageViewModel: ObservableObject { checkLimitNotifications(for: limits) } catch AppError.notAuthenticated { isNotAuthenticated = true + isSignedIn = false errorMessage = "Not signed in" } catch let error as DecodingError { switch error { @@ -192,7 +193,7 @@ class UsageViewModel: ObservableObject { private func claudeCookieHeader() async -> String? { let cookies = await WKWebsiteDataStore.default().httpCookieStore.allCookies() - let claudeCookies = cookies.filter { $0.domain.contains("claude.ai") } + let claudeCookies = cookies.filter { $0.domain.contains("claude.ai") || $0.domain.contains("anthropic.com") } return HTTPCookie.requestHeaderFields(with: claudeCookies)["Cookie"] } diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c408a82..d3c4a36 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,4 +6,6 @@ - Fixed login window auto-closing before the user could sign in — the login window now correctly loads the `/login` page so it only detects auth after the actual sign-in redirect - Fixed "No API key configured" showing after signing out — now correctly shows "Not signed in" with a prompt to sign in - Added `/api/organizations` as a final fallback for org ID resolution when the bootstrap API response doesn't include it -- Fixed usage data not loading after sign-in — API requests now include required browser-like headers (Origin, Referer, User-Agent) that Claude's usage endpoints require +- Fixed usage data not loading — API requests now include required browser-like headers (Origin, Referer, User-Agent) +- Fixed sign-in detection and cookie handling for accounts whose session cookies are on the `anthropic.com` domain rather than `claude.ai` +- Fixed Settings incorrectly showing "Signed in" after a failed refresh — sign-in state now resets when authentication fails