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

Function internalComputerOwner

src/http-personal-computers.ts:239–247  ·  view source on GitHub ↗
(request: Request, expectedOwner: string, env: CloudboxBindings)

Source from the content-addressed store, hash-verified

237// only by trusted internal callers until verified end-user delegation exists;
238// these routes intentionally reject ordinary public API traffic.
239function internalComputerOwner(request: Request, expectedOwner: string, env: CloudboxBindings): Response | null {
240 const internalToken = env.CLOUDBOX_INTERNAL_TOKEN;
241 const gotToken = request.headers.get("x-cloudbox-internal-token");
242 const owner = request.headers.get("x-cloudbox-owner");
243 if (!internalToken || gotToken !== internalToken || !owner || owner.toLowerCase() !== expectedOwner.toLowerCase()) {
244 return jsonErrorResponse(403, "computer_internal_only", "durable computer slice requires trusted owner delegation");
245 }
246 return null;
247}
248
249function personalComputerId(owner: string): string {
250 return `personal:${owner.trim().toLowerCase()}`;

Callers 1

Calls 2

jsonErrorResponseFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected