import { cookies } from 'next/headers'; import { verifySurrealJwt, type UserSession } from './jwt'; /** * Gets the current authenticated user from the session cookie. * This function should be called from Server Components or API routes. * * @returns The user session if authenticated, null otherwise */ export async function getCurrentUser(): Promise { const cookieStore = await cookies(); const authCookie = cookieStore.get('ponderants-auth'); if (!authCookie?.value) { return null; } return verifySurrealJwt(authCookie.value); }