import { getSession } from '@/lib/session'
import { requestSecurityToken } from '@/lib/security-token'

export async function POST(request: Request) {
  const session = await getSession()
  if (!session.accountId) return Response.json({ success: false, error: 'notAuthenticated' }, { status: 401 })
  const ip = (request.headers.get('x-forwarded-for') || '').split(',')[0].trim()
  return Response.json(await requestSecurityToken(session, ip))
}
