Skip to content

v0.1.1 — file transfer in the demo

Choose a tag to compare

@NiKrause NiKrause released this 27 Jul 12:11
c009add

A demo-only release. The published package is unchanged@le-space/libp2p-webrtc-qr@0.1.0 remains current on npm, and nothing in packages/webrtc-qr moved.

Live: https://webrtc-qr.le-space.de

Drag and drop file transfer

Drop a file into the demo and the other browser downloads it, over the same connection the QR handshake produced. No server anywhere in the path.

The sender adds the bytes to Helia and announces only the CID over the chat stream. The receiver pulls the bytes with bitswap across the QR-negotiated libp2p connection and renders a download link with the file name, size and CID.

Chat messages became JSON envelopes so plain text and file announcements can share one stream. sendMessage and getLastReceivedMessage kept their shape, so the existing specs were untouched.

Why Helia is composed by hand

helia = withBitswap(withLibp2p(createHeliaLight(), node))
await helia.start()

createHelia() is internally withBitswap(withLibp2p(withHTTP(...))), and that withHTTP layer adds trustless gateways plus a delegated routing endpoint. With it, a dropped file could arrive from trustless-gateway.link instead of from the peer across the QR connection — the demo would quietly stop demonstrating anything while still appearing to work.

Without it, bitswap over that single libp2p connection is the only path the bytes have.

Tests

24 tests, all green and gating the deploy:

  • 18 unit tests on the signaling codec
  • 4 browser end-to-end tests, one of them new
  • 2 Helia end-to-end tests

The new spec asserts the bytes, not just that an announcement arrived: it reads the generated download link back through fetch() and compares it to what was sent, then checks the anchor carries the right download filename.

UI

A dashed drop zone below the message field — disabled until a peer is connected, coral highlight while dragging, click and keyboard accessible. Received files are listed with name, size, CID and a download link.

Full changes in #1.