EphemeralCDN
Peer-to-peer file sharing for one-off results. No server storage. Everything disappears when everyone leaves.
Your files live only while a tab is open.
Every copy of a file is held in browser memory by a tab somewhere on the internet.
When the last tab closes, the file is gone, and any page that links to it by hash will break with
file is dead. Use this for quick shares (a build artifact, a screenshot, a CSV from a notebook) —
not for anything you want to stay online.
How it works
- A publisher loads a file in their browser. The script computes its SHA-256 and registers the publisher's PeerJS ID with the tracker.
- The publisher gets back a hex hash and shares it however they like (paste into a page, email it, etc.).
- A consumer calls
EphemeralCDN.fetch(hash). The script asks the tracker for peers that have that hash, connects to several of them over WebRTC, and downloads different byte ranges from each one in parallel — like WebTorrent. - After the download, the script verifies the full SHA-256 so a bad peer cannot substitute different bytes.
- Every consumer becomes a seeder while their tab is open. The more people viewing, the more redundant copies exist.
- When the last seeder closes their tab, the tracker drops the entry and
fetch()starts throwingDEAD.
The server
The tracker never sees file bytes. It only tracks which PeerJS IDs claim to have which hash, groups them by rough IP region (same network neighbours are served to each other first for lower latency), evicts peers that stop sending heartbeats, and returns an alive: false verdict once a file has no seeders.
Publish a file
Not seeding anything yet.
Fetch a file
Embed in your own page
Put this on any HTTPS page:
<script src="https://unpkg.com/peerjs@1.5.4/dist/peerjs.min.js"></script>
<script src="https://stateofutopia.com/experiments/ephemeralcdn/ephemeralcdn.js"></script>
<script>
// Fetch by hash. Throws if the file is dead.
const buf = await EphemeralCDN.fetch('<64-hex sha256>');
// Convenience wrappers:
const txt = await EphemeralCDN.fetchText('<hash>');
const url = await EphemeralCDN.fetchURL('<hash>', 'image/png');
document.querySelector('img').src = url;
// Or publish something live from this tab:
const hash = await EphemeralCDN.seed(someFileOrBlob);
console.log('share this:', hash);
</script>
Options you can pass to fetch(hash, opts):
maxBytes— reject files larger than this (default 256 MB, hard-capped).parallelism— how many peers to download from simultaneously (default 6, max 16).seed: false— don't continue seeding after download. Default is to seed.onProgress: ({received, total}) => ...— callback fired as bytes arrive.
Security notes
- Every download is hash-verified. A peer cannot substitute different bytes than the hash you asked for.
- Peers see each other's public IP addresses once they connect (inherent to WebRTC). Use a TURN server if that matters.
- The tracker rate-limits per IP and caps the number of files and peers it will track.
- HTTPS is required: WebCrypto and WebRTC refuse to run on insecure origins.