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

  1. A publisher loads a file in their browser. The script computes its SHA-256 and registers the publisher's PeerJS ID with the tracker.
  2. The publisher gets back a hex hash and shares it however they like (paste into a page, email it, etc.).
  3. 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.
  4. After the download, the script verifies the full SHA-256 so a bad peer cannot substitute different bytes.
  5. Every consumer becomes a seeder while their tab is open. The more people viewing, the more redundant copies exist.
  6. When the last seeder closes their tab, the tracker drops the entry and fetch() starts throwing DEAD.

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):

Security notes