Skip to main content

Core functionality of bovine needed to build fediverse applications

Project description

Bovine

Bovine is a basic utility library for the Fediverse. It can be used both to build ActivityPub Client applications and ActivityPub Servers. In addition to ActivityPub support, it also provides utilities to deal with webfinger, nodeinfo, and HTTP Signatures.

The bovine library can just be installed via pip

pip install bovine

Documentation including tutorials is available at ReadTheDocs.

A quick Fediverse server with docker compose

Using the bovine docker image, the following docker compose file, and a service such as ngrok allowing one to expose a local port to the internet, one can create a python shell that allows one to use bovine to interact with the Fediverse

services:
  bovine:
    image: helgekr/bovine
    environment:
    - "BOVINE_TEST_HOSTNAME=${NGROK_HOSTNAME}"
    - "BOVINE_TEST_PROTOCOL=https"
    volumes: ["bovine_shared:/bovine"]
    ports: ["5000:80"]
    command: python -mbovine.testing serve --port 80 --reload --save_config=/bovine/config.toml
  repl:
    image: helgekr/bovine
    command: python -mbovine.testing shell --load_config=/bovine/config.toml
    depends_on: [bovine]
    profiles: ["repl"]
    volumes: ["bovine_shared:/bovine"]
volumes:
  bovine_shared:

When using ngrok with ngrok http 5000, you can directly run the above file via

NGROK_HOSTNAME=$(curl --silent http://127.0.0.1:4040/api/tunnels  | jq '.tunnels[0].public_url' | sed "s|https://||g" | sed 's|"||g') docker compose run repl

otherwise you will have to set the variable BOVINE_TEST_HOSTNAME to the appropriate host.

By using

>>> helge = await webfinger("acct:helge@mymath.rocks")
>>> inbox = (await actor.get(helge))["inbox"]
>>> helge
"https://mymath.rocks/endpoints/SYn3cl_N4HAPfPHgo2x37XunLEmhV9LnxCggcYwyec0"

one can resolve an acct uri to the actor's uri and then record its inbox. Then one can create a message via

>>> mention = {"href": helge, "type": "Mention"}
>>> note = object_factory.note(to={helge}, content="Writing a README thus talking to myself", tag=[mention]).as_public().build()
>>> note
{
    "@context": "https://www.w3.org/ns/activitystreams",
    "type": "Note",
    "attributedTo": "https://8fc-2003-c1-c73c-a901-b426-f511-88e5-77e3.ngrok-free.app/buttercup",
    "to": ["https://mymath.rocks/endpoints/SYn3cl_N4HAPfPHgo2x37XunLEmhV9LnxCggcYwyec0", "https://www.w3.org/ns/activitystreams#Public"],
    "id": "https://8fc-2003-c1-c73c-a901-b426-f511-88e5-77e3.ngrok-free.app/HFL5hpzi",
    "published": "2024-11-24T12:30:54Z",
    "content": "Writing a README thus talking to myself",
}

By then running

>>> await actor.post(inbox, activity_factory.create(note).build())
<ClientResponse(https://mymath.rocks/endpoints/SYONtD8yAKPapRuifwDJ8P0OhcuB7ntjkHdxh_OkrWQ) [202 None]>

one can post the message. It should then appear in your Fedi client

Screenshot of the message from buttercup

One can view messages received in the inbox via

docker compose logs -f

Further information on the testing server can be found in Using bovine with the fediverse-pasture in the documentation.

Feedback

Issues about bovine should be filed as an issue.

Running BDD Tests

bovine uses the fediverse-features to provide BDD tests. These can be run by first downloading the feature files via

poetry run python -mfediverse_features

and then running behave

poetry run behave

Contributing

If you want to contribute, you can start by working on issues labeled Good first issue. The tech stack is currently based on asynchronous python, using the following components:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bovine-0.5.17.tar.gz (410.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bovine-0.5.17-py3-none-any.whl (252.1 kB view details)

Uploaded Python 3

File details

Details for the file bovine-0.5.17.tar.gz.

File metadata

  • Download URL: bovine-0.5.17.tar.gz
  • Upload date:
  • Size: 410.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/6.1.0-30-amd64

File hashes

Hashes for bovine-0.5.17.tar.gz
Algorithm Hash digest
SHA256 be2aefdf64ce5360dccf8c1f7c1bf97cc16d4cf1742f76bb91d0c131ced568db
MD5 2f46aff0d0e14ecf1b5dec743e4254ef
BLAKE2b-256 630c9dba88022bb19c0aae335547a9f412c9ba603180d5ec90da7d7bf0995bf4

See more details on using hashes here.

File details

Details for the file bovine-0.5.17-py3-none-any.whl.

File metadata

  • Download URL: bovine-0.5.17-py3-none-any.whl
  • Upload date:
  • Size: 252.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/6.1.0-30-amd64

File hashes

Hashes for bovine-0.5.17-py3-none-any.whl
Algorithm Hash digest
SHA256 ffa5cd5eaee663c051ad1c2cfaf51e698a5baafa7dcd31aed1a7f795ce50199d
MD5 f74b447eab768eb865d7ff8f70bf4569
BLAKE2b-256 c0bb1c2be85959396010ac590c4bd87def071a1a9f9bfdb1b1948552cdd8b715

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page