Logo

dev-resources.site

for different kinds of informations.

Hidden Gems of the Fedify CLI: Tips & Tricks You Might Have Missed

Published at
11/22/2024
Categories
fediverse
activitypub
cli
fedify
Author
hongminhee
Categories
4 categories in total
fediverse
open
activitypub
open
cli
open
fedify
open
Author
10 person written this
hongminhee
open
Hidden Gems of the Fedify CLI: Tips & Tricks You Might Have Missed

While Fedify is primarily known as a framework for building ActivityPub servers, it also comes with a powerful command-line tool called fedify for debugging and testing ActivityPub implementations. Whether you're using the Fedify framework or not, this CLI tool can be invaluable for ActivityPub development.

Installation

Before diving into the features, you'll need to install the fedify command. You have several options:

Using npm (Node.js):

npm install -g @fedify/cli
Enter fullscreen mode Exit fullscreen mode

Using Bun:

bun install -g @fedify/cli
Enter fullscreen mode Exit fullscreen mode

Using Deno:

deno install -A --unstable-fs --unstable-kv --unstable-temporal -n fedify jsr:@fedify/cli
Enter fullscreen mode Exit fullscreen mode

You can also download pre-built executables from the releases page.

For more detailed installation instructions and requirements, see the official documentation.

Smart Object Lookup

The fedify lookup command is smarter than it looks—it can handle various formats of the same identifier and provides multiple output formats to suit your needs:

# Three equivalent ways to look up the same actor:
fedify lookup @[email protected]
fedify lookup [email protected]
fedify lookup acct:[email protected]

# View the raw JSON response:
fedify lookup --raw @[email protected]

# Get a compact JSON-LD representation:
fedify lookup --compact @[email protected]

# See the fully expanded JSON-LD:
fedify lookup --expanded @[email protected]
Enter fullscreen mode Exit fullscreen mode

Some ActivityPub servers require authorized fetch (also known as “secure mode”), which means all HTTP GET requests must be signed—even for public content. The -a/--authorized-fetch flag helps with this:

fedify lookup --authorized-fetch @[email protected]
Enter fullscreen mode Exit fullscreen mode

This spins up a temporary ActivityPub server and signs the request with its key. This is particularly useful when:

  • Accessing servers that require signatures for all requests (like certain Mastodon instances in secure mode)
  • Fetching non-public content like followers-only posts (assuming you have permission)
  • Testing how your server behaves with signed requests

Interactive Inbox Testing

The fedify inbox command not only provides a quick way to test federation but also comes with a powerful web interface for inspecting incoming ActivityPub activities. When you receive an activity, it shows you everything about the request, including:

  • HTTP method and headers
  • Request body (in multiple formats)
  • Response details
  • Server logs

The fedify inbox web interface showing detailed request information

You can see the raw HTTP headers that other servers send, which is invaluable when debugging signature verification issues or content negotiation problems. The interface includes tabs for viewing the activity in different formats:

  • Raw HTTP request/response
  • Compact Activity (normalized JSON-LD)
  • Expanded Activity (fully expanded JSON-LD)
  • Raw Activity (as received)
  • Server logs

The command is highly configurable—you can control which follow requests to accept:

# Only accept follows from specific actors
fedify inbox -a @[email protected] -a @[email protected]

# Accept all follow requests
fedify inbox -a "*"
Enter fullscreen mode Exit fullscreen mode

Rich NodeInfo Visualization

The fedify node command helps you understand how other instances are configured by visualizing their NodeInfo data in a user-friendly format:

# Show standard NodeInfo data with server icon
fedify node mastodon.social

# Include extra metadata that instances expose
fedify node -m mastodon.social

# Try to parse non-compliant NodeInfo responses
fedify node --best-effort problematic-instance.social

# Skip favicon fetching for faster results
fedify node --no-favicon mastodon.social
Enter fullscreen mode Exit fullscreen mode

Flexible Local Development

For testing your ActivityPub implementation locally, the fedify tunnel command lets you temporarily expose your local server to the internet. You can choose from multiple tunneling services if the default one isn't working well:

# Use the default service
fedify tunnel 3000

# Use an alternative service
fedify tunnel --service serveo.net 3000
Enter fullscreen mode Exit fullscreen mode

Shell Integration

Save yourself some typing by enabling shell completions—available for bash, fish, and zsh:

# For bash
source <(fedify completions bash)

# For fish
source (fedify completions fish | psub)

# For zsh
source <(fedify completions zsh)
Enter fullscreen mode Exit fullscreen mode

Coming in Fedify 1.3.0: Custom User-Agent Support

The upcoming Fedify 1.3.0 release will include a feature to set custom User-Agent headers, which is helpful for tracking your requests in server logs:

# Set a custom User-Agent for lookup
fedify lookup --user-agent "MyApp/1.0" @[email protected]

# Set a custom User-Agent for NodeInfo requests
fedify node --user-agent "MyApp/1.0" mastodon.social
Enter fullscreen mode Exit fullscreen mode

These features might not be immediately obvious when you first start using the Fedify CLI, but they can be incredibly helpful when debugging federation issues or testing your ActivityPub implementation.

activitypub Article's
30 articles in total
Favicon
Fedify 1.3.0: OpenTelemetry support & enhanced message queue
Favicon
Hidden Gems of the Fedify CLI: Tips & Tricks You Might Have Missed
Favicon
Discover the Best Programming Codes – No Signup or Fees Required!
Favicon
Handling Errors and Job Lifecycles in Rails 7.1: Master ActiveJob with `retry_on`, `discard_on`, and `after_discard`
Favicon
AT Protocol services
Favicon
Fedify, an ActivityPub server framework, reached v1.0.0
Favicon
Discover Nostr: The New Way to Stay Anonymous Online
Favicon
Intrigued by the Fediverse — Traverse our Accounts to Map your Journey
Favicon
Bringing your site to the Fediverse: A practical guide for static sites - Part 1
Favicon
How to Maximise the ROI from Team Building Activities in Sydney
Favicon
How to Overcome Common Challenges When Implementing Team Activities in Sydney
Favicon
[Wild League] why ActivityPub?
Favicon
My Blog is now Fediverse ready! What about you?
Favicon
Top Airdrops and Crypto Activities November List
Favicon
Bringing together Mastodon and WordPress
Favicon
Bridging Communities: An Overview of the WordPress ActivityPub Plugin
Favicon
Community Spotlight: Casey Kolderup, creator of Postmarks, has joined the W3C’s Social Web Community Group!
Favicon
ActivityPub, Fediverse and the Future of social networks
Favicon
#DEVDiscuss: Is Threads Truly Decentralized?
Favicon
Understanding the Power of the Decentralized Web: A Deep Dive into ActivityPub Protocol
Favicon
#DEVDiscuss: can the AT Protocol and the Fediverse coexist?
Favicon
You say you want a revolution: help the free, fair, and friendly Fediverse destroy Big Social
Favicon
Supporting Fediverse developer communities
Favicon
Mastodon instance with 6 files
Favicon
A 🦣 opportunity for developers
Favicon
The AT Protocol
Favicon
W3c Activitypub Protocol
Favicon
Taking a look at Mastodon
Favicon
How (and Why) to Switch from Twitter to Mastodon
Favicon
Inventur

Featured ones: