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

Function equalsInConstantTime

telemetry-dashboard/src/auth.ts:77–83  ·  view source on GitHub ↗

* Constant-time string equality. Both sides are hashed first so the digests are * always the same length — `timingSafeEqual` throws on a length mismatch, and a * throw would itself leak the length of the secret.

(a: string, b: string)

Source from the content-addressed store, hash-verified

75 * throw would itself leak the length of the secret.
76 */
77async function equalsInConstantTime(a: string, b: string): Promise<boolean> {
78 const [digestA, digestB] = await Promise.all([
79 crypto.subtle.digest('SHA-256', encoder.encode(a)),
80 crypto.subtle.digest('SHA-256', encoder.encode(b)),
81 ]);
82 return crypto.subtle.timingSafeEqual(digestA, digestB);
83}
84
85/** Short, non-reversible marker of the current password, embedded in the session. */
86async function passwordFingerprint(password: string): Promise<string> {

Callers 1

checkPasswordFunction · 0.85

Calls 1

allMethod · 0.65

Tested by

no test coverage detected