MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / tokenMatches

Function tokenMatches

telemetry-worker/src/rollup.ts:547–554  ·  view source on GitHub ↗

Constant-time over digests, so neither the length nor a prefix of the token leaks.

(provided: string, expected: string)

Source from the content-addressed store, hash-verified

545
546/** Constant-time over digests, so neither the length nor a prefix of the token leaks. */
547async function tokenMatches(provided: string, expected: string): Promise<boolean> {
548 const encoder = new TextEncoder();
549 const [a, b] = await Promise.all([
550 crypto.subtle.digest('SHA-256', encoder.encode(provided)),
551 crypto.subtle.digest('SHA-256', encoder.encode(expected)),
552 ]);
553 return crypto.subtle.timingSafeEqual(a, b);
554}
555
556/**
557 * `POST /admin/rollup?day=YYYY-MM-DD[&days=N][&reset=1]`, header `x-admin-token`.

Callers 1

handleAdminRollupFunction · 0.85

Calls 1

allMethod · 0.65

Tested by

no test coverage detected