cabal-club / cabal-client

interface for writing peer-to-peer chat clients
GNU General Public License v3.0
97 stars 14 forks source link

Expand dat-dns regexes, enabling sharing default mod key via dns #41

Closed cblgh closed 4 years ago

cblgh commented 4 years ago

For the moderation grant we have been talking about enabling people to set a default administrator, or moderator.

The reasoning is, without that ability, entering a cabal for the first time as a new person risks exposing people to a bunch of trolls or other malicious participants which have already been blocked by the regular people in the cabal.

The way to do it with out dns, which at least I advocate for, is setting moderators & administrators via URL parameters, as in:

cabal://<cabal key>?mod=<public key of moderator>&admin=<public key of administrator>

The tricky part seemed to be how we add support for that to the DNS shortnames, which enable people to join cabal via existing domain names as in cabal://cabal.chat. (See the DNS shortname link for more info.)

I was just experimenting with a shortname solution, and realized we could just use the former way of setting admin & mod keys as URL parameters, and reusing the solution for the DNS shortname method. That's what this PR introduces.

See this regexr example of what the extended regexes matches against https://regexr.com/54f5g

⚠️ this PR needs a companion PR in cabal-core for the passed in mod key not to be rejected as an error

cblgh commented 4 years ago

simplified the regex after talking with @substack and realizing that if we also capture the protocol part (cabal://), then we can use new URL(captureKey).searchParams.get("mod") to get the search params easily

less strictness in the regex also means we can introduce future query parameters without needing to update the regex (validation can happen in cabal-core, instead of dat-dns)