MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / safeTokenCompare

Function safeTokenCompare

packages/http-routes/src/auth.ts:31–35  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

29const hmacKey = randomBytes(32)
30
31function safeTokenCompare(a: string, b: string): boolean {
32 const hashA = createHmac('sha256', hmacKey).update(a).digest()
33 const hashB = createHmac('sha256', hmacKey).update(b).digest()
34 return timingSafeEqual(hashA, hashB)
35}
36
37export async function authHook(request: FastifyRequest, reply: FastifyReply): Promise<void> {
38 if (!cachedToken) return

Callers 1

requireBearerTokenFunction · 0.70

Calls 1

updateMethod · 0.65

Tested by

no test coverage detected