Chapter 11
Implementation notes
The spec is firmly opinionated in some places and open-ended in others, so developers of space hosts, PDSes, applications, and tools have a lot of room in what they build and how. This chapter walks through the directions those choices can take and what each one implies, including its side effects, along with the passages that need careful reading and a checklist for your own conformance.
Where the spec leaves a choice#
These are the choices atproto-crates makes. Another conforming implementation may differ, so clients should not depend on them.
Reference
Authorization choices spec crates#
What happens inside authorizeSpaceSync when the spec doesn’t pin it down.
| Choice | What the spec says | What atproto-crates does |
|---|---|---|
| Check order | Unstated | Key and notify, hosted authority, active authority, SpaceDeleted, delegation token, attestation, policy |
| HTTP status of refusals | Unstated | NotAuthorized, AppNotAuthorized, InvalidClientAttestation, and BlobNotFound all return 400 |
| Managing app can’t answer | No error declared | 502 UpstreamFailure; the credential isn’t issued, and the registration is kept |
| Suspended authority | RepoTakendown or RepoDeactivated | Adds RepoSuspended |
RepoSuspended is there because repo-host reads already declare it. A client gets the same error for the same account state whichever host it asks.
Reference
Notification and sync choices spec crates#
How the space host talks to syncers.
| Choice | What the spec says | What atproto-crates does |
|---|---|---|
| Notify token | Opaque, at most 512 bytes, one per space and stable across authorizations | The client derives an HMAC-SHA256 of the space URI under an app secret and checks it statelessly |
confirmRegistration challenge | A random challenge | 32 random bytes in hex, with 10 seconds to answer |
| Expiry and deletion notice retries | Backoff for at least 72 h | 1 m, 10 m, 1 h, 6 h, then every 12 h, with 50 to 100% jitter, for at least 72 h |
| Write and removal updates | Reasonable-effort delivery | Queued in the notify outbox; a failure that might clear is retried |
listRepoOps with both since and cursor | Both parameters exist | Both apply; a stale since returns the remaining ops and the commit |
The retry schedule is front-loaded so a syncer that was briefly down hears about an expiry or deletion within the hour. After that it settles to every 12 hours, which keeps the 72-hour window to a handful of attempts. The jitter spreads retries out, so a syncer coming back from an outage isn’t hit by every space at once.
Reference
Membership and migration choices spec crates#
| Choice | What the spec says | What atproto-crates does |
|---|---|---|
Repeated DID in putMembers | Unstated | Last entry wins |
managingApp validation | A did#serviceId string | An absolute did:plc or did:web with a fragment, checked on create, update, and import |
| Export by a restricted account | Taken-down accounts may export | Suspended and deactivated accounts may too |
Passages that need careful reading#
The delegation token section says the token is "addressed (aud) to the space authority", but the normative example uses the space host’s service id, which for the family space is did:plc:ejjl2znzqp3ci25dqaslpkk2#atproto_pds. Use the service id, as client attestations also do.
The policy section says that after a policy migration "applications remain responsible for removing any writers", while memberspace says the authority should remove a removed member from the writer set. Hosts may prune differently on a policy change. A careful syncer re-reads listWriters after any policy change it learns of.
clearRecords clears the operation log along with the records. A syncer resuming from an old since gets no ops, and the commit it gets back has the empty digest, so its fold mismatches and it recovers with getRepo (or treats the repo as empty).
Design trade-offs worth knowing#
No proof of possession at authorization#
authorizeSpaceSync binds credentialKey without asking the caller to sign with it. Whoever holds a valid delegation token can bind a credential to a key of their choosing. Delegation tokens are single-use, last 60 seconds, and name one host, so the exposure is small, but treat one as a bearer secret for that minute and keep it out of logs.
Audience replay is allowed#
A credential signature covers only the credential and the audience, not the HTTP method or request path, so a captured request can be replayed to the same audience until the credential expires. That is deliberate. The design targets one threat, a repo host that received the credential replaying it to another host, and binding the signature to the audience is enough to stop it. Within one audience, TLS keeps a request from being captured in the first place, so covering the method and path would add nothing against that threat.
Notifications are unauthenticated beyond the token#
confirmRegistration and notifySpaceUpdate carry no service auth. A leaked token can only make a syncer check for updates unnecessarily, provided the syncer confirms everything with the repo host or space host and never drops data on a notice alone.
Compressed versus uncompressed keys#
DID documents and did:key carry compressed P-256 keys; HPKE’s enc and the derivation use uncompressed 65-byte encodings.
Conformance checklist#
LtHash: empty digest matches
e5a00aa9...b183ad; add then remove returns to empty; order of adds doesn’t matterElement bytes are exactly
{collection}/with the CID as a string{rkey}/ {cid} HPKE secret export matches the export-only P-256 entry in the RFC 9180 test vectors
A new ephemeral KEM key for every request, retry, and page
Accept-Signaturewith the right profile tag on every credentialedgetLatestCommit,getRepo,listRepoOps, andgetRecordMAC verified as
hmac-sha256over thesf-canonicalized covered header, and the header matched against the bodyMAC failure triggers a DID refresh and a retry with a new key
Credential signature found by tag
atproto-space-credentialunder any label, covering exactly("authorization" "atproto-space-audience")keyidchecked againstcnf.kidwhen present; extra parameters ignoredVerifiers accept high-S P-256 signatures
Audience is the repo DID for repo methods and the authority DID for host methods
Credentials capped at 60 minutes; revoked
jtivalues held 60 minuteslistWritersentries branched on$type;#repoRemovedstops a repo being treated as part of the spacelistRepoOpsapplied until a page has nocursor, then compared with that page’s commitSTAR reader refuses bad control bytes, missing end byte, trailing bytes, out-of-order keys, and size-limit breaches
confirmRegistrationechoes the challenge only for a token issued for that spacenotifySpaceUpdatematched on full$type, with unknown types ignored#spaceDeletedtriggers reauthorization; data is dropped only on aSpaceDeletedanswerA checkpoint older than 72 hours lists the whole writer set
UpstreamFailuretreated as retryable, never as a refusalSpace-only syncers still consume
#accountand#identityfirehose events
Chapter 11 of 11 · AT Protocol Spaces: A Field Guide