ActivityPub in OCaml using jsont/eio/requests
1# ActivityPub Implementation Plan
2
3## Overview
4
5The `requests` library already provides RFC 9421 HTTP Message Signatures via `Requests.Signature`.
6This simplifies Phase 1 significantly - we just need to integrate the existing signing.
7
8## Phase 1: Integrate HTTP Signatures ✓
9
10The requests library provides:
11- `Signature.config` - signing configuration with key, keyid, components
12- `Signature.Key` - Ed25519, RSA, ECDSA P-256/P-384, HMAC keys
13- `Signature.sign` - sign request headers
14- `Signature.sign_with_digest` - sign with Content-Digest (RFC 9530)
15- `Signature.verify` - verify signatures
16- `Signature.Content_digest` - body digest computation
17
18### 1.1 Update Apubt.Signing ✓
19- [x] Already has key_id and private_key fields
20- [x] Add proper Key.t construction from PEM
21- [x] Configure default signed components for ActivityPub
22
23### 1.2 Integrate into Http.post ✓
24- [x] Create signature config from Apubt.Signing
25- [x] Sign requests before sending
26- [x] Add Content-Digest for POST bodies
27
28## Phase 2: Activity Delivery ✓
29
30### 2.1 Inbox Delivery ✓
31- [x] `Inbox.post` - POST signed activity to inbox URI
32- [x] `Inbox.post_to_actor` - resolve inbox from actor, deliver
33- [x] `Inbox.post_to_shared_inbox` - batch delivery to shared inbox
34
35### 2.2 Recipient Resolution ✓
36- [x] Extract recipients from to/cc/bto/bcc fields
37- [x] Dereference collection URIs to get actor list
38- [x] Handle Public collection (use shared inbox)
39- [x] De-duplicate recipients
40
41## Phase 3: Outbox Operations ✓
42
43### 3.1 Note Creation ✓
44- [x] `Outbox.create_note` - construct Create(Note) activity
45- [x] `Outbox.public_note` - to: Public, cc: followers
46- [x] `Outbox.followers_only_note` - to: followers only
47- [x] `Outbox.direct_note` - to: specific actors
48- [x] Generate unique activity/object IDs
49
50### 3.2 Interactions ✓
51- [x] `Outbox.like` - Like activity
52- [x] `Outbox.unlike` - Undo(Like)
53- [x] `Outbox.announce` - boost/reblog
54- [x] `Outbox.unannounce` - Undo(Announce)
55
56### 3.3 Modifications ✓
57- [x] `Outbox.delete` - Delete with Tombstone
58- [x] `Outbox.update_note` - Update activity
59
60## Phase 4: Follow Protocol ✓
61
62### 4.1 Outgoing Follows ✓
63- [x] `Actor.follow` - send Follow to target inbox
64- [x] `Actor.unfollow` - send Undo(Follow)
65
66### 4.2 Incoming Follows ✓
67- [x] `Actor.accept_follow` - send Accept(Follow)
68- [x] `Actor.reject_follow` - send Reject(Follow)
69
70## Phase 5: Proto Properties ✓
71
72### 5.1 Actor Properties ✓
73- [x] `also_known_as: Uri.t list option`
74- [x] `discoverable: bool option`
75- [x] `suspended: bool option`
76- [x] `moved_to: Uri.t option`
77- [x] `featured: Uri.t option`
78- [x] `featured_tags: Uri.t option`
79
80### 5.2 Object Properties ✓
81- [x] `conversation: Uri.t option` (conversation threading)
82- [x] `audience: Recipient.t list option`
83- [x] `location: Link_or_uri.t option`
84- [x] `preview: Link_or_uri.t option`
85
86### 5.3 Question Activity ✓
87- [x] `one_of: Object_ref.t list option`
88- [x] `any_of: Object_ref.t list option`
89- [x] `closed: Datetime.t option`
90
91## Phase 6: NodeInfo ✓
92
93- [x] Fetch `/.well-known/nodeinfo`
94- [x] Parse nodeinfo links for schema 2.0/2.1
95- [x] Fetch and decode nodeinfo document
96
97## Phase 7: CLI Enhancements ✓
98
99Current commands:
100- [x] `apub webfinger` - look up account via Webfinger
101- [x] `apub actor` - fetch an ActivityPub actor
102- [x] `apub outbox` - fetch an actor's outbox
103- [x] `apub post` - create and post a note
104- [x] `apub follow` - follow an actor
105- [x] `apub like` - like a post
106- [x] `apub boost` - announce/reblog a post
107
108## Phase 8: WebFinger Integration ✓
109
110Integrated the `webfinger` library for RFC 7033/7565 compliant discovery:
111- [x] Use `Webfinger.query_acct` for proper acct URI handling
112- [x] Support for percent-encoding in userparts
113- [x] Added `Webfinger.lookup_raw` for efficient direct JRD access
114- [x] Added ActivityPub WebFinger spec to `spec/` directory
115
116## Implementation Order
117
118```
119Phase 1.1-1.2 (Signing integration) ✓
120 ↓
121Phase 2 (Delivery) ✓ ──→ Phase 4 (Follow) ✓
122 ↓
123Phase 3 (Outbox) ✓
124 ↓
125Phase 7 (CLI) ✓
126 ↓
127Phase 8 (WebFinger) ✓
128
129Phase 5 (Properties) ✓
130Phase 6 (NodeInfo) ✓
131```
132
133## Completed
134
135All phases are now complete. The library provides:
136- Full HTTP signature support (RFC 9421)
137- Activity delivery to inboxes
138- Outbox operations (create, like, boost, delete, update)
139- Follow protocol (follow, unfollow, accept, reject)
140- Question/poll activity support
141- NodeInfo discovery
142- Complete CLI with read and write operations
143- RFC 7033/7565 compliant WebFinger via the `webfinger` library