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

Function hmacKey

telemetry-dashboard/src/auth.ts:54–65  ·  view source on GitHub ↗
(secret: string)

Source from the content-addressed store, hash-verified

52let cachedKey: { secret: string; key: CryptoKey } | null = null;
53
54async function hmacKey(secret: string): Promise<CryptoKey> {
55 if (cachedKey?.secret === secret) return cachedKey.key;
56 const key = await crypto.subtle.importKey(
57 'raw',
58 encoder.encode(secret),
59 { name: 'HMAC', hash: 'SHA-256' },
60 false,
61 ['sign'],
62 );
63 cachedKey = { secret, key };
64 return key;
65}
66
67async function sign(secret: string, payload: string): Promise<Uint8Array> {
68 const signature = await crypto.subtle.sign('HMAC', await hmacKey(secret), encoder.encode(payload));

Callers 1

signFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected