bovine

The config object should have either the form

config = {
        "host": "domain",
        "private_key": "z3u2Yxcowsarethebestcowsarethebestcowsarethebest"
}

for Moo-Auth-1 or

config = {
        "account_url": "https://mymath.rocks/endpoints/SYn3cl_N4HAPfPHgo2x37XunLEmhV9LnxCggcYwyec0",
        "public_key_url": "https://mymath.rocks/endpoints/SYn3cl_N4HAPfPHgo2x37XunLEmhV9LnxCggcYwyec0#serverKey"
        "private_key": "-----BEGIN PRIVATE KEY-----\n....==\n-----END PRIVATE KEY-----\n"
}

for authorization using HTTP-Signatures. HTTP-Signatures are the form used for communication between ActivityPub Servers at the time of writing.

class bovine.BovineActor(**config)[source]

Defines the Bovine version of an ActivityPub Actor. This class is meant to be used when implementing an ActivityPub Server in order to handle the HTTP requests to another server.

Currently most of these interactions use HTTP Signatures.

Usage is either:

async with BovineActor(**config) as actor:
    await do_something(actor)

or

actor = await BovineActor(**config)
await actor.init()
await do_something(actor)
Parameters:
  • domain – Specifies the domain the actor is on, used for Moo-Auth-1

  • host – Alias for domain

  • actor_id – URI of the actor, used for Bearer Auth and HTTP Signatures

  • account_url – Alias for actor_id

  • secret – The private key material for Moo-Auth-1 and HTTP Signatures

  • access_token – The access token for Bearer auth

async get(target: str, fail_silently: bool = False)[source]

Retrieve target with a get. An exception is raised if the request fails

Parameters:
  • target – The URL of the object to retrieve

  • fail_silently – do not raise an exception if the request fails

async get_ordered_collection(url: str, max_items: int | None = None)[source]

Retrieve target ordered collection

Parameters:
  • url – url of the ordered collection

  • max_items – maximal number of items to retrieve, use None for all

async init(session=None)[source]

Manually initializes the BovineActor for cases when not used within async with

Parameters:

session – can be used to specify an existing aiohttp.ClientSession. Otherwise a new one is created.

async post(target: str, data: dict)[source]

Send a signed post with data to target

class bovine.BovineClient(**kwargs)[source]

BovineClient is meant to serve as the basis of building ActivityPub Clients. It defines methods for interacting with the endpoints defined by the corresponding ActivityPub Actor: inbox, outbox, and proxyUrl.

Usage is either:

async with BovineClient(**config) as actor:
    await do_something(actor)

or

actor = await BovineClient(**config)
await actor.init()
await do_something(actor)

I still call the variable actor as it represents the ActivityPub Actor through a client.

Parameters:
  • domain – Specifies the domain the actor is on, used for Moo-Auth-1

  • host – Alias for domain

  • actor_id – URI of the actor, used for Bearer Auth and HTTP Signatures

  • account_url – Alias for actor_id

  • secret – The private key material for Moo-Auth-1 and HTTP Signatures

  • access_token – The access token for Bearer auth

property activity_factory

Returns an ActivityFactory for objects corresponding to the client’s actor

collection_helper(collection, resolve=False)[source]

Returns a CollectionHelper for the collection provided. Usage:

async for x in client.collection_helper(uri_of_collection):
    await do_something(x)
Parameters:
  • collection – Uri of the collection to irater over

  • resolve – If true objects are automatically fetched

async event_source()[source]

Returns an EventSource corresponding to the actor’s

The syntax for this will probably change

property followers: str

The id of the follows collection

static from_file(config_file: str)[source]

Initializes the BovineClient from a toml config file

property host

The host the actor is on

inbox(resolve=True)[source]

Provides a CollectionHelper for the Actors inbox

async init(session=None)[source]

Manually initializes the BovineClient for cases when not used within async with. Also loads the actor information.

Parameters:

session – can be used to specify an existing aiohttp.ClientSession. Otherwise a new one is created.

property object_factory

Returns an ObjectFactory for objects corresponding to the client’s actor

outbox(resolve=True)[source]

Provides a CollectionHelper for the Actors outbox

async proxy(target: str)[source]

Retrieve’s an element through the actors’ proxyUrl endpoint as specified in ActivityPub.

param target:

The URL of the object to retrieve

FIXME: Support for non-json stuff

async send_to_outbox(data: dict)[source]

sends data to outbox of actor

Parameters:

data – The data to send as python dict

Returns:

The aiohttp.ClientResponse object. This means return_value.headers[“location”] will contain the id of the posted activity.

async simplify_collection(collection)[source]

Returns a Collection containing all items from the passed collection or collection id