Skip to content

Instantly share code, notes, and snippets.

@burningtree
Last active September 11, 2024 23:20
Show Gist options
  • Select an option

  • Save burningtree/70b4818c1535b196fbac7ba7d9bcb670 to your computer and use it in GitHub Desktop.

Select an option

Save burningtree/70b4818c1535b196fbac7ba7d9bcb670 to your computer and use it in GitHub Desktop.

0005? Network Abstraction Proposal for AT Protocol

Author: @tree.fail

Warning

This is the Draft, WiP - Work in progress

Introduction

Currently, PDS (Personal Data Server) and all its repositories (or accounts) is hard-fixed to a single "Network" (which is bundle of AppView, Relay & Moderation service). This proposal is to enable the use of many different separate "Networks", which will be configured on the individual repository (account) level.

These modifications will allow to use the current Bluesky apps (mobile, web, etc.) and lexicons alternatively with other microblogging providers (or protocols). Closed communities can be created, with their own moderation and independent of the rules and conditions of the Bluesky PBC.

Types of Network

  • native - default AT Protocol interface through AppView, Relay and Moderation Service
  • custom - non-native network, for example bridged Nostr or Mastodon (ActivityPub) client

New lexicons

com.atproto.repo.networks (record type)

{
  "lexicon": 1,
  "id": "com.atproto.repo.networks",
  "defs": {
    "main": {
      "type": "record",
      "description": "A declaration of a connected AT Protocol networks.",
      "key": "literal:self",
      "record": {
        "type": "array",
        "items": {
          "name": { "type": "string", "maxLength": 64 },
          "type": { "type": "string", "enum": [ "native", "custom" ] },
          "endpoints": {
            "type": "object",
            "properties": {
              "appview": { "type": "string", "format": "uri" },
              "appview:did": { "type": "string", "format": "did" },
              "relay": { "type": "string", "format": "uri" },
              "relay:did": { "type": "string", "format": "did" },
              "moderation": { "type": "string", "format": "uri" },
              "moderation:did": { "type": "string", "format": "did" }
            }
          },
          "default": { "type": "boolean" },
          "createdAt": { "type": "string", "format": "datetime" }
        }
      }
    }
  }
}

Example:

[
  {
    "name": "Bluesky",
    "type": "native",
    "endpoints": {
      "appview": "https://api.bsky.app",
      "appview:did": "did:web:api.bsky.app",
      "relay": "https://bsky.network",
      "moderation": "https://mod.bsky.app",
      "moderation:did": "did:plc:ar7c4by46qjdydhdevvrndac",
    },
    "default": true,
    "createdAt": "2024-09-11T21:26:09.448Z"
  },
  {
    "name": "My Community Server",
    "type": "native",
    "endpoints": {
      "appview": "https://my-bluesky-instance.com",
      "relay": "https://my-bluesky-instance.com",
      "moderation": "https://my-bluesky-instance.com"
    },
    "createdAt": "2024-09-11T21:26:09.448Z"
  },
  {
    "name": "Custom network",
    "type": "custom",
    "createdAt": "2024-09-11T21:26:09.448Z"
  }
]

Implementation in PDS

Modifications within the PDS are crucial. Here we need to get rid of the hard-fixed "Network" settings within the configuration, and use the dynamic settings based on the each repository (record in com.atproto.repo.networks collection).

Fixed Bluesky AppView in PDS configuration (current situation):

PDS_BSKY_APP_VIEW_URL="https://api.bsky.app"
PDS_BSKY_APP_VIEW_DID="did:web:api.bsky.app"
PDS_REPORT_SERVICE_URL="https://mod.bsky.app"
PDS_REPORT_SERVICE_DID="did:plc:ar7c4by46qjdydhdevvrndac"
PDS_CRAWLERS="https://bsky.network"

https://github.com/bluesky-social/pds/blob/main/installer.sh#L54-L58

Modifications of endpoints

Endpoints, where we need to add new optional query parameter network and pipethrough to AppView of this network:

  • app.bsky.actor.getProfile
  • app.bsky.actor.getProfiles
  • app.bsky.feed.getActorLikes
  • app.bsky.feed.getAuthorFeed
  • app.bsky.feed.getFeed
  • app.bsky.feed.getPostThread
  • app.bsky.feed.getTimeline
  • app.bsky.notification.registerPush

Implementation in clients (web & mobile)

Within clients, the implementation is very simple and there is no breaking changes.

New page: Networks settings

This page represents self record item in the com.atproto.repo.networks collection (the lexicon and example JSON described above).

There may also be an "Discover New Networks" section as suggestions for users (similar to "Discover New Feeds").

Dialog modification: "New post"

Within the "New post" dialog, we need to add a choice of the network that the post should be part of. For maximum clarity, this could be part of a post button that instead of "Post" can say "Post to Bluesky" or "Post to My Community Server".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment