From bf286c11d3244afb5132271dac656109934150e0 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Thu, 1 Jan 2026 21:19:30 +0900
Subject: fix(auth): add automatic token refresh on 401 responses
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The client session was too short because access tokens (15 min) weren't
being automatically refreshed using the refresh token (7 days). Now the
ApiClient intercepts 401 responses, attempts token refresh, and retries
the original request. This extends effective session duration to 7 days.

Closes #6

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---
 src/client/stores/sync.test.tsx | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'src/client/stores/sync.test.tsx')

diff --git a/src/client/stores/sync.test.tsx b/src/client/stores/sync.test.tsx
index fee79d7..20de69d 100644
--- a/src/client/stores/sync.test.tsx
+++ b/src/client/stores/sync.test.tsx
@@ -16,6 +16,9 @@ global.fetch = mockFetch;
 vi.mock("../api/client", () => ({
 	apiClient: {
 		getAuthHeader: vi.fn(() => ({ Authorization: "Bearer token" })),
+		authenticatedFetch: vi.fn((input: RequestInfo | URL, init?: RequestInit) =>
+			mockFetch(input, init),
+		),
 	},
 }));
 
-- 
cgit v1.2.3-70-g09d2

