refactor: unify duplicate session restoration logic (#21)
* refactor: unify duplicate session restoration logic
Extract shared restoreOAuthSession() into lib/session.ts to eliminate
duplicate cookie-lookup + OAuth-restore logic from middleware/auth.ts
and routes/auth.ts. The auth middleware now wraps the shared function
to produce AuthenticatedUser with Agent/handle/pdsUrl enrichment.
* fix: eliminate redundant cookie store query in session restoration
Changes:
- `restoreOAuthSession()` now returns both oauth + cookie sessions
- Removes duplicate `cookieSessionStore.get()` call in auth middleware
- Adds `handle` field to `/api/auth/session` response (bonus improvement)
- Updates tests to match new return structure
Before: Cookie store queried twice per authenticated request
After: Single query, both sessions returned together
Addresses PR #21 review feedback (Option A - recommended approach)
---------
Co-authored-by: Claude <noreply@anthropic.com>