MCPcopy
hub / github.com/rohitg00/agentmemory / checkAuth

Function checkAuth

src/triggers/api.ts:39–52  ·  view source on GitHub ↗
(
  req: ApiRequest,
  secret: string | undefined,
)

Source from the content-addressed store, hash-verified

37}
38
39function checkAuth(
40 req: ApiRequest,
41 secret: string | undefined,
42): Response | null {
43 if (!secret) return null;
44 const auth = req.headers?.["authorization"] || req.headers?.["Authorization"];
45 if (
46 typeof auth !== "string" ||
47 !timingSafeCompare(auth, `Bearer ${secret}`)
48 ) {
49 return { status_code: 401, body: { error: "unauthorized" } };
50 }
51 return null;
52}
53
54function requireConfiguredSecret(
55 secret: string | undefined,

Callers 1

registerApiTriggersFunction · 0.70

Calls 1

timingSafeCompareFunction · 0.85

Tested by

no test coverage detected