Something went wrong. Try again.
FlockOff is a mass-block tool for the Atmosphere flockoff.app
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536import 'server-only'import { getIronSession } from 'iron-session'import { cookies } from 'next/headers'import type { SessionData } from '@/types'
function getSessionOptions() { const sessionSecret = process.env.SESSION_SECRET if (!sessionSecret || sessionSecret.length < 32) { throw new Error('SESSION_SECRET must be set and at least 32 characters long') }
return { password: sessionSecret, cookieName: 'flockoff-session', cookieOptions: { httpOnly: true, secure: process.env.NODE_ENV === 'production', sameSite: 'lax' as const, maxAge: 60 * 60 * 24 * 30, // 30 days }, }}
export async function getSession() { const cookieStore = await cookies() return getIronSession<SessionData>(cookieStore, getSessionOptions())}
export async function requireSession() { const session = await getSession() if (!session.did) { throw new Error('Not authenticated') } return session as { did: string; handle?: string }}