Skip to content

Instantly share code, notes, and snippets.

@capjamesg
Created September 21, 2023 17:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capjamesg/559395b17b62d97a74e3272b887175e5 to your computer and use it in GitHub Desktop.
Save capjamesg/559395b17b62d97a74e3272b887175e5 to your computer and use it in GitHub Desktop.

Screenshot of IndieChat

IndieChat

IndieChat is a decentralized messaging client that uses WebSub, TicketAuth, and IndieAuth. Messages are exchanged over HTTPS.

Getting Started

First, clone the project repository and install the required dependencies:

git clone https://github.com/capjamesg/indiechat
cd indiechat
pip install -r requirements.txt

Create a file called config.py and add the following values:

ME="https://example.com" # your domain name
WEBSUB_HUB="https://switchboard.p3k.io/" # the WebSub hub you use on your personal website
CALLBACK_URL="https://example.com/listener" # the callback URL for IndieChat

Then, run the application:

python app.py

How it Works

Sending a Message

  1. You sign in to IndieChat with your domain name.
  2. You subscribe to a private feed to which someone has given you access via TicketAuth.
  3. Every time you send a message, it is saved in a database and published on your message feed with a user.
  4. A notification is sent to the recipient's WebSub hub to say your message feed has been updated.

Receiving a Message

  1. When a feed to which you are subscribed is updated, you receive a notification from the WebSub hub.
  2. The feed URL is retrieved using the Link header from the notification.
  3. The token redeemed via TicketAuth is used to retrieve the mf2+html representation of the sender's feed.
  4. The feed is retrieved and the latest message is / messages are saved in the recipient's database.
  5. You can read the message(s) in IndieChat.

The Flow

  1. James decides to send a private message to Angelo
  2. James creates a ticket in his web interface and sends it to Angelo’s ticket endpoint
  3. Angelo’s ticket endpoint redeems the ticket for a token
  4. Angelo sends the token in all requests to get the resource for which the token was issued (feed of posts / chats)
  5. Now Angelo can read my content
  6. Angelo sends a POST request to my WebSub server to subscribe to content
  7. Angelo has an endpoint on his chat server that can receive messages from the WebSub feed
  8. Angelo listens for WebSub messages
  9. James sends a message
  10. James' chat client sends a POST request to James' WebSub server. The WebSub server will inform Angelo a new message is available.
  11. Angelo's chat client retrieves and parses the feed.
  12. Messages whose u-uid have not been found in the feed are added to a messages table that stores the chat

Standards Used

  • WebSub: For real-time notifications of feed updates
  • TicketAuth: For granting access to private feeds
  • IndieAuth: For authentication
  • microformats2: For marking up feeds with messages (h-feed and h-entry)

License

This project is licensed under an MIT license.

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