Skip to content

Conversation

@sij411
Copy link
Contributor

@sij411 sij411 commented Oct 9, 2025

Summary

This PR introduces the new @fedify/relay package, providing a comprehensive implementation of ActivityPub relay functionality for the Fedify ecosystem. This implementation enables the
creation and management of relay servers that can forward activities between federated instances.

Related Issue

Changes

  • Created new @fedify/relay package in packages/relay/
  • Implemented Relay interface defining the common contract for relay implementations
  • Added MastodonRelay class implementing Mastodon-compatible relay protocol:
    • Actor dispatcher for relay Application actor at /users/relay
    • Key pair management (RSA and Ed25519) with KV storage
    • Followers collection dispatcher
    • Inbox listeners for Follow, Undo, Create, Update, Move, and Delete activities
    • Subscription approval/rejection workflow with Accept/Reject responses
    • Activity forwarding to all followers
  • Added LitePubRelay class skeleton for future LitePub relay protocol support
  • Implemented SubscriptionRequestHandler for custom subscription approval logic
  • Created comprehensive test suite with 505 lines covering:
    • Relay initialization and configuration
    • Actor fetching and properties
    • Followers collection management
    • Follow/Undo activity handling
    • Subscription approval/rejection workflows
    • Multiple follower scenarios
  • Added package README and module exports in packages/relay/src/mod.ts

Benefits

  • Developer-friendly API: Simple, chainable interface for setting up relay servers
  • Protocol compliance: Fully compatible with Mastodon's relay protocol for immediate interoperability with existing fediverse infrastructure
  • Flexible subscription control: Custom handlers allow server administrators to approve/reject subscription requests based on their policies
  • Type-safe implementation: Full TypeScript support with proper ActivityPub vocabulary types
  • Comprehensive testing: Extensive test coverage ensures reliability and correctness
  • Foundation for expansion: Architecture supports future addition of LitePub relay protocol
  • Seamless integration: Leverages existing Fedify infrastructure (Federation, KvStore, signatures, etc.)

Checklist

  • Did you add a changelog entry to the CHANGES.md? [ ]
  • Did you write some relevant docs about this change (if it's a new feature)? [ ]
  • Did you write a regression test to reproduce the bug (if it's a bug fix)? [ ]
  • Did you write some tests for this change (if it's a new feature)? [x]
  • Did you run deno task test-all on your machine? [x]

Additional Notes

This is the initial implementation focusing on the Mastodon relay protocol. The LitePubRelay class is included as a skeleton for future development. The implementation follows Fedify's
existing patterns for federation handling, actor dispatchers, and inbox processing.

Key design decisions:

  • Uses a single "relay" actor (Application type) to represent the relay server
  • Stores followers using their Follow activity IDs as keys in KV storage
  • Supports custom subscription handlers for flexible access control
  • Automatically forwards Create, Update, Move, and Delete activities to all followers
  • Generates and persists both RSA and Ed25519 key pairs for HTTP signatures

@issues-auto-labeler issues-auto-labeler bot added activitypub/interop Interoperability issues activitypub/mastodon Mastodon compatibility component/federation Federation object related component/relay labels Oct 9, 2025
@ThisIsMissEm
Copy link
Contributor

What's changed since the last attempt to land this in hollo or fedify?

@ThisIsMissEm
Copy link
Contributor

Also, is there an FEP describing this protocol?

@sij411
Copy link
Contributor Author

sij411 commented Oct 9, 2025

Also, is there an FEP describing this protocol?

https://w3id.org/fep/ae0c

@sij411
Copy link
Contributor Author

sij411 commented Oct 9, 2025

What's changed since the last attempt to land this in hollo or fedify?

This is the first attempt as far as I know.

@ThisIsMissEm
Copy link
Contributor

What's changed since the last attempt to land this in hollo or fedify?

This is the first attempt as far as I know.

Ah, I confused this with Hollo: fedify-dev/hollo#109

@sij411 sij411 marked this pull request as ready for review October 10, 2025 01:02
Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, there doesn't seem to be an issue with the code, but it looks like we need to verify if it actually works. We'll need to set up a real Mastodon server and check if it's functional. I'll help you with that.

@dahlia dahlia added this to the Fedify 2.0 milestone Oct 13, 2025
@dahlia dahlia linked an issue Oct 13, 2025 that may be closed by this pull request
dahlia added a commit that referenced this pull request Oct 13, 2025
- Add comprehensive changelog entry for @fedify/relay package
- Enhance README.md with detailed documentation including:

  - Introduction to ActivityPub relays and their purpose
  - Explanation of Mastodon-style and LitePub-style protocols
  - Installation instructions for multiple package managers
  - Usage examples and code samples
  - Architecture overview and workflow description
  - Storage requirements and KvStore integration
  - Complete API reference for MastodonRelay, RelayOptions,
    and SubscriptionRequestHandler
  - Integration examples with web frameworks

#459

Co-Authored-By: Claude <[email protected]>
dahlia added a commit that referenced this pull request Oct 13, 2025
Implemet Mastodon Relay protocol for `@fedify/relay`
@dahlia dahlia merged commit 367cb68 into fedify-dev:next Oct 13, 2025
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

activitypub/interop Interoperability issues activitypub/mastodon Mastodon compatibility component/federation Federation object related component/relay

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The @fedify/relay package for ActivityPub relays

3 participants