import { supabase } from '../../lib/supabase' import { AdminServiceError } from './admin-service' export async function requireAdminAccessToken(expectedUserId: string): Promise { const { data, error } = await supabase.auth.getSession() const session = data.session if (error !== null || session === null || session.user.id !== expectedUserId) { throw new AdminServiceError('auth', null, false) } const token = session.access_token.trim() if (token.length < 20 || token.length > 16_384 || /\s/.test(token)) { throw new AdminServiceError('auth', null, false) } return token }