import { cookies } from "next/headers"; import { getOAuthClient } from "./client"; import type { OAuthSession } from "@atproto/oauth-client-node"; export async function getSession(): Promise { const did = await getDid(); if (!did) return null; try { const client = await getOAuthClient(); return await client.restore(did); } catch { return null; } } export async function getDid(): Promise { const cookieStore = await cookies(); return cookieStore.get("did")?.value ?? null; }