Skip to content

Anyone with your publishable key and a room name, from a page on one of your allowed origins. The origin check stops other websites from using your key, but not a determined person with a script. So:

  • Treat room names as secrets. Generate them on your server (for example base64url of an HMAC of your own room code, 22 or more characters) and give them only to people who should be in the room.
  • Keep authority on your server. Decide anything that must be fair or secret there.
  • Use join tickets when you have users. Your server signs a short-lived ticket for one user and one room, and jsflow admits only joins that carry one; room.user(peerId) then tells every peer who is who, vouched for by the service.

send and sendReliable are sealed end to end (X25519 key agreement, AES-GCM). Peers that forward the message, and the relay, cannot read or change it, and the receiver knows which peer sent it. Every broadcast is signed (Ed25519) by its sender, and every peer checks the signature: a forged broadcast is dropped where it arrives, so a peer cannot make a broadcast appear to come from someone else. The keys are vouched for by the signalling service, which signs each peer’s keys into its join.

broadcast is signed, not sealed. Anyone in the room can read a broadcast. And signed means that from is the real sender, not that what the sender says is true: a peer is an equal and can send false state as itself. Do not take a broadcast’s content on trust for anything that matters (scoring, permissions). Use your server, or check broadcasts against state your server gave out.

When two browsers connect directly, each can see the other’s public IP address. That is how direct connections work, and it matters when the people in a room do not know each other. Tell your users before they join. Suggested text for your page, which you may adapt:

When you join, your device may connect directly to another participant’s device. That participant can see your public IP address.

Use relay-only when the peers are strangers or the room is sensitive. Join with iceTransportPolicy: 'relay' and every connection goes through jsflow’s relay, so no peer sees another’s address. We recommend it by default for matching people who do not know each other, for apps used by children, and for any room where a revealed address could put someone at risk. It costs a little latency (in lab tests, p95 16 ms instead of 7 ms on one network) and makes delivery depend on the relay path.

import { join } from 'jsflow-sdk';
const room = await join({
app: 'pk_…',
room: 'private-chat',
iceTransportPolicy: 'relay',
});
room.on('state', (s) => console.log(s));

The services still see addresses. Relay-only hides addresses from the other peers, not from us: the signalling service and the relay receive every user’s IP address, because they need it to connect them. We use it for routing, rate limiting and abuse handling, as the privacy policy says. Mention all of this in your own privacy text, as the person who decides how jsflow is used in your product.