@rmdes/indiekit-endpoint-activitypub 1.1.12 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,267 @@
1
+ # @rmdes/indiekit-endpoint-activitypub
2
+
3
+ ActivityPub federation endpoint for [Indiekit](https://getindiekit.com). Makes your IndieWeb site a full fediverse actor — discoverable, followable, and interactive from Mastodon, Misskey, Pixelfed, and any ActivityPub-compatible platform.
4
+
5
+ ## Features
6
+
7
+ **Federation**
8
+ - Full ActivityPub actor with WebFinger, NodeInfo, HTTP Signatures, and Object Integrity Proofs (Ed25519)
9
+ - Outbox syndication — posts created via Micropub are automatically delivered to followers
10
+ - Inbox processing — receives follows, likes, boosts, replies, mentions, deletes, and account moves
11
+ - Content negotiation — ActivityPub clients requesting your site get JSON-LD; browsers get HTML
12
+ - Reply delivery — replies are addressed to and delivered directly to the original post's author
13
+ - Shared inbox support with collection sync (FEP-8fcf)
14
+ - Configurable actor type (Person, Service, Organization, Group)
15
+
16
+ **Reader**
17
+ - Timeline view showing posts from followed accounts
18
+ - Notifications for likes, boosts, follows, mentions, and replies
19
+ - Compose form with dual-path posting (quick AP reply or Micropub blog post)
20
+ - Native interactions (like, boost, reply, follow/unfollow from the reader)
21
+ - Remote actor profile pages
22
+ - Content warnings and sensitive content handling
23
+ - Media display (images, video, audio)
24
+ - Configurable timeline retention
25
+
26
+ **Moderation**
27
+ - Mute actors or keywords
28
+ - Block actors (also removes from followers)
29
+ - All moderation actions available from the reader UI
30
+
31
+ **Mastodon Migration**
32
+ - Import following/followers lists from Mastodon CSV exports
33
+ - Set `alsoKnownAs` alias for account Move verification
34
+ - Batch re-follow processor — gradually sends Follow activities to imported accounts
35
+ - Progress tracking with pause/resume controls
36
+
37
+ **Admin UI**
38
+ - Dashboard with follower/following counts and recent activity
39
+ - Profile editor (name, bio, avatar, header, profile links with rel="me" verification)
40
+ - Pinned posts (featured collection)
41
+ - Featured tags (hashtag collection)
42
+ - Activity log (inbound/outbound)
43
+ - Follower and following lists with source tracking
44
+
45
+ ## Requirements
46
+
47
+ - [Indiekit](https://getindiekit.com) v1.0.0-beta.25+
48
+ - Node.js >= 22
49
+ - MongoDB (used by Indiekit)
50
+ - Redis (recommended for production delivery queue; in-process queue available for development)
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ npm install @rmdes/indiekit-endpoint-activitypub
56
+ ```
57
+
58
+ ## Configuration
59
+
60
+ Add the plugin to your Indiekit config:
61
+
62
+ ```javascript
63
+ // indiekit.config.js
64
+ export default {
65
+ plugins: [
66
+ "@rmdes/indiekit-endpoint-activitypub",
67
+ ],
68
+ "@rmdes/indiekit-endpoint-activitypub": {
69
+ mountPath: "/activitypub",
70
+ actor: {
71
+ handle: "yourname",
72
+ name: "Your Name",
73
+ summary: "A short bio",
74
+ icon: "https://example.com/avatar.jpg",
75
+ },
76
+ },
77
+ };
78
+ ```
79
+
80
+ ### All Options
81
+
82
+ | Option | Type | Default | Description |
83
+ |---|---|---|---|
84
+ | `mountPath` | string | `"/activitypub"` | URL prefix for all plugin routes |
85
+ | `actor.handle` | string | `"rick"` | Fediverse username (e.g. `@handle@yourdomain.com`) |
86
+ | `actor.name` | string | `""` | Display name (used to seed profile on first run) |
87
+ | `actor.summary` | string | `""` | Bio text (used to seed profile on first run) |
88
+ | `actor.icon` | string | `""` | Avatar URL (used to seed profile on first run) |
89
+ | `checked` | boolean | `true` | Whether the syndicator is checked by default in the post editor |
90
+ | `alsoKnownAs` | string | `""` | Mastodon migration alias URL |
91
+ | `activityRetentionDays` | number | `90` | Days to keep activity log entries (0 = forever) |
92
+ | `storeRawActivities` | boolean | `false` | Store full raw JSON of inbound activities |
93
+ | `redisUrl` | string | `""` | Redis connection URL for delivery queue |
94
+ | `parallelWorkers` | number | `5` | Number of parallel delivery workers (requires Redis) |
95
+ | `actorType` | string | `"Person"` | Actor type: `Person`, `Service`, `Organization`, or `Group` |
96
+ | `timelineRetention` | number | `1000` | Maximum timeline items to keep (0 = unlimited) |
97
+
98
+ ### Redis (Recommended for Production)
99
+
100
+ Without Redis, the plugin uses an in-process message queue. This works for development but won't survive restarts and has limited throughput.
101
+
102
+ ```javascript
103
+ "@rmdes/indiekit-endpoint-activitypub": {
104
+ redisUrl: "redis://localhost:6379",
105
+ parallelWorkers: 5,
106
+ },
107
+ ```
108
+
109
+ ### Nginx Configuration (Reverse Proxy)
110
+
111
+ If you serve a static site alongside Indiekit (e.g. with Eleventy), you need nginx rules to route ActivityPub requests to Indiekit while serving HTML to browsers:
112
+
113
+ ```nginx
114
+ # ActivityPub content negotiation — detect AP clients
115
+ map $http_accept $is_activitypub {
116
+ default 0;
117
+ "~*application/activity\+json" 1;
118
+ "~*application/ld\+json" 1;
119
+ }
120
+
121
+ # Proxy /activitypub to Indiekit
122
+ location /activitypub {
123
+ proxy_pass http://127.0.0.1:8080;
124
+ proxy_set_header Host $host;
125
+ proxy_set_header X-Forwarded-Proto https;
126
+ }
127
+
128
+ # Default: static site, but AP clients get proxied
129
+ location / {
130
+ if ($is_activitypub) {
131
+ proxy_pass http://127.0.0.1:8080;
132
+ }
133
+ try_files $uri $uri/ $uri.html =404;
134
+ }
135
+ ```
136
+
137
+ ## How It Works
138
+
139
+ ### Syndication (Outbound)
140
+
141
+ When you create a post via Micropub, Indiekit's syndication system calls this plugin's syndicator. The plugin:
142
+
143
+ 1. Converts the JF2 post properties to an ActivityStreams 2.0 `Create(Note)` or `Create(Article)` activity
144
+ 2. For replies, resolves the original post's author to include them in CC and deliver directly to their inbox
145
+ 3. Sends the activity to all followers via shared inboxes using Fedify's delivery queue
146
+ 4. Appends a permalink to the content so fediverse clients link back to your canonical post
147
+
148
+ ### Inbox Processing (Inbound)
149
+
150
+ When remote servers send activities to your inbox:
151
+
152
+ - **Follow** → Auto-accepted, stored in `ap_followers`, notification created
153
+ - **Undo(Follow)** → Removed from `ap_followers`
154
+ - **Like** → Logged in activity log, notification created (only for reactions to your own posts)
155
+ - **Announce (Boost)** → Logged + notification (your content) or stored in timeline (followed account)
156
+ - **Create (Note/Article)** → Stored in timeline if from a followed account; notification if it's a reply or mention
157
+ - **Update** → Updates timeline item content or refreshes follower profile data
158
+ - **Delete** → Removes from activity log and timeline
159
+ - **Move** → Updates follower's actor URL
160
+ - **Accept(Follow)** → Marks our follow as accepted
161
+ - **Reject(Follow)** → Marks our follow as rejected
162
+ - **Block** → Removes actor from our followers
163
+
164
+ ### Content Negotiation
165
+
166
+ The plugin mounts a root-level router that intercepts requests from ActivityPub clients (detected by `Accept: application/activity+json` or `application/ld+json`):
167
+
168
+ - Root URL (`/`) → Redirects to the Fedify actor document
169
+ - Post URLs → Looks up the post in MongoDB, converts to AS2 JSON
170
+ - NodeInfo (`/nodeinfo/2.1`) → Delegated to Fedify
171
+
172
+ Regular browser requests pass through unmodified.
173
+
174
+ ### Mastodon Migration
175
+
176
+ The plugin supports migrating from a Mastodon account:
177
+
178
+ 1. **Set alias** — Configure `alsoKnownAs` with your old Mastodon profile URL. This is verified by Mastodon before allowing a Move.
179
+ 2. **Import social graph** — Upload Mastodon's `following_accounts.csv` and `followers.csv` exports. Following entries are resolved via WebFinger and stored locally.
180
+ 3. **Trigger Move** — From Mastodon's settings, initiate a Move to `@handle@yourdomain.com`. Mastodon notifies your followers, and compatible servers auto-refollow.
181
+ 4. **Batch re-follow** — The plugin gradually sends Follow activities to all imported accounts (10 per batch, 30s between batches) so remote servers start delivering content to your inbox.
182
+
183
+ ## Verification
184
+
185
+ After deployment, verify federation is working:
186
+
187
+ ```bash
188
+ # WebFinger discovery
189
+ curl -s "https://yourdomain.com/.well-known/webfinger?resource=acct:handle@yourdomain.com" | jq .
190
+
191
+ # Actor document
192
+ curl -s -H "Accept: application/activity+json" "https://yourdomain.com/" | jq .
193
+
194
+ # NodeInfo
195
+ curl -s "https://yourdomain.com/nodeinfo/2.1" | jq .
196
+ ```
197
+
198
+ Then search for `@handle@yourdomain.com` from any Mastodon instance — your profile should appear.
199
+
200
+ ## Admin UI Pages
201
+
202
+ All admin pages are behind IndieAuth authentication:
203
+
204
+ | Page | Path | Description |
205
+ |---|---|---|
206
+ | Dashboard | `/activitypub` | Overview with follower/following counts, recent activity |
207
+ | Reader | `/activitypub/admin/reader` | Timeline from followed accounts |
208
+ | Notifications | `/activitypub/admin/reader/notifications` | Likes, boosts, follows, mentions, replies |
209
+ | Compose | `/activitypub/admin/reader/compose` | Reply composer (quick AP or Micropub) |
210
+ | Moderation | `/activitypub/admin/reader/moderation` | Muted/blocked accounts and keywords |
211
+ | Profile | `/activitypub/admin/profile` | Edit actor display name, bio, avatar, links |
212
+ | Followers | `/activitypub/admin/followers` | List of accounts following you |
213
+ | Following | `/activitypub/admin/following` | List of accounts you follow |
214
+ | Activity Log | `/activitypub/admin/activities` | Inbound/outbound activity history |
215
+ | Pinned Posts | `/activitypub/admin/featured` | Pin/unpin posts to your featured collection |
216
+ | Featured Tags | `/activitypub/admin/tags` | Add/remove featured hashtags |
217
+ | Migration | `/activitypub/admin/migrate` | Mastodon import wizard |
218
+
219
+ ## MongoDB Collections
220
+
221
+ The plugin creates these collections automatically:
222
+
223
+ | Collection | Description |
224
+ |---|---|
225
+ | `ap_followers` | Accounts following your actor |
226
+ | `ap_following` | Accounts you follow |
227
+ | `ap_activities` | Activity log with automatic TTL cleanup |
228
+ | `ap_keys` | RSA and Ed25519 key pairs for HTTP Signatures |
229
+ | `ap_kv` | Fedify key-value store and batch job state |
230
+ | `ap_profile` | Actor profile (single document) |
231
+ | `ap_featured` | Pinned/featured posts |
232
+ | `ap_featured_tags` | Featured hashtags |
233
+ | `ap_timeline` | Reader timeline items from followed accounts |
234
+ | `ap_notifications` | Interaction notifications |
235
+ | `ap_muted` | Muted actors and keywords |
236
+ | `ap_blocked` | Blocked actors |
237
+ | `ap_interactions` | Per-post like/boost tracking |
238
+
239
+ ## Supported Post Types
240
+
241
+ The JF2-to-ActivityStreams converter handles these Indiekit post types:
242
+
243
+ | Post Type | ActivityStreams |
244
+ |---|---|
245
+ | note, reply, bookmark, jam, rsvp, checkin | `Create(Note)` |
246
+ | article | `Create(Article)` |
247
+ | like | `Like` |
248
+ | repost | `Announce` |
249
+ | photo, video, audio | Attachments on Note/Article |
250
+
251
+ Categories are converted to `Hashtag` tags. Bookmarks include a bookmark emoji and link.
252
+
253
+ ## Known Limitations
254
+
255
+ - **No automated tests** — Manual testing against real fediverse servers
256
+ - **Single actor** — One fediverse identity per Indiekit instance
257
+ - **No Authorized Fetch enforcement** — Disabled due to Fedify's current limitation with authenticated outgoing fetches (causes infinite loops with servers that require it)
258
+ - **No image upload in reader** — Compose form is text-only
259
+ - **In-process queue without Redis** — Activities may be lost on restart
260
+
261
+ ## License
262
+
263
+ MIT
264
+
265
+ ## Author
266
+
267
+ [Ricardo Mendes](https://rmendes.net) ([@rick@rmendes.net](https://rmendes.net))
@@ -47,6 +47,7 @@ export function readerController(mountPath) {
47
47
  // Tab filtering
48
48
  if (tab === "notes") {
49
49
  options.type = "note";
50
+ options.excludeReplies = true;
50
51
  } else if (tab === "articles") {
51
52
  options.type = "article";
52
53
  } else if (tab === "boosts") {
@@ -75,6 +75,15 @@ export async function getTimelineItems(collections, options = {}) {
75
75
  query.type = options.type;
76
76
  }
77
77
 
78
+ // Exclude replies (notes with inReplyTo set)
79
+ if (options.excludeReplies) {
80
+ query.$or = [
81
+ { inReplyTo: null },
82
+ { inReplyTo: "" },
83
+ { inReplyTo: { $exists: false } },
84
+ ];
85
+ }
86
+
78
87
  // Author filter (for profile view) — validate string type to prevent operator injection
79
88
  if (options.authorUrl) {
80
89
  if (typeof options.authorUrl !== "string") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-activitypub",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
5
5
  "keywords": [
6
6
  "indiekit",
@@ -46,7 +46,8 @@
46
46
  <div class="ap-profile__info">
47
47
  <div class="ap-profile__avatar-wrap">
48
48
  {% if icon %}
49
- <img src="{{ icon }}" alt="{{ name }}" class="ap-profile__avatar">
49
+ <img src="{{ icon }}" alt="{{ name }}" class="ap-profile__avatar"
50
+ onerror="this.replaceWith(Object.assign(document.createElement('div'),{className:'ap-profile__avatar ap-profile__avatar--placeholder',textContent:'{{ name[0] }}'}))">
50
51
  {% else %}
51
52
  <div class="ap-profile__avatar ap-profile__avatar--placeholder">{{ name[0] }}</div>
52
53
  {% endif %}
@@ -24,7 +24,8 @@
24
24
  {# Author header #}
25
25
  <header class="ap-card__author">
26
26
  {% if item.author.photo %}
27
- <img src="{{ item.author.photo }}" alt="{{ item.author.name }}" class="ap-card__avatar" loading="lazy">
27
+ <img src="{{ item.author.photo }}" alt="{{ item.author.name }}" class="ap-card__avatar"
28
+ onerror="this.replaceWith(Object.assign(document.createElement('span'),{className:'ap-card__avatar ap-card__avatar--default',textContent:'{{ item.author.name[0] | upper if item.author.name else "?" }}'}))">
28
29
  {% else %}
29
30
  <span class="ap-card__avatar ap-card__avatar--default" aria-hidden="true">{{ item.author.name[0] | upper if item.author.name else "?" }}</span>
30
31
  {% endif %}