@evanp/activitypub-bot 0.42.1 → 0.43.0

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.
@@ -1,3 +1,4 @@
1
1
  {
2
+ "MD013": { "code_blocks": false },
2
3
  "MD024": { "siblings_only": true }
3
4
  }
package/CHANGELOG.md CHANGED
@@ -9,6 +9,28 @@ and this project adheres to
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.43.0] - 2026-04-22
13
+
14
+ ### Added
15
+
16
+ - Top-level exports for `LitePubRelayClientBot` and `LitePubRelayServerBot`
17
+ from `@evanp/activitypub-bot`.
18
+ - Back-compat aliases `RelayClientBot` and `RelayServerBot`, each re-exported
19
+ as the corresponding Mastodon relay class.
20
+ - README documentation for the `--allow-private`, `--redis-url`, and
21
+ `--trust-proxy` command-line options.
22
+ - README sections for `BotContext.duplicate()`, `updateNote()`, `deleteNote()`,
23
+ `getFollowersId()`, `isFollower()`, `isFollowing()`, `isPendingFollowing()`,
24
+ `followers()`, `following()`, `isLocal()`, and `onIdle()`.
25
+
26
+ ### Changed
27
+
28
+ - `.markdownlint.json` disables `MD013` inside code blocks so the CLI
29
+ help-output block can include longer option descriptions verbatim.
30
+ - README now documents `Bot.actorOK()` with its actual `actorId` parameter
31
+ name, and `BotContext.announceObject()` with its optional `actors` argument.
32
+ - `get botID ()` in the README was a typo for `get botId ()`; corrected.
33
+
12
34
  ## [0.42.1] - 2026-04-22
13
35
 
14
36
  ### Added
package/README.md CHANGED
@@ -64,6 +64,9 @@ Options:
64
64
  --intake <number> Number of background intake workers
65
65
  --index-file <path> HTML page to show at root path
66
66
  --profile-file <path> HTML page to show for bot profiles
67
+ --allow-private flag to allow private network requests
68
+ --redis-url <url> Redis connection URL for rate limiting
69
+ --trust-proxy <value> Express 'trust proxy' setting (e.g. "1", "loopback", "true")
67
70
  -h, --help Show this help
68
71
  ```
69
72
 
@@ -139,6 +142,24 @@ Path to the HTML file to show for bot profile pages. Like `--index-file`, any ex
139
142
 
140
143
  Falls back to the `PROFILE_FILE` environment variable. The default profile file is in `web/profile.html`.
141
144
 
145
+ #### --allow-private
146
+
147
+ Boolean flag. When set, the server will make outbound HTTP requests to private IP addresses (loopback, link-local, private, unique-local). By default these are blocked by `SafeAgent` to protect against SSRF. Enable this only when you need to reach ActivityPub peers on your local network or container network — for example, during development or integration testing.
148
+
149
+ Falls back to the `ALLOW_PRIVATE` environment variable. Default is `false`.
150
+
151
+ #### --redis-url
152
+
153
+ Redis connection URL used to back the rate-limit store. If unset, rate-limit counters live in memory, which is fine for a single-process deployment but loses state on restart and doesn't coordinate across multiple instances. Provide a Redis URL to share limits across processes.
154
+
155
+ Falls back to the `REDIS_URL` environment variable. Default is unset (in-memory limiter).
156
+
157
+ #### --trust-proxy
158
+
159
+ Express [`trust proxy`](https://expressjs.com/en/guide/behind-proxies.html) setting. Needed when the server runs behind a reverse proxy or load balancer so that `req.ip`, rate limiting, and logged client IPs reflect the real client rather than the proxy. Numeric values are parsed as a hop count (`1` means trust one hop), boolean-like values (`true`, `false`) toggle trust on or off, and any other value is passed through as a string (e.g. `"loopback"`, or a specific IP or CIDR range).
160
+
161
+ Falls back to the `TRUST_PROXY` environment variable. Default is unset (Express default, no proxy trust).
162
+
142
163
  ### Config file
143
164
 
144
165
  The config file defines the bots provided by this server.
@@ -188,13 +209,21 @@ A *DoNothingBot* instance will only do default stuff, like accepting follows.
188
209
  A *FollowBackBot* will follow back anyone who follows it. Useful for collecting
189
210
  public information.
190
211
 
191
- #### RelayClientBot
212
+ #### MastodonRelayClientBot
213
+
214
+ A *MastodonRelayClientBot* can be the client of a Mastodon relay.
192
215
 
193
- A *RelayClientBot* can be the client of a Mastodon or Pleroma relay.
216
+ #### MastodonRelayServerBot
194
217
 
195
- #### RelayServerBot
218
+ A *MastodonRelayServerBot* will act as a relay server for remote Mastodon servers.
196
219
 
197
- A *RelayServerBot* will act as a relay server for remote servers.
220
+ #### LitePubRelayClientBot
221
+
222
+ A *LitePubRelayClientBot* can be the client of a LitePub (Pleroma) relay.
223
+
224
+ #### LitePubRelayServerBot
225
+
226
+ A *LitePubRelayServerBot* will act as a relay server for remote Pleroma servers and other LitePub-relay-compliant servers.
198
227
 
199
228
  ## API
200
229
 
@@ -246,6 +275,11 @@ A [getter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Fun
246
275
 
247
276
  A [getter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get) for the username of the bot. Should match the constructor argument.
248
277
 
278
+ #### get type ()
279
+
280
+ A getter for the type of the bot. This should be an Activity Streams 2.0 object type;
281
+ the default is `Service`.
282
+
249
283
  #### get _context ()
250
284
 
251
285
  A protected [getter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get) for the context of the bot. (The default implementation stashes the context in a private variable, so this protected
@@ -277,11 +311,11 @@ Called when the server receives a public activity to its shared inbox. This can
277
311
 
278
312
  Called when one of the bot's objects is shared by another actor. The first argument is the object, and the second is the `Announce` activity itself. This method is called after the activity has been added to the `shares` collection.
279
313
 
280
- #### async actorOK (actor, activity)
314
+ #### async actorOK (actorId, activity)
281
315
 
282
316
  Lets the bot override the default check for matching the actor who sent an activity with the
283
317
  actor who did the activity. Usually, these need to be the same, but for some sub-protocols, like
284
- relays, it can be different. Returns a boolean saying whether the actor is OK.
318
+ relays, it can be different. `actorId` is the id of the actor who delivered the activity. Returns a boolean saying whether the actor is OK.
285
319
 
286
320
  #### async handleActivity (activity)
287
321
 
@@ -309,7 +343,7 @@ When a public activity is received at the shared inbox of the server, this metho
309
343
 
310
344
  This is the bot's control panel for working with the rest of the server.
311
345
 
312
- #### get botID ()
346
+ #### get botId ()
313
347
 
314
348
  Returns the username of the bot this context was created for.
315
349
 
@@ -333,6 +367,10 @@ Deletes the data stored for this key. There's no backup; it's just gone.
333
367
 
334
368
  Checks to see if any data has been previously stored with this key; returns a boolean.
335
369
 
370
+ #### async duplicate (username)
371
+
372
+ Returns a new `BotContext` identical to this one but scoped to the given `username`. Used by `BotFactory` implementations to produce a per-bot context from a shared template without re-wiring the underlying storage, client, and formatter.
373
+
336
374
  #### async getObject (id)
337
375
 
338
376
  Given an [ActivityPub object identifier](https://www.w3.org/TR/activitypub/#obj-id), returns an [activitystrea.ms](#activitystreams) object.
@@ -355,6 +393,14 @@ The optional additional parameters are strings used for ActivityPub properties o
355
393
 
356
394
  A shortcut for sending a reply with `content` to the `object`. Extracts and configures the right addressing properties and threading properties from `object`, and passes them to `sendNote()`.
357
395
 
396
+ #### async updateNote (note, content)
397
+
398
+ Updates a previously-sent `Note` with new `content`. Re-runs the microtext transformation, stores the updated object, and sends an `Update` activity to the original addressees.
399
+
400
+ #### async deleteNote (note)
401
+
402
+ Deletes a previously-sent `Note`. Replaces the stored object with a `Tombstone` and sends a `Delete` activity to the original addressees.
403
+
358
404
  #### async likeObject (obj)
359
405
 
360
406
  Sends a `Like` activity for the passed-in object in [activitystrea.ms](#activitystreams) form.
@@ -363,9 +409,9 @@ Sends a `Like` activity for the passed-in object in [activitystrea.ms](#activity
363
409
 
364
410
  Sends an `Undo`/`Like` activity for the passed-in object in [activitystrea.ms](#activitystreams) form which was previously liked.
365
411
 
366
- #### async announceObject (obj)
412
+ #### async announceObject (obj, actors = null)
367
413
 
368
- Sends an `Announce` activity for the passed-in object in [activitystrea.ms](#activitystreams) form to followers.
414
+ Sends an `Announce` activity for the passed-in object in [activitystrea.ms](#activitystreams) form. If `actors` is `null` (the default), the `Announce` is addressed to the bot's followers. Otherwise, pass an array of actor IDs (or actor objects) to address the `Announce` to a specific set of recipients — useful for relay-style re-Announce.
369
415
 
370
416
  #### async unannounceObject (obj)
371
417
 
@@ -401,6 +447,38 @@ Gets the `id` of the [ActivityPub Actor](https://www.w3.org/TR/activitypub/#acto
401
447
 
402
448
  Gets the [WebFinger](https://en.wikipedia.org/wiki/WebFinger) identity of the [ActivityPub Actor](https://www.w3.org/TR/activitypub/#actors) with the given `id`.
403
449
 
450
+ #### getFollowersId ()
451
+
452
+ Returns the URL of this bot's `followers` collection. Synchronous.
453
+
454
+ #### async isFollower (obj)
455
+
456
+ Returns `true` if `obj` (an actor object in [activitystrea.ms](#activitystreams) form, or anything with an `id`) is in this bot's `followers` collection.
457
+
458
+ #### async isFollowing (obj)
459
+
460
+ Returns `true` if `obj` is in this bot's `following` collection.
461
+
462
+ #### async isPendingFollowing (obj)
463
+
464
+ Returns `true` if this bot has sent a `Follow` to `obj` that has not yet been accepted or rejected.
465
+
466
+ #### async \* followers ()
467
+
468
+ Async generator that yields each actor in this bot's `followers` collection, one at a time, across collection pages.
469
+
470
+ #### async \* following ()
471
+
472
+ Async generator that yields each actor in this bot's `following` collection, one at a time, across collection pages.
473
+
474
+ #### isLocal (url)
475
+
476
+ Returns `true` if `url` is served by this activitypub-bot instance (i.e. its origin matches the configured `--origin`). Synchronous.
477
+
478
+ #### async onIdle ()
479
+
480
+ Resolves when the background distribution queue has drained. Intended for test code that needs to wait for outbound activities to finish being delivered before asserting on their effects.
481
+
404
482
  ### activitystrea.ms
405
483
 
406
484
  Activity Streams 2.0 objects are represented internally as [activitystrea.ms](https://www.npmjs.com/package/activitystrea.ms) library objects.
package/lib/index.js CHANGED
@@ -3,6 +3,8 @@ export { default as Bot } from './bot.js'
3
3
  export { default as BotFactory } from './botfactory.js'
4
4
  export { default as OKBot } from './bots/ok.js'
5
5
  export { default as DoNothingBot } from './bots/donothing.js'
6
- export { default as MastodonRelayClientBot } from './bots/mastodonrelayclient.js'
7
- export { default as MastodonRelayServerBot } from './bots/mastodonrelayserver.js'
6
+ export { default as MastodonRelayClientBot, default as RelayClientBot } from './bots/mastodonrelayclient.js'
7
+ export { default as MastodonRelayServerBot, default as RelayServerBot } from './bots/mastodonrelayserver.js'
8
8
  export { default as FollowBackBot } from './bots/followback.js'
9
+ export { default as LitePubRelayClientBot } from './bots/litepubrelayclient.js'
10
+ export { default as LitePubRelayServerBot } from './bots/litepubrelayserver.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.42.1",
3
+ "version": "0.43.0",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",