StashJS
Every page in this reference is generated from the library's own source comments. You put bytes in and get a ref back - a 256-bit random capability, not a content address. You take the bytes out, and when the terms say once, they're gone.
Quick start
npm install @blamejs/stash
import { Stash } from "@blamejs/stash";
import { MemoryBackend } from "@blamejs/stash/backends/memory";
const stash = new Stash({ backend: new MemoryBackend() });
const ref = await stash.push(ciphertext); // ref: 'v1_...' - a capability
const entry = await stash.show(ref); // metadata only, never contents
const readable = await stash.apply(ref); // digest-verified stream
mkdir -p .stash && node --permission --allow-fs-read=. --allow-fs-write=./.stash app.js. A compromised dependency cannot reach outside the grant to the wider filesystem.Design tenets
- Crypto-agnostic by architecture. There is no key parameter on any method and no cipher import anywhere in the tree. A store with nowhere for a key to live survives compulsion; encryption belongs to the consumer.
- Refs are capabilities. A ref is 256 bits of randomness, never a content hash - a content hash is guessable by anyone holding the content, and dedup buys nothing on ciphertext.
- Fail closed. Every failure is a typed
StashErrorwith a stablecode; no error message ever contains a ref, ametavalue, or a path. - Streaming-first. No method buffers a whole blob; size limits are enforced mid-stream, and reads are digest-verified as they drain.
- The lifecycle is monotone. Entries are write-once and every state change moves them closer to destruction - no
touch(), no TTL extension, no metadata mutation. - Zero dependencies. Node builtins only, at runtime and in development; the published dependency object is empty.
Namespaces
Backends
The storage contract and both shipped backends -- Map-backed memory, and sidecar-file disk with atomic writes and realpath containment.
Backend conformance
The SPEC.md 9 backend contract as a runnable suite -- point it at your own backend factory and your runner's `test`, and it certifies the store behaves like the ones that ship.
Stash
The policy layer -- push bytes in for a random-capability ref, stream them back out, destroy on demand; write-once entries, fail-closed verdicts.
Errors
Typed error classes with stable codes -- the fail-closed verdict surface of the store.
CLI
Inspect and maintain a disk stash from the shell -- verify, stats, prune, list, tombstones, has -- without writing Node. Never moves bytes.