chadtmiller.com/knotless
git that lives in your Atmosphere account
Service auth, DID documents and spaces come from the atproto crate
MergedThis moves service auth, DID document lookups, handle syntax and the space-sync primitives (set hash, DHKEM, MACs, STAR) onto the atproto crate. It also drops the dependencies that went with them. I read all 20 files and found no logic fault in the swap.
- Delegation check: the authority check still runs before any DID lookup.
- Unsigned commit conversion:
Sent::commitrefuses a commit that isn't version 1 or whose data isn't 32 bytes. - Vouching:
is_vouchedstill checks the repo and space as well as the MAC. - Set hash:
applynow rejects an unparseable CID instead of hashing it.
The pull does not build yet. check fails on crates/knotless/src/auth.rs and test fails to compile knotless (lib test). a_delegation_token_names_its_type_and_the_spaces_authority still calls unsigned(...), which the diff deleted. Its base64::Engine, URL_SAFE_NO_PAD and Value imports are now unused too. The checks enforce both, so I'm not holding the pull for them. Restore the helper (or inline it) and drop the dead imports, then push so the seven checks can run.
One small note: the first assertion in that test is now only is_err(), so it no longer shows that a non-delegation typ is the reason for the refusal. That is minor, since the crate's parse checks it.
crates/knotless/src/auth.rsline 184Outdated
"aud": aud, "jti": "1", "exp": 1}) | |
}; | |
let typ = |typ: &str| json!({"alg": "ES256K", "typ": typ, "kid": "#atproto"}); | |
let service = unsigned(typ("JWT"), claims("did:plc:owner#atproto_pds")); |
unsigned was removed from this module (old lines 203-208) but is still called here, at elsewhere and at bare. This is the compile error check and test report. The Engine, URL_SAFE_NO_PAD and Value imports above it are unused until the helper is restored.
The one change since my approval restores the unsigned test helper in auth.rs. That fixes the compile error and the unused imports I raised last round. I found nothing else in it. The check, test and e2e runs were still going when I looked, so the build is unconfirmed until they finish. The small note about the first assertion being only is_err() still applies, but it is minor.
9 passed, 1 skipped
What changes
The second of the pulls moving knotless onto the
atprotocrate, after knotless takes its keys, JWTs, base32 and TIDs from the atproto crate. This one covers the parts that group-host shares or that decide who is asking. It leaves out the DRISL, CID, CAR and MST code, whose formats are settled.Service auth.
auth::verifyreads, checks and verifies a service token withservice_auth::{parts, check, verify}, and loopback tokens are checked the same way.signed_bytakes the check to run, and tries the cached signing key first and then the freshly read one, as before.Delegation tokens.
auth::verify_delegationparses and verifies withspace_authas aKind::Delegationtoken, so it now also requires thekid,jtiandexpthe alpha requires. Its ownDelegationstruct is gone: it returns the crate'sToken, andviewer.rsreadsissandsub. A token for another space's authority is still refused before any DID document is fetched.DID documents and handles.
identity::{service, signing_key, kem_key, method_key, valid_handle}are gone. Their callers useatproto::did::{service, pds, signing_key, kem_key, handle}andatproto::syntax::is_handle.is_handleaccepts exactly whatvalid_handledid: a last label may not start with a digit or-.verified_handlenow takes the firstat://entry inalsoKnownAs, where it used to take whatever came first.Space sync.
space_sync'sSetHash, DHKEM and HMAC derivation, commit MAC, MAC header parsing and STAR reader are gone. In their place areLtHash,element,encapsulate,Commit::mac,parse_mac_headerandread_star. A commit sent in an oplog page is converted to the crate'sCommit, which must be version 1 with a 32-byte digest. What stays in knotless is how a write moves the hash (apply, which now parses each CID), the check that the commit is the requested repo's in the requested space, and setting unreadable records aside.Space requests.
space::signedsigns withspace_auth::sign_request, andwant_mac_fromwrites its header withwant_mac_header.RECORD_MACandCOMMIT_MACcome from the crate.P256Key::keypairhands the crate the key.Dependencies.
bs58,blake3andhmacare dropped from the workspace.k256andp256are now dev-dependencies ofknotless, andknotless-servedepends onatprotodirectly.Why
These were copies of what the crate already has, checked there against
@atproto/space's and atproto's vectors. The spaces alpha is the part that still changes: its October build broke knotless's pushes and reads. With group-host on the same crate, the next change is made once.How it was checked
The unit tests that only re-checked the crate's own behaviour (key lookup, handle syntax, the known DHKEM secret and MAC, STAR framing errors) are gone. The tests that stayed check what knotless itself does:
space_auth::verify_requestagainst the bound key and not against another;Nothing was built here; the compile, the tests and the spaces alpha runs are left to CI.
Shortcomings
aturi::SpaceRefis still knotless's own. It is tied intoAtUriwithHashandOrd, which the crate'sSpaceReflacks.kidof#atproto, ajtiand anexp. The alpha's PDS writes these, but a PDS that leaves one out would now be refused.read_starcopies each record out of the archive rather than borrowing it. That happens only when a whole repo is read, which already decodes every record to JSON.Changeset: none