import { hkdfSync } from "node:crypto";

export function deriveKey(masterSecret: Uint8Array, purpose: string): Uint8Array {
  const key = hkdfSync(
    "sha256",
    Buffer.from(masterSecret),
    Buffer.from("cpanel-mail-mcp-v1", "utf8"),
    Buffer.from(purpose, "utf8"),
    32,
  );
  return new Uint8Array(key);
}
