1. Trusted input
Receive the sensitive identity inside a server route, job, or trusted Node.js process.
Private identity
Ordinary deterministic output is reproducible by anyone who knows the seed. For emails, account IDs, or other sensitive values, derive an HMAC seed on a trusted Node.js server first.
The private entry point canonicalizes the identifier and namespace, then signs a domain-separated message with HMAC-SHA-256. Only the derived value needs to reach ordinary rendering code.
Receive the sensitive identity inside a server route, job, or trusted Node.js process.
Use a secret of at least 32 encoded bytes. Keep the secret exclusively in server-side configuration.
Render the returned hmac-sha256: value or call a private avatar helper directly.
Import from the Node.js-only agent-avatars/private entry point. It uses the Web Crypto implementation from node:crypto.
import { derivePrivateSeed } from "agent-avatars/private";
import { createHashAvatar } from "agent-avatars";
const privateSeed = await derivePrivateSeed("person@example.com", {
namespace: "my-product/users",
secret: process.env.AVATAR_HMAC_SECRET,
});
const svg = createHashAvatar(privateSeed, {
seedMode: "raw",
namespace: "my-product/users",
});derivePrivateSeed()Returns the stable HMAC-derived seed for storage or use by another renderer.
createPrivateAvatarDescriptor()Returns a complete descriptor using the HMAC-derived seed for avatar selection.
createPrivateHashAvatar()Derives and renders an SVG string in one asynchronous call.
Use a secret manager or protected environment configuration. Validate that it exists at startup and keep environments isolated.
HMAC output depends on the secret. Rotating it intentionally produces new derived seeds and therefore new avatars.
Plan rotation like a data migration: version the active secret, keep the previous version during a controlled transition, regenerate stored output, and remove old access only when clients have adopted the new identity.
Your application manages keys, stores identifiers, and migrates existing records.
HMAC derivation uses a server-side secret to protect the seed. Evaluate avatar privacy alongside the surrounding product context.
The same private identity remains recognizable wherever the same derivation domain and rendering options are reused.
Application logs, URLs, analytics payloads, and surrounding profile data can reveal identity independently of the avatar.
Use ordinary seeds for agents and services that are already public. Use server-side derivation for sensitive identifiers.