import { getCookie } from "hono/cookie"; import { getOAuthClient } from "./client"; import type { Context } from "hono"; import type { OAuthSession } from "@atproto/oauth-client-node"; export async function getDid(c: Context): Promise { return getCookie(c, "did") ?? null; } export async function getSession( c: Context ): Promise { const did = await getDid(c); if (!did) return null; try { const client = await getOAuthClient(); return await client.restore(did); } catch { return null; } }