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

Function safeTokenCompare

apps/desktop/main/internal-api.ts:350–354  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

348const hmacKey = randomBytes(32)
349
350function safeTokenCompare(a: string, b: string): boolean {
351 const hashA = createHmac('sha256', hmacKey).update(a).digest()
352 const hashB = createHmac('sha256', hmacKey).update(b).digest()
353 return timingSafeEqual(hashA, hashB)
354}
355
356/**
357 * Auth hook for the Internal Server. ALL routes require Bearer token, no exceptions.

Callers 1

createInternalAuthHookFunction · 0.70

Calls 1

updateMethod · 0.65

Tested by

no test coverage detected