AT protocol / bluesky from scratch - Handle
- Published on 2023-08-22 by Sebastien Marie
- Reading time: 2 minutes #atproto
Let's look at the AT protocol starting from scratch, with just an handle semarie.bsky.social.
Handle
The handle is just a name for humans. It is first resolved to a Decentralized Identifiers (DID).
It is just an resolvable hostname (resolvable to some extent as we will see).
$ dig +short semarie.bsky.social
44.216.73.82
34.197.208.36
52.22.43.240
$
In fact, there is two differents supported methods to resolv the handle to DID identifier.
DNS TXT record
The first one to test is to try resolv _atproto.semarie.bsky.social to get a TXT record.
$ dig +short _atproto.semarie.bsky.social TXT
$
Ah, there is no result. So we will test the second method. But let's see first the result for an handle using DNS TXT.
$ dig +short _atproto.semarie.kapouay.eu.org TXT
"did=did:plc:26sw3p6ebn4p6fn5otobufyn"
$
And we get the DID identifier (did:plc:26sw3p6ebn4p6fn5otobufyn).
HTTPS (+ DNS) well-known record
The second method uses HTTPS. So it needs a HTTP server (with proper certificate…), and so a valid IP address to contact it. As seen with semarie.bsky.social, the handle resolves to IPv4 addresses (but no IPv6 address at the time).
The DID is obtained from getting the document at https://HANDLE/.well-known/atproto-did.
$ curl -s https://semarie.bsky.social/.well-known/atproto-did
did:plc:26sw3p6ebn4p6fn5otobufyn
$
And we get the DID identifier (did:plc:26sw3p6ebn4p6fn5otobufyn).
Some remarks
- Anybody could place an handle to any DID identifier, even if not "owning" it.
- AT protocol asks to resolve the DID identifier to DID document (we will see that later), and to check back the handle in the DID document.
- The handle is an hostname
- there is some size restriction on hostname, but it could be a long name (up to 253 characters with
.) - the allowed characters in hostname could be tricky, and leads to differences in implementations
- in original STD-13, the Name space specifications is just "octet" (so any character)
- usually only ASCII
[a-z0-9-]are used - but
_could be found too - and internationalized domain names makes most of Unicode available (via a transformation)
- so at least a presentation question in interface
- there is some size restriction on hostname, but it could be a long name (up to 253 characters with