| … | … | @@ -0,0 +1,37 @@ |
| 1 | # atproto-did-peer |
| 2 | |
| 3 | **Keyless P2P reader** for a self-custody atproto peer's repo + firehose. Given a DID (and its verify key), |
| 4 | it announces + replicates the peer's Hypercores over Hyperswarm and derives a read view — holding **no key** |
| 5 | and never re-minting a signature (the peer's own signed commits travel in its firehose). |
| 6 | |
| 7 | Extracted from [atproto-bridge](../atproto-bridge)'s `PeerFront`/`PeerRouter` so the read path is a shared |
| 8 | module. Consumed by [favela-web](../favela-web) (its appview reads community members' repos) and the bridge. |
| 9 | |
| 10 | ## API |
| 11 | |
| 12 | ```js |
| 13 | import { DidPeer, DidPeerRouter } from 'atproto-did-peer' |
| 14 | |
| 15 | // single DID |
| 16 | const peer = new DidPeer(corestore, { did, verifyKey }) |
| 17 | await peer.ready() |
| 18 | for (const r of await peer.listRecords('app.bsky.feed.post')) { … } // snapshot read |
| 19 | for await (const { bytes } of peer.subscribeRepos(from)) { … } // live firehose tail |
| 20 | const ops = await DidPeer.commitOps(frameBody) // decode a #commit's ops |
| 21 | |
| 22 | // MANY DIDs over ONE announce channel (the multi-DID fix — a per-peer attach collides on the |
| 23 | // single ANNOUNCE_PROTOCOL channel; the router owns replication + dispatch by DID) |
| 24 | const router = new DidPeerRouter(corestore) |
| 25 | swarm.on('connection', (c) => router.onconnection(c)) |
| 26 | const peer = router.add(did, { verifyKey }) |
| 27 | ``` |
| 28 | |
| 29 | ## Why keyless |
| 30 | |
| 31 | The firehose is already torrent-like (hypercore: multi-source parallel download, per-block |
| 32 | Merkle + signature piece-hashes, sparse, non-author seeding, live-append). A reader verifies each signed |
| 33 | commit against the DID's key; it never needs the signing key to READ. This is the substrate favela's |
| 34 | per-peer appview and the keyless membrane both build on. |
| 35 | |
| 36 | See also: [atproto-store](../atproto-store) (repo storage + firehose codec), |
| 37 | [hyper-proto-peer](../hyper-proto-peer) (the self-custody peer that holds the key). |