-
Notifications
You must be signed in to change notification settings - Fork 106
ActivityPub Integration
Bryan Ashby edited this page Jan 24, 2023
·
30 revisions
Discussion and design of ActivityPub / Mastodon with ENiGMA½. See also ActivityPub / Mastodon #459.
- Act as both a server and a client
- On behalf of users (client)
- AP server-to-server (Federated)
- As the BBS itself (bot)
- Feed views
- Local
- Federated
- Following
- Inbox
- Direct replies also land in user's inbox
- User can again reply, or directly post to ActivityPub addresses
- Similar to NetMail (more direct), via @[email protected] syntax
- See https://github.com/w3c/activitypub/issues/196
- Message Areas
- Ability to map a message area to a ActivityPub 'group'
- Read and reply in message base
- Similar to EchoMail
- Bridged/mapped message areas, such as FTN (non-Mastodon node) <-> Local (Mastodon) <-> Fediverse
- Users
- Users should be aware of any Mastodon bridged message networks or any time their messages land on Mastodon in general
- Q: A reply in a mapped area may land in both the inbox and said area?
- Should we create a more generalized ActivityPub support/module/classes that Mastodon then extends?
- We have been building our own
- How are we going to deal with profile pictures and banners? Have users upload them to the BBS? Add URLs on account creation? Both?
- Two main properties in actor:
image
andicon
- Two main properties in actor:
- Is the web part of this big enough that we should look into using something like express.js and a module like activitypub-express instead of rolling our own implementation - ANSWER: not at this time, we are going to try to create our own first
- How to allow users to choose to use real vs username for Mastodon specific browse/follow/reply/etc.
- Note: Message areas have the ability to control this currently
- Part of ActivityPub config mod
- How to handle follower approval (
manuallyApprovesFollowers
actor property)- See other properties to be user controlled also; perhaps with +op defaults
- Similar to above, allow users to control if they are
discoverable
(actor property)
- Looks like Mastodon is adding some Group functionality that might make my suggested workaround for message areas unnecessary (depends on timing, I see anything about when it will be released though it does look like it is funded work): https://github.com/mastodon/mastodon/pull/19059
- Research user private key storage; this seems like a major security issue
- These certificates are used for server-to-server only, not e.g. message encryption; mostly non-issue: https://github.com/mastodon/mastodon/discussions/18669
- Rename keys to be more ActivityPub explicit; note in code their usage is reserved
- We need to delete from
private_mail
at some point, specifically the sent messages- What frequency for messages in outbox? How many to keep? When to remove?
-
trimExternalPrivateSentMail()
does this for messages with the exported flag, but we may need a diff freq for AP - Note also: Exported is only a single flag, so does not account for e.g. FTN and ActivityPub
-
maxMessageLength
- Per mapped area configuration
- When sending from private mail to a ActivityPub address
- Perhaps addition to address info?
- Use Mastodon defualt length
500
- Determine how groups are to work
- A post to
areaTag
should go to a "group" on Mastodon - Incoming messages map to
areaTag
-
areaTag
mapping ala FTN -
maxMessageLength
optionally configured (overridden from def)
- A post to
- Replies
- Incoming:
inReplyTo
-> ID in local Activities / Message meta - Outgoing:
message.replyToMsgId
-> AP ID ->inReplyto
- Incoming:
- Move Web server to it's own log
- Same setup - rotation/etc.
- Default config with overrides available to +op
- Settings
- Determine exactly how "private" (user-to-user only) are to work
- Implement followers
- Track who is following each account
- On export, export to all followers if not a direct message
First class Mastodon support
- Send
POST
to remote inbox- Private user-to-user
- Via local mail to/from @user@host
- Receive
POST
to local inbox:- Remote user places items in local user's inbox
- Receive
GET
of local inbox- Clients: Fetch new inbox items Not required for initial offering
- Support for alt/non-BBS client interaction
- Items
POST
ed from other federated servers
- BBS: no GET request, interaction is within BBS
- Read and respond via private mail box (ala local, NetMail, ...)
- Clients: Fetch new inbox items Not required for initial offering
-
GET
of remote outbox to see new messages- Fetching new posts
-
POST
to local outbox- Stored locally
- Public
- In "groups" mapped to local
areaTag
- To local
activityPub
area tag for both Federated and Local views - No
POST
/ endpoint actually used within BBS
- In "groups" mapped to local
- External Clients
- Actual
POST
to outbox - Stored locally
- Actual
-
GET
of remote outbox to see new messages- External clients
Object
/
id
-
Actor
/- Provides information about an Actor (user's in our case)
static fromLocalUser(userId, ...)
-
Activity
/- Can wrap other Objects --
static wrapObject(obj)
- Can wrap other Objects --
-
Collection
/- Fetching and building of various collections
- inbox, outbox, followers, following, likes, ...
static get(...)
core/
servers/
content/
web.js
web_handlers/
webfinger.js
activitypub.js
-
webfinger.js
- Handles standard WebFinger requests via
acct:
- Handles standard profile request associated with WebFinger
- Includes additional
rel
and aliases if an ActivityPub system is also enabled, such as Mastodon- It would be nice if these could be 'injected' by
mastdon.js
- Perhaps at least only if +op has enabled activitypub
- It would be nice if these could be 'injected' by
- Handles standard WebFinger requests via
-
activitypub.js
- An ActivityPub implementation with Mastodon extensions support
- In order to interoperate with Mastodon, we need to implement HTTP Signatures. More info at: https://docs.joinmastodon.org/spec/security/
- Implementation in activitypub-express
- Based on node-http-signature - probably a good idea for us to use as well
- Private / Public keypairs are generated with the Node.JS crypto library.
- Notes on approach:
- Need to create a new public / private keypair and store in the db on account creation (or one-time during migration)
- As subscribe requests occur or lookups to other servers, the Actor object needs to be stored into the database
- On outbound requests from the the BBS that involve an actor, the private key is used to sign the requests
- On incoming requests that involve a remote actor, the public key stored for the actor is used to verify the signature
- With increased usage of HTTP with ActivityPub/Mastodon support, we should look at additional security testing as well. See: Free for Open-Source App Security Tools for some tools that are free for Open Source projects.
These certificates are used for server-to-server only, not e.g. message encryption; mostly non-issue: https://github.com/mastodon/mastodon/discussions/18669
- ActivityPub
- https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/
- https://www.justingarrison.com/blog/2022-12-06-mastodon-files-instance/
- https://github.com/jakelazaroff/dumbo
- https://macwright.com/2022/12/09/activitypub.html
- https://github.com/jwilk/zygolophodon
- https://github.com/dariusk/express-activitypub
- https://www.npmjs.com/package/activitypub-express / https://github.com/immers-space/activitypub-express
- Build our own (maybe using https://github.com/jakelazaroff/dumbo as a guide)
- Advantages
- No rework required, extending what we already have
- Can build it up a little at a time
- Disadvantages
- We are totally on the hook for interoperability
- Maybe more work overall when some of it has already been done for us
- Advantages
- Use existing activitypub-express module - https://github.com/immers-space/activitypub-express
- Advantages
- Very complete
- Popular
- Interchangeable storage (that we would have to swap out)
- Active (last update Nov 11)
- Disadvantages
- The completeness might lead to additional time to understand the full codebase
- Although storage is interchangeable, it is centered around ActivityPub, decent amount of work there to interface
- Advantages