gun icon indicating copy to clipboard operation
gun copied to clipboard

webrtc room should not default to hash/path

Open eyaler opened this issue 4 months ago • 1 comments

webrtc.js room defaults to the hash or path if no room is specified: opt.rtc.room = opt.rtc.room || GUN.window && (location.hash.slice(1) || location.pathname.slice(1));

This is not well documented, and while for some apps already using the hash as the graph node key this makes sense, in a more general scenario this can be very suprising and cause some issues:

  1. the hash/path is silently leaked, which is a privacy issue
  2. bad hashes can cause errors in sea modules running on peers e.g. Object { "#": "fmhk6VELS", "@": "JVy9cxro9", err: "Unverified data.", _: _(). not sure if this was due to some bad chars or due to my hash being 150k chars long... so maybe don't grab my hash by default ;)
  3. my app uses hashes for internal state, so different clients would not connect over webrtc before i learned i should set a common room key

eyaler avatar Aug 28 '25 12:08 eyaler

@eyaler agreed, especially with (1) good call. I still want some reasonable deterministic fallback tho, maybe just location.pathname ? Willing to do the honors & PR? (whatsapp / DM me tho, github fails to send me notifications)

amark avatar Dec 01 '25 05:12 amark