1import { cookies } from 'next/headers';
5 authenticated: boolean;
15export async function getStoredAuth(): Promise<SessionData | null> {
17 const cookieStore = await cookies();
18 const sessionCookie = cookieStore.get('fieldpine-session');
24 const sessionData: SessionData = JSON.parse(sessionCookie.value);
26 // Check if session is expired (8 hours)
27 if (Date.now() - sessionData.timestamp > 8 * 60 * 60 * 1000) {
33 console.error('Error retrieving stored auth:', error);
38export async function getStoredApiKey(): Promise<string | null> {
39 const auth = await getStoredAuth();
40 return auth?.apiKey || null;
43export async function isAuthenticated(): Promise<boolean> {
44 const auth = await getStoredAuth();
45 return auth?.authenticated === true;