import { ServiceError } from "./service-error"; /** Device upload tokens cannot authorize staff actions or issue other credentials. */ export async function browserAccount( request: Pick, getUser: () => Promise, ): Promise { if (request.headers.has("authorization")) throw new ServiceError("Use your signed-in account for this action", 403); const account = await getUser(); if (!account) throw new ServiceError("Sign in to continue", 401); return account; } export async function limitRoomCreation( accountId: string, accessHash: string, limit: (key: string, count: number, seconds: number) => Promise, ) { // A browser cookie is replaceable. The verified account is the durable limit. await limit("multiplayer:create:account:" + accountId, 20, 3600); await limit("multiplayer:create:" + accessHash, 20, 3600); }