hepgg-secrets package

A small Node library that pulls your Hep.gg Secrets into process.env at app launch, like dotenv, with an encrypted last-good cache so a brief outage can't stop your app from booting.

hepgg-secrets

hepgg-secrets pulls your Hep.gg Secrets into process.env when your app starts. It is a one-shot injector (like dotenv), not a daemon: each boot fetches the current values for one environment and sets process.env. If Hep.gg is briefly unreachable it falls back to the last successful pull (encrypted on disk) so an outage can't stop your app from booting.

Install

flag
npm install hepgg-secrets --registry https://npm.hep.gg

Use

Call config() as the very first thing your app runs, before anything reads process.env.

esm
import { config } from "hepgg-secrets";
 
await config({
  env: "production",
  token: process.env.HEPGG_SECRETS_TOKEN, // hsk_...
});
console.log(process.env.DATABASE_URL);

Zero-config via environment

Every option has an env-var fallback, so you can keep code clean:

OptionEnv var
urlHEPGG_SECRETS_URL
envHEPGG_SECRETS_ENV
tokenHEPGG_SECRETS_TOKEN
keyHEPGG_SECRETS_KEY

url defaults to https://hep.gg/api/v1/secrets/pull, so usually just a token (and an env for project-wide tokens) is enough.

import { config } from "hepgg-secrets";
await config(); // reads HEPGG_SECRETS_URL / ENV / TOKEN

End-to-end encrypted projects

If your project is E2EE, supply the passphrase (or recovery key) so the package can decrypt locally. The key is never sent to Hep.gg.

await config({
  env: "production",
  token: process.env.HEPGG_SECRETS_TOKEN,
  key: process.env.HEPGG_SECRETS_KEY, // your passphrase or recovery key
});

Options

config(options)
url
stringoptionaldefault: https://hep.gg/api/v1/secrets/pull
Pull endpoint.
env
stringoptional
Environment to fetch. Required for project-wide tokens.
token
stringoptional
Your hsk_ pull token.
key
stringoptional
E2EE passphrase or recovery key. Only for end-to-end-encrypted projects.
keys
string[]optional
Only fetch these names. Default: the whole environment.
override
booleanoptionaldefault: false
Overwrite variables already present in process.env.
cache
boolean | stringoptionaldefault: true
Encrypted last-good cache: true, false, or a custom path.
timeoutMs
numberoptionaldefault: 8000
Network timeout.
quiet
booleanoptionaldefault: false
Suppress the "using cached secrets" warning.

Accessors

import { config, get, all } from "hepgg-secrets";
await config();
get("DATABASE_URL"); // string | undefined
all();               // { DATABASE_URL: "...", ... }