(request: Request, expectedOwner: string, env: CloudboxBindings)
| 237 | // only by trusted internal callers until verified end-user delegation exists; |
| 238 | // these routes intentionally reject ordinary public API traffic. |
| 239 | function 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 | |
| 249 | function personalComputerId(owner: string): string { |
| 250 | return `personal:${owner.trim().toLowerCase()}`; |
no test coverage detected