Meal planning and recipes sorted
1import { cookies } from "next/headers";
2import { getOAuthClient } from "./client";
3import type { OAuthSession } from "@atproto/oauth-client-node";
4
5export async function getSession(): Promise<OAuthSession | null> {
6 const did = await getDid();
7 if (!did) return null;
8
9 try {
10 const client = await getOAuthClient();
11 return await client.restore(did);
12 } catch {
13 return null;
14 }
15}
16
17export async function getDid(): Promise<string | null> {
18 const cookieStore = await cookies();
19 return cookieStore.get("did")?.value ?? null;
20}