Servers and CI shouldn't hold your master key. They get a service token instead: a read-only credential for exactly one vault that you can expire, revoke and audit.
Service tokens
fishmem secrets token create -p my-saas-prod --name vercel --expires 90dThe token (fmst_…) is shown once. Store it in your platform's secret settings as FISHMEM_TOKEN.
How a token is built:
- It contains an id and a random secret. From the secret, the client derives two keys: an auth string sent to the server, which stores only a hash of it, and a wrap key that never leaves the client.
- The server keeps a copy of the vault's key sealed with that wrap key. Only someone holding the token can unseal it.
- So a token opens one vault and nothing else in the account: no other vaults, no passwords, files or history. It reads every item in that vault, including items linked in from other vaults; edit a linked item anywhere and the token reads the new value next time. It can't write, create tokens or sign in.
Managing tokens:
fishmem secrets token ls
fishmem secrets token revoke vercel # by name or id; stops working immediately
fishmem secrets log my-saas # reads, token changes, vault writesTokens can also be revoked from the apps and from the Dashboard's Settings › Devices. The access log keeps 90 days. Each token can make 120 reads a minute, so load secrets at start-up, not per request.
Revoking a token doesn't change the keys it could read. If a token leaked, rotate those keys at their providers too.
Creating service tokens needs Premium. If the plan ends, existing tokens keep reading for a 30-day grace period.
Use a token with the CLI
FISHMEM_TOKEN=fmst_… fishmem run -- node server.jsNo vault, sign-in or keychain is needed on the machine. Everything fishmem run does with a vault works the same with a token, including --env-file and fm:// references.
Keep running when Fishmem is unreachable
FISHMEM_TOKEN=fmst_… fishmem run --cache /var/cache/app.fmc -- node server.jsWith --cache, each successful read also writes an encrypted copy to that file. If the server can't be reached at the next start, a copy up to 7 days old is used instead (--cache-ttl changes the limit). The cache is encrypted with a key derived from the token.
The JS SDK
Where the CLI can't run, such as Cloudflare Workers or serverless functions, use @fishmem/secrets. Values are decrypted in your process; the server returns only ciphertext.
import { loadSecrets } from "@fishmem/secrets";
let secrets;
export default {
async fetch(req, env) {
secrets ??= await loadSecrets({ token: env.FISHMEM_TOKEN }); // once per isolate
const stripe = secrets.values.STRIPE_KEY;
// …
},
};In Node, injectSecrets() copies the token's vault into process.env before your app starts, resolving any fm:// values already there:
import { injectSecrets } from "@fishmem/secrets";
await injectSecrets(); // reads FISHMEM_TOKEN
await import("./server.js");The SDK isn't published to npm yet. Until it is, it ships in the Fishmem repository under
sdk/js.
GitHub Actions and other CI
The Fishmem action
The action installs the CLI and loads the token's vault on Linux, macOS and Windows runners:
# .github/workflows/test.yml
steps:
- uses: actions/checkout@v4
- uses: fishmem-labs/fishmem-action@v1
with:
token: ${{ secrets.FISHMEM_TOKEN }}
- run: npm test # the vault's secrets are set, masked as *** in logsEvery value is masked with ::add-mask:: before it becomes an environment variable for the following steps. To keep the secrets out of the job's environment and give them only to the commands that need them, add export: false and use fishmem run:
- uses: fishmem-labs/fishmem-action@v1
with:
token: ${{ secrets.FISHMEM_TOKEN }}
export: false
- run: fishmem run -- npm testThe action keeps an encrypted copy of the vault in the Actions cache and uses it, at most 7 days old (cache-ttl), when Fishmem can't be reached; turn that off with offline-cache: false. Until prebuilt binaries are published, the first run builds the CLI from source (a few minutes), and later runs restore it from the cache. The version input picks the CLI's branch or tag.
Other CI
Install the CLI as in Install, and pass the token as FISHMEM_TOKEN:
env:
FISHMEM_TOKEN: ${{ secrets.FISHMEM_TOKEN }}
steps:
- uses: actions/checkout@v4
- run: fishmem run -- npm testGive CI its own vault and token, separate from production. Check that two vaults haven't drifted apart:
fishmem secrets diff my-saas my-saas-prod --check # exit 1 if a name is missing on either sidePush keys to Vercel, Cloudflare and GitHub
Vercel, Cloudflare and GitHub Actions each keep their own copy of your environment variables. Push copies a vault into them, so Fishmem stays the one place you change a key. Rotate STRIPE_SECRET_KEY in Fishmem, run fishmem secrets push -p my-saas-prod, and Vercel's production and preview variables and your GitHub Actions secrets all have the new value, without pasting it into three dashboards. You add each target once; it's saved with the vault, so you can push again from any of your devices.
fishmem secrets targets add web vercel:my-site#production,preview -p my-saas-prod --token-ref fm://VERCEL_TOKEN
fishmem secrets targets add api cloudflare:ACCOUNT_ID/my-worker -p my-saas-prod
fishmem secrets targets add pages cloudflare-pages:ACCOUNT_ID/my-site -p my-saas-prod
fishmem secrets targets add ci github:owner/repo@production -p my-saas-prod
fishmem secrets push -p my-saas-prod --dry-run # show what would change
fishmem secrets push -p my-saas-prod # push every target of the vault
fishmem secrets push -p my-saas-prod --prune # also delete variables fishmem pushed before and you since removed- Targets are saved in the vault, encrypted, so every device sees the same list.
- The platform's own API token is best stored as a secret and referenced with
--token-ref fm://NAME. Cloudflare also reads$CLOUDFLARE_API_TOKEN. --pruneonly removes variables Fishmem created; anything you set on the platform by hand is left alone.- Push from the command line (it comes with the Mac app) or from the Windows and Android apps. The Dashboard shows a vault's targets but can't push, because those platform APIs don't accept calls from a browser.
Pushing is part of every paid plan.