MCPcopy Index your code
hub / github.com/cameri/nostream / deriveFromSecret

Function deriveFromSecret

src/utils/secret.ts:3–9  ·  view source on GitHub ↗
(purpose: string | Buffer)

Source from the content-addressed store, hash-verified

1import { createHmac } from 'crypto'
2
3export function deriveFromSecret(purpose: string | Buffer): Buffer {
4 if (!process.env.SECRET) {
5 throw new Error('SECRET environment variable not set')
6 }
7
8 return hmacSha256(process.env.SECRET, purpose)
9}
10
11export function hmacSha256(secret: string | Buffer, data: string | Buffer): Buffer {
12 return createHmac('sha256', secret).update(data).digest()

Callers 5

makeValidQueryFunction · 0.90
handleRequestMethod · 0.90
getRelayPrivateKeyFunction · 0.90
createInvoiceMethod · 0.90

Calls 1

hmacSha256Function · 0.85

Tested by 1

makeValidQueryFunction · 0.72