Repository navigation
feat(turn): short-lived TURN credentials for WebRTC calls - #242
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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 coreitself, so it can't sign arbitrary data. Usessign_rawbecausesignmsgpack-encodes its input, which an external verifier can't reproduce. Returns the raw 32-byte space/agent cores and the 64-byte signature.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'siceServers; refreshed before WebRTC init and on the call heartbeat when under 5 minutes remain. Issuer requests time out after 5s.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 viacreatePeer, 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 rejectedsvelte-check: 0 errorsNote:
message.test.ts"create and read Message" / "create and update Message" fail on this branch and identically onfeat/av-conferences-newwithout these changes (pre-existing).