Skip to content

feat(turn): short-lived TURN credentials for WebRTC calls - #242

Merged
MasterK0927 merged 2 commits into
feat/av-conferences-newfrom
feat/turn-credentials
Oct 13, 2026
Merged

MasterK0927 merged 2 commits into
feat/av-conferences-newfrom
feat/turn-credentials

Conversation

@MasterK0927

Copy link
Copy Markdown
Contributor

Summary

Volla Messages side of the TURN credential design (bootstrap/sidecar issuer mints short-lived coturn REST credentials after an ed25519 nonce challenge). Stacked on #17.

  • Zome fn sign_turn_challenge (relay coordinator, turn.rs): takes only a 32-byte nonce and builds "k2-turn-cred-v1" || nonce || dna_hash core || agent_key core itself, so it can't sign arbitrary data. Uses sign_raw because sign msgpack-encodes its input, which an external verifier can't reproduce. Returns the raw 32-byte space/agent cores and the 64-byte signature.
  • UI turnCredentials.ts: fetches a nonce from the issuer, gets it signed, POSTs the proof, caches the returned {urls, username, credential} until expiry. Added to every new SimplePeer connection's iceServers; refreshed before WebRTC init and on the call heartbeat when under 5 minutes remain. Issuer requests time out after 5s.
  • Transport gate: the WebRTC toggle now appears when a credential has been fetched (or manual TURN servers are set in localStorage). If the issuer is unreachable, calls stay on the Holochain transport.
  • Config: issuer URL comes from VITE_TURN_ISSUER_URL; empty by default, so nothing changes for users until an issuer is deployed.

No setConfiguration()/restartIce() handling is needed: failed connections are torn down and recreated via createPeer, which reads the cached credential fresh, and coturn doesn't re-check expiry on existing allocations.

Test plan

  • tests/src/relay/relay/turn.test.ts: signature verifies with Node's ed25519 over the exact raw message; a different nonce fails; nonces of length 0/31/33/64 are rejected
  • svelte-check: 0 errors
  • End-to-end against a running issuer + coturn (blocked until the issuer is deployed)

Note: message.test.ts "create and read Message" / "create and update Message" fail on this branch and identically on feat/av-conferences-new without these changes (pre-existing).

…t key

sign_turn_challenge takes only a 32-byte nonce from the caller and builds
"k2-turn-cred-v1" || nonce || dna hash core || agent key core itself, so it
can't be used to sign arbitrary data. Uses sign_raw because sign msgpack-
encodes its input, which the external credential issuer can't verify.
When VITE_TURN_ISSUER_URL is set, fetch a nonce, sign it via
sign_turn_challenge, and exchange the proof for a coturn credential that is
added to every new peer connection. Refreshed before WebRTC init and on the
call heartbeat when under 5 minutes remain. The WebRTC transport option only
appears once a credential is in hand, so a failed fetch keeps calls on the
Holochain transport.
@MasterK0927
MasterK0927 merged commit 428d23c into feat/av-conferences-new Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants