subconsciousnetwork / subtext

Markup for note taking
Apache License 2.0
271 stars 20 forks source link

Supporting DID links to sphere content #51

Open gordonbrander opened 1 year ago

gordonbrander commented 1 year ago

Recently the team has been discussing the value of supporting a did link form for sphere content. This has many upsides.

DIDs are identifiers (stable and globally unique). Slashlinks are locators (they tell you how to find stuff), but not identifiers. Given that slashlinks dereference to sphere DIDs under the hood, it would be a nice fallback if slashlinks could reference DIDs directly. It would also be nice if that form were a stable identifier.

This choice has cascading effects on the UX of Subconscious, the UX of writing Subtext, the parsing of Subtext, and more. Design is navigating tradeoffs by values. To that end, This note is an attempt to explore and reflect on these interconnected aspects, how they intersect with the design values of Subtext, and to find a balance of tradeoffs that best suit our values.

Values:

Previously-resolved tradeoffs:

gordonbrander commented 1 year ago

It is worth noting that these are both structurally valid DID URLs:

did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK/foo
did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK@petname/foo

However,

References:

gordonbrander commented 1 year ago

One approach we could take is to only allow "absolute" did links, without petnames.

did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK/slug

To traverse from one sphere to another, you would "absolutize" the slashlink, at each step, so there is never a traversal path. This keeps the did path simple. This is in keeping with the idea that the did is an "unknown", so the petnames in their address book do not provide much information security.

This is a valid DID URL, with caveats:

Regex for whole match (markup would require two regex cases, one for did, one for petname slashlink)

(?:(?<did>did:key:[a-zA-Z0-9_\-%]+)|(?<petname>@[\w\-]+(?:\.[\w\-]+)*))?(?<slug>\/[\w\-]+(?:\/[\w\-]+)*)?
gordonbrander commented 1 year ago

Another approach could be to allow slashlinks after a did, with or without petnames.

did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK@bob.alice/slug

This gets visually complicated quickly. The petnames in the path are not really providing much value.

I believe this is a valid DID URL, with same caveats as above.

bmann commented 1 year ago

This is interesting, but possibly premature? Other systems mostly don't know what to do with DIDs at all, and haven't thought about the interfaces.

Maybe @-syntax is correct? So either @petname (which resolves to a DID) or @did:key (which may get looked up and replaced with a label or a petname).

Also: what about other mentions that themselves resolve to a DID? So, @bmann.ca has an _atproto subdomain / TXT record which contains a DID.

@boris.fission.name contains a _did subdomain / TXT record.

DNS flavoured links that resolve to DIDs at well known locations could be a good start?

gordonbrander commented 1 year ago

Did slashlink syntax

I'm strongly partial to

did:key:abc123/slug
(<did>|<petname>)<slug>

If DID, no petname. If petname, no DID. Rationale:

I like not having the @ for did-slashlinks, but I can see the other side of it. did:method is enough for us to sniff out supported did methods in the text. However, since we are "hijacking" the path-part of DID-URLs for addressing sphere content, I could imagine the leading @ being useful for disambiguating this use. Another possibility might be a custom DID method. Going to mull on this for a bit.

For now, we have implemented did:key:abc123/slug style slashlinks for database indexing in the app, but are not exposing them on the user-facing markup side until we work this out a bit more. See https://github.com/subconsciousnetwork/subconscious/pull/561

DNS names

Worth noting that @boris.fission.name creates an ambiguity with potential @boris.fission.name petnames. This ambiguity might be worth coping with for the utility of bridging to DNS. It's also possible to bridge to DNS via making com, org, name, etc, spheres with address books to DNS.

I'm not sure if this decision should belong to Subtext, or the app implementing it. Spec'ing this into subtext seems like too much app domain knowledge leaking back into a markup spec. Perhaps if we pursue it, it could belong to an "extension spec".