This library provides a simple interface to work with the ActivityPub protocol in Ruby applications.
- Create and manage ActivityPub Objects.
- Send and receive Activities using Outbox and Inbox functionality.
- Signature verification for secured interactions.
- Simple Sinatra example to demonstrate usage.
For usage guides on RubyOnRails please check theguides folder.
gem install activitypub
Or add it to your Gemfile:
gem 'activitypub'
Then run bundle install
.
activity = ActivityPub::Object.new(type: "Note", content: "Hello ActivityPub!")
outbox = ActivityPub::Outbox.new("https://recipient.com/actors/2/inbox")
outbox.send(activity)
inbox = ActivityPub::Inbox.new
received_activity = inbox.receive(request_body)
signature = ActivityPub::Signature.new
if signature.verify(received_activity)
puts "Signature is valid!"
else
puts "Signature is invalid!"
end
A simple Sinatra app is included to demonstrate the library's functionality. To run it:
- Navigate to the
example
directory. - Run
bundle install
. - Run the app with
ruby app.rb
.
Visit http://localhost:4567
to access the example interface.
Contributions are welcome! Please submit a pull request or open an issue to discuss any changes or features.
This library is released under the MIT License. See LICENSE
for details.
To test the Sinatra app that we just set up, you'll need to interact with its endpoints, specifically sending and receiving activities to and from the outbox and inbox respectively.
Let's first ensure that the Sinatra app is running:
-
Run the Sinatra application:
bundle exec ruby app.rb
-
Visit
http://localhost:4567/
in your browser to confirm that the app is running.
Note: As this example is highly simplified, it doesn't handle potential errors or specific responses you'd expect from a fully-fledged ActivityPub service. Ensure that any production implementation follows the ActivityPub specification closely and manages potential risks.