MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / safeTokenCompare

Function safeTokenCompare

apps/desktop/main/api/auth.ts:10–15  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

8import { unauthorized, errorResponse } from './errors'
9
10function safeTokenCompare(a: string, b: string): boolean {
11 const bufA = Buffer.from(a)
12 const bufB = Buffer.from(b)
13 if (bufA.length !== bufB.length) return false
14 return timingSafeEqual(bufA, bufB)
15}
16
17export async function authHook(request: FastifyRequest, reply: FastifyReply): Promise<void> {
18 const authHeader = request.headers.authorization

Callers 1

authHookFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected