MCPcopy Create free account
hub / github.com/Shinplex/rever / requireAuth

Function requireAuth

retool.ts:253–260  ·  view source on GitHub ↗
(req: Request)

Source from the content-addressed store, hash-verified

251// HTTP Server
252// ----------------------------------------------------------------------------
253function requireAuth(req: Request): string {
254 const header = req.headers.get("Authorization") ?? "";
255 const m = header.match(/^Bearer\s+(.+)$/i);
256 if (!m) throw new Error("401");
257 const token = m[1].trim();
258 if (!VALID_CLIENT_KEYS.has(token)) throw new Error("403");
259 return token;
260}
261
262function jsonResponse(obj: unknown, status = 200) {
263 return new Response(JSON.stringify(obj), {

Callers 1

handleRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected