chadtmiller.com/group-host
atmosphere group host
0
0
A moved group's commit is checked by atproto's Commit::verified
crates/group-host/src/migration.rs+5−4
| @@ -303,16 +303,17 @@ pub(crate) fn create(path: &str, value: &[u8]) -> Option<Write> { | ||
}) | ||
} | ||
| ||
/// The records of a repo's CAR, once its commit is `group`'s, signed by | ||
/// `key`, and its tree and records are whole. | ||
/// The records of a repo's CAR, once its commit is `group`'s, at a TID, | ||
/// signed by `key` (`atproto::Commit::verified`), and its tree and records | ||
/// are whole. | ||
pub(crate) fn repo_writes( | ||
bytes: &[u8], | ||
group: &str, | ||
key: &atproto::PublicKey, | ||
) -> Option<Vec<Write>> { | ||
let repo = car::read(bytes).ok()?; | ||
let commit = atproto::Commit::from_bytes(repo.blocks.get(repo.roots.first()?)?).ok()?; | ||
(commit.did == group && commit.verify(key)).then_some(())?; | ||
let root = repo.roots.first()?; | ||
let commit = atproto::Commit::verified(repo.blocks.get(root)?, group, key).ok()?; | ||
let tree = Tree::read(commit.data, &repo.blocks).ok()?; | ||
let leaves = tree.leaves(); | ||
leaves | ||
crates/group-host/tests/account_move.rs+1−1
| @@ -221,7 +221,7 @@ fn public_repo(did: &str, key: &Keypair) -> Vec<u8> { | ||
Cid::of_cbor(&post), | ||
)]); | ||
let tree = Tree::build(&paths); | ||
let commit = Commit::sign(did, tree.root(), "3lz", key); | ||
let commit = Commit::sign(did, tree.root(), "3l5mz5mkbn22b", key); | ||
let mut blocks: Vec<(Cid, Vec<u8>)> = tree.blocks().into_iter().collect(); | ||
blocks.push((Cid::of_cbor(&post), post)); | ||
blocks.push((commit.cid(), commit.to_bytes())); | ||
crates/group-host/tests/import.rs+1−1
| @@ -110,7 +110,7 @@ fn repo_of(did: &str, key: &Keypair, records: &[(&str, Vec<u8>)]) -> Vec<u8> { | ||
.map(|(p, r)| (p.to_string(), Cid::of_cbor(r))) | ||
.collect(); | ||
let tree = Tree::build(&paths); | ||
let commit = Commit::sign(did, tree.root(), "3lz", key); | ||
let commit = Commit::sign(did, tree.root(), "3l5mz5mkbn22b", key); | ||
let mut blocks: Vec<(Cid, Vec<u8>)> = tree.blocks().into_iter().collect(); | ||
blocks.extend(records.iter().map(|(_, r)| (Cid::of_cbor(r), r.clone()))); | ||
blocks.push((commit.cid(), commit.to_bytes())); | ||
crates/group-host/tests/migration.rs+1−1
| @@ -669,7 +669,7 @@ fn repo_of(did: &str, key: &Keypair) -> Vec<u8> { | ||
drisl::encode(&drisl::Value::from_json(&json!({"$type": "a.b.c", "x": 1})).unwrap()); | ||
let cid = Cid::of_cbor(&record); | ||
let tree = Tree::build(&BTreeMap::from([("a.b.c/r".to_string(), cid)])); | ||
let commit = Commit::sign(did, tree.root(), "3lz", key); | ||
let commit = Commit::sign(did, tree.root(), "3l5mz5mkbn22b", key); | ||
let mut blocks: Vec<(Cid, Vec<u8>)> = tree.blocks().into_iter().collect(); | ||
blocks.push((cid, record)); | ||
blocks.push((commit.cid(), commit.to_bytes())); | ||
Cargo.lock+2−2
| @@ -49,9 +49,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" | ||
| ||
[[package]] | ||
name = "atproto" | ||
version = "0.2.0" | ||
version = "0.2.2" | ||
source = "sparse+https://knotless.dev/cargo/did:plc:bcgltzqazw5tb6k2g3ttenbj/3mzr5vldibtui/" | ||
checksum = "1e2e64b879335e9885d684bd1f93acd1d28acefa4e498daf6b3249a6e20d396f" | ||
checksum = "8795ce2e4481daea735af125c1304ff5d180ecefd4318790ea8bbf13d50e47c8" | ||
dependencies = [ | ||
"base64 0.22.1", | ||
"blake3", | ||