MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / tokenFromRequest

Function tokenFromRequest

projects/runtime-node/src/server.ts:40–45  ·  view source on GitHub ↗
(request: http.IncomingMessage)

Source from the content-addressed store, hash-verified

38}
39
40function tokenFromRequest(request: http.IncomingMessage): string | null {
41 const protocolHeader = request.headers["sec-websocket-protocol"]
42 const protocols = Array.isArray(protocolHeader) ? protocolHeader.flatMap((value) => value.split(",")) : (protocolHeader ?? "").split(",")
43 const bearer = protocols.map((value) => value.trim()).find((value) => value.startsWith("bearer."))
44 return bearer?.slice("bearer.".length) ?? null
45}
46
47function clientRequestPrincipalFromRequest(request: http.IncomingMessage): string | undefined {
48 const token = tokenFromRequest(request)

Callers 2

isAuthorizedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected