MCPcopy Create free account
hub / github.com/acoyfellow/cloudbox / validateSpec

Function validateSpec

src/http.ts:303–311  ·  view source on GitHub ↗
(spec: ComputerSpec | null)

Source from the content-addressed store, hash-verified

301function authorizeAction(request: Request, action: string, env: CloudboxBindings): Response | null {
302 if (request.headers.get("x-cloudbox-demo") === "1") return null;
303 if (env.CLOUDBOX_INTERNAL_TOKEN && request.headers.get("x-cloudbox-internal-token") === env.CLOUDBOX_INTERNAL_TOKEN) return null;
304 const token = env.CLOUDBOX_API_TOKEN;
305 if (!token) return null;
306 const got = request.headers.get("authorization")?.replace(/^Bearer\s+/i, "") ?? request.headers.get("x-cloudbox-token");
307 return got === token ? null : jsonErrorResponse(401, "unauthorized", "valid Cloudbox token required");
308}
309
310function isPublicDemoSpec(spec: ComputerSpec | null): boolean {
311 return !!spec?.name && spec.name === "agent-launch-readiness" && typeof spec.runId === "string" && spec.runId.startsWith("browser-");
312}
313
314function validateSpec(spec: ComputerSpec | null): Response | null {

Callers 1

http.tsFile · 0.70

Calls 1

jsonErrorResponseFunction · 0.90

Tested by

no test coverage detected