MCPcopy Create free account
hub / github.com/CapSoftware/Cap / getHmacKey

Function getHmacKey

apps/web/lib/developer-key-hash.ts:5–17  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3let hmacKeyCache: CryptoKey | null = null;
4
5async function getHmacKey(): Promise<CryptoKey> {
6 if (hmacKeyCache) return hmacKeyCache;
7 const secret = serverEnv().NEXTAUTH_SECRET;
8 const encoder = new TextEncoder();
9 hmacKeyCache = await crypto.subtle.importKey(
10 "raw",
11 encoder.encode(secret),
12 { name: "HMAC", hash: "SHA-256" },
13 false,
14 ["sign"],
15 );
16 return hmacKeyCache;
17}
18
19export async function hashKey(key: string): Promise<string> {
20 const hmacKey = await getHmacKey();

Callers 1

hashKeyFunction · 0.85

Calls 1

serverEnvFunction · 0.90

Tested by

no test coverage detected