MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / extractBearer

Function extractBearer

packages/server/src/middleware/auth.ts:73–79  ·  view source on GitHub ↗

* Extract the bearer token from the raw `Authorization` header. * * Returns `null` when the header is missing, lacks the case-sensitive * `Bearer ` prefix, or carries an empty token — all treated as 401.

(header: string | undefined)

Source from the content-addressed store, hash-verified

71 * `Bearer ` prefix, or carries an empty token — all treated as 401.
72 */
73function extractBearer(header: string | undefined): string | null {
74 if (header === undefined || !header.startsWith(BEARER_PREFIX)) {
75 return null;
76 }
77 const token = header.slice(BEARER_PREFIX.length);
78 return token.length === 0 ? null : token;
79}
80
81/**
82 * Build the global `onRequest` auth hook.

Callers 1

createAuthHookFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected